From d69146db718443f6c51d976491e2cc90715dcc53 Mon Sep 17 00:00:00 2001 From: StapleButter Date: Mon, 2 Oct 2017 03:34:17 +0200 Subject: [PATCH] [melonDS] uiArea: Resize event --- ui.h | 3 +++ unix/area.c | 4 ++++ windows/area.cpp | 3 +++ 3 files changed, 10 insertions(+) diff --git a/ui.h b/ui.h index 9584abff..cb7541ae 100644 --- a/ui.h +++ b/ui.h @@ -302,6 +302,8 @@ typedef struct uiAreaKeyEvent uiAreaKeyEvent; typedef struct uiDrawContext uiDrawContext; +// TO CONSIDER: the uiAreaHandler param there seems useless +// (might use individual callbacks instead of handler struct?) struct uiAreaHandler { void (*Draw)(uiAreaHandler *, uiArea *, uiAreaDrawParams *); // TODO document that resizes cause a full redraw for non-scrolling areas; implementation-defined for scrolling areas @@ -311,6 +313,7 @@ struct uiAreaHandler { void (*MouseCrossed)(uiAreaHandler *, uiArea *, int left); void (*DragBroken)(uiAreaHandler *, uiArea *); int (*KeyEvent)(uiAreaHandler *, uiArea *, uiAreaKeyEvent *); + void (*Resize)(uiAreaHandler *, uiArea *, int, int); }; // TODO RTL layouts? diff --git a/unix/area.c b/unix/area.c index 4add3554..71a93a50 100644 --- a/unix/area.c +++ b/unix/area.c @@ -97,6 +97,8 @@ static void areaWidget_size_allocate(GtkWidget *w, GtkAllocation *allocation) // TODO drop this rule; it was stupid and documenting this was stupid — let platforms where it matters do it on their own // TODO or do we not, for parity of performance? gtk_widget_queue_resize(w); + + a->ah->Resize(a->ah, a, allocation->width, allocation->height); } static void loadAreaSize(uiArea *a, double *width, double *height) @@ -161,6 +163,8 @@ static void areaWidget_get_preferred_height(GtkWidget *w, gint *min, gint *nat) *min = a->scrollHeight; *nat = a->scrollHeight; } + + // TODO: min size } static void areaWidget_get_preferred_width(GtkWidget *w, gint *min, gint *nat) diff --git a/windows/area.cpp b/windows/area.cpp index 9c31ba35..908ea5ab 100644 --- a/windows/area.cpp +++ b/windows/area.cpp @@ -11,6 +11,7 @@ static LRESULT CALLBACK areaWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM RECT client; WINDOWPOS *wp = (WINDOWPOS *) lParam; LRESULT lResult; + double w, h; a = (uiArea *) GetWindowLongPtrW(hwnd, GWLP_USERDATA); if (a == NULL) { @@ -37,6 +38,8 @@ static LRESULT CALLBACK areaWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM uiWindowsEnsureGetClientRect(a->hwnd, &client); areaDrawOnResize(a, &client); areaScrollOnResize(a, &client); + loadAreaSize(a, a->rt, &w, &h); + a->ah->Resize(a->ah, a, (int)w, (int)h); return 0; }