Skip to content
Snippets Groups Projects
Commit 277afc9a authored by Maxime Graulich's avatar Maxime Graulich
Browse files

Android: adapt font size according to screen density

parent b5ffe457
No related branches found
No related tags found
No related merge requests found
......@@ -14,7 +14,7 @@ public class Gmsh implements Parcelable {
System.loadLibrary("GetDP");
System.loadLibrary("Onelab");
}
private native long init(); // Init Gmsh
private native long init(float fontFactor); // Init Gmsh
private native void loadFile(long ptr, String name); // load a file(OpenProjet)
private native void initView(long ptr, int w, int h); // Called each time the GLView change
private native void drawView(long ptr); // Called each time the GLView request a render
......@@ -44,8 +44,8 @@ public class Gmsh implements Parcelable {
private long ptr;
private Handler handler;
public Gmsh(Handler handler) {
ptr = this.init();
public Gmsh(Handler handler, float fontFactor) {
ptr = this.init(fontFactor);
this.handler = handler;
}
......
......@@ -50,7 +50,7 @@ public class MainActivity extends Activity{
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
setContentView(R.layout.main_activity_layout);
_gmsh = new Gmsh(mainHandler);
_gmsh = new Gmsh(mainHandler, getResources().getDisplayMetrics().density);
_notify = false;
ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
......
......@@ -126,13 +126,13 @@ extern "C" {
return JNI_VERSION_1_6;
}
JNIEXPORT jlong JNICALL Java_org_geuz_onelab_Gmsh_init
(JNIEnv *env, jobject obj)
(JNIEnv *env, jobject obj, jfloat fontFactor)
{
if(gCallbackObject != NULL) env->DeleteGlobalRef(gCallbackObject);
gCallbackObject = env->NewGlobalRef(obj);
gJavaVM->GetEnv((void**)&env, JNI_VERSION_1_6);
Msg::SetCallback(new MobileMessage());
return reinterpret_cast<jlong>(new drawContext());
return reinterpret_cast<jlong>(new drawContext(fontFactor));
}
JNIEXPORT void JNICALL Java_org_geuz_onelab_Gmsh_loadFile
(JNIEnv *env, jobject obj, jlong jptr, jstring jname)
......
......@@ -12,10 +12,10 @@ extern "C" {
/*
* Class: org_geuz_onelab_Gmsh
* Method: init
* Signature: (Ljava/lang/String;)J
* Signature: (F)J
*/
JNIEXPORT jlong JNICALL Java_org_geuz_onelab_Gmsh_init
(JNIEnv *, jobject);
(JNIEnv *, jobject, jfloat);
/*
* Class: org_geuz_onelab_Gmsh
......
......@@ -53,7 +53,7 @@
static bool locked = false;
static bool onelabStop = false;
drawContext::drawContext(bool isRetina)
drawContext::drawContext(float fontFactor)
{
GmshInitialize();
GmshSetOption("General", "Terminal", 1.0);
......@@ -66,7 +66,7 @@ drawContext::drawContext(bool isRetina)
_fillMesh = false;
_gradiant = true;
_fontFactor = isRetina ? 1.5 : 1;
_fontFactor = fontFactor;
}
static void checkGlError(const char* op)
......
......@@ -44,7 +44,7 @@ private:
void drawPView(PView *p);
void drawVectorArray(PViewOptions *opt, VertexArray *va);
public:
drawContext(bool isRetina=false);
drawContext(float fontFactor=1.);
~drawContext(){}
void load(std::string filename);
void eventHandler(int event, float x=0, float y=0);
......
......@@ -54,7 +54,7 @@
//[self release];
return nil;
}
mContext = new drawContext(eaglLayer.contentsScale==2);
mContext = new drawContext((eaglLayer.contentsScale==2)? 1.5:1);
}
rendering = NO;
return self;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment