Implemented making invisible children of uiStacks not count when drawing or calculating preferred size. Need to implement the new methods on uiStack itself before we can test.

This commit is contained in:
Pietro Gagliardi 2015-04-11 14:30:07 -04:00
parent b57c885505
commit 0430ca9102
2 changed files with 18 additions and 3 deletions

View File

@ -87,8 +87,10 @@ static void singleShow(uiControl *c)
singleWidget *s = (singleWidget *) (c->internal); singleWidget *s = (singleWidget *) (c->internal);
s->userHid = FALSE; s->userHid = FALSE;
if (!s->containerHid) if (!s->containerHid) {
gtk_widget_show_all(s->immediate); gtk_widget_show_all(s->immediate);
updateParent(s->parent);
}
} }
static void singleHide(uiControl *c) static void singleHide(uiControl *c)
@ -97,6 +99,7 @@ static void singleHide(uiControl *c)
s->userHid = TRUE; s->userHid = TRUE;
gtk_widget_hide(s->immediate); gtk_widget_hide(s->immediate);
updateParent(s->parent);
} }
static void singleContainerShow(uiControl *c) static void singleContainerShow(uiControl *c)
@ -104,8 +107,10 @@ static void singleContainerShow(uiControl *c)
singleWidget *s = (singleWidget *) (c->internal); singleWidget *s = (singleWidget *) (c->internal);
s->containerHid = FALSE; s->containerHid = FALSE;
if (!s->userHid) if (!s->userHid) {
gtk_widget_show_all(s->immediate); gtk_widget_show_all(s->immediate);
updateParent(s->parent);
}
} }
static void singleContainerHide(uiControl *c) static void singleContainerHide(uiControl *c)
@ -114,6 +119,7 @@ static void singleContainerHide(uiControl *c)
s->containerHid = TRUE; s->containerHid = TRUE;
gtk_widget_hide(s->immediate); gtk_widget_hide(s->immediate);
updateParent(s->parent);
} }
static void singleEnable(uiControl *c) static void singleEnable(uiControl *c)

View File

@ -97,6 +97,8 @@ static void stackPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intma
maxStretchyWidth = 0; maxStretchyWidth = 0;
maxStretchyHeight = 0; maxStretchyHeight = 0;
for (i = 0; i < s->len; i++) { for (i = 0; i < s->len; i++) {
if (!uiControlVisible(s->controls[i].c))
continue;
uiControlPreferredSize(s->controls[i].c, d, &preferredWidth, &preferredHeight); uiControlPreferredSize(s->controls[i].c, d, &preferredWidth, &preferredHeight);
if (s->controls[i].stretchy) { if (s->controls[i].stretchy) {
nStretchy++; nStretchy++;
@ -157,6 +159,8 @@ static void stackResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, in
stretchyht = height; stretchyht = height;
nStretchy = 0; nStretchy = 0;
for (i = 0; i < s->len; i++) { for (i = 0; i < s->len; i++) {
if (!uiControlVisible(s->controls[i].c))
continue;
if (s->controls[i].stretchy) { if (s->controls[i].stretchy) {
nStretchy++; nStretchy++;
continue; continue;
@ -180,14 +184,19 @@ static void stackResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, in
stretchyht /= nStretchy; stretchyht /= nStretchy;
else else
stretchywid /= nStretchy; stretchywid /= nStretchy;
for (i = 0; i < s->len; i++) for (i = 0; i < s->len; i++) {
if (!uiControlVisible(s->controls[i].c))
continue;
if (s->controls[i].stretchy) { if (s->controls[i].stretchy) {
s->controls[i].width = stretchywid; s->controls[i].width = stretchywid;
s->controls[i].height = stretchyht; s->controls[i].height = stretchyht;
} }
}
// 3) now we can position controls // 3) now we can position controls
for (i = 0; i < s->len; i++) { for (i = 0; i < s->len; i++) {
if (!uiControlVisible(s->controls[i].c))
continue;
uiControlResize(s->controls[i].c, x, y, s->controls[i].width, s->controls[i].height, d); uiControlResize(s->controls[i].c, x, y, s->controls[i].width, s->controls[i].height, d);
if (s->vertical) if (s->vertical)
y += s->controls[i].height + ypadding; y += s->controls[i].height + ypadding;