mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-22 05:40:15 -06:00
add support for setting an explicit min size for libui controls. for now only supported by uiArea.
This commit is contained in:
@ -62,6 +62,14 @@ void uiControlSetFocus(uiControl *c)
|
|||||||
(*(c->SetFocus))(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
|
#define uiControlSignature 0x7569436F
|
||||||
|
|
||||||
uiControl *uiAllocControl(size_t size, uint32_t OSsig, uint32_t typesig, const char *typenamestr)
|
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->Signature = uiControlSignature;
|
||||||
c->OSSignature = OSsig;
|
c->OSSignature = OSsig;
|
||||||
c->TypeSignature = typesig;
|
c->TypeSignature = typesig;
|
||||||
|
|
||||||
|
c->MinWidth = -1;
|
||||||
|
c->MinHeight = -1;
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,6 +73,8 @@ struct uiControl {
|
|||||||
void (*Enable)(uiControl *);
|
void (*Enable)(uiControl *);
|
||||||
void (*Disable)(uiControl *);
|
void (*Disable)(uiControl *);
|
||||||
void (*SetFocus)(uiControl *);
|
void (*SetFocus)(uiControl *);
|
||||||
|
|
||||||
|
int MinWidth, MinHeight;
|
||||||
};
|
};
|
||||||
// TOOD add argument names to all arguments
|
// TOOD add argument names to all arguments
|
||||||
#define uiControl(this) ((uiControl *) (this))
|
#define uiControl(this) ((uiControl *) (this))
|
||||||
@ -88,6 +90,7 @@ _UI_EXTERN int uiControlEnabled(uiControl *);
|
|||||||
_UI_EXTERN void uiControlEnable(uiControl *);
|
_UI_EXTERN void uiControlEnable(uiControl *);
|
||||||
_UI_EXTERN void uiControlDisable(uiControl *);
|
_UI_EXTERN void uiControlDisable(uiControl *);
|
||||||
_UI_EXTERN void uiControlSetFocus(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 uiControl *uiAllocControl(size_t n, uint32_t OSsig, uint32_t typesig, const char *typenamestr);
|
||||||
_UI_EXTERN void uiFreeControl(uiControl *);
|
_UI_EXTERN void uiFreeControl(uiControl *);
|
||||||
|
@ -55,9 +55,11 @@ uiWindowsControlAllDefaults(uiArea)
|
|||||||
|
|
||||||
static void uiAreaMinimumSize(uiWindowsControl *c, int *width, int *height)
|
static void uiAreaMinimumSize(uiWindowsControl *c, int *width, int *height)
|
||||||
{
|
{
|
||||||
// TODO
|
*width = c->c.MinWidth;
|
||||||
*width = 1;
|
if (*width < 1) *width = 1;
|
||||||
*height = 1;
|
|
||||||
|
*height = c->c.MinHeight;
|
||||||
|
if (*height < 1) *height = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ATOM registerAreaClass(HICON hDefaultIcon, HCURSOR hDefaultCursor)
|
ATOM registerAreaClass(HICON hDefaultIcon, HCURSOR hDefaultCursor)
|
||||||
|
@ -592,6 +592,7 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
MainDrawArea = uiNewArea(&areahandler);
|
MainDrawArea = uiNewArea(&areahandler);
|
||||||
uiWindowSetChild(MainWindow, uiControl(MainDrawArea));
|
uiWindowSetChild(MainWindow, uiControl(MainDrawArea));
|
||||||
|
uiControlSetMinSize(uiControl(MainDrawArea), 256, 384);
|
||||||
|
|
||||||
EmuRunning = 2;
|
EmuRunning = 2;
|
||||||
RunningSomething = false;
|
RunningSomething = false;
|
||||||
|
Reference in New Issue
Block a user