apply theme to some objects

This commit is contained in:
Gabor Kiss-Vamosi
2020-01-20 16:11:38 +01:00
parent ed35420475
commit 2dedea5600
18 changed files with 352 additions and 328 deletions

View File

@@ -282,8 +282,8 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
new_obj->ext_attr = NULL;
lv_style_list_init(&new_obj->style_list);
if(copy == NULL) {
lv_style_list_init(&new_obj->style_list);
if(parent != NULL) lv_obj_add_theme(new_obj, LV_OBJ_PART_MAIN, LV_THEME_PANEL);
else lv_obj_add_theme(new_obj, LV_OBJ_PART_MAIN, LV_THEME_SCR);
} else {
@@ -746,7 +746,7 @@ void lv_obj_set_size(lv_obj_t * obj, lv_coord_t w, lv_coord_t h)
/*Tell the children the parent's size has changed*/
lv_obj_t * i;
LV_LL_READ(obj->child_ll, i) {
i->signal_cb(i, LV_SIGNAL_PARENT_SIZE_CHG, NULL);
i->signal_cb(i, LV_SIGNAL_PARENT_SIZE_CHG, &ori);
}
/*Invalidate the new area*/
@@ -1467,6 +1467,7 @@ void lv_obj_set_state(lv_obj_t * obj, lv_obj_state_t state)
obj->state = new_state;
obj->prev_state = new_state;
obj->state_anim = 0;
lv_obj_refresh_style(obj);
}
/*Start transition if set*/
else {
@@ -1476,6 +1477,7 @@ void lv_obj_set_state(lv_obj_t * obj, lv_obj_state_t state)
obj->state = new_state;
obj->prev_state = new_state;
obj->state_anim = 0;
lv_obj_refresh_style(obj);
}
/*Set the new state for prev state too to get the TRANSITION_TIME for the new state*/
else {
@@ -2649,7 +2651,7 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t
if(draw_dsc->border_opa > LV_OPA_MIN) {
draw_dsc->border_width = lv_obj_get_style_int(obj, part, LV_STYLE_BORDER_WIDTH);
if(draw_dsc->border_width) {
draw_dsc->border_part = lv_obj_get_style_int(obj, part, LV_STYLE_BORDER_SIDE);
draw_dsc->border_side = lv_obj_get_style_int(obj, part, LV_STYLE_BORDER_SIDE);
draw_dsc->border_color = lv_obj_get_style_color(obj, part, LV_STYLE_BORDER_COLOR);
}
draw_dsc->border_blend_mode = lv_obj_get_style_int(obj, part, LV_STYLE_BORDER_BLEND_MODE);

View File

@@ -90,7 +90,7 @@ void lv_style_list_init(lv_style_list_t * list)
void lv_style_list_copy(lv_style_list_t * list_dest, const lv_style_list_t * list_src)
{
lv_style_list_init(list_dest);
lv_style_list_reset(list_dest);
if(list_src->style_list == NULL) return;

View File

@@ -144,10 +144,8 @@ enum {
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;
#define LV_STYLE_STATE_POS 8
#define LV_STYLE_STATE_MASK 0x7F00

View File

@@ -55,7 +55,7 @@ void lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc)
dsc->overlay_opa = LV_OPA_TRANSP;
dsc->pattern_font = LV_FONT_DEFAULT;
dsc->shadow_opa = LV_OPA_COVER;
dsc->border_part = LV_BORDER_SIDE_FULL;
dsc->border_side = LV_BORDER_SIDE_FULL;
}
/**
@@ -117,10 +117,10 @@ static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_re
/*If the border fully covers make the bg area 1px smaller to avoid artifacts on the corners*/
if(dsc->border_width > 1 && dsc->border_opa >= LV_OPA_MAX && dsc->radius != 0) {
coords_bg.x1++;
coords_bg.y1++;
coords_bg.x2--;
coords_bg.y2--;
coords_bg.x1 += dsc->border_side & LV_BORDER_SIDE_LEFT ? 1 : 0;
coords_bg.y1 += dsc->border_side & LV_BORDER_SIDE_TOP ? 1 : 0;
coords_bg.x2 -= dsc->border_side & LV_BORDER_SIDE_RIGHT ? 1 : 0;
coords_bg.y2 -= dsc->border_side & LV_BORDER_SIDE_BOTTOM ? 1 : 0;
}
lv_opa_t opa = dsc->bg_opa;
@@ -314,7 +314,7 @@ static void draw_border(const lv_area_t * coords, const lv_area_t * clip, lv_dra
bool simple_mode = true;
if(lv_draw_mask_get_cnt()!= 0) simple_mode = false;
else if(dsc->border_part != LV_BORDER_SIDE_FULL) simple_mode = false;
else if(dsc->border_side != LV_BORDER_SIDE_FULL) simple_mode = false;
else if(dsc->bg_grad_dir == LV_GRAD_DIR_HOR) simple_mode = false;
int16_t mask_rout_id = LV_MASK_ID_INV;
@@ -342,10 +342,10 @@ static void draw_border(const lv_area_t * coords, const lv_area_t * clip, lv_dra
/*Get the inner area*/
lv_area_t area_small;
lv_area_copy(&area_small, coords);
area_small.x1 += ((dsc->border_part & LV_BORDER_SIDE_LEFT) ? border_width : - (border_width + rout));
area_small.x2 -= ((dsc->border_part & LV_BORDER_SIDE_RIGHT) ? border_width : - (border_width + rout));
area_small.y1 += ((dsc->border_part & LV_BORDER_SIDE_TOP) ? border_width : - (border_width + rout));
area_small.y2 -= ((dsc->border_part & LV_BORDER_SIDE_BOTTOM) ? border_width : - (border_width + rout));
area_small.x1 += ((dsc->border_side & LV_BORDER_SIDE_LEFT) ? border_width : - (border_width + rout));
area_small.x2 -= ((dsc->border_side & LV_BORDER_SIDE_RIGHT) ? border_width : - (border_width + rout));
area_small.y1 += ((dsc->border_side & LV_BORDER_SIDE_TOP) ? border_width : - (border_width + rout));
area_small.y2 -= ((dsc->border_side & LV_BORDER_SIDE_BOTTOM) ? border_width : - (border_width + rout));
/*Create inner the mask*/
lv_draw_mask_radius_param_t mask_rin_param;
@@ -402,7 +402,7 @@ static void draw_border(const lv_area_t * coords, const lv_area_t * clip, lv_dra
}
/*Draw the lower corner area corner area*/
if(dsc->border_part & LV_BORDER_SIDE_BOTTOM) {
if(dsc->border_side & LV_BORDER_SIDE_BOTTOM) {
lv_coord_t lower_corner_end = coords->y2 - disp_area->y1 - corner_size;
if(lower_corner_end <= upper_corner_end) lower_corner_end = upper_corner_end + 1;
fill_area.y1 = disp_area->y1 + lower_corner_end;
@@ -1048,6 +1048,7 @@ static void draw_img(const lv_area_t * coords, const lv_area_t * clip, lv_draw_r
lv_draw_label_dsc_init(&label_dsc);
label_dsc.color = dsc->pattern_recolor;
label_dsc.font = dsc->pattern_font;
label_dsc.opa = dsc->pattern_opa;
lv_point_t s;
lv_txt_get_size(&s, dsc->pattern_src, label_dsc.font, label_dsc.letter_space, label_dsc.line_space, LV_COORD_MAX, LV_TXT_FLAG_NONE);
img_w = s.x;

View File

@@ -40,7 +40,7 @@ typedef struct {
lv_color_t border_color;
lv_style_int_t border_width;
lv_blend_mode_t border_blend_mode;
lv_style_int_t border_part;
lv_style_int_t border_side;
lv_opa_t border_opa;
/*Shadow*/

View File

@@ -37,6 +37,17 @@
* STATIC FUNCTIONS
**********************/
lv_color_t lv_color_lighten(lv_color_t c, lv_opa_t lvl)
{
return lv_color_mix(LV_COLOR_WHITE, c, lvl);
}
lv_color_t lv_color_darken(lv_color_t c, lv_opa_t lvl)
{
return lv_color_mix(LV_COLOR_BLACK, c, lvl);
}
/**
* Convert a HSV color to RGB
* @param h hue [0..359]

View File

@@ -557,6 +557,10 @@ static inline lv_color_t lv_color_hex3(uint32_t c)
(uint8_t)((c & 0xF) | ((c & 0xF) << 4)));
}
lv_color_t lv_color_lighten(lv_color_t c, lv_opa_t lvl);
lv_color_t lv_color_darken(lv_color_t c, lv_opa_t lvl);
/**
* Convert a HSV color to RGB
* @param h hue [0..359]

View File

@@ -103,13 +103,14 @@ lv_obj_t * lv_bar_create(lv_obj_t * par, const lv_obj_t * copy)
#endif
ext->type = LV_BAR_TYPE_NORMAL;
lv_style_list_init(&ext->style_indic);
lv_obj_set_signal_cb(bar, lv_bar_signal);
lv_obj_set_design_cb(bar, lv_bar_design);
/*Init the new bar object*/
if(copy == NULL) {
lv_style_list_init(&ext->style_indic);
lv_obj_set_click(bar, false);
lv_obj_set_size(bar, LV_DPI * 2, LV_DPI / 10);

View File

@@ -73,17 +73,17 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy)
LV_LOG_TRACE("button matrix create started");
/*Create the ancestor object*/
lv_obj_t * new_btnm = lv_obj_create(par, copy);
LV_ASSERT_MEM(new_btnm);
if(new_btnm == NULL) return NULL;
lv_obj_t * btnm = lv_obj_create(par, copy);
LV_ASSERT_MEM(btnm);
if(btnm == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_btnm);
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(btnm);
/*Allocate the object type specific extended data*/
lv_btnm_ext_t * ext = lv_obj_allocate_ext_attr(new_btnm, sizeof(lv_btnm_ext_t));
lv_btnm_ext_t * ext = lv_obj_allocate_ext_attr(btnm, sizeof(lv_btnm_ext_t));
LV_ASSERT_MEM(ext);
if(ext == NULL) {
lv_obj_del(new_btnm);
lv_obj_del(btnm);
return NULL;
}
@@ -98,24 +98,16 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy)
ext->one_toggle = 0;
lv_style_list_init(&ext->style_btn);
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_cb(new_btnm);
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_cb(btnm);
lv_obj_set_signal_cb(new_btnm, lv_btnm_signal);
lv_obj_set_design_cb(new_btnm, lv_btnm_design);
lv_obj_set_signal_cb(btnm, lv_btnm_signal);
lv_obj_set_design_cb(btnm, lv_btnm_design);
/*Init the new button matrix object*/
if(copy == NULL) {
lv_btnm_set_map(new_btnm, lv_btnm_def_map);
lv_obj_set_size(new_btnm, LV_DPI * 3, LV_DPI * 2);
/*Set the default styles*/
lv_obj_reset_style(new_btnm, LV_BTNM_PART_BG);
_ot(new_btnm, LV_BTNM_PART_BG, BTNM);
/* Do not cache the button style because it's independent from the object's style.
* (Therefore it can't be cached)*/
// ext->style_btn.cache.enabled = 0;
_ot(new_btnm, LV_BTNM_PART_BTN, BTNM_BTN);
lv_btnm_set_map(btnm, lv_btnm_def_map);
lv_obj_set_size(btnm, LV_DPI * 3, LV_DPI * 2);
lv_theme_apply(btnm, LV_THEME_BTNM);
}
/*Copy an existing object*/
else {
@@ -126,7 +118,7 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy)
LV_LOG_INFO("button matrix created");
return new_btnm;
return btnm;
}
/*=====================
@@ -676,8 +668,8 @@ static lv_design_res_t lv_btnm_design(lv_obj_t * btnm, const lv_area_t * clip_ar
bool tgl_state = button_get_tgl_state(ext->ctrl_bits[btn_i]);
if(button_is_inactive(ext->ctrl_bits[btn_i])) {
draw_rect_dsc_act = &draw_rect_rel_dsc;
draw_label_dsc_act = &draw_label_rel_dsc;
draw_rect_dsc_act = &draw_rect_ina_dsc;
draw_label_dsc_act = &draw_label_ina_dsc;
}
/*Simple released or checked buttons button*/
else if(btn_i != ext->btn_id_pr && btn_i != ext->btn_id_focused) {
@@ -686,9 +678,6 @@ static lv_design_res_t lv_btnm_design(lv_obj_t * btnm, const lv_area_t * clip_ar
}
/*Focused and/or pressed + checked or released button*/
else {
/*The state changes without re-caching the styles, disable the use of cache*/
// btnm->style_dsc.cache.enabled = 0;
if(tgl_state) btnm->state = LV_OBJ_STATE_CHECKED;
if(ext->btn_id_pr == btn_i) btnm->state |= LV_OBJ_STATE_PRESSED;
if(ext->btn_id_focused == btn_i) btnm->state |= LV_OBJ_STATE_FOCUS;
@@ -700,37 +689,37 @@ static lv_design_res_t lv_btnm_design(lv_obj_t * btnm, const lv_area_t * clip_ar
draw_rect_dsc_act = &draw_rect_tmp_dsc;
draw_label_dsc_act = &draw_label_tmp_dsc;
btnm->state = state_ori;
btnm->state = prev_state_ori;
// btnm->style_dsc.cache.enabled = 1;
btnm->prev_state = prev_state_ori;
}
lv_style_int_t border_part_ori = draw_rect_dsc_act->border_part;
lv_style_int_t border_part_ori = draw_rect_dsc_act->border_side;
/*Remove borders on the edges if `LV_BORDER_INTERNAL`*/
if(border_part_ori & LV_BORDER_SIDE_INTERNAL) {
/*Top/Bottom lines*/
if(area_tmp.y1 == btnm->coords.y1 + padding_top) {
draw_rect_dsc_act->border_part &= ~LV_BORDER_SIDE_TOP;
draw_rect_dsc_act->border_side &= ~LV_BORDER_SIDE_TOP;
}
if(area_tmp.y2 == btnm->coords.y2 - padding_bottom) {
draw_rect_dsc_act->border_part &= ~LV_BORDER_SIDE_BOTTOM;
draw_rect_dsc_act->border_side &= ~LV_BORDER_SIDE_BOTTOM;
}
/*Left/right columns*/
if(txt_i == 0) { /*First button*/
draw_rect_dsc_act->border_part &= ~LV_BORDER_SIDE_LEFT;
draw_rect_dsc_act->border_side &= ~LV_BORDER_SIDE_LEFT;
} else if(strcmp(ext->map_p[txt_i - 1], "\n") == 0) {
draw_rect_dsc_act->border_part &= ~LV_BORDER_SIDE_LEFT;
draw_rect_dsc_act->border_side &= ~LV_BORDER_SIDE_LEFT;
}
if(ext->map_p[txt_i + 1][0] == '\0' || strcmp(ext->map_p[txt_i + 1], "\n") == 0) {
draw_rect_dsc_act->border_part &= ~LV_BORDER_SIDE_RIGHT;
draw_rect_dsc_act->border_side &= ~LV_BORDER_SIDE_RIGHT;
}
}
lv_draw_rect(&area_tmp, clip_area, draw_rect_dsc_act);
draw_rect_dsc_act->border_side = border_part_ori;
/*Calculate the size of the text*/
const lv_font_t * font = draw_label_dsc_act->font;
lv_style_int_t letter_space = draw_label_dsc_act->letter_space;
@@ -747,6 +736,8 @@ static lv_design_res_t lv_btnm_design(lv_obj_t * btnm, const lv_area_t * clip_ar
lv_draw_label(&area_tmp, clip_area, draw_label_dsc_act, txt, NULL);
}
} else if(mode == LV_DESIGN_DRAW_POST) {
ancestor_design_f(btnm, clip_area, mode);
}
return LV_DESIGN_RES_OK;
}

View File

@@ -52,55 +52,51 @@ lv_obj_t * lv_cb_create(lv_obj_t * par, const lv_obj_t * copy)
LV_LOG_TRACE("check box create started");
/*Create the ancestor basic object*/
lv_obj_t * new_cb = lv_btn_create(par, copy);
LV_ASSERT_MEM(new_cb);
if(new_cb == NULL) return NULL;
lv_obj_t * cb = lv_btn_create(par, copy);
LV_ASSERT_MEM(cb);
if(cb == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_cb);
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(cb);
lv_cb_ext_t * ext = lv_obj_allocate_ext_attr(new_cb, sizeof(lv_cb_ext_t));
lv_cb_ext_t * ext = lv_obj_allocate_ext_attr(cb, sizeof(lv_cb_ext_t));
LV_ASSERT_MEM(ext);
if(ext == NULL) {
lv_obj_del(new_cb);
lv_obj_del(cb);
return NULL;
}
ext->bullet = NULL;
ext->label = NULL;
lv_obj_set_signal_cb(new_cb, lv_cb_signal);
lv_obj_set_signal_cb(cb, lv_cb_signal);
/*Init the new checkbox object*/
if(copy == NULL) {
ext->bullet = lv_obj_create(new_cb, NULL);
ext->bullet = lv_obj_create(cb, NULL);
lv_obj_set_click(ext->bullet, false);
ext->label = lv_label_create(new_cb, NULL);
ext->label = lv_label_create(cb, NULL);
lv_cb_set_text(new_cb, "Check box");
lv_btn_set_layout(new_cb, LV_LAYOUT_ROW_M);
lv_btn_set_fit(new_cb, LV_FIT_TIGHT);
lv_btn_set_toggle(new_cb, true);
lv_obj_set_protect(new_cb, LV_PROTECT_PRESS_LOST);
lv_cb_set_text(cb, "Check box");
lv_btn_set_layout(cb, LV_LAYOUT_ROW_M);
lv_btn_set_fit(cb, LV_FIT_TIGHT);
lv_btn_set_toggle(cb, true);
lv_obj_set_protect(cb, LV_PROTECT_PRESS_LOST);
lv_obj_reset_style(new_cb, LV_CB_PART_BG);
// lv_obj_reset_style(new_cb, LV_CB_PART_BULLET);
_ot(new_cb, LV_CB_PART_BG, CB);
_ot(new_cb, LV_CB_PART_BULLET, CB_BULLET);
lv_theme_apply(cb, LV_THEME_CB);
} else {
lv_cb_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
ext->bullet = lv_obj_create(new_cb, copy_ext->bullet);
ext->label = lv_label_create(new_cb, copy_ext->label);
ext->bullet = lv_obj_create(cb, copy_ext->bullet);
ext->label = lv_label_create(cb, copy_ext->label);
/*Refresh the style with new signal function*/
// lv_obj_refresh_style(new_cb);
// lv_obj_refresh_style(cb);
}
LV_LOG_INFO("check box created");
return new_cb;
return cb;
}
/*=====================
@@ -185,9 +181,7 @@ static lv_res_t lv_cb_signal(lv_obj_t * cb, lv_signal_t sign, void * param)
const lv_font_t * font = lv_obj_get_style_ptr(ext->label, LV_LABEL_PART_MAIN, LV_STYLE_FONT);
lv_coord_t line_height = lv_font_get_line_height(font);
lv_obj_set_size(ext->bullet, line_height, line_height);
ext->bullet->state = cb->state;
ext->bullet->prev_state = cb->state;
lv_obj_refresh_style(ext->bullet);
lv_btn_set_state(ext->bullet, lv_btn_get_state(cb));
} else if(sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_PRESS_LOST) {
lv_btn_set_state(ext->bullet, lv_btn_get_state(cb));
} else if(sign == LV_SIGNAL_CONTROL) {

View File

@@ -25,7 +25,6 @@
#define LV_CHART_HDIV_DEF 3
#define LV_CHART_VDIV_DEF 5
#define LV_CHART_PNUM_DEF 10
#define LV_CHART_AXIS_TO_LABEL_DISTANCE 4
#define LV_CHART_AXIS_MAJOR_TICK_LEN_COE 1 / 15
#define LV_CHART_AXIS_MINOR_TICK_LEN_COE 2 / 3
#define LV_CHART_AXIS_PRIMARY_Y 1
@@ -88,15 +87,15 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy)
LV_LOG_TRACE("chart create started");
/*Create the ancestor basic object*/
lv_obj_t * new_chart = lv_obj_create(par, copy);
LV_ASSERT_MEM(new_chart);
if(new_chart == NULL) return NULL;
lv_obj_t * chart = lv_obj_create(par, copy);
LV_ASSERT_MEM(chart);
if(chart == NULL) return NULL;
/*Allocate the object type specific extended data*/
lv_chart_ext_t * ext = lv_obj_allocate_ext_attr(new_chart, sizeof(lv_chart_ext_t));
lv_chart_ext_t * ext = lv_obj_allocate_ext_attr(chart, sizeof(lv_chart_ext_t));
LV_ASSERT_MEM(ext);
if(ext == NULL) {
lv_obj_del(new_chart);
lv_obj_del(chart);
return NULL;
}
@@ -123,20 +122,17 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy)
lv_style_list_init(&ext->style_series_bg);
lv_style_list_init(&ext->style_series);
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_chart);
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_chart);
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(chart);
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(chart);
lv_obj_set_signal_cb(new_chart, lv_chart_signal);
lv_obj_set_design_cb(new_chart, lv_chart_design);
lv_obj_set_signal_cb(chart, lv_chart_signal);
lv_obj_set_design_cb(chart, lv_chart_design);
/*Init the new chart background object*/
if(copy == NULL) {
lv_obj_set_size(new_chart, LV_DPI * 3, LV_DPI * 2);
lv_obj_set_size(chart, LV_DPI * 3, LV_DPI * 2);
lv_style_list_reset(&new_chart->style_list);
lv_obj_add_theme(new_chart, LV_CHART_PART_BG, LV_THEME_CHART_BG);
lv_obj_add_theme(new_chart, LV_CHART_PART_SERIES_BG, LV_THEME_CHART_SERIES_BG);
lv_obj_add_theme(new_chart, LV_CHART_PART_SERIES, LV_THEME_CHART_SERIES);
lv_theme_apply(chart, LV_THEME_CHART);
} else {
lv_chart_ext_t * ext_copy = lv_obj_get_ext_attr(copy);
@@ -152,12 +148,12 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy)
memcpy(&ext->secondary_y_axis, &ext_copy->secondary_y_axis, sizeof(lv_chart_axis_cfg_t));
/*Refresh the style with new signal function*/
lv_obj_refresh_style(new_chart);
lv_obj_refresh_style(chart);
}
LV_LOG_INFO("chart created");
return new_chart;
return chart;
}
/*======================
@@ -798,7 +794,7 @@ static void draw_series_line(lv_obj_t * chart, const lv_area_t * series_area, co
has_fade = area_dsc.bg_grad_dir == LV_GRAD_DIR_VER ? true : false;
if(has_fade) {
lv_draw_mask_fade_init(&mask_fade_p, &chart->coords, area_dsc.bg_grad_color_stop, chart->coords.y1, area_dsc.bg_main_color_stop, chart->coords.y2);
lv_draw_mask_fade_init(&mask_fade_p, &chart->coords, area_dsc.bg_main_color_stop, chart->coords.y1, area_dsc.bg_grad_color_stop, chart->coords.y2);
}
}
@@ -828,7 +824,6 @@ static void draw_series_line(lv_obj_t * chart, const lv_area_t * series_area, co
p2.y = h - y_tmp + y_ofs;
for(i = 0; i < ext->point_cnt; i++) {
p1.x = p2.x;
p1.y = p2.y;
@@ -899,7 +894,8 @@ static void draw_series_line(lv_obj_t * chart, const lv_area_t * series_area, co
point_area.y1 -= point_radius;
if(ser->points[p_act] != LV_CHART_POINT_DEF) {
lv_draw_rect(&point_area, &series_mask, &point_dsc);
/*Don't limit to `series_mask` to get full circles on the ends*/
lv_draw_rect(&point_area, clip_area, &point_dsc);
}
}
}
@@ -1199,6 +1195,8 @@ static void draw_y_ticks(lv_obj_t * chart, const lv_area_t * series_area, const
else
num_scale_ticks = (y_axis->num_tick_marks * (num_of_labels - 1));
lv_style_int_t label_dist = lv_obj_get_style_int(chart, LV_CHART_PART_SERIES_BG, which_axis == LV_CHART_AXIS_PRIMARY_Y ? LV_STYLE_PAD_LEFT : LV_STYLE_PAD_RIGHT);
lv_draw_line_dsc_t line_dsc;
lv_draw_line_dsc_init(&line_dsc);
lv_obj_init_draw_line_dsc(chart, LV_CHART_PART_BG, &line_dsc);
@@ -1256,11 +1254,11 @@ static void draw_y_ticks(lv_obj_t * chart, const lv_area_t * series_area, const
lv_area_t a = {.y1 = p2.y - size.y / 2, .y2 = p2.y + size.y / 2};
if(which_axis == LV_CHART_AXIS_PRIMARY_Y) {
a.x1 = p2.x - size.x - LV_CHART_AXIS_TO_LABEL_DISTANCE;
a.x2 = p2.x - LV_CHART_AXIS_TO_LABEL_DISTANCE;
a.x1 = p2.x - size.x - label_dist;
a.x2 = p2.x - label_dist;
} else {
a.x1 = p2.x + LV_CHART_AXIS_TO_LABEL_DISTANCE;
a.x2 = p2.x + size.x + LV_CHART_AXIS_TO_LABEL_DISTANCE;
a.x1 = p2.x + label_dist;
a.x2 = p2.x + size.x + label_dist;
}
lv_draw_label(&a, mask, &label_dsc, buf, NULL);
@@ -1312,6 +1310,9 @@ static void draw_x_ticks(lv_obj_t * chart, const lv_area_t * series_area, const
else
num_scale_ticks = (ext->x_axis.num_tick_marks * (num_of_labels - 1));
lv_style_int_t label_dist = lv_obj_get_style_int(chart, LV_CHART_PART_SERIES_BG, LV_STYLE_PAD_BOTTOM);
lv_draw_line_dsc_t line_dsc;
lv_draw_line_dsc_init(&line_dsc);
lv_obj_init_draw_line_dsc(chart, LV_CHART_PART_BG, &line_dsc);
@@ -1350,8 +1351,8 @@ static void draw_x_ticks(lv_obj_t * chart, const lv_area_t * series_area, const
LV_COORD_MAX, LV_TXT_FLAG_CENTER);
/* set the area at some distance of the major tick len under of the tick */
lv_area_t a = {(p2.x - size.x / 2), (p2.y + LV_CHART_AXIS_TO_LABEL_DISTANCE), (p2.x + size.x / 2),
(p2.y + size.y + LV_CHART_AXIS_TO_LABEL_DISTANCE)};
lv_area_t a = {(p2.x - size.x / 2), (p2.y + label_dist), (p2.x + size.x / 2),
(p2.y + size.y + label_dist)};
lv_draw_label(&a, mask, &label_dsc, buf, NULL);
}
}

View File

@@ -279,9 +279,8 @@ static lv_res_t lv_cont_signal(lv_obj_t * cont, lv_signal_t sign, void * param)
lv_cont_refr_autofit(cont);
}
} else if(sign == LV_SIGNAL_PARENT_SIZE_CHG) {
/*FLOOD and FILL fit needs to be refreshed if the parent size has changed*/
/*FLOOD and FILL fit needs to be refreshed if the parent's size has changed*/
lv_cont_refr_autofit(cont);
}
return res;
@@ -729,9 +728,8 @@ static void lv_cont_refr_autofit(lv_obj_t * cont)
}
/*Tell the children the parent's size has changed*/
LV_LL_READ(cont->child_ll, child_i)
{
child_i->signal_cb(child_i, LV_SIGNAL_PARENT_SIZE_CHG, NULL);
LV_LL_READ(cont->child_ll, child_i) {
child_i->signal_cb(child_i, LV_SIGNAL_PARENT_SIZE_CHG, &ori);
}
}
}

