[melonDS] uiArea: Resize event
This commit is contained in:
parent
3ea407f050
commit
d69146db71
3
ui.h
3
ui.h
|
@ -302,6 +302,8 @@ typedef struct uiAreaKeyEvent uiAreaKeyEvent;
|
||||||
|
|
||||||
typedef struct uiDrawContext uiDrawContext;
|
typedef struct uiDrawContext uiDrawContext;
|
||||||
|
|
||||||
|
// TO CONSIDER: the uiAreaHandler param there seems useless
|
||||||
|
// (might use individual callbacks instead of handler struct?)
|
||||||
struct uiAreaHandler {
|
struct uiAreaHandler {
|
||||||
void (*Draw)(uiAreaHandler *, uiArea *, uiAreaDrawParams *);
|
void (*Draw)(uiAreaHandler *, uiArea *, uiAreaDrawParams *);
|
||||||
// TODO document that resizes cause a full redraw for non-scrolling areas; implementation-defined for scrolling areas
|
// 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 (*MouseCrossed)(uiAreaHandler *, uiArea *, int left);
|
||||||
void (*DragBroken)(uiAreaHandler *, uiArea *);
|
void (*DragBroken)(uiAreaHandler *, uiArea *);
|
||||||
int (*KeyEvent)(uiAreaHandler *, uiArea *, uiAreaKeyEvent *);
|
int (*KeyEvent)(uiAreaHandler *, uiArea *, uiAreaKeyEvent *);
|
||||||
|
void (*Resize)(uiAreaHandler *, uiArea *, int, int);
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO RTL layouts?
|
// TODO RTL layouts?
|
||||||
|
|
|
@ -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 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?
|
// TODO or do we not, for parity of performance?
|
||||||
gtk_widget_queue_resize(w);
|
gtk_widget_queue_resize(w);
|
||||||
|
|
||||||
|
a->ah->Resize(a->ah, a, allocation->width, allocation->height);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void loadAreaSize(uiArea *a, double *width, double *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;
|
*min = a->scrollHeight;
|
||||||
*nat = a->scrollHeight;
|
*nat = a->scrollHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: min size
|
||||||
}
|
}
|
||||||
|
|
||||||
static void areaWidget_get_preferred_width(GtkWidget *w, gint *min, gint *nat)
|
static void areaWidget_get_preferred_width(GtkWidget *w, gint *min, gint *nat)
|
||||||
|
|
|
@ -11,6 +11,7 @@ static LRESULT CALLBACK areaWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
|
||||||
RECT client;
|
RECT client;
|
||||||
WINDOWPOS *wp = (WINDOWPOS *) lParam;
|
WINDOWPOS *wp = (WINDOWPOS *) lParam;
|
||||||
LRESULT lResult;
|
LRESULT lResult;
|
||||||
|
double w, h;
|
||||||
|
|
||||||
a = (uiArea *) GetWindowLongPtrW(hwnd, GWLP_USERDATA);
|
a = (uiArea *) GetWindowLongPtrW(hwnd, GWLP_USERDATA);
|
||||||
if (a == NULL) {
|
if (a == NULL) {
|
||||||
|
@ -37,6 +38,8 @@ static LRESULT CALLBACK areaWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
|
||||||
uiWindowsEnsureGetClientRect(a->hwnd, &client);
|
uiWindowsEnsureGetClientRect(a->hwnd, &client);
|
||||||
areaDrawOnResize(a, &client);
|
areaDrawOnResize(a, &client);
|
||||||
areaScrollOnResize(a, &client);
|
areaScrollOnResize(a, &client);
|
||||||
|
loadAreaSize(a, a->rt, &w, &h);
|
||||||
|
a->ah->Resize(a->ah, a, (int)w, (int)h);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue