implement PopupWindow.update()

This commit is contained in:
Julian Winkler
2025-02-15 10:39:14 +01:00
parent 9f94f9d668
commit 4a7db70fbc
4 changed files with 26 additions and 3 deletions

View File

@@ -47,6 +47,14 @@ JNIEXPORT jboolean JNICALL Java_android_widget_PopupWindow_native_1isShowing
JNIEXPORT void JNICALL Java_android_widget_PopupWindow_native_1dismiss
(JNIEnv *, jobject, jlong);
/*
* Class: android_widget_PopupWindow
* Method: native_update
* Signature: (JJIIII)V
*/
JNIEXPORT void JNICALL Java_android_widget_PopupWindow_native_1update
(JNIEnv *, jobject, jlong, jlong, jint, jint, jint, jint);
/*
* Class: android_widget_PopupWindow
* Method: setOnDismissListener

View File

@@ -68,3 +68,13 @@ JNIEXPORT void JNICALL Java_android_widget_PopupWindow_native_1dismiss(JNIEnv *e
{
gtk_popover_popdown(GTK_POPOVER(_PTR(popover_ptr)));
}
JNIEXPORT void JNICALL Java_android_widget_PopupWindow_native_1update(JNIEnv *env, jobject this, jlong popover_ptr, jlong anchor_ptr, jint x, jint y, jint width, jint height)
{
GtkPopover *popover = GTK_POPOVER(_PTR(popover_ptr));
WrapperWidget *anchor = WRAPPER_WIDGET(gtk_widget_get_parent(GTK_WIDGET(_PTR(anchor_ptr))));
gtk_widget_set_size_request(GTK_WIDGET(popover), width, height);
gtk_widget_insert_before(GTK_WIDGET(popover), GTK_WIDGET(anchor), NULL);
gtk_popover_present(GTK_POPOVER(popover));
gtk_popover_popup(popover);
}

View File

@@ -669,9 +669,9 @@ public class ListPopupWindow {
mPopup.setOutsideTouchable(!mForceIgnoreOutsideTouch && !mDropDownAlwaysVisible);
// mPopup.update(getAnchorView(), mDropDownHorizontalOffset,
// mDropDownVerticalOffset, (widthSpec < 0)? -1 : widthSpec,
// (heightSpec < 0)? -1 : heightSpec);
mPopup.update(getAnchorView(), mDropDownHorizontalOffset,
mDropDownVerticalOffset, (widthSpec < 0)? -1 : widthSpec,
(heightSpec < 0)? -1 : heightSpec);
// mPopup.getContentView().restoreDefaultFocus();
} else {
final int widthSpec;

View File

@@ -45,6 +45,7 @@ public class PopupWindow {
protected native void native_showAsDropDown(long widget, long anchor, int xoff, int yoff, int gravity);
protected native boolean native_isShowing(long widget);
protected native void native_dismiss(long widget);
protected native void native_update(long widget, long anchor, int xoff, int yoff, int width, int height);
public void setBackgroundDrawable(Drawable background) {}
@@ -109,4 +110,8 @@ public class PopupWindow {
public void setTouchModal(boolean touchModal) {}
public void setElevation(float elevation) {}
public void update(View anchor, int xoff, int yoff, int width, int height) {
native_update(popover, anchor.widget, xoff, yoff, width, height);
}
}