Set up a system by which a control can trigger the relayout of its parents. Not quite perfect yet.
This commit is contained in:
parent
b9b8ab7552
commit
77a293b699
|
@ -35,6 +35,13 @@ uintptr_t uiControlHandle(uiControl *c)
|
||||||
return (*(c->Handle))(c);
|
return (*(c->Handle))(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uiControl *uiControlParent(uiControl *c)
|
||||||
|
{
|
||||||
|
struct controlBase *cb = controlBase(c);
|
||||||
|
|
||||||
|
return cb->parent;
|
||||||
|
}
|
||||||
|
|
||||||
static void controlUpdateState(uiControl *);
|
static void controlUpdateState(uiControl *);
|
||||||
|
|
||||||
void uiControlSetParent(uiControl *c, uiControl *parent)
|
void uiControlSetParent(uiControl *c, uiControl *parent)
|
||||||
|
|
|
@ -190,6 +190,13 @@ static void relayout(uiBox *b)
|
||||||
|
|
||||||
[metrics release];
|
[metrics release];
|
||||||
[views release];
|
[views release];
|
||||||
|
|
||||||
|
uiDarwinControlRelayoutParent(uiControl(b));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void boxRelayout(uiDarwinControl *c)
|
||||||
|
{
|
||||||
|
relayout(uiBox(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiBoxAppend(uiBox *b, uiControl *c, int stretchy)
|
void uiBoxAppend(uiBox *b, uiControl *c, int stretchy)
|
||||||
|
@ -274,6 +281,7 @@ static uiBox *finishNewBox(BOOL vertical)
|
||||||
setHuggingPri(b->noStretchyView, NSLayoutPriorityDefaultLow, NSLayoutConstraintOrientationVertical);
|
setHuggingPri(b->noStretchyView, NSLayoutPriorityDefaultLow, NSLayoutConstraintOrientationVertical);
|
||||||
|
|
||||||
uiDarwinFinishNewControl(b, uiBox);
|
uiDarwinFinishNewControl(b, uiBox);
|
||||||
|
uiDarwinControl(b)->Relayout = boxRelayout;
|
||||||
|
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,16 @@ uintmax_t uiDarwinControlType(void)
|
||||||
return type_uiDarwinControl;
|
return type_uiDarwinControl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void uiDarwinControlRelayoutParent(uiDarwinControl *c)
|
||||||
|
{
|
||||||
|
uiControl *p;
|
||||||
|
|
||||||
|
p = uiControlParent(uiControl(c));
|
||||||
|
if (p == NULL)
|
||||||
|
return;
|
||||||
|
(*(uiDarwinControl(p)->Relayout))(p);
|
||||||
|
}
|
||||||
|
|
||||||
void osCommitShow(uiControl *c)
|
void osCommitShow(uiControl *c)
|
||||||
{
|
{
|
||||||
NSView *view;
|
NSView *view;
|
||||||
|
|
|
@ -61,6 +61,7 @@ _UI_EXTERN uintmax_t uiControlType(void);
|
||||||
#define uiControl(this) ((uiControl *) uiIsA((this), uiControlType(), 1))
|
#define uiControl(this) ((uiControl *) uiIsA((this), uiControlType(), 1))
|
||||||
_UI_EXTERN void uiControlDestroy(uiControl *);
|
_UI_EXTERN void uiControlDestroy(uiControl *);
|
||||||
_UI_EXTERN uintptr_t uiControlHandle(uiControl *);
|
_UI_EXTERN uintptr_t uiControlHandle(uiControl *);
|
||||||
|
_UI_EXTERN uiControl *uiControlParent(uiControl *);
|
||||||
_UI_EXTERN void uiControlSetParent(uiControl *, uiControl *);
|
_UI_EXTERN void uiControlSetParent(uiControl *, uiControl *);
|
||||||
_UI_EXTERN void uiControlShow(uiControl *);
|
_UI_EXTERN void uiControlShow(uiControl *);
|
||||||
_UI_EXTERN void uiControlHide(uiControl *);
|
_UI_EXTERN void uiControlHide(uiControl *);
|
||||||
|
|
|
@ -10,8 +10,12 @@ This file assumes that you have imported <Cocoa/Cocoa.h> and "ui.h" beforehand.
|
||||||
typedef struct uiDarwinControl uiDarwinControl;
|
typedef struct uiDarwinControl uiDarwinControl;
|
||||||
struct uiDarwinControl {
|
struct uiDarwinControl {
|
||||||
uiControl c;
|
uiControl c;
|
||||||
|
void (*Relayout)(uiControl *);
|
||||||
};
|
};
|
||||||
_UI_EXTERN uintmax_t uiDarwinControlType(void);
|
_UI_EXTERN uintmax_t uiDarwinControlType(void);
|
||||||
|
#define uiDarwinControl(this) ((uiDarwinControl *) uiIsA((this), uiDarwinControlType(), 1))
|
||||||
|
// TODO document
|
||||||
|
_UI_EXTERN void uiDarwinControlRelayoutParent(uiDarwinControl *);
|
||||||
|
|
||||||
// TODO document
|
// TODO document
|
||||||
#define uiDarwinDefineControlWithOnDestroy(type, typefn, handlefield, onDestroy) \
|
#define uiDarwinDefineControlWithOnDestroy(type, typefn, handlefield, onDestroy) \
|
||||||
|
@ -35,6 +39,10 @@ _UI_EXTERN uintmax_t uiDarwinControlType(void);
|
||||||
static void _ ## type ## ContainerUpdateState(uiControl *c) \
|
static void _ ## type ## ContainerUpdateState(uiControl *c) \
|
||||||
{ \
|
{ \
|
||||||
/* do nothing */ \
|
/* do nothing */ \
|
||||||
|
} \
|
||||||
|
static void _ ## type ## Relayout(uiControl *c) \
|
||||||
|
{ \
|
||||||
|
uiDarwinControlRelayoutParent(uiDarwinControl(c)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define uiDarwinDefineControl(type, typefn, handlefield) \
|
#define uiDarwinDefineControl(type, typefn, handlefield) \
|
||||||
|
@ -44,6 +52,7 @@ _UI_EXTERN uintmax_t uiDarwinControlType(void);
|
||||||
uiControl(variable)->CommitDestroy = _ ## type ## CommitDestroy; \
|
uiControl(variable)->CommitDestroy = _ ## type ## CommitDestroy; \
|
||||||
uiControl(variable)->Handle = _ ## type ## Handle; \
|
uiControl(variable)->Handle = _ ## type ## Handle; \
|
||||||
uiControl(variable)->ContainerUpdateState = _ ## type ## ContainerUpdateState; \
|
uiControl(variable)->ContainerUpdateState = _ ## type ## ContainerUpdateState; \
|
||||||
|
uiDarwinControl(variable)->Relayout = _ ## type ## Relayout; \
|
||||||
uiDarwinFinishControl(uiControl(variable));
|
uiDarwinFinishControl(uiControl(variable));
|
||||||
|
|
||||||
// This is a function used to set up a control.
|
// This is a function used to set up a control.
|
||||||
|
|
Loading…
Reference in New Issue