Use own LVGL theme
This commit is contained in:
committed by
Raphael Coeffic
parent
28c28fb521
commit
eac3f4fce5
+1
-4
@@ -138,16 +138,13 @@ TextButton::TextButton(Window* parent, const rect_t& rect, std::string text,
|
|||||||
{
|
{
|
||||||
setTextFlags(textFlags | COLOR_THEME_PRIMARY1);
|
setTextFlags(textFlags | COLOR_THEME_PRIMARY1);
|
||||||
lv_obj_add_flag(lvobj, LV_OBJ_FLAG_CHECKABLE);
|
lv_obj_add_flag(lvobj, LV_OBJ_FLAG_CHECKABLE);
|
||||||
|
|
||||||
if (windowFlags & BUTTON_CHECKED)
|
if (windowFlags & BUTTON_CHECKED)
|
||||||
lv_obj_add_state(lvobj, LV_STATE_CHECKED);
|
lv_obj_add_state(lvobj, LV_STATE_CHECKED);
|
||||||
|
|
||||||
label = lv_label_create(lvobj);
|
label = lv_label_create(lvobj);
|
||||||
lv_label_set_text(label, this->text.c_str());
|
lv_label_set_text(label, this->text.c_str());
|
||||||
lv_obj_center(label);
|
lv_obj_center(label);
|
||||||
lv_obj_set_style_text_color(label, makeLvColor(this->getTextFlags()),
|
|
||||||
LV_PART_MAIN);
|
|
||||||
lv_obj_set_style_text_color(label, makeLvColor(COLOR_THEME_PRIMARY2),
|
|
||||||
LV_PART_MAIN | LV_STATE_FOCUSED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IconButton::paint(BitmapBuffer * dc)
|
void IconButton::paint(BitmapBuffer * dc)
|
||||||
|
|||||||
-54
@@ -21,43 +21,6 @@
|
|||||||
#include "bitmapbuffer.h"
|
#include "bitmapbuffer.h"
|
||||||
#include "libopenui_config.h"
|
#include "libopenui_config.h"
|
||||||
|
|
||||||
// FormField styles
|
|
||||||
static lv_style_t bg_style;
|
|
||||||
static lv_style_t focus_style;
|
|
||||||
static lv_style_t edit_style;
|
|
||||||
|
|
||||||
// FormGroup styles
|
|
||||||
static lv_style_t border_style;
|
|
||||||
static lv_style_t focus_border_style;
|
|
||||||
|
|
||||||
static void init_styles()
|
|
||||||
{
|
|
||||||
static bool inited = false;
|
|
||||||
if (inited) return;
|
|
||||||
|
|
||||||
inited = true;
|
|
||||||
|
|
||||||
// FormField styles
|
|
||||||
lv_style_init(&bg_style);
|
|
||||||
lv_style_set_bg_color(&bg_style, makeLvColor(COLOR_THEME_PRIMARY2));
|
|
||||||
lv_style_set_bg_opa(&bg_style, LV_OPA_COVER);
|
|
||||||
|
|
||||||
lv_style_init(&focus_style);
|
|
||||||
lv_style_set_bg_color(&focus_style, makeLvColor(COLOR_THEME_FOCUS));
|
|
||||||
|
|
||||||
lv_style_init(&edit_style);
|
|
||||||
lv_style_set_bg_color(&edit_style, makeLvColor(COLOR_THEME_EDIT));
|
|
||||||
|
|
||||||
// FormGroup styles
|
|
||||||
lv_style_init(&border_style);
|
|
||||||
lv_style_set_border_width(&border_style, 2);
|
|
||||||
lv_style_set_border_color(&border_style, makeLvColor(COLOR_THEME_FOCUS));
|
|
||||||
|
|
||||||
lv_style_init(&focus_border_style);
|
|
||||||
lv_style_set_border_width(&focus_border_style, 1);
|
|
||||||
lv_style_set_border_color(&focus_border_style, makeLvColor(COLOR_THEME_SECONDARY2));
|
|
||||||
}
|
|
||||||
|
|
||||||
FormField::FormField(Window* parent, const rect_t& rect,
|
FormField::FormField(Window* parent, const rect_t& rect,
|
||||||
WindowFlags windowFlags, LcdFlags textFlags,
|
WindowFlags windowFlags, LcdFlags textFlags,
|
||||||
LvglCreate objConstruct) :
|
LvglCreate objConstruct) :
|
||||||
@@ -69,16 +32,6 @@ FormField::FormField(Window* parent, const rect_t& rect,
|
|||||||
cont->addField(this);
|
cont->addField(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lv_obj_enable_style_refresh(false);
|
|
||||||
init_styles();
|
|
||||||
|
|
||||||
lv_obj_add_style(lvobj, &bg_style, LV_PART_MAIN);
|
|
||||||
lv_obj_add_style(lvobj, &focus_style, LV_PART_MAIN | LV_STATE_FOCUSED);
|
|
||||||
lv_obj_add_style(lvobj, &edit_style, LV_PART_MAIN | LV_STATE_EDITED);
|
|
||||||
|
|
||||||
lv_obj_enable_style_refresh(true);
|
|
||||||
lv_obj_refresh_style(lvobj, LV_PART_ANY, LV_STYLE_PROP_ANY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HARDWARE_KEYS)
|
#if defined(HARDWARE_KEYS)
|
||||||
@@ -190,15 +143,8 @@ FormGroup::FormGroup(Window* parent, const rect_t& rect,
|
|||||||
{
|
{
|
||||||
lv_obj_set_style_bg_opa(lvobj, LV_OPA_TRANSP, LV_PART_MAIN);
|
lv_obj_set_style_bg_opa(lvobj, LV_OPA_TRANSP, LV_PART_MAIN);
|
||||||
|
|
||||||
if (!(windowFlags & (FORM_NO_BORDER | FORM_FORWARD_FOCUS))) {
|
|
||||||
|
|
||||||
init_styles();
|
|
||||||
lv_obj_add_style(lvobj, &border_style, LV_PART_MAIN | LV_STATE_FOCUSED);
|
|
||||||
|
|
||||||
if (!(windowFlags & FORM_BORDER_FOCUS_ONLY)) {
|
|
||||||
lv_obj_add_style(lvobj, &focus_border_style, LV_PART_MAIN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormGroup::clear()
|
void FormGroup::clear()
|
||||||
|
|||||||
@@ -174,9 +174,9 @@ set(LVGL_SOURCES
|
|||||||
extra/widgets/span/lv_span.c
|
extra/widgets/span/lv_span.c
|
||||||
extra/widgets/keyboard/lv_keyboard.c
|
extra/widgets/keyboard/lv_keyboard.c
|
||||||
extra/widgets/msgbox/lv_msgbox.c
|
extra/widgets/msgbox/lv_msgbox.c
|
||||||
extra/themes/basic/lv_theme_basic.c
|
# extra/themes/basic/lv_theme_basic.c
|
||||||
extra/themes/default/lv_theme_default.c
|
# extra/themes/default/lv_theme_default.c
|
||||||
extra/themes/mono/lv_theme_mono.c
|
# extra/themes/mono/lv_theme_mono.c
|
||||||
)
|
)
|
||||||
|
|
||||||
foreach(LVGL_FILE ${LVGL_SOURCES_MINIMAL})
|
foreach(LVGL_FILE ${LVGL_SOURCES_MINIMAL})
|
||||||
|
|||||||
Reference in New Issue
Block a user