InfiniTime.git

commit bb11891b6e66efdc0a0fc8a9761d94719fd4748f

Author: JF <jf@codingfield.com>

Remove custom styles in Screens and define default style and "Big style" in LittleVgl during the initialization of LVGL.

 src/DisplayApp/LittleVgl.cpp | 6 ++++++
 src/DisplayApp/LittleVgl.h | 1 +
 src/DisplayApp/Screens/Clock.cpp | 13 ++-----------
 src/DisplayApp/Screens/Clock.h | 7 -------
 src/DisplayApp/Screens/Message.cpp | 7 -------
 src/DisplayApp/Screens/Message.h | 2 --


diff --git a/src/DisplayApp/LittleVgl.cpp b/src/DisplayApp/LittleVgl.cpp
index 7b6cda94326e1ffa404e3b05b60305b9b5afd144..3483f8e8041571330ae907fd1736ef8dfb01fbef 100644
--- a/src/DisplayApp/LittleVgl.cpp
+++ b/src/DisplayApp/LittleVgl.cpp
@@ -17,6 +17,8 @@ LV_FONT_DECLARE(jetbrains_mono_extrabold_compressed)
 LV_FONT_DECLARE(jetbrains_mono_bold_20)
 }
 
+lv_style_t* LabelBigStyle = nullptr;
+
 static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p) {
   auto* lvgl = static_cast<LittleVgl*>(disp_drv->user_data);
   lvgl->FlushDisplay(area, color_p);
@@ -360,6 +362,10 @@
 void LittleVgl::InitThemeLabel() {
   lv_style_copy(&prim, &bg);
   prim.text.color = lv_color_hsv_to_rgb(hue, 5, 95);
+
+  lv_style_copy(&labelBigStyle, &prim);
+  labelBigStyle.text.font = &jetbrains_mono_extrabold_compressed;
+  LabelBigStyle = &(this->labelBigStyle);
 
   lv_style_copy(&sec, &bg);
   sec.text.color = lv_color_hsv_to_rgb(hue, 15, 65);




diff --git a/src/DisplayApp/LittleVgl.h b/src/DisplayApp/LittleVgl.h
index c6e728b2f7fbd999b4d224ed4f414939c4976401..8bd56ddf4193741ccea3df1b56f7bb431ed4da11 100644
--- a/src/DisplayApp/LittleVgl.h
+++ b/src/DisplayApp/LittleVgl.h
@@ -79,6 +79,7 @@         lv_font_t * font = nullptr;
         uint16_t hue = 10;
         lv_theme_t theme;
         lv_style_t btn_rel, btn_pr, btn_tgl_rel, btn_tgl_pr, btn_ina;
+        lv_style_t labelBigStyle;
         lv_style_t prim, sec, hint;
         lv_style_t led;
         lv_style_t bar_bg, bar_indic;




diff --git a/src/DisplayApp/Screens/Clock.cpp b/src/DisplayApp/Screens/Clock.cpp
index 07db83eeedb0de4829a9a91ee17d663b4d8de44d..68471854574102ee50a8268256ad0e0d6afe285c 100644
--- a/src/DisplayApp/Screens/Clock.cpp
+++ b/src/DisplayApp/Screens/Clock.cpp
@@ -11,7 +11,7 @@
 using namespace Pinetime::Applications::Screens;
 extern lv_font_t jetbrains_mono_extrabold_compressed;
 extern lv_font_t jetbrains_mono_bold_20;
-
+extern lv_style_t* LabelBigStyle;
 
 static void event_handler(lv_obj_t * obj, lv_event_t event) {
   Clock* screen = static_cast<Clock *>(obj->user_data);
@@ -41,21 +41,12 @@   label_date = lv_label_create(lv_scr_act(), NULL);
 
   lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 60);
 
-  labelStyle = const_cast<lv_style_t *>(lv_label_get_style(label_date, LV_LABEL_STYLE_MAIN));
-  labelStyle->text.font = &jetbrains_mono_bold_20;
-
-  lv_style_copy(&labelBigStyle, labelStyle);
-  labelBigStyle.text.font = &jetbrains_mono_extrabold_compressed;
-
-  lv_label_set_style(label_date, LV_LABEL_STYLE_MAIN, labelStyle);
-
   label_time = lv_label_create(lv_scr_act(), NULL);
-  lv_label_set_style(label_time, LV_LABEL_STYLE_MAIN, &labelBigStyle);
+  lv_label_set_style(label_time, LV_LABEL_STYLE_MAIN, LabelBigStyle);
   lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 0);
 
   backgroundLabel = lv_label_create(lv_scr_act(), NULL);
   backgroundLabel->user_data = this;
-  lv_label_set_style(backgroundLabel, LV_LABEL_STYLE_MAIN, labelStyle);
   lv_obj_set_click(backgroundLabel, true);
   lv_obj_set_event_cb(backgroundLabel, event_handler);
   lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);




