Merge pull request #718 from kieranc/pts-settings
Integrate color picker into PineTimeStyle watchface
This commit is contained in:
commit
395590d2d8
|
@ -445,7 +445,6 @@ list(APPEND SOURCE_FILES
|
||||||
displayapp/screens/settings/SettingWakeUp.cpp
|
displayapp/screens/settings/SettingWakeUp.cpp
|
||||||
displayapp/screens/settings/SettingDisplay.cpp
|
displayapp/screens/settings/SettingDisplay.cpp
|
||||||
displayapp/screens/settings/SettingSteps.cpp
|
displayapp/screens/settings/SettingSteps.cpp
|
||||||
displayapp/screens/settings/SettingPineTimeStyle.cpp
|
|
||||||
displayapp/screens/settings/SettingSetDate.cpp
|
displayapp/screens/settings/SettingSetDate.cpp
|
||||||
displayapp/screens/settings/SettingSetTime.cpp
|
displayapp/screens/settings/SettingSetTime.cpp
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,6 @@ namespace Pinetime {
|
||||||
SettingDisplay,
|
SettingDisplay,
|
||||||
SettingWakeUp,
|
SettingWakeUp,
|
||||||
SettingSteps,
|
SettingSteps,
|
||||||
SettingPineTimeStyle,
|
|
||||||
SettingSetDate,
|
SettingSetDate,
|
||||||
SettingSetTime,
|
SettingSetTime,
|
||||||
Error,
|
Error,
|
||||||
|
|
|
@ -45,7 +45,6 @@
|
||||||
#include "displayapp/screens/settings/SettingWakeUp.h"
|
#include "displayapp/screens/settings/SettingWakeUp.h"
|
||||||
#include "displayapp/screens/settings/SettingDisplay.h"
|
#include "displayapp/screens/settings/SettingDisplay.h"
|
||||||
#include "displayapp/screens/settings/SettingSteps.h"
|
#include "displayapp/screens/settings/SettingSteps.h"
|
||||||
#include "displayapp/screens/settings/SettingPineTimeStyle.h"
|
|
||||||
#include "displayapp/screens/settings/SettingSetDate.h"
|
#include "displayapp/screens/settings/SettingSetDate.h"
|
||||||
#include "displayapp/screens/settings/SettingSetTime.h"
|
#include "displayapp/screens/settings/SettingSetTime.h"
|
||||||
|
|
||||||
|
@ -255,10 +254,10 @@ void DisplayApp::Refresh() {
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case Messages::ButtonPushed:
|
case Messages::ButtonPushed:
|
||||||
|
if (!currentScreen->OnButtonPushed()) {
|
||||||
if (currentApp == Apps::Clock) {
|
if (currentApp == Apps::Clock) {
|
||||||
PushMessageToSystemTask(System::Messages::GoToSleep);
|
PushMessageToSystemTask(System::Messages::GoToSleep);
|
||||||
} else {
|
} else {
|
||||||
if (!currentScreen->OnButtonPushed()) {
|
|
||||||
LoadApp(returnToApp, returnDirection);
|
LoadApp(returnToApp, returnDirection);
|
||||||
brightnessController.Set(settingsController.GetBrightness());
|
brightnessController.Set(settingsController.GetBrightness());
|
||||||
brightnessController.Backup();
|
brightnessController.Backup();
|
||||||
|
@ -416,10 +415,6 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
|
||||||
currentScreen = std::make_unique<Screens::SettingSetTime>(this, dateTimeController);
|
currentScreen = std::make_unique<Screens::SettingSetTime>(this, dateTimeController);
|
||||||
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
||||||
break;
|
break;
|
||||||
case Apps::SettingPineTimeStyle:
|
|
||||||
currentScreen = std::make_unique<Screens::SettingPineTimeStyle>(this, settingsController);
|
|
||||||
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
|
||||||
break;
|
|
||||||
case Apps::BatteryInfo:
|
case Apps::BatteryInfo:
|
||||||
currentScreen = std::make_unique<Screens::BatteryInfo>(this, batteryController);
|
currentScreen = std::make_unique<Screens::BatteryInfo>(this, batteryController);
|
||||||
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
||||||
|
|
|
@ -55,6 +55,10 @@ bool Clock::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
||||||
return screen->OnTouchEvent(event);
|
return screen->OnTouchEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Clock::OnButtonPushed() {
|
||||||
|
return screen->OnButtonPushed();
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<Screen> Clock::WatchFaceDigitalScreen() {
|
std::unique_ptr<Screen> Clock::WatchFaceDigitalScreen() {
|
||||||
return std::make_unique<Screens::WatchFaceDigital>(app,
|
return std::make_unique<Screens::WatchFaceDigital>(app,
|
||||||
dateTimeController,
|
dateTimeController,
|
||||||
|
|
|
@ -32,6 +32,7 @@ namespace Pinetime {
|
||||||
~Clock() override;
|
~Clock() override;
|
||||||
|
|
||||||
bool OnTouchEvent(TouchEvents event) override;
|
bool OnTouchEvent(TouchEvents event) override;
|
||||||
|
bool OnButtonPushed() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Controllers::DateTime& dateTimeController;
|
Controllers::DateTime& dateTimeController;
|
||||||
|
|
|
@ -37,6 +37,13 @@
|
||||||
|
|
||||||
using namespace Pinetime::Applications::Screens;
|
using namespace Pinetime::Applications::Screens;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
void event_handler(lv_obj_t* obj, lv_event_t event) {
|
||||||
|
auto* screen = static_cast<PineTimeStyle*>(obj->user_data);
|
||||||
|
screen->UpdateSelected(obj, event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PineTimeStyle::PineTimeStyle(DisplayApp* app,
|
PineTimeStyle::PineTimeStyle(DisplayApp* app,
|
||||||
Controllers::DateTime& dateTimeController,
|
Controllers::DateTime& dateTimeController,
|
||||||
Controllers::Battery& batteryController,
|
Controllers::Battery& batteryController,
|
||||||
|
@ -53,16 +60,13 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
|
||||||
settingsController {settingsController},
|
settingsController {settingsController},
|
||||||
motionController {motionController} {
|
motionController {motionController} {
|
||||||
|
|
||||||
// This sets the watchface number to return to after leaving the menu
|
|
||||||
settingsController.SetClockFace(2);
|
|
||||||
|
|
||||||
displayedChar[0] = 0;
|
displayedChar[0] = 0;
|
||||||
displayedChar[1] = 0;
|
displayedChar[1] = 0;
|
||||||
displayedChar[2] = 0;
|
displayedChar[2] = 0;
|
||||||
displayedChar[3] = 0;
|
displayedChar[3] = 0;
|
||||||
displayedChar[4] = 0;
|
displayedChar[4] = 0;
|
||||||
|
|
||||||
//Create a 200px wide background rectangle
|
// Create a 200px wide background rectangle
|
||||||
timebar = lv_obj_create(lv_scr_act(), nullptr);
|
timebar = lv_obj_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(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_style_local_radius(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
||||||
|
@ -97,7 +101,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
|
||||||
|
|
||||||
// Display icons
|
// Display icons
|
||||||
batteryIcon = lv_label_create(lv_scr_act(), nullptr);
|
batteryIcon = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
||||||
lv_label_set_text(batteryIcon, Symbols::batteryFull);
|
lv_label_set_text(batteryIcon, Symbols::batteryFull);
|
||||||
lv_obj_align(batteryIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 2);
|
lv_obj_align(batteryIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 2);
|
||||||
lv_obj_set_auto_realign(batteryIcon, true);
|
lv_obj_set_auto_realign(batteryIcon, true);
|
||||||
|
@ -112,59 +116,63 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
|
||||||
|
|
||||||
// Calendar icon
|
// Calendar icon
|
||||||
calendarOuter = lv_obj_create(lv_scr_act(), nullptr);
|
calendarOuter = lv_obj_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_bg_color(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
lv_obj_set_style_local_bg_color(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
||||||
lv_obj_set_style_local_radius(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
lv_obj_set_style_local_radius(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
||||||
lv_obj_set_size(calendarOuter, 34, 34);
|
lv_obj_set_size(calendarOuter, 34, 34);
|
||||||
lv_obj_align(calendarOuter, sidebar, LV_ALIGN_CENTER, 0, 0);
|
lv_obj_align(calendarOuter, sidebar, LV_ALIGN_CENTER, 0, 0);
|
||||||
|
|
||||||
calendarInner = lv_obj_create(lv_scr_act(), nullptr);
|
calendarInner = lv_obj_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_bg_color(calendarInner, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xffffff));
|
lv_obj_set_style_local_bg_color(calendarInner, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
||||||
lv_obj_set_style_local_radius(calendarInner, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
lv_obj_set_style_local_radius(calendarInner, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
||||||
lv_obj_set_size(calendarInner, 27, 27);
|
lv_obj_set_size(calendarInner, 27, 27);
|
||||||
lv_obj_align(calendarInner, calendarOuter, LV_ALIGN_CENTER, 0, 0);
|
lv_obj_align(calendarInner, calendarOuter, LV_ALIGN_CENTER, 0, 0);
|
||||||
|
|
||||||
calendarBar1 = lv_obj_create(lv_scr_act(), nullptr);
|
calendarBar1 = lv_obj_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_bg_color(calendarBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
lv_obj_set_style_local_bg_color(calendarBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
||||||
lv_obj_set_style_local_radius(calendarBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
lv_obj_set_style_local_radius(calendarBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
||||||
lv_obj_set_size(calendarBar1, 3, 12);
|
lv_obj_set_size(calendarBar1, 3, 12);
|
||||||
lv_obj_align(calendarBar1, calendarOuter, LV_ALIGN_IN_TOP_MID, -6, -3);
|
lv_obj_align(calendarBar1, calendarOuter, LV_ALIGN_IN_TOP_MID, -6, -3);
|
||||||
|
|
||||||
calendarBar2 = lv_obj_create(lv_scr_act(), nullptr);
|
calendarBar2 = lv_obj_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_bg_color(calendarBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
lv_obj_set_style_local_bg_color(calendarBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
||||||
lv_obj_set_style_local_radius(calendarBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
lv_obj_set_style_local_radius(calendarBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
||||||
lv_obj_set_size(calendarBar2, 3, 12);
|
lv_obj_set_size(calendarBar2, 3, 12);
|
||||||
lv_obj_align(calendarBar2, calendarOuter, LV_ALIGN_IN_TOP_MID, 6, -3);
|
lv_obj_align(calendarBar2, calendarOuter, LV_ALIGN_IN_TOP_MID, 6, -3);
|
||||||
|
|
||||||
calendarCrossBar1 = lv_obj_create(lv_scr_act(), nullptr);
|
calendarCrossBar1 = lv_obj_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_bg_color(calendarCrossBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
lv_obj_set_style_local_bg_color(calendarCrossBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
||||||
lv_obj_set_style_local_radius(calendarCrossBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
lv_obj_set_style_local_radius(calendarCrossBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
||||||
lv_obj_set_size(calendarCrossBar1, 8, 3);
|
lv_obj_set_size(calendarCrossBar1, 8, 3);
|
||||||
lv_obj_align(calendarCrossBar1, calendarBar1, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
lv_obj_align(calendarCrossBar1, calendarBar1, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
||||||
|
|
||||||
calendarCrossBar2 = lv_obj_create(lv_scr_act(), nullptr);
|
calendarCrossBar2 = lv_obj_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_bg_color(calendarCrossBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
lv_obj_set_style_local_bg_color(calendarCrossBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
||||||
lv_obj_set_style_local_radius(calendarCrossBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
lv_obj_set_style_local_radius(calendarCrossBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
||||||
lv_obj_set_size(calendarCrossBar2, 8, 3);
|
lv_obj_set_size(calendarCrossBar2, 8, 3);
|
||||||
lv_obj_align(calendarCrossBar2, calendarBar2, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
lv_obj_align(calendarCrossBar2, calendarBar2, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
||||||
|
|
||||||
// Display date
|
// Display date
|
||||||
dateDayOfWeek = lv_label_create(lv_scr_act(), nullptr);
|
dateDayOfWeek = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_text_color(dateDayOfWeek, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
lv_obj_set_style_local_text_color(dateDayOfWeek, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
||||||
lv_label_set_text(dateDayOfWeek, "THU");
|
lv_label_set_text(dateDayOfWeek, "THU");
|
||||||
lv_obj_align(dateDayOfWeek, sidebar, LV_ALIGN_CENTER, 0, -34);
|
lv_obj_align(dateDayOfWeek, sidebar, LV_ALIGN_CENTER, 0, -34);
|
||||||
|
|
||||||
dateDay = lv_label_create(lv_scr_act(), nullptr);
|
dateDay = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_text_color(dateDay, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
lv_obj_set_style_local_text_color(dateDay, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
||||||
lv_label_set_text(dateDay, "25");
|
lv_label_set_text(dateDay, "25");
|
||||||
lv_obj_align(dateDay, sidebar, LV_ALIGN_CENTER, 0, 3);
|
lv_obj_align(dateDay, sidebar, LV_ALIGN_CENTER, 0, 3);
|
||||||
|
|
||||||
dateMonth = lv_label_create(lv_scr_act(), nullptr);
|
dateMonth = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_style_local_text_color(dateMonth, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
lv_obj_set_style_local_text_color(dateMonth, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
||||||
lv_label_set_text(dateMonth, "MAR");
|
lv_label_set_text(dateMonth, "MAR");
|
||||||
lv_obj_align(dateMonth, sidebar, LV_ALIGN_CENTER, 0, 32);
|
lv_obj_align(dateMonth, sidebar, LV_ALIGN_CENTER, 0, 32);
|
||||||
|
|
||||||
// Step count gauge
|
// Step count gauge
|
||||||
|
if (settingsController.GetPTSColorBar() == Pinetime::Controllers::Settings::Colors::White) {
|
||||||
|
needle_colors[0] = LV_COLOR_BLACK;
|
||||||
|
} else {
|
||||||
needle_colors[0] = LV_COLOR_WHITE;
|
needle_colors[0] = LV_COLOR_WHITE;
|
||||||
|
}
|
||||||
stepGauge = lv_gauge_create(lv_scr_act(), nullptr);
|
stepGauge = lv_gauge_create(lv_scr_act(), nullptr);
|
||||||
lv_gauge_set_needle_count(stepGauge, 1, needle_colors);
|
lv_gauge_set_needle_count(stepGauge, 1, needle_colors);
|
||||||
lv_obj_set_size(stepGauge, 40, 40);
|
lv_obj_set_size(stepGauge, 40, 40);
|
||||||
|
@ -193,6 +201,100 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
|
||||||
lv_obj_set_pos(backgroundLabel, 0, 0);
|
lv_obj_set_pos(backgroundLabel, 0, 0);
|
||||||
lv_label_set_text(backgroundLabel, "");
|
lv_label_set_text(backgroundLabel, "");
|
||||||
|
|
||||||
|
btnNextTime = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
|
btnNextTime->user_data = this;
|
||||||
|
lv_obj_set_size(btnNextTime, 60, 60);
|
||||||
|
lv_obj_align(btnNextTime, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -15, -80);
|
||||||
|
lv_obj_set_style_local_bg_opa(btnNextTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
|
||||||
|
lv_obj_set_style_local_value_str(btnNextTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, ">");
|
||||||
|
lv_obj_set_event_cb(btnNextTime, event_handler);
|
||||||
|
lv_obj_set_hidden(btnNextTime, true);
|
||||||
|
|
||||||
|
btnPrevTime = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
|
btnPrevTime->user_data = this;
|
||||||
|
lv_obj_set_size(btnPrevTime, 60, 60);
|
||||||
|
lv_obj_align(btnPrevTime, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 15, -80);
|
||||||
|
lv_obj_set_style_local_bg_opa(btnPrevTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
|
||||||
|
lv_obj_set_style_local_value_str(btnPrevTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<");
|
||||||
|
lv_obj_set_event_cb(btnPrevTime, event_handler);
|
||||||
|
lv_obj_set_hidden(btnPrevTime, true);
|
||||||
|
|
||||||
|
btnNextBar = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
|
btnNextBar->user_data = this;
|
||||||
|
lv_obj_set_size(btnNextBar, 60, 60);
|
||||||
|
lv_obj_align(btnNextBar, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -15, 0);
|
||||||
|
lv_obj_set_style_local_bg_opa(btnNextBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
|
||||||
|
lv_obj_set_style_local_value_str(btnNextBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, ">");
|
||||||
|
lv_obj_set_event_cb(btnNextBar, event_handler);
|
||||||
|
lv_obj_set_hidden(btnNextBar, true);
|
||||||
|
|
||||||
|
btnPrevBar = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
|
btnPrevBar->user_data = this;
|
||||||
|
lv_obj_set_size(btnPrevBar, 60, 60);
|
||||||
|
lv_obj_align(btnPrevBar, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 15, 0);
|
||||||
|
lv_obj_set_style_local_bg_opa(btnPrevBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
|
||||||
|
lv_obj_set_style_local_value_str(btnPrevBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<");
|
||||||
|
lv_obj_set_event_cb(btnPrevBar, event_handler);
|
||||||
|
lv_obj_set_hidden(btnPrevBar, true);
|
||||||
|
|
||||||
|
btnNextBG = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
|
btnNextBG->user_data = this;
|
||||||
|
lv_obj_set_size(btnNextBG, 60, 60);
|
||||||
|
lv_obj_align(btnNextBG, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -15, 80);
|
||||||
|
lv_obj_set_style_local_bg_opa(btnNextBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
|
||||||
|
lv_obj_set_style_local_value_str(btnNextBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, ">");
|
||||||
|
lv_obj_set_event_cb(btnNextBG, event_handler);
|
||||||
|
lv_obj_set_hidden(btnNextBG, true);
|
||||||
|
|
||||||
|
btnPrevBG = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
|
btnPrevBG->user_data = this;
|
||||||
|
lv_obj_set_size(btnPrevBG, 60, 60);
|
||||||
|
lv_obj_align(btnPrevBG, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 15, 80);
|
||||||
|
lv_obj_set_style_local_bg_opa(btnPrevBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
|
||||||
|
lv_obj_set_style_local_value_str(btnPrevBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<");
|
||||||
|
lv_obj_set_event_cb(btnPrevBG, event_handler);
|
||||||
|
lv_obj_set_hidden(btnPrevBG, true);
|
||||||
|
|
||||||
|
btnReset = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
|
btnReset->user_data = this;
|
||||||
|
lv_obj_set_size(btnReset, 60, 60);
|
||||||
|
lv_obj_align(btnReset, lv_scr_act(), LV_ALIGN_CENTER, 0, 80);
|
||||||
|
lv_obj_set_style_local_bg_opa(btnReset, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
|
||||||
|
lv_obj_set_style_local_value_str(btnReset, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "Rst");
|
||||||
|
lv_obj_set_event_cb(btnReset, event_handler);
|
||||||
|
lv_obj_set_hidden(btnReset, true);
|
||||||
|
|
||||||
|
btnRandom = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
|
btnRandom->user_data = this;
|
||||||
|
lv_obj_set_size(btnRandom, 60, 60);
|
||||||
|
lv_obj_align(btnRandom, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
|
||||||
|
lv_obj_set_style_local_bg_opa(btnRandom, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
|
||||||
|
lv_obj_set_style_local_value_str(btnRandom, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "Rnd");
|
||||||
|
lv_obj_set_event_cb(btnRandom, event_handler);
|
||||||
|
lv_obj_set_hidden(btnRandom, true);
|
||||||
|
|
||||||
|
btnClose = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
|
btnClose->user_data = this;
|
||||||
|
lv_obj_set_size(btnClose, 60, 60);
|
||||||
|
lv_obj_align(btnClose, lv_scr_act(), LV_ALIGN_CENTER, 0, -80);
|
||||||
|
lv_obj_set_style_local_bg_opa(btnClose, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
|
||||||
|
lv_obj_set_style_local_value_str(btnClose, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "X");
|
||||||
|
lv_obj_set_event_cb(btnClose, event_handler);
|
||||||
|
lv_obj_set_hidden(btnClose, true);
|
||||||
|
|
||||||
|
btnSet = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
|
btnSet->user_data = this;
|
||||||
|
lv_obj_set_height(btnSet, 150);
|
||||||
|
lv_obj_set_width(btnSet, 150);
|
||||||
|
lv_obj_align(btnSet, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
|
||||||
|
lv_obj_set_style_local_radius(btnSet, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 30);
|
||||||
|
lv_obj_set_style_local_bg_opa(btnSet, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
|
||||||
|
lv_obj_set_event_cb(btnSet, event_handler);
|
||||||
|
lbl_btnSet = lv_label_create(btnSet, nullptr);
|
||||||
|
lv_obj_set_style_local_text_font(lbl_btnSet, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48);
|
||||||
|
lv_label_set_text_static(lbl_btnSet, Symbols::settings);
|
||||||
|
lv_obj_set_hidden(btnSet, true);
|
||||||
|
|
||||||
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
|
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
@ -202,6 +304,39 @@ PineTimeStyle::~PineTimeStyle() {
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PineTimeStyle::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
||||||
|
if ((event == Pinetime::Applications::TouchEvents::LongTap) && lv_obj_get_hidden(btnRandom)) {
|
||||||
|
lv_obj_set_hidden(btnSet, false);
|
||||||
|
savedTick = lv_tick_get();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if ((event == Pinetime::Applications::TouchEvents::DoubleTap) && (lv_obj_get_hidden(btnRandom) == false)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PineTimeStyle::CloseMenu() {
|
||||||
|
settingsController.SaveSettings();
|
||||||
|
lv_obj_set_hidden(btnNextTime, true);
|
||||||
|
lv_obj_set_hidden(btnPrevTime, true);
|
||||||
|
lv_obj_set_hidden(btnNextBar, true);
|
||||||
|
lv_obj_set_hidden(btnPrevBar, true);
|
||||||
|
lv_obj_set_hidden(btnNextBG, true);
|
||||||
|
lv_obj_set_hidden(btnPrevBG, true);
|
||||||
|
lv_obj_set_hidden(btnReset, true);
|
||||||
|
lv_obj_set_hidden(btnRandom, true);
|
||||||
|
lv_obj_set_hidden(btnClose, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PineTimeStyle::OnButtonPushed() {
|
||||||
|
if (!lv_obj_get_hidden(btnClose)) {
|
||||||
|
CloseMenu();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void PineTimeStyle::SetBatteryIcon() {
|
void PineTimeStyle::SetBatteryIcon() {
|
||||||
auto batteryPercent = batteryPercentRemaining.Get();
|
auto batteryPercent = batteryPercentRemaining.Get();
|
||||||
lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent));
|
lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent));
|
||||||
|
@ -323,4 +458,154 @@ void PineTimeStyle::Refresh() {
|
||||||
lv_obj_set_style_local_scale_grad_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
lv_obj_set_style_local_scale_grad_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!lv_obj_get_hidden(btnSet)) {
|
||||||
|
if ((savedTick > 0) && (lv_tick_get() - savedTick > 3000)) {
|
||||||
|
lv_obj_set_hidden(btnSet, true);
|
||||||
|
savedTick = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PineTimeStyle::UpdateSelected(lv_obj_t* object, lv_event_t event) {
|
||||||
|
auto valueTime = settingsController.GetPTSColorTime();
|
||||||
|
auto valueBar = settingsController.GetPTSColorBar();
|
||||||
|
auto valueBG = settingsController.GetPTSColorBG();
|
||||||
|
|
||||||
|
if (event == LV_EVENT_CLICKED) {
|
||||||
|
if (object == btnNextTime) {
|
||||||
|
valueTime = GetNext(valueTime);
|
||||||
|
if (valueTime == valueBG) {
|
||||||
|
valueTime = GetNext(valueTime);
|
||||||
|
}
|
||||||
|
settingsController.SetPTSColorTime(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) {
|
||||||
|
valueTime = GetPrevious(valueTime);
|
||||||
|
if (valueTime == valueBG) {
|
||||||
|
valueTime = GetPrevious(valueTime);
|
||||||
|
}
|
||||||
|
settingsController.SetPTSColorTime(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) {
|
||||||
|
valueBar = GetNext(valueBar);
|
||||||
|
if (valueBar == Controllers::Settings::Colors::Black) {
|
||||||
|
valueBar = GetNext(valueBar);
|
||||||
|
}
|
||||||
|
if (valueBar == Controllers::Settings::Colors::White) {
|
||||||
|
needle_colors[0] = LV_COLOR_BLACK;
|
||||||
|
} else {
|
||||||
|
needle_colors[0] = LV_COLOR_WHITE;
|
||||||
|
}
|
||||||
|
settingsController.SetPTSColorBar(valueBar);
|
||||||
|
lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBar));
|
||||||
|
}
|
||||||
|
if (object == btnPrevBar) {
|
||||||
|
valueBar = GetPrevious(valueBar);
|
||||||
|
if (valueBar == Controllers::Settings::Colors::Black) {
|
||||||
|
valueBar = GetPrevious(valueBar);
|
||||||
|
}
|
||||||
|
if (valueBar == Controllers::Settings::Colors::White) {
|
||||||
|
needle_colors[0] = LV_COLOR_BLACK;
|
||||||
|
} else {
|
||||||
|
needle_colors[0] = LV_COLOR_WHITE;
|
||||||
|
}
|
||||||
|
settingsController.SetPTSColorBar(valueBar);
|
||||||
|
lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBar));
|
||||||
|
}
|
||||||
|
if (object == btnNextBG) {
|
||||||
|
valueBG = GetNext(valueBG);
|
||||||
|
if (valueBG == valueTime) {
|
||||||
|
valueBG = GetNext(valueBG);
|
||||||
|
}
|
||||||
|
settingsController.SetPTSColorBG(valueBG);
|
||||||
|
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBG));
|
||||||
|
}
|
||||||
|
if (object == btnPrevBG) {
|
||||||
|
valueBG = GetPrevious(valueBG);
|
||||||
|
if (valueBG == valueTime) {
|
||||||
|
valueBG = GetPrevious(valueBG);
|
||||||
|
}
|
||||||
|
settingsController.SetPTSColorBG(valueBG);
|
||||||
|
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBG));
|
||||||
|
}
|
||||||
|
if (object == btnReset) {
|
||||||
|
needle_colors[0] = LV_COLOR_WHITE;
|
||||||
|
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) {
|
||||||
|
valueTime = static_cast<Controllers::Settings::Colors>(rand() % 17);
|
||||||
|
valueBar = static_cast<Controllers::Settings::Colors>(rand() % 17);
|
||||||
|
valueBG = static_cast<Controllers::Settings::Colors>(rand() % 17);
|
||||||
|
if (valueTime == valueBG) {
|
||||||
|
valueBG = GetNext(valueBG);
|
||||||
|
}
|
||||||
|
if (valueBar == Controllers::Settings::Colors::Black) {
|
||||||
|
valueBar = GetPrevious(valueBar);
|
||||||
|
}
|
||||||
|
if (valueBar == Controllers::Settings::Colors::White) {
|
||||||
|
needle_colors[0] = LV_COLOR_BLACK;
|
||||||
|
} else {
|
||||||
|
needle_colors[0] = LV_COLOR_WHITE;
|
||||||
|
}
|
||||||
|
settingsController.SetPTSColorTime(static_cast<Controllers::Settings::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));
|
||||||
|
settingsController.SetPTSColorBar(static_cast<Controllers::Settings::Colors>(valueBar));
|
||||||
|
lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBar));
|
||||||
|
settingsController.SetPTSColorBG(static_cast<Controllers::Settings::Colors>(valueBG));
|
||||||
|
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBG));
|
||||||
|
}
|
||||||
|
if (object == btnClose) {
|
||||||
|
CloseMenu();
|
||||||
|
}
|
||||||
|
if (object == btnSet) {
|
||||||
|
lv_obj_set_hidden(btnSet, true);
|
||||||
|
lv_obj_set_hidden(btnNextTime, false);
|
||||||
|
lv_obj_set_hidden(btnPrevTime, false);
|
||||||
|
lv_obj_set_hidden(btnNextBar, false);
|
||||||
|
lv_obj_set_hidden(btnPrevBar, false);
|
||||||
|
lv_obj_set_hidden(btnNextBG, false);
|
||||||
|
lv_obj_set_hidden(btnPrevBG, false);
|
||||||
|
lv_obj_set_hidden(btnReset, false);
|
||||||
|
lv_obj_set_hidden(btnRandom, false);
|
||||||
|
lv_obj_set_hidden(btnClose, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Pinetime::Controllers::Settings::Colors PineTimeStyle::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 PineTimeStyle::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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "displayapp/screens/Screen.h"
|
#include "displayapp/screens/Screen.h"
|
||||||
|
#include "displayapp/Colors.h"
|
||||||
#include "components/datetime/DateTimeController.h"
|
#include "components/datetime/DateTimeController.h"
|
||||||
|
|
||||||
namespace Pinetime {
|
namespace Pinetime {
|
||||||
|
@ -30,8 +31,13 @@ namespace Pinetime {
|
||||||
Controllers::MotionController& motionController);
|
Controllers::MotionController& motionController);
|
||||||
~PineTimeStyle() override;
|
~PineTimeStyle() override;
|
||||||
|
|
||||||
|
bool OnTouchEvent(TouchEvents event) override;
|
||||||
|
bool OnButtonPushed() override;
|
||||||
|
|
||||||
void Refresh() override;
|
void Refresh() override;
|
||||||
|
|
||||||
|
void UpdateSelected(lv_obj_t *object, lv_event_t event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char displayedChar[5];
|
char displayedChar[5];
|
||||||
|
|
||||||
|
@ -39,6 +45,7 @@ namespace Pinetime {
|
||||||
Pinetime::Controllers::DateTime::Months currentMonth = Pinetime::Controllers::DateTime::Months::Unknown;
|
Pinetime::Controllers::DateTime::Months currentMonth = Pinetime::Controllers::DateTime::Months::Unknown;
|
||||||
Pinetime::Controllers::DateTime::Days currentDayOfWeek = Pinetime::Controllers::DateTime::Days::Unknown;
|
Pinetime::Controllers::DateTime::Days currentDayOfWeek = Pinetime::Controllers::DateTime::Days::Unknown;
|
||||||
uint8_t currentDay = 0;
|
uint8_t currentDay = 0;
|
||||||
|
uint32_t savedTick = 0;
|
||||||
|
|
||||||
DirtyValue<uint8_t> batteryPercentRemaining {};
|
DirtyValue<uint8_t> batteryPercentRemaining {};
|
||||||
DirtyValue<bool> isCharging {};
|
DirtyValue<bool> isCharging {};
|
||||||
|
@ -48,6 +55,18 @@ namespace Pinetime {
|
||||||
DirtyValue<uint32_t> stepCount {};
|
DirtyValue<uint32_t> stepCount {};
|
||||||
DirtyValue<bool> notificationState {};
|
DirtyValue<bool> notificationState {};
|
||||||
|
|
||||||
|
static Pinetime::Controllers::Settings::Colors GetNext(Controllers::Settings::Colors color);
|
||||||
|
static Pinetime::Controllers::Settings::Colors GetPrevious(Controllers::Settings::Colors color);
|
||||||
|
|
||||||
|
lv_obj_t* btnNextTime;
|
||||||
|
lv_obj_t* btnPrevTime;
|
||||||
|
lv_obj_t* btnNextBar;
|
||||||
|
lv_obj_t* btnPrevBar;
|
||||||
|
lv_obj_t* btnNextBG;
|
||||||
|
lv_obj_t* btnPrevBG;
|
||||||
|
lv_obj_t* btnReset;
|
||||||
|
lv_obj_t* btnRandom;
|
||||||
|
lv_obj_t* btnClose;
|
||||||
lv_obj_t* timebar;
|
lv_obj_t* timebar;
|
||||||
lv_obj_t* sidebar;
|
lv_obj_t* sidebar;
|
||||||
lv_obj_t* timeDD1;
|
lv_obj_t* timeDD1;
|
||||||
|
@ -67,6 +86,8 @@ namespace Pinetime {
|
||||||
lv_obj_t* calendarCrossBar2;
|
lv_obj_t* calendarCrossBar2;
|
||||||
lv_obj_t* notificationIcon;
|
lv_obj_t* notificationIcon;
|
||||||
lv_obj_t* stepGauge;
|
lv_obj_t* stepGauge;
|
||||||
|
lv_obj_t* btnSet;
|
||||||
|
lv_obj_t* lbl_btnSet;
|
||||||
lv_color_t needle_colors[1];
|
lv_color_t needle_colors[1];
|
||||||
|
|
||||||
Controllers::DateTime& dateTimeController;
|
Controllers::DateTime& dateTimeController;
|
||||||
|
@ -77,6 +98,7 @@ namespace Pinetime {
|
||||||
Controllers::MotionController& motionController;
|
Controllers::MotionController& motionController;
|
||||||
|
|
||||||
void SetBatteryIcon();
|
void SetBatteryIcon();
|
||||||
|
void CloseMenu();
|
||||||
void AlignIcons();
|
void AlignIcons();
|
||||||
|
|
||||||
lv_task_t* taskRefresh;
|
lv_task_t* taskRefresh;
|
||||||
|
|
|
@ -1,318 +0,0 @@
|
||||||
#include "displayapp/screens/settings/SettingPineTimeStyle.h"
|
|
||||||
#include <lvgl/lvgl.h>
|
|
||||||
#include <displayapp/Colors.h>
|
|
||||||
#include "displayapp/DisplayApp.h"
|
|
||||||
#include "displayapp/screens/Symbols.h"
|
|
||||||
|
|
||||||
using namespace Pinetime::Applications::Screens;
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
static void event_handler(lv_obj_t* obj, lv_event_t event) {
|
|
||||||
SettingPineTimeStyle* screen = static_cast<SettingPineTimeStyle*>(obj->user_data);
|
|
||||||
screen->UpdateSelected(obj, event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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, 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);
|
|
||||||
|
|
||||||
// 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, 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, 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, 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);
|
|
||||||
|
|
||||||
// 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, 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);
|
|
||||||
|
|
||||||
// Display icons
|
|
||||||
|
|
||||||
batteryIcon = lv_label_create(lv_scr_act(), nullptr);
|
|
||||||
lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
|
||||||
lv_label_set_text(batteryIcon, Symbols::batteryFull);
|
|
||||||
lv_obj_align(batteryIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 2);
|
|
||||||
|
|
||||||
bleIcon = lv_label_create(lv_scr_act(), nullptr);
|
|
||||||
lv_obj_set_style_local_text_color(bleIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
|
||||||
lv_label_set_text(bleIcon, Symbols::bluetooth);
|
|
||||||
lv_obj_align(bleIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 25);
|
|
||||||
|
|
||||||
// Calendar icon
|
|
||||||
|
|
||||||
calendarOuter = lv_obj_create(lv_scr_act(), nullptr);
|
|
||||||
lv_obj_set_style_local_bg_color(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
|
||||||
lv_obj_set_style_local_radius(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
|
||||||
lv_obj_set_size(calendarOuter, 34, 34);
|
|
||||||
lv_obj_align(calendarOuter, sidebar, LV_ALIGN_CENTER, 0, 0);
|
|
||||||
|
|
||||||
calendarInner = lv_obj_create(lv_scr_act(), nullptr);
|
|
||||||
lv_obj_set_style_local_bg_color(calendarInner, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xffffff));
|
|
||||||
lv_obj_set_style_local_radius(calendarInner, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
|
||||||
lv_obj_set_size(calendarInner, 27, 27);
|
|
||||||
lv_obj_align(calendarInner, calendarOuter, LV_ALIGN_CENTER, 0, 0);
|
|
||||||
|
|
||||||
calendarBar1 = lv_obj_create(lv_scr_act(), nullptr);
|
|
||||||
lv_obj_set_style_local_bg_color(calendarBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
|
||||||
lv_obj_set_style_local_radius(calendarBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
|
||||||
lv_obj_set_size(calendarBar1, 3, 12);
|
|
||||||
lv_obj_align(calendarBar1, calendarOuter, LV_ALIGN_IN_TOP_MID, -6, -3);
|
|
||||||
|
|
||||||
calendarBar2 = lv_obj_create(lv_scr_act(), nullptr);
|
|
||||||
lv_obj_set_style_local_bg_color(calendarBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
|
||||||
lv_obj_set_style_local_radius(calendarBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
|
||||||
lv_obj_set_size(calendarBar2, 3, 12);
|
|
||||||
lv_obj_align(calendarBar2, calendarOuter, LV_ALIGN_IN_TOP_MID, 6, -3);
|
|
||||||
|
|
||||||
calendarCrossBar1 = lv_obj_create(lv_scr_act(), nullptr);
|
|
||||||
lv_obj_set_style_local_bg_color(calendarCrossBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
|
||||||
lv_obj_set_style_local_radius(calendarCrossBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
|
||||||
lv_obj_set_size(calendarCrossBar1, 8, 3);
|
|
||||||
lv_obj_align(calendarCrossBar1, calendarBar1, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
|
||||||
|
|
||||||
calendarCrossBar2 = lv_obj_create(lv_scr_act(), nullptr);
|
|
||||||
lv_obj_set_style_local_bg_color(calendarCrossBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
|
||||||
lv_obj_set_style_local_radius(calendarCrossBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
|
||||||
lv_obj_set_size(calendarCrossBar2, 8, 3);
|
|
||||||
lv_obj_align(calendarCrossBar2, calendarBar2, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
|
||||||
|
|
||||||
// Display date
|
|
||||||
|
|
||||||
dateDayOfWeek = lv_label_create(lv_scr_act(), nullptr);
|
|
||||||
lv_obj_set_style_local_text_color(dateDayOfWeek, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
|
||||||
lv_label_set_text(dateDayOfWeek, "THU");
|
|
||||||
lv_obj_align(dateDayOfWeek, sidebar, LV_ALIGN_CENTER, 0, -34);
|
|
||||||
|
|
||||||
dateDay = lv_label_create(lv_scr_act(), nullptr);
|
|
||||||
lv_obj_set_style_local_text_color(dateDay, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
|
||||||
lv_label_set_text(dateDay, "25");
|
|
||||||
lv_obj_align(dateDay, sidebar, LV_ALIGN_CENTER, 0, 3);
|
|
||||||
|
|
||||||
dateMonth = lv_label_create(lv_scr_act(), nullptr);
|
|
||||||
lv_obj_set_style_local_text_color(dateMonth, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
|
|
||||||
lv_label_set_text(dateMonth, "MAR");
|
|
||||||
lv_obj_align(dateMonth, sidebar, LV_ALIGN_CENTER, 0, 32);
|
|
||||||
|
|
||||||
// Step count gauge
|
|
||||||
needle_colors[0] = LV_COLOR_WHITE;
|
|
||||||
stepGauge = lv_gauge_create(lv_scr_act(), nullptr);
|
|
||||||
lv_gauge_set_needle_count(stepGauge, 1, needle_colors);
|
|
||||||
lv_obj_set_size(stepGauge, 40, 40);
|
|
||||||
lv_obj_align(stepGauge, sidebar, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
|
||||||
lv_gauge_set_scale(stepGauge, 360, 11, 0);
|
|
||||||
lv_gauge_set_angle_offset(stepGauge, 180);
|
|
||||||
lv_gauge_set_critical_value(stepGauge, (100));
|
|
||||||
lv_gauge_set_range(stepGauge, 0, (100));
|
|
||||||
lv_gauge_set_value(stepGauge, 0, 0);
|
|
||||||
|
|
||||||
lv_obj_set_style_local_pad_right(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 3);
|
|
||||||
lv_obj_set_style_local_pad_left(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 3);
|
|
||||||
lv_obj_set_style_local_pad_bottom(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 3);
|
|
||||||
lv_obj_set_style_local_line_opa(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_COVER);
|
|
||||||
lv_obj_set_style_local_scale_width(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 4);
|
|
||||||
lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 4);
|
|
||||||
lv_obj_set_style_local_line_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
|
||||||
lv_obj_set_style_local_line_opa(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, LV_OPA_COVER);
|
|
||||||
lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 3);
|
|
||||||
lv_obj_set_style_local_pad_inner(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 4);
|
|
||||||
|
|
||||||
backgroundLabel = lv_label_create(lv_scr_act(), nullptr);
|
|
||||||
lv_obj_set_click(backgroundLabel, true);
|
|
||||||
lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
|
|
||||||
lv_obj_set_size(backgroundLabel, 240, 240);
|
|
||||||
lv_obj_set_pos(backgroundLabel, 0, 0);
|
|
||||||
lv_label_set_text(backgroundLabel, "");
|
|
||||||
|
|
||||||
btnNextTime = lv_btn_create(lv_scr_act(), nullptr);
|
|
||||||
btnNextTime->user_data = this;
|
|
||||||
lv_obj_set_size(btnNextTime, 60, 60);
|
|
||||||
lv_obj_align(btnNextTime, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -15, -80);
|
|
||||||
lv_obj_set_style_local_bg_opa(btnNextTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
|
|
||||||
lv_obj_set_style_local_value_str(btnNextTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, ">");
|
|
||||||
lv_obj_set_event_cb(btnNextTime, event_handler);
|
|
||||||
|
|
||||||
btnPrevTime = lv_btn_create(lv_scr_act(), nullptr);
|
|
||||||
btnPrevTime->user_data = this;
|
|
||||||
lv_obj_set_size(btnPrevTime, 60, 60);
|
|
||||||
lv_obj_align(btnPrevTime, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 15, -80);
|
|
||||||
lv_obj_set_style_local_bg_opa(btnPrevTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
|
|
||||||
lv_obj_set_style_local_value_str(btnPrevTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<");
|
|
||||||
lv_obj_set_event_cb(btnPrevTime, event_handler);
|
|
||||||
|
|
||||||
btnNextBar = lv_btn_create(lv_scr_act(), nullptr);
|
|
||||||
btnNextBar->user_data = this;
|
|
||||||
lv_obj_set_size(btnNextBar, 60, 60);
|
|
||||||
lv_obj_align(btnNextBar, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -15, 0);
|
|
||||||
lv_obj_set_style_local_bg_opa(btnNextBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
|
|
||||||
lv_obj_set_style_local_value_str(btnNextBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, ">");
|
|
||||||
lv_obj_set_event_cb(btnNextBar, event_handler);
|
|
||||||
|
|
||||||
btnPrevBar = lv_btn_create(lv_scr_act(), nullptr);
|
|
||||||
btnPrevBar->user_data = this;
|
|
||||||
lv_obj_set_size(btnPrevBar, 60, 60);
|
|
||||||
lv_obj_align(btnPrevBar, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 15, 0);
|
|
||||||
lv_obj_set_style_local_bg_opa(btnPrevBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
|
|
||||||
lv_obj_set_style_local_value_str(btnPrevBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<");
|
|
||||||
lv_obj_set_event_cb(btnPrevBar, event_handler);
|
|
||||||
|
|
||||||
btnNextBG = lv_btn_create(lv_scr_act(), nullptr);
|
|
||||||
btnNextBG->user_data = this;
|
|
||||||
lv_obj_set_size(btnNextBG, 60, 60);
|
|
||||||
lv_obj_align(btnNextBG, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -15, 80);
|
|
||||||
lv_obj_set_style_local_bg_opa(btnNextBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
|
|
||||||
lv_obj_set_style_local_value_str(btnNextBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, ">");
|
|
||||||
lv_obj_set_event_cb(btnNextBG, event_handler);
|
|
||||||
|
|
||||||
btnPrevBG = lv_btn_create(lv_scr_act(), nullptr);
|
|
||||||
btnPrevBG->user_data = this;
|
|
||||||
lv_obj_set_size(btnPrevBG, 60, 60);
|
|
||||||
lv_obj_align(btnPrevBG, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 15, 80);
|
|
||||||
lv_obj_set_style_local_bg_opa(btnPrevBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
|
|
||||||
lv_obj_set_style_local_value_str(btnPrevBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<");
|
|
||||||
lv_obj_set_event_cb(btnPrevBG, event_handler);
|
|
||||||
|
|
||||||
btnReset = lv_btn_create(lv_scr_act(), nullptr);
|
|
||||||
btnReset->user_data = this;
|
|
||||||
lv_obj_set_size(btnReset, 60, 60);
|
|
||||||
lv_obj_align(btnReset, lv_scr_act(), LV_ALIGN_CENTER, 0, 80);
|
|
||||||
lv_obj_set_style_local_bg_opa(btnReset, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
|
|
||||||
lv_obj_set_style_local_value_str(btnReset, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "Rst");
|
|
||||||
lv_obj_set_event_cb(btnReset, event_handler);
|
|
||||||
|
|
||||||
btnRandom = lv_btn_create(lv_scr_act(), nullptr);
|
|
||||||
btnRandom->user_data = this;
|
|
||||||
lv_obj_set_size(btnRandom, 60, 60);
|
|
||||||
lv_obj_align(btnRandom, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
|
|
||||||
lv_obj_set_style_local_bg_opa(btnRandom, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
|
|
||||||
lv_obj_set_style_local_value_str(btnRandom, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "Rnd");
|
|
||||||
lv_obj_set_event_cb(btnRandom, event_handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
SettingPineTimeStyle::~SettingPineTimeStyle() {
|
|
||||||
lv_obj_clean(lv_scr_act());
|
|
||||||
settingsController.SaveSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingPineTimeStyle::UpdateSelected(lv_obj_t* object, lv_event_t event) {
|
|
||||||
auto valueTime = settingsController.GetPTSColorTime();
|
|
||||||
auto valueBar = settingsController.GetPTSColorBar();
|
|
||||||
auto valueBG = settingsController.GetPTSColorBG();
|
|
||||||
|
|
||||||
if (event == LV_EVENT_CLICKED) {
|
|
||||||
if (object == btnNextTime) {
|
|
||||||
valueTime = GetNext(valueTime);
|
|
||||||
|
|
||||||
settingsController.SetPTSColorTime(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) {
|
|
||||||
valueTime = GetPrevious(valueTime);
|
|
||||||
settingsController.SetPTSColorTime(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) {
|
|
||||||
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, Convert(valueBar));
|
|
||||||
}
|
|
||||||
if (object == btnPrevBar) {
|
|
||||||
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, Convert(valueBar));
|
|
||||||
}
|
|
||||||
if (object == btnNextBG) {
|
|
||||||
valueBG = GetNext(valueBG);
|
|
||||||
settingsController.SetPTSColorBG(valueBG);
|
|
||||||
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBG));
|
|
||||||
}
|
|
||||||
if (object == btnPrevBG) {
|
|
||||||
valueBG = GetPrevious(valueBG);
|
|
||||||
settingsController.SetPTSColorBG(valueBG);
|
|
||||||
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBG));
|
|
||||||
}
|
|
||||||
if (object == btnReset) {
|
|
||||||
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;
|
|
||||||
uint8_t randBar = rand() % 17;
|
|
||||||
uint8_t randBG = 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 (randTime == randBG) {
|
|
||||||
randBG += 1;
|
|
||||||
}
|
|
||||||
if (randBar == 3) {
|
|
||||||
randBar -= 1;
|
|
||||||
}
|
|
||||||
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)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <lvgl/lvgl.h>
|
|
||||||
#include "components/settings/Settings.h"
|
|
||||||
#include "displayapp/screens/Screen.h"
|
|
||||||
|
|
||||||
namespace Pinetime {
|
|
||||||
|
|
||||||
namespace Applications {
|
|
||||||
namespace Screens {
|
|
||||||
|
|
||||||
class SettingPineTimeStyle : public Screen{
|
|
||||||
public:
|
|
||||||
SettingPineTimeStyle(DisplayApp* app, Pinetime::Controllers::Settings &settingsController);
|
|
||||||
~SettingPineTimeStyle() 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;
|
|
||||||
lv_obj_t * btnPrevBar;
|
|
||||||
lv_obj_t * btnNextBG;
|
|
||||||
lv_obj_t * btnPrevBG;
|
|
||||||
lv_obj_t * btnReset;
|
|
||||||
lv_obj_t * btnRandom;
|
|
||||||
lv_obj_t * timebar;
|
|
||||||
lv_obj_t * sidebar;
|
|
||||||
lv_obj_t * timeDD1;
|
|
||||||
lv_obj_t * timeDD2;
|
|
||||||
lv_obj_t * timeAMPM;
|
|
||||||
lv_obj_t * dateDayOfWeek;
|
|
||||||
lv_obj_t * dateDay;
|
|
||||||
lv_obj_t * dateMonth;
|
|
||||||
lv_obj_t * backgroundLabel;
|
|
||||||
lv_obj_t * batteryIcon;
|
|
||||||
lv_obj_t * bleIcon;
|
|
||||||
lv_obj_t * calendarOuter;
|
|
||||||
lv_obj_t * calendarInner;
|
|
||||||
lv_obj_t * calendarBar1;
|
|
||||||
lv_obj_t * calendarBar2;
|
|
||||||
lv_obj_t * calendarCrossBar1;
|
|
||||||
lv_obj_t * calendarCrossBar2;
|
|
||||||
lv_obj_t * stepGauge;
|
|
||||||
lv_color_t needle_colors[1];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -60,10 +60,10 @@ std::unique_ptr<Screen> Settings::CreateScreen2() {
|
||||||
std::unique_ptr<Screen> Settings::CreateScreen3() {
|
std::unique_ptr<Screen> Settings::CreateScreen3() {
|
||||||
|
|
||||||
std::array<Screens::List::Applications, 4> applications {{
|
std::array<Screens::List::Applications, 4> applications {{
|
||||||
{Symbols::paintbrush, "PTS Colors", Apps::SettingPineTimeStyle},
|
|
||||||
{Symbols::check, "Firmware", Apps::FirmwareValidation},
|
{Symbols::check, "Firmware", Apps::FirmwareValidation},
|
||||||
{Symbols::list, "About", Apps::SysInfo},
|
{Symbols::list, "About", Apps::SysInfo},
|
||||||
{Symbols::none, "None", Apps::None},
|
{Symbols::none, "None", Apps::None},
|
||||||
|
{Symbols::none, "None", Apps::None}
|
||||||
}};
|
}};
|
||||||
|
|
||||||
return std::make_unique<Screens::List>(2, 3, app, settingsController, applications);
|
return std::make_unique<Screens::List>(2, 3, app, settingsController, applications);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user