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
WrapperWidget: overwrite measured size if layout size is fixed
This commit is contained in:
@@ -247,6 +247,8 @@ JNIEXPORT void JNICALL Java_android_view_View_native_1setLayoutParams(JNIEnv *en
|
|||||||
GtkLayoutManager *layout_manager = gtk_widget_get_layout_manager(WRAPPER_WIDGET(widget)->child);
|
GtkLayoutManager *layout_manager = gtk_widget_get_layout_manager(WRAPPER_WIDGET(widget)->child);
|
||||||
if (ATL_IS_ANDROID_LAYOUT(layout_manager))
|
if (ATL_IS_ANDROID_LAYOUT(layout_manager))
|
||||||
android_layout_set_params(ATL_ANDROID_LAYOUT(layout_manager), width, height);
|
android_layout_set_params(ATL_ANDROID_LAYOUT(layout_manager), width, height);
|
||||||
|
|
||||||
|
wrapper_widget_set_layout_params(WRAPPER_WIDGET(widget), width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_android_view_View_native_1setVisibility(JNIEnv *env, jobject this, jlong widget_ptr, jint visibility) {
|
JNIEXPORT void JNICALL Java_android_view_View_native_1setVisibility(JNIEnv *env, jobject this, jlong widget_ptr, jint visibility) {
|
||||||
|
|||||||
@@ -58,6 +58,11 @@ void wrapper_widget_measure(GtkWidget *widget, GtkOrientation orientation, int f
|
|||||||
{
|
{
|
||||||
WrapperWidget *wrapper = WRAPPER_WIDGET(widget);
|
WrapperWidget *wrapper = WRAPPER_WIDGET(widget);
|
||||||
gtk_widget_measure(wrapper->child, orientation, for_size, minimum, natural, minimum_baseline, natural_baseline);
|
gtk_widget_measure(wrapper->child, orientation, for_size, minimum, natural, minimum_baseline, natural_baseline);
|
||||||
|
if (orientation == GTK_ORIENTATION_HORIZONTAL && (wrapper->layout_width > 0)) {
|
||||||
|
*minimum = *natural = wrapper->layout_width;
|
||||||
|
} else if (orientation == GTK_ORIENTATION_VERTICAL && (wrapper->layout_height > 0)) {
|
||||||
|
*minimum = *natural = wrapper->layout_height;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wrapper_widget_allocate(GtkWidget *widget, int width, int height, int baseline)
|
void wrapper_widget_allocate(GtkWidget *widget, int width, int height, int baseline)
|
||||||
@@ -161,3 +166,9 @@ void wrapper_widget_set_jobject(WrapperWidget *wrapper, JNIEnv *env, jobject job
|
|||||||
wrapper->computeScroll_method = computeScroll_method;
|
wrapper->computeScroll_method = computeScroll_method;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wrapper_widget_set_layout_params(WrapperWidget *wrapper, int width, int height)
|
||||||
|
{
|
||||||
|
wrapper->layout_width = width;
|
||||||
|
wrapper->layout_height = height;
|
||||||
|
}
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ struct _WrapperWidget
|
|||||||
jmethodID draw_method;
|
jmethodID draw_method;
|
||||||
jmethodID measure_method;
|
jmethodID measure_method;
|
||||||
jmethodID computeScroll_method;
|
jmethodID computeScroll_method;
|
||||||
|
int layout_width;
|
||||||
|
int layout_height;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _WrapperWidgetClass
|
struct _WrapperWidgetClass
|
||||||
@@ -28,6 +30,7 @@ GtkWidget * wrapper_widget_new(void);
|
|||||||
void wrapper_widget_set_child(WrapperWidget *parent, GtkWidget *child);
|
void wrapper_widget_set_child(WrapperWidget *parent, GtkWidget *child);
|
||||||
void wrapper_widget_set_jobject(WrapperWidget *wrapper, JNIEnv *env, jobject jobj);
|
void wrapper_widget_set_jobject(WrapperWidget *wrapper, JNIEnv *env, jobject jobj);
|
||||||
void wrapper_widget_queue_draw(WrapperWidget *wrapper);
|
void wrapper_widget_queue_draw(WrapperWidget *wrapper);
|
||||||
|
void wrapper_widget_set_layout_params(WrapperWidget *wrapper, int width, int height);
|
||||||
|
|
||||||
void _setOnTouchListener(JNIEnv *env, jobject this, GtkWidget *widget, jobject on_touch_listener);
|
void _setOnTouchListener(JNIEnv *env, jobject this, GtkWidget *widget, jobject on_touch_listener);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user