Improve random color selection, disable longpress when settings are visible
This commit is contained in:
parent
32978b6a06
commit
3ed01b33e7
|
@ -305,7 +305,7 @@ PineTimeStyle::~PineTimeStyle() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PineTimeStyle::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
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);
|
lv_obj_set_hidden(btnSet, false);
|
||||||
savedTick = lv_tick_get();
|
savedTick = lv_tick_get();
|
||||||
return true;
|
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));
|
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Black));
|
||||||
}
|
}
|
||||||
if (object == btnRandom) {
|
if (object == btnRandom) {
|
||||||
uint8_t randTime = rand() % 17;
|
valueTime = static_cast<Controllers::Settings::Colors>(rand() % 17);
|
||||||
uint8_t randBar = rand() % 17;
|
valueBar = static_cast<Controllers::Settings::Colors>(rand() % 17);
|
||||||
uint8_t randBG = rand() % 17;
|
valueBG = static_cast<Controllers::Settings::Colors>(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 (valueTime == valueBG) {
|
||||||
if (randTime == randBG) {
|
valueBG = GetNext(valueBG);
|
||||||
randBG += 1;
|
|
||||||
}
|
}
|
||||||
if (randBar == 3) {
|
if (valueBar == Controllers::Settings::Colors::Black) {
|
||||||
randBar -= 1;
|
valueBar = GetPrevious(valueBar);
|
||||||
}
|
}
|
||||||
if (randBar == 0) {
|
if (valueBar == Controllers::Settings::Colors::White) {
|
||||||
needle_colors[0] = LV_COLOR_BLACK;
|
needle_colors[0] = LV_COLOR_BLACK;
|
||||||
} else {
|
} else {
|
||||||
needle_colors[0] = LV_COLOR_WHITE;
|
needle_colors[0] = LV_COLOR_WHITE;
|
||||||
}
|
}
|
||||||
settingsController.SetPTSColorTime(static_cast<Controllers::Settings::Colors>(randTime));
|
settingsController.SetPTSColorTime(static_cast<Controllers::Settings::Colors>(valueTime));
|
||||||
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(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(static_cast<Controllers::Settings::Colors>(randTime)));
|
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(static_cast<Controllers::Settings::Colors>(randTime)));
|
lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
|
||||||
settingsController.SetPTSColorBar(static_cast<Controllers::Settings::Colors>(randBar));
|
settingsController.SetPTSColorBar(static_cast<Controllers::Settings::Colors>(valueBar));
|
||||||
lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast<Controllers::Settings::Colors>(randBar)));
|
lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBar));
|
||||||
settingsController.SetPTSColorBG(static_cast<Controllers::Settings::Colors>(randBG));
|
settingsController.SetPTSColorBG(static_cast<Controllers::Settings::Colors>(valueBG));
|
||||||
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast<Controllers::Settings::Colors>(randBG)));
|
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBG));
|
||||||
}
|
}
|
||||||
if (object == btnClose) {
|
if (object == btnClose) {
|
||||||
settingsController.SaveSettings();
|
settingsController.SaveSettings();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user