Laid the foundation for control showing, hiding, enabling, and disabling.

This commit is contained in:
Pietro Gagliardi 2015-04-11 14:12:12 -04:00
parent 901e1cffd6
commit 37975ae082
3 changed files with 116 additions and 1 deletions

View File

@ -30,3 +30,48 @@ void uiControlResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, intma
{
(*(c->resize))(c, x, y, width, height, d);
}
int uiControlVisible(uiControl *c)
{
return (*(c->visible))(c);
}
void uiControlShow(uiControl *c)
{
(*(c->show))(c);
}
void uiControlHide(uiControl *c)
{
(*(c->hide))(c);
}
void uiControlContainerShow(uiControl *c)
{
(*(c->containerShow))(c);
}
void uiControlContainerHide(uiControl *c)
{
(*(c->containerHide))(c);
}
void uiControlEnable(uiControl *c)
{
(*(c->enable))(c);
}
void uiControlDisable(uiControl *c)
{
(*(c->disable))(c);
}
void uiControlContainerEnable(uiControl *c)
{
(*(c->containerEnable))(c);
}
void uiControlContainerDisable(uiControl *c)
{
(*(c->containerDisable))(c);
}

54
test.c
View File

@ -67,7 +67,7 @@ static void setCheckboxText(uiControl *b, void *data)
}
uiWindow *w;
#define nStacks 5
#define nStacks 7
uiControl *stacks[nStacks];
uiControl *spaced;
@ -110,6 +110,26 @@ static void showSpaced(uiControl *c, void *data)
uiEntrySetText(e, msg);
}
static void showControl(uiControl *c, void *data)
{
uiControlShow((uiControl *) data);
}
static void hideControl(uiControl *c, void *data)
{
uiControlHide((uiControl *) data);
}
static void enableControl(uiControl *c, void *data)
{
uiControlEnable((uiControl *) data);
}
static void disableControl(uiControl *c, void *data)
{
uiControlDisable((uiControl *) data);
}
int main(int argc, char *argv[])
{
uiInitOptions o;
@ -186,6 +206,38 @@ int main(int argc, char *argv[])
uiStackAdd(stacks[4], setButton, 0);
uiStackAdd(stacks[0], stacks[4], 0);
stacks[5] = uiNewHorizontalStack();
getButton = uiNewButton("Button");
uiStackAdd(stacks[5], getButton, 1);
setButton = uiNewButton("Show");
uiButtonOnClicked(setButton, showControl, getButton);
uiStackAdd(stacks[5], setButton, 0);
setButton = uiNewButton("Hide");
uiButtonOnClicked(setButton, hideControl, getButton);
uiStackAdd(stacks[5], setButton, 0);
setButton = uiNewButton("Enable");
uiButtonOnClicked(setButton, enableControl, getButton);
uiStackAdd(stacks[5], setButton, 0);
setButton = uiNewButton("Disable");
uiButtonOnClicked(setButton, disableControl, getButton);
uiStackAdd(stacks[5], setButton, 0);
uiStackAdd(stacks[0], stacks[5], 0);
stacks[6] = uiNewHorizontalStack();
setButton = uiNewButton("Show Stack");
uiButtonOnClicked(setButton, showControl, stacks[5]);
uiStackAdd(stacks[6], setButton, 1);
setButton = uiNewButton("Hide Stack");
uiButtonOnClicked(setButton, hideControl, stacks[5]);
uiStackAdd(stacks[6], setButton, 1);
setButton = uiNewButton("Enable Stack");
uiButtonOnClicked(setButton, enableControl, stacks[5]);
uiStackAdd(stacks[6], setButton, 1);
setButton = uiNewButton("Disable Stack");
uiButtonOnClicked(setButton, disableControl, stacks[5]);
uiStackAdd(stacks[6], setButton, 1);
uiStackAdd(stacks[0], stacks[6], 0);
uiWindowShow(w);
uiMain();
printf("after uiMain()\n");

18
ui.h
View File

@ -42,6 +42,15 @@ struct uiControl {
void (*removeParent)(uiControl *);
void (*preferredSize)(uiControl *, uiSizing *, intmax_t *, intmax_t *);
void (*resize)(uiControl *, intmax_t, intmax_t, intmax_t, intmax_t, uiSizing *);
int (*visible)(uiControl *);
void (*show)(uiControl *);
void (*hide)(uiControl *);
void (*containerShow)(uiControl *);
void (*containerHide)(uiControl *);
void (*enable)(uiControl *);
void (*disable)(uiControl *);
void (*containerEnable)(uiControl *);
void (*containerDisable)(uiControl *);
};
void uiControlDestroy(uiControl *);
uintptr_t uiControlHandle(uiControl *);
@ -49,6 +58,15 @@ void uiControlSetParent(uiControl *, uintptr_t);
void uiControlRemoveParent(uiControl *);
void uiControlPreferredSize(uiControl *, uiSizing *, intmax_t *width, intmax_t *height);
void uiControlResize(uiControl *, intmax_t, intmax_t, intmax_t, intmax_t, uiSizing *);
int uiControlVisible(uiControl *);
void uiControlShow(uiControl *);
void uiControlHide(uiControl *);
void uiControlContainerShow(uiControl *);
void uiControlContainerHide(uiControl *);
void uiControlEnable(uiControl *);
void uiControlDisable(uiControl *);
void uiControlContainerEnable(uiControl *);
void uiControlContainerDisable(uiControl *);
typedef struct uiWindow uiWindow;
uiWindow *uiNewWindow(char *, int, int);