Implemented z-ordering on uiBox.

This commit is contained in:
Pietro Gagliardi 2015-09-02 09:36:53 -04:00
parent 6be1cabf22
commit 8846af48d4
3 changed files with 26 additions and 23 deletions

View File

@ -231,37 +231,30 @@ static void boxContainerUpdateState(uiControl *c)
}
}
static void redoControlIDsZOrder(uiBox *b)
{
struct child *bc;
LONG_PTR controlID;
HWND insertAfter;
uintmax_t i;
controlID = 100;
insertAfter = NULL;
for (i = 0; i < b->controls->len; i++) {
bc = ptrArrayIndex(b->controls, struct child *, i);
childAssignControlIDZOrder(bc, &controlID, &insertAfter);
}
}
void uiBoxAppend(uiBox *b, uiControl *c, int stretchy)
{
struct child *bc;
/* TODO
uintptr_t zorder;
int dozorder;
uintmax_t i;
// start the zorder with the *CURRENT* first child
// this is in case we're adding a new first child
dozorder = 0;
if (b->controls->len != 0) {
dozorder = 1;
bc = ptrArrayIndex(b->controls, struct child *, 0);
zorder = uiControlStartZOrder(bc->c);
}
*/
bc = newChild(c, uiControl(b), b->hwnd);
ctrlSetStretchy(bc, stretchy);
ptrArrayAppend(b->controls, bc);
redoControlIDsZOrder(b);
uiWindowsControlQueueRelayout(uiWindowsControl(b));
/* TODO
// and now update the zorder for all controls
if (dozorder)
for (i = 0; i < b->controls->len; i++) {
bc = ptrArrayIndex(b->controls, struct child *, i);
zorder = uiControlSetZOrder(bc->c, zorder);
}
*/
}
void uiBoxDelete(uiBox *b, uintmax_t index)
@ -271,6 +264,7 @@ void uiBoxDelete(uiBox *b, uintmax_t index)
bc = ptrArrayIndex(b->controls, struct child *, index);
ptrArrayDelete(b->controls, index);
childRemove(bc);
redoControlIDsZOrder(b);
uiWindowsControlQueueRelayout(uiWindowsControl(b));
}

View File

@ -123,6 +123,14 @@ void childUpdateState(struct child *c)
controlUpdateState(c->c);
}
void childAssignControlIDZOrder(struct child *c, LONG_PTR *controlID, HWND *insertAfter)
{
uiWindowsControl *wc;
wc = uiWindowsControl(c->c);
(*(wc->AssignControlIDZOrder))(wc, controlID, insertAfter);
}
void childSetSoleControlID(struct child *c)
{
uiWindowsEnsureAssignControlIDZOrder(c->hwnd, 100, NULL);

View File

@ -106,6 +106,7 @@ extern void childRelayout(struct child *c, intmax_t x, intmax_t y, intmax_t widt
extern void childQueueRelayout(struct child *c);
extern int childVisible(struct child *c);
extern void childUpdateState(struct child *c);
extern void childAssignControlIDZOrder(struct child *c, LONG_PTR *controlID, HWND *insertAfter);
extern void childSetSoleControlID(struct child *c);
extern HWND childTabPage(struct child *c);
extern int childMargined(struct child *c);