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

This commit is contained in:
JF 2020-07-03 21:37:40 +02:00
parent ca549bcfd8
commit bb11891b6e
6 changed files with 9 additions and 27 deletions

View File

@ -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);
@ -361,6 +363,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);

View File

@ -79,6 +79,7 @@ namespace Pinetime {
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;

View File

@ -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 @@ Clock::Clock(DisplayApp* app,
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);

View File

@ -66,16 +66,9 @@ namespace Pinetime {
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;

View File

@ -24,17 +24,12 @@ Message::Message(DisplayApp* app) : Screen(app) {
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 @@ Message::Message(DisplayApp* app) : Screen(app) {
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");
}

View File

@ -22,8 +22,6 @@ namespace Pinetime {
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;