start to update themes

This commit is contained in:
Gabor Kiss-Vamosi
2020-12-18 15:41:22 +01:00
parent be060a0dc7
commit 01a6bacbd7
19 changed files with 254 additions and 375 deletions

View File

@@ -57,8 +57,6 @@ void _lv_scroll_handler(lv_indev_proc_t * proc)
scroll_obj = find_scroll_obj(proc); scroll_obj = find_scroll_obj(proc);
if(scroll_obj == NULL) return; if(scroll_obj == NULL) return;
lv_obj_add_state(scroll_obj, LV_STATE_SCROLLED);
init_scroll_limits(proc); init_scroll_limits(proc);
lv_indev_t * indev_act = lv_indev_get_act(); lv_indev_t * indev_act = lv_indev_get_act();
@@ -204,8 +202,6 @@ void _lv_scroll_throw_handler(lv_indev_proc_t * proc)
lv_event_send(scroll_obj, LV_EVENT_SCROLL_END, indev_act); lv_event_send(scroll_obj, LV_EVENT_SCROLL_END, indev_act);
if(proc->reset_query) return; if(proc->reset_query) return;
lv_obj_clear_state(proc->types.pointer.scroll_obj, LV_STATE_SCROLLED);
proc->types.pointer.scroll_dir = LV_SCROLL_DIR_NONE; proc->types.pointer.scroll_dir = LV_SCROLL_DIR_NONE;
proc->types.pointer.scroll_obj = NULL; proc->types.pointer.scroll_obj = NULL;
} }

View File

@@ -11,8 +11,8 @@
#include "lv_refr.h" #include "lv_refr.h"
#include "lv_group.h" #include "lv_group.h"
#include "lv_disp.h" #include "lv_disp.h"
#include "../lv_misc/lv_debug.h"
#include "../lv_themes/lv_theme.h" #include "../lv_themes/lv_theme.h"
#include "../lv_misc/lv_debug.h"
#include "../lv_draw/lv_draw.h" #include "../lv_draw/lv_draw.h"
#include "../lv_misc/lv_anim.h" #include "../lv_misc/lv_anim.h"
#include "../lv_misc/lv_timer.h" #include "../lv_misc/lv_timer.h"
@@ -198,13 +198,9 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
{ {
lv_obj_t * obj = lv_class_new(&lv_obj); lv_obj_t * obj = lv_class_new(&lv_obj);
lv_obj.constructor(obj, parent, copy); lv_obj.constructor(obj, parent, copy);
if(copy == NULL) { if(copy == NULL) lv_theme_apply(obj);
if(parent != NULL) lv_theme_apply(obj, LV_THEME_OBJ); // else lv_style_list_copy(&obj->style_list, &copy->style_list);
else lv_theme_apply(obj, LV_THEME_SCR);
}
else {
// lv_style_list_copy(&obj->style_list, &copy->style_list);
}
return obj; return obj;
} }
@@ -1257,6 +1253,16 @@ lv_res_t _lv_obj_handle_get_type_signal(lv_obj_type_t * buf, const char * name)
} }
/**
* Get object's and its ancestors type. Put their name in `type_buf` starting with the current type.
* E.g. buf.type[0]="lv_btn", buf.type[1]="lv_cont", buf.type[2]="lv_obj"
* @param obj pointer to an object which type should be get
* @param buf pointer to an `lv_obj_type_t` buffer to store the types
*/
void * lv_obj_check_type(const lv_obj_t * obj, void * class_p)
{
return obj->class_p == class_p ? true : false;
}
/** /**
* Check if any object has a given type * Check if any object has a given type
* @param obj pointer to an object * @param obj pointer to an object
@@ -1732,6 +1738,12 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
lv_obj_clear_state(obj, LV_STATE_EDITED); lv_obj_clear_state(obj, LV_STATE_EDITED);
} }
} }
else if(sign == LV_SIGNAL_SCROLL_BEGIN) {
lv_obj_add_state(obj, LV_STATE_SCROLLED);
}
else if(sign == LV_SIGNAL_SCROLL_END) {
lv_obj_clear_state(obj, LV_STATE_SCROLLED);
}
else if(sign == LV_SIGNAL_DEFOCUS) { else if(sign == LV_SIGNAL_DEFOCUS) {
/*if using focus mode, change target to parent*/ /*if using focus mode, change target to parent*/
obj = _lv_obj_get_focused_obj(obj); obj = _lv_obj_get_focused_obj(obj);

View File

@@ -681,13 +681,7 @@ bool lv_obj_hit_test(lv_obj_t * obj, lv_point_t * point);
*/ */
void * lv_obj_get_ext_attr(const lv_obj_t * obj); void * lv_obj_get_ext_attr(const lv_obj_t * obj);
/** void * lv_obj_check_type(const lv_obj_t * obj, void * class_p);
* Get object's and its ancestors type. Put their name in `type_buf` starting with the current type.
* E.g. buf.type[0]="lv_btn", buf.type[1]="lv_cont", buf.type[2]="lv_obj"
* @param obj pointer to an object which type should be get
* @param buf pointer to an `lv_obj_type_t` buffer to store the types
*/
void lv_obj_get_type(const lv_obj_t * obj, lv_obj_type_t * buf);
#if LV_USE_USER_DATA #if LV_USE_USER_DATA
/** /**

View File

@@ -54,8 +54,9 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t
draw_dsc->radius = lv_obj_get_style_radius(obj, part); draw_dsc->radius = lv_obj_get_style_radius(obj, part);
#if LV_USE_OPA_SCALE #if LV_USE_OPA_SCALE
lv_opa_t main_opa = part != LV_PART_MAIN ? lv_obj_get_style_opa(obj, part) : LV_OPA_COVER;
lv_opa_t opa = lv_obj_get_style_opa(obj, part); lv_opa_t opa = lv_obj_get_style_opa(obj, part);
if(opa <= LV_OPA_MIN) { if(opa <= LV_OPA_MIN || main_opa <= LV_OPA_MIN) {
draw_dsc->bg_opa = LV_OPA_TRANSP; draw_dsc->bg_opa = LV_OPA_TRANSP;
draw_dsc->border_opa = LV_OPA_TRANSP; draw_dsc->border_opa = LV_OPA_TRANSP;
draw_dsc->shadow_opa = LV_OPA_TRANSP; draw_dsc->shadow_opa = LV_OPA_TRANSP;
@@ -169,6 +170,10 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t
#endif #endif
#if LV_USE_OPA_SCALE #if LV_USE_OPA_SCALE
if(main_opa < LV_OPA_MAX) {
opa = (uint16_t)((uint16_t) main_opa * opa) >> 8;
}
if(opa < LV_OPA_MAX) { if(opa < LV_OPA_MAX) {
draw_dsc->bg_opa = (uint16_t)((uint16_t)draw_dsc->bg_opa * opa) >> 8; draw_dsc->bg_opa = (uint16_t)((uint16_t)draw_dsc->bg_opa * opa) >> 8;
draw_dsc->border_opa = (uint16_t)((uint16_t)draw_dsc->border_opa * opa) >> 8; draw_dsc->border_opa = (uint16_t)((uint16_t)draw_dsc->border_opa * opa) >> 8;

View File

@@ -13,8 +13,8 @@
* DEFINES * DEFINES
*********************/ *********************/
#define LV_OBJX_NAME "lv_obj" #define LV_OBJX_NAME "lv_obj"
#define SCROLL_ANIM_TIME_MIN 100 /*ms*/ #define SCROLL_ANIM_TIME_MIN 200 /*ms*/
#define SCROLL_ANIM_TIME_MAX 300 /*ms*/ #define SCROLL_ANIM_TIME_MAX 400 /*ms*/
/********************** /**********************
* TYPEDEFS * TYPEDEFS
@@ -265,7 +265,7 @@ void lv_obj_scroll_by(lv_obj_t * obj, lv_coord_t x, lv_coord_t y, lv_anim_enable
lv_anim_path_set_cb(&path, lv_anim_path_ease_out); lv_anim_path_set_cb(&path, lv_anim_path_ease_out);
if(x) { if(x) {
uint32_t t = lv_anim_speed_to_time((lv_disp_get_hor_res(d) * 3) >> 2, 0, x); uint32_t t = lv_anim_speed_to_time((lv_disp_get_hor_res(d) * 2) >> 2, 0, x);
if(t < SCROLL_ANIM_TIME_MIN) t = SCROLL_ANIM_TIME_MIN; if(t < SCROLL_ANIM_TIME_MIN) t = SCROLL_ANIM_TIME_MIN;
if(t > SCROLL_ANIM_TIME_MAX) t = SCROLL_ANIM_TIME_MAX; if(t > SCROLL_ANIM_TIME_MAX) t = SCROLL_ANIM_TIME_MAX;
lv_anim_set_time(&a, t); lv_anim_set_time(&a, t);
@@ -277,7 +277,7 @@ void lv_obj_scroll_by(lv_obj_t * obj, lv_coord_t x, lv_coord_t y, lv_anim_enable
} }
if(y) { if(y) {
uint32_t t = lv_anim_speed_to_time((lv_disp_get_ver_res(d) * 3) >> 2, 0, y); uint32_t t = lv_anim_speed_to_time((lv_disp_get_ver_res(d) * 2) >> 2, 0, y);
if(t < SCROLL_ANIM_TIME_MIN) t = SCROLL_ANIM_TIME_MIN; if(t < SCROLL_ANIM_TIME_MIN) t = SCROLL_ANIM_TIME_MIN;
if(t > SCROLL_ANIM_TIME_MAX) t = SCROLL_ANIM_TIME_MAX; if(t > SCROLL_ANIM_TIME_MAX) t = SCROLL_ANIM_TIME_MAX;
lv_anim_set_time(&a, t); lv_anim_set_time(&a, t);

View File

@@ -134,6 +134,7 @@ void lv_obj_add_style(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_
obj->style_list.styles[j] = obj->style_list.styles[j - 1]; obj->style_list.styles[j] = obj->style_list.styles[j - 1];
} }
_lv_memset_00(&obj->style_list.styles[i], sizeof(lv_obj_style_t));
obj->style_list.styles[i].style = style; obj->style_list.styles[i].style = style;
obj->style_list.styles[i].part = part; obj->style_list.styles[i].part = part;
obj->style_list.styles[i].state = state; obj->style_list.styles[i].state = state;
@@ -172,7 +173,7 @@ void lv_obj_remove_style(lv_obj_t * obj, uint32_t part, uint32_t state, lv_style
obj->style_list.style_cnt--; obj->style_list.style_cnt--;
obj->style_list.styles = lv_mem_realloc(obj->style_list.styles, obj->style_list.style_cnt * sizeof(lv_style_t)); obj->style_list.styles = lv_mem_realloc(obj->style_list.styles, obj->style_list.style_cnt * sizeof(lv_obj_style_t));
#if LV_USE_ANIMATION #if LV_USE_ANIMATION
@@ -551,6 +552,7 @@ void _lv_obj_create_style_transition(lv_obj_t * obj, lv_style_prop_t prop, uint8
*/ */
_lv_style_state_cmp_t _lv_obj_style_state_compare(lv_obj_t * obj, lv_state_t state1, lv_state_t state2) _lv_style_state_cmp_t _lv_obj_style_state_compare(lv_obj_t * obj, lv_state_t state1, lv_state_t state2)
{ {
return _LV_STYLE_STATE_CMP_DIFF_LAYOUT;
lv_obj_style_list_t * list = &obj->style_list; lv_obj_style_list_t * list = &obj->style_list;
_lv_style_state_cmp_t res = _LV_STYLE_STATE_CMP_SAME; _lv_style_state_cmp_t res = _LV_STYLE_STATE_CMP_SAME;

View File

@@ -100,6 +100,7 @@ void _alloc_ext(lv_style_t * style)
if(style->ext) return; if(style->ext) return;
style->ext = lv_mem_alloc(sizeof(lv_style_ext_t)); style->ext = lv_mem_alloc(sizeof(lv_style_ext_t));
LV_ASSERT_MEM(style->ext); LV_ASSERT_MEM(style->ext);
_lv_memset_00(style->ext, sizeof(lv_style_ext_t));
} }
void lv_style_set_prop(lv_style_t * style, lv_style_prop_t prop, lv_style_value_t value) void lv_style_set_prop(lv_style_t * style, lv_style_prop_t prop, lv_style_value_t value)

