summaryrefslogtreecommitdiff
path: root/new/stack.c
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2015-04-14 10:20:07 -0400
committerPietro Gagliardi <[email protected]>2015-04-14 10:20:07 -0400
commit6185187506dd4bebaa801aaa1d4d1c783557e786 (patch)
tree577413b20fbb36707390c88918d4d52b1ac0b6f2 /new/stack.c
parent689e9c71011e2bfcd2ad1d05f19077ed9937a8a1 (diff)
More uiParent work. Something I did broke stack removal...
Diffstat (limited to 'new/stack.c')
-rw-r--r--new/stack.c27
1 files changed, 9 insertions, 18 deletions
diff --git a/new/stack.c b/new/stack.c
index 3850a63..a5de6a4 100644
--- a/new/stack.c
+++ b/new/stack.c
@@ -48,24 +48,16 @@ static void stackSetParent(uiControl *c, uiParent *parent)
{
stack *s = (stack *) (c->data);
uintmax_t i;
-
- s->parent = parent;
- for (i = 0; i < s->len; i++)
- uiControlSetParent(s->controls[i].c, s->parent);
- uiParentUpdate(s->parent);
-}
-
-static void stackRemoveParent(uiControl *c)
-{
- stack *s = (stack *) (c->data);
- uintmax_t i;
uiParent *oldparent;
oldparent = s->parent;
- s->parent = NULL;
+ s->parent = parent;
for (i = 0; i < s->len; i++)
- uiControlRemoveParent(s->controls[i].c);
- uiParentUpdate(oldparent);
+ uiControlSetParent(s->controls[i].c, s->parent);
+ if (oldparent != NULL)
+ uiParentUpdate(oldparent);
+ if (s->parent != NULL)
+ uiParentUpdate(s->parent);
}
static void stackPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t *height)
@@ -324,7 +316,6 @@ uiControl *uiNewHorizontalStack(void)
c->destroy = stackDestroy;
c->handle = stackHandle;
c->setParent = stackSetParent;
- c->removeParent = stackRemoveParent;
c->preferredSize = stackPreferredSize;
c->resize = stackResize;
c->visible = stackVisible;
@@ -363,14 +354,14 @@ void uiStackAdd(uiControl *st, uiControl *c, int stretchy)
}
s->controls[s->len].c = c;
s->controls[s->len].stretchy = stretchy;
- s->len++;
if (s->parent != NULL) {
uiControlSetParent(s->controls[s->len].c, s->parent);
uiParentUpdate(s->parent);
}
+ s->len++;
}
-void uiStackRemove(uiControl *st, uintptr_t index)
+void uiStackRemove(uiControl *st, uintmax_t index)
{
stack *s = (stack *) (st->data);
uiControl *removed;
@@ -382,7 +373,7 @@ void uiStackRemove(uiControl *st, uintptr_t index)
memmove(&(s->controls[index + 1]), &(s->controls[index]), nAfter * sizeof (stackControl));
s->len--;
if (s->parent != NULL) {
- uiControlRemoveParent(removed);
+ uiControlSetParent(removed, NULL);
uiParentUpdate(s->parent);
}
}