More uiParent work. Something I did broke stack removal...
This commit is contained in:
parent
689e9c7101
commit
6185187506
|
@ -16,11 +16,6 @@ void uiControlSetParent(uiControl *c, uiParent *parent)
|
||||||
(*(c->setParent))(c, parent);
|
(*(c->setParent))(c, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiControlRemoveParent(uiControl *c)
|
|
||||||
{
|
|
||||||
(*(c->removeParent))(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
void uiControlPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t *height)
|
void uiControlPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t *height)
|
||||||
{
|
{
|
||||||
(*(c->preferredSize))(c, d, width, height);
|
(*(c->preferredSize))(c, d, width, height);
|
||||||
|
|
|
@ -32,25 +32,22 @@ static uintptr_t singleHandle(uiControl *c)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void singleSetParent(uiControl *c, uiParent *parent)
|
static void singleSetParent(uiControl *c, uiParent *parent)
|
||||||
{
|
|
||||||
singleHWND *s = (singleHWND *) (c->internal);
|
|
||||||
|
|
||||||
s->parent = parent;
|
|
||||||
if (SetParent(s->hwnd, uiParentHWND(s->parent)) == NULL)
|
|
||||||
logLastError("error setting control parent in singleSetParent()");
|
|
||||||
uiParentUpdate(s->parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void singleRemoveParent(uiControl *c)
|
|
||||||
{
|
{
|
||||||
singleHWND *s = (singleHWND *) (c->internal);
|
singleHWND *s = (singleHWND *) (c->internal);
|
||||||
uiParent *oldparent;
|
uiParent *oldparent;
|
||||||
|
HWND newParentHWND;
|
||||||
|
|
||||||
oldparent = s->parent;
|
oldparent = s->parent;
|
||||||
s->parent = NULL;
|
s->parent = parent;
|
||||||
if (SetParent(s->hwnd, initialParent) == NULL)
|
newParentHWND = initialParent;
|
||||||
logLastError("error removing control parent in singleSetParent()");
|
if (s->parent != NULL)
|
||||||
|
newParentHWND = uiParentHWND(s->parent);
|
||||||
|
if (SetParent(s->hwnd, newParentHWND) == NULL)
|
||||||
|
logLastError("error setting control parent in singleSetParent()");
|
||||||
|
if (oldparent != NULL)
|
||||||
uiParentUpdate(oldparent);
|
uiParentUpdate(oldparent);
|
||||||
|
if (s->parent != NULL)
|
||||||
|
uiParentUpdate(s->parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void singleResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, intmax_t height, uiSizing *d)
|
static void singleResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, intmax_t height, uiSizing *d)
|
||||||
|
@ -199,7 +196,6 @@ uiControl *uiWindowsNewControl(uiWindowsNewControlParams *p)
|
||||||
c->destroy = singleDestroy;
|
c->destroy = singleDestroy;
|
||||||
c->handle = singleHandle;
|
c->handle = singleHandle;
|
||||||
c->setParent = singleSetParent;
|
c->setParent = singleSetParent;
|
||||||
c->removeParent = singleRemoveParent;
|
|
||||||
c->resize = singleResize;
|
c->resize = singleResize;
|
||||||
c->visible = singleVisible;
|
c->visible = singleVisible;
|
||||||
c->show = singleShow;
|
c->show = singleShow;
|
||||||
|
|
25
new/stack.c
25
new/stack.c
|
@ -45,27 +45,19 @@ static uintptr_t stackHandle(uiControl *c)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stackSetParent(uiControl *c, uiParent *parent)
|
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);
|
stack *s = (stack *) (c->data);
|
||||||
uintmax_t i;
|
uintmax_t i;
|
||||||
uiParent *oldparent;
|
uiParent *oldparent;
|
||||||
|
|
||||||
oldparent = s->parent;
|
oldparent = s->parent;
|
||||||
s->parent = NULL;
|
s->parent = parent;
|
||||||
for (i = 0; i < s->len; i++)
|
for (i = 0; i < s->len; i++)
|
||||||
uiControlRemoveParent(s->controls[i].c);
|
uiControlSetParent(s->controls[i].c, s->parent);
|
||||||
|
if (oldparent != NULL)
|
||||||
uiParentUpdate(oldparent);
|
uiParentUpdate(oldparent);
|
||||||
|
if (s->parent != NULL)
|
||||||
|
uiParentUpdate(s->parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stackPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t *height)
|
static void stackPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t *height)
|
||||||
|
@ -324,7 +316,6 @@ uiControl *uiNewHorizontalStack(void)
|
||||||
c->destroy = stackDestroy;
|
c->destroy = stackDestroy;
|
||||||
c->handle = stackHandle;
|
c->handle = stackHandle;
|
||||||
c->setParent = stackSetParent;
|
c->setParent = stackSetParent;
|
||||||
c->removeParent = stackRemoveParent;
|
|
||||||
c->preferredSize = stackPreferredSize;
|
c->preferredSize = stackPreferredSize;
|
||||||
c->resize = stackResize;
|
c->resize = stackResize;
|
||||||
c->visible = stackVisible;
|
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].c = c;
|
||||||
s->controls[s->len].stretchy = stretchy;
|
s->controls[s->len].stretchy = stretchy;
|
||||||
s->len++;
|
|
||||||
if (s->parent != NULL) {
|
if (s->parent != NULL) {
|
||||||
uiControlSetParent(s->controls[s->len].c, s->parent);
|
uiControlSetParent(s->controls[s->len].c, s->parent);
|
||||||
uiParentUpdate(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);
|
stack *s = (stack *) (st->data);
|
||||||
uiControl *removed;
|
uiControl *removed;
|
||||||
|
@ -382,7 +373,7 @@ void uiStackRemove(uiControl *st, uintptr_t index)
|
||||||
memmove(&(s->controls[index + 1]), &(s->controls[index]), nAfter * sizeof (stackControl));
|
memmove(&(s->controls[index + 1]), &(s->controls[index]), nAfter * sizeof (stackControl));
|
||||||
s->len--;
|
s->len--;
|
||||||
if (s->parent != NULL) {
|
if (s->parent != NULL) {
|
||||||
uiControlRemoveParent(removed);
|
uiControlSetParent(removed, NULL);
|
||||||
uiParentUpdate(s->parent);
|
uiParentUpdate(s->parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue