You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
add support for ViewGroups with custom onLayout()
A custom GtkLayoutManager is set to these objects, which calls into the java handlers when measure or layout is requested. Androids onMeasure method is quite different from GTKs measure method, because Android already defines the final size during onMeasure. Therefore, we call onMeasure from GTKs allocate callback instead of the measure callback.
This commit is contained in:
@@ -146,7 +146,13 @@ static void on_mapped(GtkWidget* self, gpointer data)
|
||||
JNIEnv *env;
|
||||
(*wrapper->jvm)->GetEnv(wrapper->jvm, (void**)&env, JNI_VERSION_1_6);
|
||||
|
||||
(*env)->CallVoidMethod(env, wrapper->jobj, wrapper->measure_method, MEASURE_SPEC_EXACTLY, MEASURE_SPEC_EXACTLY);
|
||||
(*env)->CallVoidMethod(env, wrapper->jobj, wrapper->measure_method, MEASURE_SPEC_EXACTLY | gtk_widget_get_width(self), MEASURE_SPEC_EXACTLY | gtk_widget_get_height(self));
|
||||
int width = (*env)->CallIntMethod(env, wrapper->jobj, handle_cache.view.getMeasuredWidth);
|
||||
if (width > 0)
|
||||
g_object_set(G_OBJECT(self), "width-request", width, NULL);
|
||||
int height = (*env)->CallIntMethod(env, wrapper->jobj, handle_cache.view.getMeasuredHeight);
|
||||
if (height > 0)
|
||||
g_object_set(G_OBJECT(self), "height-request", height, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user