This commit is contained in:
不吃油炸鸡
2026-02-26 17:20:03 +08:00
parent 558bec4003
commit 495baa3905
1214 changed files with 825897 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,71 @@
/**
* @file lv_theme_default.h
*
*/
#ifndef LV_THEME_DEFAULT_H
#define LV_THEME_DEFAULT_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../lv_theme.h"
#if LV_USE_THEME_DEFAULT
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Initialize the theme
* @param disp pointer to display
* @param color_primary the primary color of the theme
* @param color_secondary the secondary color for the theme
* @param dark
* @param font pointer to a font to use.
* @return a pointer to reference this theme later
*/
lv_theme_t * lv_theme_default_init(lv_display_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark,
const lv_font_t * font);
/**
* Get default theme
* @return a pointer to default theme, or NULL if this is not initialized
*/
lv_theme_t * lv_theme_default_get(void);
/**
* Check if default theme is initialized
* @return true if default theme is initialized, false otherwise
*/
bool lv_theme_default_is_inited(void);
/**
* Deinitialize the default theme
*/
void lv_theme_default_deinit(void);
/**********************
* MACROS
**********************/
#endif
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_THEME_DEFAULT_H*/

View File

@@ -0,0 +1,122 @@
/**
* @file lv_theme.c
*
*/
/*********************
* INCLUDES
*********************/
#include "lv_theme_private.h"
#include "../core/lv_obj_private.h"
#include "../core/lv_obj_class_private.h"
#include "../../lvgl.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
static void apply_theme(lv_theme_t * th, lv_obj_t * obj);
static void apply_theme_recursion(lv_theme_t * th, lv_obj_t * obj);
/**********************
* STATIC VARIABLES
**********************/
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
lv_theme_t * lv_theme_get_from_obj(lv_obj_t * obj)
{
lv_display_t * disp = obj ? lv_obj_get_display(obj) : lv_display_get_default();
return lv_display_get_theme(disp);
}
void lv_theme_apply(lv_obj_t * obj)
{
lv_theme_t * th = lv_theme_get_from_obj(obj);
if(th == NULL) return;
lv_obj_remove_style_all(obj);
apply_theme_recursion(th, obj); /*Apply the theme including the base theme(s)*/
}
void lv_theme_set_parent(lv_theme_t * new_theme, lv_theme_t * base)
{
new_theme->parent = base;
}
void lv_theme_set_apply_cb(lv_theme_t * theme, lv_theme_apply_cb_t apply_cb)
{
theme->apply_cb = apply_cb;
}
const lv_font_t * lv_theme_get_font_small(lv_obj_t * obj)
{
lv_theme_t * th = lv_theme_get_from_obj(obj);
return th ? th->font_small : LV_FONT_DEFAULT;
}
const lv_font_t * lv_theme_get_font_normal(lv_obj_t * obj)
{
lv_theme_t * th = lv_theme_get_from_obj(obj);
return th ? th->font_normal : LV_FONT_DEFAULT;
}
const lv_font_t * lv_theme_get_font_large(lv_obj_t * obj)
{
lv_theme_t * th = lv_theme_get_from_obj(obj);
return th ? th->font_large : LV_FONT_DEFAULT;
}
lv_color_t lv_theme_get_color_primary(lv_obj_t * obj)
{
lv_theme_t * th = lv_theme_get_from_obj(obj);
return th ? th->color_primary : lv_palette_main(LV_PALETTE_BLUE_GREY);
}
lv_color_t lv_theme_get_color_secondary(lv_obj_t * obj)
{
lv_theme_t * th = lv_theme_get_from_obj(obj);
return th ? th->color_secondary : lv_palette_main(LV_PALETTE_BLUE);
}
/**********************
* STATIC FUNCTIONS
**********************/
static void apply_theme(lv_theme_t * th, lv_obj_t * obj)
{
if(th->parent) apply_theme(th->parent, obj);
if(th->apply_cb) th->apply_cb(th, obj);
}
static void apply_theme_recursion(lv_theme_t * th, lv_obj_t * obj)
{
const lv_obj_class_t * original_class_p = obj->class_p;
if(obj->class_p->base_class && obj->class_p->theme_inheritable == LV_OBJ_CLASS_THEME_INHERITABLE_TRUE) {
/*Apply the base class theme in obj*/
obj->class_p = obj->class_p->base_class;
/*apply the base first*/
apply_theme_recursion(th, obj);
}
/*Restore the original class*/
obj->class_p = original_class_p;
apply_theme(th, obj);
}

View File

@@ -0,0 +1,108 @@
/**
*@file lv_theme.h
*
*/
#ifndef LV_THEME_H
#define LV_THEME_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../core/lv_obj.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
typedef void (*lv_theme_apply_cb_t)(lv_theme_t *, lv_obj_t *);
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Get the theme assigned to the display of the object
* @param obj pointer to a theme object
* @return the theme of the object's display (can be NULL)
*/
lv_theme_t * lv_theme_get_from_obj(lv_obj_t * obj);
/**
* Apply the active theme on an object
* @param obj pointer to an object
*/
void lv_theme_apply(lv_obj_t * obj);
/**
* Set a base theme for a theme.
* The styles from the base them will be added before the styles of the current theme.
* Arbitrary long chain of themes can be created by setting base themes.
* @param new_theme pointer to theme which base should be set
* @param parent pointer to the base theme
*/
void lv_theme_set_parent(lv_theme_t * new_theme, lv_theme_t * parent);
/**
* Set an apply callback for a theme.
* The apply callback is used to add styles to different objects
* @param theme pointer to theme which callback should be set
* @param apply_cb pointer to the callback
*/
void lv_theme_set_apply_cb(lv_theme_t * theme, lv_theme_apply_cb_t apply_cb);
/**
* Get the small font of the theme
* @param obj pointer to an object
* @return pointer to the font
*/
const lv_font_t * lv_theme_get_font_small(lv_obj_t * obj);
/**
* Get the normal font of the theme
* @param obj pointer to an object
* @return pointer to the font
*/
const lv_font_t * lv_theme_get_font_normal(lv_obj_t * obj);
/**
* Get the subtitle font of the theme
* @param obj pointer to an object
* @return pointer to the font
*/
const lv_font_t * lv_theme_get_font_large(lv_obj_t * obj);
/**
* Get the primary color of the theme
* @param obj pointer to an object
* @return the color
*/
lv_color_t lv_theme_get_color_primary(lv_obj_t * obj);
/**
* Get the secondary color of the theme
* @param obj pointer to an object
* @return the color
*/
lv_color_t lv_theme_get_color_secondary(lv_obj_t * obj);
/**********************
* MACROS
**********************/
#include "default/lv_theme_default.h"
#include "mono/lv_theme_mono.h"
#include "simple/lv_theme_simple.h"
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_THEME_H*/

View File

@@ -0,0 +1,53 @@
/**
* @file lv_theme_private.h
*
*/
#ifndef LV_THEME_PRIVATE_H
#define LV_THEME_PRIVATE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_theme.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
struct lv_theme_t {
lv_theme_apply_cb_t apply_cb;
lv_theme_t * parent; /**< Apply the current theme's style on top of this theme. */
void * user_data;
lv_display_t * disp;
lv_color_t color_primary;
lv_color_t color_secondary;
const lv_font_t * font_small;
const lv_font_t * font_normal;
const lv_font_t * font_large;
uint32_t flags; /**< Any custom flag used by the theme */
};
/**********************
* GLOBAL PROTOTYPES
**********************/
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_THEME_PRIVATE_H*/

View File

@@ -0,0 +1,532 @@
/**
* @file lv_theme_mono.c
*
*/
/*********************
* INCLUDES
*********************/
#include "../lv_theme_private.h"
#include "../../../lvgl.h"
#if LV_USE_THEME_MONO
#include "lv_theme_mono.h"
#include "../../core/lv_global.h"
/*********************
* DEFINES
*********************/
struct _my_theme_t;
typedef struct _my_theme_t my_theme_t;
#define theme_def (*(my_theme_t **)(&LV_GLOBAL_DEFAULT()->theme_mono))
#define COLOR_FG dark_bg ? lv_color_white() : lv_color_black()
#define COLOR_BG dark_bg ? lv_color_black() : lv_color_white()
#define BORDER_W_NORMAL 1
#define BORDER_W_PR 3
#define BORDER_W_DIS 0
#define BORDER_W_FOCUS 1
#define BORDER_W_EDIT 2
#define PAD_DEF 4
/**********************
* TYPEDEFS
**********************/
typedef struct {
lv_style_t scr;
lv_style_t card;
lv_style_t scrollbar;
lv_style_t pr;
lv_style_t inv;
lv_style_t disabled;
lv_style_t focus;
lv_style_t edit;
lv_style_t pad_gap;
lv_style_t pad_zero;
lv_style_t no_radius;
lv_style_t radius_circle;
lv_style_t large_border;
lv_style_t large_line_space;
lv_style_t underline;
#if LV_USE_TEXTAREA
lv_style_t ta_cursor;
#endif
#if LV_USE_CHART
lv_style_t chart_indic;
#endif
} my_theme_styles_t;
struct _my_theme_t {
lv_theme_t base;
my_theme_styles_t styles;
bool inited;
};
/**********************
* STATIC PROTOTYPES
**********************/
static void style_init_reset(lv_style_t * style);
static void theme_apply(lv_theme_t * th, lv_obj_t * obj);
/**********************
* STATIC VARIABLES
**********************/
/**********************
* MACROS
**********************/
/**********************
* STATIC FUNCTIONS
**********************/
static void style_init(my_theme_t * theme, bool dark_bg, const lv_font_t * font)
{
style_init_reset(&theme->styles.scrollbar);
lv_style_set_bg_opa(&theme->styles.scrollbar, LV_OPA_COVER);
lv_style_set_bg_color(&theme->styles.scrollbar, COLOR_FG);
lv_style_set_width(&theme->styles.scrollbar, PAD_DEF);
style_init_reset(&theme->styles.scr);
lv_style_set_bg_opa(&theme->styles.scr, LV_OPA_COVER);
lv_style_set_bg_color(&theme->styles.scr, COLOR_BG);
lv_style_set_text_color(&theme->styles.scr, COLOR_FG);
lv_style_set_pad_row(&theme->styles.scr, PAD_DEF);
lv_style_set_pad_column(&theme->styles.scr, PAD_DEF);
lv_style_set_text_font(&theme->styles.scr, font);
style_init_reset(&theme->styles.card);
lv_style_set_bg_opa(&theme->styles.card, LV_OPA_COVER);
lv_style_set_bg_color(&theme->styles.card, COLOR_BG);
lv_style_set_border_color(&theme->styles.card, COLOR_FG);
lv_style_set_radius(&theme->styles.card, 2);
lv_style_set_border_width(&theme->styles.card, BORDER_W_NORMAL);
lv_style_set_pad_all(&theme->styles.card, PAD_DEF);
lv_style_set_pad_gap(&theme->styles.card, PAD_DEF);
lv_style_set_text_color(&theme->styles.card, COLOR_FG);
lv_style_set_line_width(&theme->styles.card, 2);
lv_style_set_line_color(&theme->styles.card, COLOR_FG);
lv_style_set_arc_width(&theme->styles.card, 2);
lv_style_set_arc_color(&theme->styles.card, COLOR_FG);
lv_style_set_outline_color(&theme->styles.card, COLOR_FG);
lv_style_set_anim_duration(&theme->styles.card, 300);
style_init_reset(&theme->styles.pr);
lv_style_set_border_width(&theme->styles.pr, BORDER_W_PR);
style_init_reset(&theme->styles.inv);
lv_style_set_bg_opa(&theme->styles.inv, LV_OPA_COVER);
lv_style_set_bg_color(&theme->styles.inv, COLOR_FG);
lv_style_set_border_color(&theme->styles.inv, COLOR_BG);
lv_style_set_line_color(&theme->styles.inv, COLOR_BG);
lv_style_set_arc_color(&theme->styles.inv, COLOR_BG);
lv_style_set_text_color(&theme->styles.inv, COLOR_BG);
lv_style_set_outline_color(&theme->styles.inv, COLOR_BG);
style_init_reset(&theme->styles.disabled);
lv_style_set_border_width(&theme->styles.disabled, BORDER_W_DIS);
style_init_reset(&theme->styles.focus);
lv_style_set_outline_width(&theme->styles.focus, 1);
lv_style_set_outline_pad(&theme->styles.focus, BORDER_W_FOCUS);
style_init_reset(&theme->styles.edit);
lv_style_set_outline_width(&theme->styles.edit, BORDER_W_EDIT);
style_init_reset(&theme->styles.large_border);
lv_style_set_border_width(&theme->styles.large_border, BORDER_W_EDIT);
style_init_reset(&theme->styles.pad_gap);
lv_style_set_pad_gap(&theme->styles.pad_gap, PAD_DEF);
style_init_reset(&theme->styles.pad_zero);
lv_style_set_pad_all(&theme->styles.pad_zero, 0);
lv_style_set_pad_gap(&theme->styles.pad_zero, 0);
style_init_reset(&theme->styles.no_radius);
lv_style_set_radius(&theme->styles.no_radius, 0);
style_init_reset(&theme->styles.radius_circle);
lv_style_set_radius(&theme->styles.radius_circle, LV_RADIUS_CIRCLE);
style_init_reset(&theme->styles.large_line_space);
lv_style_set_text_line_space(&theme->styles.large_line_space, 6);
style_init_reset(&theme->styles.underline);
lv_style_set_text_decor(&theme->styles.underline, LV_TEXT_DECOR_UNDERLINE);
#if LV_USE_TEXTAREA
style_init_reset(&theme->styles.ta_cursor);
lv_style_set_border_side(&theme->styles.ta_cursor, LV_BORDER_SIDE_LEFT);
lv_style_set_border_color(&theme->styles.ta_cursor, COLOR_FG);
lv_style_set_border_width(&theme->styles.ta_cursor, 2);
lv_style_set_bg_opa(&theme->styles.ta_cursor, LV_OPA_TRANSP);
lv_style_set_anim_duration(&theme->styles.ta_cursor, 500);
#endif
#if LV_USE_CHART
style_init_reset(&theme->styles.chart_indic);
lv_style_set_radius(&theme->styles.chart_indic, LV_RADIUS_CIRCLE);
lv_style_set_size(&theme->styles.chart_indic, lv_display_dpx(theme->base.disp, 8), lv_display_dpx(theme->base.disp, 8));
lv_style_set_bg_color(&theme->styles.chart_indic, COLOR_FG);
lv_style_set_bg_opa(&theme->styles.chart_indic, LV_OPA_COVER);
#endif
}
/**********************
* GLOBAL FUNCTIONS
**********************/
bool lv_theme_mono_is_inited(void)
{
my_theme_t * theme = theme_def;
if(theme == NULL) return false;
return theme->inited;
}
void lv_theme_mono_deinit(void)
{
my_theme_t * theme = theme_def;
if(theme) {
if(theme->inited) {
lv_style_t * theme_styles = (lv_style_t *)(&(theme->styles));
uint32_t i;
for(i = 0; i < sizeof(my_theme_styles_t) / sizeof(lv_style_t); i++) {
lv_style_reset(theme_styles + i);
}
}
lv_free(theme_def);
theme_def = NULL;
}
}
lv_theme_t * lv_theme_mono_init(lv_display_t * disp, bool dark_bg, const lv_font_t * font)
{
/*This trick is required only to avoid the garbage collection of
*styles' data if LVGL is used in a binding (e.g. MicroPython)
*In a general case styles could be in simple `static lv_style_t my_style...` variables*/
if(!lv_theme_mono_is_inited()) {
theme_def = lv_malloc_zeroed(sizeof(my_theme_t));
}
my_theme_t * theme = theme_def;
theme->base.disp = disp;
theme->base.font_small = LV_FONT_DEFAULT;
theme->base.font_normal = LV_FONT_DEFAULT;
theme->base.font_large = LV_FONT_DEFAULT;
theme->base.apply_cb = theme_apply;
style_init(theme, dark_bg, font);
if(disp == NULL || lv_display_get_theme(disp) == (lv_theme_t *) theme) lv_obj_report_style_change(NULL);
theme->inited = true;
return (lv_theme_t *)theme_def;
}
static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
{
LV_UNUSED(th);
my_theme_t * theme = theme_def;
lv_obj_t * parent = lv_obj_get_parent(obj);
if(parent == NULL) {
lv_obj_add_style(obj, &theme->styles.scr, 0);
lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR);
return;
}
if(lv_obj_check_type(obj, &lv_obj_class)) {
#if LV_USE_TABVIEW
/*Tabview content area*/
if(lv_obj_check_type(parent, &lv_tabview_class)) {
return;
}
/*Tabview pages*/
else if(lv_obj_check_type(lv_obj_get_parent(parent), &lv_tabview_class)) {
lv_obj_add_style(obj, &theme->styles.card, 0);
lv_obj_add_style(obj, &theme->styles.no_radius, 0);
lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR);
return;
}
#endif
#if LV_USE_WIN
/*Header*/
if(lv_obj_check_type(parent, &lv_win_class) && lv_obj_get_child(parent, 0) == 0) {
lv_obj_add_style(obj, &theme->styles.card, 0);
lv_obj_add_style(obj, &theme->styles.no_radius, 0);
return;
}
/*Content*/
else if(lv_obj_check_type(parent, &lv_win_class) && lv_obj_get_child(parent, 1) == obj) {
lv_obj_add_style(obj, &theme->styles.card, 0);
lv_obj_add_style(obj, &theme->styles.no_radius, 0);
lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR);
return;
}
#endif
lv_obj_add_style(obj, &theme->styles.card, 0);
lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR);
}
#if LV_USE_BUTTON
else if(lv_obj_check_type(obj, &lv_button_class)) {
lv_obj_add_style(obj, &theme->styles.card, 0);
lv_obj_add_style(obj, &theme->styles.pr, LV_STATE_PRESSED);
lv_obj_add_style(obj, &theme->styles.inv, LV_STATE_CHECKED);
lv_obj_add_style(obj, &theme->styles.disabled, LV_STATE_DISABLED);
lv_obj_add_style(obj, &theme->styles.focus, LV_STATE_FOCUS_KEY);
lv_obj_add_style(obj, &theme->styles.edit, LV_STATE_EDITED);
}
#endif
#if LV_USE_BUTTONMATRIX
else if(lv_obj_check_type(obj, &lv_buttonmatrix_class)) {
#if LV_USE_MSGBOX
if(lv_obj_check_type(parent, &lv_msgbox_class)) {
lv_obj_add_style(obj, &theme->styles.pad_gap, 0);
lv_obj_add_style(obj, &theme->styles.card, LV_PART_ITEMS);
lv_obj_add_style(obj, &theme->styles.pr, LV_PART_ITEMS | LV_STATE_PRESSED);
lv_obj_add_style(obj, &theme->styles.disabled, LV_PART_ITEMS | LV_STATE_DISABLED);
lv_obj_add_style(obj, &theme->styles.underline, LV_PART_ITEMS | LV_STATE_FOCUS_KEY);
lv_obj_add_style(obj, &theme->styles.large_border, LV_PART_ITEMS | LV_STATE_FOCUS_KEY);
return;
}
#endif
#if LV_USE_TABVIEW
if(lv_obj_check_type(parent, &lv_tabview_class)) {
lv_obj_add_style(obj, &theme->styles.pad_gap, 0);
lv_obj_add_style(obj, &theme->styles.card, LV_PART_ITEMS);
lv_obj_add_style(obj, &theme->styles.pr, LV_PART_ITEMS | LV_STATE_PRESSED);
lv_obj_add_style(obj, &theme->styles.inv, LV_PART_ITEMS | LV_STATE_CHECKED);
lv_obj_add_style(obj, &theme->styles.disabled, LV_PART_ITEMS | LV_STATE_DISABLED);
lv_obj_add_style(obj, &theme->styles.focus, LV_STATE_FOCUS_KEY);
lv_obj_add_style(obj, &theme->styles.underline, LV_PART_ITEMS | LV_STATE_FOCUS_KEY);
lv_obj_add_style(obj, &theme->styles.large_border, LV_PART_ITEMS | LV_STATE_FOCUS_KEY);
return;
}
#endif
lv_obj_add_style(obj, &theme->styles.card, 0);
lv_obj_add_style(obj, &theme->styles.focus, LV_STATE_FOCUS_KEY);
lv_obj_add_style(obj, &theme->styles.card, LV_PART_ITEMS);
lv_obj_add_style(obj, &theme->styles.pr, LV_PART_ITEMS | LV_STATE_PRESSED);
lv_obj_add_style(obj, &theme->styles.inv, LV_PART_ITEMS | LV_STATE_CHECKED);
lv_obj_add_style(obj, &theme->styles.disabled, LV_PART_ITEMS | LV_STATE_DISABLED);
lv_obj_add_style(obj, &theme->styles.underline, LV_PART_ITEMS | LV_STATE_FOCUS_KEY);
lv_obj_add_style(obj, &theme->styles.large_border, LV_PART_ITEMS | LV_STATE_FOCUS_KEY);
}
#endif
#if LV_USE_BAR
else if(lv_obj_check_type(obj, &lv_bar_class)) {
lv_obj_add_style(obj, &theme->styles.card, 0);
lv_obj_add_style(obj, &theme->styles.pad_zero, 0);
lv_obj_add_style(obj, &theme->styles.inv, LV_PART_INDICATOR);
lv_obj_add_style(obj, &theme->styles.focus, LV_STATE_FOCUS_KEY);
}
#endif
#if LV_USE_SLIDER
else if(lv_obj_check_type(obj, &lv_slider_class)) {
lv_obj_add_style(obj, &theme->styles.card, 0);
lv_obj_add_style(obj, &theme->styles.pad_zero, 0);
lv_obj_add_style(obj, &theme->styles.inv, LV_PART_INDICATOR);
lv_obj_add_style(obj, &theme->styles.card, LV_PART_KNOB);
lv_obj_add_style(obj, &theme->styles.radius_circle, LV_PART_KNOB);
lv_obj_add_style(obj, &theme->styles.focus, LV_STATE_FOCUS_KEY);
lv_obj_add_style(obj, &theme->styles.edit, LV_STATE_EDITED);
}
#endif
#if LV_USE_TABLE
else if(lv_obj_check_type(obj, &lv_table_class)) {
lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR);
lv_obj_add_style(obj, &theme->styles.card, LV_PART_ITEMS);
lv_obj_add_style(obj, &theme->styles.no_radius, LV_PART_ITEMS);
lv_obj_add_style(obj, &theme->styles.pr, LV_PART_ITEMS | LV_STATE_PRESSED);
lv_obj_add_style(obj, &theme->styles.focus, LV_STATE_FOCUS_KEY);
lv_obj_add_style(obj, &theme->styles.inv, LV_PART_ITEMS | LV_STATE_FOCUS_KEY);
lv_obj_add_style(obj, &theme->styles.edit, LV_STATE_EDITED);
}
#endif
#if LV_USE_CHECKBOX
else if(lv_obj_check_type(obj, &lv_checkbox_class)) {
lv_obj_add_style(obj, &theme->styles.pad_gap, LV_PART_MAIN);
lv_obj_add_style(obj, &theme->styles.card, LV_PART_INDICATOR);
lv_obj_add_style(obj, &theme->styles.disabled, LV_PART_INDICATOR | LV_STATE_DISABLED);
lv_obj_add_style(obj, &theme->styles.inv, LV_PART_INDICATOR | LV_STATE_CHECKED);
lv_obj_add_style(obj, &theme->styles.pr, LV_PART_INDICATOR | LV_STATE_PRESSED);
lv_obj_add_style(obj, &theme->styles.focus, LV_STATE_FOCUS_KEY);
lv_obj_add_style(obj, &theme->styles.edit, LV_STATE_EDITED);
}
#endif
#if LV_USE_SWITCH
else if(lv_obj_check_type(obj, &lv_switch_class)) {
lv_obj_add_style(obj, &theme->styles.card, 0);
lv_obj_add_style(obj, &theme->styles.radius_circle, 0);
lv_obj_add_style(obj, &theme->styles.pad_zero, 0);
lv_obj_add_style(obj, &theme->styles.inv, LV_PART_INDICATOR);
lv_obj_add_style(obj, &theme->styles.radius_circle, LV_PART_INDICATOR);
lv_obj_add_style(obj, &theme->styles.card, LV_PART_KNOB);
lv_obj_add_style(obj, &theme->styles.radius_circle, LV_PART_KNOB);
lv_obj_add_style(obj, &theme->styles.pad_zero, LV_PART_KNOB);
lv_obj_add_style(obj, &theme->styles.focus, LV_STATE_FOCUS_KEY);
lv_obj_add_style(obj, &theme->styles.edit, LV_STATE_EDITED);
}
#endif
#if LV_USE_CHART
else if(lv_obj_check_type(obj, &lv_chart_class)) {
lv_obj_add_style(obj, &theme->styles.card, 0);
lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR);
lv_obj_add_style(obj, &theme->styles.chart_indic, LV_PART_INDICATOR);
lv_obj_add_style(obj, &theme->styles.card, LV_PART_ITEMS);
lv_obj_add_style(obj, &theme->styles.card, LV_PART_CURSOR);
lv_obj_add_style(obj, &theme->styles.focus, LV_STATE_FOCUS_KEY);
}
#endif
#if LV_USE_ROLLER
else if(lv_obj_check_type(obj, &lv_roller_class)) {
lv_obj_add_style(obj, &theme->styles.card, 0);
lv_obj_add_style(obj, &theme->styles.large_line_space, 0);
lv_obj_add_style(obj, &theme->styles.inv, LV_PART_SELECTED);
lv_obj_add_style(obj, &theme->styles.focus, LV_STATE_FOCUS_KEY);
lv_obj_add_style(obj, &theme->styles.edit, LV_STATE_EDITED);
}
#endif
#if LV_USE_DROPDOWN
else if(lv_obj_check_type(obj, &lv_dropdown_class)) {
lv_obj_add_style(obj, &theme->styles.card, 0);
lv_obj_add_style(obj, &theme->styles.pr, LV_STATE_PRESSED);
lv_obj_add_style(obj, &theme->styles.focus, LV_STATE_FOCUS_KEY);
lv_obj_add_style(obj, &theme->styles.edit, LV_STATE_EDITED);
}
else if(lv_obj_check_type(obj, &lv_dropdownlist_class)) {
lv_obj_add_style(obj, &theme->styles.card, 0);
lv_obj_add_style(obj, &theme->styles.large_line_space, 0);
lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR);
lv_obj_add_style(obj, &theme->styles.inv, LV_PART_SELECTED | LV_STATE_CHECKED);
lv_obj_add_style(obj, &theme->styles.pr, LV_PART_SELECTED | LV_STATE_PRESSED);
lv_obj_add_style(obj, &theme->styles.focus, LV_STATE_FOCUS_KEY);
lv_obj_add_style(obj, &theme->styles.edit, LV_STATE_EDITED);
}
#endif
#if LV_USE_ARC
else if(lv_obj_check_type(obj, &lv_arc_class)) {
lv_obj_add_style(obj, &theme->styles.card, 0);
lv_obj_add_style(obj, &theme->styles.inv, LV_PART_INDICATOR);
lv_obj_add_style(obj, &theme->styles.pad_zero, LV_PART_INDICATOR);
lv_obj_add_style(obj, &theme->styles.card, LV_PART_KNOB);
lv_obj_add_style(obj, &theme->styles.radius_circle, LV_PART_KNOB);
lv_obj_add_style(obj, &theme->styles.focus, LV_STATE_FOCUS_KEY);
lv_obj_add_style(obj, &theme->styles.edit, LV_STATE_EDITED);
}
#endif
#if LV_USE_TEXTAREA
else if(lv_obj_check_type(obj, &lv_textarea_class)) {
lv_obj_add_style(obj, &theme->styles.card, 0);
lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR);
lv_obj_add_style(obj, &theme->styles.ta_cursor, LV_PART_CURSOR | LV_STATE_FOCUSED);
lv_obj_add_style(obj, &theme->styles.focus, LV_STATE_FOCUSED);
lv_obj_add_style(obj, &theme->styles.edit, LV_STATE_EDITED);
}
#endif
#if LV_USE_CALENDAR
else if(lv_obj_check_type(obj, &lv_calendar_class)) {
lv_obj_add_style(obj, &theme->styles.card, 0);
lv_obj_add_style(obj, &theme->styles.no_radius, 0);
lv_obj_add_style(obj, &theme->styles.pr, LV_PART_ITEMS | LV_STATE_PRESSED);
lv_obj_add_style(obj, &theme->styles.disabled, LV_PART_ITEMS | LV_STATE_DISABLED);
lv_obj_add_style(obj, &theme->styles.focus, LV_STATE_FOCUS_KEY);
lv_obj_add_style(obj, &theme->styles.edit, LV_STATE_EDITED);
lv_obj_add_style(obj, &theme->styles.large_border, LV_PART_ITEMS | LV_STATE_FOCUS_KEY);
}
#endif
#if LV_USE_KEYBOARD
else if(lv_obj_check_type(obj, &lv_keyboard_class)) {
lv_obj_add_style(obj, &theme->styles.card, 0);
lv_obj_add_style(obj, &theme->styles.card, LV_PART_ITEMS);
lv_obj_add_style(obj, &theme->styles.pr, LV_PART_ITEMS | LV_STATE_PRESSED);
lv_obj_add_style(obj, &theme->styles.inv, LV_PART_ITEMS | LV_STATE_CHECKED);
lv_obj_add_style(obj, &theme->styles.focus, LV_STATE_FOCUS_KEY);
lv_obj_add_style(obj, &theme->styles.edit, LV_STATE_EDITED);
lv_obj_add_style(obj, &theme->styles.large_border, LV_PART_ITEMS | LV_STATE_EDITED);
}
#endif
#if LV_USE_LIST
else if(lv_obj_check_type(obj, &lv_list_class)) {
lv_obj_add_style(obj, &theme->styles.card, 0);
lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR);
return;
}
else if(lv_obj_check_type(obj, &lv_list_text_class)) {
}
else if(lv_obj_check_type(obj, &lv_list_button_class)) {
lv_obj_add_style(obj, &theme->styles.card, 0);
lv_obj_add_style(obj, &theme->styles.pr, LV_STATE_PRESSED);
lv_obj_add_style(obj, &theme->styles.focus, LV_STATE_FOCUS_KEY);
lv_obj_add_style(obj, &theme->styles.large_border, LV_STATE_EDITED);
}
#endif
#if LV_USE_MSGBOX
else if(lv_obj_check_type(obj, &lv_msgbox_class)) {
lv_obj_add_style(obj, &theme->styles.card, 0);
return;
}
#endif
#if LV_USE_SPINBOX
else if(lv_obj_check_type(obj, &lv_spinbox_class)) {
lv_obj_add_style(obj, &theme->styles.card, 0);
lv_obj_add_style(obj, &theme->styles.inv, LV_PART_CURSOR);
lv_obj_add_style(obj, &theme->styles.focus, LV_STATE_FOCUS_KEY);
lv_obj_add_style(obj, &theme->styles.edit, LV_STATE_EDITED);
}
#endif
#if LV_USE_TILEVIEW
else if(lv_obj_check_type(obj, &lv_tileview_class)) {
lv_obj_add_style(obj, &theme->styles.scr, 0);
lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR);
}
else if(lv_obj_check_type(obj, &lv_tileview_tile_class)) {
lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR);
}
#endif
#if LV_USE_LED
else if(lv_obj_check_type(obj, &lv_led_class)) {
lv_obj_add_style(obj, &theme->styles.card, 0);
}
#endif
}
/**********************
* STATIC FUNCTIONS
**********************/
static void style_init_reset(lv_style_t * style)
{
if(lv_theme_mono_is_inited()) {
lv_style_reset(style);
}
else {
lv_style_init(style);
}
}
#endif

