diff options
author | StapleButter <thetotalworm@gmail.com> | 2017-10-02 01:58:09 +0200 |
---|---|---|
committer | StapleButter <thetotalworm@gmail.com> | 2017-10-02 01:58:09 +0200 |
commit | 09920126ddcc84d98e333287566d8483ad3410a8 (patch) | |
tree | ede915edf24788c3998cdfc7adef5249f47a7e7a /src/libui_sdl | |
parent | ce592a1d80db2eb1de0dc5ac55c2270e3a6befb3 (diff) |
add support for setting an explicit min size for libui controls. for now only supported by uiArea.
Diffstat (limited to 'src/libui_sdl')
-rw-r--r-- | src/libui_sdl/libui/common/control.c | 12 | ||||
-rw-r--r-- | src/libui_sdl/libui/ui.h | 3 | ||||
-rw-r--r-- | src/libui_sdl/libui/windows/area.cpp | 8 | ||||
-rw-r--r-- | src/libui_sdl/main.cpp | 1 |
4 files changed, 21 insertions, 3 deletions
diff --git a/src/libui_sdl/libui/common/control.c b/src/libui_sdl/libui/common/control.c index 771a29d..f811728 100644 --- a/src/libui_sdl/libui/common/control.c +++ b/src/libui_sdl/libui/common/control.c @@ -62,6 +62,14 @@ void uiControlSetFocus(uiControl *c) (*(c->SetFocus))(c); } +void uiControlSetMinSize(uiControl *c, int w, int h) +{ + c->MinWidth = w; + c->MinHeight = h; + + // TODO: resize if needed +} + #define uiControlSignature 0x7569436F uiControl *uiAllocControl(size_t size, uint32_t OSsig, uint32_t typesig, const char *typenamestr) @@ -72,6 +80,10 @@ uiControl *uiAllocControl(size_t size, uint32_t OSsig, uint32_t typesig, const c c->Signature = uiControlSignature; c->OSSignature = OSsig; c->TypeSignature = typesig; + + c->MinWidth = -1; + c->MinHeight = -1; + return c; } diff --git a/src/libui_sdl/libui/ui.h b/src/libui_sdl/libui/ui.h index d072ac2..f1937e2 100644 --- a/src/libui_sdl/libui/ui.h +++ b/src/libui_sdl/libui/ui.h @@ -73,6 +73,8 @@ struct uiControl { void (*Enable)(uiControl *); void (*Disable)(uiControl *); void (*SetFocus)(uiControl *); + + int MinWidth, MinHeight; }; // TOOD add argument names to all arguments #define uiControl(this) ((uiControl *) (this)) @@ -88,6 +90,7 @@ _UI_EXTERN int uiControlEnabled(uiControl *); _UI_EXTERN void uiControlEnable(uiControl *); _UI_EXTERN void uiControlDisable(uiControl *); _UI_EXTERN void uiControlSetFocus(uiControl *); +_UI_EXTERN void uiControlSetMinSize(uiControl *, int w, int h); // -1 = no minimum _UI_EXTERN uiControl *uiAllocControl(size_t n, uint32_t OSsig, uint32_t typesig, const char *typenamestr); _UI_EXTERN void uiFreeControl(uiControl *); diff --git a/src/libui_sdl/libui/windows/area.cpp b/src/libui_sdl/libui/windows/area.cpp index 3257631..74fe768 100644 --- a/src/libui_sdl/libui/windows/area.cpp +++ b/src/libui_sdl/libui/windows/area.cpp @@ -55,9 +55,11 @@ uiWindowsControlAllDefaults(uiArea) static void uiAreaMinimumSize(uiWindowsControl *c, int *width, int *height) { - // TODO - *width = 1; - *height = 1; + *width = c->c.MinWidth; + if (*width < 1) *width = 1; + + *height = c->c.MinHeight; + if (*height < 1) *height = 1; } ATOM registerAreaClass(HICON hDefaultIcon, HCURSOR hDefaultCursor) diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp index 241d9b7..1d5fcae 100644 --- a/src/libui_sdl/main.cpp +++ b/src/libui_sdl/main.cpp @@ -592,6 +592,7 @@ int main(int argc, char** argv) MainDrawArea = uiNewArea(&areahandler); uiWindowSetChild(MainWindow, uiControl(MainDrawArea)); + uiControlSetMinSize(uiControl(MainDrawArea), 256, 384); EmuRunning = 2; RunningSomething = false; |