summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRiku Isokoski <riksu9000@gmail.com>2021-09-23 02:53:10 +0300
committerJF <JF002@users.noreply.github.com>2021-12-09 21:32:07 +0100
commitec9b5a0bd2847d972c285d46e28deba0241d3a47 (patch)
tree6c2e05c282dbcbfe41a75fb829654e500dfadb60
parent736ae08fcdd3f87a6412985eec131179d8cc6664 (diff)
Move radio button styling to a single place
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/displayapp/screens/Styles.cpp8
-rw-r--r--src/displayapp/screens/Styles.h9
-rw-r--r--src/displayapp/screens/settings/SettingDisplay.cpp8
-rw-r--r--src/displayapp/screens/settings/SettingTimeFormat.cpp8
-rw-r--r--src/displayapp/screens/settings/SettingWatchFace.cpp8
6 files changed, 24 insertions, 18 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 5591dbcc..480b4e61 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -434,6 +434,7 @@ list(APPEND SOURCE_FILES
displayapp/screens/PassKey.cpp
displayapp/screens/Error.cpp
displayapp/screens/Alarm.cpp
+ displayapp/screens/Styles.cpp
displayapp/Colors.cpp
## Settings
diff --git a/src/displayapp/screens/Styles.cpp b/src/displayapp/screens/Styles.cpp
new file mode 100644
index 00000000..7f43fb99
--- /dev/null
+++ b/src/displayapp/screens/Styles.cpp
@@ -0,0 +1,8 @@
+#include "Styles.h"
+
+void Pinetime::Applications::Screens::SetRadioButtonStyle(lv_obj_t* checkbox) {
+ lv_obj_set_style_local_radius(checkbox, LV_CHECKBOX_PART_BULLET, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
+ lv_obj_set_style_local_border_width(checkbox, LV_CHECKBOX_PART_BULLET, LV_STATE_CHECKED, 9);
+ lv_obj_set_style_local_border_color(checkbox, LV_CHECKBOX_PART_BULLET, LV_STATE_CHECKED, LV_COLOR_GREEN);
+ lv_obj_set_style_local_bg_color(checkbox, LV_CHECKBOX_PART_BULLET, LV_STATE_CHECKED, LV_COLOR_WHITE);
+}
diff --git a/src/displayapp/screens/Styles.h b/src/displayapp/screens/Styles.h
new file mode 100644
index 00000000..a5fbb9f6
--- /dev/null
+++ b/src/displayapp/screens/Styles.h
@@ -0,0 +1,9 @@
+#include <lvgl/lvgl.h>
+
+namespace Pinetime {
+ namespace Applications {
+ namespace Screens {
+ void SetRadioButtonStyle(lv_obj_t* checkbox);
+ }
+ }
+}
diff --git a/src/displayapp/screens/settings/SettingDisplay.cpp b/src/displayapp/screens/settings/SettingDisplay.cpp
index a92d76fe..9e972afc 100644
--- a/src/displayapp/screens/settings/SettingDisplay.cpp
+++ b/src/displayapp/screens/settings/SettingDisplay.cpp
@@ -2,6 +2,7 @@
#include <lvgl/lvgl.h>
#include "displayapp/DisplayApp.h"
#include "displayapp/Messages.h"
+#include "displayapp/screens/Styles.h"
#include "displayapp/screens/Screen.h"
#include "displayapp/screens/Symbols.h"
@@ -49,12 +50,7 @@ SettingDisplay::SettingDisplay(Pinetime::Applications::DisplayApp* app, Pinetime
lv_checkbox_set_text(cbOption[i], buffer);
cbOption[i]->user_data = this;
lv_obj_set_event_cb(cbOption[i], event_handler);
-
- // radio button style
- lv_obj_set_style_local_radius(cbOption[i], LV_CHECKBOX_PART_BULLET, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
- lv_obj_set_style_local_border_width(cbOption[i], LV_CHECKBOX_PART_BULLET, LV_STATE_CHECKED, 9);
- lv_obj_set_style_local_border_color(cbOption[i], LV_CHECKBOX_PART_BULLET, LV_STATE_CHECKED, LV_COLOR_GREEN);
- lv_obj_set_style_local_bg_color(cbOption[i], LV_CHECKBOX_PART_BULLET, LV_STATE_CHECKED, LV_COLOR_WHITE);
+ SetRadioButtonStyle(cbOption[i]);
if (settingsController.GetScreenTimeOut() == options[i]) {
lv_checkbox_set_checked(cbOption[i], true);
diff --git a/src/displayapp/screens/settings/SettingTimeFormat.cpp b/src/displayapp/screens/settings/SettingTimeFormat.cpp
index e65cb9e8..bd9af156 100644
--- a/src/displayapp/screens/settings/SettingTimeFormat.cpp
+++ b/src/displayapp/screens/settings/SettingTimeFormat.cpp
@@ -1,6 +1,7 @@
#include "displayapp/screens/settings/SettingTimeFormat.h"
#include <lvgl/lvgl.h>
#include "displayapp/DisplayApp.h"
+#include "displayapp/screens/Styles.h"
#include "displayapp/screens/Screen.h"
#include "displayapp/screens/Symbols.h"
@@ -46,12 +47,7 @@ SettingTimeFormat::SettingTimeFormat(Pinetime::Applications::DisplayApp* app, Pi
lv_checkbox_set_text(cbOption[i], options[i]);
cbOption[i]->user_data = this;
lv_obj_set_event_cb(cbOption[i], event_handler);
-
- // radio button style
- lv_obj_set_style_local_radius(cbOption[i], LV_CHECKBOX_PART_BULLET, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
- lv_obj_set_style_local_border_width(cbOption[i], LV_CHECKBOX_PART_BULLET, LV_STATE_CHECKED, 9);
- lv_obj_set_style_local_border_color(cbOption[i], LV_CHECKBOX_PART_BULLET, LV_STATE_CHECKED, LV_COLOR_GREEN);
- lv_obj_set_style_local_bg_color(cbOption[i], LV_CHECKBOX_PART_BULLET, LV_STATE_CHECKED, LV_COLOR_WHITE);
+ SetRadioButtonStyle(cbOption[i]);
}
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
diff --git a/src/displayapp/screens/settings/SettingWatchFace.cpp b/src/displayapp/screens/settings/SettingWatchFace.cpp
index 0166ae97..a24eaa15 100644
--- a/src/displayapp/screens/settings/SettingWatchFace.cpp
+++ b/src/displayapp/screens/settings/SettingWatchFace.cpp
@@ -2,6 +2,7 @@
#include <lvgl/lvgl.h>
#include "displayapp/DisplayApp.h"
#include "displayapp/screens/Screen.h"
+#include "displayapp/screens/Styles.h"
#include "displayapp/screens/Symbols.h"
using namespace Pinetime::Applications::Screens;
@@ -47,12 +48,7 @@ SettingWatchFace::SettingWatchFace(Pinetime::Applications::DisplayApp* app, Pine
lv_checkbox_set_text(cbOption[i], options[i]);
cbOption[i]->user_data = this;
lv_obj_set_event_cb(cbOption[i], event_handler);
-
- // radio button style
- lv_obj_set_style_local_radius(cbOption[i], LV_CHECKBOX_PART_BULLET, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
- lv_obj_set_style_local_border_width(cbOption[i], LV_CHECKBOX_PART_BULLET, LV_STATE_CHECKED, 9);
- lv_obj_set_style_local_border_color(cbOption[i], LV_CHECKBOX_PART_BULLET, LV_STATE_CHECKED, LV_COLOR_GREEN);
- lv_obj_set_style_local_bg_color(cbOption[i], LV_CHECKBOX_PART_BULLET, LV_STATE_CHECKED, LV_COLOR_WHITE);
+ SetRadioButtonStyle(cbOption[i]);
if (settingsController.GetClockFace() == i) {
lv_checkbox_set_checked(cbOption[i], true);