View File

@@ -27,7 +27,7 @@ extern "C" {
* DEFINES * DEFINES
*********************/ *********************/
#define LV_RADIUS_CIRCLE (0x7FFF) /**< A very big radius to always draw as circle*/ #define LV_RADIUS_CIRCLE (0x7F) /**< A very big radius to always draw as circle*/
LV_EXPORT_CONST_INT(LV_RADIUS_CIRCLE); LV_EXPORT_CONST_INT(LV_RADIUS_CIRCLE);
#define LV_DEBUG_STYLE_SENTINEL_VALUE 0xAABBCCDD #define LV_DEBUG_STYLE_SENTINEL_VALUE 0xAABBCCDD
@@ -606,6 +606,26 @@ static inline void lv_style_set_transition_prop_6(lv_style_t * style, lv_style_p
static inline void lv_style_set_pad_ver(lv_style_t * style, lv_coord_t value)
{
lv_style_set_pad_top(style, value);
lv_style_set_pad_bottom(style, value);
}
static inline void lv_style_set_pad_hor(lv_style_t * style, lv_coord_t value)
{
lv_style_set_pad_left(style, value);
lv_style_set_pad_right(style, value);
}
static inline void lv_style_set_pad_all(lv_style_t * style, lv_coord_t value)
{
lv_style_set_pad_top(style, value);
lv_style_set_pad_bottom(style, value);
lv_style_set_pad_left(style, value);
lv_style_set_pad_right(style, value);
}
//static inline void lv_style_set_pad_ver(lv_style_t * style, lv_style_int_t value) //static inline void lv_style_set_pad_ver(lv_style_t * style, lv_style_int_t value)
//{ //{
// lv_style_set_pad_top(style, state, value); // lv_style_set_pad_top(style, state, value);

View File

@@ -1226,8 +1226,6 @@ static void draw_content(const lv_area_t * coords, const lv_area_t * clip, const
lv_area_t coords_tmp; lv_area_t coords_tmp;
int32_t obj_w = lv_area_get_width(coords);
int32_t obj_h = lv_area_get_height(coords);
coords_tmp.x1 = 0; coords_tmp.x1 = 0;
coords_tmp.y1 = 0; coords_tmp.y1 = 0;
coords_tmp.x2 = img_w - 1; coords_tmp.x2 = img_w - 1;

View File

@@ -259,7 +259,7 @@ lv_anim_value_t lv_anim_path_ease_in(const lv_anim_path_t * path, const lv_anim_
else else
t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time; t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time;
int32_t step = _lv_bezier3(t, 0, 0, 1024 * 1 / 3, 1024); int32_t step = _lv_bezier3(t, 0, 0, 580, 1024);
int32_t new_value; int32_t new_value;
new_value = (int32_t)step * (a->end - a->start); new_value = (int32_t)step * (a->end - a->start);
@@ -286,7 +286,7 @@ lv_anim_value_t lv_anim_path_ease_out(const lv_anim_path_t * path, const lv_anim
else else
t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time; t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time;
int32_t step = _lv_bezier3(t, 0, 1024 * 2 / 3, 1024, 1024); int32_t step = _lv_bezier3(t, 0, 420, 1000, 1024);
int32_t new_value; int32_t new_value;
new_value = (int32_t)step * (a->end - a->start); new_value = (int32_t)step * (a->end - a->start);

View File

@@ -25,7 +25,7 @@
*********************/ *********************/
/*Add memory junk on alloc (0xaa) and free(0xbb) (just for testing purposes)*/ /*Add memory junk on alloc (0xaa) and free(0xbb) (just for testing purposes)*/
#ifndef LV_MEM_ADD_JUNK #ifndef LV_MEM_ADD_JUNK
#define LV_MEM_ADD_JUNK 0 #define LV_MEM_ADD_JUNK 1
#endif #endif
#ifndef LV_MEM_FULL_DEFRAG_CNT #ifndef LV_MEM_FULL_DEFRAG_CNT

View File

@@ -19,7 +19,7 @@
/********************** /**********************
* STATIC PROTOTYPES * STATIC PROTOTYPES
**********************/ **********************/
static void apply_theme(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name); static void apply_theme(lv_theme_t * th, lv_obj_t * obj);
/********************** /**********************
* STATIC VARIABLES * STATIC VARIABLES
@@ -58,14 +58,12 @@ lv_theme_t * lv_theme_get_act(void)
* @param obj pointer to an object * @param obj pointer to an object
* @param name the name of the theme element to apply. E.g. `LV_THEME_BTN` * @param name the name of the theme element to apply. E.g. `LV_THEME_BTN`
*/ */
void lv_theme_apply(lv_obj_t * obj, lv_theme_style_t name) void lv_theme_apply(lv_obj_t * obj)
{ {
/* Remove the existing styles from all part of the object. */
lv_obj_remove_all_styles(obj); lv_obj_remove_all_styles(obj);
/*Apply the theme including the base theme(s)*/ /*Apply the theme including the base theme(s)*/
apply_theme(act_theme, obj);
apply_theme(act_theme, obj, name);
} }
/** /**
@@ -88,7 +86,6 @@ void lv_theme_copy(lv_theme_t * theme, const lv_theme_t * copy)
theme->flags = copy->flags; theme->flags = copy->flags;
theme->base = copy->base; theme->base = copy->base;
theme->apply_cb = copy->apply_cb; theme->apply_cb = copy->apply_cb;
theme->apply_xcb = copy->apply_xcb;
} }
} }
@@ -183,17 +180,9 @@ uint32_t lv_theme_get_flags(void)
* STATIC FUNCTIONS * STATIC FUNCTIONS
**********************/ **********************/
static void apply_theme(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) static void apply_theme(lv_theme_t * th, lv_obj_t * obj)
{ {
if(th->base) { if(th->base) apply_theme(th->base, obj);
apply_theme(th->base, obj, name);
}
/*apply_xcb is deprecated, use apply_cb instead*/ if(th->apply_cb) th->apply_cb(act_theme, obj);
if(th->apply_xcb) {
th->apply_xcb(obj, name);
}
else if(th->apply_cb) {
th->apply_cb(act_theme, obj, name);
}
} }

View File

@@ -25,91 +25,12 @@ extern "C" {
* TYPEDEFS * TYPEDEFS
**********************/ **********************/
/**
* A theme in LVGL consists of many styles bound together.
*
* There is a style for each object type, as well as a generic style for
* backgrounds and panels.
*/
typedef enum {
LV_THEME_NONE = 0,
LV_THEME_SCR,
LV_THEME_OBJ,
#if LV_USE_ARC
LV_THEME_ARC,
#endif
#if LV_USE_BAR
LV_THEME_BAR,
#endif
#if LV_USE_BTN
LV_THEME_BTN,
#endif
#if LV_USE_BTNMATRIX
LV_THEME_BTNMATRIX,
#endif
#if LV_USE_CANVAS
LV_THEME_CANVAS,
#endif
#if LV_USE_CHECKBOX
LV_THEME_CHECKBOX,
#endif
#if LV_USE_CHART
LV_THEME_CHART,
#endif
#if LV_USE_DROPDOWN
LV_THEME_DROPDOWN,
#endif
#if LV_USE_GAUGE
LV_THEME_GAUGE,
#endif
#if LV_USE_IMG
LV_THEME_IMAGE,
#endif
#if LV_USE_IMGBTN
LV_THEME_IMGBTN,
#endif
#if LV_USE_LABEL
LV_THEME_LABEL,
#endif
#if LV_USE_LINE
LV_THEME_LINE,
#endif
#if LV_USE_LINEMETER
LV_THEME_LINEMETER,
#endif
#if LV_USE_OBJMASK
LV_THEME_OBJMASK,
#endif
#if LV_USE_ROLLER
LV_THEME_ROLLER,
#endif
#if LV_USE_SLIDER
LV_THEME_SLIDER,
#endif
#if LV_USE_SWITCH
LV_THEME_SWITCH,
#endif
#if LV_USE_TABLE
LV_THEME_TABLE,
#endif
#if LV_USE_TEXTAREA
LV_THEME_TEXTAREA,
#endif
_LV_THEME_BUILTIN_LAST,
LV_THEME_CUSTOM_START = _LV_THEME_BUILTIN_LAST,
_LV_THEME_CUSTOM_LAST = 0xFFFF,
} lv_theme_style_t;
struct _lv_theme_t; struct _lv_theme_t;
typedef void (*lv_theme_apply_cb_t)(struct _lv_theme_t *, lv_obj_t *, lv_theme_style_t); typedef void (*lv_theme_apply_cb_t)(struct _lv_theme_t *, lv_obj_t *);
typedef void (*lv_theme_apply_xcb_t)(lv_obj_t *, lv_theme_style_t); /*Deprecated: use `apply_cb` instead*/
typedef struct _lv_theme_t { typedef struct _lv_theme_t {
lv_theme_apply_cb_t apply_cb; lv_theme_apply_cb_t apply_cb;
lv_theme_apply_xcb_t apply_xcb; /*Deprecated: use `apply_cb` instead*/
struct _lv_theme_t * base; /**< Apply the current theme's style on top of this theme.*/ struct _lv_theme_t * base; /**< Apply the current theme's style on top of this theme.*/
lv_color_t color_primary; lv_color_t color_primary;
lv_color_t color_secondary; lv_color_t color_secondary;
@@ -141,9 +62,8 @@ lv_theme_t * lv_theme_get_act(void);
/** /**
* Apply the active theme on an object * Apply the active theme on an object
* @param obj pointer to an object * @param obj pointer to an object
* @param name the name of the theme element to apply. E.g. `LV_THEME_BTN`
*/ */
void lv_theme_apply(lv_obj_t * obj, lv_theme_style_t name); void lv_theme_apply(lv_obj_t * obj);
/** /**
* Copy a theme to an other or initialize a theme * Copy a theme to an other or initialize a theme
@@ -220,7 +140,7 @@ uint32_t lv_theme_get_flags(void);
* POST INCLUDE * POST INCLUDE
*********************/ *********************/
#include "lv_theme_empty.h" #include "lv_theme_empty.h"
#include "lv_theme_material.h" #include "lv_theme_default.h"
#include "lv_theme_mono.h" #include "lv_theme_mono.h"
#ifdef __cplusplus #ifdef __cplusplus

View File

@@ -8,7 +8,7 @@
*********************/ *********************/
#include "../../lvgl.h" /*To see all the widgets*/ #include "../../lvgl.h" /*To see all the widgets*/
#if LV_USE_THEME_MATERIAL #if LV_USE_THEME_DEFAULT
#include "../lv_misc/lv_gc.h" #include "../lv_misc/lv_gc.h"
@@ -20,40 +20,42 @@
* DEFINES * DEFINES
*********************/ *********************/
/*SCREEN*/ #define RADIUS_DEFAULT LV_DPX(8)
/*SCREEN*/
#define COLOR_SCR (IS_LIGHT ? lv_color_hex(0xeaeff3) : lv_color_hex(0x444b5a)) #define COLOR_SCR (IS_LIGHT ? lv_color_hex(0xeaeff3) : lv_color_hex(0x444b5a))
#define COLOR_SCR_TEXT (IS_LIGHT ? lv_color_hex(0x3b3e42) : lv_color_hex(0xe7e9ec)) #define COLOR_SCR_TEXT (IS_LIGHT ? lv_color_hex(0x3b3e42) : lv_color_hex(0xe7e9ec))
/*BUTTON*/ /*BUTTON*/
#define COLOR_BTN (IS_LIGHT ? lv_color_hex(0xffffff) : lv_color_hex(0x586273)) #define BTN_COLOR (theme.color_primary)
#define COLOR_BTN_PR (IS_LIGHT ? lv_color_mix(theme.color_primary, COLOR_BTN, LV_OPA_20) : lv_color_mix(theme.color_primary, COLOR_BTN, LV_OPA_30)) #define BTN_PR_COLOR (lv_color_darken(theme.color_primary, LV_OPA_20))
#define BTN_CHK_DIS_COLOR (lv_color_lighten(theme.color_primary, LV_OPA_40))
#define COLOR_BTN_CHK (theme.color_primary) #define BTN_CHK_COLOR (theme.color_secondary)
#define COLOR_BTN_CHK_PR (lv_color_darken(theme.color_primary, LV_OPA_30)) #define BTN_CHK_PR_COLOR (lv_color_darken(theme.color_secondary, LV_OPA_20))
#define COLOR_BTN_DIS (IS_LIGHT ? lv_color_hex3(0xccc) : lv_color_hex3(0x888)) #define BTN_DIS_COLOR (lv_color_lighten(theme.color_secondary, LV_OPA_40))
#define COLOR_BTN_BORDER theme.color_primary #define BTN_BORDER_COLOR theme.color_primary
#define COLOR_BTN_BORDER_PR theme.color_primary #define COLOR_BTN_BORDER_PR theme.color_primary
#define COLOR_BTN_BORDER_CHK theme.color_primary #define COLOR_BTN_BORDER_CHK theme.color_primary
#define COLOR_BTN_BORDER_CHK_PR theme.color_primary #define COLOR_BTN_BORDER_CHK_PR theme.color_primary
#define COLOR_BTN_BORDER_INA (IS_LIGHT ? lv_color_hex3(0x888) : lv_color_hex(0x404040)) #define COLOR_BTN_BORDER_INA (IS_LIGHT ? lv_color_hex3(0x888) : lv_color_hex(0x404040))
/*BACKGROUND*/ /*BACKGROUND*/
#define COLOR_BG (IS_LIGHT ? lv_color_hex(0xffffff) : lv_color_hex(0x586273)) #define CARD_COLOR (IS_LIGHT ? lv_color_hex(0xffffff) : lv_color_hex(0x586273))
#define COLOR_BG_PR (IS_LIGHT ? lv_color_hex(0xeeeeee) : lv_color_hex(0x494f57)) #define CARD_PR_COLOR (IS_LIGHT ? lv_color_hex(0xeeeeee) : lv_color_hex(0x494f57))
#define COLOR_BG_CHK theme.color_primary #define COLOR_BG_CHK theme.color_primary
#define COLOR_BG_PR_CHK lv_color_darken(theme.color_primary, LV_OPA_20) #define COLOR_BG_PR_CHK lv_color_darken(theme.color_primary, LV_OPA_20)
#define COLOR_BG_DIS COLOR_BG #define COLOR_BG_DIS CARD_COLOR
#define COLOR_BG_BORDER (IS_LIGHT ? lv_color_hex(0xd6dde3) : lv_color_hex(0x808a97)) /*dfe7ed*/ #define CARD_BORDER_COLOR (IS_LIGHT ? lv_color_hex(0xd6dde3) : lv_color_hex(0x808a97)) /*dfe7ed*/
#define COLOR_BG_BORDER_PR (IS_LIGHT ? lv_color_hex3(0xccc) : lv_color_hex(0x5f656e)) #define COLOR_BG_BORDER_PR (IS_LIGHT ? lv_color_hex3(0xccc) : lv_color_hex(0x5f656e))
#define COLOR_BG_BORDER_CHK (IS_LIGHT ? lv_color_hex(0xd6dde3) : lv_color_hex(0x5f656e)) #define COLOR_BG_BORDER_CHK (IS_LIGHT ? lv_color_hex(0xd6dde3) : lv_color_hex(0x5f656e))
#define COLOR_BG_BORDER_CHK_PR (IS_LIGHT ? lv_color_hex3(0xccc) : lv_color_hex(0x5f656e)) #define COLOR_BG_BORDER_CHK_PR (IS_LIGHT ? lv_color_hex3(0xccc) : lv_color_hex(0x5f656e))
#define COLOR_BG_BORDER_DIS (IS_LIGHT ? lv_color_hex(0xd6dde3) : lv_color_hex(0x5f656e)) #define COLOR_BG_BORDER_DIS (IS_LIGHT ? lv_color_hex(0xd6dde3) : lv_color_hex(0x5f656e))
#define COLOR_BG_TEXT (IS_LIGHT ? lv_color_hex(0x3b3e42) : lv_color_hex(0xffffff)) #define CARD_TEXT_COLOR (IS_LIGHT ? lv_color_hex(0x3b3e42) : lv_color_hex(0xffffff))
#define COLOR_BG_TEXT_PR (IS_LIGHT ? lv_color_hex(0x3b3e42) : lv_color_hex(0xffffff)) #define CARD_TEXT_PR_COLOR (IS_LIGHT ? lv_color_hex(0x3b3e42) : lv_color_hex(0xffffff))
#define COLOR_BG_TEXT_CHK (IS_LIGHT ? lv_color_hex(0xffffff) : lv_color_hex(0xffffff)) #define COLOR_BG_TEXT_CHK (IS_LIGHT ? lv_color_hex(0xffffff) : lv_color_hex(0xffffff))
#define COLOR_BG_TEXT_CHK_PR (IS_LIGHT ? lv_color_hex(0xffffff) : lv_color_hex(0xffffff)) #define COLOR_BG_TEXT_CHK_PR (IS_LIGHT ? lv_color_hex(0xffffff) : lv_color_hex(0xffffff))
#define COLOR_BG_TEXT_DIS (IS_LIGHT ? lv_color_hex3(0xaaa) : lv_color_hex3(0x999)) #define COLOR_BG_TEXT_DIS (IS_LIGHT ? lv_color_hex3(0xaaa) : lv_color_hex3(0x999))
@@ -64,7 +66,7 @@
#define COLOR_BG_SEC_TEXT (IS_LIGHT ? lv_color_hex(0x31404f) : lv_color_hex(0xa5a8ad)) #define COLOR_BG_SEC_TEXT (IS_LIGHT ? lv_color_hex(0x31404f) : lv_color_hex(0xa5a8ad))
#define COLOR_BG_SEC_TEXT_DIS (IS_LIGHT ? lv_color_hex(0xaaaaaa) : lv_color_hex(0xa5a8ad)) #define COLOR_BG_SEC_TEXT_DIS (IS_LIGHT ? lv_color_hex(0xaaaaaa) : lv_color_hex(0xa5a8ad))
#define TRANSITION_TIME ((theme.flags & LV_THEME_MATERIAL_FLAG_NO_TRANSITION) ? 0 : 150) #define TRANSITION_TIME ((theme.flags & LV_THEME_MATERIAL_FLAG_NO_TRANSITION) ? 0 : 100)
#define BORDER_WIDTH LV_DPX(2) #define BORDER_WIDTH LV_DPX(2)
#define OUTLINE_WIDTH ((theme.flags & LV_THEME_MATERIAL_FLAG_NO_FOCUS) ? 0 : LV_DPX(2)) #define OUTLINE_WIDTH ((theme.flags & LV_THEME_MATERIAL_FLAG_NO_FOCUS) ? 0 : LV_DPX(2))
#define IS_LIGHT (theme.flags & LV_THEME_MATERIAL_FLAG_LIGHT) #define IS_LIGHT (theme.flags & LV_THEME_MATERIAL_FLAG_LIGHT)
@@ -76,12 +78,33 @@
**********************/ **********************/
typedef struct { typedef struct {
lv_style_t scr; lv_style_t scr;
lv_style_t sb; lv_style_t scrollbar;
lv_style_t bg; lv_style_t scrollbar_scrolled;
lv_style_t bg_click; lv_style_t card;
lv_style_t bg_sec;
lv_style_t btn; lv_style_t btn;
lv_style_t btn_pressed;
lv_style_t btn_disabled;
lv_style_t btn_color;
lv_style_t btn_color_disabled;
lv_style_t btn_color_pressed;
lv_style_t btn_color_checked;
lv_style_t btn_color_pressed_checked;
lv_style_t btn_color_checked_disabled;
/*Utility*/
lv_style_t pad_small; lv_style_t pad_small;
lv_style_t focus_border;
lv_style_t focus_outline;
lv_style_t edit_outline;
lv_style_t edit_border;
lv_style_t circle;
lv_style_t no_radius;
lv_style_t clip_corner;
lv_style_t bg_color_primary;
/*Parts*/
lv_style_t knob;
#if LV_USE_ARC #if LV_USE_ARC
lv_style_t arc_indic; lv_style_t arc_indic;
@@ -143,7 +166,7 @@ typedef struct {
/********************** /**********************
* STATIC PROTOTYPES * STATIC PROTOTYPES
**********************/ **********************/
static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name); static void theme_apply(lv_theme_t * th, lv_obj_t * obj);
static void style_init_reset(lv_style_t * style); static void style_init_reset(lv_style_t * style);
/********************** /**********************
@@ -164,133 +187,100 @@ static bool inited;
static void basic_init(void) static void basic_init(void)
{ {
style_init_reset(&styles->sb); style_init_reset(&styles->scrollbar);
lv_style_set_scrollbar_bg_opa(&styles->sb, LV_STATE_DEFAULT, LV_OPA_COVER); lv_style_set_bg_opa(&styles->scrollbar, LV_OPA_COVER);
lv_style_set_scrollbar_bg_color(&styles->sb, LV_STATE_DEFAULT, (IS_LIGHT ? lv_color_hex(0xcccfd1) : lv_color_hex(0x777f85))); lv_style_set_bg_color(&styles->scrollbar, (IS_LIGHT ? lv_color_hex(0xcccfd1) : lv_color_hex(0x777f85)));
lv_style_set_scrollbar_radius(&styles->sb, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE); lv_style_set_radius(&styles->scrollbar, LV_RADIUS_CIRCLE);
lv_style_set_scrollbar_tickness(&styles->sb, LV_STATE_DEFAULT, LV_DPX(7)); lv_style_set_pad_left(&styles->scrollbar, LV_DPX(7));
lv_style_set_scrollbar_space_side(&styles->sb, LV_STATE_DEFAULT, LV_DPX(7)); lv_style_set_margin_right(&styles->scrollbar, LV_DPX(7));
lv_style_set_scrollbar_space_end(&styles->sb, LV_STATE_DEFAULT, LV_DPX(7)); lv_style_set_margin_top(&styles->scrollbar, LV_DPX(7));
lv_style_set_bg_opa(&styles->scrollbar, LV_OPA_50);
lv_style_set_transition_prop_6(&styles->scrollbar, LV_STYLE_BG_OPA);
lv_style_set_transition_time(&styles->scrollbar, TRANSITION_TIME * 2);
style_init_reset(&styles->scrollbar_scrolled);
lv_style_set_bg_opa(&styles->scrollbar_scrolled, LV_OPA_COVER);
lv_style_set_transition_time(&styles->scrollbar_scrolled, TRANSITION_TIME);
style_init_reset(&styles->scr); style_init_reset(&styles->scr);
lv_style_set_bg_opa(&styles->scr, LV_STATE_DEFAULT, LV_OPA_COVER); lv_style_set_bg_opa(&styles->scr, LV_OPA_COVER);
lv_style_set_bg_color(&styles->scr, LV_STATE_DEFAULT, COLOR_SCR); lv_style_set_bg_color(&styles->scr, COLOR_SCR);
lv_style_set_text_color(&styles->scr, LV_STATE_DEFAULT, COLOR_SCR_TEXT); lv_style_set_text_color(&styles->scr, COLOR_SCR_TEXT);
lv_style_set_value_color(&styles->scr, LV_STATE_DEFAULT, COLOR_SCR_TEXT);
lv_style_set_text_sel_color(&styles->scr, LV_STATE_DEFAULT, COLOR_SCR_TEXT);
lv_style_set_text_sel_bg_color(&styles->scr, LV_STATE_DEFAULT, theme.color_primary);
lv_style_set_value_font(&styles->scr, LV_STATE_DEFAULT, theme.font_normal);
style_init_reset(&styles->bg); style_init_reset(&styles->card);
lv_style_set_radius(&styles->bg, LV_STATE_DEFAULT, LV_DPX(8)); lv_style_set_radius(&styles->card, RADIUS_DEFAULT);
lv_style_set_bg_opa(&styles->bg, LV_STATE_DEFAULT, LV_OPA_COVER); lv_style_set_bg_opa(&styles->card, LV_OPA_COVER);
lv_style_set_bg_color(&styles->bg, LV_STATE_DEFAULT, COLOR_BG); lv_style_set_bg_color(&styles->card, CARD_COLOR);
lv_style_set_border_color(&styles->bg, LV_STATE_DEFAULT, COLOR_BG_BORDER); lv_style_set_border_color(&styles->card, CARD_BORDER_COLOR);
if((theme.flags & LV_THEME_MATERIAL_FLAG_NO_FOCUS) == 0)lv_style_set_border_color(&styles->bg, LV_STATE_FOCUSED, lv_style_set_border_width(&styles->card, BORDER_WIDTH);
theme.color_primary); lv_style_set_border_post(&styles->card, true);
lv_style_set_border_color(&styles->bg, LV_STATE_EDITED, theme.color_secondary); lv_style_set_text_color(&styles->card, CARD_TEXT_COLOR);
lv_style_set_border_width(&styles->bg, LV_STATE_DEFAULT, BORDER_WIDTH); lv_style_set_img_recolor(&styles->card, CARD_TEXT_COLOR);
lv_style_set_border_post(&styles->bg, LV_STATE_DEFAULT, true);
lv_style_set_text_color(&styles->bg, LV_STATE_DEFAULT, COLOR_BG_TEXT);
lv_style_set_value_font(&styles->bg, LV_STATE_DEFAULT, theme.font_normal);
lv_style_set_value_color(&styles->bg, LV_STATE_DEFAULT, COLOR_BG_TEXT);
lv_style_set_image_recolor(&styles->bg, LV_STATE_DEFAULT, COLOR_BG_TEXT);
lv_style_set_line_color(&styles->bg, LV_STATE_DEFAULT, COLOR_BG_TEXT);
lv_style_set_line_width(&styles->bg, LV_STATE_DEFAULT, 1);
lv_style_set_pad_left(&styles->bg, LV_STATE_DEFAULT, PAD_DEF + BORDER_WIDTH); lv_style_set_pad_all(&styles->card, PAD_DEF);
lv_style_set_pad_right(&styles->bg, LV_STATE_DEFAULT, PAD_DEF + BORDER_WIDTH); lv_style_set_transition_time(&styles->card, TRANSITION_TIME);
lv_style_set_pad_top(&styles->bg, LV_STATE_DEFAULT, PAD_DEF + BORDER_WIDTH); lv_style_set_transition_prop_6(&styles->card, LV_STYLE_BORDER_COLOR);
lv_style_set_pad_bottom(&styles->bg, LV_STATE_DEFAULT, PAD_DEF + BORDER_WIDTH);
lv_style_set_transition_time(&styles->bg, LV_STATE_DEFAULT, TRANSITION_TIME);
lv_style_set_transition_prop_6(&styles->bg, LV_STATE_DEFAULT, LV_STYLE_BORDER_COLOR);
style_init_reset(&styles->bg_sec); style_init_reset(&styles->focus_border);
lv_style_copy(&styles->bg_sec, &styles->bg); lv_style_set_border_color(&styles->focus_border, theme.color_primary);
lv_style_set_bg_color(&styles->bg_sec, LV_STATE_DEFAULT, COLOR_BG_SEC);
lv_style_set_border_color(&styles->bg_sec, LV_STATE_DEFAULT, COLOR_BG_SEC_BORDER);
lv_style_set_text_color(&styles->bg_sec, LV_STATE_DEFAULT, COLOR_BG_SEC_TEXT);
lv_style_set_value_color(&styles->bg_sec, LV_STATE_DEFAULT, COLOR_BG_SEC_TEXT);
lv_style_set_image_recolor(&styles->bg_sec, LV_STATE_DEFAULT, COLOR_BG_SEC_TEXT);
lv_style_set_line_color(&styles->bg_sec, LV_STATE_DEFAULT, COLOR_BG_SEC_TEXT);
style_init_reset(&styles->bg_click); style_init_reset(&styles->edit_border);
lv_style_set_bg_color(&styles->bg_click, LV_STATE_PRESSED, COLOR_BG_PR); lv_style_set_border_color(&styles->edit_border, theme.color_secondary);
lv_style_set_bg_color(&styles->bg_click, LV_STATE_CHECKED, COLOR_BG_CHK);
lv_style_set_bg_color(&styles->bg_click, LV_STATE_PRESSED | LV_STATE_CHECKED, COLOR_BG_PR_CHK); style_init_reset(&styles->focus_outline);
lv_style_set_bg_color(&styles->bg_click, LV_STATE_DISABLED, COLOR_BG_DIS); lv_style_set_outline_color(&styles->focus_outline, theme.color_primary);
lv_style_set_border_width(&styles->bg_click, LV_STATE_CHECKED, 0); lv_style_set_outline_width(&styles->focus_outline, OUTLINE_WIDTH);
lv_style_set_border_color(&styles->bg_click, LV_STATE_FOCUSED | LV_STATE_PRESSED, lv_color_darken(theme.color_primary, lv_style_set_outline_opa(&styles->focus_outline, LV_OPA_50);
LV_OPA_20));
lv_style_set_border_color(&styles->bg_click, LV_STATE_PRESSED, COLOR_BG_BORDER_PR); style_init_reset(&styles->edit_outline);
lv_style_set_border_color(&styles->bg_click, LV_STATE_CHECKED, COLOR_BG_BORDER_CHK); lv_style_set_outline_color(&styles->edit_outline, theme.color_secondary);
lv_style_set_border_color(&styles->bg_click, LV_STATE_PRESSED | LV_STATE_CHECKED, COLOR_BG_BORDER_CHK_PR); lv_style_set_outline_opa(&styles->edit_outline, LV_OPA_50);
lv_style_set_border_color(&styles->bg_click, LV_STATE_DISABLED, COLOR_BG_BORDER_DIS);
lv_style_set_text_color(&styles->bg_click, LV_STATE_PRESSED, COLOR_BG_TEXT_PR);
lv_style_set_text_color(&styles->bg_click, LV_STATE_CHECKED, COLOR_BG_TEXT_CHK);
lv_style_set_text_color(&styles->bg_click, LV_STATE_PRESSED | LV_STATE_CHECKED, COLOR_BG_TEXT_CHK_PR);
lv_style_set_text_color(&styles->bg_click, LV_STATE_DISABLED, COLOR_BG_TEXT_DIS);
lv_style_set_image_recolor(&styles->bg_click, LV_STATE_PRESSED, COLOR_BG_TEXT_PR);
lv_style_set_image_recolor(&styles->bg_click, LV_STATE_CHECKED, COLOR_BG_TEXT_CHK);
lv_style_set_image_recolor(&styles->bg_click, LV_STATE_PRESSED | LV_STATE_CHECKED, COLOR_BG_TEXT_CHK_PR);
lv_style_set_image_recolor(&styles->bg_click, LV_STATE_DISABLED, COLOR_BG_TEXT_DIS);
lv_style_set_transition_prop_5(&styles->bg_click, LV_STATE_DEFAULT, LV_STYLE_BG_COLOR);
style_init_reset(&styles->btn); style_init_reset(&styles->btn);
lv_style_set_radius(&styles->btn, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE); lv_style_set_radius(&styles->btn, RADIUS_DEFAULT);
lv_style_set_bg_opa(&styles->btn, LV_STATE_DEFAULT, LV_OPA_COVER); lv_style_set_bg_opa(&styles->btn, LV_OPA_COVER);
lv_style_set_bg_color(&styles->btn, LV_STATE_DEFAULT, COLOR_BTN); lv_style_set_bg_color(&styles->btn, CARD_COLOR);
lv_style_set_bg_color(&styles->btn, LV_STATE_PRESSED, COLOR_BTN_PR); lv_style_set_border_color(&styles->btn, CARD_BORDER_COLOR);
lv_style_set_bg_color(&styles->btn, LV_STATE_CHECKED, COLOR_BTN_CHK); lv_style_set_border_width(&styles->btn, BORDER_WIDTH);
lv_style_set_bg_color(&styles->btn, LV_STATE_CHECKED | LV_STATE_PRESSED, COLOR_BTN_CHK_PR); lv_style_set_text_color(&styles->btn, CARD_TEXT_COLOR);
lv_style_set_bg_color(&styles->btn, LV_STATE_DISABLED, COLOR_BTN); lv_style_set_img_recolor(&styles->btn, CARD_TEXT_COLOR);
lv_style_set_bg_color(&styles->btn, LV_STATE_DISABLED | LV_STATE_CHECKED, COLOR_BTN_DIS); lv_style_set_pad_hor(&styles->btn, LV_DPX(40));
lv_style_set_border_color(&styles->btn, LV_STATE_DEFAULT, COLOR_BTN_BORDER); lv_style_set_pad_ver(&styles->btn, LV_DPX(15));
lv_style_set_border_color(&styles->btn, LV_STATE_PRESSED, COLOR_BTN_BORDER_PR); lv_style_set_transition_prop_5(&styles->btn, LV_STYLE_BG_COLOR);
lv_style_set_border_color(&styles->btn, LV_STATE_DISABLED, COLOR_BTN_BORDER_INA); lv_style_set_transition_prop_6(&styles->btn, LV_STYLE_OUTLINE_OPA);
lv_style_set_border_width(&styles->btn, LV_STATE_DEFAULT, BORDER_WIDTH); lv_style_set_transition_time(&styles->btn, TRANSITION_TIME);
lv_style_set_border_opa(&styles->btn, LV_STATE_CHECKED, LV_OPA_TRANSP); lv_style_set_transition_delay(&styles->btn, TRANSITION_TIME);
lv_style_set_text_color(&styles->btn, LV_STATE_DEFAULT, IS_LIGHT ? lv_color_hex(0x31404f) : lv_color_hex(0xffffff)); style_init_reset(&styles->btn_pressed);
lv_style_set_text_color(&styles->btn, LV_STATE_PRESSED, IS_LIGHT ? lv_color_hex(0x31404f) : lv_color_hex(0xffffff)); lv_style_set_bg_color(&styles->btn_pressed, CARD_PR_COLOR);
lv_style_set_text_color(&styles->btn, LV_STATE_CHECKED, lv_color_hex(0xffffff)); lv_style_set_text_color(&styles->btn_pressed, CARD_TEXT_PR_COLOR);
lv_style_set_text_color(&styles->btn, LV_STATE_CHECKED | LV_STATE_PRESSED, lv_color_hex(0xffffff)); lv_style_set_img_recolor(&styles->btn_pressed, CARD_TEXT_PR_COLOR);
lv_style_set_text_color(&styles->btn, LV_STATE_DISABLED, IS_LIGHT ? lv_color_hex(0x888888) : lv_color_hex(0x888888)); lv_style_set_transition_delay(&styles->btn_pressed, 0);
lv_style_set_image_recolor(&styles->btn, LV_STATE_DEFAULT, IS_LIGHT ? lv_color_hex(0x31404f) : lv_color_hex(0xffffff)); style_init_reset(&styles->btn_color);
lv_style_set_image_recolor(&styles->btn, LV_STATE_PRESSED, IS_LIGHT ? lv_color_hex(0x31404f) : lv_color_hex(0xffffff)); lv_style_set_border_width(&styles->btn_color, 0);
lv_style_set_image_recolor(&styles->btn, LV_STATE_PRESSED, lv_color_hex(0xffffff)); lv_style_set_bg_color(&styles->btn_color, BTN_COLOR);
lv_style_set_image_recolor(&styles->btn, LV_STATE_CHECKED | LV_STATE_PRESSED, lv_color_hex(0xffffff)); lv_style_set_text_color(&styles->btn_color, LV_COLOR_WHITE);
lv_style_set_image_recolor(&styles->btn, LV_STATE_DISABLED, IS_LIGHT ? lv_color_hex(0x888888) : lv_color_hex(0x888888)); lv_style_set_img_recolor(&styles->btn_color, LV_COLOR_WHITE);
lv_style_set_value_color(&styles->btn, LV_STATE_DEFAULT, IS_LIGHT ? lv_color_hex(0x31404f) : lv_color_hex(0xffffff)); style_init_reset(&styles->btn_color_pressed);
lv_style_set_value_color(&styles->btn, LV_STATE_PRESSED, IS_LIGHT ? lv_color_hex(0x31404f) : lv_color_hex(0xffffff)); lv_style_set_bg_color(&styles->btn_color_pressed, BTN_PR_COLOR);
lv_style_set_value_color(&styles->btn, LV_STATE_CHECKED, lv_color_hex(0xffffff));
lv_style_set_value_color(&styles->btn, LV_STATE_CHECKED | LV_STATE_PRESSED, lv_color_hex(0xffffff));
lv_style_set_value_color(&styles->btn, LV_STATE_DISABLED, IS_LIGHT ? lv_color_hex(0x888888) : lv_color_hex(0x888888));
lv_style_set_pad_left(&styles->btn, LV_STATE_DEFAULT, LV_DPX(40)); style_init_reset(&styles->btn_color_checked);
lv_style_set_pad_right(&styles->btn, LV_STATE_DEFAULT, LV_DPX(40)); lv_style_set_bg_color(&styles->btn_color_checked, BTN_CHK_PR_COLOR);
lv_style_set_pad_top(&styles->btn, LV_STATE_DEFAULT, LV_DPX(15));
lv_style_set_pad_bottom(&styles->btn, LV_STATE_DEFAULT, LV_DPX(15)); style_init_reset(&styles->btn_color_disabled);
lv_style_set_outline_width(&styles->btn, LV_STATE_DEFAULT, OUTLINE_WIDTH); lv_style_set_bg_color(&styles->btn_color_checked, BTN_DIS_COLOR);
lv_style_set_outline_opa(&styles->btn, LV_STATE_DEFAULT, LV_OPA_0);
lv_style_set_outline_opa(&styles->btn, LV_STATE_FOCUSED, LV_OPA_50); style_init_reset(&styles->btn_color_checked_disabled);
lv_style_set_outline_color(&styles->btn, LV_STATE_DEFAULT, theme.color_primary); lv_style_set_bg_color(&styles->btn_color_checked_disabled, BTN_CHK_DIS_COLOR);
lv_style_set_outline_color(&styles->btn, LV_STATE_EDITED, theme.color_secondary);
lv_style_set_transition_time(&styles->btn, LV_STATE_DEFAULT, TRANSITION_TIME); style_init_reset(&styles->clip_corner);
lv_style_set_transition_prop_4(&styles->btn, LV_STATE_DEFAULT, LV_STYLE_BORDER_OPA); lv_style_set_clip_corner(&styles->clip_corner, BTN_CHK_DIS_COLOR);
lv_style_set_transition_prop_5(&styles->btn, LV_STATE_DEFAULT, LV_STYLE_BG_COLOR);
lv_style_set_transition_prop_6(&styles->btn, LV_STATE_DEFAULT, LV_STYLE_OUTLINE_OPA);
lv_style_set_transition_delay(&styles->btn, LV_STATE_DEFAULT, TRANSITION_TIME);
lv_style_set_transition_delay(&styles->btn, LV_STATE_PRESSED, 0);
style_init_reset(&styles->pad_small); style_init_reset(&styles->pad_small);
lv_style_int_t pad_small_value = lv_disp_get_size_category(NULL) <= LV_DISP_MEDIUM_LIMIT ? LV_DPX(10) : LV_DPX(20); lv_coord_t pad_small_value = lv_disp_get_size_category(NULL) <= LV_DISP_MEDIUM_LIMIT ? LV_DPX(10) : LV_DPX(20);
lv_style_set_pad_left(&styles->pad_small, LV_STATE_DEFAULT, pad_small_value); lv_style_set_pad_all(&styles->pad_small, pad_small_value);
lv_style_set_pad_right(&styles->pad_small, LV_STATE_DEFAULT, pad_small_value);
lv_style_set_pad_top(&styles->pad_small, LV_STATE_DEFAULT, pad_small_value);
lv_style_set_pad_bottom(&styles->pad_small, LV_STATE_DEFAULT, pad_small_value);
} }
@@ -484,7 +474,7 @@ static void chart_init(void)
lv_style_set_line_width(&styles->chart_series_bg, LV_STATE_DEFAULT, LV_DPX(1)); lv_style_set_line_width(&styles->chart_series_bg, LV_STATE_DEFAULT, LV_DPX(1));
lv_style_set_line_dash_width(&styles->chart_series_bg, LV_STATE_DEFAULT, LV_DPX(10)); lv_style_set_line_dash_width(&styles->chart_series_bg, LV_STATE_DEFAULT, LV_DPX(10));
lv_style_set_line_dash_gap(&styles->chart_series_bg, LV_STATE_DEFAULT, LV_DPX(10)); lv_style_set_line_dash_gap(&styles->chart_series_bg, LV_STATE_DEFAULT, LV_DPX(10));
lv_style_set_line_color(&styles->chart_series_bg, LV_STATE_DEFAULT, COLOR_BG_BORDER); lv_style_set_line_color(&styles->chart_series_bg, LV_STATE_DEFAULT, CARD_BORDER_COLOR);
style_init_reset(&styles->chart_series); style_init_reset(&styles->chart_series);
lv_style_set_line_width(&styles->chart_series, LV_STATE_DEFAULT, LV_DPX(3)); lv_style_set_line_width(&styles->chart_series, LV_STATE_DEFAULT, LV_DPX(3));
@@ -552,8 +542,8 @@ static void ddlist_init(void)
lv_style_set_bg_opa(&styles->ddlist_sel, LV_STATE_DEFAULT, LV_OPA_COVER); lv_style_set_bg_opa(&styles->ddlist_sel, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&styles->ddlist_sel, LV_STATE_DEFAULT, theme.color_primary); lv_style_set_bg_color(&styles->ddlist_sel, LV_STATE_DEFAULT, theme.color_primary);
lv_style_set_text_color(&styles->ddlist_sel, LV_STATE_DEFAULT, IS_LIGHT ? lv_color_hex3(0xfff) : lv_color_hex3(0xfff)); lv_style_set_text_color(&styles->ddlist_sel, LV_STATE_DEFAULT, IS_LIGHT ? lv_color_hex3(0xfff) : lv_color_hex3(0xfff));
lv_style_set_bg_color(&styles->ddlist_sel, LV_STATE_PRESSED, COLOR_BG_PR); lv_style_set_bg_color(&styles->ddlist_sel, LV_STATE_PRESSED, CARD_PR_COLOR);
lv_style_set_text_color(&styles->ddlist_sel, LV_STATE_PRESSED, COLOR_BG_TEXT_PR); lv_style_set_text_color(&styles->ddlist_sel, LV_STATE_PRESSED, CARD_TEXT_PR_COLOR);
#endif #endif
} }
@@ -586,7 +576,7 @@ static void table_init(void)
{ {
#if LV_USE_TABLE != 0 #if LV_USE_TABLE != 0
style_init_reset(&styles->table_cell); style_init_reset(&styles->table_cell);
lv_style_set_border_color(&styles->table_cell, LV_STATE_DEFAULT, COLOR_BG_BORDER); lv_style_set_border_color(&styles->table_cell, LV_STATE_DEFAULT, CARD_BORDER_COLOR);
lv_style_set_border_width(&styles->table_cell, LV_STATE_DEFAULT, 1); lv_style_set_border_width(&styles->table_cell, LV_STATE_DEFAULT, 1);
lv_style_set_border_side(&styles->table_cell, LV_STATE_DEFAULT, LV_BORDER_SIDE_TOP | LV_BORDER_SIDE_BOTTOM); lv_style_set_border_side(&styles->table_cell, LV_STATE_DEFAULT, LV_BORDER_SIDE_TOP | LV_BORDER_SIDE_BOTTOM);
lv_style_set_pad_left(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF); lv_style_set_pad_left(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF);
@@ -618,7 +608,7 @@ static void win_init(void)
* @param font_title pointer to a extra large font * @param font_title pointer to a extra large font
* @return a pointer to reference this theme later * @return a pointer to reference this theme later
*/ */
lv_theme_t * lv_theme_material_init(lv_color_t color_primary, lv_color_t color_secondary, uint32_t flags, lv_theme_t * lv_theme_default_init(lv_color_t color_primary, lv_color_t color_secondary, uint32_t flags,
const lv_font_t * font_small, const lv_font_t * font_normal, const lv_font_t * font_subtitle, const lv_font_t * font_small, const lv_font_t * font_normal, const lv_font_t * font_subtitle,
const lv_font_t * font_title) const lv_font_t * font_title)
{ {
@@ -662,7 +652,6 @@ lv_theme_t * lv_theme_material_init(lv_color_t color_primary, lv_color_t color_s
table_init(); table_init();
win_init(); win_init();
theme.apply_xcb = NULL;
theme.apply_cb = theme_apply; theme.apply_cb = theme_apply;
inited = true; inited = true;
@@ -673,47 +662,48 @@ lv_theme_t * lv_theme_material_init(lv_color_t color_primary, lv_color_t color_s
} }
static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
{ {
LV_UNUSED(th); LV_UNUSED(th);
lv_style_list_t * list; if(lv_obj_get_parent(obj) == NULL) {
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->scr);
switch(name) { lv_obj_add_style(obj, LV_PART_SCROLLBAR, LV_STATE_DEFAULT, &styles->scrollbar);
case LV_THEME_NONE: lv_obj_add_style(obj, LV_PART_SCROLLBAR, LV_STATE_SCROLLED, &styles->scrollbar_scrolled);
break; return;
}
case LV_THEME_SCR:
list = _lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN);
_lv_style_list_add_style(list, &styles->scr);
_lv_style_list_add_style(list, &styles->sb);
break;
case LV_THEME_OBJ:
list = _lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->sb);
break;
if(lv_obj_check_type(obj, &lv_obj)) {
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->card);
lv_obj_add_style(obj, LV_PART_SCROLLBAR, LV_STATE_DEFAULT, &styles->scrollbar);
lv_obj_add_style(obj, LV_PART_SCROLLBAR, LV_STATE_SCROLLED, &styles->scrollbar_scrolled);
}
#if LV_USE_BTN #if LV_USE_BTN
case LV_THEME_BTN: else if(lv_obj_check_type(obj, &lv_btn)) {
list = _lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->btn);
_lv_style_list_add_style(list, &styles->btn); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->btn_color);
break; lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_PRESSED, &styles->btn_pressed);
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_PRESSED, &styles->btn_color_pressed);
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_CHECKED, &styles->btn_color_checked);
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_PRESSED | LV_STATE_CHECKED, &styles->btn_color_pressed_checked);
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DISABLED, &styles->btn_color_disabled);
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_CHECKED | LV_STATE_DISABLED, &styles->btn_color_checked_disabled);
}
#endif #endif
#if LV_USE_BTNMATRIX #if LV_USE_BTNMATRIX
case LV_THEME_BTNMATRIX: case LV_THEME_BTNMATRIX:
list = _lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_MAIN); list = _lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_MAIN);
_lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->card);
_lv_style_list_add_style(list, &styles->pad_small); _lv_style_list_add_style(list, &styles->pad_small);
list = _lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BTN); list = _lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BTN);
_lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->card);
_lv_style_list_add_style(list, &styles->bg_click); _lv_style_list_add_style(list, &styles->bg_click);
_lv_style_list_add_style(list, &styles->btnmatrix_btn); _lv_style_list_add_style(list, &styles->btnmatrix_btn);
list = _lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BTN_2); list = _lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BTN_2);
_lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->card);
_lv_style_list_add_style(list, &styles->bg_click); _lv_style_list_add_style(list, &styles->bg_click);
_lv_style_list_add_style(list, &styles->btnmatrix_btn); _lv_style_list_add_style(list, &styles->btnmatrix_btn);
break; break;
@@ -765,7 +755,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_ARC #if LV_USE_ARC
case LV_THEME_ARC: case LV_THEME_ARC:
list = _lv_obj_get_style_list(obj, LV_ARC_PART_BG); list = _lv_obj_get_style_list(obj, LV_ARC_PART_BG);
_lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->card);
_lv_style_list_add_style(list, &styles->arc_bg); _lv_style_list_add_style(list, &styles->arc_bg);
_lv_style_list_add_style(list, &styles->sb); _lv_style_list_add_style(list, &styles->sb);
@@ -773,7 +763,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name)
_lv_style_list_add_style(list, &styles->arc_indic); _lv_style_list_add_style(list, &styles->arc_indic);
list = _lv_obj_get_style_list(obj, LV_ARC_PART_KNOB); list = _lv_obj_get_style_list(obj, LV_ARC_PART_KNOB);
_lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->card);
_lv_style_list_add_style(list, &styles->bg_click); _lv_style_list_add_style(list, &styles->bg_click);
_lv_style_list_add_style(list, &styles->arc_knob); _lv_style_list_add_style(list, &styles->arc_knob);
break; break;
@@ -808,7 +798,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_ROLLER #if LV_USE_ROLLER
case LV_THEME_ROLLER: case LV_THEME_ROLLER:
list = _lv_obj_get_style_list(obj, LV_ROLLER_PART_BG); list = _lv_obj_get_style_list(obj, LV_ROLLER_PART_BG);
_lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->card);
_lv_style_list_add_style(list, &styles->roller_bg); _lv_style_list_add_style(list, &styles->roller_bg);
_lv_style_list_add_style(list, &styles->sb); _lv_style_list_add_style(list, &styles->sb);
@@ -826,12 +816,12 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_DROPDOWN #if LV_USE_DROPDOWN
case LV_THEME_DROPDOWN: case LV_THEME_DROPDOWN:
list = _lv_obj_get_style_list(obj, LV_DROPDOWN_PART_MAIN); list = _lv_obj_get_style_list(obj, LV_DROPDOWN_PART_MAIN);
_lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->card);
_lv_style_list_add_style(list, &styles->bg_click); _lv_style_list_add_style(list, &styles->bg_click);
_lv_style_list_add_style(list, &styles->pad_small); _lv_style_list_add_style(list, &styles->pad_small);
list = _lv_obj_get_style_list(obj, LV_DROPDOWN_PART_LIST); list = _lv_obj_get_style_list(obj, LV_DROPDOWN_PART_LIST);
_lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->card);
_lv_style_list_add_style(list, &styles->ddlist_page); _lv_style_list_add_style(list, &styles->ddlist_page);
_lv_style_list_add_style(list, &styles->sb); _lv_style_list_add_style(list, &styles->sb);
@@ -843,7 +833,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_CHART #if LV_USE_CHART
case LV_THEME_CHART: case LV_THEME_CHART:
list = _lv_obj_get_style_list(obj, LV_CHART_PART_BG); list = _lv_obj_get_style_list(obj, LV_CHART_PART_BG);
_lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->card);
_lv_style_list_add_style(list, &styles->chart_bg); _lv_style_list_add_style(list, &styles->chart_bg);
_lv_style_list_add_style(list, &styles->pad_small); _lv_style_list_add_style(list, &styles->pad_small);
@@ -861,7 +851,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_TABLE #if LV_USE_TABLE
case LV_THEME_TABLE: { case LV_THEME_TABLE: {
list = _lv_obj_get_style_list(obj, LV_TABLE_PART_BG); list = _lv_obj_get_style_list(obj, LV_TABLE_PART_BG);
_lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->card);
int idx = 1; /* start value should be 1, not zero, since cell styles int idx = 1; /* start value should be 1, not zero, since cell styles
start at 1 due to presence of LV_TABLE_PART_BG=0 start at 1 due to presence of LV_TABLE_PART_BG=0
@@ -878,7 +868,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_TEXTAREA #if LV_USE_TEXTAREA
case LV_THEME_TEXTAREA: case LV_THEME_TEXTAREA:
list = _lv_obj_get_style_list(obj, LV_TEXTAREA_PART_MAIN); list = _lv_obj_get_style_list(obj, LV_TEXTAREA_PART_MAIN);
_lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->card);
_lv_style_list_add_style(list, &styles->pad_small); _lv_style_list_add_style(list, &styles->pad_small);
_lv_style_list_add_style(list, &styles->sb); _lv_style_list_add_style(list, &styles->sb);
@@ -894,14 +884,14 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_LINEMETER #if LV_USE_LINEMETER
case LV_THEME_LINEMETER: case LV_THEME_LINEMETER:
list = _lv_obj_get_style_list(obj, LV_LINEMETER_PART_MAIN); list = _lv_obj_get_style_list(obj, LV_LINEMETER_PART_MAIN);
_lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->card);
_lv_style_list_add_style(list, &styles->lmeter); _lv_style_list_add_style(list, &styles->lmeter);
break; break;
#endif #endif
#if LV_USE_GAUGE #if LV_USE_GAUGE
case LV_THEME_GAUGE: case LV_THEME_GAUGE:
list = _lv_obj_get_style_list(obj, LV_GAUGE_PART_MAIN); list = _lv_obj_get_style_list(obj, LV_GAUGE_PART_MAIN);
_lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->card);
_lv_style_list_add_style(list, &styles->gauge_main); _lv_style_list_add_style(list, &styles->gauge_main);
list = _lv_obj_get_style_list(obj, LV_GAUGE_PART_MAJOR); list = _lv_obj_get_style_list(obj, LV_GAUGE_PART_MAJOR);
@@ -911,11 +901,6 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name)
_lv_style_list_add_style(list, &styles->gauge_needle); _lv_style_list_add_style(list, &styles->gauge_needle);
break; break;
#endif #endif
default:
break;
}
_lv_obj_refresh_style(obj, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
} }
/********************** /**********************

View File

@@ -1,10 +1,10 @@
/** /**
* @file lv_theme_material.h * @file lv_theme_default.h
* *
*/ */
#ifndef LV_THEME_MATERIAL_H #ifndef LV_THEME_DEFAULT_H
#define LV_THEME_MATERIAL_H #define LV_THEME_DEFAULT_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@@ -15,7 +15,7 @@ extern "C" {
*********************/ *********************/
#include "../lv_conf_internal.h" #include "../lv_conf_internal.h"
#if LV_USE_THEME_MATERIAL #if LV_USE_THEME_DEFAULT
/********************* /*********************
* DEFINES * DEFINES
@@ -46,7 +46,7 @@ typedef enum {
* @param font_title pointer to a extra large font * @param font_title pointer to a extra large font
* @return a pointer to reference this theme later * @return a pointer to reference this theme later
*/ */
lv_theme_t * lv_theme_material_init(lv_color_t color_primary, lv_color_t color_secondary, uint32_t flags, lv_theme_t * lv_theme_default_init(lv_color_t color_primary, lv_color_t color_secondary, uint32_t flags,
const lv_font_t * font_small, const lv_font_t * font_normal, const lv_font_t * font_subtitle, const lv_font_t * font_small, const lv_font_t * font_normal, const lv_font_t * font_subtitle,
const lv_font_t * font_title); const lv_font_t * font_title);
/********************** /**********************
@@ -59,4 +59,4 @@ lv_theme_t * lv_theme_material_init(lv_color_t color_primary, lv_color_t color_s
} /* extern "C" */ } /* extern "C" */
#endif #endif
#endif /*LV_THEME_MATERIAL_H*/ #endif /*LV_THEME_DEFAULT_H*/

