WrapperWidget: overwrite measured size if layout size is fixed

This commit is contained in:
Julian Winkler
2023-11-10 23:36:57 +01:00
parent e11d9ec6b6
commit c0804c3329
3 changed files with 16 additions and 0 deletions

View File

@@ -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);
if (ATL_IS_ANDROID_LAYOUT(layout_manager))
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) {

View File

@@ -58,6 +58,11 @@ void wrapper_widget_measure(GtkWidget *widget, GtkOrientation orientation, int f
{
WrapperWidget *wrapper = WRAPPER_WIDGET(widget);
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)
@@ -161,3 +166,9 @@ void wrapper_widget_set_jobject(WrapperWidget *wrapper, JNIEnv *env, jobject job
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;
}

View File

@@ -17,6 +17,8 @@ struct _WrapperWidget
jmethodID draw_method;
jmethodID measure_method;
jmethodID computeScroll_method;
int layout_width;
int layout_height;
};
struct _WrapperWidgetClass
@@ -28,6 +30,7 @@ GtkWidget * wrapper_widget_new(void);
void wrapper_widget_set_child(WrapperWidget *parent, GtkWidget *child);
void wrapper_widget_set_jobject(WrapperWidget *wrapper, JNIEnv *env, jobject jobj);
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);