Skip to content

Commit 5b5952b

Browse files
committed
feat(ui): update button styles so focused is highlighted red so it is easy to see what button is selected when using the gamepad
1 parent cbceec3 commit 5b5952b

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

components/gui/include/gui.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ class Gui {
214214
std::atomic<int> focused_rom_{-1};
215215
lv_img_dsc_t focused_boxart_;
216216

217+
// style for buttons
218+
lv_style_t button_style_;
219+
217220
lv_anim_t rom_label_animation_template_;
218221
lv_style_t rom_label_style_;
219222

components/gui/src/gui.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,22 @@ void Gui::init_ui() {
168168
lv_group_add_obj(settings_screen_group_, ui_hapticupbutton);
169169
lv_group_add_obj(settings_screen_group_, ui_hapticplaybutton);
170170

171+
// set the focused style for all the buttons to have a red border
172+
lv_style_init(&button_style_);
173+
lv_style_set_border_color(&button_style_, lv_palette_main(LV_PALETTE_RED));
174+
lv_style_set_border_width(&button_style_, 2);
175+
176+
lv_obj_add_style(ui_settingsbutton, &button_style_, LV_STATE_FOCUSED);
177+
lv_obj_add_style(ui_playbutton, &button_style_, LV_STATE_FOCUSED);
178+
lv_obj_add_style(ui_closebutton, &button_style_, LV_STATE_FOCUSED);
179+
lv_obj_add_style(ui_volumeupbutton, &button_style_, LV_STATE_FOCUSED);
180+
lv_obj_add_style(ui_volumedownbutton, &button_style_, LV_STATE_FOCUSED);
181+
lv_obj_add_style(ui_mutebutton, &button_style_, LV_STATE_FOCUSED);
182+
lv_obj_add_style(ui_hapticupbutton, &button_style_, LV_STATE_FOCUSED);
183+
lv_obj_add_style(ui_hapticdownbutton, &button_style_, LV_STATE_FOCUSED);
184+
lv_obj_add_style(ui_hapticplaybutton, &button_style_, LV_STATE_FOCUSED);
185+
lv_obj_add_style(ui_videosettingdropdown, &button_style_, LV_STATE_FOCUSED);
186+
171187
focus_rommenu();
172188
}
173189

components/menu/include/menu.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,10 @@ class Menu {
172172
void on_value_changed(lv_event_t *e);
173173
void on_key(lv_event_t *e);
174174

175+
// LVLG menu objects
176+
lv_style_t button_style_;
175177
lv_group_t *group_{nullptr};
176178

177-
// LVLG menu objects
178179
lv_img_dsc_t state_image_;
179180
lv_img_dsc_t paused_image_;
180181

components/menu/src/menu.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,23 @@ void Menu::init_ui() {
6868
lv_group_add_obj(group_, ui_reset_btn);
6969
lv_group_add_obj(group_, ui_quit_btn);
7070

71+
// set the focused style for all the buttons to have a red border
72+
lv_style_init(&button_style_);
73+
lv_style_set_border_color(&button_style_, lv_palette_main(LV_PALETTE_RED));
74+
lv_style_set_border_width(&button_style_, 2);
75+
76+
lv_obj_add_style(ui_resume_btn, &button_style_, LV_STATE_FOCUSED);
77+
lv_obj_add_style(ui_volume_mute_btn, &button_style_, LV_STATE_FOCUSED);
78+
lv_obj_add_style(ui_volume_dec_btn, &button_style_, LV_STATE_FOCUSED);
79+
lv_obj_add_style(ui_volume_inc_btn, &button_style_, LV_STATE_FOCUSED);
80+
lv_obj_add_style(ui_btn_slot_dec, &button_style_, LV_STATE_FOCUSED);
81+
lv_obj_add_style(ui_btn_slot_inc, &button_style_, LV_STATE_FOCUSED);
82+
lv_obj_add_style(ui_load_btn, &button_style_, LV_STATE_FOCUSED);
83+
lv_obj_add_style(ui_save_btn, &button_style_, LV_STATE_FOCUSED);
84+
lv_obj_add_style(ui_Dropdown2, &button_style_, LV_STATE_FOCUSED);
85+
lv_obj_add_style(ui_reset_btn, &button_style_, LV_STATE_FOCUSED);
86+
lv_obj_add_style(ui_quit_btn, &button_style_, LV_STATE_FOCUSED);
87+
7188
// now focus the resume button
7289
lv_group_focus_obj(ui_resume_btn);
7390
lv_group_focus_freeze(group_, false);

0 commit comments

Comments
 (0)