View File

@@ -89,7 +89,6 @@ lv_theme_t * lv_theme_empty_init(lv_color_t color_primary, lv_color_t color_seco
style_init_reset(&styles->opa_cover); style_init_reset(&styles->opa_cover);
lv_style_set_bg_opa(&styles->opa_cover, LV_OPA_COVER); lv_style_set_bg_opa(&styles->opa_cover, LV_OPA_COVER);
theme.apply_xcb = NULL;
theme.apply_cb = theme_apply; theme.apply_cb = theme_apply;
return &theme; return &theme;
} }

View File

@@ -42,8 +42,6 @@ static void lv_bar_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t
static void lv_bar_destructor(void * obj); static void lv_bar_destructor(void * obj);
static lv_design_res_t lv_bar_design(lv_obj_t * bar, const lv_area_t * clip_area, lv_design_mode_t mode); static lv_design_res_t lv_bar_design(lv_obj_t * bar, const lv_area_t * clip_area, lv_design_mode_t mode);
static lv_res_t lv_bar_signal(lv_obj_t * bar, lv_signal_t sign, void * param); static lv_res_t lv_bar_signal(lv_obj_t * bar, lv_signal_t sign, void * param);
static lv_style_list_t * lv_bar_get_style(lv_bar_t * bar, uint8_t part);
static void draw_indic(lv_obj_t * bar, const lv_area_t * clip_area); static void draw_indic(lv_obj_t * bar, const lv_area_t * clip_area);
#if LV_USE_ANIMATION #if LV_USE_ANIMATION
@@ -89,11 +87,8 @@ lv_obj_t * lv_bar_create(lv_obj_t * parent, const lv_obj_t * copy)
lv_bar_t * bar = (lv_bar_t *) obj; lv_bar_t * bar = (lv_bar_t *) obj;
const lv_bar_t * bar_copy = (const lv_bar_t *) copy; const lv_bar_t * bar_copy = (const lv_bar_t *) copy;
if(!copy) lv_theme_apply(obj, LV_THEME_BAR); if(!copy) lv_theme_apply(obj);
else { // else lv_style_list_copy(&bar->style_indic, &bar_copy->style_indic);
lv_style_list_copy(&bar->style_indic, &bar_copy->style_indic);
_lv_obj_refresh_style(obj, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
}
return obj; return obj;
} }
@@ -398,7 +393,7 @@ static lv_design_res_t lv_bar_design(lv_obj_t * obj, const lv_area_t * clip_area
draw_dsc.bg_opa = LV_OPA_TRANSP; draw_dsc.bg_opa = LV_OPA_TRANSP;
draw_dsc.border_opa = LV_OPA_TRANSP; draw_dsc.border_opa = LV_OPA_TRANSP;
draw_dsc.shadow_opa = LV_OPA_TRANSP; draw_dsc.shadow_opa = LV_OPA_TRANSP;
draw_dsc.pattern_opa = LV_OPA_TRANSP; draw_dsc.content_opa = LV_OPA_TRANSP;
draw_dsc.outline_opa = LV_OPA_TRANSP; draw_dsc.outline_opa = LV_OPA_TRANSP;
lv_obj_init_draw_rect_dsc(obj, LV_BAR_PART_MAIN, &draw_dsc); lv_obj_init_draw_rect_dsc(obj, LV_BAR_PART_MAIN, &draw_dsc);
lv_draw_rect(&bar->coords, clip_area, &draw_dsc); lv_draw_rect(&bar->coords, clip_area, &draw_dsc);
@@ -424,10 +419,10 @@ static void draw_indic(lv_obj_t * obj, const lv_area_t * clip_area)
bar->start_value == bar->min_value) sym = true; bar->start_value == bar->min_value) sym = true;
/*Calculate the indicator area*/ /*Calculate the indicator area*/
lv_style_int_t bg_left = lv_obj_get_style_pad_left(obj, LV_BAR_PART_MAIN); lv_coord_t bg_left = lv_obj_get_style_pad_left(obj, LV_BAR_PART_MAIN);
lv_style_int_t bg_right = lv_obj_get_style_pad_right(obj, LV_BAR_PART_MAIN); lv_coord_t bg_right = lv_obj_get_style_pad_right(obj, LV_BAR_PART_MAIN);
lv_style_int_t bg_top = lv_obj_get_style_pad_top(obj, LV_BAR_PART_MAIN); lv_coord_t bg_top = lv_obj_get_style_pad_top(obj, LV_BAR_PART_MAIN);
lv_style_int_t bg_bottom = lv_obj_get_style_pad_bottom(obj, LV_BAR_PART_MAIN); lv_coord_t bg_bottom = lv_obj_get_style_pad_bottom(obj, LV_BAR_PART_MAIN);
/*Respect padding and minimum width/height too*/ /*Respect padding and minimum width/height too*/
lv_area_copy(&bar->indic_area, &bar->coords); lv_area_copy(&bar->indic_area, &bar->coords);
@@ -552,18 +547,14 @@ static void draw_indic(lv_obj_t * obj, const lv_area_t * clip_area)
(!hor && lv_area_get_height(&bar->indic_area) > bg_radius * 2)) { (!hor && lv_area_get_height(&bar->indic_area) > bg_radius * 2)) {
lv_opa_t bg_opa = draw_indic_dsc.bg_opa; lv_opa_t bg_opa = draw_indic_dsc.bg_opa;
lv_opa_t border_opa = draw_indic_dsc.border_opa; lv_opa_t border_opa = draw_indic_dsc.border_opa;
lv_opa_t value_opa = draw_indic_dsc.value_opa; lv_opa_t content_opa = draw_indic_dsc.content_opa;
const void * pattern_src = draw_indic_dsc.bg_img_src;
draw_indic_dsc.bg_opa = LV_OPA_TRANSP; draw_indic_dsc.bg_opa = LV_OPA_TRANSP;
draw_indic_dsc.border_opa = LV_OPA_TRANSP; draw_indic_dsc.border_opa = LV_OPA_TRANSP;
draw_indic_dsc.value_opa = LV_OPA_TRANSP; draw_indic_dsc.content_opa = LV_OPA_TRANSP;
draw_indic_dsc.bg_img_src = NULL;
lv_draw_rect(&bar->indic_area, clip_area, &draw_indic_dsc); lv_draw_rect(&bar->indic_area, clip_area, &draw_indic_dsc);
draw_indic_dsc.bg_opa = bg_opa; draw_indic_dsc.bg_opa = bg_opa;
draw_indic_dsc.border_opa = border_opa; draw_indic_dsc.border_opa = border_opa;
draw_indic_dsc.value_opa = value_opa; draw_indic_dsc.content_opa = content_opa;
draw_indic_dsc.bg_img_src = pattern_src;
} }
lv_draw_mask_radius_param_t mask_bg_param; lv_draw_mask_radius_param_t mask_bg_param;
@@ -573,10 +564,10 @@ static void draw_indic(lv_obj_t * obj, const lv_area_t * clip_area)
/*Draw_only the background and the pattern*/ /*Draw_only the background and the pattern*/
lv_opa_t shadow_opa = draw_indic_dsc.shadow_opa; lv_opa_t shadow_opa = draw_indic_dsc.shadow_opa;
lv_opa_t border_opa = draw_indic_dsc.border_opa; lv_opa_t border_opa = draw_indic_dsc.border_opa;
lv_opa_t value_opa = draw_indic_dsc.value_opa; lv_opa_t content_opa = draw_indic_dsc.content_opa;
draw_indic_dsc.border_opa = LV_OPA_TRANSP; draw_indic_dsc.border_opa = LV_OPA_TRANSP;
draw_indic_dsc.shadow_opa = LV_OPA_TRANSP; draw_indic_dsc.shadow_opa = LV_OPA_TRANSP;
draw_indic_dsc.value_opa = LV_OPA_TRANSP; draw_indic_dsc.content_opa = LV_OPA_TRANSP;
/*Get the max possible indicator area. The gradient should be applied on this*/ /*Get the max possible indicator area. The gradient should be applied on this*/
lv_area_t mask_indic_max_area; lv_area_t mask_indic_max_area;
@@ -602,20 +593,19 @@ static void draw_indic(lv_obj_t * obj, const lv_area_t * clip_area)
lv_draw_rect(&mask_indic_max_area, clip_area, &draw_indic_dsc); lv_draw_rect(&mask_indic_max_area, clip_area, &draw_indic_dsc);
draw_indic_dsc.border_opa = border_opa; draw_indic_dsc.border_opa = border_opa;
draw_indic_dsc.shadow_opa = shadow_opa; draw_indic_dsc.shadow_opa = shadow_opa;
draw_indic_dsc.value_opa = value_opa; draw_indic_dsc.content_opa = content_opa;
/*Draw the border*/ /*Draw the border*/
draw_indic_dsc.bg_opa = LV_OPA_TRANSP; draw_indic_dsc.bg_opa = LV_OPA_TRANSP;
draw_indic_dsc.shadow_opa = LV_OPA_TRANSP; draw_indic_dsc.shadow_opa = LV_OPA_TRANSP;
draw_indic_dsc.value_opa = LV_OPA_TRANSP; draw_indic_dsc.content_opa = LV_OPA_TRANSP;
draw_indic_dsc.bg_img_src = NULL;
lv_draw_rect(&bar->indic_area, clip_area, &draw_indic_dsc); lv_draw_rect(&bar->indic_area, clip_area, &draw_indic_dsc);
lv_draw_mask_remove_id(mask_indic_id); lv_draw_mask_remove_id(mask_indic_id);
lv_draw_mask_remove_id(mask_bg_id); lv_draw_mask_remove_id(mask_bg_id);
/*When not masks draw the value*/ /*When not masks draw the value*/
draw_indic_dsc.value_opa = value_opa; draw_indic_dsc.content_opa = content_opa;
draw_indic_dsc.border_opa = LV_OPA_TRANSP; draw_indic_dsc.border_opa = LV_OPA_TRANSP;
lv_draw_rect(&bar->indic_area, clip_area, &draw_indic_dsc); lv_draw_rect(&bar->indic_area, clip_area, &draw_indic_dsc);
@@ -639,13 +629,7 @@ static lv_res_t lv_bar_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
res = lv_bar.base_p->signal_cb(obj, sign, param); res = lv_bar.base_p->signal_cb(obj, sign, param);
if(res != LV_RES_OK) return res; if(res != LV_RES_OK) return res;
if(sign == LV_SIGNAL_GET_STYLE) { if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
lv_get_style_info_t * info = param;
info->result = lv_bar_get_style(bar, info->part);
if(info->result != NULL) return LV_RES_OK;
else return lv_bar.base_p->signal_cb(obj, sign, param);
}
else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
lv_coord_t indic_size; lv_coord_t indic_size;
indic_size = _lv_obj_get_draw_rect_ext_pad_size(obj, LV_BAR_PART_INDIC); indic_size = _lv_obj_get_draw_rect_ext_pad_size(obj, LV_BAR_PART_INDIC);
@@ -657,24 +641,6 @@ static lv_res_t lv_bar_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
return res; return res;
} }
static lv_style_list_t * lv_bar_get_style(lv_bar_t * bar, uint8_t part)
{
lv_style_list_t * list;
switch(part) {
case LV_BAR_PART_MAIN:
list = &bar->style_list;
break;
case LV_BAR_PART_INDIC:
list = &bar->style_indic;
break;
default:
list = NULL;
}
return list;
}
#if LV_USE_ANIMATION #if LV_USE_ANIMATION
static void lv_bar_anim(lv_bar_anim_t * var, lv_anim_value_t value) static void lv_bar_anim(lv_bar_anim_t * var, lv_anim_value_t value)
{ {

View File

@@ -68,7 +68,7 @@ lv_obj_t * lv_btn_create(lv_obj_t * parent, const lv_obj_t * copy)
lv_obj_t * obj = lv_class_new(&lv_btn); lv_obj_t * obj = lv_class_new(&lv_btn);
lv_btn.constructor(obj, parent, copy); lv_btn.constructor(obj, parent, copy);
if(!copy) lv_theme_apply(obj, LV_THEME_BTN); if(!copy) lv_theme_apply(obj);
LV_LOG_TRACE("button create started"); LV_LOG_TRACE("button create started");
return obj; return obj;

View File

@@ -27,14 +27,6 @@ extern "C" {
* TYPEDEFS * TYPEDEFS
**********************/ **********************/
/**Styles*/
enum {
LV_BTN_PART_MAIN = LV_OBJ_PART_MAIN,
};
typedef uint8_t lv_btn_part_t;
LV_CLASS_DECLARE_START(lv_btn, lv_obj); LV_CLASS_DECLARE_START(lv_btn, lv_obj);
#define _lv_btn_constructor void (*constructor)(struct _lv_obj_t * obj, struct _lv_obj_t * parent, const struct _lv_obj_t * copy) #define _lv_btn_constructor void (*constructor)(struct _lv_obj_t * obj, struct _lv_obj_t * parent, const struct _lv_obj_t * copy)