Skip to content

Commit 477ff32

Browse files
committed
Add randomise button to color picker
1 parent 6bffc7d commit 477ff32

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

src/displayapp/screens/settings/SettingPineTimeStyle.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,14 @@ SettingPineTimeStyle::SettingPineTimeStyle(
203203
lv_obj_set_style_local_bg_opa(btnReset, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
204204
lv_obj_set_style_local_value_str(btnReset, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "Rst");
205205
lv_obj_set_event_cb(btnReset, event_handler);
206+
207+
btnRandom = lv_btn_create(lv_scr_act(), nullptr);
208+
btnRandom->user_data = this;
209+
lv_obj_set_size(btnRandom, 60, 60);
210+
lv_obj_align(btnRandom, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
211+
lv_obj_set_style_local_bg_opa(btnRandom, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
212+
lv_obj_set_style_local_value_str(btnRandom, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "Rnd");
213+
lv_obj_set_event_cb(btnRandom, event_handler);
206214
}
207215

208216
SettingPineTimeStyle::~SettingPineTimeStyle() {
@@ -303,4 +311,17 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) {
303311
settingsController.SetPTSColorBG(3);
304312
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[3]);
305313
}
314+
if((object == btnRandom) && (event == LV_EVENT_PRESSED)) {
315+
uint8_t randTime = rand() % 17;
316+
uint8_t randBar = rand() % 17;
317+
uint8_t randBG = rand() % 17;
318+
settingsController.SetPTSColorTime(randTime);
319+
lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randTime]);
320+
lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randTime]);
321+
lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randTime]);
322+
settingsController.SetPTSColorBar(randBar);
323+
lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randBar]);
324+
settingsController.SetPTSColorBG(randBG);
325+
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randBG]);
326+
}
306327
}

src/displayapp/screens/settings/SettingPineTimeStyle.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ namespace Pinetime {
2828
lv_obj_t * btnNextBG;
2929
lv_obj_t * btnPrevBG;
3030
lv_obj_t * btnReset;
31+
lv_obj_t * btnRandom;
3132
lv_obj_t * timeColor;
3233
lv_obj_t * barColor;
3334
lv_obj_t * bgColor;

0 commit comments

Comments
 (0)