Skip to content

Commit

Permalink
[Painter][WIP] Tweak menu render code
Browse files Browse the repository at this point in the history
  • Loading branch information
drashna committed Aug 11, 2024
1 parent 2db74e5 commit cd603c1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 3 additions & 1 deletion users/drashna/display/painter/ili9341_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -690,8 +690,10 @@ __attribute__((weak)) void ili9341_draw_user(void) {
}
layer_map_has_updated = false;
}

#endif

void render_menu(painter_device_t display, uint16_t width, uint16_t height);
render_menu(ili9341_display, width, height);
}
qp_flush(ili9341_display);
}
12 changes: 6 additions & 6 deletions users/drashna/display/painter/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ bool process_record_menu(uint16_t keycode, keyrecord_t *record) {

extern painter_font_handle_t font_thintel, font_mono, font_oled;

void render_menu(painter_device_t display) {
void render_menu(painter_device_t display, uint16_t width, uint16_t height) {
static menu_state_t last_state;
if (memcmp(&last_state, &state, sizeof(menu_state_t)) == 0) {
return;
Expand All @@ -378,18 +378,18 @@ void render_menu(painter_device_t display) {
memcpy(&last_state, &state, sizeof(menu_state_t));

if (state.is_in_menu) {
qp_rect(display, 0, 0, 239, 319, 0, 0, 0, true);
qp_rect(display, 0, 0, width - 1, height - 1, 0, 0, 0, true);

uint8_t hue = rgb_matrix_get_hue();
menu_entry_t *menu = get_current_menu();
menu_entry_t *selected = get_selected_menu_item();

int y = 80;
qp_rect(display, 0, y, 239, y + 3, hue, 255, 255, true);
qp_rect(display, 0, y, width, y + 3, hue, 255, 255, true);
y += 8;
qp_drawtext(display, 8, y, font_oled, menu->text);
y += font_oled->line_height + 4;
qp_rect(display, 0, y, 239, y + 3, hue, 255, 255, true);
qp_rect(display, 0, y, width, y + 3, hue, 255, 255, true);
y += 8;
for (int i = 0; i < menu->parent.child_count; ++i) {
menu_entry_t *child = &menu->parent.children[i];
Expand All @@ -408,10 +408,10 @@ void render_menu(painter_device_t display) {
qp_drawtext(display, 8 + x, y, font_oled, buf);
}
y += font_oled->line_height + 4;
qp_rect(display, 0, y, 239, y, hue, 255, 255, true);
qp_rect(display, 0, y, width - 1, y, hue, 255, 255, true);
y += 5;
}
} else {
qp_rect(display, 0, 0, 239, 319, 0, 0, 0, true);
qp_rect(display, 0, 0, width - 1, height - 1, 0, 0, 0, true);
}
}

0 comments on commit cd603c1

Please sign in to comment.