Added a facility to the OS X port to be notified when a child's visibility has changed; this is necessary for implementing hiding and showing properly.
This commit is contained in:
parent
48546f6b44
commit
d54f7dd682
|
@ -396,6 +396,13 @@ static void uiBoxChildEdgeHuggingChanged(uiDarwinControl *c)
|
|||
uiDarwinControlDefaultHuggingPriority(uiBox, view)
|
||||
uiDarwinControlDefaultSetHuggingPriority(uiBox, view)
|
||||
|
||||
static void uiBoxChildVisibilityChanged(uiDarwinControl *c)
|
||||
{
|
||||
uiBox *b = uiBox(c);
|
||||
|
||||
[b->view establishOurConstraints];
|
||||
}
|
||||
|
||||
void uiBoxAppend(uiBox *b, uiControl *c, int stretchy)
|
||||
{
|
||||
// LONGTERM on other platforms
|
||||
|
|
|
@ -36,6 +36,11 @@ void uiDarwinControlSetHuggingPriority(uiDarwinControl *c, NSLayoutPriority prio
|
|||
(*(c->SetHuggingPriority))(c, priority, orientation);
|
||||
}
|
||||
|
||||
void uiDarwinControlChildVisibilityChanged(uiDarwinControl *c)
|
||||
{
|
||||
(*(c->ChildVisibilityChanged))(c);
|
||||
}
|
||||
|
||||
void uiDarwinSetControlFont(NSControl *c, NSControlSize size)
|
||||
{
|
||||
[c setFont:[NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:size]]];
|
||||
|
@ -68,3 +73,12 @@ void uiDarwinNotifyEdgeHuggingChanged(uiDarwinControl *c)
|
|||
if (parent != NULL)
|
||||
uiDarwinControlChildEdgeHuggingChanged(uiDarwinControl(parent));
|
||||
}
|
||||
|
||||
void uiDarwinNotifyVisibilityChanged(uiDarwinControl *c)
|
||||
{
|
||||
uiControl *parent;
|
||||
|
||||
parent = uiControlParent(uiControl(c));
|
||||
if (parent != NULL)
|
||||
uiDarwinControlChildVisibilityChanged(uiDarwinControl(parent));
|
||||
}
|
||||
|
|
|
@ -476,6 +476,13 @@ static void uiFormChildEdgeHuggingChanged(uiDarwinControl *c)
|
|||
uiDarwinControlDefaultHuggingPriority(uiForm, view)
|
||||
uiDarwinControlDefaultSetHuggingPriority(uiForm, view)
|
||||
|
||||
static void uiFormChildVisibilityChanged(uiDarwinControl *c)
|
||||
{
|
||||
uiForm *f = uiForm(c);
|
||||
|
||||
[f->view establishOurConstraints];
|
||||
}
|
||||
|
||||
void uiFormAppend(uiForm *f, const char *label, uiControl *c, int stretchy)
|
||||
{
|
||||
// LONGTERM on other platforms
|
||||
|
|
|
@ -590,6 +590,13 @@ static void uiGridChildEdgeHuggingChanged(uiDarwinControl *c)
|
|||
uiDarwinControlDefaultHuggingPriority(uiGrid, view)
|
||||
uiDarwinControlDefaultSetHuggingPriority(uiGrid, view)
|
||||
|
||||
static void uiGridChildVisibilityChanged(uiDarwinControl *c)
|
||||
{
|
||||
uiGrid *g = uiGrid(c);
|
||||
|
||||
[g->view establishOurConstraints];
|
||||
}
|
||||
|
||||
static gridChild *toChild(uiControl *c, int xspan, int yspan, int hexpand, uiAlign halign, int vexpand, uiAlign valign)
|
||||
{
|
||||
gridChild *gc;
|
||||
|
|
|
@ -117,6 +117,13 @@ static void uiGroupSetHuggingPriority(uiDarwinControl *c, NSLayoutPriority prior
|
|||
uiDarwinNotifyEdgeHuggingChanged(uiDarwinControl(g));
|
||||
}
|
||||
|
||||
static void uiGroupChildVisibilityChanged(uiDarwinControl *c)
|
||||
{
|
||||
uiGroup *g = uiGroup(c);
|
||||
|
||||
groupRelayout(g);
|
||||
}
|
||||
|
||||
char *uiGroupTitle(uiGroup *g)
|
||||
{
|
||||
return uiDarwinNSStringToText([g->box title]);
|
||||
|
|
|
@ -180,6 +180,13 @@ static void uiTabSetHuggingPriority(uiDarwinControl *c, NSLayoutPriority priorit
|
|||
uiDarwinNotifyEdgeHuggingChanged(uiDarwinControl(t));
|
||||
}
|
||||
|
||||
static void uiTabChildVisibilityChanged(uiDarwinControl *c)
|
||||
{
|
||||
uiTab *t = uiTab(c);
|
||||
|
||||
tabRelayout(t);
|
||||
}
|
||||
|
||||
void uiTabAppend(uiTab *t, const char *name, uiControl *child)
|
||||
{
|
||||
uiTabInsertAt(t, name, [t->pages count], child);
|
||||
|
|
|
@ -187,6 +187,13 @@ uiDarwinControlDefaultHuggingPriority(uiWindow, window)
|
|||
uiDarwinControlDefaultSetHuggingPriority(uiWindow, window)
|
||||
// end TODO
|
||||
|
||||
static void uiWindowChildVisibilityChanged(uiDarwinControl *c)
|
||||
{
|
||||
uiWindow *w = uiWindow(c);
|
||||
|
||||
windowRelayout(w);
|
||||
}
|
||||
|
||||
char *uiWindowTitle(uiWindow *w)
|
||||
{
|
||||
return uiDarwinNSStringToText([w->window title]);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "test.h"
|
||||
|
||||
// TODO add a test for childless windows
|
||||
// TODO add tests for contianers with all controls hidden
|
||||
|
||||
static uiGroup *newg(const char *n, int s)
|
||||
{
|
||||
|
|
16
ui_darwin.h
16
ui_darwin.h
|
@ -24,6 +24,7 @@ struct uiDarwinControl {
|
|||
void (*ChildEdgeHuggingChanged)(uiDarwinControl *);
|
||||
NSLayoutPriority (*HuggingPriority)(uiDarwinControl *, NSLayoutConstraintOrientation);
|
||||
void (*SetHuggingPriority)(uiDarwinControl *, NSLayoutPriority, NSLayoutConstraintOrientation);
|
||||
void (*ChildVisibilityChanged)(uiDarwinControl *);
|
||||
};
|
||||
#define uiDarwinControl(this) ((uiDarwinControl *) (this))
|
||||
// TODO document
|
||||
|
@ -34,6 +35,7 @@ _UI_EXTERN BOOL uiDarwinControlHugsBottom(uiDarwinControl *);
|
|||
_UI_EXTERN void uiDarwinControlChildEdgeHuggingChanged(uiDarwinControl *);
|
||||
_UI_EXTERN NSLayoutPriority uiDarwinControlHuggingPriority(uiDarwinControl *, NSLayoutConstraintOrientation);
|
||||
_UI_EXTERN void uiDarwinControlSetHuggingPriority(uiDarwinControl *, NSLayoutPriority, NSLayoutConstraintOrientation);
|
||||
_UI_EXTERN void uiDarwinControlChildVisibilityChanged(uiDarwinControl *);
|
||||
|
||||
#define uiDarwinControlDefaultDestroy(type, handlefield) \
|
||||
static void type ## Destroy(uiControl *c) \
|
||||
|
@ -72,12 +74,14 @@ _UI_EXTERN void uiDarwinControlSetHuggingPriority(uiDarwinControl *, NSLayoutPri
|
|||
{ \
|
||||
uiDarwinControl(c)->visible = YES; \
|
||||
[type(c)->handlefield setHidden:NO]; \
|
||||
uiDarwinNotifyVisibilityChanged(uiDarwinControl(c)); \
|
||||
}
|
||||
#define uiDarwinControlDefaultHide(type, handlefield) \
|
||||
static void type ## Hide(uiControl *c) \
|
||||
{ \
|
||||
uiDarwinControl(c)->visible = NO; \
|
||||
[type(c)->handlefield setHidden:YES]; \
|
||||
uiDarwinNotifyVisibilityChanged(uiDarwinControl(c)); \
|
||||
}
|
||||
#define uiDarwinControlDefaultEnabled(type, handlefield) \
|
||||
static int type ## Enabled(uiControl *c) \
|
||||
|
@ -102,7 +106,7 @@ _UI_EXTERN void uiDarwinControlSetHuggingPriority(uiDarwinControl *, NSLayoutPri
|
|||
if (uiDarwinShouldStopSyncEnableState(c, enabled)) \
|
||||
return; \
|
||||
if ([type(c)->handlefield respondsToSelector:@selector(setEnabled:)]) \
|
||||
[((id) type(c)->handlefield) setEnabled:enabled]; /* id cast to make compiler happy; thanks mikeash in irc.freenode.net/#macdev */ \
|
||||
[((id) (type(c)->handlefield)) setEnabled:enabled]; /* id cast to make compiler happy; thanks mikeash in irc.freenode.net/#macdev */ \
|
||||
}
|
||||
#define uiDarwinControlDefaultSetSuperview(type, handlefield) \
|
||||
static void type ## SetSuperview(uiDarwinControl *c, NSView *superview) \
|
||||
|
@ -138,6 +142,11 @@ _UI_EXTERN void uiDarwinControlSetHuggingPriority(uiDarwinControl *, NSLayoutPri
|
|||
{ \
|
||||
[type(c)->handlefield setContentHuggingPriority:priority forOrientation:orientation]; \
|
||||
}
|
||||
#define uiDarwinControlDefaultChildVisibilityChanged(type, handlefield) \
|
||||
static void type ## ChildVisibilityChanged(uiDarwinControl *c) \
|
||||
{ \
|
||||
/* do nothing */ \
|
||||
}
|
||||
|
||||
#define uiDarwinControlAllDefaultsExceptDestroy(type, handlefield) \
|
||||
uiDarwinControlDefaultHandle(type, handlefield) \
|
||||
|
@ -156,7 +165,8 @@ _UI_EXTERN void uiDarwinControlSetHuggingPriority(uiDarwinControl *, NSLayoutPri
|
|||
uiDarwinControlDefaultHugsBottom(type, handlefield) \
|
||||
uiDarwinControlDefaultChildEdgeHuggingChanged(type, handlefield) \
|
||||
uiDarwinControlDefaultHuggingPriority(type, handlefield) \
|
||||
uiDarwinControlDefaultSetHuggingPriority(type, handlefield)
|
||||
uiDarwinControlDefaultSetHuggingPriority(type, handlefield) \
|
||||
uiDarwinControlDefaultChildVisibilityChanged(type, handlefield)
|
||||
|
||||
#define uiDarwinControlAllDefaults(type, handlefield) \
|
||||
uiDarwinControlDefaultDestroy(type, handlefield) \
|
||||
|
@ -183,6 +193,7 @@ _UI_EXTERN void uiDarwinControlSetHuggingPriority(uiDarwinControl *, NSLayoutPri
|
|||
uiDarwinControl(var)->ChildEdgeHuggingChanged = type ## ChildEdgeHuggingChanged; \
|
||||
uiDarwinControl(var)->HuggingPriority = type ## HuggingPriority; \
|
||||
uiDarwinControl(var)->SetHuggingPriority = type ## SetHuggingPriority; \
|
||||
uiDarwinControl(var)->ChildVisibilityChanged = type ## ChildVisibilityChanged; \
|
||||
uiDarwinControl(var)->visible = YES; \
|
||||
uiDarwinControl(var)->enabled = YES;
|
||||
// TODO document
|
||||
|
@ -199,6 +210,7 @@ _UI_EXTERN BOOL uiDarwinShouldStopSyncEnableState(uiDarwinControl *, BOOL);
|
|||
|
||||
// TODO document
|
||||
_UI_EXTERN void uiDarwinNotifyEdgeHuggingChanged(uiDarwinControl *);
|
||||
_UI_EXTERN void uiDarwinNotifyVisibilityChanged(uiDarwinControl *c);
|
||||
|
||||
// TODO document
|
||||
// TODO document that values should not be cached
|
||||
|
|
Loading…
Reference in New Issue