summaryrefslogtreecommitdiff
path: root/src/displayapp
diff options
context:
space:
mode:
authorJean-François Milants <jf@codingfield.com>2021-08-28 21:02:11 +0200
committerJean-François Milants <jf@codingfield.com>2021-08-28 21:02:11 +0200
commit31bc47d1cb397f5de0275d0d95aac7ca29cc7392 (patch)
tree1fa8900ad36efc720f4c1cb741afbe545d930c94 /src/displayapp
parentef9f809e14155ff304b8f047aa3beae3dabb78e8 (diff)
Settings : use enums instead of ints to store colors. Group all PTS settings into a struct.
PTS/SettingsPTS : Convert to/from LVGL color and Settings::Color, add functions to reduce code duplication. Adapt SettingPineTimeStyle with the last Screen Interface
Diffstat (limited to 'src/displayapp')
-rw-r--r--src/displayapp/Colors.cpp27
-rw-r--r--src/displayapp/Colors.h10
-rw-r--r--src/displayapp/screens/PineTimeStyle.cpp11
-rw-r--r--src/displayapp/screens/PineTimeStyle.h5
-rw-r--r--src/displayapp/screens/settings/SettingPineTimeStyle.cpp147
-rw-r--r--src/displayapp/screens/settings/SettingPineTimeStyle.h12
6 files changed, 116 insertions, 96 deletions
diff --git a/src/displayapp/Colors.cpp b/src/displayapp/Colors.cpp
new file mode 100644
index 00000000..f45f0722
--- /dev/null
+++ b/src/displayapp/Colors.cpp
@@ -0,0 +1,27 @@
+#include "Colors.h"
+
+using namespace Pinetime::Applications;
+using namespace Pinetime::Controllers;
+
+lv_color_t Pinetime::Applications::Convert(Pinetime::Controllers::Settings::Colors color) {
+ switch (color) {
+ case Pinetime::Controllers::Settings::Colors::White: return LV_COLOR_WHITE;
+ case Pinetime::Controllers::Settings::Colors::Silver: return LV_COLOR_SILVER;
+ case Pinetime::Controllers::Settings::Colors::Gray: return LV_COLOR_GRAY;
+ case Pinetime::Controllers::Settings::Colors::Black: return LV_COLOR_BLACK;
+ case Pinetime::Controllers::Settings::Colors::Red: return LV_COLOR_RED;
+ case Pinetime::Controllers::Settings::Colors::Maroon: return LV_COLOR_MAROON;
+ case Pinetime::Controllers::Settings::Colors::Yellow: return LV_COLOR_YELLOW;
+ case Pinetime::Controllers::Settings::Colors::Olive: return LV_COLOR_OLIVE;
+ case Pinetime::Controllers::Settings::Colors::Lime: return LV_COLOR_LIME;
+ case Pinetime::Controllers::Settings::Colors::Green: return LV_COLOR_GREEN;
+ case Pinetime::Controllers::Settings::Colors::Cyan: return LV_COLOR_CYAN;
+ case Pinetime::Controllers::Settings::Colors::Teal: return LV_COLOR_TEAL;
+ case Pinetime::Controllers::Settings::Colors::Blue: return LV_COLOR_BLUE;
+ case Pinetime::Controllers::Settings::Colors::Navy: return LV_COLOR_NAVY;
+ case Pinetime::Controllers::Settings::Colors::Magenta: return LV_COLOR_MAGENTA;
+ case Pinetime::Controllers::Settings::Colors::Purple: return LV_COLOR_PURPLE;
+ case Pinetime::Controllers::Settings::Colors::Orange: return LV_COLOR_ORANGE;
+ default: return LV_COLOR_WHITE;
+ }
+}
diff --git a/src/displayapp/Colors.h b/src/displayapp/Colors.h
new file mode 100644
index 00000000..9db7dd20
--- /dev/null
+++ b/src/displayapp/Colors.h
@@ -0,0 +1,10 @@
+#pragma once
+
+#include <lvgl/src/lv_misc/lv_color.h>
+#include <components/settings/Settings.h>
+
+namespace Pinetime {
+ namespace Applications {
+ lv_color_t Convert(Controllers::Settings::Colors color);
+ }
+} \ No newline at end of file
diff --git a/src/displayapp/screens/PineTimeStyle.cpp b/src/displayapp/screens/PineTimeStyle.cpp
index 772e4612..7a712f43 100644
--- a/src/displayapp/screens/PineTimeStyle.cpp
+++ b/src/displayapp/screens/PineTimeStyle.cpp
@@ -23,6 +23,7 @@
#include <date/date.h>
#include <lvgl/lvgl.h>
#include <cstdio>
+#include <displayapp/Colors.h>
#include "BatteryIcon.h"
#include "BleIcon.h"
#include "NotificationIcon.h"
@@ -63,7 +64,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
//Create a 200px wide background rectangle
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_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorBG()));
lv_obj_set_style_local_radius(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
lv_obj_set_size(timebar, 200, 240);
lv_obj_align(timebar, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 0);
@@ -71,25 +72,25 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
// Display the time
timeDD1 = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
- lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorTime()]);
+ lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
lv_label_set_text(timeDD1, "12");
lv_obj_align(timeDD1, timebar, LV_ALIGN_IN_TOP_MID, 5, 5);
timeDD2 = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
- lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorTime()]);
+ lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
lv_label_set_text(timeDD2, "34");
lv_obj_align(timeDD2, timebar, LV_ALIGN_IN_BOTTOM_MID, 5, -5);
timeAMPM = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorTime()]);
+ lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
lv_obj_set_style_local_text_line_space(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, -3);
lv_label_set_text(timeAMPM, "");
lv_obj_align(timeAMPM, timebar, LV_ALIGN_IN_BOTTOM_LEFT, 2, -20);
// Create a 40px wide bar down the right side of the screen
sidebar = lv_obj_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorBar()]);
+ lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorBar()));
lv_obj_set_style_local_radius(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
lv_obj_set_size(sidebar, 40, 240);
lv_obj_align(sidebar, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0);
diff --git a/src/displayapp/screens/PineTimeStyle.h b/src/displayapp/screens/PineTimeStyle.h
index 16b6de19..cb74ead5 100644
--- a/src/displayapp/screens/PineTimeStyle.h
+++ b/src/displayapp/screens/PineTimeStyle.h
@@ -68,11 +68,6 @@ namespace Pinetime {
lv_obj_t* notificationIcon;
lv_obj_t* stepGauge;
lv_color_t needle_colors[1];
- lv_color_t pts_colors[17] = {LV_COLOR_WHITE, LV_COLOR_SILVER, LV_COLOR_GRAY, LV_COLOR_BLACK,
- LV_COLOR_RED, LV_COLOR_MAROON, LV_COLOR_YELLOW, LV_COLOR_OLIVE,
- LV_COLOR_LIME, LV_COLOR_GREEN, LV_COLOR_CYAN, LV_COLOR_TEAL,
- LV_COLOR_BLUE, LV_COLOR_NAVY, LV_COLOR_MAGENTA, LV_COLOR_PURPLE,
- LV_COLOR_ORANGE};
Controllers::DateTime& dateTimeController;
Controllers::Battery& batteryController;
diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp
index e125c8a2..c9af19b6 100644
--- a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp
+++ b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp
@@ -1,5 +1,6 @@
#include "SettingPineTimeStyle.h"
#include <lvgl/lvgl.h>
+#include <displayapp/Colors.h>
#include "displayapp/DisplayApp.h"
#include "displayapp/screens/Symbols.h"
@@ -15,7 +16,7 @@ namespace {
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_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorBG()));
lv_obj_set_style_local_radius(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
lv_obj_set_size(timebar, 200, 240);
lv_obj_align(timebar, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 0);
@@ -24,18 +25,18 @@ SettingPineTimeStyle::SettingPineTimeStyle(Pinetime::Applications::DisplayApp* a
timeDD1 = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
- lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorTime()]);
+ lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
lv_label_set_text(timeDD1, "12");
lv_obj_align(timeDD1, timebar, LV_ALIGN_IN_TOP_MID, 5, 5);
timeDD2 = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
- lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorTime()]);
+ lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
lv_label_set_text(timeDD2, "34");
lv_obj_align(timeDD2, timebar, LV_ALIGN_IN_BOTTOM_MID, 5, -5);
timeAMPM = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorTime()]);
+ lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
lv_obj_set_style_local_text_line_space(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, -3);
lv_label_set_text(timeAMPM, "A\nM");
lv_obj_align(timeAMPM, timebar, LV_ALIGN_IN_BOTTOM_LEFT, 2, -20);
@@ -43,7 +44,7 @@ SettingPineTimeStyle::SettingPineTimeStyle(Pinetime::Applications::DisplayApp* a
// Create a 40px wide bar down the right side of the screen
sidebar = lv_obj_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[settingsController.GetPTSColorBar()]);
+ lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorBar()));
lv_obj_set_style_local_radius(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
lv_obj_set_size(sidebar, 40, 240);
lv_obj_align(sidebar, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0);
@@ -215,91 +216,60 @@ SettingPineTimeStyle::~SettingPineTimeStyle() {
settingsController.SaveSettings();
}
-bool SettingPineTimeStyle::Refresh() {
- return running;
-}
-
void SettingPineTimeStyle::UpdateSelected(lv_obj_t* object, lv_event_t event) {
- uint8_t valueTime = settingsController.GetPTSColorTime();
- uint8_t valueBar = settingsController.GetPTSColorBar();
- uint8_t valueBG = settingsController.GetPTSColorBG();
+ auto valueTime = settingsController.GetPTSColorTime();
+ auto valueBar = settingsController.GetPTSColorBar();
+ auto valueBG = settingsController.GetPTSColorBG();
if (event == LV_EVENT_CLICKED) {
if (object == btnNextTime) {
- if (valueTime < 16) {
- valueTime += 1;
- } else {
- valueTime = 0;
- }
+ valueTime = GetNext(valueTime);
+
settingsController.SetPTSColorTime(valueTime);
- lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]);
- 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]);
+ 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));
}
if (object == btnPrevTime) {
- if (valueTime > 0) {
- valueTime -= 1;
- } else {
- valueTime = 16;
- }
+ valueTime = GetPrevious(valueTime);
settingsController.SetPTSColorTime(valueTime);
- lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueTime]);
- 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]);
+ 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));
}
if (object == btnNextBar) {
- if (valueBar < 16) {
- valueBar += 1;
- // Avoid setting the sidebar black
- if (valueBar == 3) {
- valueBar += 1;
- }
- } else {
- valueBar = 0;
- }
+ valueBar = GetNext(valueBar);
+ if(valueBar == Controllers::Settings::Colors::Black)
+ valueBar = GetNext(valueBar);
settingsController.SetPTSColorBar(valueBar);
- lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]);
+ lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBar));
}
if (object == btnPrevBar) {
- if (valueBar > 0) {
- valueBar -= 1;
- // Avoid setting the sidebar black
- if (valueBar == 3) {
- valueBar -= 1;
- }
- } else {
- valueBar = 16;
- }
+ valueBar = GetPrevious(valueBar);
+ if(valueBar == Controllers::Settings::Colors::Black)
+ valueBar = GetPrevious(valueBar);
settingsController.SetPTSColorBar(valueBar);
- lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBar]);
+ lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBar));
}
if (object == btnNextBG) {
- if (valueBG < 16) {
- valueBG += 1;
- } else {
- valueBG = 0;
- }
+ valueBG = GetNext(valueBG);
settingsController.SetPTSColorBG(valueBG);
- lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]);
+ lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBG));
}
if (object == btnPrevBG) {
- if (valueBG > 0) {
- valueBG -= 1;
- } else {
- valueBG = 16;
- }
+ valueBG = GetPrevious(valueBG);
settingsController.SetPTSColorBG(valueBG);
- lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[valueBG]);
+ lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBG));
}
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]);
- lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[11]);
- settingsController.SetPTSColorBar(11);
- lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[11]);
- settingsController.SetPTSColorBG(3);
- lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[3]);
+ settingsController.SetPTSColorTime(Controllers::Settings::Colors::Teal);
+ lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal));
+ lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal));
+ lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal));
+ settingsController.SetPTSColorBar(Controllers::Settings::Colors::Teal);
+ lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal));
+ settingsController.SetPTSColorBG(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) {
uint8_t randTime = rand() % 17;
@@ -312,14 +282,37 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t* object, lv_event_t event) {
if (randBar == 3) {
randBar -= 1;
}
- settingsController.SetPTSColorTime(randTime);
- lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randTime]);
- lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randTime]);
- lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randTime]);
- settingsController.SetPTSColorBar(randBar);
- lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randBar]);
- settingsController.SetPTSColorBG(randBG);
- lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, pts_colors[randBG]);
+ 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)));
}
}
-} \ No newline at end of file
+}
+
+Pinetime::Controllers::Settings::Colors SettingPineTimeStyle::GetNext(Pinetime::Controllers::Settings::Colors color) {
+ auto colorAsInt = static_cast<uint8_t>(color);
+ Pinetime::Controllers::Settings::Colors nextColor;
+ if (colorAsInt < 16) {
+ nextColor = static_cast<Controllers::Settings::Colors>(colorAsInt + 1);
+ } else {
+ nextColor = static_cast<Controllers::Settings::Colors>(0);
+ }
+ return nextColor;
+}
+
+Pinetime::Controllers::Settings::Colors SettingPineTimeStyle::GetPrevious(Pinetime::Controllers::Settings::Colors color) {
+ auto colorAsInt = static_cast<uint8_t>(color);
+ Pinetime::Controllers::Settings::Colors prevColor;
+
+ if (colorAsInt > 0) {
+ prevColor = static_cast<Controllers::Settings::Colors>(colorAsInt - 1);
+ } else {
+ prevColor = static_cast<Controllers::Settings::Colors>(16);
+ }
+ return prevColor;
+}
diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.h b/src/displayapp/screens/settings/SettingPineTimeStyle.h
index 1a01ebbb..397bd86d 100644
--- a/src/displayapp/screens/settings/SettingPineTimeStyle.h
+++ b/src/displayapp/screens/settings/SettingPineTimeStyle.h
@@ -15,12 +15,14 @@ namespace Pinetime {
SettingPineTimeStyle(DisplayApp* app, Pinetime::Controllers::Settings &settingsController);
~SettingPineTimeStyle() override;
- bool Refresh() override;
void UpdateSelected(lv_obj_t *object, lv_event_t event);
private:
Controllers::Settings& settingsController;
+ Pinetime::Controllers::Settings::Colors GetNext(Controllers::Settings::Colors color);
+ Pinetime::Controllers::Settings::Colors GetPrevious(Controllers::Settings::Colors color);
+
lv_obj_t * btnNextTime;
lv_obj_t * btnPrevTime;
lv_obj_t * btnNextBar;
@@ -29,9 +31,6 @@ namespace Pinetime {
lv_obj_t * btnPrevBG;
lv_obj_t * btnReset;
lv_obj_t * btnRandom;
- lv_obj_t * timeColor;
- lv_obj_t * barColor;
- lv_obj_t * bgColor;
lv_obj_t * timebar;
lv_obj_t * sidebar;
lv_obj_t * timeDD1;
@@ -51,11 +50,6 @@ namespace Pinetime {
lv_obj_t * calendarCrossBar2;
lv_obj_t * stepGauge;
lv_color_t needle_colors[1];
- lv_color_t pts_colors[17] = {LV_COLOR_WHITE, LV_COLOR_SILVER, LV_COLOR_GRAY, LV_COLOR_BLACK,
- LV_COLOR_RED, LV_COLOR_MAROON, LV_COLOR_YELLOW, LV_COLOR_OLIVE,
- LV_COLOR_LIME, LV_COLOR_GREEN, LV_COLOR_CYAN, LV_COLOR_TEAL,
- LV_COLOR_BLUE, LV_COLOR_NAVY, LV_COLOR_MAGENTA, LV_COLOR_PURPLE,
- LV_COLOR_ORANGE};
};
}
}