mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
add chart to v8 with zoom and scroll support (not finished)
This commit is contained in:
parent
aed63d9cbd
commit
31372d6972
@ -255,6 +255,7 @@ enum {
|
||||
LV_PART_INDICATOR,
|
||||
LV_PART_KNOB,
|
||||
LV_PART_PLACEHOLDER,
|
||||
LV_PART_CURSOR,
|
||||
LV_PART_HIGHLIGHT,
|
||||
LV_PART_MARKER,
|
||||
};
|
||||
|
@ -194,34 +194,34 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t
|
||||
*/
|
||||
void lv_obj_init_draw_label_dsc(lv_obj_t * obj, uint8_t part, lv_draw_label_dsc_t * draw_dsc)
|
||||
{
|
||||
// draw_dsc->opa = lv_obj_get_style_text_opa(obj, part);
|
||||
// if(draw_dsc->opa <= LV_OPA_MIN) return;
|
||||
//
|
||||
//#if LV_USE_OPA_SCALE
|
||||
// lv_opa_t opa_scale = lv_obj_get_style_opa_scale(obj, part);
|
||||
// if(opa_scale < LV_OPA_MAX) {
|
||||
// draw_dsc->opa = (uint16_t)((uint16_t)draw_dsc->opa * opa_scale) >> 8;
|
||||
// }
|
||||
// if(draw_dsc->opa <= LV_OPA_MIN) return;
|
||||
//#endif
|
||||
//
|
||||
// draw_dsc->color = lv_obj_get_style_text_color(obj, part);
|
||||
// draw_dsc->letter_space = lv_obj_get_style_text_letter_space(obj, part);
|
||||
// draw_dsc->line_space = lv_obj_get_style_text_line_space(obj, part);
|
||||
// draw_dsc->decor = lv_obj_get_style_text_decor(obj, part);
|
||||
//#if LV_USE_BLEND_MODES
|
||||
// draw_dsc->blend_mode = lv_obj_get_style_text_blend_mode(obj, part);
|
||||
//#endif
|
||||
//
|
||||
// draw_dsc->font = lv_obj_get_style_text_font(obj, part);
|
||||
//
|
||||
draw_dsc->opa = lv_obj_get_style_text_opa(obj, part);
|
||||
if(draw_dsc->opa <= LV_OPA_MIN) return;
|
||||
|
||||
#if LV_USE_OPA_SCALE
|
||||
lv_opa_t opa = lv_obj_get_style_opa(obj, part);
|
||||
if(opa < LV_OPA_MAX) {
|
||||
draw_dsc->opa = (uint16_t)((uint16_t)draw_dsc->opa * opa) >> 8;
|
||||
}
|
||||
if(draw_dsc->opa <= LV_OPA_MIN) return;
|
||||
#endif
|
||||
|
||||
draw_dsc->color = lv_obj_get_style_text_color(obj, part);
|
||||
draw_dsc->letter_space = lv_obj_get_style_text_letter_space(obj, part);
|
||||
draw_dsc->line_space = lv_obj_get_style_text_line_space(obj, part);
|
||||
draw_dsc->decor = lv_obj_get_style_text_decor(obj, part);
|
||||
#if LV_USE_BLEND_MODES
|
||||
draw_dsc->blend_mode = lv_obj_get_style_text_blend_mode(obj, part);
|
||||
#endif
|
||||
|
||||
draw_dsc->font = lv_obj_get_style_text_font(obj, part);
|
||||
|
||||
// if(draw_dsc->sel_start != LV_DRAW_LABEL_NO_TXT_SEL && draw_dsc->sel_end != LV_DRAW_LABEL_NO_TXT_SEL) {
|
||||
// draw_dsc->color = lv_obj_get_style_text_sel_color(obj, part);
|
||||
// }
|
||||
//
|
||||
//#if LV_USE_BIDI
|
||||
// draw_dsc->bidi_dir = lv_obj_get_base_dir(obj);
|
||||
//#endif
|
||||
|
||||
#if LV_USE_BIDI
|
||||
draw_dsc->bidi_dir = lv_obj_get_base_dir(obj);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@ -270,33 +270,33 @@ void lv_obj_init_draw_img_dsc(lv_obj_t * obj, uint8_t part, lv_draw_img_dsc_t *
|
||||
*/
|
||||
void lv_obj_init_draw_line_dsc(lv_obj_t * obj, uint8_t part, lv_draw_line_dsc_t * draw_dsc)
|
||||
{
|
||||
// draw_dsc->width = lv_obj_get_style_line_width(obj, part);
|
||||
// if(draw_dsc->width == 0) return;
|
||||
//
|
||||
// draw_dsc->opa = lv_obj_get_style_line_opa(obj, part);
|
||||
// if(draw_dsc->opa <= LV_OPA_MIN) return;
|
||||
//
|
||||
//#if LV_USE_OPA_SCALE
|
||||
// lv_opa_t opa_scale = lv_obj_get_style_opa_scale(obj, part);
|
||||
// if(opa_scale < LV_OPA_MAX) {
|
||||
// draw_dsc->opa = (uint16_t)((uint16_t)draw_dsc->opa * opa_scale) >> 8;
|
||||
// }
|
||||
// if(draw_dsc->opa <= LV_OPA_MIN) return;
|
||||
//#endif
|
||||
//
|
||||
// draw_dsc->color = lv_obj_get_style_line_color(obj, part);
|
||||
//
|
||||
// draw_dsc->dash_width = lv_obj_get_style_line_dash_width(obj, part);
|
||||
// if(draw_dsc->dash_width) {
|
||||
// draw_dsc->dash_gap = lv_obj_get_style_line_dash_gap(obj, part);
|
||||
// }
|
||||
//
|
||||
// draw_dsc->round_start = lv_obj_get_style_line_rounded(obj, part);
|
||||
// draw_dsc->round_end = draw_dsc->round_start;
|
||||
//
|
||||
//#if LV_USE_BLEND_MODES
|
||||
// draw_dsc->blend_mode = lv_obj_get_style_line_blend_mode(obj, part);
|
||||
//#endif
|
||||
draw_dsc->width = lv_obj_get_style_line_width(obj, part);
|
||||
if(draw_dsc->width == 0) return;
|
||||
|
||||
draw_dsc->opa = lv_obj_get_style_line_opa(obj, part);
|
||||
if(draw_dsc->opa <= LV_OPA_MIN) return;
|
||||
|
||||
#if LV_USE_OPA_SCALE
|
||||
lv_opa_t opa = lv_obj_get_style_opa(obj, part);
|
||||
if(opa < LV_OPA_MAX) {
|
||||
draw_dsc->opa = (uint16_t)((uint16_t)draw_dsc->opa * opa) >> 8;
|
||||
}
|
||||
if(draw_dsc->opa <= LV_OPA_MIN) return;
|
||||
#endif
|
||||
|
||||
draw_dsc->color = lv_obj_get_style_line_color(obj, part);
|
||||
|
||||
draw_dsc->dash_width = lv_obj_get_style_line_dash_width(obj, part);
|
||||
if(draw_dsc->dash_width) {
|
||||
draw_dsc->dash_gap = lv_obj_get_style_line_dash_gap(obj, part);
|
||||
}
|
||||
|
||||
draw_dsc->round_start = lv_obj_get_style_line_rounded(obj, part);
|
||||
draw_dsc->round_end = draw_dsc->round_start;
|
||||
|
||||
#if LV_USE_BLEND_MODES
|
||||
draw_dsc->blend_mode = lv_obj_get_style_line_blend_mode(obj, part);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -542,64 +542,63 @@ 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)
|
||||
{
|
||||
return _LV_STYLE_STATE_CMP_DIFF_LAYOUT;
|
||||
// lv_obj_style_list_t * list = &obj->style_list;
|
||||
// _lv_style_state_cmp_t res = _LV_STYLE_STATE_CMP_SAME;
|
||||
//
|
||||
// /*Are there any new styles for the new state?*/
|
||||
// uint32_t i;
|
||||
// for(i = 0; i < list->style_cnt; i++) {
|
||||
// if(list->styles[i].is_trans) continue;
|
||||
//
|
||||
// /*The style is valid for a stat but not the other*/
|
||||
// bool valid1 = list->styles[i].state & (~state1) ? false : true;
|
||||
// bool valid2 = list->styles[i].state & (~state2) ? false : true;
|
||||
// if(valid1 != valid2) {
|
||||
// lv_style_t * style = list->styles[i].style;
|
||||
//
|
||||
// /*If there is layout difference on the main part, return immediately. There is no more serious difference*/
|
||||
// _lv_style_state_cmp_t res_tmp = res;
|
||||
// if(style->has_pad_bottom) res_tmp = _LV_STYLE_STATE_CMP_DIFF_LAYOUT;
|
||||
// else if(style->has_pad_top) res_tmp = _LV_STYLE_STATE_CMP_DIFF_LAYOUT;
|
||||
// else if(style->has_pad_left) res_tmp = _LV_STYLE_STATE_CMP_DIFF_LAYOUT;
|
||||
// else if(style->has_pad_right) res_tmp = _LV_STYLE_STATE_CMP_DIFF_LAYOUT;
|
||||
// else if(style->ext && style->ext->has_margin_bottom) res_tmp = _LV_STYLE_STATE_CMP_DIFF_LAYOUT;
|
||||
// else if(style->ext && style->ext->has_margin_top) res_tmp = _LV_STYLE_STATE_CMP_DIFF_LAYOUT;
|
||||
// else if(style->ext && style->ext->has_margin_left) res_tmp = _LV_STYLE_STATE_CMP_DIFF_LAYOUT;
|
||||
// else if(style->ext && style->ext->has_margin_right) res_tmp = _LV_STYLE_STATE_CMP_DIFF_LAYOUT;
|
||||
//
|
||||
// if(res_tmp == _LV_STYLE_STATE_CMP_DIFF_LAYOUT) {
|
||||
// if(list->styles[i].part == LV_PART_MAIN) return _LV_STYLE_STATE_CMP_DIFF_LAYOUT;
|
||||
// else {
|
||||
// res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /*Check for draw pad changes*/
|
||||
// if(style->ext && style->ext->has_transform_width) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
|
||||
// else if(style->ext && style->ext->has_transform_height) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
|
||||
// else if(style->ext && style->ext->has_transform_angle) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
|
||||
// else if(style->ext && style->ext->has_transform_zoom) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
|
||||
// else if(style->ext && style->ext->has_outline_opa) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
|
||||
// else if(style->ext && style->ext->has_outline_pad) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
|
||||
// else if(style->ext && style->ext->has_shadow_width) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
|
||||
// else if(style->ext && style->ext->has_shadow_opa) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
|
||||
// else if(style->ext && style->ext->has_shadow_ofs_x) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
|
||||
// else if(style->ext && style->ext->has_shadow_ofs_y) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
|
||||
// else if(style->ext && style->ext->has_shadow_spread) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
|
||||
// else if(style->ext && style->ext->has_line_width) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
|
||||
// else if(style->ext && style->ext->has_content_src) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
|
||||
// else if(style->ext && style->ext->has_content_ofs_x) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
|
||||
// else if(style->ext && style->ext->has_content_ofs_y) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
|
||||
// else if(style->ext && style->ext->has_content_align) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
|
||||
// else {
|
||||
// if(res != _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD) res = _LV_STYLE_STATE_CMP_DIFF_REDRAW;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return res;
|
||||
lv_obj_style_list_t * list = &obj->style_list;
|
||||
_lv_style_state_cmp_t res = _LV_STYLE_STATE_CMP_SAME;
|
||||
|
||||
/*Are there any new styles for the new state?*/
|
||||
uint32_t i;
|
||||
for(i = 0; i < list->style_cnt; i++) {
|
||||
if(list->styles[i].is_trans) continue;
|
||||
|
||||
/*The style is valid for a stat but not the other*/
|
||||
bool valid1 = list->styles[i].state & (~state1) ? false : true;
|
||||
bool valid2 = list->styles[i].state & (~state2) ? false : true;
|
||||
if(valid1 != valid2) {
|
||||
lv_style_t * style = list->styles[i].style;
|
||||
|
||||
/*If there is layout difference on the main part, return immediately. There is no more serious difference*/
|
||||
_lv_style_state_cmp_t res_tmp = res;
|
||||
if(style->pad_bottom || (style->ext && style->ext->has.pad_bottom)) res_tmp = _LV_STYLE_STATE_CMP_DIFF_LAYOUT;
|
||||
else if(style->pad_top || (style->ext && style->ext->has.pad_bottom)) res_tmp = _LV_STYLE_STATE_CMP_DIFF_LAYOUT;
|
||||
else if(style->pad_left || (style->ext && style->ext->has.pad_bottom)) res_tmp = _LV_STYLE_STATE_CMP_DIFF_LAYOUT;
|
||||
else if(style->pad_right || (style->ext && style->ext->has.pad_bottom)) res_tmp = _LV_STYLE_STATE_CMP_DIFF_LAYOUT;
|
||||
else if(style->margin_bottom || (style->ext && style->ext->has.margin_bottom)) res_tmp = _LV_STYLE_STATE_CMP_DIFF_LAYOUT;
|
||||
else if(style->margin_top || (style->ext && style->ext->has.margin_top)) res_tmp = _LV_STYLE_STATE_CMP_DIFF_LAYOUT;
|
||||
else if(style->margin_left || (style->ext && style->ext->has.margin_left)) res_tmp = _LV_STYLE_STATE_CMP_DIFF_LAYOUT;
|
||||
else if(style->margin_right || (style->ext && style->ext->has.margin_right)) res_tmp = _LV_STYLE_STATE_CMP_DIFF_LAYOUT;
|
||||
|
||||
if(res_tmp == _LV_STYLE_STATE_CMP_DIFF_LAYOUT) {
|
||||
if(list->styles[i].part == LV_PART_MAIN) return _LV_STYLE_STATE_CMP_DIFF_LAYOUT;
|
||||
else {
|
||||
res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/*Check for draw pad changes*/
|
||||
if(style->ext && style->ext->has.transform_width) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
|
||||
else if(style->transform_width || (style->ext && style->ext->has.transform_height)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
|
||||
else if(style->ext && style->ext->has.transform_angle) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
|
||||
else if(style->ext && style->ext->has.transform_zoom) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
|
||||
else if(style->outline_opa || (style->ext && style->ext->has.outline_opa)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
|
||||
else if(style->outline_pad || (style->ext && style->ext->has.outline_pad)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
|
||||
else if(style->shadow_width|| (style->ext && style->ext->has.shadow_width)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
|
||||
else if(style->shadow_opa|| (style->ext && style->ext->has.shadow_opa)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
|
||||
else if(style->shadow_ofs_x|| (style->ext && style->ext->has.shadow_ofs_x)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
|
||||
else if(style->shadow_ofs_y|| (style->ext && style->ext->has.shadow_ofs_y)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
|
||||
else if(style->shadow_spread|| (style->ext && style->ext->has.shadow_spread)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
|
||||
else if(style->line_width || (style->ext && style->ext->has.line_width)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
|
||||
else if(style->ext && style->ext->has.content_src) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
|
||||
else if(style->ext && style->ext->has.content_ofs_x) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
|
||||
else if(style->ext && style->ext->has.content_ofs_y) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
|
||||
else if(style->ext && style->ext->has.content_align) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
|
||||
else {
|
||||
if(res != _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD) res = _LV_STYLE_STATE_CMP_DIFF_REDRAW;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**********************
|
||||
|
@ -142,6 +142,7 @@ lv_style_value_t lv_style_prop_get_default(lv_style_prop_t prop)
|
||||
case LV_STYLE_BORDER_OPA:
|
||||
case LV_STYLE_TEXT_OPA:
|
||||
case LV_STYLE_IMG_OPA:
|
||||
case LV_STYLE_LINE_OPA:
|
||||
case LV_STYLE_OUTLINE_OPA:
|
||||
case LV_STYLE_SHADOW_OPA:
|
||||
value._int = LV_OPA_COVER;
|
||||
@ -779,7 +780,7 @@ static void set_prop(lv_style_t * style, lv_style_prop_t prop, lv_style_value_t
|
||||
style->has_line_rounded = 1;
|
||||
break;
|
||||
case LV_STYLE_LINE_COLOR:
|
||||
id= style->dont_index ? 0 : get_index_num(value);
|
||||
id= style->dont_index ? 0 : get_index_color(value);
|
||||
if(id > 0) {
|
||||
style->line_color = id;
|
||||
} else {
|
||||
|
@ -66,7 +66,7 @@
|
||||
#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 TRANSITION_TIME ((theme.flags & LV_THEME_MATERIAL_FLAG_NO_TRANSITION) ? 0 : 150)
|
||||
#define TRANSITION_TIME ((theme.flags & LV_THEME_MATERIAL_FLAG_NO_TRANSITION) ? 0 : 85)
|
||||
#define BORDER_WIDTH 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)
|
||||
@ -89,6 +89,7 @@ typedef struct {
|
||||
/*Utility*/
|
||||
lv_style_t bg_color_primary;
|
||||
lv_style_t bg_color_gray;
|
||||
lv_style_t bg_color_white;
|
||||
lv_style_t pressed;
|
||||
lv_style_t disabled;
|
||||
lv_style_t pad_zero;
|
||||
@ -122,11 +123,11 @@ typedef struct {
|
||||
#endif
|
||||
|
||||
#if LV_USE_CHART
|
||||
lv_style_t chart_bg, chart_series_bg, chart_series;
|
||||
lv_style_t chart_bg, chart_series;
|
||||
#endif
|
||||
|
||||
#if LV_USE_CHECKBOX
|
||||
lv_style_t cb_marker;
|
||||
lv_style_t cb_marker, cb_marker_checked;
|
||||
#endif
|
||||
|
||||
#if LV_USE_DROPDOWN
|
||||
@ -185,11 +186,13 @@ static bool inited;
|
||||
static void basic_init(void)
|
||||
{
|
||||
const static lv_style_prop_t trans_props[] = {
|
||||
LV_STYLE_BG_OPA, LV_STYLE_BG_COLOR, LV_STYLE_TRANSFORM_WIDTH, LV_STYLE_TRANSFORM_HEIGHT, LV_STYLE_COLOR_FILTER_OPA, LV_STYLE_COLOR_FILTER_CB, 0
|
||||
LV_STYLE_BG_OPA, LV_STYLE_BG_COLOR,
|
||||
LV_STYLE_TRANSFORM_WIDTH, LV_STYLE_TRANSFORM_HEIGHT,
|
||||
LV_STYLE_COLOR_FILTER_OPA, LV_STYLE_COLOR_FILTER_CB, 0
|
||||
};
|
||||
|
||||
static lv_style_transiton_t trans_delayed;
|
||||
lv_style_transition_init(&trans_delayed, trans_props, &lv_anim_path_def, TRANSITION_TIME, TRANSITION_TIME / 2);
|
||||
lv_style_transition_init(&trans_delayed, trans_props, &lv_anim_path_def, TRANSITION_TIME, 70);
|
||||
|
||||
static lv_style_transiton_t trans_slow;
|
||||
lv_style_transition_init(&trans_slow, trans_props, &lv_anim_path_def, TRANSITION_TIME * 2, 0);
|
||||
@ -282,10 +285,10 @@ static void basic_init(void)
|
||||
lv_style_set_pad_all(&styles->pad_small, pad_small_value);
|
||||
|
||||
style_init_reset(&styles->pad_small_negative);
|
||||
lv_style_set_pad_all(&styles->pad_small_negative, - LV_DPX(2));
|
||||
lv_style_set_pad_all(&styles->pad_small_negative, - LV_DPX(4));
|
||||
|
||||
style_init_reset(&styles->pad_zero);
|
||||
lv_style_set_pad_all(&styles->pad_zero, LV_DPX(2));
|
||||
lv_style_set_pad_all(&styles->pad_zero, 0);
|
||||
|
||||
style_init_reset(&styles->bg_color_primary);
|
||||
lv_style_set_bg_color(&styles->bg_color_primary, theme.color_primary);
|
||||
@ -295,12 +298,16 @@ static void basic_init(void)
|
||||
lv_style_set_bg_color(&styles->bg_color_gray, COLOR_GRAY);
|
||||
lv_style_set_bg_opa(&styles->bg_color_gray, LV_OPA_COVER);
|
||||
|
||||
style_init_reset(&styles->bg_color_white);
|
||||
lv_style_set_bg_color(&styles->bg_color_white, LV_COLOR_WHITE);
|
||||
lv_style_set_bg_opa(&styles->bg_color_white, LV_OPA_COVER);
|
||||
|
||||
style_init_reset(&styles->circle);
|
||||
lv_style_set_radius(&styles->circle, LV_RADIUS_CIRCLE);
|
||||
|
||||
style_init_reset(&styles->grow);
|
||||
lv_style_set_transform_width(&styles->grow, LV_DPX(5));
|
||||
lv_style_set_transform_height(&styles->grow, LV_DPX(5));
|
||||
lv_style_set_transform_width(&styles->grow, LV_DPX(3));
|
||||
lv_style_set_transform_height(&styles->grow, LV_DPX(3));
|
||||
|
||||
style_init_reset(&styles->knob);
|
||||
lv_style_set_bg_color(&styles->knob, IS_LIGHT ? theme.color_primary : LV_COLOR_WHITE);
|
||||
@ -308,38 +315,35 @@ static void basic_init(void)
|
||||
lv_style_set_pad_all(&styles->knob, LV_DPX(5));
|
||||
lv_style_set_radius(&styles->knob, LV_RADIUS_CIRCLE);
|
||||
|
||||
|
||||
style_init_reset(&styles->cb_marker);
|
||||
lv_style_set_pad_all(&styles->cb_marker, LV_DPX(3));
|
||||
lv_style_set_border_width(&styles->cb_marker, BORDER_WIDTH);
|
||||
lv_style_set_border_color(&styles->cb_marker, theme.color_primary);
|
||||
lv_style_set_bg_color(&styles->cb_marker, LV_COLOR_WHITE);
|
||||
lv_style_set_bg_opa(&styles->cb_marker, LV_OPA_COVER);
|
||||
lv_style_set_margin_right(&styles->cb_marker, LV_DPX(6));
|
||||
lv_style_set_radius(&styles->cb_marker, RADIUS_DEFAULT / 2);
|
||||
|
||||
style_init_reset(&styles->cb_marker_checked);
|
||||
lv_style_set_content_src(&styles->cb_marker_checked, LV_SYMBOL_OK);
|
||||
lv_style_set_text_color(&styles->cb_marker_checked, LV_COLOR_WHITE);
|
||||
lv_style_set_text_font(&styles->cb_marker_checked, theme.font_small);
|
||||
|
||||
|
||||
style_init_reset(&styles->chart_bg);
|
||||
lv_style_set_line_width(&styles->chart_bg, LV_DPX(1));
|
||||
lv_style_set_line_dash_width(&styles->chart_bg, LV_DPX(10));
|
||||
lv_style_set_line_dash_gap(&styles->chart_bg, LV_DPX(10));
|
||||
lv_style_set_line_color(&styles->chart_bg, LV_COLOR_RED);//CARD_BORDER_COLOR);
|
||||
lv_style_set_text_color(&styles->chart_bg, LV_COLOR_RED);//CARD_BORDER_COLOR);
|
||||
|
||||
style_init_reset(&styles->chart_series);
|
||||
lv_style_set_line_width(&styles->chart_series, LV_DPX(3));
|
||||
// lv_style_set_size(&styles->chart_series, LV_DPX(4));
|
||||
lv_style_set_pad_all(&styles->chart_series, LV_DPX(2)); /*Space between columns*/
|
||||
lv_style_set_radius(&styles->chart_series, LV_DPX(1));
|
||||
|
||||
|
||||
//static void checkbox_init(void)
|
||||
//{
|
||||
//#if LV_USE_CHECKBOX != 0
|
||||
// style_init_reset(&styles->cb_bg);
|
||||
// lv_style_set_radius(&styles->cb_bg, LV_STATE_DEFAULT, LV_DPX(4));
|
||||
// lv_style_set_outline_color(&styles->cb_bg, LV_STATE_DEFAULT, theme.color_primary);
|
||||
// lv_style_set_outline_opa(&styles->cb_bg, LV_STATE_DEFAULT, LV_OPA_TRANSP);
|
||||
// lv_style_set_outline_opa(&styles->cb_bg, LV_STATE_FOCUSED, LV_OPA_50);
|
||||
// lv_style_set_outline_width(&styles->cb_bg, LV_STATE_DEFAULT, OUTLINE_WIDTH);
|
||||
// lv_style_set_outline_pad(&styles->cb_bg, LV_STATE_DEFAULT, LV_DPX(6));
|
||||
// lv_style_set_transition_time(&styles->cb_bg, LV_STATE_DEFAULT, TRANSITION_TIME);
|
||||
// lv_style_set_transition_prop_6(&styles->cb_bg, LV_STATE_DEFAULT, LV_STYLE_OUTLINE_OPA);
|
||||
//
|
||||
// style_init_reset(&styles->cb_bullet);
|
||||
// lv_style_set_outline_opa(&styles->cb_bullet, LV_STATE_FOCUSED, LV_OPA_TRANSP);
|
||||
// lv_style_set_radius(&styles->cb_bullet, LV_STATE_DEFAULT, LV_DPX(4));
|
||||
// lv_style_set_pattern_image(&styles->cb_bullet, LV_STATE_CHECKED, LV_SYMBOL_OK);
|
||||
// lv_style_set_pattern_recolor(&styles->cb_bullet, LV_STATE_CHECKED, LV_COLOR_WHITE);
|
||||
// lv_style_set_pattern_opa(&styles->cb_bullet, LV_STATE_DEFAULT, LV_OPA_TRANSP);
|
||||
// lv_style_set_pattern_opa(&styles->cb_bullet, LV_STATE_CHECKED, LV_OPA_COVER);
|
||||
// lv_style_set_transition_prop_3(&styles->cb_bullet, LV_STATE_DEFAULT, LV_STYLE_PATTERN_OPA);
|
||||
// lv_style_set_text_font(&styles->cb_bullet, LV_STATE_CHECKED, theme.font_small);
|
||||
// lv_style_set_pad_left(&styles->cb_bullet, LV_STATE_DEFAULT, LV_DPX(3));
|
||||
// lv_style_set_pad_right(&styles->cb_bullet, LV_STATE_DEFAULT, LV_DPX(3));
|
||||
// lv_style_set_pad_top(&styles->cb_bullet, LV_STATE_DEFAULT, LV_DPX(3));
|
||||
// lv_style_set_pad_bottom(&styles->cb_bullet, LV_STATE_DEFAULT, LV_DPX(3));
|
||||
// lv_style_set_margin_right(&styles->cb_bullet, LV_STATE_DEFAULT, LV_DPX(6));
|
||||
//#endif
|
||||
//}
|
||||
|
||||
|
||||
}
|
||||
@ -359,20 +363,6 @@ static void line_init(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void switch_init(void)
|
||||
{
|
||||
#if LV_USE_SWITCH != 0
|
||||
style_init_reset(&styles->sw_knob);
|
||||
lv_style_set_bg_opa(&styles->sw_knob, LV_STATE_DEFAULT, LV_OPA_COVER);
|
||||
lv_style_set_bg_color(&styles->sw_knob, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
||||
lv_style_set_radius(&styles->sw_knob, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
|
||||
lv_style_set_pad_top(&styles->sw_knob, LV_STATE_DEFAULT, - LV_DPX(4));
|
||||
lv_style_set_pad_bottom(&styles->sw_knob, LV_STATE_DEFAULT, - LV_DPX(4));
|
||||
lv_style_set_pad_left(&styles->sw_knob, LV_STATE_DEFAULT, - LV_DPX(4));
|
||||
lv_style_set_pad_right(&styles->sw_knob, LV_STATE_DEFAULT, - LV_DPX(4));
|
||||
#endif
|
||||
}
|
||||
|
||||
static void linemeter_init(void)
|
||||
{
|
||||
#if LV_USE_LINEMETER != 0
|
||||
@ -458,23 +448,7 @@ static void spinner_init(void)
|
||||
|
||||
static void chart_init(void)
|
||||
{
|
||||
#if LV_USE_CHART
|
||||
style_init_reset(&styles->chart_bg);
|
||||
lv_style_set_text_color(&styles->chart_bg, LV_STATE_DEFAULT, IS_LIGHT ? COLOR_BG_TEXT_DIS : lv_color_hex(0xa1adbd));
|
||||
|
||||
style_init_reset(&styles->chart_series_bg);
|
||||
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_gap(&styles->chart_series_bg, LV_STATE_DEFAULT, LV_DPX(10));
|
||||
lv_style_set_line_color(&styles->chart_series_bg, LV_STATE_DEFAULT, CARD_BORDER_COLOR);
|
||||
|
||||
style_init_reset(&styles->chart_series);
|
||||
lv_style_set_line_width(&styles->chart_series, LV_STATE_DEFAULT, LV_DPX(3));
|
||||
lv_style_set_size(&styles->chart_series, LV_STATE_DEFAULT, LV_DPX(4));
|
||||
lv_style_set_pad_all(&styles->chart_series, LV_STATE_DEFAULT, LV_DPX(2)); /*Space between columns*/
|
||||
lv_style_set_radius(&styles->chart_series, LV_STATE_DEFAULT, LV_DPX(1));
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
static void textarea_init(void)
|
||||
@ -594,7 +568,6 @@ lv_theme_t * lv_theme_default_init(lv_color_t color_primary, lv_color_t color_se
|
||||
basic_init();
|
||||
btnmatrix_init();
|
||||
line_init();
|
||||
switch_init();
|
||||
linemeter_init();
|
||||
gauge_init();
|
||||
arc_init();
|
||||
@ -642,7 +615,6 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
|
||||
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_PRESSED, &styles->pressed);
|
||||
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_PRESSED, &styles->transition_normal);
|
||||
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_PRESSED, &styles->grow);
|
||||
// lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_BORN, &styles->grow);
|
||||
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_CHECKED, &styles->btn_color_checked);
|
||||
}
|
||||
#endif
|
||||
@ -659,7 +631,6 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
|
||||
#if LV_USE_SLIDER
|
||||
else if(lv_obj_check_type(obj, &lv_slider)) {
|
||||
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->bg_color_gray);
|
||||
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_PRESSED, &styles->grow);
|
||||
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->circle);
|
||||
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->transition_delayed);
|
||||
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_PRESSED, &styles->transition_normal);
|
||||
@ -674,15 +645,44 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
|
||||
|
||||
#if LV_USE_CHECKBOX
|
||||
else if(lv_obj_check_type(obj, &lv_checkbox)) {
|
||||
lv_obj_add_style(obj, LV_PART_MARKER, LV_STATE_DEFAULT, &styles->card);
|
||||
lv_obj_add_style(obj, LV_PART_MARKER, LV_STATE_DEFAULT, &styles->pad_zero);
|
||||
lv_obj_add_style(obj, LV_PART_MARKER, LV_STATE_DEFAULT, &styles->cb_marker);
|
||||
lv_obj_add_style(obj, LV_PART_MARKER, LV_STATE_CHECKED, &styles->bg_color_primary);
|
||||
lv_obj_add_style(obj, LV_PART_MARKER, LV_STATE_CHECKED, &styles->cb_marker_checked);
|
||||
lv_obj_add_style(obj, LV_PART_MARKER, LV_STATE_PRESSED, &styles->pressed);
|
||||
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_PRESSED, &styles->transition_normal);
|
||||
lv_obj_add_style(obj, LV_PART_MARKER, LV_STATE_PRESSED, &styles->grow);
|
||||
lv_obj_add_style(obj, LV_PART_MARKER, LV_STATE_PRESSED, &styles->transition_normal);
|
||||
lv_obj_add_style(obj, LV_PART_MARKER, LV_STATE_DEFAULT, &styles->transition_delayed);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LV_USE_SWITCH
|
||||
else if(lv_obj_check_type(obj, &lv_switch)) {
|
||||
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->bg_color_gray);
|
||||
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->circle);
|
||||
lv_obj_add_style(obj, LV_PART_INDICATOR, LV_STATE_DEFAULT, &styles->bg_color_primary);
|
||||
lv_obj_add_style(obj, LV_PART_INDICATOR, LV_STATE_DEFAULT, &styles->circle);
|
||||
lv_obj_add_style(obj, LV_PART_KNOB, LV_STATE_DEFAULT, &styles->knob);
|
||||
lv_obj_add_style(obj, LV_PART_KNOB, LV_STATE_DEFAULT, &styles->bg_color_white);
|
||||
lv_obj_add_style(obj, LV_PART_KNOB, LV_STATE_DEFAULT, &styles->pad_small_negative);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LV_USE_SWITCH
|
||||
else if(lv_obj_check_type(obj, &lv_chart)) {
|
||||
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->card);
|
||||
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->chart_bg);
|
||||
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->pad_zero);
|
||||
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);
|
||||
lv_obj_add_style(obj, LV_PART_SERIES, LV_STATE_DEFAULT, &styles->chart_series);
|
||||
// lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->circle);
|
||||
// lv_obj_add_style(obj, LV_PART_INDICATOR, LV_STATE_DEFAULT, &styles->bg_color_primary);
|
||||
// lv_obj_add_style(obj, LV_PART_INDICATOR, LV_STATE_DEFAULT, &styles->circle);
|
||||
// lv_obj_add_style(obj, LV_PART_KNOB, LV_STATE_DEFAULT, &styles->knob);
|
||||
// lv_obj_add_style(obj, LV_PART_KNOB, LV_STATE_DEFAULT, &styles->bg_color_white);
|
||||
// lv_obj_add_style(obj, LV_PART_KNOB, LV_STATE_DEFAULT, &styles->pad_small_negative);
|
||||
}
|
||||
#endif
|
||||
#if LV_USE_BTNMATRIX
|
||||
case LV_THEME_BTNMATRIX:
|
||||
list = _lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_MAIN);
|
||||
@ -701,20 +701,6 @@ case LV_THEME_BTNMATRIX:
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
||||
#if LV_USE_SWITCH
|
||||
case LV_THEME_SWITCH:
|
||||
list = _lv_obj_get_style_list(obj, LV_SWITCH_PART_MAIN);
|
||||
_lv_style_list_add_style(list, &styles->bar_bg);
|
||||
|
||||
list = _lv_obj_get_style_list(obj, LV_SWITCH_PART_INDIC);
|
||||
_lv_style_list_add_style(list, &styles->bar_indic);
|
||||
|
||||
list = _lv_obj_get_style_list(obj, LV_SWITCH_PART_KNOB);
|
||||
_lv_style_list_add_style(list, &styles->sw_knob);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_IMG
|
||||
case LV_THEME_IMAGE:
|
||||
break;
|
||||
@ -782,24 +768,24 @@ case LV_THEME_DROPDOWN:
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_CHART
|
||||
case LV_THEME_CHART:
|
||||
list = _lv_obj_get_style_list(obj, LV_CHART_PART_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->pad_small);
|
||||
|
||||
list = _lv_obj_get_style_list(obj, LV_CHART_PART_SERIES_BG);
|
||||
_lv_style_list_add_style(list, &styles->pad_small);
|
||||
_lv_style_list_add_style(list, &styles->chart_series_bg);
|
||||
|
||||
list = _lv_obj_get_style_list(obj, LV_CHART_PART_CURSOR);
|
||||
_lv_style_list_add_style(list, &styles->chart_series_bg);
|
||||
|
||||
list = _lv_obj_get_style_list(obj, LV_CHART_PART_SERIES);
|
||||
_lv_style_list_add_style(list, &styles->chart_series);
|
||||
break;
|
||||
#endif
|
||||
//#if LV_USE_CHART
|
||||
//case LV_THEME_CHART:
|
||||
// list = _lv_obj_get_style_list(obj, LV_CHART_PART_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->pad_small);
|
||||
//
|
||||
// list = _lv_obj_get_style_list(obj, LV_CHART_PART_SERIES_BG);
|
||||
// _lv_style_list_add_style(list, &styles->pad_small);
|
||||
// _lv_style_list_add_style(list, &styles->chart_series_bg);
|
||||
//
|
||||
// list = _lv_obj_get_style_list(obj, LV_CHART_PART_CURSOR);
|
||||
// _lv_style_list_add_style(list, &styles->chart_series_bg);
|
||||
//
|
||||
// list = _lv_obj_get_style_list(obj, LV_CHART_PART_SERIES);
|
||||
// _lv_style_list_add_style(list, &styles->chart_series);
|
||||
// break;
|
||||
//#endif
|
||||
#if LV_USE_TABLE
|
||||
case LV_THEME_TABLE: {
|
||||
list = _lv_obj_get_style_list(obj, LV_TABLE_PART_BG);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -27,9 +27,6 @@ extern "C" {
|
||||
/**Default value of points. Can be used to not draw a point*/
|
||||
#define LV_CHART_POINT_DEF (LV_COORD_MIN)
|
||||
|
||||
/**Automatically calculate the tick length*/
|
||||
#define LV_CHART_TICK_LENGTH_AUTO 255
|
||||
|
||||
LV_EXPORT_CONST_INT(LV_CHART_POINT_DEF);
|
||||
LV_EXPORT_CONST_INT(LV_CHART_TICK_LENGTH_AUTO);
|
||||
|
||||
@ -99,34 +96,36 @@ typedef struct {
|
||||
uint8_t minor_tick_len;
|
||||
} lv_chart_axis_cfg_t;
|
||||
|
||||
/*Data of chart */
|
||||
typedef struct {
|
||||
/*No inherited ext*/ /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
lv_ll_t series_ll; /*Linked list for the data line pointers (stores lv_chart_series_t)*/
|
||||
lv_ll_t cursors_ll; /*Linked list for the cursor pointers (stores lv_chart_cursor_t)*/
|
||||
lv_coord_t ymin[_LV_CHART_AXIS_LAST]; /*y min values for both axis (used to scale the data)*/
|
||||
lv_coord_t ymax[_LV_CHART_AXIS_LAST]; /*y max values for both axis (used to scale the data)*/
|
||||
uint8_t hdiv_cnt; /*Number of horizontal division lines*/
|
||||
uint8_t vdiv_cnt; /*Number of vertical division lines*/
|
||||
uint16_t point_cnt; /*Point number in a data line*/
|
||||
lv_style_list_t style_series_bg;
|
||||
lv_style_list_t style_series;
|
||||
lv_style_list_t style_cursors;
|
||||
lv_chart_type_t type; /*Line, column or point chart (from 'lv_chart_type_t')*/
|
||||
lv_chart_axis_cfg_t y_axis;
|
||||
lv_chart_axis_cfg_t x_axis;
|
||||
lv_chart_axis_cfg_t secondary_y_axis;
|
||||
uint8_t update_mode : 1;
|
||||
} lv_chart_ext_t;
|
||||
|
||||
/*Parts of the chart*/
|
||||
enum {
|
||||
LV_CHART_PART_BG = LV_OBJ_PART_MAIN,
|
||||
LV_CHART_PART_SERIES_BG,
|
||||
LV_CHART_PART_SERIES,
|
||||
LV_CHART_PART_CURSOR
|
||||
};
|
||||
LV_CLASS_DECLARE_START(lv_chart, lv_obj);
|
||||
|
||||
#define _lv_chart_constructor void (*constructor)(struct _lv_obj_t * obj, struct _lv_obj_t * parent, const struct _lv_obj_t * copy)
|
||||
|
||||
#define _lv_chart_data \
|
||||
_lv_obj_data \
|
||||
lv_ll_t series_ll; /*Linked list for the data line pointers (stores lv_chart_series_t)*/ \
|
||||
lv_ll_t cursors_ll; /*Linked list for the cursor pointers (stores lv_chart_cursor_t)*/ \
|
||||
lv_coord_t ymin[_LV_CHART_AXIS_LAST]; /*y min values for both axis (used to scale the data)*/ \
|
||||
lv_coord_t ymax[_LV_CHART_AXIS_LAST]; /*y max values for both axis (used to scale the data)*/ \
|
||||
uint8_t hdiv_cnt; /*Number of horizontal division lines*/ \
|
||||
uint8_t vdiv_cnt; /*Number of vertical division lines*/ \
|
||||
uint16_t point_cnt; /*Point number in a data line*/ \
|
||||
lv_chart_type_t type; /*Line, column or point chart (from 'lv_chart_type_t')*/ \
|
||||
lv_chart_axis_cfg_t y_axis; \
|
||||
lv_chart_axis_cfg_t x_axis; \
|
||||
lv_chart_axis_cfg_t secondary_y_axis; \
|
||||
uint16_t x_zoom; \
|
||||
uint16_t y_zoom; \
|
||||
uint8_t update_mode : 1;
|
||||
|
||||
#define _lv_chart_class_dsc \
|
||||
_lv_obj_class_dsc
|
||||
|
||||
LV_CLASS_DECLARE_END(lv_chart, lv_obj);
|
||||
|
||||
extern lv_chart_class_t lv_chart;
|
||||
|
||||
#define LV_PART_SERIES 20
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
@ -385,13 +384,6 @@ lv_coord_t lv_chart_get_point_id(lv_obj_t * chart, lv_chart_series_t * ser, uint
|
||||
*/
|
||||
lv_chart_axis_t lv_chart_get_series_axis(lv_obj_t * chart, lv_chart_series_t * ser);
|
||||
|
||||
/**
|
||||
* Get an individual point y value in the chart series directly based on index
|
||||
* @param chart pointer to a chart object
|
||||
* @param series_area pointer to an area variable that the result will put in.
|
||||
*/
|
||||
void lv_chart_get_series_area(lv_obj_t * chart, lv_area_t * series_area);
|
||||
|
||||
/**
|
||||
* Get the coordinate of the cursor with respect
|
||||
* to the origin of series area of the chart.
|
||||
|
@ -207,23 +207,32 @@ static lv_design_res_t lv_checkbox_design(lv_obj_t * obj, const lv_area_t * clip
|
||||
lv_coord_t bg_topp = lv_obj_get_style_pad_top(obj, LV_PART_MAIN);
|
||||
lv_coord_t bg_leftp = lv_obj_get_style_pad_left(obj, LV_PART_MAIN);
|
||||
|
||||
lv_coord_t bullet_rightm = lv_obj_get_style_margin_right(obj, LV_PART_MARKER);
|
||||
lv_coord_t marker_rightm = lv_obj_get_style_margin_right(obj, LV_PART_MARKER);
|
||||
|
||||
lv_coord_t bullet_leftp = lv_obj_get_style_pad_left(obj, LV_PART_MARKER);
|
||||
lv_coord_t bullet_rightp = lv_obj_get_style_pad_right(obj, LV_PART_MARKER);
|
||||
lv_coord_t bullet_topp = lv_obj_get_style_pad_top(obj, LV_PART_MARKER);
|
||||
lv_coord_t bullet_bottomp = lv_obj_get_style_pad_bottom(obj, LV_PART_MARKER);
|
||||
lv_coord_t marker_leftp = lv_obj_get_style_pad_left(obj, LV_PART_MARKER);
|
||||
lv_coord_t marker_rightp = lv_obj_get_style_pad_right(obj, LV_PART_MARKER);
|
||||
lv_coord_t marker_topp = lv_obj_get_style_pad_top(obj, LV_PART_MARKER);
|
||||
lv_coord_t marker_bottomp = lv_obj_get_style_pad_bottom(obj, LV_PART_MARKER);
|
||||
|
||||
lv_draw_rect_dsc_t bullet_dsc;
|
||||
lv_draw_rect_dsc_init(&bullet_dsc);
|
||||
lv_obj_init_draw_rect_dsc(obj, LV_PART_MARKER, &bullet_dsc);
|
||||
lv_area_t bullet_area;
|
||||
bullet_area.x1 = cb->coords.x1 + bg_leftp;
|
||||
bullet_area.x2 = bullet_area.x1 + font_h + bullet_leftp + bullet_rightp - 1;
|
||||
bullet_area.y1 = cb->coords.y1 + bg_topp;
|
||||
bullet_area.y2 = bullet_area.y1 + font_h + bullet_topp + bullet_bottomp - 1;
|
||||
lv_coord_t tranf_w = lv_obj_get_style_transform_width(obj, LV_PART_MARKER);
|
||||
lv_coord_t tranf_h = lv_obj_get_style_transform_height(obj, LV_PART_MARKER);
|
||||
|
||||
lv_draw_rect(&bullet_area, clip_area, &bullet_dsc);
|
||||
lv_draw_rect_dsc_t marker_dsc;
|
||||
lv_draw_rect_dsc_init(&marker_dsc);
|
||||
lv_obj_init_draw_rect_dsc(obj, LV_PART_MARKER, &marker_dsc);
|
||||
lv_area_t marker_area;
|
||||
marker_area.x1 = cb->coords.x1 + bg_leftp;
|
||||
marker_area.x2 = marker_area.x1 + font_h + marker_leftp + marker_rightp - 1;
|
||||
marker_area.y1 = cb->coords.y1 + bg_topp;
|
||||
marker_area.y2 = marker_area.y1 + font_h + marker_topp + marker_bottomp - 1;
|
||||
|
||||
lv_area_t marker_area_transf;
|
||||
lv_area_copy(&marker_area_transf, &marker_area);
|
||||
marker_area_transf.x1 -= tranf_w;
|
||||
marker_area_transf.x2 += tranf_w;
|
||||
marker_area_transf.y1 -= tranf_h;
|
||||
marker_area_transf.y2 += tranf_h;
|
||||
lv_draw_rect(&marker_area_transf, clip_area, &marker_dsc);
|
||||
|
||||
lv_coord_t line_space = lv_obj_get_style_text_line_space(obj, LV_PART_MAIN);
|
||||
lv_coord_t letter_space = lv_obj_get_style_text_letter_space(obj, LV_PART_MAIN);
|
||||
@ -235,9 +244,9 @@ static lv_design_res_t lv_checkbox_design(lv_obj_t * obj, const lv_area_t * clip
|
||||
lv_draw_label_dsc_init(&txt_dsc);
|
||||
lv_obj_init_draw_label_dsc(obj, LV_PART_MAIN, &txt_dsc);
|
||||
|
||||
lv_coord_t y_ofs = (lv_area_get_height(&bullet_area) - font_h) / 2;
|
||||
lv_coord_t y_ofs = (lv_area_get_height(&marker_area) - font_h) / 2;
|
||||
lv_area_t txt_area;
|
||||
txt_area.x1 = bullet_area.x2 + bullet_rightm;
|
||||
txt_area.x1 = marker_area.x2 + marker_rightm;
|
||||
txt_area.x2 = txt_area.x1 + txt_size.x;
|
||||
txt_area.y1 = cb->coords.y1 + bg_topp + y_ofs;
|
||||
txt_area.y2 = txt_area.y1 + txt_size.y;
|
||||
@ -264,7 +273,7 @@ static lv_res_t lv_checkbox_signal(lv_obj_t * obj, lv_signal_t sign, void * para
|
||||
res = lv_checkbox.base_p->signal_cb(obj, sign, param);
|
||||
if(res != LV_RES_OK) return res;
|
||||
|
||||
else if (sign == LV_SIGNAL_GET_SELF_SIZE) {
|
||||
if (sign == LV_SIGNAL_GET_SELF_SIZE) {
|
||||
lv_point_t * p = param;
|
||||
lv_checkbox_t * cb = (lv_checkbox_t *) obj;
|
||||
|
||||
@ -276,19 +285,23 @@ static lv_res_t lv_checkbox_signal(lv_obj_t * obj, lv_signal_t sign, void * para
|
||||
lv_point_t txt_size;
|
||||
_lv_txt_get_size(&txt_size, cb->txt, font, letter_space, line_space, LV_COORD_MAX, LV_TXT_FLAG_NONE);
|
||||
|
||||
lv_coord_t bullet_rightm = lv_obj_get_style_margin_right(obj, LV_PART_MARKER);
|
||||
lv_coord_t bullet_bottomm = lv_obj_get_style_margin_bottom(obj, LV_PART_MARKER);
|
||||
lv_coord_t bullet_leftp = lv_obj_get_style_pad_left(obj, LV_PART_MARKER);
|
||||
lv_coord_t bullet_rightp = lv_obj_get_style_pad_right(obj, LV_PART_MARKER);
|
||||
lv_coord_t bullet_topp = lv_obj_get_style_pad_top(obj, LV_PART_MARKER);
|
||||
lv_coord_t bullet_bottomp = lv_obj_get_style_pad_bottom(obj, LV_PART_MARKER);
|
||||
lv_point_t bullet_size;
|
||||
bullet_size.x = font_h + bullet_rightm + bullet_leftp + bullet_rightp;
|
||||
bullet_size.y = font_h + bullet_bottomm + bullet_topp + bullet_bottomp;
|
||||
|
||||
p->x = bullet_size.x + txt_size.x;
|
||||
p->y = LV_MATH_MAX(bullet_size.y, txt_size.y);
|
||||
lv_coord_t marker_rightm = lv_obj_get_style_margin_right(obj, LV_PART_MARKER);
|
||||
lv_coord_t marker_bottomm = lv_obj_get_style_margin_bottom(obj, LV_PART_MARKER);
|
||||
lv_coord_t marker_leftp = lv_obj_get_style_pad_left(obj, LV_PART_MARKER);
|
||||
lv_coord_t marker_rightp = lv_obj_get_style_pad_right(obj, LV_PART_MARKER);
|
||||
lv_coord_t marker_topp = lv_obj_get_style_pad_top(obj, LV_PART_MARKER);
|
||||
lv_coord_t marker_bottomp = lv_obj_get_style_pad_bottom(obj, LV_PART_MARKER);
|
||||
lv_point_t marker_size;
|
||||
marker_size.x = font_h + marker_rightm + marker_leftp + marker_rightp;
|
||||
marker_size.y = font_h + marker_bottomm + marker_topp + marker_bottomp;
|
||||
|
||||
p->x = marker_size.x + txt_size.x;
|
||||
p->y = LV_MATH_MAX(marker_size.y, txt_size.y);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
|
||||
lv_coord_t *s = param;
|
||||
lv_coord_t m = _lv_obj_get_draw_rect_ext_pad_size(obj, LV_PART_MARKER);
|
||||
*s = LV_MATH_MAX(*s, m);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
@ -38,7 +38,6 @@ static void lv_switch_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_ob
|
||||
static void lv_switch_destructor(void * obj);
|
||||
static lv_res_t lv_switch_signal(lv_obj_t * obj, lv_signal_t sign, void * param);
|
||||
static lv_design_res_t lv_switch_design(lv_obj_t * sw, const lv_area_t * clip_area, lv_design_mode_t mode);
|
||||
static lv_style_list_t * lv_switch_get_style(lv_obj_t * sw, uint8_t part);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
@ -73,14 +72,7 @@ lv_obj_t * lv_switch_create(lv_obj_t * parent, const lv_obj_t * copy)
|
||||
lv_obj_t * obj = lv_class_new(&lv_switch);
|
||||
lv_switch.constructor(obj, parent, copy);
|
||||
|
||||
lv_switch_t * sw = (lv_switch_t *) obj;
|
||||
const lv_switch_t * sw_copy = (const lv_switch_t *) copy;
|
||||
if(!copy) lv_theme_apply(obj, LV_THEME_SWITCH);
|
||||
else {
|
||||
lv_style_list_copy(&sw->style_indic, &sw_copy->style_indic);
|
||||
lv_style_list_copy(&sw->style_knob, &sw_copy->style_knob);
|
||||
_lv_obj_refresh_style(obj, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
|
||||
}
|
||||
lv_obj_create_finish(obj, parent, copy);
|
||||
|
||||
return obj;
|
||||
}
|
||||
@ -98,9 +90,6 @@ static void lv_switch_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_ob
|
||||
lv_switch.base_p->constructor(obj, parent, copy);
|
||||
|
||||
lv_switch_t * sw = (lv_switch_t *) obj;
|
||||
lv_style_list_init(&sw->style_indic);
|
||||
lv_style_list_init(&sw->style_knob);
|
||||
|
||||
|
||||
if(copy == NULL) {
|
||||
lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE);
|
||||
@ -117,7 +106,7 @@ static void lv_switch_destructor(void * obj)
|
||||
// lv_bar_t * bar = obj;
|
||||
//
|
||||
// _lv_obj_reset_style_list_no_refr(obj, LV_BAR_PART_INDIC);
|
||||
// _lv_obj_reset_style_list_no_refr(sw, LV_SWITCH_PART_KNOB);
|
||||
// _lv_obj_reset_style_list_no_refr(sw, LV_PART_KNOB);
|
||||
//
|
||||
// bar->class_p->base_p->destructor(obj);
|
||||
}
|
||||
@ -149,10 +138,10 @@ static lv_design_res_t lv_switch_design(lv_obj_t * obj, const lv_area_t * clip_a
|
||||
lv_switch_t * sw = (lv_switch_t *)obj;
|
||||
|
||||
/*Calculate the indicator area*/
|
||||
lv_style_int_t bg_left = lv_obj_get_style_pad_left(obj, LV_SWITCH_PART_MAIN);
|
||||
lv_style_int_t bg_right = lv_obj_get_style_pad_right(obj, LV_SWITCH_PART_MAIN);
|
||||
lv_style_int_t bg_top = lv_obj_get_style_pad_top(obj, LV_SWITCH_PART_MAIN);
|
||||
lv_style_int_t bg_bottom = lv_obj_get_style_pad_bottom(obj, LV_SWITCH_PART_MAIN);
|
||||
lv_coord_t bg_left = lv_obj_get_style_pad_left(obj, LV_PART_MAIN);
|
||||
lv_coord_t bg_right = lv_obj_get_style_pad_right(obj, LV_PART_MAIN);
|
||||
lv_coord_t bg_top = lv_obj_get_style_pad_top(obj, LV_PART_MAIN);
|
||||
lv_coord_t bg_bottom = lv_obj_get_style_pad_bottom(obj, LV_PART_MAIN);
|
||||
|
||||
bool chk = lv_obj_get_state(obj) & LV_STATE_CHECKED;
|
||||
/*Draw the indicator in checked state*/
|
||||
@ -167,7 +156,7 @@ static lv_design_res_t lv_switch_design(lv_obj_t * obj, const lv_area_t * clip_a
|
||||
|
||||
lv_draw_rect_dsc_t draw_indic_dsc;
|
||||
lv_draw_rect_dsc_init(&draw_indic_dsc);
|
||||
lv_obj_init_draw_rect_dsc(obj, LV_SWITCH_PART_INDIC, &draw_indic_dsc);
|
||||
lv_obj_init_draw_rect_dsc(obj, LV_PART_INDICATOR, &draw_indic_dsc);
|
||||
lv_draw_rect(&indic_area, clip_area, &draw_indic_dsc);
|
||||
}
|
||||
|
||||
@ -189,10 +178,10 @@ static lv_design_res_t lv_switch_design(lv_obj_t * obj, const lv_area_t * clip_a
|
||||
knob_area.y1 = sw->coords.y1 + bg_top;
|
||||
knob_area.y2 = sw->coords.y2 - bg_bottom;
|
||||
|
||||
lv_style_int_t knob_left = lv_obj_get_style_pad_left(obj, LV_SWITCH_PART_KNOB);
|
||||
lv_style_int_t knob_right = lv_obj_get_style_pad_right(obj, LV_SWITCH_PART_KNOB);
|
||||
lv_style_int_t knob_top = lv_obj_get_style_pad_top(obj, LV_SWITCH_PART_KNOB);
|
||||
lv_style_int_t knob_bottom = lv_obj_get_style_pad_bottom(obj, LV_SWITCH_PART_KNOB);
|
||||
lv_coord_t knob_left = lv_obj_get_style_pad_left(obj, LV_PART_KNOB);
|
||||
lv_coord_t knob_right = lv_obj_get_style_pad_right(obj, LV_PART_KNOB);
|
||||
lv_coord_t knob_top = lv_obj_get_style_pad_top(obj, LV_PART_KNOB);
|
||||
lv_coord_t knob_bottom = lv_obj_get_style_pad_bottom(obj, LV_PART_KNOB);
|
||||
|
||||
/*Apply the paddings on the knob area*/
|
||||
knob_area.x1 -= knob_left;
|
||||
@ -202,7 +191,7 @@ static lv_design_res_t lv_switch_design(lv_obj_t * obj, const lv_area_t * clip_a
|
||||
|
||||
lv_draw_rect_dsc_t knob_rect_dsc;
|
||||
lv_draw_rect_dsc_init(&knob_rect_dsc);
|
||||
lv_obj_init_draw_rect_dsc(obj, LV_SWITCH_PART_KNOB, &knob_rect_dsc);
|
||||
lv_obj_init_draw_rect_dsc(obj, LV_PART_KNOB, &knob_rect_dsc);
|
||||
|
||||
lv_draw_rect(&knob_area, clip_area, &knob_rect_dsc);
|
||||
|
||||
@ -231,28 +220,23 @@ static lv_res_t lv_switch_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
||||
res = lv_switch.base_p->signal_cb(obj, sign, param);
|
||||
if(res != LV_RES_OK) return res;
|
||||
|
||||
if(sign == LV_SIGNAL_GET_STYLE) {
|
||||
lv_get_style_info_t * info = param;
|
||||
info->result = lv_switch_get_style(obj, info->part);
|
||||
if(info->result != NULL) return LV_RES_OK;
|
||||
else return lv_switch.base_p->signal_cb(obj, sign, param);
|
||||
}
|
||||
|
||||
else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
|
||||
lv_style_int_t knob_left = lv_obj_get_style_pad_left(obj, LV_SWITCH_PART_KNOB);
|
||||
lv_style_int_t knob_right = lv_obj_get_style_pad_right(obj, LV_SWITCH_PART_KNOB);
|
||||
lv_style_int_t knob_top = lv_obj_get_style_pad_top(obj, LV_SWITCH_PART_KNOB);
|
||||
lv_style_int_t knob_bottom = lv_obj_get_style_pad_bottom(obj, LV_SWITCH_PART_KNOB);
|
||||
lv_coord_t knob_left = lv_obj_get_style_pad_left(obj, LV_PART_KNOB);
|
||||
lv_coord_t knob_right = lv_obj_get_style_pad_right(obj, LV_PART_KNOB);
|
||||
lv_coord_t knob_top = lv_obj_get_style_pad_top(obj, LV_PART_KNOB);
|
||||
lv_coord_t knob_bottom = lv_obj_get_style_pad_bottom(obj, LV_PART_KNOB);
|
||||
|
||||
/* The smaller size is the knob diameter*/
|
||||
lv_coord_t knob_size = LV_MATH_MIN(lv_obj_get_width(obj), lv_obj_get_height(obj)) >> 1;
|
||||
knob_size += LV_MATH_MAX(LV_MATH_MAX(knob_left, knob_right), LV_MATH_MAX(knob_bottom, knob_top));
|
||||
knob_size += 2; /*For rounding error*/
|
||||
|
||||
knob_size += _lv_obj_get_draw_rect_ext_pad_size(obj, LV_SWITCH_PART_KNOB);
|
||||
knob_size += _lv_obj_get_draw_rect_ext_pad_size(obj, LV_PART_KNOB);
|
||||
|
||||
lv_coord_t * s = param;
|
||||
*s = LV_MATH_MAX(*s, knob_size);
|
||||
*s = LV_MATH_MAX(*s, _lv_obj_get_draw_rect_ext_pad_size(obj, LV_SWITCH_PART_INDIC));
|
||||
*s = LV_MATH_MAX(*s, _lv_obj_get_draw_rect_ext_pad_size(obj, LV_PART_INDICATOR));
|
||||
}
|
||||
else if(sign == LV_SIGNAL_RELEASED) {
|
||||
lv_obj_invalidate(obj);
|
||||
@ -267,27 +251,4 @@ static lv_res_t lv_switch_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
||||
return res;
|
||||
}
|
||||
|
||||
static lv_style_list_t * lv_switch_get_style(lv_obj_t * obj, uint8_t part)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
lv_switch_t * sw = (lv_switch_t *) obj;
|
||||
lv_style_list_t * style_dsc_p;
|
||||
|
||||
switch(part) {
|
||||
case LV_SWITCH_PART_MAIN:
|
||||
style_dsc_p = &sw->style_list;
|
||||
break;
|
||||
case LV_SWITCH_PART_INDIC:
|
||||
style_dsc_p = &sw->style_indic;
|
||||
break;
|
||||
case LV_SWITCH_PART_KNOB:
|
||||
style_dsc_p = &sw->style_knob;
|
||||
break;
|
||||
default:
|
||||
style_dsc_p = NULL;
|
||||
}
|
||||
|
||||
return style_dsc_p;
|
||||
}
|
||||
#endif
|
||||
|
@ -38,9 +38,7 @@ LV_CLASS_DECLARE_START(lv_switch, lv_obj);
|
||||
#define _lv_switch_constructor void (*constructor)(struct _lv_obj_t * obj, struct _lv_obj_t * parent, const struct _lv_obj_t * copy)
|
||||
|
||||
#define _lv_switch_data \
|
||||
_lv_obj_data \
|
||||
lv_style_list_t style_indic; \
|
||||
lv_style_list_t style_knob;
|
||||
_lv_obj_data
|
||||
|
||||
#define _lv_switch_class_dsc \
|
||||
_lv_obj_class_dsc \
|
||||
@ -49,18 +47,6 @@ LV_CLASS_DECLARE_END(lv_switch, lv_obj);
|
||||
|
||||
extern lv_switch_class_t lv_switch;
|
||||
|
||||
/**
|
||||
* Switch parts.
|
||||
*/
|
||||
enum {
|
||||
LV_SWITCH_PART_MAIN = LV_OBJ_PART_MAIN, /**< Switch background. */
|
||||
LV_SWITCH_PART_INDIC, /**< Switch fill area. */
|
||||
LV_SWITCH_PART_KNOB, /**< Switch knob. */
|
||||
_LV_SWITCH_PART_VIRTUAL_LAST
|
||||
};
|
||||
|
||||
typedef uint8_t lv_switch_part_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
Loading…
x
Reference in New Issue
Block a user