WIP sliders and incrimenting

This commit is contained in:
Dylan Smith
2026-01-16 14:45:38 -05:00
parent 6711b5dcc1
commit 7dc4bf493d
6 changed files with 178 additions and 73 deletions

View File

@@ -25,4 +25,30 @@ void DrawBox(uint32_t topleft_x_loc, uint32_t topleft_y_loc, uint32_t width, uin
}
}
}
}
void draw_toggle_switch(volatile pixel_t *const framebuffer, const toggle_switch_t *const toggle_switch)
{
const uint16_t x_loc = toggle_switch->x;
const uint16_t y_loc = toggle_switch->y;
const uint16_t width = toggle_switch->width ? toggle_switch->width : 50;
const uint16_t height = toggle_switch->height ? toggle_switch->height : 20;
const pixel_t on_color = toggle_switch->on_color ? toggle_switch->on_color : MAKE_PIXEL(0, 255, 0);
const pixel_t off_color = toggle_switch->off_color ? toggle_switch->off_color : MAKE_PIXEL(160, 20, 20);
const bool value = toggle_switch->value;
DrawBox(x_loc, y_loc, width, height, value ? on_color : off_color);
if (value)
{
const uint16_t inner_switchbox_width = height - (toggle_switch->inner_padding_pixels * 2);
const uint16_t inner_switchbox_x_loc = x_loc + width - toggle_switch->inner_padding_pixels - inner_switchbox_width;
const uint16_t inner_switchbox_y_loc = y_loc + toggle_switch->inner_padding_pixels;
DrawBox(inner_switchbox_x_loc, inner_switchbox_y_loc, inner_switchbox_width, inner_switchbox_width, MAKE_PIXEL(255, 255, 255));
} else {
const uint16_t inner_switchbox_width = height - (toggle_switch->inner_padding_pixels * 2);
const uint16_t inner_switchbox_x_loc = x_loc + toggle_switch->inner_padding_pixels;
const uint16_t inner_switchbox_y_loc = y_loc + toggle_switch->inner_padding_pixels;
DrawBox(inner_switchbox_x_loc, inner_switchbox_y_loc, inner_switchbox_width, inner_switchbox_width, MAKE_PIXEL(255, 255, 255));
}
}