More tidying following review

This commit is contained in:
Kieran Cawthray 2021-08-15 15:00:54 +02:00
parent 5789f1527c
commit 639fd3a9bd

View file

@ -12,11 +12,8 @@ namespace {
}
}
SettingPineTimeStyle::SettingPineTimeStyle(
Pinetime::Applications::DisplayApp *app, Pinetime::Controllers::Settings &settingsController) :
Screen(app),
settingsController{settingsController}
{
SettingPineTimeStyle::SettingPineTimeStyle(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController)
: Screen(app), settingsController {settingsController} {
timebar = lv_obj_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorBG()]);
lv_obj_set_style_local_radius(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
@ -227,7 +224,8 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) {
uint8_t valueBar = settingsController.GetPTSColorBar();
uint8_t valueBG = settingsController.GetPTSColorBG();
if((object == btnNextTime) && (event == LV_EVENT_PRESSED)) {
if (event == LV_EVENT_CLICKED) {
if (object == btnNextTime) {
if (valueTime < 16) {
valueTime += 1;
} else {
@ -238,7 +236,7 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) {
lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]);
lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]);
}
if((object == btnPrevTime) && (event == LV_EVENT_PRESSED)) {
if (object == btnPrevTime) {
if (valueTime > 0) {
valueTime -= 1;
} else {
@ -249,29 +247,33 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) {
lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]);
lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]);
}
if((object == btnNextBar) && (event == LV_EVENT_PRESSED)) {
if (object == btnNextBar) {
if (valueBar < 16) {
valueBar += 1;
// Avoid setting the sidebar black
if ( valueBar == 3 ) { valueBar += 1; }
if (valueBar == 3) {
valueBar += 1;
}
} else {
valueBar = 0;
}
settingsController.SetPTSColorBar(valueBar);
lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]);
}
if((object == btnPrevBar) && (event == LV_EVENT_PRESSED)) {
if (object == btnPrevBar) {
if (valueBar > 0) {
valueBar -= 1;
// Avoid setting the sidebar black
if ( valueBar == 3 ) { valueBar -= 1; }
if (valueBar == 3) {
valueBar -= 1;
}
} else {
valueBar = 16;
}
settingsController.SetPTSColorBar(valueBar);
lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]);
}
if((object == btnNextBG) && (event == LV_EVENT_PRESSED)) {
if (object == btnNextBG) {
if (valueBG < 16) {
valueBG += 1;
} else {
@ -280,7 +282,7 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) {
settingsController.SetPTSColorBG(valueBG);
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]);
}
if((object == btnPrevBG) && (event == LV_EVENT_PRESSED)) {
if (object == btnPrevBG) {
if (valueBG > 0) {
valueBG -= 1;
} else {
@ -289,7 +291,7 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) {
settingsController.SetPTSColorBG(valueBG);
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]);
}
if((object == btnReset) && (event == LV_EVENT_PRESSED)) {
if (object == btnReset) {
settingsController.SetPTSColorTime(11);
lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[11]);
lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[11]);
@ -299,7 +301,7 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) {
settingsController.SetPTSColorBG(3);
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[3]);
}
if((object == btnRandom) && (event == LV_EVENT_PRESSED)) {
if (object == btnRandom) {
uint8_t randTime = rand() % 17;
uint8_t randBar = rand() % 17;
uint8_t randBG = rand() % 17;
@ -320,3 +322,4 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t *object, lv_event_t event) {
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randBG]);
}
}
}