Implemented visibility change detection on Windows. Now to refine the actual implementation of hidden controls.
This commit is contained in:
parent
6e5cf97623
commit
997c8aac35
|
@ -20,6 +20,8 @@ This README is being written.<br>
|
||||||
|
|
||||||
* **14 June 2016**
|
* **14 June 2016**
|
||||||
* uiDarwinControl now has a `ChildVisibilityChanged()` method and a corresponding `NotifyVisibilityChanged()` function that is called by the default show/hide handlers. This is used to make visibility changes work on OS X; uiBox, uiForm, and uiGrid all respect these now.
|
* uiDarwinControl now has a `ChildVisibilityChanged()` method and a corresponding `NotifyVisibilityChanged()` function that is called by the default show/hide handlers. This is used to make visibility changes work on OS X; uiBox, uiForm, and uiGrid all respect these now.
|
||||||
|
* The same has been done on the Windows side as well.
|
||||||
|
* Hiding a control in a uiForm now hides its label on all platforms.
|
||||||
|
|
||||||
* **13 June 2016**
|
* **13 June 2016**
|
||||||
* `intmax_t` and `uintmax_t` are no longer used for libui API functions; now we use `int`. This should make things much easier for bindings. `int` should be at least 32 bits wide; this should be sufficient for all but the most extreme cases.
|
* `intmax_t` and `uintmax_t` are no longer used for libui API functions; now we use `int`. This should make things much easier for bindings. `int` should be at least 32 bits wide; this should be sufficient for all but the most extreme cases.
|
||||||
|
|
16
ui_windows.h
16
ui_windows.h
|
@ -26,6 +26,7 @@ struct uiWindowsControl {
|
||||||
void (*MinimumSizeChanged)(uiWindowsControl *);
|
void (*MinimumSizeChanged)(uiWindowsControl *);
|
||||||
void (*LayoutRect)(uiWindowsControl *c, RECT *r);
|
void (*LayoutRect)(uiWindowsControl *c, RECT *r);
|
||||||
void (*AssignControlIDZOrder)(uiWindowsControl *, LONG_PTR *, HWND *);
|
void (*AssignControlIDZOrder)(uiWindowsControl *, LONG_PTR *, HWND *);
|
||||||
|
void (*ChildVisibilityChanged)(uiWindowsControl *);
|
||||||
};
|
};
|
||||||
#define uiWindowsControl(this) ((uiWindowsControl *) (this))
|
#define uiWindowsControl(this) ((uiWindowsControl *) (this))
|
||||||
// TODO document
|
// TODO document
|
||||||
|
@ -35,6 +36,7 @@ _UI_EXTERN void uiWindowsControlMinimumSize(uiWindowsControl *, int *, int *);
|
||||||
_UI_EXTERN void uiWindowsControlMinimumSizeChanged(uiWindowsControl *);
|
_UI_EXTERN void uiWindowsControlMinimumSizeChanged(uiWindowsControl *);
|
||||||
_UI_EXTERN void uiWindowsControlLayoutRect(uiWindowsControl *, RECT *);
|
_UI_EXTERN void uiWindowsControlLayoutRect(uiWindowsControl *, RECT *);
|
||||||
_UI_EXTERN void uiWindowsControlAssignControlIDZOrder(uiWindowsControl *, LONG_PTR *, HWND *);
|
_UI_EXTERN void uiWindowsControlAssignControlIDZOrder(uiWindowsControl *, LONG_PTR *, HWND *);
|
||||||
|
_UI_EXTERN void uiWindowsControlChildVisibilityChanged(uiWindowsControl *);
|
||||||
|
|
||||||
// TODO document
|
// TODO document
|
||||||
#define uiWindowsControlDefaultDestroy(type) \
|
#define uiWindowsControlDefaultDestroy(type) \
|
||||||
|
@ -74,12 +76,14 @@ _UI_EXTERN void uiWindowsControlAssignControlIDZOrder(uiWindowsControl *, LONG_P
|
||||||
{ \
|
{ \
|
||||||
uiWindowsControl(c)->visible = 1; \
|
uiWindowsControl(c)->visible = 1; \
|
||||||
ShowWindow(type(c)->hwnd, SW_SHOW); \
|
ShowWindow(type(c)->hwnd, SW_SHOW); \
|
||||||
|
uiWindowsControlNotifyVisibilityChanged(uiWindowsControl(c)); \
|
||||||
}
|
}
|
||||||
#define uiWindowsControlDefaultHide(type) \
|
#define uiWindowsControlDefaultHide(type) \
|
||||||
static void type ## Hide(uiControl *c) \
|
static void type ## Hide(uiControl *c) \
|
||||||
{ \
|
{ \
|
||||||
uiWindowsControl(c)->visible = 0; \
|
uiWindowsControl(c)->visible = 0; \
|
||||||
ShowWindow(type(c)->hwnd, SW_HIDE); \
|
ShowWindow(type(c)->hwnd, SW_HIDE); \
|
||||||
|
uiWindowsControlNotifyVisibilityChanged(uiWindowsControl(c)); \
|
||||||
}
|
}
|
||||||
#define uiWindowsControlDefaultEnabled(type) \
|
#define uiWindowsControlDefaultEnabled(type) \
|
||||||
static int type ## Enabled(uiControl *c) \
|
static int type ## Enabled(uiControl *c) \
|
||||||
|
@ -131,6 +135,11 @@ _UI_EXTERN void uiWindowsControlAssignControlIDZOrder(uiWindowsControl *, LONG_P
|
||||||
{ \
|
{ \
|
||||||
uiWindowsEnsureAssignControlIDZOrder(type(c)->hwnd, controlID, insertAfter); \
|
uiWindowsEnsureAssignControlIDZOrder(type(c)->hwnd, controlID, insertAfter); \
|
||||||
}
|
}
|
||||||
|
#define uiWindowsControlDefaultChildVisibilityChanged(type) \
|
||||||
|
static void type ## ChildVisibilityChanged(uiWindowsControl *c) \
|
||||||
|
{ \
|
||||||
|
/* do nothing */ \
|
||||||
|
}
|
||||||
|
|
||||||
#define uiWindowsControlAllDefaultsExceptDestroy(type) \
|
#define uiWindowsControlAllDefaultsExceptDestroy(type) \
|
||||||
uiWindowsControlDefaultHandle(type) \
|
uiWindowsControlDefaultHandle(type) \
|
||||||
|
@ -147,7 +156,8 @@ _UI_EXTERN void uiWindowsControlAssignControlIDZOrder(uiWindowsControl *, LONG_P
|
||||||
uiWindowsControlDefaultSetParentHWND(type) \
|
uiWindowsControlDefaultSetParentHWND(type) \
|
||||||
uiWindowsControlDefaultMinimumSizeChanged(type) \
|
uiWindowsControlDefaultMinimumSizeChanged(type) \
|
||||||
uiWindowsControlDefaultLayoutRect(type) \
|
uiWindowsControlDefaultLayoutRect(type) \
|
||||||
uiWindowsControlDefaultAssignControlIDZOrder(type)
|
uiWindowsControlDefaultAssignControlIDZOrder(type) \
|
||||||
|
uiWindowsControlDefaultChildVisibilityChanged(type)
|
||||||
|
|
||||||
#define uiWindowsControlAllDefaults(type) \
|
#define uiWindowsControlAllDefaults(type) \
|
||||||
uiWindowsControlDefaultDestroy(type) \
|
uiWindowsControlDefaultDestroy(type) \
|
||||||
|
@ -173,6 +183,7 @@ _UI_EXTERN void uiWindowsControlAssignControlIDZOrder(uiWindowsControl *, LONG_P
|
||||||
uiWindowsControl(var)->MinimumSizeChanged = type ## MinimumSizeChanged; \
|
uiWindowsControl(var)->MinimumSizeChanged = type ## MinimumSizeChanged; \
|
||||||
uiWindowsControl(var)->LayoutRect = type ## LayoutRect; \
|
uiWindowsControl(var)->LayoutRect = type ## LayoutRect; \
|
||||||
uiWindowsControl(var)->AssignControlIDZOrder = type ## AssignControlIDZOrder; \
|
uiWindowsControl(var)->AssignControlIDZOrder = type ## AssignControlIDZOrder; \
|
||||||
|
uiWindowsControl(var)->ChildVisibilityChanged = type ## ChildVisibilityChanged; \
|
||||||
uiWindowsControl(var)->visible = 1; \
|
uiWindowsControl(var)->visible = 1; \
|
||||||
uiWindowsControl(var)->enabled = 1;
|
uiWindowsControl(var)->enabled = 1;
|
||||||
// TODO document
|
// TODO document
|
||||||
|
@ -246,6 +257,9 @@ _UI_EXTERN void uiWindowsControlAssignSoleControlIDZOrder(uiWindowsControl *);
|
||||||
// TODO document
|
// TODO document
|
||||||
_UI_EXTERN BOOL uiWindowsShouldStopSyncEnableState(uiWindowsControl *c, int enabled);
|
_UI_EXTERN BOOL uiWindowsShouldStopSyncEnableState(uiWindowsControl *c, int enabled);
|
||||||
|
|
||||||
|
// TODO document
|
||||||
|
_UI_EXTERN void uiWindowsControlNotifyVisibilityChanged(uiWindowsControl *c);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -226,6 +226,12 @@ static void uiBoxMinimumSizeChanged(uiWindowsControl *c)
|
||||||
uiWindowsControlDefaultLayoutRect(uiBox)
|
uiWindowsControlDefaultLayoutRect(uiBox)
|
||||||
uiWindowsControlDefaultAssignControlIDZOrder(uiBox)
|
uiWindowsControlDefaultAssignControlIDZOrder(uiBox)
|
||||||
|
|
||||||
|
static void uiBoxChildVisibilityChanged(uiWindowsControl *c)
|
||||||
|
{
|
||||||
|
// TODO eliminate the redundancy
|
||||||
|
uiWindowsControlMinimumSizeChanged(c);
|
||||||
|
}
|
||||||
|
|
||||||
static void boxArrangeChildren(uiBox *b)
|
static void boxArrangeChildren(uiBox *b)
|
||||||
{
|
{
|
||||||
LONG_PTR controlID;
|
LONG_PTR controlID;
|
||||||
|
|
|
@ -21,6 +21,7 @@ void uiWindowsControlMinimumSizeChanged(uiWindowsControl *c)
|
||||||
(*(c->MinimumSizeChanged))(c);
|
(*(c->MinimumSizeChanged))(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO get rid of this
|
||||||
void uiWindowsControlLayoutRect(uiWindowsControl *c, RECT *r)
|
void uiWindowsControlLayoutRect(uiWindowsControl *c, RECT *r)
|
||||||
{
|
{
|
||||||
(*(c->LayoutRect))(c, r);
|
(*(c->LayoutRect))(c, r);
|
||||||
|
@ -31,6 +32,11 @@ void uiWindowsControlAssignControlIDZOrder(uiWindowsControl *c, LONG_PTR *contro
|
||||||
(*(c->AssignControlIDZOrder))(c, controlID, insertAfter);
|
(*(c->AssignControlIDZOrder))(c, controlID, insertAfter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void uiWindowsControlChildVisibilityChanged(uiWindowsControl *c)
|
||||||
|
{
|
||||||
|
(*(c->ChildVisibilityChanged))(c);
|
||||||
|
}
|
||||||
|
|
||||||
HWND uiWindowsEnsureCreateControlHWND(DWORD dwExStyle, LPCWSTR lpClassName, LPCWSTR lpWindowName, DWORD dwStyle, HINSTANCE hInstance, LPVOID lpParam, BOOL useStandardControlFont)
|
HWND uiWindowsEnsureCreateControlHWND(DWORD dwExStyle, LPCWSTR lpClassName, LPCWSTR lpWindowName, DWORD dwStyle, HINSTANCE hInstance, LPVOID lpParam, BOOL useStandardControlFont)
|
||||||
{
|
{
|
||||||
HWND hwnd;
|
HWND hwnd;
|
||||||
|
@ -106,3 +112,10 @@ void uiWindowsControlContinueMinimumSizeChanged(uiWindowsControl *c)
|
||||||
if (parent != NULL)
|
if (parent != NULL)
|
||||||
uiWindowsControlMinimumSizeChanged(uiWindowsControl(parent));
|
uiWindowsControlMinimumSizeChanged(uiWindowsControl(parent));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO rename this nad the OS X this and hugging ones to NotifyChild
|
||||||
|
void uiWindowsControlNotifyVisibilityChanged(uiWindowsControl *c)
|
||||||
|
{
|
||||||
|
// TODO we really need to figure this out; the duplication is a mess
|
||||||
|
uiWindowsControlContinueMinimumSizeChanged(c);
|
||||||
|
}
|
||||||
|
|
|
@ -222,6 +222,12 @@ static void uiFormMinimumSizeChanged(uiWindowsControl *c)
|
||||||
uiWindowsControlDefaultLayoutRect(uiForm)
|
uiWindowsControlDefaultLayoutRect(uiForm)
|
||||||
uiWindowsControlDefaultAssignControlIDZOrder(uiForm)
|
uiWindowsControlDefaultAssignControlIDZOrder(uiForm)
|
||||||
|
|
||||||
|
static void uiFormChildVisibilityChanged(uiWindowsControl *c)
|
||||||
|
{
|
||||||
|
// TODO eliminate the redundancy
|
||||||
|
uiWindowsControlMinimumSizeChanged(c);
|
||||||
|
}
|
||||||
|
|
||||||
static void formArrangeChildren(uiForm *f)
|
static void formArrangeChildren(uiForm *f)
|
||||||
{
|
{
|
||||||
LONG_PTR controlID;
|
LONG_PTR controlID;
|
||||||
|
|
|
@ -422,6 +422,12 @@ static void uiGridMinimumSizeChanged(uiWindowsControl *c)
|
||||||
uiWindowsControlDefaultLayoutRect(uiGrid)
|
uiWindowsControlDefaultLayoutRect(uiGrid)
|
||||||
uiWindowsControlDefaultAssignControlIDZOrder(uiGrid)
|
uiWindowsControlDefaultAssignControlIDZOrder(uiGrid)
|
||||||
|
|
||||||
|
static void uiGridChildVisibilityChanged(uiWindowsControl *c)
|
||||||
|
{
|
||||||
|
// TODO eliminate the redundancy
|
||||||
|
uiWindowsControlMinimumSizeChanged(c);
|
||||||
|
}
|
||||||
|
|
||||||
// must have called gridRecomputeMinMax() first
|
// must have called gridRecomputeMinMax() first
|
||||||
static void gridArrangeChildren(uiGrid *g)
|
static void gridArrangeChildren(uiGrid *g)
|
||||||
{
|
{
|
||||||
|
|
|
@ -121,6 +121,12 @@ static void uiGroupMinimumSizeChanged(uiWindowsControl *c)
|
||||||
uiWindowsControlDefaultLayoutRect(uiGroup)
|
uiWindowsControlDefaultLayoutRect(uiGroup)
|
||||||
uiWindowsControlDefaultAssignControlIDZOrder(uiGroup)
|
uiWindowsControlDefaultAssignControlIDZOrder(uiGroup)
|
||||||
|
|
||||||
|
static void uiGroupChildVisibilityChanged(uiWindowsControl *c)
|
||||||
|
{
|
||||||
|
// TODO eliminate the redundancy
|
||||||
|
uiWindowsControlMinimumSizeChanged(c);
|
||||||
|
}
|
||||||
|
|
||||||
char *uiGroupTitle(uiGroup *g)
|
char *uiGroupTitle(uiGroup *g)
|
||||||
{
|
{
|
||||||
return uiWindowsWindowText(g->hwnd);
|
return uiWindowsWindowText(g->hwnd);
|
||||||
|
|
|
@ -166,6 +166,12 @@ static void uiTabMinimumSizeChanged(uiWindowsControl *c)
|
||||||
uiWindowsControlDefaultLayoutRect(uiTab)
|
uiWindowsControlDefaultLayoutRect(uiTab)
|
||||||
uiWindowsControlDefaultAssignControlIDZOrder(uiTab)
|
uiWindowsControlDefaultAssignControlIDZOrder(uiTab)
|
||||||
|
|
||||||
|
static void uiTabChildVisibilityChanged(uiWindowsControl *c)
|
||||||
|
{
|
||||||
|
// TODO eliminate the redundancy
|
||||||
|
uiWindowsControlMinimumSizeChanged(c);
|
||||||
|
}
|
||||||
|
|
||||||
static void tabArrangePages(uiTab *t)
|
static void tabArrangePages(uiTab *t)
|
||||||
{
|
{
|
||||||
LONG_PTR controlID = 100;
|
LONG_PTR controlID = 100;
|
||||||
|
|
|
@ -260,6 +260,12 @@ static void uiWindowLayoutRect(uiWindowsControl *c, RECT *r)
|
||||||
|
|
||||||
uiWindowsControlDefaultAssignControlIDZOrder(uiWindow)
|
uiWindowsControlDefaultAssignControlIDZOrder(uiWindow)
|
||||||
|
|
||||||
|
static void uiWindowChildVisibilityChanged(uiWindowsControl *c)
|
||||||
|
{
|
||||||
|
// TODO eliminate the redundancy
|
||||||
|
uiWindowsControlMinimumSizeChanged(c);
|
||||||
|
}
|
||||||
|
|
||||||
char *uiWindowTitle(uiWindow *w)
|
char *uiWindowTitle(uiWindow *w)
|
||||||
{
|
{
|
||||||
return uiWindowsWindowText(w->hwnd);
|
return uiWindowsWindowText(w->hwnd);
|
||||||
|
|
Loading…
Reference in New Issue