add support for setting an explicit min size for libui controls. for now only supported by uiArea.
This commit is contained in:
parent
ce592a1d80
commit
09920126dd
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 *);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue