reenablea groups + remove overlay style properties

This commit is contained in:
Gabor Kiss-Vamosi
2020-01-21 15:56:03 +01:00
parent 3ec7ca2b37
commit da095828dc
9 changed files with 42 additions and 184 deletions

View File

@@ -28,9 +28,6 @@
/********************** /**********************
* STATIC PROTOTYPES * STATIC PROTOTYPES
**********************/ **********************/
static void style_mod_def(lv_group_t * group, lv_style_t * style);
static void style_mod_edit_def(lv_group_t * group, lv_style_t * style);
static void refresh_theme(lv_group_t * g, lv_theme_t * th);
static void focus_next_core(lv_group_t * group, void * (*begin)(const lv_ll_t *), static void focus_next_core(lv_group_t * group, void * (*begin)(const lv_ll_t *),
void * (*move)(const lv_ll_t *, const void *)); void * (*move)(const lv_ll_t *, const void *));
static void lv_group_refocus(lv_group_t * g); static void lv_group_refocus(lv_group_t * g);
@@ -79,9 +76,6 @@ lv_group_t * lv_group_create(void)
memset(&group->user_data, 0, sizeof(lv_group_user_data_t)); memset(&group->user_data, 0, sizeof(lv_group_user_data_t));
#endif #endif
/*Initialize style modification callbacks from current theme*/
refresh_theme(group, lv_theme_get_current());
return group; return group;
} }
@@ -501,27 +495,6 @@ bool lv_group_get_wrap(lv_group_t * group)
return group->wrap ? true : false; return group->wrap ? true : false;
} }
/**
* Notify the group that current theme changed and style modification callbacks need to be
* refreshed.
* @param group pointer to group. If NULL then all groups are notified.
*/
void lv_group_report_style_mod(lv_group_t * group)
{
lv_theme_t * th = lv_theme_get_current();
if(group != NULL) {
refresh_theme(group, th);
return;
}
lv_group_t * i;
LV_LL_READ(LV_GC_ROOT(_lv_group_ll), i)
{
refresh_theme(i, th);
}
}
/********************** /**********************
* STATIC FUNCTIONS * STATIC FUNCTIONS
**********************/ **********************/
@@ -540,89 +513,6 @@ static void lv_group_refocus(lv_group_t * g)
g->wrap = temp_wrap; g->wrap = temp_wrap;
} }
/**
* Default style modifier function
* @param group pointer to the caller group
* @param style pointer to a style to modify. (Typically group.style_tmp) It will be OVERWRITTEN.
*/
static void style_mod_def(lv_group_t * group, lv_style_t * style)
{
(void)group; /*Unused*/
#if LV_COLOR_DEPTH != 1
// /*Make the style to be a little bit orange*/
// style->body.border.opa = LV_OPA_COVER;
// style->body.border.color = LV_COLOR_ORANGE;
//
// /*If not transparent or has border then emphasis the border*/
// if(style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) style->body.border.width = LV_DPI / 20;
//
// style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_ORANGE, LV_OPA_70);
// style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_ORANGE, LV_OPA_70);
// style->body.shadow.color = lv_color_mix(style->body.shadow.color, LV_COLOR_ORANGE, LV_OPA_60);
//
// style->text.color = lv_color_mix(style->text.color, LV_COLOR_ORANGE, LV_OPA_70);
//
// /*Add some recolor to the images*/
// if(style->image.intense < LV_OPA_MIN) {
// style->image.color = LV_COLOR_ORANGE;
// style->image.intense = LV_OPA_40;
// }
#else
style->body.border.opa = LV_OPA_COVER;
style->body.border.color = LV_COLOR_BLACK;
style->body.border.width = 2;
#endif
}
/**
* Default style modifier function
* @param group pointer to the caller group
* @param style pointer to a style to modify. (Typically group.style_tmp) It will be OVERWRITTEN.
*/
static void style_mod_edit_def(lv_group_t * group, lv_style_t * style)
{
(void)group; /*Unused*/
#if LV_COLOR_DEPTH != 1
// /*Make the style to be a little bit orange*/
// style->body.border.opa = LV_OPA_COVER;
// style->body.border.color = LV_COLOR_GREEN;
//
// /*If not empty or has border then emphasis the border*/
// if(style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) style->body.border.width = LV_DPI / 20;
//
// style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_GREEN, LV_OPA_70);
// style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_GREEN, LV_OPA_70);
// style->body.shadow.color = lv_color_mix(style->body.shadow.color, LV_COLOR_GREEN, LV_OPA_60);
//
// style->text.color = lv_color_mix(style->text.color, LV_COLOR_GREEN, LV_OPA_70);
//
// /*Add some recolor to the images*/
// if(style->image.intense < LV_OPA_MIN) {
// style->image.color = LV_COLOR_GREEN;
// style->image.intense = LV_OPA_40;
// }
#else
style->body.border.opa = LV_OPA_COVER;
style->body.border.color = LV_COLOR_BLACK;
style->body.border.width = 3;
#endif
}
static void refresh_theme(lv_group_t * g, lv_theme_t * th)
{
g->style_mod_cb = style_mod_def;
g->style_mod_edit_cb = style_mod_edit_def;
if(th) {
if(th->group.style_mod_xcb) g->style_mod_cb = th->group.style_mod_xcb;
if(th->group.style_mod_edit_xcb) g->style_mod_edit_cb = th->group.style_mod_edit_xcb;
}
}
static void focus_next_core(lv_group_t * group, void * (*begin)(const lv_ll_t *), static void focus_next_core(lv_group_t * group, void * (*begin)(const lv_ll_t *),
void * (*move)(const lv_ll_t *, const void *)) void * (*move)(const lv_ll_t *, const void *))
{ {

View File

@@ -268,13 +268,6 @@ bool lv_group_get_click_focus(const lv_group_t * group);
*/ */
bool lv_group_get_wrap(lv_group_t * group); bool lv_group_get_wrap(lv_group_t * group);
/**
* Notify the group that current theme changed and style modification callbacks need to be
* refreshed.
* @param group pointer to group. If NULL then all groups are notified.
*/
void lv_group_report_style_mod(lv_group_t * group);
/********************** /**********************
* MACROS * MACROS
**********************/ **********************/

View File

@@ -2680,11 +2680,6 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t
} }
} }
draw_dsc->overlay_opa = lv_obj_get_style_opa(obj, part, LV_STYLE_OVERLAY_OPA);
if(draw_dsc->overlay_opa > LV_OPA_MIN) {
draw_dsc->overlay_color = lv_obj_get_style_color(obj, part, LV_STYLE_OVERLAY_COLOR);
}
if(draw_dsc->shadow_opa != LV_OPA_TRANSP) { if(draw_dsc->shadow_opa != LV_OPA_TRANSP) {
draw_dsc->shadow_opa = lv_obj_get_style_opa(obj, part, LV_STYLE_SHADOW_OPA); draw_dsc->shadow_opa = lv_obj_get_style_opa(obj, part, LV_STYLE_SHADOW_OPA);
if(draw_dsc->shadow_opa > LV_OPA_MIN) { if(draw_dsc->shadow_opa > LV_OPA_MIN) {
@@ -2705,6 +2700,7 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t
draw_dsc->pattern_opa = (uint16_t)((uint16_t)draw_dsc->pattern_opa * opa_scale) >> 8; draw_dsc->pattern_opa = (uint16_t)((uint16_t)draw_dsc->pattern_opa * opa_scale) >> 8;
} }
} }
void lv_obj_init_draw_label_dsc(lv_obj_t * obj, uint8_t part, lv_draw_label_dsc_t * draw_dsc) void lv_obj_init_draw_label_dsc(lv_obj_t * obj, uint8_t part, lv_draw_label_dsc_t * draw_dsc)
@@ -2748,11 +2744,6 @@ void lv_obj_init_draw_img_dsc(lv_obj_t * obj, uint8_t part, lv_draw_img_dsc_t *
draw_dsc->recolor_opa = lv_obj_get_style_opa(obj, part, LV_STYLE_IMAGE_RECOLOR_OPA); draw_dsc->recolor_opa = lv_obj_get_style_opa(obj, part, LV_STYLE_IMAGE_RECOLOR_OPA);
draw_dsc->recolor = lv_obj_get_style_color(obj, part, LV_STYLE_IMAGE_RECOLOR); draw_dsc->recolor = lv_obj_get_style_color(obj, part, LV_STYLE_IMAGE_RECOLOR);
draw_dsc->overlay_opa = lv_obj_get_style_opa(obj, part, LV_STYLE_OVERLAY_OPA);
if(draw_dsc->overlay_opa > LV_OPA_MIN) {
draw_dsc->overlay_color = lv_obj_get_style_color(obj, part, LV_STYLE_OVERLAY_COLOR);
}
draw_dsc->blend_mode = lv_obj_get_style_int(obj, part, LV_STYLE_IMAGE_BLEND_MODE); draw_dsc->blend_mode = lv_obj_get_style_int(obj, part, LV_STYLE_IMAGE_BLEND_MODE);
} }

View File

@@ -252,7 +252,7 @@ typedef struct _lv_obj_t
lv_bidi_dir_t base_dir :2; /**< Base direction of texts related to this object */ lv_bidi_dir_t base_dir :2; /**< Base direction of texts related to this object */
#if LV_USE_GROUP != 0 #if LV_USE_GROUP != 0
uint8_t group_id :LV_GROUP_ID_MAX; void * group_p;
#endif #endif
uint8_t protect; /**< Automatically happening actions can be prevented. uint8_t protect; /**< Automatically happening actions can be prevented.

View File

@@ -135,14 +135,11 @@ enum {
LV_STYLE_PROP_INIT(LV_STYLE_IMAGE_OPA, 0x8, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_INHERIT), LV_STYLE_PROP_INIT(LV_STYLE_IMAGE_OPA, 0x8, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_IMAGE_RECOLOR_OPA, 0x8, LV_STYLE_ID_OPA + 1, LV_STYLE_ATTR_INHERIT), LV_STYLE_PROP_INIT(LV_STYLE_IMAGE_RECOLOR_OPA, 0x8, LV_STYLE_ID_OPA + 1, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_OVERLAY_COLOR, 0x9, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_INHERIT), LV_STYLE_PROP_INIT(LV_STYLE_SIZE, 0x9, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_OVERLAY_OPA, 0x9, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_INHERIT), LV_STYLE_PROP_INIT(LV_STYLE_SCALE_WIDTH, 0x9, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_SCALE_COLOR, 0x9, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_SIZE, 0xA, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_SCALE_GRAD_COLOR, 0x9, LV_STYLE_ID_COLOR + 1, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_SCALE_WIDTH, 0xA, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_SCALE_END_COLOR, 0x9, LV_STYLE_ID_COLOR + 2, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_SCALE_COLOR, 0xA, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_SCALE_GRAD_COLOR, 0xA, LV_STYLE_ID_COLOR + 1, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_SCALE_END_COLOR, 0xA, LV_STYLE_ID_COLOR + 2, LV_STYLE_ATTR_NONE),
}; };
typedef uint16_t lv_style_property_t; typedef uint16_t lv_style_property_t;

View File

@@ -39,11 +39,8 @@ typedef struct {
lv_opa_t recolor_opa; lv_opa_t recolor_opa;
lv_color_t recolor; lv_color_t recolor;
lv_opa_t overlay_opa;
lv_color_t overlay_color;
lv_blend_mode_t blend_mode; lv_blend_mode_t blend_mode;
uint8_t antialias :1; uint8_t antialias :1;
} lv_draw_img_dsc_t; } lv_draw_img_dsc_t;

View File

@@ -1459,20 +1459,16 @@ static lv_res_t lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param)
#endif #endif
} else if(sign == LV_SIGNAL_FOCUS) { } else if(sign == LV_SIGNAL_FOCUS) {
#if LV_USE_GROUP #if LV_USE_GROUP
lv_cursor_type_t cur_type;
cur_type = lv_ta_get_cursor_type(ta);
lv_group_t * g = lv_obj_get_group(ta); lv_group_t * g = lv_obj_get_group(ta);
bool editing = lv_group_get_editing(g); bool editing = lv_group_get_editing(g);
lv_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act()); lv_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
/*Encoders need special handling*/ /*Encoders need special handling*/
if(indev_type == LV_INDEV_TYPE_ENCODER) { if(indev_type == LV_INDEV_TYPE_ENCODER) {
if(editing) if(editing) lv_ta_set_cursor_hidden(ta, false);
lv_ta_set_cursor_type(ta, cur_type & (~LV_CURSOR_HIDDEN)); else lv_ta_set_cursor_hidden(ta, true);
else
lv_ta_set_cursor_type(ta, cur_type | LV_CURSOR_HIDDEN);
} else { } else {
lv_ta_set_cursor_type(ta, cur_type & (~LV_CURSOR_HIDDEN)); lv_ta_set_cursor_hidden(ta, false);
} }
#endif #endif
} else if(sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_PRESSING || sign == LV_SIGNAL_PRESS_LOST || } else if(sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_PRESSING || sign == LV_SIGNAL_PRESS_LOST ||

View File

@@ -43,6 +43,8 @@ typedef enum {
LV_THEME_LABEL, LV_THEME_LABEL,
LV_THEME_IMAGE,
LV_THEME_BTNM, LV_THEME_BTNM,
LV_THEME_BTNM_BTN, LV_THEME_BTNM_BTN,

View File

@@ -127,6 +127,7 @@ static void basic_init(void)
lv_style_set_int(&panel, LV_STYLE_RADIUS, LV_DPI / 25); lv_style_set_int(&panel, LV_STYLE_RADIUS, LV_DPI / 25);
lv_style_set_opa(&panel, LV_STYLE_BG_OPA, LV_OPA_COVER); lv_style_set_opa(&panel, LV_STYLE_BG_OPA, LV_OPA_COVER);
lv_style_set_color(&panel, LV_STYLE_BG_COLOR, COLOR_CONTAINER); lv_style_set_color(&panel, LV_STYLE_BG_COLOR, COLOR_CONTAINER);
lv_style_set_color(&panel, LV_STYLE_BG_COLOR | LV_STYLE_STATE_FOCUS, LV_COLOR_RED);
lv_style_set_color(&panel, LV_STYLE_BORDER_COLOR, lv_color_lighten(COLOR_CONTAINER, LV_OPA_10)); lv_style_set_color(&panel, LV_STYLE_BORDER_COLOR, lv_color_lighten(COLOR_CONTAINER, LV_OPA_10));
lv_style_set_int(&panel, LV_STYLE_BORDER_WIDTH, LV_DPI / 50 > 0 ? LV_DPI / 50 : 1); lv_style_set_int(&panel, LV_STYLE_BORDER_WIDTH, LV_DPI / 50 > 0 ? LV_DPI / 50 : 1);
lv_style_set_int(&panel, LV_STYLE_BORDER_SIDE , LV_BORDER_SIDE_TOP); lv_style_set_int(&panel, LV_STYLE_BORDER_SIDE , LV_BORDER_SIDE_TOP);
@@ -135,6 +136,7 @@ static void basic_init(void)
lv_style_set_int(&panel, LV_STYLE_PAD_TOP, LV_DPI / 5); lv_style_set_int(&panel, LV_STYLE_PAD_TOP, LV_DPI / 5);
lv_style_set_int(&panel, LV_STYLE_PAD_BOTTOM, LV_DPI / 5); lv_style_set_int(&panel, LV_STYLE_PAD_BOTTOM, LV_DPI / 5);
lv_style_set_int(&panel, LV_STYLE_PAD_INNER, LV_DPI / 5); lv_style_set_int(&panel, LV_STYLE_PAD_INNER, LV_DPI / 5);
lv_style_set_int(&panel, LV_STYLE_PAD_INNER | LV_STYLE_STATE_FOCUS, LV_DPI);
lv_style_set_color(&panel, LV_STYLE_TEXT_COLOR, lv_color_hex(0x979a9f)); lv_style_set_color(&panel, LV_STYLE_TEXT_COLOR, lv_color_hex(0x979a9f));
lv_style_set_ptr(&panel, LV_STYLE_FONT, &lv_font_roboto_16); lv_style_set_ptr(&panel, LV_STYLE_FONT, &lv_font_roboto_16);
lv_style_set_color(&panel, LV_STYLE_IMAGE_RECOLOR, lv_color_hex(0x979a9f)); lv_style_set_color(&panel, LV_STYLE_IMAGE_RECOLOR, lv_color_hex(0x979a9f));
@@ -573,6 +575,10 @@ static void win_init(void)
*/ */
lv_theme_t * lv_theme_alien_init(uint16_t hue, lv_font_t * font) lv_theme_t * lv_theme_alien_init(uint16_t hue, lv_font_t * font)
{ {
lv_mem_monitor_t mon1;
lv_mem_monitor(&mon1);
basic_init(); basic_init();
cont_init(); cont_init();
btn_init(); btn_init();
@@ -607,6 +613,11 @@ lv_theme_t * lv_theme_alien_init(uint16_t hue, lv_font_t * font)
theme.get_style_cb = lv_theme_alien_get_style; theme.get_style_cb = lv_theme_alien_get_style;
theme.apply_cb = lv_theme_alien_apply; theme.apply_cb = lv_theme_alien_apply;
lv_mem_monitor_t mon2;
lv_mem_monitor(&mon2);
printf("theme size: %d\n", mon1.free_size - mon2.free_size);
return &theme; return &theme;
} }
@@ -625,6 +636,11 @@ void lv_theme_alien_apply(lv_obj_t * obj, lv_theme_style_t name)
lv_style_list_t * list; lv_style_list_t * list;
switch(name) { switch(name) {
case LV_THEME_SCR:
list = lv_obj_get_style(obj, LV_BTN_PART_MAIN);
lv_style_list_reset(list);
lv_style_list_reset(&scr);
break;
case LV_THEME_BTN: case LV_THEME_BTN:
list = lv_obj_get_style(obj, LV_BTN_PART_MAIN); list = lv_obj_get_style(obj, LV_BTN_PART_MAIN);
lv_style_list_reset(list); lv_style_list_reset(list);
@@ -664,6 +680,20 @@ void lv_theme_alien_apply(lv_obj_t * obj, lv_theme_style_t name)
lv_style_list_add_style(list, &sw_knob); lv_style_list_add_style(list, &sw_knob);
break; break;
#if LV_USE_IMG
case LV_THEME_IMAGE:
list = lv_obj_get_style(obj, LV_IMG_PART_MAIN);
lv_style_list_reset(list);
break;
#endif
#if LV_USE_LABEL
case LV_THEME_LABEL:
list = lv_obj_get_style(obj, LV_LABEL_PART_MAIN);
lv_style_list_reset(list);
break;
#endif
#if LV_USE_SLIDER #if LV_USE_SLIDER
case LV_THEME_SLIDER: case LV_THEME_SLIDER:
list = lv_obj_get_style(obj, LV_SLIDER_PART_BG); list = lv_obj_get_style(obj, LV_SLIDER_PART_BG);
@@ -803,21 +833,6 @@ void lv_theme_alien_apply(lv_obj_t * obj, lv_theme_style_t name)
lv_style_t * lv_theme_alien_get_style(lv_theme_style_t name) lv_style_t * lv_theme_alien_get_style(lv_theme_style_t name)
{ {
switch(name) { switch(name) {
case LV_THEME_SCR:
return &scr;
case LV_THEME_PANEL:
return &panel;
case LV_THEME_BTNM:
return &panel;
case LV_THEME_BTNM_BTN:
return &btn;
#if LV_USE_CB
case LV_THEME_CB:
return &panel;
case LV_THEME_CB_BULLET:
return &btn;
#endif
#if LV_USE_DDLIST #if LV_USE_DDLIST
case LV_THEME_DDLIST_SCRL: case LV_THEME_DDLIST_SCRL:
return NULL; return NULL;
@@ -834,10 +849,6 @@ lv_style_t * lv_theme_alien_get_style(lv_theme_style_t name)
case LV_THEME_GAUGE_STRONG: case LV_THEME_GAUGE_STRONG:
return &gauge_strong; return &gauge_strong;
#endif #endif
#if LV_USE_TA
case LV_THEME_TA_CURSOR:
return &ta_cursor;
#endif
#if LV_USE_LIST #if LV_USE_LIST
case LV_THEME_LIST_BTN: case LV_THEME_LIST_BTN:
return &btn; return &btn;
@@ -869,25 +880,6 @@ lv_style_t * lv_theme_alien_get_style(lv_theme_style_t name)
case LV_THEME_MBOX_BTN: case LV_THEME_MBOX_BTN:
return &btn; return &btn;
#endif #endif
#if LV_USE_TABLE
case LV_THEME_TABLE_BG:
return NULL;
case LV_THEME_TABLE_CELL1:
case LV_THEME_TABLE_CELL2:
case LV_THEME_TABLE_CELL3:
case LV_THEME_TABLE_CELL4:
return &table_cell;
#endif
#if LV_USE_CHART
case LV_THEME_CHART_BG:
return &panel;
case LV_THEME_CHART_SERIES_BG:
return NULL;
case LV_THEME_CHART_SERIES:
return &chart_series;
#endif
} }
return NULL; return NULL;