More boilerplate for uiTab parent changes: added a way to rearrange the Z-order of the current control.

This commit is contained in:
Pietro Gagliardi 2015-09-02 12:59:57 -04:00
parent f6bb30b1e5
commit eaf8875b3f
6 changed files with 59 additions and 0 deletions

View File

@ -16,6 +16,7 @@ struct uiWindowsControl {
void (*MinimumSize)(uiWindowsControl *, uiWindowsSizing *, intmax_t *, intmax_t *); void (*MinimumSize)(uiWindowsControl *, uiWindowsSizing *, intmax_t *, intmax_t *);
void (*Relayout)(uiWindowsControl *, intmax_t, intmax_t, intmax_t, intmax_t); void (*Relayout)(uiWindowsControl *, intmax_t, intmax_t, intmax_t, intmax_t);
void (*AssignControlIDZOrder)(uiWindowsControl *, LONG_PTR *, HWND *); void (*AssignControlIDZOrder)(uiWindowsControl *, LONG_PTR *, HWND *);
void (*ArrangeChildrenControlIDsZOrder)(uiWindowsControl *);
}; };
_UI_EXTERN uintmax_t uiWindowsControlType(void); _UI_EXTERN uintmax_t uiWindowsControlType(void);
#define uiWindowsControl(this) ((uiWindowsControl *) uiIsA((this), uiWindowsControlType(), 1)) #define uiWindowsControl(this) ((uiWindowsControl *) uiIsA((this), uiWindowsControlType(), 1))
@ -59,6 +60,10 @@ _UI_EXTERN void uiWindowsControlQueueRelayout(uiWindowsControl *);
uiWindowsEnsureAssignControlIDZOrder(type(c)->hwnd, *controlID, *insertAfter); \ uiWindowsEnsureAssignControlIDZOrder(type(c)->hwnd, *controlID, *insertAfter); \
(*controlID)++; \ (*controlID)++; \
*insertAfter = type(c)->hwnd; \ *insertAfter = type(c)->hwnd; \
} \
static void _ ## type ## ArrangeChildrenControlIDsZOrder(uiWindowsControl *c) \
{ \
/* do nothing */ \
} }
#define uiWindowsDefineControl(type, typefn) \ #define uiWindowsDefineControl(type, typefn) \
@ -72,6 +77,7 @@ _UI_EXTERN void uiWindowsControlQueueRelayout(uiWindowsControl *);
uiWindowsControl(variable)->MinimumSize = minimumSize; \ uiWindowsControl(variable)->MinimumSize = minimumSize; \
uiWindowsControl(variable)->Relayout = _ ## type ## Relayout; \ uiWindowsControl(variable)->Relayout = _ ## type ## Relayout; \
uiWindowsControl(variable)->AssignControlIDZOrder = _ ## type ## AssignControlIDZOrder; \ uiWindowsControl(variable)->AssignControlIDZOrder = _ ## type ## AssignControlIDZOrder; \
uiWindowsControl(variable)->ArrangeChildrenControlIDsZOrder = _ ## type ## ArrangeChildrenControlIDsZOrder; \
uiWindowsFinishControl(uiControl(variable)); uiWindowsFinishControl(uiControl(variable));
// This is a function used to set up a control. // 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. // libui handles errors for you.
_UI_EXTERN void uiWindowsEnsureAssignControlIDZOrder(HWND hwnd, LONG_PTR controlID, HWND insertAfter); _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 /////////////////// /////////////////// TODO ///////////////////
//////////////////////////////////////////// ////////////////////////////////////////////

View File

@ -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) void uiBoxAppend(uiBox *b, uiControl *c, int stretchy)
{ {
struct child *bc; struct child *bc;
@ -277,6 +284,7 @@ static uiBox *finishNewBox(int vertical)
uiWindowsFinishNewControl(b, uiBox); uiWindowsFinishNewControl(b, uiBox);
uiControl(b)->ContainerUpdateState = boxContainerUpdateState; uiControl(b)->ContainerUpdateState = boxContainerUpdateState;
uiWindowsControl(b)->Relayout = boxRelayout; uiWindowsControl(b)->Relayout = boxRelayout;
uiWindowsControl(b)->ArrangeChildrenControlIDsZOrder = boxArrangeChildrenControlIDsZOrder;
return b; return b;
} }

