More boilerplate for uiTab parent changes: added a way to rearrange the Z-order of the current control.
This commit is contained in:
parent
f6bb30b1e5
commit
eaf8875b3f
|
@ -16,6 +16,7 @@ struct uiWindowsControl {
|
|||
void (*MinimumSize)(uiWindowsControl *, uiWindowsSizing *, intmax_t *, intmax_t *);
|
||||
void (*Relayout)(uiWindowsControl *, intmax_t, intmax_t, intmax_t, intmax_t);
|
||||
void (*AssignControlIDZOrder)(uiWindowsControl *, LONG_PTR *, HWND *);
|
||||
void (*ArrangeChildrenControlIDsZOrder)(uiWindowsControl *);
|
||||
};
|
||||
_UI_EXTERN uintmax_t uiWindowsControlType(void);
|
||||
#define uiWindowsControl(this) ((uiWindowsControl *) uiIsA((this), uiWindowsControlType(), 1))
|
||||
|
@ -59,6 +60,10 @@ _UI_EXTERN void uiWindowsControlQueueRelayout(uiWindowsControl *);
|
|||
uiWindowsEnsureAssignControlIDZOrder(type(c)->hwnd, *controlID, *insertAfter); \
|
||||
(*controlID)++; \
|
||||
*insertAfter = type(c)->hwnd; \
|
||||
} \
|
||||
static void _ ## type ## ArrangeChildrenControlIDsZOrder(uiWindowsControl *c) \
|
||||
{ \
|
||||
/* do nothing */ \
|
||||
}
|
||||
|
||||
#define uiWindowsDefineControl(type, typefn) \
|
||||
|
@ -72,6 +77,7 @@ _UI_EXTERN void uiWindowsControlQueueRelayout(uiWindowsControl *);
|
|||
uiWindowsControl(variable)->MinimumSize = minimumSize; \
|
||||
uiWindowsControl(variable)->Relayout = _ ## type ## Relayout; \
|
||||
uiWindowsControl(variable)->AssignControlIDZOrder = _ ## type ## AssignControlIDZOrder; \
|
||||
uiWindowsControl(variable)->ArrangeChildrenControlIDsZOrder = _ ## type ## ArrangeChildrenControlIDsZOrder; \
|
||||
uiWindowsFinishControl(uiControl(variable));
|
||||
|
||||
// This is a function used to set up a control.
|
||||
|
@ -93,6 +99,9 @@ _UI_EXTERN void uiWindowsEnsureMoveWindow(HWND hwnd, intmax_t x, intmax_t y, int
|
|||
// libui handles errors for you.
|
||||
_UI_EXTERN void uiWindowsEnsureAssignControlIDZOrder(HWND hwnd, LONG_PTR controlID, HWND insertAfter);
|
||||
|
||||
// Use this to tell a control's parent that the control needs to rearrange its Z-order.
|
||||
_UI_EXTERN void uiWindowsRearrangeControlIDsZOrder(uiControl *);
|
||||
|
||||
////////////////////////////////////////////
|
||||
/////////////////// TODO ///////////////////
|
||||
////////////////////////////////////////////
|
||||
|
|
|
@ -230,6 +230,13 @@ static void redoControlIDsZOrder(uiBox *b)
|
|||
}
|
||||
}
|
||||
|
||||
static void boxArrangeChildrenControlIDsZOrder(uiWindowsControl *c)
|
||||
{
|
||||
uiBox *b = uiBox(c);
|
||||
|
||||
redoControlIDsZOrder(b);
|
||||
}
|
||||
|
||||
void uiBoxAppend(uiBox *b, uiControl *c, int stretchy)
|
||||
{
|
||||
struct child *bc;
|
||||
|
@ -277,6 +284,7 @@ static uiBox *finishNewBox(int vertical)
|
|||
uiWindowsFinishNewControl(b, uiBox);
|
||||
uiControl(b)->ContainerUpdateState = boxContainerUpdateState;
|
||||
uiWindowsControl(b)->Relayout = boxRelayout;
|
||||
uiWindowsControl(b)->ArrangeChildrenControlIDsZOrder = boxArrangeChildrenControlIDsZOrder;
|
||||
|
||||
return b;
|
||||
}
|
||||
|
|
|
@ -74,3 +74,14 @@ void uiWindowsUtilSetText(HWND hwnd, const char *text)
|
|||
logLastError("error setting control text in uiWindowsControlSetText()");
|
||||
uiFree(wtext);
|
||||
}
|
||||
|
||||
void uiWindowsRearrangeControlIDsZOrder(uiControl *c)
|
||||
{
|
||||
uiWindowsControl *wc;
|
||||
|
||||
c = uiControlParent(c);
|
||||
if (c == NULL)
|
||||
return;
|
||||
wc = uiWindowsControl(c);
|
||||
(*(wc->ArrangeChildrenControlIDsZOrder))(wc);
|
||||
}
|
||||
|
|
|
@ -85,6 +85,14 @@ static void groupContainerUpdateState(uiControl *c)
|
|||
childUpdateState(g->child);
|
||||
}
|
||||
|
||||
static void groupArrangeChildrenControlIDsZOrder(uiWindowsControl *c)
|
||||
{
|
||||
uiGroup *g = uiGroup(c);
|
||||
|
||||
if (g->child != NULL)
|
||||
childSetSoleControlID(g->child);
|
||||
}
|
||||
|
||||
char *uiGroupTitle(uiGroup *g)
|
||||
{
|
||||
return uiWindowsUtilText(g->hwnd);
|
||||
|
@ -155,6 +163,7 @@ uiGroup *uiNewGroup(const char *text)
|
|||
uiWindowsFinishNewControl(g, uiGroup);
|
||||
uiControl(g)->ContainerUpdateState = groupContainerUpdateState;
|
||||
uiWindowsControl(g)->Relayout = groupRelayout;
|
||||
uiWindowsControl(g)->ArrangeChildrenControlIDsZOrder = groupArrangeChildrenControlIDsZOrder;
|
||||
|
||||
return g;
|
||||
}
|
||||
|
|
|
@ -141,6 +141,18 @@ static void tabContainerUpdateState(uiControl *c)
|
|||
}
|
||||
}
|
||||
|
||||
static void tabArrangeChildrenControlIDsZOrder(uiWindowsControl *c)
|
||||
{
|
||||
uiTab *t = uiTab(c);
|
||||
struct child *page;
|
||||
uintmax_t i;
|
||||
|
||||
for (i = 0; i < t->pages->len; i++) {
|
||||
page = ptrArrayIndex(t->pages, struct child *, i);
|
||||
childSetSoleControlID(page);
|
||||
}
|
||||
}
|
||||
|
||||
void uiTabAppend(uiTab *t, const char *name, uiControl *child)
|
||||
{
|
||||
uiTabInsertAt(t, name, t->pages->len, child);
|
||||
|
@ -234,6 +246,7 @@ uiTab *uiNewTab(void)
|
|||
uiWindowsFinishNewControl(t, uiTab);
|
||||
uiControl(t)->ContainerUpdateState = tabContainerUpdateState;
|
||||
uiWindowsControl(t)->Relayout = tabRelayout;
|
||||
uiWindowsControl(t)->ArrangeChildrenControlIDsZOrder = tabArrangeChildrenControlIDsZOrder;
|
||||
|
||||
return t;
|
||||
}
|
||||
|
|
|
@ -168,6 +168,14 @@ static void windowRelayout(uiWindowsControl *c, intmax_t x, intmax_t y, intmax_t
|
|||
uiWindowsFreeSizing(d);
|
||||
}
|
||||
|
||||
static void windowArrangeChildrenControlIDsZOrder(uiWindowsControl *c)
|
||||
{
|
||||
uiWindow *w = uiWindow(c);
|
||||
|
||||
if (w->child != NULL)
|
||||
childSetSoleControlID(w->child);
|
||||
}
|
||||
|
||||
char *uiWindowTitle(uiWindow *w)
|
||||
{
|
||||
return uiWindowsUtilText(w->hwnd);
|
||||
|
@ -276,6 +284,7 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)
|
|||
uiControl(w)->CommitShow = windowCommitShow;
|
||||
uiControl(w)->ContainerUpdateState = windowContainerUpdateState;
|
||||
uiWindowsControl(w)->Relayout = windowRelayout;
|
||||
uiWindowsControl(w)->ArrangeChildrenControlIDsZOrder = windowArrangeChildrenControlIDsZOrder;
|
||||
|
||||
return w;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue