void drawUIItems(NVGcontext *vg, int item, int corners) { int kid = uiFirstChild(item); while (kid > 0) { drawUI(vg, kid, corners); kid = uiNextSibling(kid); } }
void drawUIItemsVbox(NVGcontext *vg, int item) { int kid = uiFirstChild(item); if (kid < 0) return; int nextkid = uiNextSibling(kid); if (nextkid < 0) { drawUI(vg, kid, BND_CORNER_NONE); } else { drawUI(vg, kid, BND_CORNER_DOWN); kid = nextkid; while (uiNextSibling(kid) > 0) { drawUI(vg, kid, BND_CORNER_ALL); kid = uiNextSibling(kid); } drawUI(vg, kid, BND_CORNER_TOP); } }
void drawUI(NVGcontext *vg, int item, int x, int y) { const UIData *head = (const UIData *)uiGetData(item); UIrect rect = uiGetRect(item); rect.x += x; rect.y += y; if (uiGetState(item) == UI_FROZEN) { nvgGlobalAlpha(vg, 0.5); } if (head) { switch (head->subtype) { case ST_PANEL: { bndBevel(vg,rect.x,rect.y,rect.w,rect.h); } break; case ST_LABEL: { const UIButtonData *data = (UIButtonData*)head; bndLabel(vg,rect.x,rect.y,rect.w,rect.h, data->iconid,data->label); } break; case ST_BUTTON: { const UIButtonData *data = (UIButtonData*)head; bndToolButton(vg,rect.x,rect.y,rect.w,rect.h, cornerFlags(item),(BNDwidgetState)uiGetState(item), data->iconid,data->label); } break; case ST_CHECK: { const UICheckData *data = (UICheckData*)head; BNDwidgetState state = (BNDwidgetState)uiGetState(item); if (*data->option) state = BND_ACTIVE; bndOptionButton(vg,rect.x,rect.y,rect.w,rect.h, state, data->label); } break; case ST_RADIO: { const UIRadioData *data = (UIRadioData*)head; BNDwidgetState state = (BNDwidgetState)uiGetState(item); if (*data->value == uiGetChildId(item)) state = BND_ACTIVE; bndRadioButton(vg,rect.x,rect.y,rect.w,rect.h, cornerFlags(item),state, data->iconid,data->label); } break; case ST_SLIDER: { const UISliderData *data = (UISliderData*)head; BNDwidgetState state = (BNDwidgetState)uiGetState(item); static char value[32]; sprintf(value,"%.0f%%", (*data->progress)*100.0f); bndSlider(vg,rect.x,rect.y,rect.w,rect.h, cornerFlags(item),state, *data->progress,data->label,value); } break; case ST_TEXT: { const UITextData *data = (UITextData*)head; BNDwidgetState state = (BNDwidgetState)uiGetState(item); int idx = strlen(data->text); bndTextField(vg,rect.x,rect.y,rect.w,rect.h, cornerFlags(item),state, -1, data->text, idx, idx); } break; default: { testrect(vg,rect); } break; } } else { testrect(vg,rect); } { // Recursively parse all the children int kid = uiFirstChild(item); while (kid > 0) { drawUI(vg, kid, rect.x, rect.y); kid = uiNextSibling(kid); } } if (uiGetState(item) == UI_FROZEN) { nvgGlobalAlpha(vg, 1.0); } }