Set up work for rearranging control layout to be depth-first and to relayout the entire window on a change.

This commit is contained in:
Pietro Gagliardi 2015-08-18 19:57:16 -04:00
parent b78693f21a
commit 2cf0707c3e
4 changed files with 24 additions and 6 deletions

View File

@ -42,6 +42,21 @@ uiControl *uiControlParent(uiControl *c)
return cb->parent;
}
// returns self if self is a window
uiControl *toplevelOwning(uiControl *c)
{
struct controlBase *cb;
for (;;) {
if (uiIsA(c, uiWindowType(), 0) != NULL)
return c;
cb = controlBase(c);
if (cb->parent == NULL)
return NULL;
c = cb->parent;
}
}
static void controlUpdateState(uiControl *);
void uiControlSetParent(uiControl *c, uiControl *parent)

View File

@ -10,14 +10,15 @@ uintmax_t uiDarwinControlType(void)
return type_uiDarwinControl;
}
void uiDarwinControlRelayoutParent(uiDarwinControl *c)
void uiDarwinControlTriggerRelayout(uiDarwinControl *c)
{
uiControl *p;
p = uiControlParent(uiControl(c));
if (p == NULL)
p = toplevelOwning(uiControl(c));
if (p == NULL) // not in a window
return;
(*(uiDarwinControl(p)->Relayout))(uiDarwinControl(p));
c = uiDarwinControl(p);
(*(c->Relayout))(uiDarwinControl(c));
}
void osCommitShow(uiControl *c)

View File

@ -15,7 +15,7 @@ struct uiDarwinControl {
_UI_EXTERN uintmax_t uiDarwinControlType(void);
#define uiDarwinControl(this) ((uiDarwinControl *) uiIsA((this), uiDarwinControlType(), 1))
// TODO document
_UI_EXTERN void uiDarwinControlRelayoutParent(uiDarwinControl *);
_UI_EXTERN void uiDarwinControlTriggerRelayout(uiDarwinControl *);
// TODO document
#define uiDarwinDefineControlWithOnDestroy(type, typefn, handlefield, onDestroy) \
@ -42,7 +42,7 @@ _UI_EXTERN void uiDarwinControlRelayoutParent(uiDarwinControl *);
} \
static void _ ## type ## Relayout(uiDarwinControl *c) \
{ \
uiDarwinControlRelayoutParent(uiDarwinControl(c)); \
/* do nothing */ \
}
#define uiDarwinDefineControl(type, typefn, handlefield) \

View File

@ -15,6 +15,8 @@ extern void uiFree(void *);
extern void complain(const char *, ...);
extern uiControl *toplevelOwning(uiControl *);
extern void osCommitShow(uiControl *);
extern void osCommitHide(uiControl *);
extern void osCommitEnable(uiControl *);