View File

@ -74,3 +74,14 @@ void uiWindowsUtilSetText(HWND hwnd, const char *text)
logLastError("error setting control text in uiWindowsControlSetText()"); logLastError("error setting control text in uiWindowsControlSetText()");
uiFree(wtext); uiFree(wtext);
} }
void uiWindowsRearrangeControlIDsZOrder(uiControl *c)
{
uiWindowsControl *wc;
c = uiControlParent(c);
if (c == NULL)
return;
wc = uiWindowsControl(c);
(*(wc->ArrangeChildrenControlIDsZOrder))(wc);
}

View File

@ -85,6 +85,14 @@ static void groupContainerUpdateState(uiControl *c)
childUpdateState(g->child); childUpdateState(g->child);
} }
static void groupArrangeChildrenControlIDsZOrder(uiWindowsControl *c)
{
uiGroup *g = uiGroup(c);
if (g->child != NULL)
childSetSoleControlID(g->child);
}
char *uiGroupTitle(uiGroup *g) char *uiGroupTitle(uiGroup *g)
{ {
return uiWindowsUtilText(g->hwnd); return uiWindowsUtilText(g->hwnd);
@ -155,6 +163,7 @@ uiGroup *uiNewGroup(const char *text)
uiWindowsFinishNewControl(g, uiGroup); uiWindowsFinishNewControl(g, uiGroup);
uiControl(g)->ContainerUpdateState = groupContainerUpdateState; uiControl(g)->ContainerUpdateState = groupContainerUpdateState;
uiWindowsControl(g)->Relayout = groupRelayout; uiWindowsControl(g)->Relayout = groupRelayout;
uiWindowsControl(g)->ArrangeChildrenControlIDsZOrder = groupArrangeChildrenControlIDsZOrder;
return g; return g;
} }

View File

@ -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) void uiTabAppend(uiTab *t, const char *name, uiControl *child)
{ {
uiTabInsertAt(t, name, t->pages->len, child); uiTabInsertAt(t, name, t->pages->len, child);
@ -234,6 +246,7 @@ uiTab *uiNewTab(void)
uiWindowsFinishNewControl(t, uiTab); uiWindowsFinishNewControl(t, uiTab);
uiControl(t)->ContainerUpdateState = tabContainerUpdateState; uiControl(t)->ContainerUpdateState = tabContainerUpdateState;
uiWindowsControl(t)->Relayout = tabRelayout; uiWindowsControl(t)->Relayout = tabRelayout;
uiWindowsControl(t)->ArrangeChildrenControlIDsZOrder = tabArrangeChildrenControlIDsZOrder;
return t; return t;
} }

View File

@ -168,6 +168,14 @@ static void windowRelayout(uiWindowsControl *c, intmax_t x, intmax_t y, intmax_t
uiWindowsFreeSizing(d); uiWindowsFreeSizing(d);
} }
static void windowArrangeChildrenControlIDsZOrder(uiWindowsControl *c)
{
uiWindow *w = uiWindow(c);
if (w->child != NULL)
childSetSoleControlID(w->child);
}
char *uiWindowTitle(uiWindow *w) char *uiWindowTitle(uiWindow *w)
{ {
return uiWindowsUtilText(w->hwnd); 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)->CommitShow = windowCommitShow;
uiControl(w)->ContainerUpdateState = windowContainerUpdateState; uiControl(w)->ContainerUpdateState = windowContainerUpdateState;
uiWindowsControl(w)->Relayout = windowRelayout; uiWindowsControl(w)->Relayout = windowRelayout;
uiWindowsControl(w)->ArrangeChildrenControlIDsZOrder = windowArrangeChildrenControlIDsZOrder;
return w; return w;
} }