[melonDS] uiArea: Resize event

This commit is contained in:
StapleButter 2017-10-02 03:34:17 +02:00 committed by Mike Sinkovsky
parent 3ea407f050
commit d69146db71
3 changed files with 10 additions and 0 deletions

3
ui.h
View File

@ -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?

View File

@ -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)

View File

@ -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;
}