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**
|
||||
* 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**
|
||||
* `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 (*LayoutRect)(uiWindowsControl *c, RECT *r);
|
||||
void (*AssignControlIDZOrder)(uiWindowsControl *, LONG_PTR *, HWND *);
|
||||
void (*ChildVisibilityChanged)(uiWindowsControl *);
|
||||
};
|
||||
#define uiWindowsControl(this) ((uiWindowsControl *) (this))
|
||||
// TODO document
|
||||
|
@ -35,6 +36,7 @@ _UI_EXTERN void uiWindowsControlMinimumSize(uiWindowsControl *, int *, int *);
|
|||
_UI_EXTERN void uiWindowsControlMinimumSizeChanged(uiWindowsControl *);
|
||||
_UI_EXTERN void uiWindowsControlLayoutRect(uiWindowsControl *, RECT *);
|
||||
_UI_EXTERN void uiWindowsControlAssignControlIDZOrder(uiWindowsControl *, LONG_PTR *, HWND *);
|
||||
_UI_EXTERN void uiWindowsControlChildVisibilityChanged(uiWindowsControl *);
|
||||
|
||||
// TODO document
|
||||
#define uiWindowsControlDefaultDestroy(type) \
|
||||
|
@ -74,12 +76,14 @@ _UI_EXTERN void uiWindowsControlAssignControlIDZOrder(uiWindowsControl *, LONG_P
|
|||
{ \
|
||||
uiWindowsControl(c)->visible = 1; \
|
||||
ShowWindow(type(c)->hwnd, SW_SHOW); \
|
||||
uiWindowsControlNotifyVisibilityChanged(uiWindowsControl(c)); \
|
||||
}
|
||||
#define uiWindowsControlDefaultHide(type) \
|
||||
static void type ## Hide(uiControl *c) \
|
||||
{ \
|
||||
uiWindowsControl(c)->visible = 0; \
|
||||
ShowWindow(type(c)->hwnd, SW_HIDE); \
|
||||
uiWindowsControlNotifyVisibilityChanged(uiWindowsControl(c)); \
|
||||
}
|
||||
#define uiWindowsControlDefaultEnabled(type) \
|
||||
static int type ## Enabled(uiControl *c) \
|
||||
|
@ -131,6 +135,11 @@ _UI_EXTERN void uiWindowsControlAssignControlIDZOrder(uiWindowsControl *, LONG_P
|
|||
{ \
|
||||
uiWindowsEnsureAssignControlIDZOrder(type(c)->hwnd, controlID, insertAfter); \
|
||||
}
|
||||
#define uiWindowsControlDefaultChildVisibilityChanged(type) \
|
||||
static void type ## ChildVisibilityChanged(uiWindowsControl *c) \
|
||||
{ \
|
||||
/* do nothing */ \
|
||||
}
|
||||
|
||||
#define uiWindowsControlAllDefaultsExceptDestroy(type) \
|
||||
uiWindowsControlDefaultHandle(type) \
|
||||
|
@ -147,7 +156,8 @@ _UI_EXTERN void uiWindowsControlAssignControlIDZOrder(uiWindowsControl *, LONG_P
|
|||
uiWindowsControlDefaultSetParentHWND(type) \
|
||||
uiWindowsControlDefaultMinimumSizeChanged(type) \
|
||||
uiWindowsControlDefaultLayoutRect(type) \
|
||||
uiWindowsControlDefaultAssignControlIDZOrder(type)
|
||||
uiWindowsControlDefaultAssignControlIDZOrder(type) \
|
||||
uiWindowsControlDefaultChildVisibilityChanged(type)
|
||||
|
||||
#define uiWindowsControlAllDefaults(type) \
|
||||
uiWindowsControlDefaultDestroy(type) \
|
||||
|
@ -173,6 +183,7 @@ _UI_EXTERN void uiWindowsControlAssignControlIDZOrder(uiWindowsControl *, LONG_P
|
|||
uiWindowsControl(var)->MinimumSizeChanged = type ## MinimumSizeChanged; \
|
||||
uiWindowsControl(var)->LayoutRect = type ## LayoutRect; \
|
||||
uiWindowsControl(var)->AssignControlIDZOrder = type ## AssignControlIDZOrder; \
|
||||
uiWindowsControl(var)->ChildVisibilityChanged = type ## ChildVisibilityChanged; \
|
||||
uiWindowsControl(var)->visible = 1; \
|
||||
uiWindowsControl(var)->enabled = 1;
|
||||
// TODO document
|
||||
|
@ -246,6 +257,9 @@ _UI_EXTERN void uiWindowsControlAssignSoleControlIDZOrder(uiWindowsControl *);
|
|||
// TODO document
|
||||
_UI_EXTERN BOOL uiWindowsShouldStopSyncEnableState(uiWindowsControl *c, int enabled);
|
||||
|
||||
// TODO document
|
||||
_UI_EXTERN void uiWindowsControlNotifyVisibilityChanged(uiWindowsControl *c);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -226,6 +226,12 @@ static void uiBoxMinimumSizeChanged(uiWindowsControl *c)
|
|||
uiWindowsControlDefaultLayoutRect(uiBox)
|
||||
uiWindowsControlDefaultAssignControlIDZOrder(uiBox)
|
||||
|
||||
static void uiBoxChildVisibilityChanged(uiWindowsControl *c)
|
||||
{
|
||||
// TODO eliminate the redundancy
|
||||
uiWindowsControlMinimumSizeChanged(c);
|
||||
}
|
||||
|
||||
static void boxArrangeChildren(uiBox *b)
|
||||
{
|
||||
LONG_PTR controlID;
|
||||
|
|
|
@ -21,6 +21,7 @@ void uiWindowsControlMinimumSizeChanged(uiWindowsControl *c)
|
|||
(*(c->MinimumSizeChanged))(c);
|
||||
}
|
||||
|
||||
// TODO get rid of this
|
||||
void uiWindowsControlLayoutRect(uiWindowsControl *c, RECT *r)
|
||||
{
|
||||
(*(c->LayoutRect))(c, r);
|
||||
|
@ -31,6 +32,11 @@ void uiWindowsControlAssignControlIDZOrder(uiWindowsControl *c, LONG_PTR *contro
|
|||
(*(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 hwnd;
|
||||
|
@ -106,3 +112,10 @@ void uiWindowsControlContinueMinimumSizeChanged(uiWindowsControl *c)
|
|||
if (parent != NULL)
|
||||
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)
|
||||
uiWindowsControlDefaultAssignControlIDZOrder(uiForm)
|
||||
|
||||
static void uiFormChildVisibilityChanged(uiWindowsControl *c)
|
||||
{
|
||||
// TODO eliminate the redundancy
|
||||
uiWindowsControlMinimumSizeChanged(c);
|
||||
}
|
||||
|
||||
static void formArrangeChildren(uiForm *f)
|
||||
{
|
||||
LONG_PTR controlID;
|
||||
|
|
|
@ -422,6 +422,12 @@ static void uiGridMinimumSizeChanged(uiWindowsControl *c)
|
|||
uiWindowsControlDefaultLayoutRect(uiGrid)
|
||||
uiWindowsControlDefaultAssignControlIDZOrder(uiGrid)
|
||||
|
||||
static void uiGridChildVisibilityChanged(uiWindowsControl *c)
|
||||
{
|
||||
// TODO eliminate the redundancy
|
||||
uiWindowsControlMinimumSizeChanged(c);
|
||||
}
|
||||
|
||||
// must have called gridRecomputeMinMax() first
|
||||
static void gridArrangeChildren(uiGrid *g)
|
||||
{
|
||||
|
|
|
@ -121,6 +121,12 @@ static void uiGroupMinimumSizeChanged(uiWindowsControl *c)
|
|||
uiWindowsControlDefaultLayoutRect(uiGroup)
|
||||
uiWindowsControlDefaultAssignControlIDZOrder(uiGroup)
|
||||
|
||||
static void uiGroupChildVisibilityChanged(uiWindowsControl *c)
|
||||
{
|
||||
// TODO eliminate the redundancy
|
||||
uiWindowsControlMinimumSizeChanged(c);
|
||||
}
|
||||
|
||||
char *uiGroupTitle(uiGroup *g)
|
||||
{
|
||||
return uiWindowsWindowText(g->hwnd);
|
||||
|
|
|
@ -166,6 +166,12 @@ static void uiTabMinimumSizeChanged(uiWindowsControl *c)
|
|||
uiWindowsControlDefaultLayoutRect(uiTab)
|
||||
uiWindowsControlDefaultAssignControlIDZOrder(uiTab)
|
||||
|
||||
static void uiTabChildVisibilityChanged(uiWindowsControl *c)
|
||||
{
|
||||
// TODO eliminate the redundancy
|
||||
uiWindowsControlMinimumSizeChanged(c);
|
||||
}
|
||||
|
||||
static void tabArrangePages(uiTab *t)
|
||||
{
|
||||
LONG_PTR controlID = 100;
|
||||
|
|
|
@ -260,6 +260,12 @@ static void uiWindowLayoutRect(uiWindowsControl *c, RECT *r)
|
|||
|
||||
uiWindowsControlDefaultAssignControlIDZOrder(uiWindow)
|
||||
|
||||
static void uiWindowChildVisibilityChanged(uiWindowsControl *c)
|
||||
{
|
||||
// TODO eliminate the redundancy
|
||||
uiWindowsControlMinimumSizeChanged(c);
|
||||
}
|
||||
|
||||
char *uiWindowTitle(uiWindow *w)
|
||||
{
|
||||
return uiWindowsWindowText(w->hwnd);
|
||||
|
|
Loading…
Reference in New Issue