diff options
| author | Pietro Gagliardi <[email protected]> | 2015-04-11 14:44:40 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2015-04-11 14:44:40 -0400 |
| commit | 9ea35db265a3a9a0ae0d697aa1ef871713151c82 (patch) | |
| tree | 4fb512cbeeb613624bc3ac23771d620f24532455 | |
| parent | 0430ca9102b54fd9127d8b998d45f1941c1a278a (diff) | |
Implemented show/hide/enable/disable on uiStack and fixed other bugs. It works!
| -rw-r--r-- | new/newcontrol_unix.c | 4 | ||||
| -rw-r--r-- | new/stack.c | 110 |
2 files changed, 112 insertions, 2 deletions
diff --git a/new/newcontrol_unix.c b/new/newcontrol_unix.c index c3fad42..0f6388b 100644 --- a/new/newcontrol_unix.c +++ b/new/newcontrol_unix.c @@ -78,8 +78,8 @@ static int singleVisible(uiControl *c) singleWidget *s = (singleWidget *) (c->internal); if (s->userHid) - return 1; - return 0; + return 0; + return 1; } static void singleShow(uiControl *c) diff --git a/new/stack.c b/new/stack.c index 3899f83..c4f8ab3 100644 --- a/new/stack.c +++ b/new/stack.c @@ -11,6 +11,10 @@ struct stack { int vertical; uintptr_t parent; int padded; + int userHid; + int containerHid; + int userDisabled; + int containerDisabled; }; struct stackControl { @@ -205,6 +209,103 @@ static void stackResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, in } } +static int stackVisible(uiControl *c) +{ + stack *s = (stack *) (c->data); + + return !(s->userHid); +} + +static void stackShow(uiControl *c) +{ + stack *s = (stack *) (c->data); + uintmax_t i; + + s->userHid = 0; + if (!s->containerHid) { + for (i = 0; i < s->len; i++) + uiControlContainerShow(s->controls[i].c); + updateParent(s->parent); + } +} + +static void stackHide(uiControl *c) +{ + stack *s = (stack *) (c->data); + uintmax_t i; + + s->userHid = 1; + for (i = 0; i < s->len; i++) + uiControlContainerHide(s->controls[i].c); + updateParent(s->parent); +} + +static void stackContainerShow(uiControl *c) +{ + stack *s = (stack *) (c->data); + uintmax_t i; + + s->containerHid = 0; + if (!s->userHid) { + for (i = 0; i < s->len; i++) + uiControlContainerShow(s->controls[i].c); + updateParent(s->parent); + } +} + +static void stackContainerHide(uiControl *c) +{ + stack *s = (stack *) (c->data); + uintmax_t i; + + s->containerHid = 1; + for (i = 0; i < s->len; i++) + uiControlContainerHide(s->controls[i].c); + updateParent(s->parent); +} + +static void stackEnable(uiControl *c) +{ + stack *s = (stack *) (c->data); + uintmax_t i; + + s->userDisabled = 0; + if (!s->containerDisabled) + for (i = 0; i < s->len; i++) + uiControlContainerEnable(s->controls[i].c); +} + +static void stackDisable(uiControl *c) +{ + stack *s = (stack *) (c->data); + uintmax_t i; + + s->userDisabled = 1; + for (i = 0; i < s->len; i++) + uiControlContainerDisable(s->controls[i].c); +} + +static void stackContainerEnable(uiControl *c) +{ + stack *s = (stack *) (c->data); + uintmax_t i; + + s->containerDisabled = 0; + if (!s->userDisabled) + for (i = 0; i < s->len; i++) + uiControlContainerEnable(s->controls[i].c); +} + +static void stackContainerDisable(uiControl *c) +{ + stack *s = (stack *) (c->data); + uintmax_t i; + + s->containerDisabled = 1; + for (i = 0; i < s->len; i++) + uiControlContainerDisable(s->controls[i].c); +} + uiControl *uiNewHorizontalStack(void) { uiControl *c; @@ -220,6 +321,15 @@ uiControl *uiNewHorizontalStack(void) c->removeParent = stackRemoveParent; c->preferredSize = stackPreferredSize; c->resize = stackResize; + c->visible = stackVisible; + c->show = stackShow; + c->hide = stackHide; + c->containerShow = stackContainerShow; + c->containerHide = stackContainerHide; + c->enable = stackEnable; + c->disable = stackDisable; + c->containerEnable = stackContainerEnable; + c->containerDisable = stackContainerDisable; return c; } |
