feat(gui): add toolbar widget
This commit is contained in:
parent
afc063b2ab
commit
b42bf74472
51 changed files with 2191 additions and 1461 deletions
|
|
@ -173,6 +173,22 @@ bool pxl8_gui_slider_int(pxl8_gui_state* state, pxl8_gfx* gfx, u32 id, i32 x, i3
|
|||
return changed;
|
||||
}
|
||||
|
||||
i32 pxl8_gui_toolbar(pxl8_gui_state* state, pxl8_gfx* gfx, u32 base_id,
|
||||
i32 x, i32 y, i32 btn_w, i32 btn_h,
|
||||
const char** labels, i32 count, i32 selected) {
|
||||
i32 result = -1;
|
||||
for (i32 i = 0; i < count; i++) {
|
||||
i32 bx = x + i * (btn_w + 2);
|
||||
bool clicked = pxl8_gui_button(state, gfx, base_id + (u32)i, bx, y, btn_w, btn_h, labels[i]);
|
||||
if (clicked) result = i;
|
||||
if (i == selected) {
|
||||
u8 sel_color = pxl8_gui_color(gfx, PXL8_UI_FG0);
|
||||
pxl8_2d_rect(gfx, bx, y + btn_h - 2, btn_w, 2, sel_color);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void pxl8_gui_window(pxl8_gfx* gfx, i32 x, i32 y, i32 w, i32 h, const char* title) {
|
||||
if (!gfx || !title) return;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue