From 7ea67007fc09c8c4ab6dcfdf7fd371dc4ea0984c Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Fri, 15 May 2015 18:34:17 -0400 Subject: [PATCH] Re-added uiControlContainerShow() and uiControlContainerHide(). This is needed on Windows for uiTab. --- TODO.md | 1 + redo/ui.idl | 4 +++- redo/windows/control.c | 39 ++++++++++++++++++++++++++++++++------- redo/windows/window.c | 24 +++++++++++++++--------- 4 files changed, 51 insertions(+), 17 deletions(-) diff --git a/TODO.md b/TODO.md index 67776544..64b9ca0e 100644 --- a/TODO.md +++ b/TODO.md @@ -38,3 +38,4 @@ notes to self - note that if a menu is requested on systems with menubars on windows but no menus are defined, the result is a blank menubar, with whatever that means left up to the OS to decide - note that type mixing == undefined behavior - note that handling of multiple consecutive separators in menus, leading separators in menus, and trailing separators in menus are all implementation-defined +- note that ContainerVisible() returns true if both user and container not hidden; container use only diff --git a/redo/ui.idl b/redo/ui.idl index aec29eb9..bc0af71d 100644 --- a/redo/ui.idl +++ b/redo/ui.idl @@ -50,9 +50,11 @@ interface Control { func QueueResize(void); func GetSizing(d *Sizing); func ComputeChildSize(x *intmax_t, y *intmax_t, width *intmax_t, height *intmax_t, d *Sizing); - func Visible(void) int; + func ContainerVisible(void) int; func Show(void); func Hide(void); + func ContainerShow(void); + func ContainerHide(void); func Enable(void); func Disable(void); func ContainerEnable(void); diff --git a/redo/windows/control.c b/redo/windows/control.c index 9a12c0a0..87cdd3f2 100644 --- a/redo/windows/control.c +++ b/redo/windows/control.c @@ -8,7 +8,8 @@ struct singleHWND { void (*onDestroy)(void *); void *onDestroyData; uiContainer *parent; - int hidden; + int userHidden; + int containerHidden; int userDisabled; int containerDisabled; }; @@ -76,19 +77,20 @@ static void singleComputeChildSize(uiControl *c, intmax_t *x, intmax_t *y, intma complain("attempt to call uiControlComputeChildSize() on a non-container"); } -static int singleVisible(uiControl *c) +static int singleContainerVisible(uiControl *c) { struct singleHWND *s = (struct singleHWND *) (c->Internal); - return !s->hidden; + return !s->userHidden && !s->containerHidden; } static void singleShow(uiControl *c) { struct singleHWND *s = (struct singleHWND *) (c->Internal); - ShowWindow(s->hwnd, SW_SHOW); - s->hidden = 0; + s->userHidden = 0; + if (!s->containerHidden) + ShowWindow(s->hwnd, SW_SHOW); if (s->parent != NULL) uiContainerUpdate(s->parent); } @@ -97,8 +99,29 @@ static void singleHide(uiControl *c) { struct singleHWND *s = (struct singleHWND *) (c->Internal); + s->userHidden = 1; + ShowWindow(s->hwnd, SW_HIDE); + if (s->parent != NULL) + uiContainerUpdate(s->parent); +} + +static void singleContainerShow(uiControl *c) +{ + struct singleHWND *s = (struct singleHWND *) (c->Internal); + + s->containerHidden = 0; + if (!s->userHidden) + ShowWindow(s->hwnd, SW_SHOW); + if (s->parent != NULL) + uiContainerUpdate(s->parent); +} + +static void singleContainerHide(uiControl *c) +{ + struct singleHWND *s = (struct singleHWND *) (c->Internal); + + s->containerHidden = 1; ShowWindow(s->hwnd, SW_HIDE); - s->hidden = 1; if (s->parent != NULL) uiContainerUpdate(s->parent); } @@ -219,9 +242,11 @@ void uiWindowsMakeControl(uiControl *c, uiWindowsMakeControlParams *p) uiControl(c)->QueueResize = singleQueueResize; uiControl(c)->GetSizing = singleGetSizing; uiControl(c)->ComputeChildSize = singleComputeChildSize; - uiControl(c)->Visible = singleVisible; + uiControl(c)->ContainerVisible = singleContainerVisible; uiControl(c)->Show = singleShow; uiControl(c)->Hide = singleHide; + uiControl(c)->ContainerShow = singleContainerShow; + uiControl(c)->ContainerHide = singleContainerHide; uiControl(c)->Enable = singleEnable; uiControl(c)->Disable = singleDisable; uiControl(c)->ContainerEnable = singleContainerEnable; diff --git a/redo/windows/window.c b/redo/windows/window.c index 4f1d7805..85cf0002 100644 --- a/redo/windows/window.c +++ b/redo/windows/window.c @@ -8,7 +8,6 @@ struct window { HWND hwnd; HMENU menubar; uiControl *child; - int hidden; BOOL shownOnce; int (*onClosing)(uiWindow *, void *); void *onClosingData; @@ -156,11 +155,9 @@ static void windowComputeChildSize(uiControl *c, intmax_t *x, intmax_t *y, intma } } -static int windowVisible(uiControl *c) +static int windowContainerVisible(uiControl *c) { - struct window *w = (struct window *) c; - - return !w->hidden; + complain("attempt to get container visibility state of uiWindow %p", c); } static void windowShow(uiControl *c) @@ -169,7 +166,6 @@ static void windowShow(uiControl *c) if (w->shownOnce) { ShowWindow(w->hwnd, SW_SHOW); - w->hidden = 0; return; } w->shownOnce = TRUE; @@ -178,7 +174,6 @@ static void windowShow(uiControl *c) ShowWindow(w->hwnd, nCmdShow); if (UpdateWindow(w->hwnd) == 0) logLastError("error calling UpdateWindow() after showing uiWindow for the first time in windowShow()"); - w->hidden = 0; } static void windowHide(uiControl *c) @@ -186,7 +181,16 @@ static void windowHide(uiControl *c) struct window *w = (struct window *) c; ShowWindow(w->hwnd, SW_HIDE); - w->hidden = 1; +} + +static void windowContainerShow(uiControl *c) +{ + complain("attempt to container show uiWindow %p", c); +} + +static void windowContainerHide(uiControl *c) +{ + complain("attempt to container hide uiWindow %p", c); } static void windowEnable(uiControl *c) @@ -357,9 +361,11 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar) uiControl(w)->QueueResize = windowQueueResize uiControl(w)->GetSizing = windowGetSizing; uiControl(w)->ComputeChildSize = windowComputeChildSize; - uiControl(w)->Visible = windowVisible; + uiControl(w)->ContainerVisible = windowContainerVisible; uiControl(w)->Show = windowShow; uiControl(w)->Hide = windowHide; + uiControl(w)->ContainerShow = windowContainerShow; + uiControl(w)->ContainerHide = windowContainerHide; uiControl(w)->Enable = windowEnable; uiControl(w)->Disable = windowDisable; uiControl(w)->ContainerEnable = windowContainerEnable;