From 0cbf0fbf6c25b08e13318ac350f81e72d7769aed Mon Sep 17 00:00:00 2001 From: kevin koenig Date: Tue, 22 Feb 2022 07:47:27 -0500 Subject: [PATCH] move styles from textedit to theme --- radio/src/gui/colorlcd/LvglWrapper.cpp | 40 ++++++++++++++++++++++++++ radio/src/thirdparty/libopenui | 2 +- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/radio/src/gui/colorlcd/LvglWrapper.cpp b/radio/src/gui/colorlcd/LvglWrapper.cpp index 4ca6c6753..eb8a2fd12 100644 --- a/radio/src/gui/colorlcd/LvglWrapper.cpp +++ b/radio/src/gui/colorlcd/LvglWrapper.cpp @@ -199,6 +199,11 @@ static lv_style_t btn_focused_style; static lv_style_t btn_checked_focused_style; static lv_style_t menu_line_style; static lv_style_t menu_checked_style; +static lv_style_t textedit_style_main; +static lv_style_t textedit_style_focused; +static lv_style_t textedit_style_cursor; +static lv_style_t textedit_style_cursor_edit; + static void theme_apply_cb(lv_theme_t * th, lv_obj_t * obj) { @@ -212,6 +217,14 @@ static void theme_apply_cb(lv_theme_t * th, lv_obj_t * obj) return; } + if (lv_obj_check_type(obj, &lv_textarea_class)) { + lv_obj_add_style(obj, &textedit_style_main, LV_PART_MAIN); + lv_obj_add_style(obj, &textedit_style_focused, LV_PART_MAIN | LV_STATE_FOCUSED); + lv_obj_add_style(obj, &textedit_style_cursor, LV_PART_CURSOR); + lv_obj_add_style(obj, &textedit_style_cursor_edit, LV_PART_CURSOR | LV_STATE_EDITED); + return; + } + if (lv_obj_check_type(obj, &lv_btn_class)) { lv_obj_add_style(obj, &btn_style, 0); lv_obj_add_style(obj, &btn_checked_style, LV_STATE_CHECKED); @@ -239,6 +252,33 @@ static void init_theme() lv_style_set_border_width(&generic_style, 0); lv_style_set_radius(&generic_style, 0); + // textedit + lv_style_init(&textedit_style_main); + lv_style_init(&textedit_style_focused); + lv_style_init(&textedit_style_cursor); + lv_style_init(&textedit_style_cursor_edit); + + // textedit style main + lv_style_set_border_width(&textedit_style_main, 1); + lv_style_set_border_color(&textedit_style_main, makeLvColor(COLOR_THEME_SECONDARY2)); + lv_style_set_bg_color(&textedit_style_main, makeLvColor(COLOR_THEME_PRIMARY2)); + lv_style_set_bg_opa(&textedit_style_main, LV_OPA_COVER); + lv_style_set_text_font(&textedit_style_main, &lv_font_roboto_13); + lv_style_set_text_color(&textedit_style_main, makeLvColor(COLOR_THEME_SECONDARY1)); + lv_style_set_pad_left(&textedit_style_main, FIELD_PADDING_LEFT); + lv_style_set_pad_top(&textedit_style_main, FIELD_PADDING_TOP); + + //textedit style focused + lv_style_set_bg_color(&textedit_style_focused, makeLvColor(COLOR_THEME_FOCUS)); + lv_style_set_text_color(&textedit_style_focused, makeLvColor(COLOR_THEME_PRIMARY2)); + + // hide cursor when not editing + lv_style_set_opa(&textedit_style_cursor, LV_OPA_0); + + // Show Cursor in "Edit" mode + lv_style_set_opa(&textedit_style_cursor_edit, LV_OPA_COVER); + lv_style_set_bg_opa(&textedit_style_cursor_edit, LV_OPA_50); + // Buttons lv_style_init(&btn_style); lv_style_set_bg_opa(&btn_style, LV_OPA_100); diff --git a/radio/src/thirdparty/libopenui b/radio/src/thirdparty/libopenui index 0c03b487d..e717e3b85 160000 --- a/radio/src/thirdparty/libopenui +++ b/radio/src/thirdparty/libopenui @@ -1 +1 @@ -Subproject commit 0c03b487d6a445d60d88f30214713b48c0be44aa +Subproject commit e717e3b85b823b2fc8cd026105b2fdcaef4c9abd