diff --git a/src/ugui_div.c3 b/src/ugui_div.c3 index 952a4c7..833b6ec 100644 --- a/src/ugui_div.c3 +++ b/src/ugui_div.c3 @@ -39,14 +39,7 @@ fn void! Ctx.div_begin(&ctx, String label, Rect size) } // Add the background to the draw stack - Cmd cmd = { - .type = CMD_RECT, - .rect = { - .rect = c_elem.bounds, - .color = c_elem.div.color_bg, - }, - }; - ctx.cmd_queue.enqueue(&cmd)!; + ctx.push_rect(c_elem.bounds, c_elem.div.color_bg)!; // TODO: check active // TODO: check resizeable @@ -95,17 +88,8 @@ fn void! Ctx.div_begin(&ctx, String label, Rect size) c_elem.div.origin_r = c_elem.div.origin_c; } - Cmd scrl = { - .type = CMD_RECT, - .rect.rect = vslider, - .rect.color = uint_to_rgba(0x999999ff), - }; - ctx.cmd_queue.enqueue(&scrl)!; - - scrl.rect.rect = vhandle; - scrl.rect.color = uint_to_rgba(0x9999ffff); - ctx.cmd_queue.enqueue(&scrl)!; - + ctx.push_rect(vslider, uint_to_rgba(0x999999ff))!; + ctx.push_rect(vhandle, uint_to_rgba(0x9999ffff))!; } else { c_elem.div.scroll.on_y = false; } diff --git a/src/ugui_slider.c3 b/src/ugui_slider.c3 index 0184553..a32ffc5 100644 --- a/src/ugui_slider.c3 +++ b/src/ugui_slider.c3 @@ -42,27 +42,11 @@ fn ElemEvents! Ctx.slider_hor(&ctx, String label, Rect size) } } - // Draw the button + // Draw the slider background and handle Color bg_color = uint_to_rgba(0x0000ffff); Color handle_color = uint_to_rgba(0x0ff000ff); - - Cmd cmd = { - .type = CMD_RECT, - .rect = { - .rect = c_elem.bounds, - .color = bg_color, - }, - }; - ctx.cmd_queue.enqueue(&cmd)!; - - cmd = Cmd{ - .type = CMD_RECT, - .rect = { - .rect = c_elem.slider.handle, - .color = handle_color, - }, - }; - ctx.cmd_queue.enqueue(&cmd)!; + ctx.push_rect(c_elem.bounds, bg_color)!; + ctx.push_rect(c_elem.slider.handle, handle_color)!; return c_elem.events; } @@ -117,24 +101,8 @@ fn ElemEvents! Ctx.slider_ver(&ctx, String label, Rect size) // Draw the button Color bg_color = uint_to_rgba(0x0000ffff); Color handle_color = uint_to_rgba(0x0ff000ff); - - Cmd cmd = { - .type = CMD_RECT, - .rect = { - .rect = c_elem.bounds, - .color = bg_color, - }, - }; - ctx.cmd_queue.enqueue(&cmd)!; - - cmd = Cmd{ - .type = CMD_RECT, - .rect = { - .rect = c_elem.slider.handle, - .color = handle_color, - }, - }; - ctx.cmd_queue.enqueue(&cmd)!; + ctx.push_rect(c_elem.bounds, bg_color)!; + ctx.push_rect(c_elem.slider.handle, handle_color)!; return c_elem.events; }