diff options
author | Kieran Cawthray <kieranc@gmail.com> | 2021-10-20 17:44:10 +0200 |
---|---|---|
committer | Kieran Cawthray <kieranc@gmail.com> | 2021-10-20 17:44:10 +0200 |
commit | 3ed01b33e7303a64615bfc0db2e9d42bb2624bb6 (patch) | |
tree | 55f3718f65010f27f06241e358417ebfdcaf11d1 /src/displayapp/screens/PineTimeStyle.cpp | |
parent | 32978b6a06330dcc5b7e757a4ba9d9b5349277f2 (diff) |
Improve random color selection, disable longpress when settings are visible
Diffstat (limited to 'src/displayapp/screens/PineTimeStyle.cpp')
-rw-r--r-- | src/displayapp/screens/PineTimeStyle.cpp | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/src/displayapp/screens/PineTimeStyle.cpp b/src/displayapp/screens/PineTimeStyle.cpp index 98f15ef0..fa9aec1c 100644 --- a/src/displayapp/screens/PineTimeStyle.cpp +++ b/src/displayapp/screens/PineTimeStyle.cpp @@ -305,7 +305,7 @@ PineTimeStyle::~PineTimeStyle() { } bool PineTimeStyle::OnTouchEvent(Pinetime::Applications::TouchEvents event) { - if (event == Pinetime::Applications::TouchEvents::LongTap) { + if ((event == Pinetime::Applications::TouchEvents::LongTap) && (lv_obj_get_hidden(btnRandom) == true)) { lv_obj_set_hidden(btnSet, false); savedTick = lv_tick_get(); return true; @@ -508,29 +508,28 @@ void PineTimeStyle::UpdateSelected(lv_obj_t* object, lv_event_t event) { lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Black)); } if (object == btnRandom) { - uint8_t randTime = rand() % 17; - uint8_t randBar = rand() % 17; - uint8_t randBG = rand() % 17; - // Check if the time color is the same as its background, or if the sidebar is black. If so, change them to more useful values. - if (randTime == randBG) { - randBG += 1; + valueTime = static_cast<Controllers::Settings::Colors>(rand() % 17); + valueBar = static_cast<Controllers::Settings::Colors>(rand() % 17); + valueBG = static_cast<Controllers::Settings::Colors>(rand() % 17); + if (valueTime == valueBG) { + valueBG = GetNext(valueBG); } - if (randBar == 3) { - randBar -= 1; + if (valueBar == Controllers::Settings::Colors::Black) { + valueBar = GetPrevious(valueBar); } - if (randBar == 0) { + if (valueBar == Controllers::Settings::Colors::White) { needle_colors[0] = LV_COLOR_BLACK; } else { needle_colors[0] = LV_COLOR_WHITE; } - settingsController.SetPTSColorTime(static_cast<Controllers::Settings::Colors>(randTime)); - lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast<Controllers::Settings::Colors>(randTime))); - lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast<Controllers::Settings::Colors>(randTime))); - lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast<Controllers::Settings::Colors>(randTime))); - settingsController.SetPTSColorBar(static_cast<Controllers::Settings::Colors>(randBar)); - lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast<Controllers::Settings::Colors>(randBar))); - settingsController.SetPTSColorBG(static_cast<Controllers::Settings::Colors>(randBG)); - lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast<Controllers::Settings::Colors>(randBG))); + settingsController.SetPTSColorTime(static_cast<Controllers::Settings::Colors>(valueTime)); + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime)); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime)); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime)); + settingsController.SetPTSColorBar(static_cast<Controllers::Settings::Colors>(valueBar)); + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBar)); + settingsController.SetPTSColorBG(static_cast<Controllers::Settings::Colors>(valueBG)); + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBG)); } if (object == btnClose) { settingsController.SaveSettings(); |