View File

@@ -0,0 +1,62 @@
/**
* @file lv_theme_mono.h
*
*/
#ifndef LV_THEME_MONO_H
#define LV_THEME_MONO_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../lv_theme.h"
#if LV_USE_THEME_MONO
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Initialize the theme
* @param disp pointer to display
* @param dark_bg
* @param font pointer to a font to use.
* @return a pointer to reference this theme later
*/
lv_theme_t * lv_theme_mono_init(lv_display_t * disp, bool dark_bg, const lv_font_t * font);
/**
* Check if the theme is initialized
* @return true if default theme is initialized, false otherwise
*/
bool lv_theme_mono_is_inited(void);
/**
* Deinitialize the mono theme
*/
void lv_theme_mono_deinit(void);
/**********************
* MACROS
**********************/
#endif
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /* LV_THEME_MONO_H */

View File

@@ -0,0 +1,438 @@
/**
* @file lv_theme_simple.c
*
*/
/*********************
* INCLUDES
*********************/
#include "../lv_theme_private.h"
#include "../../../lvgl.h" /*To see all the widgets*/
#if LV_USE_THEME_SIMPLE
#include "lv_theme_simple.h"
#include "../../core/lv_global.h"
/*********************
* DEFINES
*********************/
struct _my_theme_t;
typedef struct _my_theme_t my_theme_t;
#define theme_def (*(my_theme_t **)(&LV_GLOBAL_DEFAULT()->theme_simple))
#define COLOR_SCR lv_palette_lighten(LV_PALETTE_GREY, 4)
#define COLOR_WHITE lv_color_white()
#define COLOR_LIGHT lv_palette_lighten(LV_PALETTE_GREY, 2)
#define COLOR_DARK lv_palette_main(LV_PALETTE_GREY)
#define COLOR_DIM lv_palette_darken(LV_PALETTE_GREY, 2)
#define SCROLLBAR_WIDTH 2
/**********************
* TYPEDEFS
**********************/
typedef struct {
lv_style_t scr;
lv_style_t transp;
lv_style_t white;
lv_style_t light;
lv_style_t dark;
lv_style_t dim;
lv_style_t scrollbar;
#if LV_USE_ARC
lv_style_t arc_line;
lv_style_t arc_knob;
#endif
#if LV_USE_TEXTAREA
lv_style_t ta_cursor;
#endif
} my_theme_styles_t;
struct _my_theme_t {
lv_theme_t base;
my_theme_styles_t styles;
bool inited;
};
/**********************
* STATIC PROTOTYPES
**********************/
static void style_init_reset(lv_style_t * style);
static void theme_apply(lv_theme_t * th, lv_obj_t * obj);
/**********************
* STATIC VARIABLES
**********************/
/**********************
* MACROS
**********************/
/**********************
* STATIC FUNCTIONS
**********************/
static void style_init(my_theme_t * theme)
{
style_init_reset(&theme->styles.scrollbar);
lv_style_set_bg_opa(&theme->styles.scrollbar, LV_OPA_COVER);
lv_style_set_bg_color(&theme->styles.scrollbar, COLOR_DARK);
lv_style_set_width(&theme->styles.scrollbar, SCROLLBAR_WIDTH);
style_init_reset(&theme->styles.scr);
lv_style_set_bg_opa(&theme->styles.scr, LV_OPA_COVER);
lv_style_set_bg_color(&theme->styles.scr, COLOR_SCR);
lv_style_set_text_color(&theme->styles.scr, COLOR_DIM);
style_init_reset(&theme->styles.transp);
lv_style_set_bg_opa(&theme->styles.transp, LV_OPA_TRANSP);
style_init_reset(&theme->styles.white);
lv_style_set_bg_opa(&theme->styles.white, LV_OPA_COVER);
lv_style_set_bg_color(&theme->styles.white, COLOR_WHITE);
lv_style_set_line_width(&theme->styles.white, 1);
lv_style_set_line_color(&theme->styles.white, COLOR_WHITE);
lv_style_set_arc_width(&theme->styles.white, 2);
lv_style_set_arc_color(&theme->styles.white, COLOR_WHITE);
style_init_reset(&theme->styles.light);
lv_style_set_bg_opa(&theme->styles.light, LV_OPA_COVER);
lv_style_set_bg_color(&theme->styles.light, COLOR_LIGHT);
lv_style_set_line_width(&theme->styles.light, 1);
lv_style_set_line_color(&theme->styles.light, COLOR_LIGHT);
lv_style_set_arc_width(&theme->styles.light, 2);
lv_style_set_arc_color(&theme->styles.light, COLOR_LIGHT);
style_init_reset(&theme->styles.dark);
lv_style_set_bg_opa(&theme->styles.dark, LV_OPA_COVER);
lv_style_set_bg_color(&theme->styles.dark, COLOR_DARK);
lv_style_set_line_width(&theme->styles.dark, 1);
lv_style_set_line_color(&theme->styles.dark, COLOR_DARK);
lv_style_set_arc_width(&theme->styles.dark, 2);
lv_style_set_arc_color(&theme->styles.dark, COLOR_DARK);
style_init_reset(&theme->styles.dim);
lv_style_set_bg_opa(&theme->styles.dim, LV_OPA_COVER);
lv_style_set_bg_color(&theme->styles.dim, COLOR_DIM);
lv_style_set_line_width(&theme->styles.dim, 1);
lv_style_set_line_color(&theme->styles.dim, COLOR_DIM);
lv_style_set_arc_width(&theme->styles.dim, 2);
lv_style_set_arc_color(&theme->styles.dim, COLOR_DIM);
#if LV_USE_ARC
style_init_reset(&theme->styles.arc_line);
lv_style_set_arc_width(&theme->styles.arc_line, 6);
style_init_reset(&theme->styles.arc_knob);
lv_style_set_pad_all(&theme->styles.arc_knob, 5);
#endif
#if LV_USE_TEXTAREA
style_init_reset(&theme->styles.ta_cursor);
lv_style_set_border_side(&theme->styles.ta_cursor, LV_BORDER_SIDE_LEFT);
lv_style_set_border_color(&theme->styles.ta_cursor, COLOR_DIM);
lv_style_set_border_width(&theme->styles.ta_cursor, 2);
lv_style_set_bg_opa(&theme->styles.ta_cursor, LV_OPA_TRANSP);
lv_style_set_anim_duration(&theme->styles.ta_cursor, 500);
#endif
}
/**********************
* GLOBAL FUNCTIONS
**********************/
bool lv_theme_simple_is_inited(void)
{
my_theme_t * theme = theme_def;
if(theme == NULL) return false;
return theme->inited;
}
lv_theme_t * lv_theme_simple_get(void)
{
if(!lv_theme_simple_is_inited()) {
return NULL;
}
return (lv_theme_t *)theme_def;
}
void lv_theme_simple_deinit(void)
{
my_theme_t * theme = theme_def;
if(theme) {
if(theme->inited) {
lv_style_t * theme_styles = (lv_style_t *)(&(theme->styles));
uint32_t i;
for(i = 0; i < sizeof(my_theme_styles_t) / sizeof(lv_style_t); i++) {
lv_style_reset(theme_styles + i);
}
}
lv_free(theme_def);
theme_def = NULL;
}
}
lv_theme_t * lv_theme_simple_init(lv_display_t * disp)
{
/*This trick is required only to avoid the garbage collection of
*styles' data if LVGL is used in a binding (e.g. MicroPython)
*In a general case styles could be in simple `static lv_style_t my_style...` variables*/
if(!lv_theme_simple_is_inited()) {
theme_def = lv_malloc_zeroed(sizeof(my_theme_t));
}
my_theme_t * theme = theme_def;
theme->base.disp = disp;
theme->base.font_small = LV_FONT_DEFAULT;
theme->base.font_normal = LV_FONT_DEFAULT;
theme->base.font_large = LV_FONT_DEFAULT;
theme->base.apply_cb = theme_apply;
style_init(theme);
if(disp == NULL || lv_display_get_theme(disp) == (lv_theme_t *)theme) {
lv_obj_report_style_change(NULL);
}
theme->inited = true;
return (lv_theme_t *)theme_def;
}
static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
{
LV_UNUSED(th);
my_theme_t * theme = theme_def;
lv_obj_t * parent = lv_obj_get_parent(obj);
if(parent == NULL) {
lv_obj_add_style(obj, &theme->styles.scr, 0);
lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR);
return;
}
if(lv_obj_check_type(obj, &lv_obj_class)) {
#if LV_USE_TABVIEW
/*Tabview content area*/
if(lv_obj_check_type(parent, &lv_tabview_class)) {
lv_obj_add_style(obj, &theme->styles.scr, 0);
return;
}
/*Tabview pages*/
else if(lv_obj_check_type(lv_obj_get_parent(parent), &lv_tabview_class)) {
lv_obj_add_style(obj, &theme->styles.scr, 0);
lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR);
return;
}
#endif
#if LV_USE_WIN
/*Header*/
if(lv_obj_check_type(parent, &lv_win_class) && lv_obj_get_child(parent, 0) == obj) {
lv_obj_add_style(obj, &theme->styles.light, 0);
return;
}
/*Content*/
else if(lv_obj_check_type(parent, &lv_win_class) && lv_obj_get_child(parent, 1) == obj) {
lv_obj_add_style(obj, &theme->styles.light, 0);
lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR);
return;
}
#endif
lv_obj_add_style(obj, &theme->styles.white, 0);
lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR);
}
#if LV_USE_BUTTON
else if(lv_obj_check_type(obj, &lv_button_class)) {
lv_obj_add_style(obj, &theme->styles.dark, 0);
}
#endif
#if LV_USE_BUTTONMATRIX
else if(lv_obj_check_type(obj, &lv_buttonmatrix_class)) {
#if LV_USE_MSGBOX
if(lv_obj_check_type(parent, &lv_msgbox_class)) {
lv_obj_add_style(obj, &theme->styles.light, LV_PART_ITEMS);
return;
}
#endif
#if LV_USE_TABVIEW
if(lv_obj_check_type(parent, &lv_tabview_class)) {
lv_obj_add_style(obj, &theme->styles.light, LV_PART_ITEMS);
return;
}
#endif
lv_obj_add_style(obj, &theme->styles.white, 0);
lv_obj_add_style(obj, &theme->styles.light, LV_PART_ITEMS);
}
#endif
#if LV_USE_BAR
else if(lv_obj_check_type(obj, &lv_bar_class)) {
lv_obj_add_style(obj, &theme->styles.light, 0);
lv_obj_add_style(obj, &theme->styles.dark, LV_PART_INDICATOR);
}
#endif
#if LV_USE_SLIDER
else if(lv_obj_check_type(obj, &lv_slider_class)) {
lv_obj_add_style(obj, &theme->styles.light, 0);
lv_obj_add_style(obj, &theme->styles.dark, LV_PART_INDICATOR);
lv_obj_add_style(obj, &theme->styles.dim, LV_PART_KNOB);
}
#endif
#if LV_USE_TABLE
else if(lv_obj_check_type(obj, &lv_table_class)) {
lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR);
lv_obj_add_style(obj, &theme->styles.light, LV_PART_ITEMS);
}
#endif
#if LV_USE_CHECKBOX
else if(lv_obj_check_type(obj, &lv_checkbox_class)) {
lv_obj_add_style(obj, &theme->styles.light, LV_PART_INDICATOR);
lv_obj_add_style(obj, &theme->styles.dark, LV_PART_INDICATOR | LV_STATE_CHECKED);
}
#endif
#if LV_USE_SWITCH
else if(lv_obj_check_type(obj, &lv_switch_class)) {
lv_obj_add_style(obj, &theme->styles.light, 0);
lv_obj_add_style(obj, &theme->styles.dim, LV_PART_KNOB);
}
#endif
#if LV_USE_CHART
else if(lv_obj_check_type(obj, &lv_chart_class)) {
lv_obj_add_style(obj, &theme->styles.white, 0);
lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR);
lv_obj_add_style(obj, &theme->styles.light, LV_PART_ITEMS);
lv_obj_add_style(obj, &theme->styles.dark, LV_PART_CURSOR);
}
#endif
#if LV_USE_ROLLER
else if(lv_obj_check_type(obj, &lv_roller_class)) {
lv_obj_add_style(obj, &theme->styles.light, 0);
lv_obj_add_style(obj, &theme->styles.dark, LV_PART_SELECTED);
}
#endif
#if LV_USE_DROPDOWN
else if(lv_obj_check_type(obj, &lv_dropdown_class)) {
lv_obj_add_style(obj, &theme->styles.white, 0);
}
else if(lv_obj_check_type(obj, &lv_dropdownlist_class)) {
lv_obj_add_style(obj, &theme->styles.white, 0);
lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR);
lv_obj_add_style(obj, &theme->styles.light, LV_PART_SELECTED);
lv_obj_add_style(obj, &theme->styles.dark, LV_PART_SELECTED | LV_STATE_CHECKED);
}
#endif
#if LV_USE_ARC
else if(lv_obj_check_type(obj, &lv_arc_class)) {
lv_obj_add_style(obj, &theme->styles.light, 0);
lv_obj_add_style(obj, &theme->styles.transp, 0);
lv_obj_add_style(obj, &theme->styles.arc_line, 0);
lv_obj_add_style(obj, &theme->styles.dark, LV_PART_INDICATOR);
lv_obj_add_style(obj, &theme->styles.arc_line, LV_PART_INDICATOR);
lv_obj_add_style(obj, &theme->styles.dim, LV_PART_KNOB);
lv_obj_add_style(obj, &theme->styles.arc_knob, LV_PART_KNOB);
}
#endif
#if LV_USE_SPINNER
else if(lv_obj_check_type(obj, &lv_spinner_class)) {
lv_obj_add_style(obj, &theme->styles.light, 0);
lv_obj_add_style(obj, &theme->styles.transp, 0);
lv_obj_add_style(obj, &theme->styles.arc_line, 0);
lv_obj_add_style(obj, &theme->styles.dark, LV_PART_INDICATOR);
lv_obj_add_style(obj, &theme->styles.arc_line, LV_PART_INDICATOR);
}
#endif
#if LV_USE_TEXTAREA
else if(lv_obj_check_type(obj, &lv_textarea_class)) {
lv_obj_add_style(obj, &theme->styles.white, 0);
lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR);
lv_obj_add_style(obj, &theme->styles.ta_cursor, LV_PART_CURSOR | LV_STATE_FOCUSED);
}
#endif
#if LV_USE_CALENDAR
else if(lv_obj_check_type(obj, &lv_calendar_class)) {
lv_obj_add_style(obj, &theme->styles.light, 0);
}
#endif
#if LV_USE_KEYBOARD
else if(lv_obj_check_type(obj, &lv_keyboard_class)) {
lv_obj_add_style(obj, &theme->styles.scr, 0);
lv_obj_add_style(obj, &theme->styles.white, LV_PART_ITEMS);
lv_obj_add_style(obj, &theme->styles.light, LV_PART_ITEMS | LV_STATE_CHECKED);
}
#endif
#if LV_USE_LIST
else if(lv_obj_check_type(obj, &lv_list_class)) {
lv_obj_add_style(obj, &theme->styles.light, 0);
lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR);
return;
}
else if(lv_obj_check_type(obj, &lv_list_text_class)) {
}
else if(lv_obj_check_type(obj, &lv_list_button_class)) {
lv_obj_add_style(obj, &theme->styles.dark, 0);
}
#endif
#if LV_USE_MSGBOX
else if(lv_obj_check_type(obj, &lv_msgbox_class)) {
lv_obj_add_style(obj, &theme->styles.light, 0);
return;
}
#endif
#if LV_USE_SPINBOX
else if(lv_obj_check_type(obj, &lv_spinbox_class)) {
lv_obj_add_style(obj, &theme->styles.light, 0);
lv_obj_add_style(obj, &theme->styles.dark, LV_PART_CURSOR);
}
#endif
#if LV_USE_TILEVIEW
else if(lv_obj_check_type(obj, &lv_tileview_class)) {
lv_obj_add_style(obj, &theme->styles.scr, 0);
lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR);
}
else if(lv_obj_check_type(obj, &lv_tileview_tile_class)) {
lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR);
}
#endif
#if LV_USE_LED
else if(lv_obj_check_type(obj, &lv_led_class)) {
lv_obj_add_style(obj, &theme->styles.light, 0);
}
#endif
}
/**********************
* STATIC FUNCTIONS
**********************/
static void style_init_reset(lv_style_t * style)
{
if(lv_theme_simple_is_inited()) {
lv_style_reset(style);
}
else {
lv_style_init(style);
}
}
#endif

View File

@@ -0,0 +1,67 @@
/**
* @file lv_theme_simple.h
*
*/
#ifndef LV_THEME_SIMPLE_H
#define LV_THEME_SIMPLE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../lv_theme.h"
#include "../../display/lv_display.h"
#if LV_USE_THEME_SIMPLE
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Initialize the theme
* @param disp pointer to display to attach the theme
* @return a pointer to reference this theme later
*/
lv_theme_t * lv_theme_simple_init(lv_display_t * disp);
/**
* Check if the theme is initialized
* @return true if default theme is initialized, false otherwise
*/
bool lv_theme_simple_is_inited(void);
/**
* Get simple theme
* @return a pointer to simple theme, or NULL if this is not initialized
*/
lv_theme_t * lv_theme_simple_get(void);
/**
* Deinitialize the simple theme
*/
void lv_theme_simple_deinit(void);
/**********************
* MACROS
**********************/
#endif
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_THEME_SIMPLE_H*/