diff --git a/src/DisplayApp/Screens/Clock.h b/src/DisplayApp/Screens/Clock.h
index 7c4a09dfe27fccd48c7aaecbae1b3715ada2fb15..2450158d7fae665219693e1034a4dd47e08ba838 100644
--- a/src/DisplayApp/Screens/Clock.h
+++ b/src/DisplayApp/Screens/Clock.h
@@ -66,16 +66,9 @@           DirtyValue bleState {false};
           DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>> currentDateTime;
           DirtyValue<Pinetime::Version> version;
 
-          lv_style_t* labelStyle;
-          lv_style_t labelBigStyle;
-          lv_obj_t * label_battery;
-
-          lv_obj_t * label_ble;
           lv_obj_t* label_time;
           lv_obj_t* label_date;
-          lv_obj_t* label_version;
           lv_obj_t* backgroundLabel;
-
           lv_obj_t * batteryIcon;
           lv_obj_t * bleIcon;
 




diff --git a/src/DisplayApp/Screens/Message.cpp b/src/DisplayApp/Screens/Message.cpp
index c8a4ea1fe42402ab1e924cffc381ce406a7e6fdf..b83cb7519a56936764d226a2ad5cb766ee8e6227 100644
--- a/src/DisplayApp/Screens/Message.cpp
+++ b/src/DisplayApp/Screens/Message.cpp
@@ -24,17 +24,12 @@
   backgroundLabel = lv_label_create(lv_scr_act(), NULL);
   backgroundLabel->user_data = this;
 
-  labelStyle = const_cast<lv_style_t *>(lv_label_get_style(backgroundLabel, LV_LABEL_STYLE_MAIN));
-  labelStyle->text.font = &jetbrains_mono_bold_20;
-
-  lv_label_set_style(backgroundLabel, LV_LABEL_STYLE_MAIN, labelStyle);
   lv_obj_set_click(backgroundLabel, true);
   lv_obj_set_event_cb(backgroundLabel, event_handler);
   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, "");
-//  lv_obj_align(backgroundLabel, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 0);
 
   button = lv_btn_create(lv_scr_act(), NULL);
   lv_obj_set_event_cb(button, event_handler);
@@ -42,11 +37,9 @@   lv_obj_align(button, NULL, LV_ALIGN_CENTER, 0, -40);
   button->user_data = this;
 
   label = lv_label_create(button, NULL);
-  lv_label_set_style(label, LV_LABEL_STYLE_MAIN, labelStyle);
   lv_label_set_text(label, "Hello!");
 
   labelClick = lv_label_create(lv_scr_act(), NULL);
-  lv_label_set_style(labelClick, LV_LABEL_STYLE_MAIN, labelStyle);
   lv_obj_align(labelClick, button, LV_ALIGN_OUT_BOTTOM_MID, 0, 30);
   lv_label_set_text(labelClick, "0");
 }




diff --git a/src/DisplayApp/Screens/Message.h b/src/DisplayApp/Screens/Message.h
index 4e87bba423c7a89b093bc34a6efc33f55770c4dc..6ddcbb438ead45e203e8f9faf790c7b110585045 100644
--- a/src/DisplayApp/Screens/Message.h
+++ b/src/DisplayApp/Screens/Message.h
@@ -22,8 +22,6 @@           bool OnButtonPushed();
           void OnObjectEvent(lv_obj_t* obj, lv_event_t event);
 
         private:
-
-          lv_style_t* labelStyle;
           lv_obj_t * label;
           lv_obj_t* backgroundLabel;
           lv_obj_t * button;