summaryrefslogtreecommitdiff
path: root/src/displayapp/screens/settings
diff options
context:
space:
mode:
Diffstat (limited to 'src/displayapp/screens/settings')
-rw-r--r--src/displayapp/screens/settings/SettingSetDate.cpp6
-rw-r--r--src/displayapp/screens/settings/SettingSetDate.h1
-rw-r--r--src/displayapp/screens/settings/SettingSetTime.cpp8
-rw-r--r--src/displayapp/screens/settings/SettingSetTime.h1
-rw-r--r--src/displayapp/screens/settings/SettingSteps.cpp6
-rw-r--r--src/displayapp/screens/settings/SettingWatchFace.cpp98
-rw-r--r--src/displayapp/screens/settings/SettingWatchFace.h11
7 files changed, 68 insertions, 63 deletions
diff --git a/src/displayapp/screens/settings/SettingSetDate.cpp b/src/displayapp/screens/settings/SettingSetDate.cpp
index 1407a98f..421aef02 100644
--- a/src/displayapp/screens/settings/SettingSetDate.cpp
+++ b/src/displayapp/screens/settings/SettingSetDate.cpp
@@ -79,9 +79,11 @@ SettingSetDate::SettingSetDate(Pinetime::Applications::DisplayApp* app, Pinetime
lv_obj_set_size(btnSetTime, 120, 48);
lv_obj_align(btnSetTime, lv_scr_act(), LV_ALIGN_IN_BOTTOM_MID, 0, 0);
lv_obj_set_style_local_bg_color(btnSetTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_MAKE(0x38, 0x38, 0x38));
- lv_obj_set_style_local_value_str(btnSetTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "Set");
+ lblSetTime = lv_label_create(btnSetTime, nullptr);
+ lv_label_set_text_static(lblSetTime, "Set");
lv_obj_set_event_cb(btnSetTime, event_handler);
lv_btn_set_state(btnSetTime, LV_BTN_STATE_DISABLED);
+ lv_obj_set_state(lblSetTime, LV_STATE_DISABLED);
}
SettingSetDate::~SettingSetDate() {
@@ -102,10 +104,12 @@ void SettingSetDate::HandleButtonPress() {
dateTimeController.Seconds(),
nrf_rtc_counter_get(portNRF_RTC_REG));
lv_btn_set_state(btnSetTime, LV_BTN_STATE_DISABLED);
+ lv_obj_set_state(lblSetTime, LV_STATE_DISABLED);
}
void SettingSetDate::CheckDay() {
const int maxDay = MaximumDayOfMonth(monthCounter.GetValue(), yearCounter.GetValue());
dayCounter.SetMax(maxDay);
lv_btn_set_state(btnSetTime, LV_BTN_STATE_RELEASED);
+ lv_obj_set_state(lblSetTime, LV_STATE_DEFAULT);
}
diff --git a/src/displayapp/screens/settings/SettingSetDate.h b/src/displayapp/screens/settings/SettingSetDate.h
index af0d654e..a0ffc683 100644
--- a/src/displayapp/screens/settings/SettingSetDate.h
+++ b/src/displayapp/screens/settings/SettingSetDate.h
@@ -21,6 +21,7 @@ namespace Pinetime {
Controllers::DateTime& dateTimeController;
lv_obj_t* btnSetTime;
+ lv_obj_t* lblSetTime;
Widgets::Counter dayCounter = Widgets::Counter(1, 31, jetbrains_mono_bold_20);
Widgets::Counter monthCounter = Widgets::Counter(1, 12, jetbrains_mono_bold_20);
diff --git a/src/displayapp/screens/settings/SettingSetTime.cpp b/src/displayapp/screens/settings/SettingSetTime.cpp
index 47b786e4..e7d824fd 100644
--- a/src/displayapp/screens/settings/SettingSetTime.cpp
+++ b/src/displayapp/screens/settings/SettingSetTime.cpp
@@ -67,13 +67,15 @@ SettingSetTime::SettingSetTime(Pinetime::Applications::DisplayApp* app,
btnSetTime->user_data = this;
lv_obj_set_size(btnSetTime, 120, 50);
lv_obj_align(btnSetTime, lv_scr_act(), LV_ALIGN_IN_BOTTOM_MID, 0, 0);
- lv_obj_set_style_local_value_str(btnSetTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "Set");
+ lblSetTime = lv_label_create(btnSetTime, nullptr);
+ lv_label_set_text_static(lblSetTime, "Set");
lv_obj_set_style_local_bg_color(btnSetTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Colors::bgAlt);
- lv_obj_set_style_local_value_color(btnSetTime, LV_BTN_PART_MAIN, LV_STATE_DISABLED, LV_COLOR_GRAY);
+ lv_obj_set_style_local_text_color(lblSetTime, LV_LABEL_PART_MAIN, LV_STATE_DISABLED, LV_COLOR_GRAY);
lv_obj_set_event_cb(btnSetTime, SetTimeEventHandler);
UpdateScreen();
lv_obj_set_state(btnSetTime, LV_STATE_DISABLED);
+ lv_obj_set_state(lblSetTime, LV_STATE_DISABLED);
}
SettingSetTime::~SettingSetTime() {
@@ -89,6 +91,7 @@ void SettingSetTime::UpdateScreen() {
}
}
lv_obj_set_state(btnSetTime, LV_STATE_DEFAULT);
+ lv_obj_set_state(lblSetTime, LV_STATE_DEFAULT);
}
void SettingSetTime::SetTime() {
@@ -104,4 +107,5 @@ void SettingSetTime::SetTime() {
0,
nrf_rtc_counter_get(portNRF_RTC_REG));
lv_obj_set_state(btnSetTime, LV_STATE_DISABLED);
+ lv_obj_set_state(lblSetTime, LV_STATE_DISABLED);
}
diff --git a/src/displayapp/screens/settings/SettingSetTime.h b/src/displayapp/screens/settings/SettingSetTime.h
index e0b42bdd..b61962c1 100644
--- a/src/displayapp/screens/settings/SettingSetTime.h
+++ b/src/displayapp/screens/settings/SettingSetTime.h
@@ -26,6 +26,7 @@ namespace Pinetime {
lv_obj_t* lblampm;
lv_obj_t* btnSetTime;
+ lv_obj_t* lblSetTime;
Widgets::Counter hourCounter = Widgets::Counter(0, 23, jetbrains_mono_42);
Widgets::Counter minuteCounter = Widgets::Counter(0, 59, jetbrains_mono_42);
};
diff --git a/src/displayapp/screens/settings/SettingSteps.cpp b/src/displayapp/screens/settings/SettingSteps.cpp
index af5bd6e9..a6b6f4a8 100644
--- a/src/displayapp/screens/settings/SettingSteps.cpp
+++ b/src/displayapp/screens/settings/SettingSteps.cpp
@@ -48,7 +48,8 @@ SettingSteps::SettingSteps(Pinetime::Applications::DisplayApp* app, Pinetime::Co
btnPlus->user_data = this;
lv_obj_set_size(btnPlus, 80, 50);
lv_obj_align(btnPlus, lv_scr_act(), LV_ALIGN_CENTER, 55, 80);
- lv_obj_set_style_local_value_str(btnPlus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "+");
+ lv_obj_t* lblPlus = lv_label_create(btnPlus, nullptr);
+ lv_label_set_text_static(lblPlus, "+");
lv_obj_set_event_cb(btnPlus, event_handler);
btnMinus = lv_btn_create(lv_scr_act(), nullptr);
@@ -56,7 +57,8 @@ SettingSteps::SettingSteps(Pinetime::Applications::DisplayApp* app, Pinetime::Co
lv_obj_set_size(btnMinus, 80, 50);
lv_obj_set_event_cb(btnMinus, event_handler);
lv_obj_align(btnMinus, lv_scr_act(), LV_ALIGN_CENTER, -55, 80);
- lv_obj_set_style_local_value_str(btnMinus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "-");
+ lv_obj_t* lblMinus = lv_label_create(btnMinus, nullptr);
+ lv_label_set_text_static(lblMinus, "-");
}
SettingSteps::~SettingSteps() {
diff --git a/src/displayapp/screens/settings/SettingWatchFace.cpp b/src/displayapp/screens/settings/SettingWatchFace.cpp
index be595a74..411cc898 100644
--- a/src/displayapp/screens/settings/SettingWatchFace.cpp
+++ b/src/displayapp/screens/settings/SettingWatchFace.cpp
@@ -1,58 +1,29 @@
#include "displayapp/screens/settings/SettingWatchFace.h"
#include <lvgl/lvgl.h>
#include "displayapp/DisplayApp.h"
+#include "displayapp/screens/CheckboxList.h"
#include "displayapp/screens/Screen.h"
#include "displayapp/screens/Styles.h"
#include "displayapp/screens/Symbols.h"
+#include "components/settings/Settings.h"
using namespace Pinetime::Applications::Screens;
-namespace {
- void event_handler(lv_obj_t* obj, lv_event_t event) {
- auto* screen = static_cast<SettingWatchFace*>(obj->user_data);
- screen->UpdateSelected(obj, event);
- }
-}
-
-constexpr std::array<const char*, 4> SettingWatchFace::options;
+constexpr const char* SettingWatchFace::title;
+constexpr const char* SettingWatchFace::symbol;
SettingWatchFace::SettingWatchFace(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController)
- : Screen(app), settingsController {settingsController} {
-
- lv_obj_t* container1 = lv_cont_create(lv_scr_act(), nullptr);
-
- lv_obj_set_style_local_bg_opa(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP);
- lv_obj_set_style_local_pad_all(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 10);
- lv_obj_set_style_local_pad_inner(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 5);
- lv_obj_set_style_local_border_width(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 0);
-
- lv_obj_set_pos(container1, 10, 60);
- lv_obj_set_width(container1, LV_HOR_RES - 20);
- lv_obj_set_height(container1, LV_VER_RES - 50);
- lv_cont_set_layout(container1, LV_LAYOUT_COLUMN_LEFT);
-
- lv_obj_t* title = lv_label_create(lv_scr_act(), nullptr);
- lv_label_set_text_static(title, "Watch face");
- lv_label_set_align(title, LV_LABEL_ALIGN_CENTER);
- lv_obj_align(title, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 10, 15);
-
- lv_obj_t* icon = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_text_color(icon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE);
- lv_label_set_text_static(icon, Symbols::home);
- lv_label_set_align(icon, LV_LABEL_ALIGN_CENTER);
- lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0);
-
- for (unsigned int i = 0; i < options.size(); i++) {
- cbOption[i] = lv_checkbox_create(container1, nullptr);
- lv_checkbox_set_text(cbOption[i], options[i]);
- cbOption[i]->user_data = this;
- lv_obj_set_event_cb(cbOption[i], event_handler);
- SetRadioButtonStyle(cbOption[i]);
-
- if (settingsController.GetClockFace() == i) {
- lv_checkbox_set_checked(cbOption[i], true);
- }
- }
+ : Screen(app),
+ settingsController {settingsController},
+ screens {app,
+ settingsController.GetWatchfacesMenu(),
+ {[this]() -> std::unique_ptr<Screen> {
+ return CreateScreen1();
+ },
+ [this]() -> std::unique_ptr<Screen> {
+ return CreateScreen2();
+ }},
+ Screens::ScreenListModes::UpDown} {
}
SettingWatchFace::~SettingWatchFace() {
@@ -60,15 +31,32 @@ SettingWatchFace::~SettingWatchFace() {
settingsController.SaveSettings();
}
-void SettingWatchFace::UpdateSelected(lv_obj_t* object, lv_event_t event) {
- if (event == LV_EVENT_VALUE_CHANGED) {
- for (unsigned int i = 0; i < options.size(); i++) {
- if (object == cbOption[i]) {
- lv_checkbox_set_checked(cbOption[i], true);
- settingsController.SetClockFace(i);
- } else {
- lv_checkbox_set_checked(cbOption[i], false);
- }
- }
- }
+bool SettingWatchFace::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
+ return screens.OnTouchEvent(event);
+}
+
+std::unique_ptr<Screen> SettingWatchFace::CreateScreen1() {
+ std::array<const char*, 4> watchfaces {"Digital face", "Analog face", "PineTimeStyle", "Terminal"};
+ return std::make_unique<Screens::CheckboxList>(0,
+ 2,
+ app,
+ settingsController,
+ title,
+ symbol,
+ &Controllers::Settings::SetClockFace,
+ &Controllers::Settings::GetClockFace,
+ watchfaces);
+}
+
+std::unique_ptr<Screen> SettingWatchFace::CreateScreen2() {
+ std::array<const char*, 4> watchfaces {"Infineat face", "Casio G7710", "", ""};
+ return std::make_unique<Screens::CheckboxList>(1,
+ 2,
+ app,
+ settingsController,
+ title,
+ symbol,
+ &Controllers::Settings::SetClockFace,
+ &Controllers::Settings::GetClockFace,
+ watchfaces);
}
diff --git a/src/displayapp/screens/settings/SettingWatchFace.h b/src/displayapp/screens/settings/SettingWatchFace.h
index d65f4a22..7d14554e 100644
--- a/src/displayapp/screens/settings/SettingWatchFace.h
+++ b/src/displayapp/screens/settings/SettingWatchFace.h
@@ -4,8 +4,10 @@
#include <cstdint>
#include <lvgl/lvgl.h>
+#include "displayapp/screens/ScreenList.h"
#include "components/settings/Settings.h"
#include "displayapp/screens/Screen.h"
+#include "displayapp/screens/Symbols.h"
namespace Pinetime {
@@ -17,13 +19,16 @@ namespace Pinetime {
SettingWatchFace(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
~SettingWatchFace() override;
- void UpdateSelected(lv_obj_t* object, lv_event_t event);
+ bool OnTouchEvent(TouchEvents event) override;
private:
- static constexpr std::array<const char*, 4> options = {"Digital face", "Analog face", "PineTimeStyle", "Terminal"};
Controllers::Settings& settingsController;
+ ScreenList<2> screens;
- lv_obj_t* cbOption[options.size()];
+ static constexpr const char* title = "Watch face";
+ static constexpr const char* symbol = Symbols::home;
+ std::unique_ptr<Screen> CreateScreen1();
+ std::unique_ptr<Screen> CreateScreen2();
};
}
}