diff --git a/redo/control.c b/redo/control.c index eb57ea21..d0fda2fd 100644 --- a/redo/control.c +++ b/redo/control.c @@ -77,6 +77,14 @@ void uiControlSetParent(uiControl *c, uiControl *parent) controlUpdateState(c); } +// only to be called by the immediate parent of a control +int controlSelfVisible(uiControl *c) +{ + struct controlBase *cb = controlBase(c); + + return !cb->hidden; +} + static int controlContainerVisible(uiControl *c) { struct controlBase *cb = controlBase(c); @@ -143,6 +151,7 @@ void controlUpdateState(uiControl *c) osCommitDisable(c); (*(c->ContainerUpdateState))(c); // and queue a resize, just in case we showed/hid something + // for instance, on Windows uiBox, if we don't do this, hiding a control will show empty space until the window is resized //TODO uiControlQueueResize(c); } diff --git a/redo/uipriv.h b/redo/uipriv.h index 3210bfb1..830e70f8 100644 --- a/redo/uipriv.h +++ b/redo/uipriv.h @@ -17,6 +17,7 @@ extern void complain(const char *, ...); extern int isToplevel(uiControl *); extern uiControl *toplevelOwning(uiControl *); +extern int controlSelfVisible(uiControl *); extern void controlUpdateState(uiControl *); extern void osCommitEnable(uiControl *); diff --git a/redo/windows/box.c b/redo/windows/box.c index 6c8e8f89..3d45414a 100644 --- a/redo/windows/box.c +++ b/redo/windows/box.c @@ -79,8 +79,8 @@ static void minimumSize(uiWindowsControl *c, uiWindowsSizing *d, intmax_t *width maxStretchyHeight = 0; for (i = 0; i < b->controls->len; i++) { bc = ptrArrayIndex(b->controls, struct child *, i); -//TODO if (!uiControlContainerVisible(bc->c)) -//TODO continue; + if (!childVisible(bc)) + continue; childMinimumSize(bc, dself, &minimumWidth, &minimumHeight); if (ctrlStretchy(bc)) { nStretchy++; @@ -151,8 +151,8 @@ static void boxRelayout(uiWindowsControl *c, intmax_t x, intmax_t y, intmax_t wi nStretchy = 0; for (i = 0; i < b->controls->len; i++) { bc = ptrArrayIndex(b->controls, struct child *, i); -//TODO if (!uiControlContainerVisible(bc->c)) -//TODO continue; + if (!childVisible(bc)) + continue; if (ctrlStretchy(bc)) { nStretchy++; continue; @@ -177,8 +177,8 @@ static void boxRelayout(uiWindowsControl *c, intmax_t x, intmax_t y, intmax_t wi stretchywid /= nStretchy; for (i = 0; i < b->controls->len; i++) { bc = ptrArrayIndex(b->controls, struct child *, i); -//TODO if (!uiControlContainerVisible(bc->c)) -//TODO continue; + if (!childVisible(bc)) + continue; if (ctrlStretchy(bc)) { ctrlSetWidth(bc, stretchywid); ctrlSetHeight(bc, stretchyht); @@ -191,8 +191,8 @@ static void boxRelayout(uiWindowsControl *c, intmax_t x, intmax_t y, intmax_t wi y = 0; for (i = 0; i < b->controls->len; i++) { bc = ptrArrayIndex(b->controls, struct child *, i); -//TODO if (!uiControlContainerVisible(bc->c)) -//TODO continue; + if (!childVisible(bc)) + continue; childRelayout(bc, x, y, ctrlWidth(bc), ctrlHeight(bc)); if (b->vertical) y += ctrlHeight(bc) + ypadding; diff --git a/redo/windows/child.c b/redo/windows/child.c index 4e1019dc..2cfa77b6 100644 --- a/redo/windows/child.c +++ b/redo/windows/child.c @@ -113,6 +113,11 @@ void childQueueRelayout(struct child *c) uiWindowsControlQueueRelayout(uiWindowsControl(c->c)); } +int childVisible(struct child *c) +{ + return controlSelfVisible(c->c); +} + void childUpdateState(struct child *c) { controlUpdateState(c->c); diff --git a/redo/windows/uipriv_windows.h b/redo/windows/uipriv_windows.h index ebbef57e..b92b52a3 100644 --- a/redo/windows/uipriv_windows.h +++ b/redo/windows/uipriv_windows.h @@ -104,6 +104,7 @@ extern HWND childHWND(struct child *c); extern void childMinimumSize(struct child *c, uiWindowsSizing *d, intmax_t *width, intmax_t *height); extern void childRelayout(struct child *c, intmax_t x, intmax_t y, intmax_t width, intmax_t height); extern void childQueueRelayout(struct child *c); +extern int childVisible(struct child *c); extern void childUpdateState(struct child *c); extern HWND childTabPage(struct child *c); extern int childMargined(struct child *c);