View File

@@ -79,18 +79,18 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy)
LV_LOG_TRACE("page create started");
/*Create the ancestor object*/
lv_obj_t * new_page = lv_cont_create(par, copy);
LV_ASSERT_MEM(new_page);
if(new_page == NULL) return NULL;
lv_obj_t * page = lv_cont_create(par, copy);
LV_ASSERT_MEM(page);
if(page == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_page);
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_page);
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(page);
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(page);
/*Allocate the object type specific extended data*/
lv_page_ext_t * ext = lv_obj_allocate_ext_attr(new_page, sizeof(lv_page_ext_t));
lv_page_ext_t * ext = lv_obj_allocate_ext_attr(page, sizeof(lv_page_ext_t));
LV_ASSERT_MEM(ext);
if(ext == NULL) {
lv_obj_del(new_page);
lv_obj_del(page);
return NULL;
}
@@ -112,11 +112,9 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy)
ext->scroll_prop = 0;
ext->scroll_prop_obj = NULL;
/*Init the new page object*/
if(copy == NULL) {
ext->scrl = lv_cont_create(new_page, NULL);
ext->scrl = lv_cont_create(page, NULL);
lv_obj_set_drag(ext->scrl, true);
lv_obj_set_drag_throw(ext->scrl, true);
lv_obj_set_protect(ext->scrl, LV_PROTECT_PARENT | LV_PROTECT_PRESS_LOST);
@@ -127,36 +125,36 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy)
/* Add the signal function only if 'scrolling' is created
+ * because everything has to be ready before any signal is received*/
lv_obj_set_signal_cb(new_page, lv_page_signal);
lv_obj_set_design_cb(new_page, lv_page_design);
lv_obj_set_signal_cb(page, lv_page_signal);
lv_obj_set_design_cb(page, lv_page_design);
lv_page_set_sb_mode(new_page, ext->sb.mode);
lv_page_set_sb_mode(page, ext->sb.mode);
lv_obj_refresh_style(new_page);
lv_theme_apply(page, LV_THEME_PAGE);
} else {
lv_page_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
ext->scrl = lv_cont_create(new_page, copy_ext->scrl);
ext->scrl = lv_cont_create(page, copy_ext->scrl);
lv_obj_set_signal_cb(ext->scrl, lv_page_scrollable_signal);
/* Add the signal function only if 'scrolling' is created
* because everything has to be ready before any signal is received*/
lv_obj_set_signal_cb(new_page, lv_page_signal);
lv_obj_set_design_cb(new_page, lv_page_design);
lv_obj_set_signal_cb(page, lv_page_signal);
lv_obj_set_design_cb(page, lv_page_design);
// lv_page_set_style(new_page, LV_PAGE_STYLE_BG, lv_page_get_style(copy, LV_PAGE_STYLE_BG));
// lv_page_set_style(new_page, LV_PAGE_STYLE_SCRL, lv_page_get_style(copy, LV_PAGE_STYLE_SCRL));
// lv_page_set_style(new_page, LV_PAGE_STYLE_SCRLBAR, lv_page_get_style(copy, LV_PAGE_STYLE_SCRLBAR));
lv_page_set_sb_mode(new_page, copy_ext->sb.mode);
lv_page_set_sb_mode(page, copy_ext->sb.mode);
}
lv_page_sb_refresh(new_page);
lv_page_sb_refresh(page);
LV_LOG_INFO("page created");
return new_page;
return page;
}
/**

View File

@@ -91,6 +91,7 @@ lv_obj_t * lv_slider_create(lv_obj_t * par, const lv_obj_t * copy)
lv_style_list_init(&ext->style_knob);
lv_theme_apply(new_slider, LV_THEME_SLIDER);
lv_obj_set_height(new_slider, LV_DPI / 15);
}
/*Copy an existing slider*/
else {
@@ -198,7 +199,7 @@ static lv_design_res_t lv_slider_design(lv_obj_t * slider, const lv_area_t * cli
}
lv_slider_position_knob(slider, &knob_area, knob_size, hor);
lv_area_copy(&ext->left_knob_area, &knob_area);
lv_area_copy(&ext->right_knob_area, &knob_area);
lv_slider_draw_knob(slider, &knob_area, clip_area);
if(lv_slider_get_type(slider) == LV_SLIDER_TYPE_RANGE) {
@@ -210,7 +211,7 @@ static lv_design_res_t lv_slider_design(lv_obj_t * slider, const lv_area_t * cli
}
lv_slider_position_knob(slider, &knob_area, knob_size, hor);
lv_area_copy(&ext->right_knob_area, &knob_area);
lv_area_copy(&ext->left_knob_area, &knob_area);
lv_slider_draw_knob(slider, &knob_area, clip_area);
}
}
@@ -254,21 +255,27 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par
lv_indev_get_point(param, &p);
bool hor = lv_obj_get_width(slider) >= lv_obj_get_height(slider);
/* Calculate the distance from each knob */
lv_coord_t dist_left, dist_right;
if(hor) {
dist_left = LV_MATH_ABS((ext->left_knob_area.x1+(ext->left_knob_area.x2 - ext->left_knob_area.x1)/2) - p.x);
dist_right = LV_MATH_ABS((ext->right_knob_area.x1+(ext->right_knob_area.x2 - ext->right_knob_area.x1)/2) - p.x);
if(p.x > ext->right_knob_area.x2) {
ext->value_to_set = &ext->bar.cur_value;
}
else if(p.x < ext->left_knob_area.x1) {
ext->value_to_set = &ext->bar.start_value;
} else {
/* Calculate the distance from each knob */
dist_left = LV_MATH_ABS((ext->left_knob_area.x1+(ext->left_knob_area.x2 - ext->left_knob_area.x1)/2) - p.x);
dist_right = LV_MATH_ABS((ext->right_knob_area.x1+(ext->right_knob_area.x2 - ext->right_knob_area.x1)/2) - p.x);
/* Use whichever one is closer */
if(dist_right < dist_left)ext->value_to_set = &ext->bar.cur_value;
else ext->value_to_set = &ext->bar.start_value;
}
} else {
dist_left = LV_MATH_ABS((ext->left_knob_area.y1+(ext->left_knob_area.y2 - ext->left_knob_area.y1)/2) - p.y);
dist_right = LV_MATH_ABS((ext->right_knob_area.y1+(ext->right_knob_area.y2 - ext->right_knob_area.y1)/2) - p.y);
}
/* Use whichever one is closer */
if(dist_right > dist_left)
ext->value_to_set = &ext->bar.cur_value;
else
ext->value_to_set = &ext->bar.start_value;
} else
ext->value_to_set = &ext->bar.cur_value;
} else if(sign == LV_SIGNAL_PRESSING && ext->value_to_set != NULL) {
@@ -283,7 +290,9 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par
lv_style_int_t bg_bottom = lv_obj_get_style_int(slider, LV_SLIDER_PART_BG, LV_STYLE_PAD_BOTTOM);
int32_t range = ext->bar.max_value - ext->bar.min_value;
int16_t new_value = 0, real_max_value = ext->bar.max_value, real_min_value = ext->bar.min_value;
int16_t new_value = 0;
int16_t real_max_value = ext->bar.max_value;
int16_t real_min_value = ext->bar.min_value;
if(w >= h) {
lv_coord_t indic_w = w - bg_left - bg_right;
@@ -298,20 +307,20 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par
}
/* Figure out the min. and max. for this mode */
if(ext->value_to_set == &ext->bar.start_value) {
real_max_value = ext->bar.cur_value;
} else
real_min_value = ext->bar.start_value;
/* Figure out the min. and max. for this mode */
if(ext->value_to_set == &ext->bar.start_value) {
real_max_value = ext->bar.cur_value;
} else {
real_min_value = ext->bar.start_value;
}
if(new_value < real_min_value) new_value = real_min_value;
if(new_value < real_min_value) new_value = real_min_value;
else if(new_value > real_max_value) new_value = real_max_value;
if(new_value != ext->bar.cur_value) {
*ext->value_to_set = new_value;
lv_obj_invalidate(slider);
res = lv_event_send(slider, LV_EVENT_VALUE_CHANGED, NULL);
if(res != LV_RES_OK) return res;
if(*ext->value_to_set != new_value) {
*ext->value_to_set = new_value;
lv_obj_invalidate(slider);
res = lv_event_send(slider, LV_EVENT_VALUE_CHANGED, NULL);
if(res != LV_RES_OK) return res;
}
} else if(sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_PRESS_LOST) {

View File

@@ -89,6 +89,7 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy)
/*Initialize the allocated 'ext' */
ext->tab_cur = 0;
ext->tab_cnt = 0;
ext->point_last.x = 0;
ext->point_last.y = 0;
ext->content = NULL;
@@ -108,7 +109,6 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy)
LV_ASSERT_MEM(ext->tab_name_ptr);
if(ext->tab_name_ptr == NULL) return NULL;
ext->tab_name_ptr[0] = "";
ext->tab_cnt = 0;
/* Set a size which fits into the parent.
* Don't use `par` directly because if the tabview is created on a page it is moved to the
@@ -156,19 +156,23 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy)
ext->tab_name_ptr[0] = "";
lv_btnm_set_map(ext->btns, ext->tab_name_ptr);
// uint16_t i;
// lv_obj_t * new_tab;
// lv_obj_t * copy_tab;
// for(i = 0; i < copy_ext->tab_cnt; i++) {
// new_tab = lv_tabview_add_tab(new_tabview, copy_ext->tab_name_ptr[i]);
// copy_tab = lv_tabview_get_tab(copy, i);
//// lv_page_set_style(new_tab, LV_PAGE_STYLE_BG, lv_page_get_style(copy_tab, LV_PAGE_STYLE_BG));
//// lv_page_set_style(new_tab, LV_PAGE_STYLE_SCRL, lv_page_get_style(copy_tab, LV_PAGE_STYLE_SCRL));
//// lv_page_set_style(new_tab, LV_PAGE_STYLE_SB, lv_page_get_style(copy_tab, LV_PAGE_STYLE_SB));
// }
//
// /*Refresh the style with new signal function*/
// lv_obj_refresh_style(new_tabview);
lv_style_list_copy(lv_obj_get_style(tabview, LV_TABVIEW_PART_BG_SCRL), lv_obj_get_style(copy, LV_TABVIEW_PART_BG_SCRL));
lv_style_list_copy(lv_obj_get_style(tabview, LV_TABVIEW_PART_TAB_BG), lv_obj_get_style(copy, LV_TABVIEW_PART_TAB_BG));
lv_style_list_copy(lv_obj_get_style(tabview, LV_TABVIEW_PART_TAB), lv_obj_get_style(copy, LV_TABVIEW_PART_TAB));
uint16_t i;
lv_obj_t * new_tab;
lv_obj_t * copy_tab;
for(i = 0; i < copy_ext->tab_cnt; i++) {
new_tab = lv_tabview_add_tab(tabview, copy_ext->tab_name_ptr[i]);
copy_tab = lv_tabview_get_tab(copy, i);
lv_style_list_copy(lv_obj_get_style(new_tab, LV_PAGE_PART_SCRL), lv_obj_get_style(copy_tab, LV_PAGE_PART_SCRL));
lv_style_list_copy(lv_obj_get_style(new_tab, LV_PAGE_PART_SCRLBAR), lv_obj_get_style(copy_tab, LV_PAGE_PART_SCRLBAR));
lv_obj_refresh_style(new_tab);
}
/*Refresh the style with new signal function*/
lv_obj_refresh_style(tabview);
}
tabview_realign(tabview);

