@@ -49,8 +49,6 @@ inline void lv_img_set_src_arr(lv_obj_t* img, const lv_img_dsc_t* src_img) {
4949Music::Music (Pinetime::Controllers::MusicService& music, const Controllers::Ble& bleController)
5050 : musicService(music), bleController {bleController} {
5151
52- lv_obj_t * label;
53-
5452 lv_style_init (&btn_style);
5553 lv_style_set_radius (&btn_style, LV_STATE_DEFAULT, 20 );
5654 lv_style_set_bg_color (&btn_style, LV_STATE_DEFAULT, Colors::bgAlt);
@@ -61,35 +59,35 @@ Music::Music(Pinetime::Controllers::MusicService& music, const Controllers::Ble&
6159 lv_obj_set_size (btnVolDown, 117 , 60 );
6260 lv_obj_align (btnVolDown, nullptr , LV_ALIGN_IN_TOP_LEFT, 0 , 0 );
6361 lv_obj_add_style (btnVolDown, LV_STATE_DEFAULT, &btn_style);
64- label = lv_label_create (btnVolDown, nullptr );
65- lv_label_set_text_static (label , Symbols::volumDown);
62+ txtVolDown = lv_label_create (btnVolDown, nullptr );
63+ lv_label_set_text_static (txtVolDown , Symbols::volumDown);
6664
6765 btnVolUp = lv_btn_create (lv_scr_act (), nullptr );
6866 btnVolUp->user_data = this ;
6967 lv_obj_set_event_cb (btnVolUp, event_handler);
7068 lv_obj_set_size (btnVolUp, 117 , 60 );
7169 lv_obj_align (btnVolUp, nullptr , LV_ALIGN_IN_TOP_RIGHT, 0 , 0 );
7270 lv_obj_add_style (btnVolUp, LV_STATE_DEFAULT, &btn_style);
73- label = lv_label_create (btnVolUp, nullptr );
74- lv_label_set_text_static (label , Symbols::volumUp);
71+ txtVolUp = lv_label_create (btnVolUp, nullptr );
72+ lv_label_set_text_static (txtVolUp , Symbols::volumUp);
7573
7674 btnPrev = lv_btn_create (lv_scr_act (), nullptr );
7775 btnPrev->user_data = this ;
7876 lv_obj_set_event_cb (btnPrev, event_handler);
7977 lv_obj_set_size (btnPrev, 76 , 76 );
8078 lv_obj_align (btnPrev, nullptr , LV_ALIGN_IN_BOTTOM_LEFT, 3 , 0 );
8179 lv_obj_add_style (btnPrev, LV_STATE_DEFAULT, &btn_style);
82- label = lv_label_create (btnPrev, nullptr );
83- lv_label_set_text_static (label , Symbols::stepBackward);
80+ txtBtnPrev = lv_label_create (btnPrev, nullptr );
81+ lv_label_set_text_static (txtBtnPrev , Symbols::stepBackward);
8482
8583 btnNext = lv_btn_create (lv_scr_act (), nullptr );
8684 btnNext->user_data = this ;
8785 lv_obj_set_event_cb (btnNext, event_handler);
8886 lv_obj_set_size (btnNext, 76 , 76 );
8987 lv_obj_align (btnNext, nullptr , LV_ALIGN_IN_BOTTOM_RIGHT, -3 , 0 );
9088 lv_obj_add_style (btnNext, LV_STATE_DEFAULT, &btn_style);
91- label = lv_label_create (btnNext, nullptr );
92- lv_label_set_text_static (label , Symbols::stepForward);
89+ txtBtnNext = lv_label_create (btnNext, nullptr );
90+ lv_label_set_text_static (txtBtnNext , Symbols::stepForward);
9391
9492 btnPlayPause = lv_btn_create (lv_scr_act (), nullptr );
9593 btnPlayPause->user_data = this ;
@@ -100,6 +98,18 @@ Music::Music(Pinetime::Controllers::MusicService& music, const Controllers::Ble&
10098 txtPlayPause = lv_label_create (btnPlayPause, nullptr );
10199 lv_label_set_text_static (txtPlayPause, Symbols::play);
102100
101+ buttons[0 ] = btnPrev;
102+ buttons[1 ] = btnPlayPause;
103+ buttons[2 ] = btnNext;
104+ buttons[3 ] = btnVolDown;
105+ buttons[4 ] = btnVolUp;
106+
107+ controlLabels[0 ] = txtBtnPrev;
108+ controlLabels[1 ] = txtPlayPause;
109+ controlLabels[2 ] = txtBtnNext;
110+ controlLabels[3 ] = txtVolDown;
111+ controlLabels[4 ] = txtVolUp;
112+
103113 // I'm using the txtTrack label as the top anchor for the whole lot
104114 // of song, artist, progress bar and duration text (0:00 and -0:00) so
105115 // its much easier to move that around and mess with the buttons separately
@@ -180,26 +190,32 @@ void Music::Refresh() {
180190void Music::SetDisconnectedUI () {
181191 lv_label_set_text_static (txtArtist, " Disconnected" );
182192 lv_label_set_text_static (txtTrack, " " );
183- lv_obj_set_style_local_bg_color (btnPrev, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Colors::bgDark);
184- lv_obj_set_style_local_bg_color (btnPlayPause, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Colors::bgDark);
185- lv_obj_set_style_local_bg_color (btnNext, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Colors::bgDark);
186- lv_obj_set_style_local_bg_color (btnVolDown, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Colors::bgDark);
187- lv_obj_set_style_local_bg_color (btnVolUp, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Colors::bgDark);
193+
194+ for (auto btn : buttons) {
195+ lv_obj_set_style_local_bg_color (btn, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Colors::bgDark);
196+ }
197+
198+ for (auto lbl : controlLabels) {
199+ lv_obj_set_style_local_text_color (lbl, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::bgAlt);
200+ }
201+
188202 lv_label_set_text_static (txtCurrentPosition, " --:--" );
189203 lv_label_set_text_static (txtTrackDuration, " --:--" );
190204 lv_bar_set_range (barTrackDuration, 0 , 1000 );
191205 lv_bar_set_value (barTrackDuration, 0 , LV_ANIM_OFF);
192- // empty these so they are successfully updated on reconnect because of how DirtyValue works
206+
193207 artist = " " ;
194208 track = " " ;
195209}
196210
197211void Music::SetConnectedUI () {
198- lv_obj_set_style_local_bg_color (btnPrev, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Colors::bgAlt);
199- lv_obj_set_style_local_bg_color (btnPlayPause, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Colors::bgAlt);
200- lv_obj_set_style_local_bg_color (btnNext, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Colors::bgAlt);
201- lv_obj_set_style_local_bg_color (btnVolDown, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Colors::bgAlt);
202- lv_obj_set_style_local_bg_color (btnVolUp, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Colors::bgAlt);
212+ for (auto btn : buttons) {
213+ lv_obj_set_style_local_bg_color (btn, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Colors::bgAlt);
214+ }
215+
216+ for (auto lbl : controlLabels) {
217+ lv_obj_set_style_local_text_color (lbl, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
218+ }
203219}
204220
205221void Music::RefreshTrackInfo () {
0 commit comments