View File

@@ -36,25 +36,12 @@ extern "C" {
typedef enum {
LV_THEME_NONE = 0,
LV_THEME_SCR,
LV_THEME_SCR_TRANSP,
LV_THEME_PANEL,
LV_THEME_PANEL_TRANSP,
LV_THEME_PANEL_FRAME,
LV_THEME_PANEL_TIGHT,
LV_THEME_PANEL_FIT,
LV_THEME_BTN,
LV_THEME_BTN_DANGER,
LV_THEME_BTN_APPROVE,
LV_THEME_BTN_TRANSP,
LV_THEME_BTN_FRAME,
LV_THEME_BTN_LARGE,
LV_THEME_BTN_SMALL,
LV_THEME_LABEL,
LV_THEME_LABEL_TITLE,
LV_THEME_LABEL_HINT,
LV_THEME_BTNM,
LV_THEME_BTNM_BTN,
@@ -68,6 +55,8 @@ typedef enum {
LV_THEME_CB,
LV_THEME_CB_BULLET,
LV_THEME_PAGE,
LV_THEME_DDLIST_BG,
LV_THEME_DDLIST_SCRL,
LV_THEME_DDLIST_SCRLBAR,
@@ -117,6 +106,7 @@ typedef enum {
LV_THEME_TABLE_CELL3,
LV_THEME_TABLE_CELL4,
LV_THEME_CHART,
LV_THEME_CHART_BG,
LV_THEME_CHART_SERIES_BG,
LV_THEME_CHART_SERIES,
@@ -126,7 +116,6 @@ typedef enum {
typedef struct {
lv_style_t * (*get_style_cb)(lv_theme_style_t);
void (*apply_cb)(lv_obj_t *,lv_theme_style_t);
lv_style_t * (*get_style_part_cb)(lv_theme_style_t name, uint8_t part);
}lv_theme_t;
/**********************

View File

@@ -14,9 +14,17 @@
/*********************
* DEFINES
*********************/
#define COLOR_BG lv_color_hex(0x22252a)
#define COLOR_PANEL lv_color_hex(0x282b30)
#define COLOR_PRIMARY lv_color_hex(0x007aff)
//#define COLOR_SCREEN lv_color_hex3(0x34a)
//#define COLOR_CONTAINER lv_color_hex3(0x888)
//#define COLOR_BACKGROUND lv_color_hex3(0x0f0)
//#define COLOR_ACCENT lv_color_hex3(0xf00)
//#define COLOR_DISABLED lv_color_hex3(0x999)
#define COLOR_SCREEN lv_color_hex(0x22252a)
#define COLOR_CONTAINER lv_color_hex(0x282b30)
#define COLOR_BACKGROUND lv_color_hex(0x2e3136)
#define COLOR_ACCENT lv_color_hex(0x007aff)
#define COLOR_DISABLED lv_color_hex(0x444444)
/**********************
* TYPEDEFS
@@ -34,11 +42,16 @@ void lv_theme_alien_apply(lv_obj_t * obj, lv_theme_style_t name);
static lv_theme_t theme;
static lv_style_t scr;
static lv_style_t transp;
static lv_style_t panel; /*General fancy background (e.g. to chart or ta)*/
static lv_style_t btn;
static lv_style_t sb;
#if LV_USE_BTNM
static lv_style_t btnm_bg;
static lv_style_t btnm_btn;
#endif
#if LV_USE_BAR
static lv_style_t bar_bg;
static lv_style_t bar_indic;
@@ -52,6 +65,10 @@ static lv_style_t slider_knob;
static lv_style_t sw_knob;
#endif
#if LV_USE_CB
static lv_style_t cb_bg, cb_bullet;
#endif
#if LV_USE_LMETER
static lv_style_t lmeter;
#endif
@@ -80,7 +97,7 @@ static lv_style_t calendar_date_nums;
#if LV_USE_TABVIEW
static lv_style_t tabview_btns, tabview_btns_bg, tabview_indic;
static lv_style_t tabview_btns, tabview_btns_bg, tabview_indic, tabaview_page_scrl;
#endif
#if LV_USE_TABLE
@@ -88,8 +105,9 @@ static lv_style_t table_cell;
#endif
#if LV_USE_CHART
static lv_style_t chart_series;
static lv_style_t chart_series_bg, chart_series;
#endif
/**********************
* MACROS
**********************/
@@ -102,14 +120,14 @@ static void basic_init(void)
{
lv_style_init(&scr);
lv_style_set_opa(&scr, LV_STYLE_BG_OPA, LV_OPA_COVER);
lv_style_set_color(&scr, LV_STYLE_BG_COLOR, COLOR_BG);
lv_style_set_color(&scr, LV_STYLE_BG_COLOR, COLOR_SCREEN);
lv_style_set_color(&scr, LV_STYLE_TEXT_COLOR , lv_color_hex(0xb8b8b9));
lv_style_init(&panel);
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_color(&panel, LV_STYLE_BG_COLOR, COLOR_PANEL);
lv_style_set_color(&panel, LV_STYLE_BORDER_COLOR, lv_color_hex(0x3a3d42));
lv_style_set_color(&panel, LV_STYLE_BG_COLOR, COLOR_CONTAINER);
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_SIDE , LV_BORDER_SIDE_TOP);
lv_style_set_int(&panel, LV_STYLE_PAD_LEFT, LV_DPI / 5);
@@ -120,15 +138,17 @@ static void basic_init(void)
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_color(&panel, LV_STYLE_IMAGE_RECOLOR, lv_color_hex(0x979a9f));
lv_style_set_color(&panel, LV_STYLE_LINE_COLOR, lv_color_hex(0x979a9f));
lv_style_set_int(&panel, LV_STYLE_LINE_WIDTH, 1);
lv_style_init(&btn);
lv_style_set_int(&btn, LV_STYLE_RADIUS, LV_RADIUS_CIRCLE);
lv_style_set_opa(&btn, LV_STYLE_BG_OPA, LV_OPA_COVER);
lv_style_set_color(&btn, LV_STYLE_BG_COLOR, COLOR_PRIMARY);
lv_style_set_color(&btn, LV_STYLE_BG_COLOR | LV_STYLE_STATE_PRESSED, lv_color_hex(0x005ec4));
lv_style_set_color(&btn, LV_STYLE_BG_COLOR | LV_STYLE_STATE_DISABLED, lv_color_hex(0x2f3237));
lv_style_set_color(&btn, LV_STYLE_BG_COLOR, COLOR_ACCENT);
lv_style_set_color(&btn, LV_STYLE_BG_COLOR | LV_STYLE_STATE_PRESSED, lv_color_darken(COLOR_ACCENT, LV_OPA_20));
lv_style_set_color(&btn, LV_STYLE_BG_COLOR | LV_STYLE_STATE_DISABLED, COLOR_DISABLED);
lv_style_set_color(&btn, LV_STYLE_TEXT_COLOR, lv_color_hex(0xffffff));
lv_style_set_color(&btn, LV_STYLE_TEXT_COLOR| LV_STYLE_STATE_PRESSED, lv_color_hex(0xdddddd));
lv_style_set_color(&btn, LV_STYLE_TEXT_COLOR| LV_STYLE_STATE_PRESSED, lv_color_darken(lv_color_hex(0xffffff), LV_OPA_20));
lv_style_set_color(&btn, LV_STYLE_TEXT_COLOR| LV_STYLE_STATE_DISABLED, lv_color_hex(0x686b70));
lv_style_set_color(&btn, LV_STYLE_IMAGE_RECOLOR, LV_COLOR_WHITE);
lv_style_set_int(&btn, LV_STYLE_PAD_LEFT, LV_DPI / 5);
@@ -136,7 +156,7 @@ static void basic_init(void)
lv_style_set_int(&btn, LV_STYLE_PAD_TOP, LV_DPI / 10);
lv_style_set_int(&btn, LV_STYLE_PAD_BOTTOM, LV_DPI / 10);
lv_style_set_int(&btn, LV_STYLE_PAD_INNER, LV_DPI / 10);
lv_style_set_int(&btn, LV_STYLE_TRANSITION_TIME, 1000);
lv_style_set_int(&btn, LV_STYLE_TRANSITION_TIME, 100);
}
static void cont_init(void)
@@ -149,84 +169,15 @@ static void cont_init(void)
static void btn_init(void)
{
#if LV_USE_BTN != 0
// lv_style_copy(&btn_rel, &def);
// btn_rel.glass = 0;
// btn_rel.body.opa = LV_OPA_TRANSP;
// btn_rel.body.radius = LV_RADIUS_CIRCLE;
// btn_rel.body.border.width = 2;
// btn_rel.body.border.color = lv_color_hsv_to_rgb(_hue, 70, 90);
// btn_rel.body.border.opa = LV_OPA_80;
// btn_rel.body.padding.left = LV_DPI / 4;
// btn_rel.body.padding.right = LV_DPI / 4;
// btn_rel.body.padding.top = LV_DPI / 6;
// btn_rel.body.padding.bottom = LV_DPI / 6;
// btn_rel.body.padding.inner = LV_DPI / 10;
// btn_rel.text.color = lv_color_hsv_to_rgb(_hue, 8, 96);
// btn_rel.text.font = _font;
// btn_rel.image.color = lv_color_hsv_to_rgb(_hue, 8, 96);
//
// lv_style_copy(&btn_pr, &btn_rel);
// btn_pr.body.opa = LV_OPA_COVER;
// btn_pr.body.main_color = lv_color_hsv_to_rgb(_hue, 50, 50);
// btn_pr.body.grad_color = lv_color_hsv_to_rgb(_hue, 50, 50);
// btn_pr.body.border.opa = LV_OPA_60;
// btn_pr.text.font = _font;
// btn_pr.text.color = lv_color_hsv_to_rgb(_hue, 10, 100);
// btn_pr.image.color = lv_color_hsv_to_rgb(_hue, 10, 100);
//
// lv_style_copy(&btn_trel, &btn_pr);
// btn_trel.body.opa = LV_OPA_COVER;
// btn_trel.body.main_color = lv_color_hsv_to_rgb(_hue, 50, 60);
// btn_trel.body.grad_color = lv_color_hsv_to_rgb(_hue, 50, 60);
// btn_trel.body.border.opa = LV_OPA_60;
// btn_trel.body.border.color = lv_color_hsv_to_rgb(_hue, 80, 90);
// btn_trel.text.font = _font;
// btn_trel.text.color = lv_color_hsv_to_rgb(_hue, 0, 100);
// btn_trel.image.color = lv_color_hsv_to_rgb(_hue, 0, 100);
//
// lv_style_copy(&btn_tpr, &btn_trel);
// btn_tpr.body.opa = LV_OPA_COVER;
// btn_tpr.body.main_color = lv_color_hsv_to_rgb(_hue, 50, 50);
// btn_tpr.body.grad_color = lv_color_hsv_to_rgb(_hue, 50, 50);
// btn_tpr.body.border.opa = LV_OPA_60;
// btn_tpr.body.border.color = lv_color_hsv_to_rgb(_hue, 80, 70);
// btn_tpr.text.font = _font;
// btn_tpr.text.color = lv_color_hsv_to_rgb(_hue, 10, 90);
// btn_tpr.image.color = lv_color_hsv_to_rgb(_hue, 10, 90);
//
// lv_style_copy(&btn_ina, &btn_rel);
// btn_ina.body.border.opa = LV_OPA_60;
// btn_ina.body.border.color = lv_color_hsv_to_rgb(_hue, 10, 50);
// btn_ina.text.font = _font;
// btn_ina.text.color = lv_color_hsv_to_rgb(_hue, 10, 90);
//
// theme.style.btn.rel = &btn_rel;
// theme.style.btn.pr = &btn_pr;
// theme.style.btn.tgl_rel = &btn_trel;
// theme.style.btn.tgl_pr = &btn_tpr;
// theme.style.btn.ina = &btn_ina;
#endif
}
static void label_init(void)
{
#if LV_USE_LABEL != 0
// static lv_style_t label_prim, label_sec, label_hint;
//
// lv_style_copy(&label_prim, &def);
// label_prim.text.font = _font;
// label_prim.text.color = lv_color_hsv_to_rgb(_hue, 80, 96);
//
// lv_style_copy(&label_sec, &label_prim);
// label_sec.text.color = lv_color_hsv_to_rgb(_hue, 40, 85);
//
// lv_style_copy(&label_hint, &label_prim);
// label_hint.text.color = lv_color_hsv_to_rgb(_hue, 20, 70);
//
// theme.style.label.prim = &label_prim;
// theme.style.label.sec = &label_sec;
// theme.style.label.hint = &label_hint;
#endif
#endif
}
static void bar_init(void)
@@ -235,14 +186,13 @@ static void bar_init(void)
lv_style_init(&bar_bg);
lv_style_set_int(&bar_bg, LV_STYLE_RADIUS, LV_RADIUS_CIRCLE);
lv_style_set_opa(&bar_bg, LV_STYLE_BG_OPA, LV_OPA_COVER);
lv_style_set_color(&bar_bg, LV_STYLE_BG_COLOR, COLOR_PANEL);
lv_style_set_color(&bar_bg, LV_STYLE_BG_COLOR, COLOR_BACKGROUND);
lv_style_init(&bar_indic);
lv_style_set_opa(&bar_indic, LV_STYLE_BG_OPA, LV_OPA_COVER);
lv_style_set_color(&bar_indic, LV_STYLE_BG_COLOR, LV_COLOR_MAROON);
lv_style_set_int(&bar_indic, LV_STYLE_RADIUS, LV_RADIUS_CIRCLE);
lv_style_set_color(&bar_indic, LV_STYLE_BG_COLOR, COLOR_PRIMARY);
lv_style_set_color(&bar_indic, LV_STYLE_BG_COLOR | LV_STYLE_STATE_DISABLED, lv_color_hex(0x4f5257));
lv_style_set_color(&bar_indic, LV_STYLE_BG_COLOR, COLOR_ACCENT);
lv_style_set_color(&bar_indic, LV_STYLE_BG_COLOR | LV_STYLE_STATE_DISABLED, COLOR_DISABLED);
#endif
}
@@ -351,12 +301,27 @@ static void preload_init(void)
static void chart_init(void)
{
#if LV_USE_CHART
lv_style_init(&chart_series_bg);
lv_style_set_int(&chart_series_bg, LV_STYLE_LINE_WIDTH , 1);
lv_style_set_int(&chart_series_bg, LV_STYLE_LINE_DASH_WIDTH, 4);
lv_style_set_int(&chart_series_bg, LV_STYLE_LINE_DASH_GAP, 4);
lv_style_set_int(&chart_series_bg, LV_STYLE_PAD_BOTTOM , LV_DPI / 10);
lv_style_set_int(&chart_series_bg, LV_STYLE_PAD_LEFT , LV_DPI / 10);
lv_style_set_int(&chart_series_bg, LV_STYLE_PAD_RIGHT , LV_DPI / 10);
lv_style_set_color(&chart_series_bg, LV_STYLE_LINE_COLOR, COLOR_DISABLED);
lv_style_init(&chart_series);
lv_style_set_int(&chart_series, LV_STYLE_LINE_WIDTH , 2);
lv_style_set_int(&chart_series, LV_STYLE_SIZE , 3);
lv_style_set_int(&chart_series, LV_STYLE_PAD_INNER , 2);
lv_style_set_int(&chart_series, LV_STYLE_RADIUS , 4);
lv_style_set_opa(&chart_series, LV_STYLE_BG_OPA , LV_OPA_COVER);
lv_style_set_opa(&chart_series, LV_STYLE_BG_OPA, LV_OPA_100);
lv_style_set_int(&chart_series, LV_STYLE_BG_GRAD_DIR, LV_GRAD_DIR_VER);
lv_style_set_int(&chart_series, LV_STYLE_BG_MAIN_STOP, 96);
lv_style_set_int(&chart_series, LV_STYLE_BG_GRAD_STOP, 32);
#endif
}
@@ -383,6 +348,19 @@ static void calendar_init(void)
static void cb_init(void)
{
#if LV_USE_CB != 0
lv_style_init(&cb_bg);
lv_style_set_int(&cb_bg, LV_STYLE_PAD_INNER , LV_DPI / 10);
lv_style_init(&cb_bullet);
lv_style_set_int(&cb_bullet, LV_STYLE_RADIUS, LV_DPI / 50);
lv_style_set_int(&cb_bullet, LV_STYLE_BORDER_WIDTH , 2);
lv_style_set_color(&cb_bullet, LV_STYLE_BORDER_COLOR , lv_color_hex(0x52555a));
lv_style_set_color(&cb_bullet, LV_STYLE_BORDER_COLOR | LV_STYLE_STATE_PRESSED , lv_color_darken(lv_color_hex(0x52555a), LV_OPA_30));
lv_style_set_color(&cb_bullet, LV_STYLE_BG_COLOR, COLOR_ACCENT);
lv_style_set_opa(&cb_bullet, LV_STYLE_BG_OPA | LV_STYLE_STATE_CHECKED , LV_OPA_COVER);
lv_style_set_opa(&cb_bullet, LV_STYLE_BORDER_OPA | LV_STYLE_STATE_CHECKED , LV_OPA_80);
lv_style_set_int(&cb_bullet, LV_STYLE_TRANSITION_TIME , 100);
#endif
@@ -391,38 +369,26 @@ static void cb_init(void)
static void btnm_init(void)
{
#if LV_USE_BTNM
// lv_style_copy(&btnm_bg, &lv_style_transp_tight);
// btnm_bg.body.border.width = 1;
// btnm_bg.body.border.color = lv_color_hsv_to_rgb(_hue, 60, 80);
// btnm_bg.body.border.opa = LV_OPA_COVER;
// btnm_bg.body.radius = LV_DPI / 8;
//
// lv_style_copy(&btnm_rel, &lv_style_plain);
// btnm_rel.body.opa = LV_OPA_TRANSP;
// btnm_rel.body.radius = LV_DPI / 8;
// btnm_rel.text.color = lv_color_hsv_to_rgb(_hue, 60, 80);
// btnm_rel.text.font = _font;
//
// lv_style_copy(&btnm_pr, &lv_style_plain);
// btnm_pr.body.main_color = lv_color_hsv_to_rgb(_hue, 40, 70);
// btnm_pr.body.grad_color = lv_color_hsv_to_rgb(_hue, 40, 70);
// btnm_pr.body.radius = LV_DPI / 8;
// btnm_pr.text.color = lv_color_hsv_to_rgb(_hue, 40, 40);
// btnm_pr.text.font = _font;
//
// lv_style_copy(&btnm_trel, &btnm_rel);
// btnm_trel.body.border.color = lv_color_hsv_to_rgb(_hue, 80, 80);
// btnm_trel.body.border.width = 3;
//
// lv_style_copy(&btnm_ina, &btnm_rel);
// btnm_ina.text.color = lv_color_hsv_to_rgb(_hue, 10, 60);
//
// theme.style.btnm.bg = &btnm_bg;
// theme.style.btnm.btn.rel = &btnm_rel;
// theme.style.btnm.btn.pr = &btnm_pr;
// theme.style.btnm.btn.tgl_rel = &btnm_trel;
// theme.style.btnm.btn.tgl_pr = &btnm_pr;
// theme.style.btnm.btn.ina = &btnm_ina;
lv_style_init(&btnm_bg);
lv_style_set_int(&btnm_bg, LV_STYLE_BORDER_WIDTH, LV_DPI / 50);
lv_style_set_color(&btnm_bg, LV_STYLE_BORDER_COLOR, lv_color_hex(0x373a3f));
lv_style_set_int(&btnm_bg, LV_STYLE_RADIUS, LV_DPI / 10);
lv_style_set_int(&btnm_bg, LV_STYLE_CLIP_CORNER, 1);
lv_style_init(&btnm_btn);
lv_style_set_int(&btnm_btn, LV_STYLE_BORDER_WIDTH, LV_DPI / 50);
lv_style_set_int(&btnm_btn, LV_STYLE_BORDER_SIDE, LV_BORDER_SIDE_FULL);
lv_style_set_color(&btnm_btn, LV_STYLE_BORDER_COLOR, lv_color_hex(0x373a3f));
lv_style_set_color(&btnm_btn, LV_STYLE_BG_COLOR | LV_STYLE_STATE_PRESSED, lv_color_hex3(0x666));
lv_style_set_color(&btnm_btn, LV_STYLE_BG_COLOR | LV_STYLE_STATE_CHECKED, COLOR_ACCENT);
lv_style_set_color(&btnm_btn, LV_STYLE_BG_COLOR | LV_STYLE_STATE_DISABLED, COLOR_DISABLED);
lv_style_set_color(&btnm_btn, LV_STYLE_BG_COLOR | LV_STYLE_STATE_CHECKED | LV_STYLE_STATE_PRESSED, lv_color_darken(COLOR_ACCENT, LV_OPA_40));
lv_style_set_color(&btnm_btn, LV_STYLE_TEXT_COLOR , LV_COLOR_WHITE);
lv_style_set_color(&btnm_btn, LV_STYLE_TEXT_COLOR | LV_STYLE_STATE_DISABLED , LV_COLOR_GRAY);
lv_style_set_opa(&btnm_btn, LV_STYLE_BG_OPA | LV_STYLE_STATE_CHECKED, LV_OPA_COVER);
lv_style_set_opa(&btnm_btn, LV_STYLE_BG_OPA | LV_STYLE_STATE_PRESSED, LV_OPA_COVER);
lv_style_set_opa(&btnm_btn, LV_STYLE_BG_OPA | LV_STYLE_STATE_DISABLED, LV_OPA_COVER);
#endif
}
@@ -442,9 +408,14 @@ static void mbox_init(void)
static void page_init(void)
{
#if LV_USE_PAGE
// theme.style.page.bg = &panel;
// theme.style.page.scrl = &lv_style_transp_fit;
// theme.style.page.sb = &sb;
lv_style_init(&sb);
lv_style_set_opa(&sb, LV_STYLE_BG_OPA, LV_OPA_COVER);
lv_style_set_color(&sb, LV_STYLE_BG_COLOR, lv_color_hex(0x3a3d42));
lv_style_set_int(&sb, LV_STYLE_RADIUS, LV_RADIUS_CIRCLE);
lv_style_set_int(&sb,LV_STYLE_SIZE, LV_DPI / 30);
lv_style_set_int(&sb,LV_STYLE_PAD_RIGHT, LV_DPI / 10);
lv_style_set_int(&sb,LV_STYLE_PAD_BOTTOM, LV_DPI / 10);
#endif
}
@@ -494,7 +465,9 @@ static void tabview_init(void)
{
#if LV_USE_TABVIEW != 0
lv_style_init(&tabview_btns_bg);
lv_style_set_color(&tabview_btns_bg, LV_STYLE_BORDER_COLOR, lv_color_hex(0x3a3d42));
lv_style_set_opa(&tabview_btns_bg, LV_STYLE_BG_OPA, LV_OPA_COVER);
lv_style_set_color(&tabview_btns_bg, LV_STYLE_BG_COLOR, COLOR_CONTAINER);
lv_style_set_color(&tabview_btns_bg, LV_STYLE_BORDER_COLOR, lv_color_lighten(COLOR_CONTAINER, LV_OPA_10));
lv_style_set_int(&tabview_btns_bg, LV_STYLE_BORDER_WIDTH, LV_DPI / 30 > 0 ? LV_DPI / 30 : 1);
lv_style_set_int(&tabview_btns_bg, LV_STYLE_BORDER_SIDE , LV_BORDER_SIDE_BOTTOM);
lv_style_set_color(&tabview_btns_bg, LV_STYLE_TEXT_COLOR, lv_color_hex(0x979a9f));
@@ -504,17 +477,24 @@ static void tabview_init(void)
lv_style_init(&tabview_btns);
lv_style_set_opa(&tabview_btns, LV_STYLE_BG_OPA | LV_STYLE_STATE_PRESSED, LV_OPA_COVER);
lv_style_set_color(&tabview_btns, LV_STYLE_BG_COLOR | LV_STYLE_STATE_PRESSED, lv_color_hex(0x666666));
lv_style_set_color(&tabview_btns, LV_STYLE_TEXT_COLOR | LV_STYLE_STATE_CHECKED, COLOR_PRIMARY);
lv_style_set_color(&tabview_btns, LV_STYLE_BG_COLOR | LV_STYLE_STATE_PRESSED, lv_color_hex(0x444444));
lv_style_set_color(&tabview_btns, LV_STYLE_TEXT_COLOR | LV_STYLE_STATE_CHECKED, COLOR_ACCENT);
lv_style_set_int(&tabview_btns, LV_STYLE_PAD_TOP, LV_DPI / 5);
lv_style_set_int(&tabview_btns, LV_STYLE_PAD_BOTTOM, LV_DPI / 5);
lv_style_init(&tabview_indic);
lv_style_set_opa(&tabview_indic, LV_STYLE_BG_OPA, LV_OPA_COVER);
lv_style_set_color(&tabview_indic, LV_STYLE_BG_COLOR, COLOR_PRIMARY);
lv_style_set_color(&tabview_indic, LV_STYLE_BG_COLOR, COLOR_ACCENT);
lv_style_set_int(&tabview_indic, LV_STYLE_SIZE, LV_DPI / 20 > 0 ? LV_DPI / 20 : 1);
lv_style_set_int(&tabview_indic, LV_STYLE_RADIUS, LV_RADIUS_CIRCLE);
lv_style_init(&tabaview_page_scrl);
lv_style_set_int(&tabaview_page_scrl, LV_STYLE_PAD_TOP, LV_DPI / 5);
lv_style_set_int(&tabaview_page_scrl, LV_STYLE_PAD_BOTTOM, LV_DPI / 5);
lv_style_set_int(&tabaview_page_scrl, LV_STYLE_PAD_LEFT, LV_DPI / 3);
lv_style_set_int(&tabaview_page_scrl, LV_STYLE_PAD_RIGHT, LV_DPI / 3);
lv_style_set_int(&tabaview_page_scrl, LV_STYLE_PAD_INNER, LV_DPI / 5);
#endif
}
@@ -643,6 +623,15 @@ void lv_theme_alien_apply(lv_obj_t * obj, lv_theme_style_t name)
lv_style_list_add_style(list, &btn);
break;
case LV_THEME_BTNM:
list = lv_obj_get_style(obj, LV_BTNM_PART_BG);
lv_style_list_reset(list);
lv_style_list_add_style(list, &btnm_bg);
list = lv_obj_get_style(obj, LV_BTNM_PART_BTN);
lv_style_list_reset(list);
lv_style_list_add_style(list, &btnm_btn);
break;
case LV_THEME_BAR:
list = lv_obj_get_style(obj, LV_BAR_PART_BG);
lv_style_list_reset(list);
@@ -667,6 +656,7 @@ void lv_theme_alien_apply(lv_obj_t * obj, lv_theme_style_t name)
lv_style_list_add_style(list, &sw_knob);
break;
#if LV_USE_SLIDER
case LV_THEME_SLIDER:
list = lv_obj_get_style(obj, LV_SLIDER_PART_BG);
lv_style_list_reset(list);
@@ -680,11 +670,38 @@ void lv_theme_alien_apply(lv_obj_t * obj, lv_theme_style_t name)
lv_style_list_reset(list);
lv_style_list_add_style(list, &slider_knob);
break;
#endif
#if LV_USE_CB
case LV_THEME_CB:
list = lv_obj_get_style(obj, LV_CB_PART_BG);
lv_style_list_reset(list);
lv_style_list_add_style(list, &cb_bg);
list = lv_obj_get_style(obj, LV_CB_PART_BULLET);
lv_style_list_reset(list);
lv_style_list_add_style(list, &cb_bullet);
break;
#endif
#if LV_USE_PAGE
case LV_THEME_PAGE:
list = lv_obj_get_style(obj, LV_PAGE_PART_BG);
lv_style_list_reset(list);
lv_style_list_add_style(list, &panel);
list = lv_obj_get_style(obj, LV_PAGE_PART_SCRL);
lv_style_list_reset(list);
list = lv_obj_get_style(obj, LV_PAGE_PART_SCRLBAR);
lv_style_list_reset(list);
lv_style_list_add_style(list, &sb);
break;
#endif
#if LV_USE_TABVIEW
case LV_THEME_TABVIEW:
list = lv_obj_get_style(obj, LV_TABVIEW_PART_BG);
lv_style_list_reset(list);
lv_style_list_add_style(list, &scr);
list = lv_obj_get_style(obj, LV_TABVIEW_PART_BG_SCRL);
lv_style_list_reset(list);
list = lv_obj_get_style(obj, LV_TABVIEW_PART_TAB_BG);
@@ -706,17 +723,23 @@ void lv_theme_alien_apply(lv_obj_t * obj, lv_theme_style_t name)
lv_style_list_reset(list);
list = lv_obj_get_style(obj, LV_PAGE_PART_SCRL);
lv_style_list_reset(list);
break;
lv_style_list_add_style(list, &tabaview_page_scrl);
// case LV_THEME_TABVIEW_BG:
// case LV_THEME_TABVIEW_BTNS_BG:
// case LV_THEME_TABVIEW_TAB_SCRL:
// case LV_THEME_TABVIEW_BG_SCRL:
// return NULL;
// case LV_THEME_TABVIEW_TAB_BG:
// return &scr;
// case LV_THEME_TABVIEW_BTNS:
// return &btn;
break;
#endif
#if LV_USE_CHART
case LV_THEME_CHART:
list = lv_obj_get_style(obj, LV_CHART_PART_BG);
lv_style_list_reset(list);
lv_style_list_add_style(list, &panel);
list = lv_obj_get_style(obj, LV_CHART_PART_SERIES_BG);
lv_style_list_reset(list);
lv_style_list_add_style(list, &chart_series_bg);
list = lv_obj_get_style(obj, LV_CHART_PART_SERIES);
lv_style_list_reset(list);
lv_style_list_add_style(list, &chart_series);
#endif
}
@@ -731,8 +754,6 @@ lv_style_t * lv_theme_alien_get_style(lv_theme_style_t name)
switch(name) {
case LV_THEME_SCR:
return &scr;
case LV_THEME_SCR_TRANSP:
return &transp;
case LV_THEME_PANEL:
return &panel;
case LV_THEME_BTNM:
@@ -810,12 +831,13 @@ lv_style_t * lv_theme_alien_get_style(lv_theme_style_t name)
#if LV_USE_CHART
case LV_THEME_CHART_BG:
case LV_THEME_CHART_SERIES_BG:
return &panel;
case LV_THEME_CHART_SERIES_BG:
return NULL;
case LV_THEME_CHART_SERIES:
return &chart_series;
}
#endif
}
return NULL;
}

View File

@@ -290,6 +290,7 @@ static void copy(void)
lv_style_list_set_local_int(&list_src, LV_STYLE_LINE_DASH_WIDTH, 20);
lv_style_list_t list_dest;
lv_style_list_init(&list_dest);
lv_style_list_copy(&list_dest, &list_src);
lv_res_t found;