change data inheritance model (drop ext)
This commit is contained in:
@@ -91,7 +91,8 @@ const lv_obj_class_t lv_obj = {
|
||||
.destructor = lv_obj_destructor,
|
||||
.signal_cb = lv_obj_signal,
|
||||
.design_cb = lv_obj_design,
|
||||
.ext_size = 0,
|
||||
.instance_size = (sizeof(lv_obj_t)),
|
||||
.base_class = NULL,
|
||||
};
|
||||
|
||||
/**********************
|
||||
@@ -223,15 +224,10 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
|
||||
|
||||
lv_obj_t * lv_obj_create_from_class(const lv_obj_class_t * class, lv_obj_t * parent, const lv_obj_t * copy)
|
||||
{
|
||||
lv_obj_t * obj = lv_mem_alloc(sizeof(lv_obj_t));
|
||||
_lv_memset_00(obj, sizeof(lv_obj_t));
|
||||
lv_obj_t * obj = lv_mem_alloc(class->instance_size);
|
||||
_lv_memset_00(obj, class->instance_size);
|
||||
obj->class_p = class;
|
||||
|
||||
if(obj->class_p->ext_size) {
|
||||
obj->ext_attr = lv_mem_alloc(obj->class_p->ext_size);
|
||||
_lv_memset_00(obj->ext_attr, obj->class_p->ext_size);
|
||||
}
|
||||
|
||||
class->constructor(obj, parent, copy);
|
||||
|
||||
if(!copy) lv_theme_apply(obj);
|
||||
|
||||
@@ -235,17 +235,17 @@ typedef struct {
|
||||
|
||||
#define _lv_obj_constructor
|
||||
|
||||
typedef struct {
|
||||
typedef struct lv_obj_class{
|
||||
const struct lv_obj_class * base_class;
|
||||
void (*constructor)(struct _lv_obj_t * obj, struct _lv_obj_t * parent, const struct _lv_obj_t * copy);
|
||||
void (*destructor)(struct _lv_obj_t * obj);
|
||||
lv_signal_cb_t signal_cb; /**< Object type specific signal function*/
|
||||
lv_design_cb_t design_cb; /**< Object type specific design function*/
|
||||
uint32_t ext_size;
|
||||
uint32_t instance_size;
|
||||
}lv_obj_class_t;
|
||||
|
||||
typedef struct _lv_obj_t{
|
||||
const lv_obj_class_t * class_p;
|
||||
void * ext_attr;
|
||||
struct _lv_obj_t * parent;
|
||||
lv_obj_spec_attr_t * spec_attr;
|
||||
lv_obj_style_list_t style_list;
|
||||
@@ -269,7 +269,8 @@ enum {
|
||||
LV_PART_HIGHLIGHT,
|
||||
LV_PART_PLACEHOLDER,
|
||||
LV_PART_CURSOR,
|
||||
LV_PART_ITEM,
|
||||
LV_PART_ITEMS,
|
||||
LV_PART_MARKER,
|
||||
|
||||
LV_PART_CUSTOM_1,
|
||||
LV_PART_CUSTOM_2,
|
||||
|
||||
@@ -337,7 +337,7 @@ lv_coord_t _lv_obj_get_draw_rect_ext_pad_size(lv_obj_t * obj, uint8_t part)
|
||||
lv_coord_t letter_space = lv_obj_get_style_text_letter_space(obj, part);
|
||||
lv_coord_t line_space = lv_obj_get_style_text_letter_space(obj, part);
|
||||
const lv_font_t * font = lv_obj_get_style_text_font(obj, part);
|
||||
_lv_txt_get_size(&content_size, content_src, font, letter_space, line_space, LV_COORD_MAX, LV_TXT_FLAG_NONE);
|
||||
_lv_txt_get_size(&content_size, content_src, font, letter_space, line_space, LV_COORD_MAX, LV_TEXT_FLAG_NONE);
|
||||
}
|
||||
} else {
|
||||
content_opa = lv_obj_get_style_img_opa(obj, part);
|
||||
|
||||
@@ -289,34 +289,34 @@ static lv_style_value_t apply_color_filter(const lv_obj_t * obj, uint32_t part,
|
||||
}
|
||||
static bool get_prop_core(const lv_obj_t * obj, uint8_t part, lv_style_prop_t prop, lv_style_value_t * v)
|
||||
{
|
||||
cache_t cache_res = read_cache(obj, part, prop);
|
||||
switch(cache_res) {
|
||||
case CACHE_ZERO:
|
||||
v->ptr = 0;
|
||||
return true;
|
||||
case CACHE_TRUE:
|
||||
v->num = 1;
|
||||
return true;
|
||||
case CACHE_255:
|
||||
v->num = 255;
|
||||
return true;
|
||||
case CACHE_UNSET:
|
||||
return false;
|
||||
case CACHE_NEED_CHECK:
|
||||
break;
|
||||
|
||||
default: /*CACHE_INDEX*/
|
||||
cache_res -= CACHE_INDEX;
|
||||
if(cache_res) {
|
||||
if(prop == LV_STYLE_BG_COLOR_FILTERED || prop == LV_STYLE_TEXT_COLOR_FILTERED) {
|
||||
v->color = lv_style_get_indexed_color(cache_res);
|
||||
} else {
|
||||
v->num = lv_style_get_indexed_num(cache_res);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
// cache_t cache_res = read_cache(obj, part, prop);
|
||||
// switch(cache_res) {
|
||||
// case CACHE_ZERO:
|
||||
// v->ptr = 0;
|
||||
// return true;
|
||||
// case CACHE_TRUE:
|
||||
// v->num = 1;
|
||||
// return true;
|
||||
// case CACHE_255:
|
||||
// v->num = 255;
|
||||
// return true;
|
||||
// case CACHE_UNSET:
|
||||
// return false;
|
||||
// case CACHE_NEED_CHECK:
|
||||
// break;
|
||||
//
|
||||
// default: /*CACHE_INDEX*/
|
||||
// cache_res -= CACHE_INDEX;
|
||||
// if(cache_res) {
|
||||
// if(prop == LV_STYLE_BG_COLOR || prop == LV_STYLE_TEXT_COLOR) {
|
||||
// v->color = lv_style_get_indexed_color(cache_res);
|
||||
// } else {
|
||||
// v->num = lv_style_get_indexed_num(cache_res);
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
|
||||
|
||||
int32_t weight = -1;
|
||||
@@ -389,6 +389,9 @@ lv_style_value_t lv_obj_get_style_prop(const lv_obj_t * obj, uint8_t part, lv_st
|
||||
lv_style_value_t value_act;
|
||||
bool inherit = prop & LV_STYLE_PROP_INHERIT ? true : false;
|
||||
bool filter = prop & LV_STYLE_PROP_FILTER ? true : false;
|
||||
if(filter) {
|
||||
prop &= ~LV_STYLE_PROP_FILTER;
|
||||
}
|
||||
bool found = false;
|
||||
while(obj) {
|
||||
found = get_prop_core(obj, part, prop, &value_act);
|
||||
@@ -599,57 +602,58 @@ 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->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;
|
||||
|
||||
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->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->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;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 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;
|
||||
//
|
||||
// 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->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->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;
|
||||
}
|
||||
@@ -1102,9 +1106,11 @@ static void trans_anim_cb(lv_style_trans_t * tr, lv_anim_value_t v)
|
||||
refr = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(tr->prop == LV_STYLE_TRANSFORM_HEIGHT) {
|
||||
printf("set\n");
|
||||
}
|
||||
lv_style_set_prop(list->styles[i].style, tr->prop, value_final);
|
||||
if (refr)_lv_obj_refresh_style(tr->obj, tr->prop);
|
||||
if (refr) _lv_obj_refresh_style(tr->obj, tr->prop);
|
||||
break;
|
||||
|
||||
}
|
||||
@@ -1125,6 +1131,13 @@ static void trans_anim_start_cb(lv_anim_t * a)
|
||||
trans_del(tr->obj, tr->part, prop_tmp, tr);
|
||||
|
||||
tr->prop = prop_tmp;
|
||||
|
||||
lv_obj_style_t * style_trans = _get_trans_style(tr->obj, tr->part);
|
||||
lv_style_set_prop(style_trans->style, tr->prop, tr->start_value); /*Be sure `trans_style` has a valid value */
|
||||
|
||||
if(tr->prop == LV_STYLE_TRANSFORM_HEIGHT) {
|
||||
printf("start\n");
|
||||
}
|
||||
}
|
||||
|
||||
static void trans_anim_ready_cb(lv_anim_t * a)
|
||||
|
||||
@@ -226,6 +226,9 @@ static inline lv_coord_t lv_obj_get_style_transform_angle(const struct _lv_obj_t
|
||||
static inline lv_opa_t lv_obj_get_style_opa(const struct _lv_obj_t * obj, uint32_t part) {
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OPA); return v.num; }
|
||||
|
||||
static inline lv_opa_t lv_obj_get_style_anim_time(const struct _lv_obj_t * obj, uint32_t part) {
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_ANIM_TIME); return v.num; }
|
||||
|
||||
static inline lv_color_filter_cb_t lv_obj_get_style_color_filter_cb(const struct _lv_obj_t * obj, uint32_t part) {
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_COLOR_FILTER_CB); return (lv_color_filter_cb_t)v.func; }
|
||||
|
||||
@@ -316,6 +319,9 @@ static inline lv_coord_t lv_obj_get_style_text_letter_space(const struct _lv_obj
|
||||
static inline lv_coord_t lv_obj_get_style_text_line_space(const struct _lv_obj_t * obj, uint32_t part) {
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_LINE_SPACE); return v.num; }
|
||||
|
||||
static inline lv_coord_t lv_obj_get_style_text_align(const struct _lv_obj_t * obj, uint32_t part) {
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_ALIGN); return v.num; }
|
||||
|
||||
static inline lv_text_decor_t lv_obj_get_style_text_decor(const struct _lv_obj_t * obj, uint32_t part) {
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_DECOR); return v.num; }
|
||||
|
||||
|
||||
@@ -281,7 +281,7 @@ void _lv_disp_refr_task(lv_timer_t * tmr)
|
||||
static lv_obj_t * perf_label = NULL;
|
||||
if(perf_label == NULL) {
|
||||
perf_label = lv_label_create(lv_layer_sys(), NULL);
|
||||
lv_label_set_align(perf_label, LV_LABEL_ALIGN_RIGHT);
|
||||
lv_label_set_align(perf_label, LV_TEXT_ALIGN_RIGHT);
|
||||
lv_obj_set_style_local_bg_opa(perf_label, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_COVER);
|
||||
lv_obj_set_style_local_bg_color(perf_label, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
||||
lv_obj_set_style_local_text_color(perf_label, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -72,6 +72,13 @@ enum {
|
||||
};
|
||||
|
||||
typedef uint8_t lv_text_decor_t;
|
||||
/** Label align policy*/
|
||||
enum {
|
||||
LV_TEXT_ALIGN_LEFT, /**< Align text to left */
|
||||
LV_TEXT_ALIGN_CENTER, /**< Align text to center */
|
||||
LV_TEXT_ALIGN_RIGHT, /**< Align text to right */
|
||||
};
|
||||
typedef uint8_t lv_text_align_t;
|
||||
|
||||
|
||||
typedef union {
|
||||
@@ -92,7 +99,8 @@ typedef enum {
|
||||
LV_STYLE_OPA = 7 | LV_STYLE_PROP_INHERIT,
|
||||
LV_STYLE_COLOR_FILTER_CB = 8,
|
||||
LV_STYLE_COLOR_FILTER_OPA = 9,
|
||||
LV_STYLE_TRANSITION = 10,
|
||||
LV_STYLE_ANIM_TIME = 10,
|
||||
LV_STYLE_TRANSITION = 11,
|
||||
|
||||
LV_STYLE_PAD_TOP = 20 | LV_STYLE_PROP_LAYOUT_REFR,
|
||||
LV_STYLE_PAD_BOTTOM = 21 | LV_STYLE_PROP_LAYOUT_REFR,
|
||||
@@ -126,7 +134,8 @@ typedef enum {
|
||||
LV_STYLE_TEXT_LETTER_SPACE = 53 | LV_STYLE_PROP_INHERIT,
|
||||
LV_STYLE_TEXT_LINE_SPACE = 54 | LV_STYLE_PROP_INHERIT,
|
||||
LV_STYLE_TEXT_DECOR = 55 | LV_STYLE_PROP_INHERIT,
|
||||
LV_STYLE_TEXT_BLEND_MODE = 56 | LV_STYLE_PROP_INHERIT,
|
||||
LV_STYLE_TEXT_ALIGN = 56 | LV_STYLE_PROP_INHERIT,
|
||||
LV_STYLE_TEXT_BLEND_MODE = 57 | LV_STYLE_PROP_INHERIT,
|
||||
|
||||
LV_STYLE_IMG_OPA = 60,
|
||||
LV_STYLE_IMG_BLEND_MODE = 61,
|
||||
@@ -171,136 +180,6 @@ typedef enum {
|
||||
|
||||
struct _lv_style_transiton_t;
|
||||
|
||||
typedef struct {
|
||||
lv_color_filter_cb_t color_filter_cb;
|
||||
const struct _lv_style_transiton_t * transition;
|
||||
const char * content_src;
|
||||
const lv_font_t * text_font;
|
||||
|
||||
lv_color_t bg_color;
|
||||
lv_color_t bg_grad_color;
|
||||
lv_color_t border_color;
|
||||
lv_color_t text_color;
|
||||
lv_color_t outline_color;
|
||||
lv_color_t shadow_color;
|
||||
lv_color_t img_recolor;
|
||||
lv_color_t line_color;
|
||||
|
||||
lv_opa_t opa;
|
||||
lv_opa_t color_filter_opa;
|
||||
lv_opa_t bg_opa;
|
||||
lv_opa_t bg_main_stop;
|
||||
lv_opa_t bg_grad_stop;
|
||||
lv_opa_t border_opa;
|
||||
lv_opa_t outline_opa;
|
||||
lv_opa_t img_opa;
|
||||
lv_opa_t img_recolor_opa;
|
||||
lv_opa_t text_opa;
|
||||
lv_opa_t shadow_opa;
|
||||
lv_opa_t line_opa;
|
||||
|
||||
int8_t transform_width;
|
||||
int8_t transform_height;
|
||||
int8_t pad_top;
|
||||
int8_t pad_bottom;
|
||||
int8_t pad_left;
|
||||
int8_t pad_right;
|
||||
int8_t pad_row;
|
||||
int8_t pad_column;
|
||||
int8_t border_width;
|
||||
uint8_t outline_width;
|
||||
uint8_t outline_pad;
|
||||
int8_t shadow_width;
|
||||
int8_t shadow_ofs_x;
|
||||
int8_t shadow_ofs_y;
|
||||
int8_t shadow_spread;
|
||||
int8_t text_letter_space;
|
||||
int8_t text_line_space;
|
||||
uint8_t line_width;
|
||||
uint8_t line_dash_width;
|
||||
uint8_t line_dash_gap;
|
||||
int8_t content_ofs_x;
|
||||
int8_t content_ofs_y;
|
||||
|
||||
uint32_t radius:12;
|
||||
uint32_t content_align :5;
|
||||
uint32_t border_side :5;
|
||||
uint32_t bg_blend_mode :2;
|
||||
uint32_t border_blend_mode :2;
|
||||
uint32_t outline_blend_mode :2;
|
||||
uint32_t shadow_blend_mode :2;
|
||||
uint32_t text_decor :2;
|
||||
|
||||
uint32_t transform_zoom :14;
|
||||
uint32_t transform_angle :14;
|
||||
uint32_t text_blend_mode :2;
|
||||
uint32_t line_blend_mode :2;
|
||||
uint32_t img_blend_mode :2;
|
||||
|
||||
struct{
|
||||
uint32_t color_filter_cb:1;
|
||||
uint32_t transition:1;
|
||||
uint32_t content_src:1;
|
||||
uint32_t bg_color:1;
|
||||
uint32_t bg_grad_color:1;
|
||||
uint32_t border_color:1;
|
||||
uint32_t text_color:1;
|
||||
uint32_t outline_color:1;
|
||||
uint32_t shadow_color:1;
|
||||
uint32_t img_recolor:1;
|
||||
uint32_t line_color:1;
|
||||
uint32_t opa:1;
|
||||
uint32_t color_filter_opa:1;
|
||||
uint32_t bg_opa:1;
|
||||
uint32_t bg_main_stop:1;
|
||||
uint32_t bg_grad_stop:1;
|
||||
uint32_t border_opa:1;
|
||||
uint32_t outline_opa:1;
|
||||
uint32_t img_opa:1;
|
||||
uint32_t img_recolor_opa:1;
|
||||
uint32_t text_font:1;
|
||||
uint32_t text_opa:1;
|
||||
uint32_t shadow_opa:1;
|
||||
uint32_t line_opa:1;
|
||||
uint32_t radius:1;
|
||||
uint32_t transform_width:1;
|
||||
uint32_t transform_height:1;
|
||||
uint32_t pad_top:1;
|
||||
uint32_t pad_bottom:1;
|
||||
uint32_t pad_left:1;
|
||||
uint32_t pad_right:1;
|
||||
uint32_t pad_row:1;
|
||||
uint32_t pad_column:1;
|
||||
uint32_t border_width:1;
|
||||
uint32_t outline_width:1;
|
||||
uint32_t outline_pad:1;
|
||||
uint32_t shadow_width:1;
|
||||
uint32_t shadow_ofs_x:1;
|
||||
uint32_t shadow_ofs_y:1;
|
||||
uint32_t shadow_spread:1;
|
||||
uint32_t text_letter_space:1;
|
||||
uint32_t text_line_space:1;
|
||||
uint32_t line_width:1;
|
||||
uint32_t line_dash_width:1;
|
||||
uint32_t line_dash_gap:1;
|
||||
uint32_t content_ofs_x:1;
|
||||
uint32_t content_ofs_y:1;
|
||||
uint32_t transform_zoom:1;
|
||||
uint32_t transform_angle:1;
|
||||
uint32_t bg_blend_mode:1;
|
||||
uint32_t border_blend_mode:1;
|
||||
uint32_t outline_blend_mode:1;
|
||||
uint32_t shadow_blend_mode:1;
|
||||
uint32_t text_decor:1;
|
||||
uint32_t text_blend_mode:1;
|
||||
uint32_t img_blend_mode:1;
|
||||
uint32_t line_blend_mode:1;
|
||||
uint32_t content_align:1;
|
||||
uint32_t border_side:1;
|
||||
}has;
|
||||
}lv_style_ext_t;
|
||||
|
||||
|
||||
typedef struct _lv_style_transiton_t{
|
||||
const lv_style_prop_t * props;
|
||||
const lv_anim_path_t * path;
|
||||
@@ -323,58 +202,21 @@ typedef struct {
|
||||
}lv_style_class_t;
|
||||
|
||||
typedef struct _lv_style_t{
|
||||
lv_style_class_t * class_p;
|
||||
lv_style_ext_t * ext;
|
||||
|
||||
_LV_STYLE_SENTINEL
|
||||
/*32*/
|
||||
uint32_t radius :5;
|
||||
uint32_t transform_width :5;
|
||||
uint32_t transform_height :5;
|
||||
uint32_t opa :5;
|
||||
uint32_t color_filter_cb :4;
|
||||
uint32_t transition :4;
|
||||
uint32_t bg_color :4;
|
||||
union {
|
||||
struct {
|
||||
lv_style_value_t value1;
|
||||
};
|
||||
struct {
|
||||
uint8_t * props_and_values;
|
||||
};
|
||||
};
|
||||
|
||||
/*32*/
|
||||
uint32_t color_filter_opa :5;
|
||||
uint32_t bg_opa :5;
|
||||
uint32_t border_opa:5;
|
||||
uint32_t img_opa:5;
|
||||
uint32_t bg_grad_color :4;
|
||||
uint32_t border_color:4;
|
||||
uint32_t border_width:4;
|
||||
|
||||
/*32*/
|
||||
uint32_t pad_top:5;
|
||||
uint32_t pad_bottom:5;
|
||||
uint32_t pad_left:5;
|
||||
uint32_t pad_right:5;
|
||||
uint32_t text_color:4;
|
||||
uint32_t text_font :4;
|
||||
uint32_t line_color :4;
|
||||
|
||||
/*32*/
|
||||
uint32_t text_opa:5;
|
||||
uint32_t line_width :5;
|
||||
uint32_t line_opa :5;
|
||||
uint32_t outline_width:5;
|
||||
uint32_t outline_pad:5;
|
||||
uint32_t outline_opa:5;
|
||||
uint32_t bg_grad_dir:2;
|
||||
|
||||
/*25*/
|
||||
uint32_t shadow_width:5;
|
||||
uint32_t shadow_opa:4;
|
||||
uint32_t outline_color:4;
|
||||
uint32_t shadow_color:4;
|
||||
uint32_t line_rounded:1;
|
||||
uint32_t border_post:1;
|
||||
uint32_t clip_corner:1;
|
||||
uint32_t has_line_rounded:1;
|
||||
uint32_t has_clip_corner:1;
|
||||
uint32_t has_bg_grad_dir:1;
|
||||
uint32_t has_border_post:1;
|
||||
uint32_t dont_index:1;
|
||||
uint16_t prop1;
|
||||
uint16_t prop_cnt:14;
|
||||
uint16_t allocated:1;
|
||||
uint16_t dont_index:1;
|
||||
} lv_style_t;
|
||||
|
||||
extern lv_style_class_t lv_style;
|
||||
|
||||
@@ -129,7 +129,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area
|
||||
bool clip_ok = _lv_area_intersect(&clipped_area, coords, mask);
|
||||
if(!clip_ok) return;
|
||||
|
||||
if((dsc->flag & LV_TXT_FLAG_EXPAND) == 0) {
|
||||
if((dsc->flag & LV_TEXT_FLAG_EXPAND) == 0) {
|
||||
/*Normally use the label's width as width*/
|
||||
w = lv_area_get_width(coords);
|
||||
}
|
||||
@@ -194,14 +194,14 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area
|
||||
}
|
||||
|
||||
/*Align to middle*/
|
||||
if(dsc->flag & LV_TXT_FLAG_CENTER) {
|
||||
if(dsc->flag & LV_TEXT_FLAG_CENTER) {
|
||||
line_width = _lv_txt_get_width(&txt[line_start], line_end - line_start, font, dsc->letter_space, dsc->flag);
|
||||
|
||||
pos.x += (lv_area_get_width(coords) - line_width) / 2;
|
||||
|
||||
}
|
||||
/*Align to the right*/
|
||||
else if(dsc->flag & LV_TXT_FLAG_RIGHT) {
|
||||
else if(dsc->flag & LV_TEXT_FLAG_RIGHT) {
|
||||
line_width = _lv_txt_get_width(&txt[line_start], line_end - line_start, font, dsc->letter_space, dsc->flag);
|
||||
pos.x += lv_area_get_width(coords) - line_width;
|
||||
}
|
||||
@@ -267,7 +267,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area
|
||||
uint32_t letter_next = _lv_txt_encoded_next(&bidi_txt[i], NULL);
|
||||
|
||||
/*Handle the re-color command*/
|
||||
if((dsc->flag & LV_TXT_FLAG_RECOLOR) != 0) {
|
||||
if((dsc->flag & LV_TEXT_FLAG_RECOLOR) != 0) {
|
||||
if(letter == (uint32_t)LV_TXT_COLOR_CMD[0]) {
|
||||
if(cmd_state == CMD_STATE_WAIT) { /*Start char*/
|
||||
par_start = i;
|
||||
@@ -361,7 +361,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area
|
||||
|
||||
pos.x = coords->x1;
|
||||
/*Align to middle*/
|
||||
if(dsc->flag & LV_TXT_FLAG_CENTER) {
|
||||
if(dsc->flag & LV_TEXT_FLAG_CENTER) {
|
||||
line_width =
|
||||
_lv_txt_get_width(&txt[line_start], line_end - line_start, font, dsc->letter_space, dsc->flag);
|
||||
|
||||
@@ -369,7 +369,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area
|
||||
|
||||
}
|
||||
/*Align to the right*/
|
||||
else if(dsc->flag & LV_TXT_FLAG_RIGHT) {
|
||||
else if(dsc->flag & LV_TEXT_FLAG_RIGHT) {
|
||||
line_width =
|
||||
_lv_txt_get_width(&txt[line_start], line_end - line_start, font, dsc->letter_space, dsc->flag);
|
||||
pos.x += lv_area_get_width(coords) - line_width;
|
||||
|
||||
@@ -39,7 +39,7 @@ typedef struct {
|
||||
lv_coord_t ofs_x;
|
||||
lv_coord_t ofs_y;
|
||||
lv_bidi_dir_t bidi_dir;
|
||||
lv_txt_flag_t flag;
|
||||
lv_text_flag_t flag;
|
||||
lv_text_decor_t decor;
|
||||
lv_blend_mode_t blend_mode;
|
||||
} lv_draw_label_dsc_t;
|
||||
|
||||
@@ -1211,7 +1211,7 @@ static void draw_content(const lv_area_t * coords, const lv_area_t * clip, const
|
||||
label_dsc.opa = dsc->content_opa;
|
||||
lv_point_t s;
|
||||
_lv_txt_get_size(&s, dsc->content_src, label_dsc.font, label_dsc.letter_space, label_dsc.line_space, LV_COORD_MAX,
|
||||
LV_TXT_FLAG_NONE);
|
||||
LV_TEXT_FLAG_NONE);
|
||||
img_w = s.x;
|
||||
img_h = s.y;
|
||||
|
||||
|
||||
@@ -475,7 +475,8 @@ static void anim_task(lv_timer_t * param)
|
||||
if(a->path.cb) new_value = a->path.cb(&a->path, a);
|
||||
else new_value = lv_anim_path_linear(&a->path, a);
|
||||
|
||||
if(new_value != a->current) {
|
||||
if(new_value != a->current)
|
||||
{
|
||||
a->current = new_value;
|
||||
/*Apply the calculated value*/
|
||||
if(a->exec_cb) a->exec_cb(a->var, new_value);
|
||||
|
||||
@@ -19,23 +19,6 @@ extern "C" {
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_MATH_MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#define LV_MATH_MIN3(a, b, c) (LV_MATH_MIN(LV_MATH_MIN(a,b), c))
|
||||
#define LV_MATH_MIN4(a, b, c, d) (LV_MATH_MIN(LV_MATH_MIN(a,b), LV_MATH_MIN(c,d)))
|
||||
|
||||
#define LV_MATH_MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#define LV_MATH_MAX3(a, b, c) (LV_MATH_MAX(LV_MATH_MAX(a,b), c))
|
||||
#define LV_MATH_MAX4(a, b, c, d) (LV_MATH_MAX(LV_MATH_MAX(a,b), LV_MATH_MAX(c,d)))
|
||||
|
||||
#define LV_MATH_ABS(x) ((x) > 0 ? (x) : (-(x)))
|
||||
|
||||
#define LV_MATH_UDIV255(x) ((uint32_t)((uint32_t) (x) * 0x8081) >> 0x17)
|
||||
|
||||
#define LV_IS_SIGNED(t) (((t)(-1)) < ((t) 0))
|
||||
#define LV_UMAX_OF(t) (((0x1ULL << ((sizeof(t) * 8ULL) - 1ULL)) - 1ULL) | (0xFULL << ((sizeof(t) * 8ULL) - 4ULL)))
|
||||
#define LV_SMAX_OF(t) (((0x1ULL << ((sizeof(t) * 8ULL) - 1ULL)) - 1ULL) | (0x7ULL << ((sizeof(t) * 8ULL) - 4ULL)))
|
||||
#define LV_MAX_OF(t) ((unsigned long) (LV_IS_SIGNED(t) ? LV_SMAX_OF(t) : LV_UMAX_OF(t)))
|
||||
|
||||
#define LV_TRIGO_SIN_MAX 32767
|
||||
#define LV_TRIGO_SHIFT 15 /**< >> LV_TRIGO_SHIFT to normalize*/
|
||||
|
||||
@@ -121,9 +104,29 @@ int64_t _lv_pow(int64_t base, int8_t exp);
|
||||
*/
|
||||
int16_t _lv_map(int32_t x, int32_t min_in, int32_t max_in, int32_t min, int32_t max);
|
||||
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
#define LV_MATH_MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#define LV_MATH_MIN3(a, b, c) (LV_MATH_MIN(LV_MATH_MIN(a,b), c))
|
||||
#define LV_MATH_MIN4(a, b, c, d) (LV_MATH_MIN(LV_MATH_MIN(a,b), LV_MATH_MIN(c,d)))
|
||||
|
||||
#define LV_MATH_MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#define LV_MATH_MAX3(a, b, c) (LV_MATH_MAX(LV_MATH_MAX(a,b), c))
|
||||
#define LV_MATH_MAX4(a, b, c, d) (LV_MATH_MAX(LV_MATH_MAX(a,b), LV_MATH_MAX(c,d)))
|
||||
|
||||
#define LV_CLAMP(min, val, max) ((val) = LV_MATH_MAX(min, LV_MATH_MIN(val, max)))
|
||||
|
||||
#define LV_MATH_ABS(x) ((x) > 0 ? (x) : (-(x)))
|
||||
|
||||
#define LV_MATH_UDIV255(x) ((uint32_t)((uint32_t) (x) * 0x8081) >> 0x17)
|
||||
|
||||
#define LV_IS_SIGNED(t) (((t)(-1)) < ((t) 0))
|
||||
#define LV_UMAX_OF(t) (((0x1ULL << ((sizeof(t) * 8ULL) - 1ULL)) - 1ULL) | (0xFULL << ((sizeof(t) * 8ULL) - 4ULL)))
|
||||
#define LV_SMAX_OF(t) (((0x1ULL << ((sizeof(t) * 8ULL) - 1ULL)) - 1ULL) | (0x7ULL << ((sizeof(t) * 8ULL) - 4ULL)))
|
||||
#define LV_MAX_OF(t) ((unsigned long) (LV_IS_SIGNED(t) ? LV_SMAX_OF(t) : LV_UMAX_OF(t)))
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
||||
@@ -94,7 +94,7 @@ static inline bool is_break_char(uint32_t letter);
|
||||
* line breaks
|
||||
*/
|
||||
void _lv_txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t * font, lv_coord_t letter_space,
|
||||
lv_coord_t line_space, lv_coord_t max_width, lv_txt_flag_t flag)
|
||||
lv_coord_t line_space, lv_coord_t max_width, lv_text_flag_t flag)
|
||||
{
|
||||
size_res->x = 0;
|
||||
size_res->y = 0;
|
||||
@@ -102,7 +102,7 @@ void _lv_txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t
|
||||
if(text == NULL) return;
|
||||
if(font == NULL) return;
|
||||
|
||||
if(flag & LV_TXT_FLAG_EXPAND) max_width = LV_COORD_MAX;
|
||||
if(flag & LV_TEXT_FLAG_EXPAND) max_width = LV_COORD_MAX;
|
||||
|
||||
uint32_t line_start = 0;
|
||||
uint32_t new_line_start = 0;
|
||||
@@ -174,12 +174,12 @@ void _lv_txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t
|
||||
*/
|
||||
static uint32_t lv_txt_get_next_word(const char * txt, const lv_font_t * font,
|
||||
lv_coord_t letter_space, lv_coord_t max_width,
|
||||
lv_txt_flag_t flag, uint32_t * word_w_ptr, lv_txt_cmd_state_t * cmd_state, bool force)
|
||||
lv_text_flag_t flag, uint32_t * word_w_ptr, lv_text_cmd_state_t * cmd_state, bool force)
|
||||
{
|
||||
if(txt == NULL || txt[0] == '\0') return 0;
|
||||
if(font == NULL) return 0;
|
||||
|
||||
if(flag & LV_TXT_FLAG_EXPAND) max_width = LV_COORD_MAX;
|
||||
if(flag & LV_TEXT_FLAG_EXPAND) max_width = LV_COORD_MAX;
|
||||
|
||||
uint32_t i = 0, i_next = 0, i_next_next = 0; /* Iterating index into txt */
|
||||
uint32_t letter = 0; /* Letter at i */
|
||||
@@ -199,7 +199,7 @@ static uint32_t lv_txt_get_next_word(const char * txt, const lv_font_t * font,
|
||||
word_len++;
|
||||
|
||||
/*Handle the recolor command*/
|
||||
if((flag & LV_TXT_FLAG_RECOLOR) != 0) {
|
||||
if((flag & LV_TEXT_FLAG_RECOLOR) != 0) {
|
||||
if(_lv_txt_is_cmd(cmd_state, letter) != false) {
|
||||
i = i_next;
|
||||
i_next = i_next_next;
|
||||
@@ -294,14 +294,14 @@ static uint32_t lv_txt_get_next_word(const char * txt, const lv_font_t * font,
|
||||
* @return the index of the first char of the new line (in byte index not letter index. With UTF-8 they are different)
|
||||
*/
|
||||
uint32_t _lv_txt_get_next_line(const char * txt, const lv_font_t * font,
|
||||
lv_coord_t letter_space, lv_coord_t max_width, lv_txt_flag_t flag)
|
||||
lv_coord_t letter_space, lv_coord_t max_width, lv_text_flag_t flag)
|
||||
{
|
||||
if(txt == NULL) return 0;
|
||||
if(font == NULL) return 0;
|
||||
|
||||
/* If max_width doesn't mater simply find the new line character
|
||||
* without thinking about word wrapping*/
|
||||
if((flag & LV_TXT_FLAG_EXPAND) || (flag & LV_TXT_FLAG_FIT)) {
|
||||
if((flag & LV_TEXT_FLAG_EXPAND) || (flag & LV_TEXT_FLAG_FIT)) {
|
||||
uint32_t i;
|
||||
for(i = 0; txt[i] != '\n' && txt[i] != '\r' && txt[i] != '\0'; i++) {
|
||||
/*Just find the new line chars or string ends by incrementing `i`*/
|
||||
@@ -310,8 +310,8 @@ uint32_t _lv_txt_get_next_line(const char * txt, const lv_font_t * font,
|
||||
return i;
|
||||
}
|
||||
|
||||
if(flag & LV_TXT_FLAG_EXPAND) max_width = LV_COORD_MAX;
|
||||
lv_txt_cmd_state_t cmd_state = LV_TXT_CMD_STATE_WAIT;
|
||||
if(flag & LV_TEXT_FLAG_EXPAND) max_width = LV_COORD_MAX;
|
||||
lv_text_cmd_state_t cmd_state = LV_TEXT_CMD_STATE_WAIT;
|
||||
uint32_t i = 0; /* Iterating index into txt */
|
||||
|
||||
while(txt[i] != '\0' && max_width > 0) {
|
||||
@@ -354,20 +354,20 @@ uint32_t _lv_txt_get_next_line(const char * txt, const lv_font_t * font,
|
||||
* @return length of a char_num long text
|
||||
*/
|
||||
lv_coord_t _lv_txt_get_width(const char * txt, uint32_t length, const lv_font_t * font, lv_coord_t letter_space,
|
||||
lv_txt_flag_t flag)
|
||||
lv_text_flag_t flag)
|
||||
{
|
||||
if(txt == NULL) return 0;
|
||||
if(font == NULL) return 0;
|
||||
|
||||
uint32_t i = 0;
|
||||
lv_coord_t width = 0;
|
||||
lv_txt_cmd_state_t cmd_state = LV_TXT_CMD_STATE_WAIT;
|
||||
lv_text_cmd_state_t cmd_state = LV_TEXT_CMD_STATE_WAIT;
|
||||
|
||||
if(length != 0) {
|
||||
while(i < length) {
|
||||
uint32_t letter = _lv_txt_encoded_next(txt, &i);
|
||||
uint32_t letter_next = _lv_txt_encoded_next(&txt[i], NULL);
|
||||
if((flag & LV_TXT_FLAG_RECOLOR) != 0) {
|
||||
if((flag & LV_TEXT_FLAG_RECOLOR) != 0) {
|
||||
if(_lv_txt_is_cmd(&cmd_state, letter) != false) {
|
||||
continue;
|
||||
}
|
||||
@@ -397,30 +397,30 @@ lv_coord_t _lv_txt_get_width(const char * txt, uint32_t length, const lv_font_t
|
||||
* @return true: the character is part of a command and should not be written,
|
||||
* false: the character should be written
|
||||
*/
|
||||
bool _lv_txt_is_cmd(lv_txt_cmd_state_t * state, uint32_t c)
|
||||
bool _lv_txt_is_cmd(lv_text_cmd_state_t * state, uint32_t c)
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
if(c == (uint32_t)LV_TXT_COLOR_CMD[0]) {
|
||||
if(*state == LV_TXT_CMD_STATE_WAIT) { /*Start char*/
|
||||
*state = LV_TXT_CMD_STATE_PAR;
|
||||
if(*state == LV_TEXT_CMD_STATE_WAIT) { /*Start char*/
|
||||
*state = LV_TEXT_CMD_STATE_PAR;
|
||||
ret = true;
|
||||
}
|
||||
/*Other start char in parameter is escaped cmd. char */
|
||||
else if(*state == LV_TXT_CMD_STATE_PAR) {
|
||||
*state = LV_TXT_CMD_STATE_WAIT;
|
||||
else if(*state == LV_TEXT_CMD_STATE_PAR) {
|
||||
*state = LV_TEXT_CMD_STATE_WAIT;
|
||||
}
|
||||
/*Command end */
|
||||
else if(*state == LV_TXT_CMD_STATE_IN) {
|
||||
*state = LV_TXT_CMD_STATE_WAIT;
|
||||
else if(*state == LV_TEXT_CMD_STATE_IN) {
|
||||
*state = LV_TEXT_CMD_STATE_WAIT;
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
|
||||
/*Skip the color parameter and wait the space after it*/
|
||||
if(*state == LV_TXT_CMD_STATE_PAR) {
|
||||
if(*state == LV_TEXT_CMD_STATE_PAR) {
|
||||
if(c == ' ') {
|
||||
*state = LV_TXT_CMD_STATE_IN; /*After the parameter the text is in the command*/
|
||||
*state = LV_TEXT_CMD_STATE_IN; /*After the parameter the text is in the command*/
|
||||
}
|
||||
ret = true;
|
||||
}
|
||||
|
||||
@@ -39,23 +39,23 @@ extern "C" {
|
||||
* Options for text rendering.
|
||||
*/
|
||||
enum {
|
||||
LV_TXT_FLAG_NONE = 0x00,
|
||||
LV_TXT_FLAG_RECOLOR = 0x01, /**< Enable parsing of recolor command*/
|
||||
LV_TXT_FLAG_EXPAND = 0x02, /**< Ignore max-width to avoid automatic word wrapping*/
|
||||
LV_TXT_FLAG_CENTER = 0x04, /**< Align the text to the middle*/
|
||||
LV_TXT_FLAG_RIGHT = 0x08, /**< Align the text to the right*/
|
||||
LV_TXT_FLAG_FIT = 0x10, /**< Max-width is already equal to the longest line. (Used to skip some calculation)*/
|
||||
LV_TEXT_FLAG_NONE = 0x00,
|
||||
LV_TEXT_FLAG_RECOLOR = 0x01, /**< Enable parsing of recolor command*/
|
||||
LV_TEXT_FLAG_EXPAND = 0x02, /**< Ignore max-width to avoid automatic word wrapping*/
|
||||
LV_TEXT_FLAG_CENTER = 0x04, /**< Align the text to the middle*/
|
||||
LV_TEXT_FLAG_RIGHT = 0x08, /**< Align the text to the right*/
|
||||
LV_TEXT_FLAG_FIT = 0x10, /**< Max-width is already equal to the longest line. (Used to skip some calculation)*/
|
||||
};
|
||||
typedef uint8_t lv_txt_flag_t;
|
||||
typedef uint8_t lv_text_flag_t;
|
||||
|
||||
/**
|
||||
* State machine for text renderer. */
|
||||
enum {
|
||||
LV_TXT_CMD_STATE_WAIT, /**< Waiting for command*/
|
||||
LV_TXT_CMD_STATE_PAR, /**< Processing the parameter*/
|
||||
LV_TXT_CMD_STATE_IN, /**< Processing the command*/
|
||||
LV_TEXT_CMD_STATE_WAIT, /**< Waiting for command*/
|
||||
LV_TEXT_CMD_STATE_PAR, /**< Processing the parameter*/
|
||||
LV_TEXT_CMD_STATE_IN, /**< Processing the command*/
|
||||
};
|
||||
typedef uint8_t lv_txt_cmd_state_t;
|
||||
typedef uint8_t lv_text_cmd_state_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
@@ -73,7 +73,7 @@ typedef uint8_t lv_txt_cmd_state_t;
|
||||
* line breaks
|
||||
*/
|
||||
void _lv_txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t * font, lv_coord_t letter_space,
|
||||
lv_coord_t line_space, lv_coord_t max_width, lv_txt_flag_t flag);
|
||||
lv_coord_t line_space, lv_coord_t max_width, lv_text_flag_t flag);
|
||||
|
||||
/**
|
||||
* Get the next line of text. Check line length and break chars too.
|
||||
@@ -87,7 +87,7 @@ void _lv_txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t
|
||||
* they are different)
|
||||
*/
|
||||
uint32_t _lv_txt_get_next_line(const char * txt, const lv_font_t * font, lv_coord_t letter_space, lv_coord_t max_width,
|
||||
lv_txt_flag_t flag);
|
||||
lv_text_flag_t flag);
|
||||
|
||||
/**
|
||||
* Give the length of a text with a given font
|
||||
@@ -100,7 +100,7 @@ uint32_t _lv_txt_get_next_line(const char * txt, const lv_font_t * font, lv_coor
|
||||
* @return length of a char_num long text
|
||||
*/
|
||||
lv_coord_t _lv_txt_get_width(const char * txt, uint32_t length, const lv_font_t * font, lv_coord_t letter_space,
|
||||
lv_txt_flag_t flag);
|
||||
lv_text_flag_t flag);
|
||||
|
||||
/**
|
||||
* Check next character in a string and decide if the character is part of the command or not
|
||||
@@ -110,7 +110,7 @@ lv_coord_t _lv_txt_get_width(const char * txt, uint32_t length, const lv_font_t
|
||||
* @return true: the character is part of a command and should not be written,
|
||||
* false: the character should be written
|
||||
*/
|
||||
bool _lv_txt_is_cmd(lv_txt_cmd_state_t * state, uint32_t c);
|
||||
bool _lv_txt_is_cmd(lv_text_cmd_state_t * state, uint32_t c);
|
||||
|
||||
/**
|
||||
* Insert a string into an other
|
||||
|
||||
@@ -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 : 85)
|
||||
#define TRANSITION_TIME ((theme.flags & LV_THEME_MATERIAL_FLAG_NO_TRANSITION) ? 0 : 850)
|
||||
#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)
|
||||
@@ -112,8 +112,7 @@ typedef struct {
|
||||
|
||||
#if LV_USE_ARC
|
||||
lv_style_t arc_indic;
|
||||
lv_style_t arc_bg;
|
||||
lv_style_t arc_knob;
|
||||
lv_style_t arc_indic_primary;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -185,16 +184,18 @@ 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, 70);
|
||||
|
||||
static lv_style_transiton_t trans_slow;
|
||||
lv_style_transition_init(&trans_slow, trans_props, &lv_anim_path_def, TRANSITION_TIME * 2, 0);
|
||||
lv_style_transition_init(&trans_slow, trans_props, &lv_anim_path_def, TRANSITION_TIME * 4, 0);
|
||||
|
||||
static lv_style_transiton_t trans_normal;
|
||||
lv_style_transition_init(&trans_normal, trans_props, &lv_anim_path_def, TRANSITION_TIME, 0);
|
||||
@@ -213,7 +214,7 @@ static void basic_init(void)
|
||||
lv_style_set_pad_left(&styles->scrollbar, LV_DPX(7));
|
||||
lv_style_set_pad_right(&styles->scrollbar, LV_DPX(7));
|
||||
lv_style_set_pad_top(&styles->scrollbar, LV_DPX(7));
|
||||
lv_style_set_bg_opa(&styles->scrollbar, LV_OPA_50);
|
||||
lv_style_set_bg_opa(&styles->scrollbar, LV_OPA_40);
|
||||
lv_style_set_transition(&styles->scrollbar, &trans_slow);
|
||||
|
||||
style_init_reset(&styles->scrollbar_scrolled);
|
||||
@@ -288,9 +289,9 @@ static void basic_init(void)
|
||||
lv_style_set_bg_opa(&styles->bg_color_primary, LV_OPA_COVER);
|
||||
|
||||
style_init_reset(&styles->bg_color_secondary);
|
||||
lv_style_set_bg_color(&styles->bg_color_primary, theme.color_secondary);
|
||||
lv_style_set_text_color(&styles->bg_color_primary, LV_COLOR_WHITE);
|
||||
lv_style_set_bg_opa(&styles->bg_color_primary, LV_OPA_COVER);
|
||||
lv_style_set_bg_color(&styles->bg_color_secondary, theme.color_secondary);
|
||||
lv_style_set_text_color(&styles->bg_color_secondary, LV_COLOR_WHITE);
|
||||
lv_style_set_bg_opa(&styles->bg_color_secondary, LV_OPA_COVER);
|
||||
|
||||
style_init_reset(&styles->bg_color_gray);
|
||||
lv_style_set_bg_color(&styles->bg_color_gray, COLOR_GRAY);
|
||||
@@ -314,6 +315,16 @@ static void basic_init(void)
|
||||
lv_style_set_pad_all(&styles->knob, LV_DPX(5));
|
||||
lv_style_set_radius(&styles->knob, LV_RADIUS_CIRCLE);
|
||||
|
||||
#if LV_USE_ARC
|
||||
style_init_reset(&styles->arc_indic);
|
||||
lv_style_set_line_color(&styles->arc_indic, COLOR_GRAY);
|
||||
lv_style_set_line_width(&styles->arc_indic, LV_DPX(15));
|
||||
lv_style_set_line_rounded(&styles->arc_indic, true);
|
||||
|
||||
style_init_reset(&styles->arc_indic_primary);
|
||||
lv_style_set_line_color(&styles->arc_indic_primary, theme.color_primary);
|
||||
#endif
|
||||
|
||||
#if LV_USE_CHECKBOX
|
||||
style_init_reset(&styles->cb_marker);
|
||||
lv_style_set_pad_all(&styles->cb_marker, LV_DPX(3));
|
||||
@@ -321,7 +332,6 @@ static void basic_init(void)
|
||||
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);
|
||||
@@ -347,6 +357,12 @@ static void basic_init(void)
|
||||
|
||||
|
||||
|
||||
#if LV_USE_TABLE
|
||||
style_init_reset(&styles->table_cell);
|
||||
lv_style_set_border_width(&styles->table_cell, 1);
|
||||
lv_style_set_border_color(&styles->table_cell, CARD_BORDER_COLOR);
|
||||
lv_style_set_border_side(&styles->table_cell, LV_BORDER_SIDE_TOP | LV_BORDER_SIDE_BOTTOM);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void line_init(void)
|
||||
@@ -410,29 +426,6 @@ static void gauge_init(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void arc_init(void)
|
||||
{
|
||||
#if LV_USE_ARC != 0
|
||||
style_init_reset(&styles->arc_indic);
|
||||
lv_style_set_line_color(&styles->arc_indic, LV_STATE_DEFAULT, theme.color_primary);
|
||||
lv_style_set_line_width(&styles->arc_indic, LV_STATE_DEFAULT, LV_DPX(25));
|
||||
lv_style_set_line_rounded(&styles->arc_indic, LV_STATE_DEFAULT, true);
|
||||
|
||||
style_init_reset(&styles->arc_bg);
|
||||
lv_style_set_line_color(&styles->arc_bg, LV_STATE_DEFAULT, COLOR_GRAY);
|
||||
lv_style_set_line_width(&styles->arc_bg, LV_STATE_DEFAULT, LV_DPX(25));
|
||||
lv_style_set_line_rounded(&styles->arc_bg, LV_STATE_DEFAULT, true);
|
||||
|
||||
style_init_reset(&styles->arc_knob);
|
||||
lv_style_set_radius(&styles->arc_knob, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
|
||||
lv_style_set_pad_top(&styles->arc_knob, LV_STATE_DEFAULT, LV_DPX(0));
|
||||
lv_style_set_pad_bottom(&styles->arc_knob, LV_STATE_DEFAULT, LV_DPX(0));
|
||||
lv_style_set_pad_left(&styles->arc_knob, LV_STATE_DEFAULT, LV_DPX(0));
|
||||
lv_style_set_pad_right(&styles->arc_knob, LV_STATE_DEFAULT, LV_DPX(0));
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
static void spinner_init(void)
|
||||
{
|
||||
#if LV_USE_SPINNER != 0
|
||||
@@ -546,7 +539,6 @@ lv_theme_t * lv_theme_default_init(lv_color_t color_primary, lv_color_t color_se
|
||||
line_init();
|
||||
linemeter_init();
|
||||
gauge_init();
|
||||
arc_init();
|
||||
spinner_init();
|
||||
chart_init();
|
||||
textarea_init();
|
||||
@@ -593,11 +585,11 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
|
||||
else if(lv_obj_check_type(obj, &lv_btnmatrix)) {
|
||||
lv_obj_add_style_no_refresh(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->card);
|
||||
lv_obj_add_style_no_refresh(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->pad_gap);
|
||||
lv_obj_add_style_no_refresh(obj, LV_PART_ITEM, LV_STATE_DEFAULT, &styles->btn);
|
||||
lv_obj_add_style_no_refresh(obj, LV_PART_ITEM, LV_STATE_PRESSED, &styles->pressed);
|
||||
lv_obj_add_style_no_refresh(obj, LV_PART_ITEM, LV_STATE_PRESSED, &styles->grow);
|
||||
lv_obj_add_style_no_refresh(obj, LV_PART_ITEM, LV_STATE_DEFAULT, &styles->transition_delayed);
|
||||
lv_obj_add_style_no_refresh(obj, LV_PART_ITEM, LV_STATE_PRESSED, &styles->transition_normal);
|
||||
lv_obj_add_style_no_refresh(obj, LV_PART_ITEMS, LV_STATE_DEFAULT, &styles->btn);
|
||||
lv_obj_add_style_no_refresh(obj, LV_PART_ITEMS, LV_STATE_PRESSED, &styles->pressed);
|
||||
lv_obj_add_style_no_refresh(obj, LV_PART_ITEMS, LV_STATE_PRESSED, &styles->grow);
|
||||
lv_obj_add_style_no_refresh(obj, LV_PART_ITEMS, LV_STATE_DEFAULT, &styles->transition_delayed);
|
||||
lv_obj_add_style_no_refresh(obj, LV_PART_ITEMS, LV_STATE_PRESSED, &styles->transition_normal);
|
||||
}
|
||||
#endif
|
||||
#if LV_USE_BAR
|
||||
@@ -629,12 +621,16 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
|
||||
lv_obj_add_style_no_refresh(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->card);
|
||||
lv_obj_add_style_no_refresh(obj, LV_PART_SCROLLBAR, LV_STATE_DEFAULT, &styles->scrollbar);
|
||||
lv_obj_add_style_no_refresh(obj, LV_PART_SCROLLBAR, LV_STATE_SCROLLED, &styles->scrollbar_scrolled);
|
||||
lv_obj_add_style_no_refresh(obj, LV_PART_ITEM, LV_STATE_DEFAULT, &styles->card);
|
||||
lv_obj_add_style_no_refresh(obj, LV_PART_MAIN, LV_STATE_SCROLLED, &styles->transition_normal);
|
||||
lv_obj_add_style_no_refresh(obj, LV_PART_ITEMS, LV_STATE_DEFAULT, &styles->bg_color_white);
|
||||
lv_obj_add_style_no_refresh(obj, LV_PART_ITEMS, LV_STATE_DEFAULT, &styles->table_cell);
|
||||
lv_obj_add_style_no_refresh(obj, LV_PART_ITEMS, LV_STATE_DEFAULT, &styles->pad_small);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LV_USE_CHECKBOX
|
||||
else if(lv_obj_check_type(obj, &lv_checkbox)) {
|
||||
lv_obj_add_style_no_refresh(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->pad_gap);
|
||||
lv_obj_add_style_no_refresh(obj, LV_PART_MARKER, LV_STATE_DEFAULT, &styles->cb_marker);
|
||||
lv_obj_add_style_no_refresh(obj, LV_PART_MARKER, LV_STATE_CHECKED, &styles->bg_color_primary);
|
||||
lv_obj_add_style_no_refresh(obj, LV_PART_MARKER, LV_STATE_CHECKED, &styles->cb_marker_checked);
|
||||
@@ -657,7 +653,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LV_USE_SWITCH
|
||||
#if LV_USE_CHART
|
||||
else if(lv_obj_check_type(obj, &lv_chart)) {
|
||||
lv_obj_add_style_no_refresh(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->card);
|
||||
lv_obj_add_style_no_refresh(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->chart_bg);
|
||||
@@ -667,14 +663,11 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
|
||||
lv_obj_add_style_no_refresh(obj, LV_PART_SERIES, LV_STATE_DEFAULT, &styles->chart_series);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LV_USE_ROLLER
|
||||
else if(lv_obj_check_type(obj, &lv_roller)) {
|
||||
lv_obj_add_style_no_refresh(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->card);
|
||||
// lv_obj_add_style_no_refresh(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->pad_zero);
|
||||
lv_obj_add_style_no_refresh(obj, LV_PART_HIGHLIGHT, LV_STATE_DEFAULT, &styles->bg_color_primary);
|
||||
// lv_obj_add_style_no_refresh(obj, LV_PART_SCROLLBAR, LV_STATE_DEFAULT, &styles->scrollbar);
|
||||
// lv_obj_add_style_no_refresh(obj, LV_PART_SCROLLBAR, LV_STATE_SCROLLED, &styles->scrollbar_scrolled);
|
||||
// lv_obj_add_style_no_refresh(obj, LV_PART_SERIES, LV_STATE_DEFAULT, &styles->chart_series);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -689,6 +682,15 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LV_USE_ARC
|
||||
else if(lv_obj_check_type(obj, &lv_arc)) {
|
||||
lv_obj_add_style_no_refresh(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->card);
|
||||
lv_obj_add_style_no_refresh(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->arc_indic);
|
||||
lv_obj_add_style_no_refresh(obj, LV_PART_INDICATOR, LV_STATE_DEFAULT, &styles->arc_indic);
|
||||
lv_obj_add_style_no_refresh(obj, LV_PART_INDICATOR, LV_STATE_DEFAULT, &styles->arc_indic_primary);
|
||||
lv_obj_add_style_no_refresh(obj, LV_PART_KNOB, LV_STATE_DEFAULT, &styles->knob);
|
||||
}
|
||||
#endif
|
||||
//#if LV_USE_BTNMATRIX
|
||||
//case LV_THEME_BTNMATRIX:
|
||||
// list = _lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_MAIN);
|
||||
@@ -722,23 +724,6 @@ case LV_THEME_LINE:
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_ARC
|
||||
case LV_THEME_ARC:
|
||||
list = _lv_obj_get_style_list(obj, LV_ARC_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->card);
|
||||
_lv_style_list_add_style(list, &styles->arc_bg);
|
||||
_lv_style_list_add_style(list, &styles->sb);
|
||||
|
||||
list = _lv_obj_get_style_list(obj, LV_ARC_PART_INDIC);
|
||||
_lv_style_list_add_style(list, &styles->arc_indic);
|
||||
|
||||
list = _lv_obj_get_style_list(obj, LV_ARC_PART_KNOB);
|
||||
_lv_style_list_add_style(list, &styles->card);
|
||||
_lv_style_list_add_style(list, &styles->bg_click);
|
||||
_lv_style_list_add_style(list, &styles->arc_knob);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_OBJMASK
|
||||
case LV_THEME_OBJMASK:
|
||||
list = _lv_obj_get_style_list(obj, LV_OBJMASK_PART_MAIN);
|
||||
|
||||
@@ -30,19 +30,25 @@
|
||||
**********************/
|
||||
|
||||
static void lv_arc_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy);
|
||||
static void lv_arc_destructor(void * obj);
|
||||
static void lv_arc_destructor(lv_obj_t * obj);
|
||||
static lv_design_res_t lv_arc_design(lv_obj_t * arc, const lv_area_t * clip_area, lv_design_mode_t mode);
|
||||
static lv_res_t lv_arc_signal(lv_obj_t * arc, lv_signal_t sign, void * param);
|
||||
static lv_style_list_t * lv_arc_get_style(lv_obj_t * arc, uint8_t part);
|
||||
static void inv_arc_area(lv_obj_t * arc, uint16_t start_angle, uint16_t end_angle, lv_arc_part_t part);
|
||||
static void get_center(lv_obj_t * arc, lv_point_t * center, lv_coord_t * arc_r);
|
||||
static void inv_arc_area(lv_obj_t * arc, uint16_t start_angle, uint16_t end_angle, uint8_t part);
|
||||
static void get_center(lv_obj_t * obj, lv_point_t * center, lv_coord_t * arc_r);
|
||||
static void get_knob_area(lv_obj_t * arc, const lv_point_t * center, lv_coord_t r, lv_area_t * knob_area);
|
||||
static void value_update(lv_obj_t * arc);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
lv_arc_class_t lv_arc;
|
||||
const lv_obj_class_t lv_arc = {
|
||||
.constructor = lv_arc_constructor,
|
||||
.destructor = lv_arc_destructor,
|
||||
.signal_cb = lv_arc_signal,
|
||||
.design_cb = lv_arc_design,
|
||||
.instance_size = sizeof(lv_arc_t),
|
||||
.base_class = &lv_obj
|
||||
};
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@@ -60,35 +66,7 @@ lv_arc_class_t lv_arc;
|
||||
*/
|
||||
lv_obj_t * lv_arc_create(lv_obj_t * parent, const lv_obj_t * copy)
|
||||
{
|
||||
|
||||
LV_LOG_TRACE("arc create started");
|
||||
|
||||
if(!lv_arc._inited) {
|
||||
LV_CLASS_INIT(lv_arc, lv_obj);
|
||||
lv_arc.constructor = lv_arc_constructor;
|
||||
lv_arc.destructor = lv_arc_destructor;
|
||||
lv_arc.design_cb = lv_arc_design;
|
||||
lv_arc.signal_cb = lv_arc_signal;
|
||||
}
|
||||
|
||||
lv_obj_t * obj = lv_class_new(&lv_arc);
|
||||
lv_arc.constructor(obj, parent, copy);
|
||||
|
||||
lv_arc_t * arc = (lv_arc_t *) obj;
|
||||
const lv_arc_t * copy_arc = (const lv_arc_t *) copy;
|
||||
if(!copy) lv_theme_apply(obj, LV_THEME_ARC);
|
||||
else {
|
||||
lv_style_list_copy(&arc->style_knob, ©_arc->style_knob);
|
||||
lv_style_list_copy(&arc->style_arc, ©_arc->style_arc);
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
_lv_obj_refresh_style(obj, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
|
||||
}
|
||||
|
||||
|
||||
LV_LOG_INFO("arc created");
|
||||
|
||||
return obj;
|
||||
return lv_obj_create_from_class(&lv_arc, parent, copy);
|
||||
}
|
||||
|
||||
/*======================
|
||||
@@ -111,23 +89,23 @@ lv_obj_t * lv_arc_create(lv_obj_t * parent, const lv_obj_t * copy)
|
||||
void lv_arc_set_start_angle(lv_obj_t * obj, uint16_t start)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
lv_arc_t * arc = (lv_arc_t*) obj;
|
||||
lv_arc_t * arc = (lv_arc_t *)obj;
|
||||
|
||||
if(start > 360) start -= 360;
|
||||
|
||||
/*Too large move, the whole arc need to be invalidated anyway*/
|
||||
if(LV_MATH_ABS(start - arc->indic_angle_start) >= 180) {
|
||||
if(LV_MATH_ABS(start -arc->indic_angle_start) >= 180) {
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
/*Only a smaller incremental move*/
|
||||
else if(arc->indic_angle_start > arc->indic_angle_end && start > arc->indic_angle_end) {
|
||||
else if(arc->indic_angle_start >arc->indic_angle_end && start >arc->indic_angle_end) {
|
||||
inv_arc_area(obj, LV_MATH_MIN(arc->indic_angle_start, start), LV_MATH_MAX(arc->indic_angle_start, start),
|
||||
LV_ARC_PART_INDIC);
|
||||
LV_PART_INDICATOR);
|
||||
}
|
||||
/*Only a smaller incremental move*/
|
||||
else if(arc->indic_angle_start < arc->indic_angle_end && start < arc->indic_angle_end) {
|
||||
else if(arc->indic_angle_start <arc->indic_angle_end && start <arc->indic_angle_end) {
|
||||
inv_arc_area(obj, LV_MATH_MIN(arc->indic_angle_start, start), LV_MATH_MAX(arc->indic_angle_start, start),
|
||||
LV_ARC_PART_INDIC);
|
||||
LV_PART_INDICATOR);
|
||||
}
|
||||
/*Crossing the start angle makes the whole arc change*/
|
||||
else {
|
||||
@@ -145,21 +123,21 @@ void lv_arc_set_start_angle(lv_obj_t * obj, uint16_t start)
|
||||
void lv_arc_set_end_angle(lv_obj_t * obj, uint16_t end)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
lv_arc_t * arc = (lv_arc_t*) obj;
|
||||
lv_arc_t * arc = (lv_arc_t *)obj;
|
||||
|
||||
if(end > (arc->indic_angle_start + 360)) end = arc->indic_angle_start + 360;
|
||||
if(end > (arc->indic_angle_start + 360)) end =arc->indic_angle_start + 360;
|
||||
|
||||
/*Too large move, the whole arc need to be invalidated anyway*/
|
||||
if(LV_MATH_ABS(end - arc->indic_angle_end) >= 180) {
|
||||
if(LV_MATH_ABS(end -arc->indic_angle_end) >= 180) {
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
/*Only a smaller incremental move*/
|
||||
else if(arc->indic_angle_end > arc->indic_angle_start && end > arc->indic_angle_start) {
|
||||
inv_arc_area(obj, LV_MATH_MIN(arc->indic_angle_end, end), LV_MATH_MAX(arc->indic_angle_end, end), LV_ARC_PART_INDIC);
|
||||
else if(arc->indic_angle_end >arc->indic_angle_start && end >arc->indic_angle_start) {
|
||||
inv_arc_area(obj, LV_MATH_MIN(arc->indic_angle_end, end), LV_MATH_MAX(arc->indic_angle_end, end), LV_PART_INDICATOR);
|
||||
}
|
||||
/*Only a smaller incremental move*/
|
||||
else if(arc->indic_angle_end < arc->indic_angle_start && end < arc->indic_angle_start) {
|
||||
inv_arc_area(obj, LV_MATH_MIN(arc->indic_angle_end, end), LV_MATH_MAX(arc->indic_angle_end, end), LV_ARC_PART_INDIC);
|
||||
else if(arc->indic_angle_end <arc->indic_angle_start && end <arc->indic_angle_start) {
|
||||
inv_arc_area(obj, LV_MATH_MIN(arc->indic_angle_end, end), LV_MATH_MAX(arc->indic_angle_end, end), LV_PART_INDICATOR);
|
||||
}
|
||||
/*Crossing the end angle makes the whole arc change*/
|
||||
else {
|
||||
@@ -179,17 +157,17 @@ void lv_arc_set_end_angle(lv_obj_t * obj, uint16_t end)
|
||||
void lv_arc_set_angles(lv_obj_t * obj, uint16_t start, uint16_t end)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
lv_arc_t * arc = (lv_arc_t*) obj;
|
||||
lv_arc_t * arc = (lv_arc_t *)obj;
|
||||
|
||||
if(start > 360) start -= 360;
|
||||
if(end > (start + 360)) end = start + 360;
|
||||
|
||||
inv_arc_area(obj, arc->indic_angle_start, arc->indic_angle_end, LV_ARC_PART_INDIC);
|
||||
inv_arc_area(obj,arc->indic_angle_start,arc->indic_angle_end, LV_PART_INDICATOR);
|
||||
|
||||
arc->indic_angle_start = start;
|
||||
arc->indic_angle_end = end;
|
||||
|
||||
inv_arc_area(obj, arc->indic_angle_start, arc->indic_angle_end, LV_ARC_PART_INDIC);
|
||||
inv_arc_area(obj,arc->indic_angle_start,arc->indic_angle_end, LV_PART_INDICATOR);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -200,21 +178,21 @@ void lv_arc_set_angles(lv_obj_t * obj, uint16_t start, uint16_t end)
|
||||
void lv_arc_set_bg_start_angle(lv_obj_t * obj, uint16_t start)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
lv_arc_t * arc = (lv_arc_t*) obj;
|
||||
lv_arc_t * arc = (lv_arc_t *)obj;
|
||||
|
||||
if(start > 360) start -= 360;
|
||||
|
||||
/*Too large move, the whole arc need to be invalidated anyway*/
|
||||
if(LV_MATH_ABS(start - arc->bg_angle_start) >= 180) {
|
||||
if(LV_MATH_ABS(start -arc->bg_angle_start) >= 180) {
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
/*Only a smaller incremental move*/
|
||||
else if(arc->bg_angle_start > arc->bg_angle_end && start > arc->bg_angle_end) {
|
||||
inv_arc_area(obj, LV_MATH_MIN(arc->bg_angle_start, start), LV_MATH_MAX(arc->bg_angle_start, start), LV_ARC_PART_BG);
|
||||
else if(arc->bg_angle_start >arc->bg_angle_end && start >arc->bg_angle_end) {
|
||||
inv_arc_area(obj, LV_MATH_MIN(arc->bg_angle_start, start), LV_MATH_MAX(arc->bg_angle_start, start), LV_PART_MAIN);
|
||||
}
|
||||
/*Only a smaller incremental move*/
|
||||
else if(arc->bg_angle_start < arc->bg_angle_end && start < arc->bg_angle_end) {
|
||||
inv_arc_area(obj, LV_MATH_MIN(arc->bg_angle_start, start), LV_MATH_MAX(arc->bg_angle_start, start), LV_ARC_PART_BG);
|
||||
else if(arc->bg_angle_start <arc->bg_angle_end && start <arc->bg_angle_end) {
|
||||
inv_arc_area(obj, LV_MATH_MIN(arc->bg_angle_start, start), LV_MATH_MAX(arc->bg_angle_start, start), LV_PART_MAIN);
|
||||
}
|
||||
/*Crossing the start angle makes the whole arc change*/
|
||||
else {
|
||||
@@ -234,22 +212,22 @@ void lv_arc_set_bg_start_angle(lv_obj_t * obj, uint16_t start)
|
||||
void lv_arc_set_bg_end_angle(lv_obj_t * obj, uint16_t end)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
lv_arc_t * arc = (lv_arc_t*) obj;
|
||||
lv_arc_t * arc = (lv_arc_t *)obj;
|
||||
|
||||
|
||||
if(end > (arc->bg_angle_start + 360)) end = arc->bg_angle_start + 360;
|
||||
if(end > (arc->bg_angle_start + 360)) end =arc->bg_angle_start + 360;
|
||||
|
||||
/*Too large move, the whole arc need to be invalidated anyway*/
|
||||
if(LV_MATH_ABS(end - arc->bg_angle_end) >= 180) {
|
||||
if(LV_MATH_ABS(end -arc->bg_angle_end) >= 180) {
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
/*Only a smaller incremental move*/
|
||||
else if(arc->bg_angle_end > arc->bg_angle_start && end > arc->bg_angle_start) {
|
||||
inv_arc_area(obj, LV_MATH_MIN(arc->bg_angle_end, end), LV_MATH_MAX(arc->bg_angle_end, end), LV_ARC_PART_BG);
|
||||
else if(arc->bg_angle_end >arc->bg_angle_start && end >arc->bg_angle_start) {
|
||||
inv_arc_area(obj, LV_MATH_MIN(arc->bg_angle_end, end), LV_MATH_MAX(arc->bg_angle_end, end), LV_PART_MAIN);
|
||||
}
|
||||
/*Only a smaller incremental move*/
|
||||
else if(arc->bg_angle_end < arc->bg_angle_start && end < arc->bg_angle_start) {
|
||||
inv_arc_area(obj, LV_MATH_MIN(arc->bg_angle_end, end), LV_MATH_MAX(arc->bg_angle_end, end), LV_ARC_PART_BG);
|
||||
else if(arc->bg_angle_end <arc->bg_angle_start && end <arc->bg_angle_start) {
|
||||
inv_arc_area(obj, LV_MATH_MIN(arc->bg_angle_end, end), LV_MATH_MAX(arc->bg_angle_end, end), LV_PART_MAIN);
|
||||
}
|
||||
/*Crossing the end angle makes the whole arc change*/
|
||||
else {
|
||||
@@ -271,17 +249,17 @@ void lv_arc_set_bg_angles(lv_obj_t * obj, uint16_t start, uint16_t end)
|
||||
{
|
||||
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
lv_arc_t * arc = (lv_arc_t*) obj;
|
||||
lv_arc_t * arc = (lv_arc_t *)obj;
|
||||
|
||||
if(start > 360) start -= 360;
|
||||
if(end > (start + 360)) end = start + 360;
|
||||
|
||||
inv_arc_area(obj, arc->bg_angle_start, arc->bg_angle_end, LV_ARC_PART_BG);
|
||||
inv_arc_area(obj,arc->bg_angle_start,arc->bg_angle_end, LV_PART_MAIN);
|
||||
|
||||
arc->bg_angle_start = start;
|
||||
arc->bg_angle_end = end;
|
||||
|
||||
inv_arc_area(obj, arc->bg_angle_start, arc->bg_angle_end, LV_ARC_PART_BG);
|
||||
inv_arc_area(obj,arc->bg_angle_start,arc->bg_angle_end, LV_PART_MAIN);
|
||||
|
||||
value_update(obj);
|
||||
}
|
||||
@@ -295,7 +273,7 @@ void lv_arc_set_angle_ofs(lv_obj_t * obj, uint16_t angle_ofs)
|
||||
{
|
||||
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
lv_arc_t * arc = (lv_arc_t*) obj;
|
||||
lv_arc_t * arc = (lv_arc_t *)obj;
|
||||
|
||||
arc->angle_ofs = angle_ofs;
|
||||
|
||||
@@ -311,15 +289,15 @@ void lv_arc_set_angle_ofs(lv_obj_t * obj, uint16_t angle_ofs)
|
||||
void lv_arc_set_type(lv_obj_t * obj, lv_arc_type_t type)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
lv_arc_t * arc = (lv_arc_t*) obj;
|
||||
lv_arc_t * arc = (lv_arc_t *)obj;
|
||||
|
||||
int16_t val = arc->value;
|
||||
int16_t val =arc->value;
|
||||
|
||||
arc->type = type;
|
||||
arc->value = -1; /** Force set_value handling*/
|
||||
|
||||
int16_t bg_midpoint, bg_end = arc->bg_angle_end;
|
||||
if(arc->bg_angle_end < arc->bg_angle_start) bg_end = arc->bg_angle_end + 360;
|
||||
int16_t bg_midpoint, bg_end =arc->bg_angle_end;
|
||||
if(arc->bg_angle_end <arc->bg_angle_start) bg_end =arc->bg_angle_end + 360;
|
||||
|
||||
switch(arc->type) {
|
||||
case LV_ARC_TYPE_SYMMETRIC:
|
||||
@@ -328,10 +306,10 @@ void lv_arc_set_type(lv_obj_t * obj, lv_arc_type_t type)
|
||||
lv_arc_set_end_angle(obj, bg_midpoint);
|
||||
break;
|
||||
case LV_ARC_TYPE_REVERSE:
|
||||
lv_arc_set_end_angle(obj, arc->bg_angle_end);
|
||||
lv_arc_set_end_angle(obj,arc->bg_angle_end);
|
||||
break;
|
||||
default: /** LV_ARC_TYPE_NORMAL*/
|
||||
lv_arc_set_start_angle(obj, arc->bg_angle_start);
|
||||
lv_arc_set_start_angle(obj,arc->bg_angle_start);
|
||||
}
|
||||
|
||||
lv_arc_set_value(obj, val);
|
||||
@@ -345,13 +323,13 @@ void lv_arc_set_type(lv_obj_t * obj, lv_arc_type_t type)
|
||||
void lv_arc_set_value(lv_obj_t * obj, int16_t value)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
lv_arc_t * arc = (lv_arc_t*) obj;
|
||||
lv_arc_t * arc = (lv_arc_t *)obj;
|
||||
|
||||
if(arc->value == value) return;
|
||||
|
||||
int16_t new_value;
|
||||
new_value = value > arc->max_value ? arc->max_value : value;
|
||||
new_value = new_value < arc->min_value ? arc->min_value : new_value;
|
||||
new_value = value >arc->max_value ?arc->max_value : value;
|
||||
new_value = new_value <arc->min_value ?arc->min_value : new_value;
|
||||
|
||||
if(arc->value == new_value) return;
|
||||
arc->value = new_value;
|
||||
@@ -368,9 +346,9 @@ void lv_arc_set_value(lv_obj_t * obj, int16_t value)
|
||||
void lv_arc_set_range(lv_obj_t * obj, int16_t min, int16_t max)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
lv_arc_t * arc = (lv_arc_t*) obj;
|
||||
lv_arc_t * arc = (lv_arc_t *)obj;
|
||||
|
||||
if(arc->min_value == min && arc->max_value == max) return;
|
||||
if(arc->min_value == min &&arc->max_value == max) return;
|
||||
|
||||
arc->min_value = min;
|
||||
arc->max_value = max;
|
||||
@@ -394,7 +372,7 @@ void lv_arc_set_range(lv_obj_t * obj, int16_t min, int16_t max)
|
||||
void lv_arc_set_chg_rate(lv_obj_t * obj, uint16_t rate)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
lv_arc_t * arc = (lv_arc_t*) obj;
|
||||
lv_arc_t * arc = (lv_arc_t *)obj;
|
||||
|
||||
arc->chg_rate = rate;
|
||||
}
|
||||
@@ -407,7 +385,7 @@ void lv_arc_set_chg_rate(lv_obj_t * obj, uint16_t rate)
|
||||
void lv_arc_set_adjustable(lv_obj_t * obj, bool adjustable)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
lv_arc_t * arc = (lv_arc_t*) obj;
|
||||
lv_arc_t * arc = (lv_arc_t *)obj;
|
||||
|
||||
if(arc->adjustable == adjustable)
|
||||
return;
|
||||
@@ -441,9 +419,9 @@ static void lv_arc_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t
|
||||
LV_LOG_TRACE("lv_arc create started");
|
||||
|
||||
LV_CLASS_CONSTRUCTOR_BEGIN(obj, lv_arc)
|
||||
lv_arc.base_p->constructor(obj, parent, copy);
|
||||
lv_obj.constructor(obj, parent, copy);
|
||||
|
||||
lv_arc_t * arc = (lv_arc_t *) obj;
|
||||
lv_arc_t * arc = (lv_arc_t *)obj;
|
||||
LV_LOG_TRACE("arc create started");
|
||||
|
||||
/*Create the ancestor of arc*/
|
||||
@@ -463,9 +441,7 @@ static void lv_arc_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t
|
||||
arc->adjustable = false;
|
||||
arc->chg_rate = 540;
|
||||
arc->last_tick = lv_tick_get();
|
||||
arc->last_angle = arc->indic_angle_end;
|
||||
lv_style_list_init(&arc->style_arc);
|
||||
lv_style_list_init(&arc->style_knob);
|
||||
arc->last_angle =arc->indic_angle_end;
|
||||
|
||||
lv_obj_set_size(obj, LV_DPI, LV_DPI);
|
||||
|
||||
@@ -473,11 +449,11 @@ static void lv_arc_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t
|
||||
if(copy == NULL) {
|
||||
lv_obj_add_flag(obj, LV_OBJ_FLAG_CLICKABLE);
|
||||
lv_obj_set_ext_click_area(obj, LV_DPI / 10, LV_DPI / 10, LV_DPI / 10, LV_DPI / 10);
|
||||
lv_arc_set_value(obj, arc->min_value);
|
||||
lv_arc_set_value(obj,arc->min_value);
|
||||
}
|
||||
/*Copy an existing arc*/
|
||||
else {
|
||||
lv_arc_t * copy_arc = (lv_arc_t*)copy;
|
||||
lv_arc_t * copy_arc = (lv_arc_t *)copy;
|
||||
arc->indic_angle_start = copy_arc->indic_angle_start;
|
||||
arc->indic_angle_end = copy_arc->indic_angle_end;
|
||||
arc->bg_angle_start = copy_arc->bg_angle_start;
|
||||
@@ -500,7 +476,7 @@ static void lv_arc_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t
|
||||
LV_LOG_INFO("arc created");
|
||||
}
|
||||
|
||||
static void lv_arc_destructor(void * obj)
|
||||
static void lv_arc_destructor(lv_obj_t * obj)
|
||||
{
|
||||
// lv_arc_t * arc = obj;
|
||||
//
|
||||
@@ -528,18 +504,18 @@ static lv_design_res_t lv_arc_design(lv_obj_t * obj, const lv_area_t * clip_area
|
||||
{
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
return lv_arc.base_p->design_cb(obj, clip_area, mode);
|
||||
return lv_obj.design_cb(obj, clip_area, mode);
|
||||
}
|
||||
/*Draw the object*/
|
||||
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
lv_arc_t * arc = (lv_arc_t*) obj;
|
||||
lv_arc_t * arc = (lv_arc_t *)obj;
|
||||
|
||||
lv_draw_rect_dsc_t bg_dsc;
|
||||
lv_draw_rect_dsc_init(&bg_dsc);
|
||||
lv_obj_init_draw_rect_dsc(obj, LV_ARC_PART_BG, &bg_dsc);
|
||||
lv_obj_init_draw_rect_dsc(obj, LV_PART_MAIN, &bg_dsc);
|
||||
|
||||
lv_draw_rect(&arc->coords, clip_area, &bg_dsc);
|
||||
lv_draw_rect(&obj->coords, clip_area, &bg_dsc);
|
||||
|
||||
lv_point_t center;
|
||||
lv_coord_t arc_r;
|
||||
@@ -549,27 +525,27 @@ static lv_design_res_t lv_arc_design(lv_obj_t * obj, const lv_area_t * clip_area
|
||||
lv_draw_line_dsc_t arc_dsc;
|
||||
if(arc_r > 0) {
|
||||
lv_draw_line_dsc_init(&arc_dsc);
|
||||
lv_obj_init_draw_line_dsc(obj, LV_ARC_PART_BG, &arc_dsc);
|
||||
lv_obj_init_draw_line_dsc(obj, LV_PART_MAIN, &arc_dsc);
|
||||
|
||||
lv_draw_arc(center.x, center.y, arc_r, arc->bg_angle_start + arc->angle_ofs,
|
||||
arc->bg_angle_end + arc->angle_ofs, clip_area,
|
||||
lv_draw_arc(center.x, center.y, arc_r,arc->bg_angle_start +arc->angle_ofs,
|
||||
arc->bg_angle_end +arc->angle_ofs, clip_area,
|
||||
&arc_dsc);
|
||||
}
|
||||
|
||||
|
||||
/*make the indicator arc smaller or larger according to its greatest padding value*/
|
||||
lv_coord_t left_indic = lv_obj_get_style_pad_left(obj, LV_ARC_PART_INDIC);
|
||||
lv_coord_t right_indic = lv_obj_get_style_pad_right(obj, LV_ARC_PART_INDIC);
|
||||
lv_coord_t top_indic = lv_obj_get_style_pad_top(obj, LV_ARC_PART_INDIC);
|
||||
lv_coord_t bottom_indic = lv_obj_get_style_pad_bottom(obj, LV_ARC_PART_INDIC);
|
||||
lv_coord_t left_indic = lv_obj_get_style_pad_left(obj, LV_PART_INDICATOR);
|
||||
lv_coord_t right_indic = lv_obj_get_style_pad_right(obj, LV_PART_INDICATOR);
|
||||
lv_coord_t top_indic = lv_obj_get_style_pad_top(obj, LV_PART_INDICATOR);
|
||||
lv_coord_t bottom_indic = lv_obj_get_style_pad_bottom(obj, LV_PART_INDICATOR);
|
||||
lv_coord_t indic_r = arc_r - LV_MATH_MAX4(left_indic, right_indic, top_indic, bottom_indic);
|
||||
|
||||
if(indic_r > 0) {
|
||||
lv_draw_line_dsc_init(&arc_dsc);
|
||||
lv_obj_init_draw_line_dsc(obj, LV_ARC_PART_INDIC, &arc_dsc);
|
||||
lv_obj_init_draw_line_dsc(obj, LV_PART_INDICATOR, &arc_dsc);
|
||||
|
||||
lv_draw_arc(center.x, center.y, indic_r, arc->indic_angle_start + arc->angle_ofs,
|
||||
arc->indic_angle_end + arc->angle_ofs, clip_area,
|
||||
lv_draw_arc(center.x, center.y, indic_r,arc->indic_angle_start +arc->angle_ofs,
|
||||
arc->indic_angle_end +arc->angle_ofs, clip_area,
|
||||
&arc_dsc);
|
||||
}
|
||||
|
||||
@@ -579,7 +555,7 @@ static lv_design_res_t lv_arc_design(lv_obj_t * obj, const lv_area_t * clip_area
|
||||
|
||||
lv_draw_rect_dsc_t knob_rect_dsc;
|
||||
lv_draw_rect_dsc_init(&knob_rect_dsc);
|
||||
lv_obj_init_draw_rect_dsc(obj, LV_ARC_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);
|
||||
}
|
||||
@@ -604,16 +580,11 @@ static lv_res_t lv_arc_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
||||
lv_res_t res;
|
||||
|
||||
/* Include the ancient signal function */
|
||||
res = lv_arc.base_p->signal_cb(obj, sign, param);
|
||||
res = lv_obj.signal_cb(obj, sign, param);
|
||||
if(res != LV_RES_OK) return res;
|
||||
|
||||
lv_arc_t * arc = (lv_arc_t*) obj;
|
||||
if(sign == LV_SIGNAL_GET_STYLE) {
|
||||
lv_get_style_info_t * info = param;
|
||||
info->result = lv_arc_get_style(obj, info->part);
|
||||
if(info->result != NULL) return LV_RES_OK;
|
||||
else return lv_arc.base_p->signal_cb(obj, sign, param);
|
||||
} else if(sign == LV_SIGNAL_PRESSING) {
|
||||
lv_arc_t * arc = (lv_arc_t *)obj;
|
||||
if(sign == LV_SIGNAL_PRESSING) {
|
||||
/* Only adjustable arcs can be dragged */
|
||||
if(!arc->adjustable) return res;
|
||||
|
||||
@@ -637,7 +608,7 @@ static lv_res_t lv_arc_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
||||
|
||||
/*Enter dragging mode if pressed out of the knob*/
|
||||
if(arc->dragging == false) {
|
||||
lv_coord_t indic_width = lv_obj_get_style_line_width(obj, LV_ARC_PART_INDIC);
|
||||
lv_coord_t indic_width = lv_obj_get_style_line_width(obj, LV_PART_INDICATOR);
|
||||
r -= indic_width;
|
||||
r -= r / 2; /*Add some more sensitive area*/
|
||||
if(p.x * p.x + p.y * p.y > r * r) {
|
||||
@@ -654,20 +625,20 @@ static lv_res_t lv_arc_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
||||
|
||||
/*Calculate the angle of the pressed point*/
|
||||
int16_t angle;
|
||||
int16_t bg_end = arc->bg_angle_end;
|
||||
if(arc->bg_angle_end < arc->bg_angle_start) {
|
||||
bg_end = arc->bg_angle_end + 360;
|
||||
int16_t bg_end =arc->bg_angle_end;
|
||||
if(arc->bg_angle_end <arc->bg_angle_start) {
|
||||
bg_end =arc->bg_angle_end + 360;
|
||||
}
|
||||
|
||||
|
||||
angle = _lv_atan2(p.y, p.x);
|
||||
angle -= arc->angle_ofs;
|
||||
angle -= arc->bg_angle_start; /*Make the angle relative to the start angle*/
|
||||
angle -=arc->angle_ofs;
|
||||
angle -=arc->bg_angle_start; /*Make the angle relative to the start angle*/
|
||||
if(angle < 0) angle += 360;
|
||||
|
||||
int16_t deg_range = bg_end - arc->bg_angle_start;
|
||||
int16_t deg_range = bg_end -arc->bg_angle_start;
|
||||
|
||||
int16_t last_angle_rel = arc->last_angle - arc->bg_angle_start;
|
||||
int16_t last_angle_rel =arc->last_angle -arc->bg_angle_start;
|
||||
int16_t delta_angle = angle - last_angle_rel;
|
||||
|
||||
/* Do not allow big jumps.
|
||||
@@ -678,7 +649,7 @@ static lv_res_t lv_arc_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
||||
else angle = deg_range;
|
||||
}
|
||||
else {
|
||||
if(angle < deg_range / 2) arc->min_close = 1;
|
||||
if(angle < deg_range / 2)arc->min_close = 1;
|
||||
else arc->min_close = 0;
|
||||
}
|
||||
|
||||
@@ -697,15 +668,15 @@ static lv_res_t lv_arc_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
||||
angle = last_angle_rel + delta_angle; /*Apply the limited angle change*/
|
||||
|
||||
/*Rounding for symmetry*/
|
||||
int32_t round = ((bg_end - arc->bg_angle_start) * 8) / (arc->max_value - arc->min_value);
|
||||
int32_t round = ((bg_end -arc->bg_angle_start) * 8) / (arc->max_value -arc->min_value);
|
||||
round = (round + 4) >> 4;
|
||||
angle += round;
|
||||
|
||||
angle += arc->bg_angle_start; /*Make the angle absolute again*/
|
||||
angle +=arc->bg_angle_start; /*Make the angle absolute again*/
|
||||
|
||||
/*Set the new value*/
|
||||
int16_t old_value = arc->value;
|
||||
int16_t new_value = _lv_map(angle, arc->bg_angle_start, bg_end, arc->min_value, arc->max_value);
|
||||
int16_t old_value =arc->value;
|
||||
int16_t new_value = _lv_map(angle,arc->bg_angle_start, bg_end,arc->min_value,arc->max_value);
|
||||
if(new_value != lv_arc_get_value(obj)) {
|
||||
arc->last_tick = lv_tick_get(); /*Cache timestamp for the next iteration*/
|
||||
lv_arc_set_value(obj, new_value); /*set_value caches the last_angle for the next iteration*/
|
||||
@@ -716,7 +687,7 @@ static lv_res_t lv_arc_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
||||
}
|
||||
|
||||
/*Don1't let the elapsed time to big while sitting on an end point*/
|
||||
if(new_value == arc->min_value || new_value == arc->max_value) {
|
||||
if(new_value ==arc->min_value || new_value ==arc->max_value) {
|
||||
arc->last_tick = lv_tick_get(); /*Cache timestamp for the next iteration*/
|
||||
}
|
||||
}
|
||||
@@ -739,7 +710,7 @@ static lv_res_t lv_arc_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
||||
|
||||
char c = *((char *)param);
|
||||
|
||||
int16_t old_value = arc->value;
|
||||
int16_t old_value =arc->value;
|
||||
if(c == LV_KEY_RIGHT || c == LV_KEY_UP) {
|
||||
lv_arc_set_value(obj, lv_arc_get_value(obj) + 1);
|
||||
}
|
||||
@@ -747,7 +718,7 @@ static lv_res_t lv_arc_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
||||
lv_arc_set_value(obj, lv_arc_get_value(obj) - 1);
|
||||
}
|
||||
|
||||
if(old_value != arc->value) {
|
||||
if(old_value !=arc->value) {
|
||||
res = lv_event_send(obj, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
if(res != LV_RES_OK) return res;
|
||||
}
|
||||
@@ -762,47 +733,16 @@ static lv_res_t lv_arc_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the style descriptor of a part of the object
|
||||
* @param arc pointer the object
|
||||
* @param part the part of the object. (LV_ARC_PART_...)
|
||||
* @return pointer to the style descriptor of the specified part
|
||||
*/
|
||||
static lv_style_list_t * lv_arc_get_style(lv_obj_t * obj, uint8_t part)
|
||||
{
|
||||
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
lv_arc_t * arc = (lv_arc_t*) obj;
|
||||
|
||||
lv_style_list_t * style_dsc_p;
|
||||
|
||||
switch(part) {
|
||||
case LV_ARC_PART_BG:
|
||||
style_dsc_p = &arc->style_list;
|
||||
break;
|
||||
case LV_ARC_PART_INDIC:
|
||||
style_dsc_p = &arc->style_arc;
|
||||
break;
|
||||
case LV_ARC_PART_KNOB:
|
||||
style_dsc_p = &arc->style_knob;
|
||||
break;
|
||||
default:
|
||||
style_dsc_p = NULL;
|
||||
}
|
||||
|
||||
return style_dsc_p;
|
||||
}
|
||||
|
||||
static void inv_arc_area(lv_obj_t * obj, uint16_t start_angle, uint16_t end_angle, lv_arc_part_t part)
|
||||
static void inv_arc_area(lv_obj_t * obj, uint16_t start_angle, uint16_t end_angle, uint8_t part)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
lv_arc_t * arc = (lv_arc_t*) obj;
|
||||
lv_arc_t * arc = (lv_arc_t *)obj;
|
||||
|
||||
/*Skip this complicated invalidation if the arc is not visible*/
|
||||
if(lv_obj_is_visible(obj) == false) return;
|
||||
|
||||
start_angle += arc->angle_ofs;
|
||||
end_angle += arc->angle_ofs;
|
||||
start_angle +=arc->angle_ofs;
|
||||
end_angle +=arc->angle_ofs;
|
||||
|
||||
if(start_angle >= 360) start_angle -= 360;
|
||||
if(end_angle >= 360) end_angle -= 360;
|
||||
@@ -810,13 +750,13 @@ static void inv_arc_area(lv_obj_t * obj, uint16_t start_angle, uint16_t end_angl
|
||||
uint8_t start_quarter = start_angle / 90;
|
||||
uint8_t end_quarter = end_angle / 90;
|
||||
|
||||
lv_coord_t left = lv_obj_get_style_pad_left(obj, LV_ARC_PART_BG);
|
||||
lv_coord_t right = lv_obj_get_style_pad_right(obj, LV_ARC_PART_BG);
|
||||
lv_coord_t top = lv_obj_get_style_pad_top(obj, LV_ARC_PART_BG);
|
||||
lv_coord_t bottom = lv_obj_get_style_pad_bottom(obj, LV_ARC_PART_BG);
|
||||
lv_coord_t left = lv_obj_get_style_pad_left(obj, LV_PART_MAIN);
|
||||
lv_coord_t right = lv_obj_get_style_pad_right(obj, LV_PART_MAIN);
|
||||
lv_coord_t top = lv_obj_get_style_pad_top(obj, LV_PART_MAIN);
|
||||
lv_coord_t bottom = lv_obj_get_style_pad_bottom(obj, LV_PART_MAIN);
|
||||
lv_coord_t rout = (LV_MATH_MIN(lv_obj_get_width(obj) - left - right, lv_obj_get_height(obj) - top - bottom)) / 2;
|
||||
lv_coord_t x = arc->coords.x1 + rout + left;
|
||||
lv_coord_t y = arc->coords.y1 + rout + top;
|
||||
lv_coord_t x = obj->coords.x1 + rout + left;
|
||||
lv_coord_t y = obj->coords.y1 + rout + top;
|
||||
lv_coord_t w = lv_obj_get_style_line_width(obj, part);
|
||||
lv_coord_t rounded = lv_obj_get_style_line_rounded(obj, part);
|
||||
lv_coord_t rin = rout - w;
|
||||
@@ -824,13 +764,13 @@ static void inv_arc_area(lv_obj_t * obj, uint16_t start_angle, uint16_t end_angl
|
||||
|
||||
extra_area = rounded ? w / 2 + 2 : 0;
|
||||
|
||||
if(part == LV_ARC_PART_INDIC && lv_style_list_get_style(&arc->style_knob, 0) != NULL) {
|
||||
lv_coord_t knob_extra_size = _lv_obj_get_draw_rect_ext_pad_size(obj, LV_ARC_PART_KNOB);
|
||||
if(part == LV_PART_INDICATOR) {
|
||||
lv_coord_t knob_extra_size = _lv_obj_get_draw_rect_ext_pad_size(obj, LV_PART_KNOB);
|
||||
|
||||
lv_coord_t knob_left = lv_obj_get_style_pad_left(obj, LV_ARC_PART_KNOB);
|
||||
lv_coord_t knob_right = lv_obj_get_style_pad_right(obj, LV_ARC_PART_KNOB);
|
||||
lv_coord_t knob_top = lv_obj_get_style_pad_top(obj, LV_ARC_PART_KNOB);
|
||||
lv_coord_t knob_bottom = lv_obj_get_style_pad_bottom(obj, LV_ARC_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);
|
||||
|
||||
knob_extra_size += LV_MATH_MAX4(knob_left, knob_right, knob_top, knob_bottom);
|
||||
|
||||
@@ -918,53 +858,53 @@ static void inv_arc_area(lv_obj_t * obj, uint16_t start_angle, uint16_t end_angl
|
||||
}
|
||||
}
|
||||
|
||||
static void get_center(lv_obj_t * arc, lv_point_t * center, lv_coord_t * arc_r)
|
||||
static void get_center(lv_obj_t * obj, lv_point_t * center, lv_coord_t * arc_r)
|
||||
{
|
||||
lv_coord_t left_bg = lv_obj_get_style_pad_left(arc, LV_ARC_PART_BG);
|
||||
lv_coord_t right_bg = lv_obj_get_style_pad_right(arc, LV_ARC_PART_BG);
|
||||
lv_coord_t top_bg = lv_obj_get_style_pad_top(arc, LV_ARC_PART_BG);
|
||||
lv_coord_t bottom_bg = lv_obj_get_style_pad_bottom(arc, LV_ARC_PART_BG);
|
||||
lv_coord_t left_bg = lv_obj_get_style_pad_left(obj, LV_PART_MAIN);
|
||||
lv_coord_t right_bg = lv_obj_get_style_pad_right(obj, LV_PART_MAIN);
|
||||
lv_coord_t top_bg = lv_obj_get_style_pad_top(obj, LV_PART_MAIN);
|
||||
lv_coord_t bottom_bg = lv_obj_get_style_pad_bottom(obj, LV_PART_MAIN);
|
||||
|
||||
lv_coord_t r = (LV_MATH_MIN(lv_obj_get_width(arc) - left_bg - right_bg,
|
||||
lv_obj_get_height(arc) - top_bg - bottom_bg)) / 2;
|
||||
lv_coord_t r = (LV_MATH_MIN(lv_obj_get_width(obj) - left_bg - right_bg,
|
||||
lv_obj_get_height(obj) - top_bg - bottom_bg)) / 2;
|
||||
|
||||
*arc_r = r;
|
||||
center->x = arc->coords.x1 + r + left_bg;
|
||||
center->y = arc->coords.y1 + r + top_bg;
|
||||
center->x = obj->coords.x1 + r + left_bg;
|
||||
center->y = obj->coords.y1 + r + top_bg;
|
||||
|
||||
|
||||
lv_coord_t indic_width = lv_obj_get_style_line_width(arc, LV_ARC_PART_INDIC);
|
||||
lv_coord_t indic_width = lv_obj_get_style_line_width(obj, LV_PART_INDICATOR);
|
||||
r -= indic_width;
|
||||
}
|
||||
|
||||
static void get_knob_area(lv_obj_t * obj, const lv_point_t * center, lv_coord_t r, lv_area_t * knob_area)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
lv_arc_t * arc = (lv_arc_t*) obj;
|
||||
lv_arc_t * arc = (lv_arc_t *)obj;
|
||||
|
||||
lv_coord_t indic_width = lv_obj_get_style_line_width(obj, LV_ARC_PART_INDIC);
|
||||
lv_coord_t indic_width = lv_obj_get_style_line_width(obj, LV_PART_INDICATOR);
|
||||
lv_coord_t indic_width_half = indic_width / 2;
|
||||
r -= indic_width_half;
|
||||
|
||||
uint16_t angle = arc->angle_ofs;
|
||||
uint16_t angle =arc->angle_ofs;
|
||||
if(arc->type == LV_ARC_TYPE_NORMAL) {
|
||||
angle += arc->indic_angle_end;
|
||||
angle +=arc->indic_angle_end;
|
||||
}
|
||||
else if(arc->type == LV_ARC_TYPE_REVERSE) {
|
||||
angle += arc->indic_angle_start;
|
||||
angle +=arc->indic_angle_start;
|
||||
}
|
||||
else if(arc->type == LV_ARC_TYPE_SYMMETRIC) {
|
||||
int32_t range_midpoint = (int32_t)(arc->min_value + arc->max_value) / 2;
|
||||
if(arc->value < range_midpoint) angle += arc->indic_angle_start;
|
||||
else angle += arc->indic_angle_end;
|
||||
int32_t range_midpoint = (int32_t)(arc->min_value +arc->max_value) / 2;
|
||||
if(arc->value < range_midpoint) angle +=arc->indic_angle_start;
|
||||
else angle +=arc->indic_angle_end;
|
||||
}
|
||||
lv_coord_t knob_x = (r * _lv_trigo_sin(angle + 90)) >> LV_TRIGO_SHIFT;
|
||||
lv_coord_t knob_y = (r * _lv_trigo_sin(angle)) >> LV_TRIGO_SHIFT;
|
||||
|
||||
lv_coord_t left_knob = lv_obj_get_style_pad_left(obj, LV_ARC_PART_KNOB);
|
||||
lv_coord_t right_knob = lv_obj_get_style_pad_right(obj, LV_ARC_PART_KNOB);
|
||||
lv_coord_t top_knob = lv_obj_get_style_pad_top(obj, LV_ARC_PART_KNOB);
|
||||
lv_coord_t bottom_knob = lv_obj_get_style_pad_bottom(obj, LV_ARC_PART_KNOB);
|
||||
lv_coord_t left_knob = lv_obj_get_style_pad_left(obj, LV_PART_KNOB);
|
||||
lv_coord_t right_knob = lv_obj_get_style_pad_right(obj, LV_PART_KNOB);
|
||||
lv_coord_t top_knob = lv_obj_get_style_pad_top(obj, LV_PART_KNOB);
|
||||
lv_coord_t bottom_knob = lv_obj_get_style_pad_bottom(obj, LV_PART_KNOB);
|
||||
|
||||
knob_area->x1 = center->x + knob_x - left_knob - indic_width_half;
|
||||
knob_area->x2 = center->x + knob_x + right_knob + indic_width_half;
|
||||
@@ -979,36 +919,36 @@ static void get_knob_area(lv_obj_t * obj, const lv_point_t * center, lv_coord_t
|
||||
static void value_update(lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
lv_arc_t * arc = (lv_arc_t*) obj;
|
||||
lv_arc_t * arc = (lv_arc_t *)obj;
|
||||
|
||||
int16_t bg_midpoint, range_midpoint, bg_end = arc->bg_angle_end;
|
||||
if(arc->bg_angle_end < arc->bg_angle_start) bg_end = arc->bg_angle_end + 360;
|
||||
int16_t bg_midpoint, range_midpoint, bg_end =arc->bg_angle_end;
|
||||
if(arc->bg_angle_end <arc->bg_angle_start) bg_end =arc->bg_angle_end + 360;
|
||||
|
||||
int16_t angle;
|
||||
switch(arc->type) {
|
||||
case LV_ARC_TYPE_SYMMETRIC:
|
||||
bg_midpoint = (arc->bg_angle_start + bg_end) / 2;
|
||||
range_midpoint = (int32_t)(arc->min_value + arc->max_value) / 2;
|
||||
range_midpoint = (int32_t)(arc->min_value +arc->max_value) / 2;
|
||||
|
||||
if(arc->value < range_midpoint) {
|
||||
angle = _lv_map(arc->value, arc->min_value, range_midpoint, arc->bg_angle_start, bg_midpoint);
|
||||
angle = _lv_map(arc->value,arc->min_value, range_midpoint,arc->bg_angle_start, bg_midpoint);
|
||||
lv_arc_set_start_angle(obj, angle);
|
||||
lv_arc_set_end_angle(obj, bg_midpoint);
|
||||
}
|
||||
else {
|
||||
angle = _lv_map(arc->value, range_midpoint, arc->max_value, bg_midpoint, bg_end);
|
||||
angle = _lv_map(arc->value, range_midpoint,arc->max_value, bg_midpoint, bg_end);
|
||||
lv_arc_set_start_angle(obj, bg_midpoint);
|
||||
lv_arc_set_end_angle(obj, angle);
|
||||
}
|
||||
break;
|
||||
case LV_ARC_TYPE_REVERSE:
|
||||
angle = _lv_map(arc->value, arc->min_value, arc->max_value, arc->bg_angle_start, bg_end);
|
||||
angle = _lv_map(arc->value,arc->min_value,arc->max_value,arc->bg_angle_start, bg_end);
|
||||
lv_arc_set_start_angle(obj, angle);
|
||||
break;
|
||||
default: /** LV_ARC_TYPE_NORMAL*/
|
||||
angle = _lv_map(arc->value, arc->min_value, arc->max_value, arc->bg_angle_start, bg_end);
|
||||
angle = _lv_map(arc->value,arc->min_value,arc->max_value,arc->bg_angle_start, bg_end);
|
||||
lv_arc_set_end_angle(obj, angle);
|
||||
lv_arc_set_start_angle(obj, arc->bg_angle_start);
|
||||
lv_arc_set_start_angle(obj,arc->bg_angle_start);
|
||||
}
|
||||
arc->last_angle = angle; /*Cache angle for slew rate limiting*/
|
||||
}
|
||||
|
||||
@@ -36,45 +36,26 @@ typedef uint8_t lv_arc_type_t;
|
||||
|
||||
|
||||
|
||||
LV_CLASS_DECLARE_START(lv_arc, lv_obj);
|
||||
|
||||
#define _lv_arc_constructor void (*constructor)(struct _lv_obj_t * obj, struct _lv_obj_t * parent, const struct _lv_obj_t * copy)
|
||||
|
||||
#define _lv_arc_data \
|
||||
_lv_obj_data \
|
||||
uint16_t angle_ofs; \
|
||||
uint16_t indic_angle_start; \
|
||||
uint16_t indic_angle_end; \
|
||||
uint16_t bg_angle_start; \
|
||||
uint16_t bg_angle_end; \
|
||||
int16_t value; /*Current value of the arc*/ \
|
||||
int16_t min_value; /*Minimum value of the arc*/ \
|
||||
int16_t max_value; /*Maximum value of the arc*/ \
|
||||
uint16_t dragging : 1; \
|
||||
uint16_t type : 2; \
|
||||
uint16_t adjustable : 1; \
|
||||
uint16_t min_close : 1; /*1: the last pressed angle was closer to minimum end*/ \
|
||||
uint16_t chg_rate; /*Drag angle rate of change of the arc (degrees/sec)*/ \
|
||||
uint32_t last_tick; /*Last dragging event timestamp of the arc*/ \
|
||||
typedef struct {
|
||||
lv_obj_t obj;
|
||||
uint16_t angle_ofs;
|
||||
uint16_t indic_angle_start;
|
||||
uint16_t indic_angle_end;
|
||||
uint16_t bg_angle_start;
|
||||
uint16_t bg_angle_end;
|
||||
int16_t value; /*Current value of the arc*/
|
||||
int16_t min_value; /*Minimum value of the arc*/
|
||||
int16_t max_value; /*Maximum value of the arc*/
|
||||
uint16_t dragging : 1;
|
||||
uint16_t type : 2;
|
||||
uint16_t adjustable : 1;
|
||||
uint16_t min_close : 1; /*1: the last pressed angle was closer to minimum end*/
|
||||
uint16_t chg_rate; /*Drag angle rate of change of the arc (degrees/sec)*/
|
||||
uint32_t last_tick; /*Last dragging event timestamp of the arc*/
|
||||
int16_t last_angle; /*Last dragging angle of the arc*/
|
||||
}lv_arc_t;
|
||||
|
||||
#define _lv_arc_class_dsc \
|
||||
_lv_obj_class_dsc \
|
||||
|
||||
LV_CLASS_DECLARE_END(lv_arc, lv_obj);
|
||||
|
||||
extern lv_arc_class_t lv_arc;
|
||||
|
||||
|
||||
|
||||
/*Parts of the arc*/
|
||||
enum {
|
||||
LV_ARC_PART_BG = LV_OBJ_PART_MAIN,
|
||||
LV_ARC_PART_INDIC,
|
||||
LV_ARC_PART_KNOB,
|
||||
_LV_ARC_PART_VIRTUAL_LAST,
|
||||
};
|
||||
typedef uint8_t lv_arc_part_t;
|
||||
extern const lv_obj_class_t lv_arc;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
|
||||
@@ -58,7 +58,8 @@ const lv_obj_class_t lv_bar = {
|
||||
.destructor = lv_bar_destructor,
|
||||
.signal_cb = lv_bar_signal,
|
||||
.design_cb = lv_bar_design,
|
||||
.ext_size = sizeof(lv_bar_ext_t),
|
||||
.instance_size = sizeof(lv_bar_t),
|
||||
.base_class = &lv_obj
|
||||
};
|
||||
|
||||
/**********************
|
||||
@@ -94,23 +95,21 @@ lv_obj_t * lv_bar_create(lv_obj_t * parent, const lv_obj_t * copy)
|
||||
void lv_bar_set_value(lv_obj_t * obj, int16_t value, lv_anim_enable_t anim)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
lv_bar_ext_t * ext = obj->ext_attr;
|
||||
lv_bar_t * bar = (lv_bar_t *)obj;
|
||||
|
||||
if(ext->cur_value == value) return;
|
||||
if(bar->cur_value == value) return;
|
||||
|
||||
int16_t new_value = value;
|
||||
new_value = value > ext->max_value ? ext->max_value : new_value;
|
||||
new_value = new_value < ext->min_value ? ext->min_value : new_value;
|
||||
new_value = new_value < ext->start_value ? ext->start_value : new_value;
|
||||
value = LV_CLAMP(bar->min_value, value, bar->max_value);
|
||||
value = value < bar->start_value ? bar->start_value : value; /*Can be smaller then the left value*/
|
||||
|
||||
|
||||
if(ext->cur_value == new_value) return;
|
||||
if(bar->cur_value == value) return;
|
||||
#if LV_USE_ANIMATION == 0
|
||||
LV_UNUSED(anim);
|
||||
ext->cur_value = new_value;
|
||||
bar->cur_value = value;
|
||||
lv_obj_invalidate(bar);
|
||||
#else
|
||||
lv_bar_set_value_with_anim(obj, new_value, &ext->cur_value, &ext->cur_value_anim, anim);
|
||||
lv_bar_set_value_with_anim(obj, value, &bar->cur_value, &bar->cur_value_anim, anim);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -124,19 +123,19 @@ void lv_bar_set_start_value(lv_obj_t * obj, int16_t start_value, lv_anim_enable_
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
lv_bar_ext_t * ext = obj->ext_attr;
|
||||
lv_bar_t * bar = (lv_bar_t *)obj;
|
||||
|
||||
int16_t new_value = start_value;
|
||||
new_value = new_value > ext->max_value ? ext->max_value : new_value;
|
||||
new_value = new_value < ext->min_value ? ext->min_value : new_value;
|
||||
new_value = new_value > ext->cur_value ? ext->cur_value : new_value;
|
||||
new_value = new_value > bar->max_value ? bar->max_value : new_value;
|
||||
new_value = new_value < bar->min_value ? bar->min_value : new_value;
|
||||
new_value = new_value > bar->cur_value ? bar->cur_value : new_value;
|
||||
|
||||
if(ext->start_value == new_value) return;
|
||||
if(bar->start_value == new_value) return;
|
||||
#if LV_USE_ANIMATION == 0
|
||||
LV_UNUSED(anim);
|
||||
ext->start_value = new_value;
|
||||
bar->start_value = new_value;
|
||||
#else
|
||||
lv_bar_set_value_with_anim(obj, new_value, &ext->start_value, &ext->start_value_anim, anim);
|
||||
lv_bar_set_value_with_anim(obj, new_value, &bar->start_value, &bar->start_value_anim, anim);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -150,23 +149,23 @@ void lv_bar_set_range(lv_obj_t * obj, int16_t min, int16_t max)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
lv_bar_ext_t * ext = obj->ext_attr;
|
||||
lv_bar_t * bar = (lv_bar_t *)obj;
|
||||
|
||||
if(ext->min_value == min && ext->max_value == max) return;
|
||||
if(bar->min_value == min && bar->max_value == max) return;
|
||||
|
||||
ext->max_value = max;
|
||||
ext->min_value = min;
|
||||
bar->max_value = max;
|
||||
bar->min_value = min;
|
||||
|
||||
if(lv_bar_get_type(obj) != LV_BAR_TYPE_CUSTOM)
|
||||
ext->start_value = min;
|
||||
bar->start_value = min;
|
||||
|
||||
if(ext->cur_value > max) {
|
||||
ext->cur_value = max;
|
||||
lv_bar_set_value(obj, ext->cur_value, false);
|
||||
if(bar->cur_value > max) {
|
||||
bar->cur_value = max;
|
||||
lv_bar_set_value(obj, bar->cur_value, false);
|
||||
}
|
||||
if(ext->cur_value < min) {
|
||||
ext->cur_value = min;
|
||||
lv_bar_set_value(obj, ext->cur_value, false);
|
||||
if(bar->cur_value < min) {
|
||||
bar->cur_value = min;
|
||||
lv_bar_set_value(obj, bar->cur_value, false);
|
||||
}
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
@@ -179,33 +178,15 @@ void lv_bar_set_range(lv_obj_t * obj, int16_t min, int16_t max)
|
||||
void lv_bar_set_type(lv_obj_t * obj, lv_bar_type_t type)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
lv_bar_ext_t * ext = obj->ext_attr;
|
||||
lv_bar_t * bar = (lv_bar_t *)obj;
|
||||
|
||||
ext->type = type;
|
||||
if(ext->type != LV_BAR_TYPE_CUSTOM)
|
||||
ext->start_value = ext->min_value;
|
||||
bar->type = type;
|
||||
if(bar->type != LV_BAR_TYPE_CUSTOM)
|
||||
bar->start_value = bar->min_value;
|
||||
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the animation time of the bar
|
||||
* @param bar pointer to a bar object
|
||||
* @param anim_time the animation time in milliseconds.
|
||||
*/
|
||||
void lv_bar_set_anim_time(lv_obj_t * obj, uint16_t anim_time)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
#if LV_USE_ANIMATION
|
||||
lv_bar_ext_t * ext = obj->ext_attr;
|
||||
ext->anim_time = anim_time;
|
||||
#else
|
||||
(void)bar; /*Unused*/
|
||||
(void)anim_time; /*Unused*/
|
||||
#endif
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
@@ -218,9 +199,9 @@ void lv_bar_set_anim_time(lv_obj_t * obj, uint16_t anim_time)
|
||||
int16_t lv_bar_get_value(const lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
lv_bar_ext_t * ext = obj->ext_attr;
|
||||
lv_bar_t * bar = (lv_bar_t *)obj;
|
||||
|
||||
return LV_BAR_GET_ANIM_VALUE(ext->cur_value, ext->cur_value_anim);
|
||||
return LV_BAR_GET_ANIM_VALUE(bar->cur_value, bar->cur_value_anim);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -231,11 +212,11 @@ int16_t lv_bar_get_value(const lv_obj_t * obj)
|
||||
int16_t lv_bar_get_start_value(const lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
lv_bar_ext_t * ext = obj->ext_attr;
|
||||
lv_bar_t * bar = (lv_bar_t *)obj;
|
||||
|
||||
if(ext->type != LV_BAR_TYPE_CUSTOM) return ext->min_value;
|
||||
if(bar->type != LV_BAR_TYPE_CUSTOM) return bar->min_value;
|
||||
|
||||
return LV_BAR_GET_ANIM_VALUE(ext->start_value, ext->start_value_anim);
|
||||
return LV_BAR_GET_ANIM_VALUE(bar->start_value, bar->start_value_anim);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -246,8 +227,8 @@ int16_t lv_bar_get_start_value(const lv_obj_t * obj)
|
||||
int16_t lv_bar_get_min_value(const lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
lv_bar_ext_t * ext = obj->ext_attr;
|
||||
return ext->min_value;
|
||||
lv_bar_t * bar = (lv_bar_t *)obj;
|
||||
return bar->min_value;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -258,9 +239,9 @@ int16_t lv_bar_get_min_value(const lv_obj_t * obj)
|
||||
int16_t lv_bar_get_max_value(const lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
lv_bar_ext_t * ext = obj->ext_attr;
|
||||
lv_bar_t * bar = (lv_bar_t *)obj;
|
||||
|
||||
return ext->max_value;
|
||||
return bar->max_value;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -271,31 +252,11 @@ int16_t lv_bar_get_max_value(const lv_obj_t * obj)
|
||||
lv_bar_type_t lv_bar_get_type(lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
lv_bar_ext_t * ext = obj->ext_attr;
|
||||
lv_bar_t * bar = (lv_bar_t *)obj;
|
||||
|
||||
return ext->type;
|
||||
return bar->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the animation time of the bar
|
||||
* @param bar pointer to a bar object
|
||||
* @return the animation time in milliseconds.
|
||||
*/
|
||||
uint16_t lv_bar_get_anim_time(const lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
#if LV_USE_ANIMATION
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
lv_bar_ext_t * ext = obj->ext_attr;
|
||||
return ext->anim_time;
|
||||
#else
|
||||
(void)bar; /*Unused*/
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
@@ -307,17 +268,16 @@ static void lv_bar_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t
|
||||
LV_CLASS_CONSTRUCTOR_BEGIN(obj, lv_bar)
|
||||
lv_obj.constructor(obj, parent, copy);
|
||||
|
||||
lv_bar_ext_t * ext = obj->ext_attr;
|
||||
ext->min_value = 0;
|
||||
ext->max_value = 100;
|
||||
ext->start_value = 0;
|
||||
ext->cur_value = 0;
|
||||
ext->type = LV_BAR_TYPE_NORMAL;
|
||||
lv_bar_t * bar = (lv_bar_t *)obj;
|
||||
bar->min_value = 0;
|
||||
bar->max_value = 100;
|
||||
bar->start_value = 0;
|
||||
bar->cur_value = 0;
|
||||
bar->type = LV_BAR_TYPE_NORMAL;
|
||||
|
||||
#if LV_USE_ANIMATION
|
||||
ext->anim_time = 200;
|
||||
lv_bar_init_anim(obj, &ext->cur_value_anim);
|
||||
lv_bar_init_anim(obj, &ext->start_value_anim);
|
||||
lv_bar_init_anim(obj, &bar->cur_value_anim);
|
||||
lv_bar_init_anim(obj, &bar->start_value_anim);
|
||||
#endif
|
||||
|
||||
if(copy == NULL) {
|
||||
@@ -326,14 +286,14 @@ static void lv_bar_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t
|
||||
lv_obj_set_size(obj, LV_DPI * 2, LV_DPI / 10);
|
||||
lv_bar_set_value(obj, 0, LV_ANIM_OFF);
|
||||
} else {
|
||||
lv_bar_ext_t * copy_ext = copy->ext_attr;
|
||||
ext->min_value = copy_ext->min_value;
|
||||
ext->start_value = copy_ext->start_value;
|
||||
ext->max_value = copy_ext->max_value;
|
||||
ext->cur_value = copy_ext->cur_value;
|
||||
ext->type = copy_ext->type;
|
||||
lv_bar_t * copy_bar = (lv_bar_t *)copy;
|
||||
bar->min_value = copy_bar->min_value;
|
||||
bar->start_value = copy_bar->start_value;
|
||||
bar->max_value = copy_bar->max_value;
|
||||
bar->cur_value = copy_bar->cur_value;
|
||||
bar->type = copy_bar->type;
|
||||
|
||||
lv_bar_set_value(obj, ext->cur_value, LV_ANIM_OFF);
|
||||
lv_bar_set_value(obj, bar->cur_value, LV_ANIM_OFF);
|
||||
}
|
||||
LV_CLASS_CONSTRUCTOR_END(obj, lv_bar)
|
||||
LV_LOG_INFO("bar created");
|
||||
@@ -345,11 +305,11 @@ static void lv_bar_destructor(lv_obj_t * obj)
|
||||
//
|
||||
// _lv_obj_reset_style_list_no_refr(obj, LV_PART_INDICATOR);
|
||||
//#if LV_USE_ANIMATION
|
||||
// lv_anim_del(&ext->cur_value_anim, NULL);
|
||||
// lv_anim_del(&ext->start_value_anim, NULL);
|
||||
// lv_anim_del(&bar->cur_value_anim, NULL);
|
||||
// lv_anim_del(&bar->start_value_anim, NULL);
|
||||
//#endif
|
||||
|
||||
// ext->class_p->base_p->destructor(obj);
|
||||
// bar->class_p->base_p->destructor(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -392,7 +352,7 @@ static lv_design_res_t lv_bar_design(lv_obj_t * obj, const lv_area_t * clip_area
|
||||
|
||||
static void draw_indic(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
{
|
||||
lv_bar_ext_t * ext = obj->ext_attr;
|
||||
lv_bar_t * bar = (lv_bar_t *)obj;
|
||||
|
||||
lv_bidi_dir_t base_dir = lv_obj_get_base_dir(obj);
|
||||
|
||||
@@ -407,11 +367,11 @@ static void draw_indic(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
bar_coords.y2 += transf_h;
|
||||
lv_coord_t barw = lv_area_get_width(&bar_coords);
|
||||
lv_coord_t barh = lv_area_get_height(&bar_coords);
|
||||
int32_t range = ext->max_value - ext->min_value;
|
||||
int32_t range = bar->max_value - bar->min_value;
|
||||
bool hor = barw >= barh ? true : false;
|
||||
bool sym = false;
|
||||
if(ext->type == LV_BAR_TYPE_SYMMETRICAL && ext->min_value < 0 && ext->max_value > 0 &&
|
||||
ext->start_value == ext->min_value) sym = true;
|
||||
if(bar->type == LV_BAR_TYPE_SYMMETRICAL && bar->min_value < 0 && bar->max_value > 0 &&
|
||||
bar->start_value == bar->min_value) sym = true;
|
||||
|
||||
/*Calculate the indicator area*/
|
||||
lv_coord_t bg_left = lv_obj_get_style_pad_left(obj, LV_PART_MAIN);
|
||||
@@ -419,23 +379,23 @@ static void draw_indic(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
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);
|
||||
/*Respect padding and minimum width/height too*/
|
||||
lv_area_copy(&ext->indic_area, &bar_coords);
|
||||
ext->indic_area.x1 += bg_left;
|
||||
ext->indic_area.x2 -= bg_right;
|
||||
ext->indic_area.y1 += bg_top;
|
||||
ext->indic_area.y2 -= bg_bottom;
|
||||
lv_area_copy(&bar->indic_area, &bar_coords);
|
||||
bar->indic_area.x1 += bg_left;
|
||||
bar->indic_area.x2 -= bg_right;
|
||||
bar->indic_area.y1 += bg_top;
|
||||
bar->indic_area.y2 -= bg_bottom;
|
||||
|
||||
if(hor && lv_area_get_height(&ext->indic_area) < LV_BAR_SIZE_MIN) {
|
||||
ext->indic_area.y1 = obj->coords.y1 + (barh / 2) - (LV_BAR_SIZE_MIN / 2);
|
||||
ext->indic_area.y2 = ext->indic_area.y1 + LV_BAR_SIZE_MIN;
|
||||
if(hor && lv_area_get_height(&bar->indic_area) < LV_BAR_SIZE_MIN) {
|
||||
bar->indic_area.y1 = obj->coords.y1 + (barh / 2) - (LV_BAR_SIZE_MIN / 2);
|
||||
bar->indic_area.y2 = bar->indic_area.y1 + LV_BAR_SIZE_MIN;
|
||||
}
|
||||
else if(!hor && lv_area_get_width(&ext->indic_area) < LV_BAR_SIZE_MIN) {
|
||||
ext->indic_area.x1 = obj->coords.x1 + (barw / 2) - (LV_BAR_SIZE_MIN / 2);
|
||||
ext->indic_area.x2 = ext->indic_area.x1 + LV_BAR_SIZE_MIN;
|
||||
else if(!hor && lv_area_get_width(&bar->indic_area) < LV_BAR_SIZE_MIN) {
|
||||
bar->indic_area.x1 = obj->coords.x1 + (barw / 2) - (LV_BAR_SIZE_MIN / 2);
|
||||
bar->indic_area.x2 = bar->indic_area.x1 + LV_BAR_SIZE_MIN;
|
||||
}
|
||||
|
||||
lv_coord_t indicw = lv_area_get_width(&ext->indic_area);
|
||||
lv_coord_t indich = lv_area_get_height(&ext->indic_area);
|
||||
lv_coord_t indicw = lv_area_get_width(&bar->indic_area);
|
||||
lv_coord_t indich = lv_area_get_height(&bar->indic_area);
|
||||
|
||||
/*Calculate the indicator length*/
|
||||
lv_coord_t anim_length = hor ? indicw : indich;
|
||||
@@ -446,24 +406,24 @@ static void draw_indic(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
lv_coord_t (*indic_length_calc)(const lv_area_t * area);
|
||||
|
||||
if(hor) {
|
||||
axis1 = &ext->indic_area.x1;
|
||||
axis2 = &ext->indic_area.x2;
|
||||
axis1 = &bar->indic_area.x1;
|
||||
axis2 = &bar->indic_area.x2;
|
||||
indic_length_calc = lv_area_get_width;
|
||||
}
|
||||
else {
|
||||
axis1 = &ext->indic_area.y1;
|
||||
axis2 = &ext->indic_area.y2;
|
||||
axis1 = &bar->indic_area.y1;
|
||||
axis2 = &bar->indic_area.y2;
|
||||
indic_length_calc = lv_area_get_height;
|
||||
}
|
||||
|
||||
#if LV_USE_ANIMATION
|
||||
if(LV_BAR_IS_ANIMATING(ext->start_value_anim)) {
|
||||
if(LV_BAR_IS_ANIMATING(bar->start_value_anim)) {
|
||||
lv_coord_t anim_start_value_start_x =
|
||||
(int32_t)((int32_t)anim_length * (ext->start_value_anim.anim_start - ext->min_value)) / range;
|
||||
(int32_t)((int32_t)anim_length * (bar->start_value_anim.anim_start - bar->min_value)) / range;
|
||||
lv_coord_t anim_start_value_end_x =
|
||||
(int32_t)((int32_t)anim_length * (ext->start_value_anim.anim_end - ext->min_value)) / range;
|
||||
(int32_t)((int32_t)anim_length * (bar->start_value_anim.anim_end - bar->min_value)) / range;
|
||||
|
||||
anim_start_value_x = (((anim_start_value_end_x - anim_start_value_start_x) * ext->start_value_anim.anim_state) /
|
||||
anim_start_value_x = (((anim_start_value_end_x - anim_start_value_start_x) * bar->start_value_anim.anim_state) /
|
||||
LV_BAR_ANIM_STATE_END);
|
||||
|
||||
anim_start_value_x += anim_start_value_start_x;
|
||||
@@ -471,24 +431,24 @@ static void draw_indic(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
else
|
||||
#endif
|
||||
{
|
||||
anim_start_value_x = (int32_t)((int32_t)anim_length * (ext->start_value - ext->min_value)) / range;
|
||||
anim_start_value_x = (int32_t)((int32_t)anim_length * (bar->start_value - bar->min_value)) / range;
|
||||
}
|
||||
|
||||
#if LV_USE_ANIMATION
|
||||
if(LV_BAR_IS_ANIMATING(ext->cur_value_anim)) {
|
||||
if(LV_BAR_IS_ANIMATING(bar->cur_value_anim)) {
|
||||
lv_coord_t anim_cur_value_start_x =
|
||||
(int32_t)((int32_t)anim_length * (ext->cur_value_anim.anim_start - ext->min_value)) / range;
|
||||
(int32_t)((int32_t)anim_length * (bar->cur_value_anim.anim_start - bar->min_value)) / range;
|
||||
lv_coord_t anim_cur_value_end_x =
|
||||
(int32_t)((int32_t)anim_length * (ext->cur_value_anim.anim_end - ext->min_value)) / range;
|
||||
(int32_t)((int32_t)anim_length * (bar->cur_value_anim.anim_end - bar->min_value)) / range;
|
||||
|
||||
anim_cur_value_x = anim_cur_value_start_x + (((anim_cur_value_end_x - anim_cur_value_start_x) *
|
||||
ext->cur_value_anim.anim_state) /
|
||||
bar->cur_value_anim.anim_state) /
|
||||
LV_BAR_ANIM_STATE_END);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
anim_cur_value_x = (int32_t)((int32_t)anim_length * (ext->cur_value - ext->min_value)) / range;
|
||||
anim_cur_value_x = (int32_t)((int32_t)anim_length * (bar->cur_value - bar->min_value)) / range;
|
||||
}
|
||||
|
||||
if(hor && base_dir == LV_BIDI_DIR_RTL) {
|
||||
@@ -512,7 +472,7 @@ static void draw_indic(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
}
|
||||
if(sym) {
|
||||
lv_coord_t zero;
|
||||
zero = *axis1 + (-ext->min_value * anim_length) / range;
|
||||
zero = *axis1 + (-bar->min_value * anim_length) / range;
|
||||
if(*axis2 > zero)
|
||||
*axis1 = zero;
|
||||
else {
|
||||
@@ -524,7 +484,7 @@ static void draw_indic(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
/*Draw the indicator*/
|
||||
|
||||
/*Do not draw a zero length indicator*/
|
||||
if(!sym && indic_length_calc(&ext->indic_area) <= 1) return;
|
||||
if(!sym && indic_length_calc(&bar->indic_area) <= 1) return;
|
||||
|
||||
uint16_t bg_radius = lv_obj_get_style_radius(obj, LV_PART_MAIN);
|
||||
lv_coord_t short_side = LV_MATH_MIN(barw, barh);
|
||||
@@ -537,15 +497,15 @@ static void draw_indic(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
/* Draw only the shadow if the indicator is long enough.
|
||||
* The radius of the bg and the indicator can make a strange shape where
|
||||
* it'd be very difficult to draw shadow. */
|
||||
if((hor && lv_area_get_width(&ext->indic_area) > bg_radius * 2) ||
|
||||
(!hor && lv_area_get_height(&ext->indic_area) > bg_radius * 2)) {
|
||||
if((hor && lv_area_get_width(&bar->indic_area) > bg_radius * 2) ||
|
||||
(!hor && lv_area_get_height(&bar->indic_area) > bg_radius * 2)) {
|
||||
lv_opa_t bg_opa = draw_indic_dsc.bg_opa;
|
||||
lv_opa_t border_opa = draw_indic_dsc.border_opa;
|
||||
lv_opa_t content_opa = draw_indic_dsc.content_opa;
|
||||
draw_indic_dsc.bg_opa = LV_OPA_TRANSP;
|
||||
draw_indic_dsc.border_opa = LV_OPA_TRANSP;
|
||||
draw_indic_dsc.content_opa = LV_OPA_TRANSP;
|
||||
lv_draw_rect(&ext->indic_area, clip_area, &draw_indic_dsc);
|
||||
lv_draw_rect(&bar->indic_area, clip_area, &draw_indic_dsc);
|
||||
draw_indic_dsc.bg_opa = bg_opa;
|
||||
draw_indic_dsc.border_opa = border_opa;
|
||||
draw_indic_dsc.content_opa = content_opa;
|
||||
@@ -581,7 +541,7 @@ static void draw_indic(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
|
||||
/*Create a mask to the current indicator area to see only this part from the whole gradient.*/
|
||||
lv_draw_mask_radius_param_t mask_indic_param;
|
||||
lv_draw_mask_radius_init(&mask_indic_param, &ext->indic_area, draw_indic_dsc.radius, false);
|
||||
lv_draw_mask_radius_init(&mask_indic_param, &bar->indic_area, draw_indic_dsc.radius, false);
|
||||
int16_t mask_indic_id = lv_draw_mask_add(&mask_indic_param, NULL);
|
||||
|
||||
lv_draw_rect(&mask_indic_max_area, clip_area, &draw_indic_dsc);
|
||||
@@ -593,7 +553,7 @@ static void draw_indic(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
draw_indic_dsc.bg_opa = LV_OPA_TRANSP;
|
||||
draw_indic_dsc.shadow_opa = LV_OPA_TRANSP;
|
||||
draw_indic_dsc.content_opa = LV_OPA_TRANSP;
|
||||
lv_draw_rect(&ext->indic_area, clip_area, &draw_indic_dsc);
|
||||
lv_draw_rect(&bar->indic_area, clip_area, &draw_indic_dsc);
|
||||
|
||||
lv_draw_mask_remove_id(mask_indic_id);
|
||||
lv_draw_mask_remove_id(mask_bg_id);
|
||||
@@ -601,7 +561,7 @@ static void draw_indic(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
/*When not masks draw the value*/
|
||||
draw_indic_dsc.content_opa = content_opa;
|
||||
draw_indic_dsc.border_opa = LV_OPA_TRANSP;
|
||||
lv_draw_rect(&ext->indic_area, clip_area, &draw_indic_dsc);
|
||||
lv_draw_rect(&bar->indic_area, clip_area, &draw_indic_dsc);
|
||||
|
||||
}
|
||||
|
||||
@@ -644,13 +604,13 @@ static void lv_bar_anim_ready(lv_anim_t * a)
|
||||
{
|
||||
lv_bar_anim_t * var = a->var;
|
||||
lv_obj_t * obj = (lv_obj_t *)var->bar;
|
||||
lv_bar_ext_t * ext = obj->ext_attr;
|
||||
lv_bar_t * bar = (lv_bar_t *)obj;
|
||||
|
||||
var->anim_state = LV_BAR_ANIM_STATE_INV;
|
||||
if(var == &ext->cur_value_anim)
|
||||
ext->cur_value = var->anim_end;
|
||||
else if(var == &ext->start_value_anim)
|
||||
ext->start_value = var->anim_end;
|
||||
if(var == &bar->cur_value_anim)
|
||||
bar->cur_value = var->anim_end;
|
||||
else if(var == &bar->start_value_anim)
|
||||
bar->start_value = var->anim_end;
|
||||
lv_obj_invalidate(var->bar);
|
||||
}
|
||||
|
||||
@@ -662,7 +622,7 @@ static void lv_bar_set_value_with_anim(lv_obj_t * obj, int16_t new_value, int16_
|
||||
lv_obj_invalidate((lv_obj_t*)obj);
|
||||
}
|
||||
else {
|
||||
lv_bar_ext_t * ext = obj->ext_attr;
|
||||
lv_bar_t * bar = (lv_bar_t *)obj;
|
||||
|
||||
/*No animation in progress -> simply set the values*/
|
||||
if(anim_info->anim_state == LV_BAR_ANIM_STATE_INV) {
|
||||
@@ -684,7 +644,7 @@ static void lv_bar_set_value_with_anim(lv_obj_t * obj, int16_t new_value, int16_
|
||||
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_bar_anim);
|
||||
lv_anim_set_values(&a, LV_BAR_ANIM_STATE_START, LV_BAR_ANIM_STATE_END);
|
||||
lv_anim_set_ready_cb(&a, lv_bar_anim_ready);
|
||||
lv_anim_set_time(&a, ext->anim_time);
|
||||
lv_anim_set_time(&a, lv_obj_get_style_anim_time(obj, LV_PART_MAIN));
|
||||
lv_anim_start(&a);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,18 +59,18 @@ typedef struct {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
lv_obj_t obj;
|
||||
int16_t cur_value; /*Current value of the bar*/
|
||||
int16_t min_value; /*Minimum value of the bar*/
|
||||
int16_t max_value; /*Maximum value of the bar*/
|
||||
int16_t start_value; /*Start value of the bar*/
|
||||
lv_area_t indic_area; /*Save the indicator area. Might be used by derived types*/
|
||||
#if LV_USE_ANIMATION
|
||||
lv_anim_value_t anim_time;
|
||||
lv_bar_anim_t cur_value_anim;
|
||||
lv_bar_anim_t start_value_anim;
|
||||
#endif
|
||||
uint8_t type : 2; /*Type of bar*/
|
||||
}lv_bar_ext_t;
|
||||
}lv_bar_t;
|
||||
|
||||
extern const lv_obj_class_t lv_bar;
|
||||
|
||||
@@ -122,13 +122,6 @@ void lv_bar_set_range(lv_obj_t * bar, int16_t min, int16_t max);
|
||||
*/
|
||||
void lv_bar_set_type(lv_obj_t * bar, lv_bar_type_t type);
|
||||
|
||||
/**
|
||||
* Set the animation time of the bar
|
||||
* @param bar pointer to a bar object
|
||||
* @param anim_time the animation time in milliseconds.
|
||||
*/
|
||||
void lv_bar_set_anim_time(lv_obj_t * bar, uint16_t anim_time);
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
@@ -168,13 +161,6 @@ int16_t lv_bar_get_max_value(const lv_obj_t * bar);
|
||||
*/
|
||||
lv_bar_type_t lv_bar_get_type(lv_obj_t * bar);
|
||||
|
||||
/**
|
||||
* Get the animation time of the bar
|
||||
* @param bar pointer to a bar object
|
||||
* @return the animation time in milliseconds.
|
||||
*/
|
||||
uint16_t lv_bar_get_anim_time(const lv_obj_t * bar);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
@@ -44,7 +44,8 @@ const lv_obj_class_t lv_btn = {
|
||||
.destructor = lv_btn_destructor,
|
||||
.signal_cb = lv_btn_signal,
|
||||
.design_cb = lv_btn_design,
|
||||
.ext_size = 0,
|
||||
.instance_size = sizeof(lv_btn_t),
|
||||
.base_class = &lv_obj
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@ extern "C" {
|
||||
**********************/
|
||||
|
||||
typedef struct {
|
||||
|
||||
}lv_btn_ext_t;
|
||||
lv_obj_t obj;
|
||||
}lv_btn_t;
|
||||
|
||||
extern const lv_obj_class_t lv_btn;
|
||||
|
||||
|
||||
@@ -58,7 +58,8 @@ const lv_obj_class_t lv_btnmatrix = {
|
||||
.destructor = lv_btnmatrix_destructor,
|
||||
.signal_cb = lv_btnmatrix_signal,
|
||||
.design_cb = lv_btnmatrix_design,
|
||||
.ext_size = sizeof(lv_btnmatrix_ext_t),
|
||||
.instance_size = sizeof(lv_btnmatrix_t),
|
||||
.base_class = &lv_obj
|
||||
};
|
||||
|
||||
/**********************
|
||||
@@ -97,11 +98,11 @@ void lv_btnmatrix_set_map(lv_obj_t * obj, const char * map[])
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
LV_ASSERT_NULL(map);
|
||||
|
||||
lv_btnmatrix_ext_t * ext = obj->ext_attr;;
|
||||
lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj;;
|
||||
|
||||
/*Analyze the map and create the required number of buttons*/
|
||||
allocate_btn_areas_and_controls(obj, map);
|
||||
ext->map_p = map;
|
||||
btnm->map_p = map;
|
||||
|
||||
lv_bidi_dir_t base_dir = lv_obj_get_base_dir(obj);
|
||||
|
||||
@@ -137,7 +138,7 @@ void lv_btnmatrix_set_map(lv_obj_t * obj, const char * map[])
|
||||
uint16_t btn_cnt = 0; /*Number of buttons in a row*/
|
||||
/*Count the buttons and units in this row*/
|
||||
while(strcmp(map_row[btn_cnt], "\n") != 0 && strlen(map_row[btn_cnt]) != '\0') {
|
||||
unit_cnt += get_button_width(ext->ctrl_bits[btn_tot_i + btn_cnt]);
|
||||
unit_cnt += get_button_width(btnm->ctrl_bits[btn_tot_i + btn_cnt]);
|
||||
btn_cnt++;
|
||||
}
|
||||
|
||||
@@ -157,7 +158,7 @@ void lv_btnmatrix_set_map(lv_obj_t * obj, const char * map[])
|
||||
uint32_t row_unit_cnt = 0; /*The current unit position in the row*/
|
||||
uint32_t btn;
|
||||
for(btn = 0; btn < btn_cnt; btn++, btn_tot_i++, txt_tot_i++) {
|
||||
uint32_t btn_u = get_button_width(ext->ctrl_bits[btn_tot_i]);
|
||||
uint32_t btn_u = get_button_width(btnm->ctrl_bits[btn_tot_i]);
|
||||
|
||||
lv_coord_t btn_x1 = pleft + (max_w_no_gap * row_unit_cnt) / unit_cnt + btn * pcol;
|
||||
lv_coord_t btn_x2 = pleft + (max_w_no_gap * (row_unit_cnt + btn_u)) / unit_cnt + btn * pcol - 1;
|
||||
@@ -171,7 +172,7 @@ void lv_btnmatrix_set_map(lv_obj_t * obj, const char * map[])
|
||||
btn_x2 = max_w - btn_x2;
|
||||
}
|
||||
|
||||
lv_area_set(&ext->button_areas[btn_tot_i], btn_x1, row_y1, btn_x2, row_y2);
|
||||
lv_area_set(&btnm->button_areas[btn_tot_i], btn_x1, row_y1, btn_x2, row_y2);
|
||||
|
||||
row_unit_cnt += btn_u;
|
||||
}
|
||||
@@ -198,10 +199,10 @@ void lv_btnmatrix_set_ctrl_map(lv_obj_t * obj, const lv_btnmatrix_ctrl_t ctrl_ma
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
lv_btnmatrix_ext_t * ext = obj->ext_attr;
|
||||
_lv_memcpy(ext->ctrl_bits, ctrl_map, sizeof(lv_btnmatrix_ctrl_t) * ext->btn_cnt);
|
||||
lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj;
|
||||
_lv_memcpy(btnm->ctrl_bits, ctrl_map, sizeof(lv_btnmatrix_ctrl_t) * btnm->btn_cnt);
|
||||
|
||||
lv_btnmatrix_set_map(obj, ext->map_p);
|
||||
lv_btnmatrix_set_map(obj, btnm->map_p);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -213,13 +214,13 @@ void lv_btnmatrix_set_focused_btn(lv_obj_t * obj, uint16_t id)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
lv_btnmatrix_ext_t * ext = obj->ext_attr;
|
||||
lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj;
|
||||
|
||||
if(id >= ext->btn_cnt && id != LV_BTNMATRIX_BTN_NONE) return;
|
||||
if(id >= btnm->btn_cnt && id != LV_BTNMATRIX_BTN_NONE) return;
|
||||
|
||||
if(id == ext->btn_id_focused) return;
|
||||
if(id == btnm->btn_id_focused) return;
|
||||
|
||||
ext->btn_id_focused = id;
|
||||
btnm->btn_id_focused = id;
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
|
||||
@@ -233,9 +234,9 @@ void lv_btnmatrix_set_recolor(const lv_obj_t * obj, bool en)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
lv_btnmatrix_ext_t * ext = obj->ext_attr;;
|
||||
lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj;;
|
||||
|
||||
ext->recolor = en;
|
||||
btnm->recolor = en;
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
|
||||
@@ -248,15 +249,15 @@ void lv_btnmatrix_set_btn_ctrl(lv_obj_t * obj, uint16_t btn_id, lv_btnmatrix_ctr
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
lv_btnmatrix_ext_t * ext = obj->ext_attr;;
|
||||
lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj;;
|
||||
|
||||
if(btn_id >= ext->btn_cnt) return;
|
||||
if(btn_id >= btnm->btn_cnt) return;
|
||||
|
||||
if(ext->one_check && (ctrl & LV_BTNMATRIX_CTRL_CHECKED)) {
|
||||
if(btnm->one_check && (ctrl & LV_BTNMATRIX_CTRL_CHECKED)) {
|
||||
lv_btnmatrix_clear_btn_ctrl_all(obj, LV_BTNMATRIX_CTRL_CHECKED);
|
||||
}
|
||||
|
||||
ext->ctrl_bits[btn_id] |= ctrl;
|
||||
btnm->ctrl_bits[btn_id] |= ctrl;
|
||||
invalidate_button_area(obj, btn_id);
|
||||
}
|
||||
|
||||
@@ -269,11 +270,11 @@ void lv_btnmatrix_clear_btn_ctrl(const lv_obj_t * obj, uint16_t btn_id, lv_btnma
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
lv_btnmatrix_ext_t * ext = obj->ext_attr;;
|
||||
lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj;;
|
||||
|
||||
if(btn_id >= ext->btn_cnt) return;
|
||||
if(btn_id >= btnm->btn_cnt) return;
|
||||
|
||||
ext->ctrl_bits[btn_id] &= (~ctrl);
|
||||
btnm->ctrl_bits[btn_id] &= (~ctrl);
|
||||
invalidate_button_area(obj, btn_id);
|
||||
}
|
||||
|
||||
@@ -286,9 +287,9 @@ void lv_btnmatrix_set_btn_ctrl_all(lv_obj_t * obj, lv_btnmatrix_ctrl_t ctrl)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
lv_btnmatrix_ext_t * ext = obj->ext_attr;;
|
||||
lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj;;
|
||||
uint16_t i;
|
||||
for(i = 0; i < ext->btn_cnt; i++) {
|
||||
for(i = 0; i < btnm->btn_cnt; i++) {
|
||||
lv_btnmatrix_set_btn_ctrl(obj, i, ctrl);
|
||||
}
|
||||
}
|
||||
@@ -303,9 +304,9 @@ void lv_btnmatrix_clear_btn_ctrl_all(lv_obj_t * obj, lv_btnmatrix_ctrl_t ctrl)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
lv_btnmatrix_ext_t * ext = obj->ext_attr;;
|
||||
lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj;;
|
||||
uint16_t i;
|
||||
for(i = 0; i < ext->btn_cnt; i++) {
|
||||
for(i = 0; i < btnm->btn_cnt; i++) {
|
||||
lv_btnmatrix_clear_btn_ctrl(obj, i, ctrl);
|
||||
}
|
||||
}
|
||||
@@ -324,12 +325,12 @@ void lv_btnmatrix_set_btn_width(lv_obj_t * obj, uint16_t btn_id, uint8_t width)
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
|
||||
lv_btnmatrix_ext_t * ext = obj->ext_attr;;
|
||||
if(btn_id >= ext->btn_cnt) return;
|
||||
ext->ctrl_bits[btn_id] &= (~LV_BTNMATRIX_WIDTH_MASK);
|
||||
ext->ctrl_bits[btn_id] |= (LV_BTNMATRIX_WIDTH_MASK & width);
|
||||
lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj;;
|
||||
if(btn_id >= btnm->btn_cnt) return;
|
||||
btnm->ctrl_bits[btn_id] &= (~LV_BTNMATRIX_WIDTH_MASK);
|
||||
btnm->ctrl_bits[btn_id] |= (LV_BTNMATRIX_WIDTH_MASK & width);
|
||||
|
||||
lv_btnmatrix_set_map(obj, ext->map_p);
|
||||
lv_btnmatrix_set_map(obj, btnm->map_p);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -343,30 +344,13 @@ void lv_btnmatrix_set_one_checked(lv_obj_t * obj, bool one_chk)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
lv_btnmatrix_ext_t * ext = obj->ext_attr;;
|
||||
ext->one_check = one_chk;
|
||||
lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj;;
|
||||
btnm->one_check = one_chk;
|
||||
|
||||
/*If more than one button is toggled only the first one should be*/
|
||||
make_one_button_checked(obj, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the align of the map text (left, right or center)
|
||||
* @param obj pointer to a btnmatrix object
|
||||
* @param align LV_LABEL_ALIGN_LEFT, LV_LABEL_ALIGN_RIGHT or LV_LABEL_ALIGN_CENTER
|
||||
*/
|
||||
void lv_btnmatrix_set_text_align(lv_obj_t * obj, lv_label_align_t align)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
lv_btnmatrix_ext_t * ext = obj->ext_attr;;
|
||||
if(ext->align == align) return;
|
||||
|
||||
ext->align = align;
|
||||
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
@@ -380,8 +364,8 @@ const char ** lv_btnmatrix_get_map_array(const lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
lv_btnmatrix_ext_t * ext = obj->ext_attr;;
|
||||
return ext->map_p;
|
||||
lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj;;
|
||||
return btnm->map_p;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -393,9 +377,9 @@ bool lv_btnmatrix_get_recolor(const lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
lv_btnmatrix_ext_t * ext = obj->ext_attr;;
|
||||
lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj;;
|
||||
|
||||
return ext->recolor;
|
||||
return btnm->recolor;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -408,8 +392,8 @@ uint16_t lv_btnmatrix_get_active_btn(const lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
lv_btnmatrix_ext_t * ext = obj->ext_attr;;
|
||||
return ext->btn_id_act;
|
||||
lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj;;
|
||||
return btnm->btn_id_act;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -422,9 +406,9 @@ const char * lv_btnmatrix_get_active_btn_text(const lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
lv_btnmatrix_ext_t * ext = obj->ext_attr;;
|
||||
if(ext->btn_id_act != LV_BTNMATRIX_BTN_NONE) {
|
||||
return lv_btnmatrix_get_btn_text(obj, ext->btn_id_act);
|
||||
lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj;;
|
||||
if(btnm->btn_id_act != LV_BTNMATRIX_BTN_NONE) {
|
||||
return lv_btnmatrix_get_btn_text(obj, btnm->btn_id_act);
|
||||
}
|
||||
else {
|
||||
return NULL;
|
||||
@@ -441,8 +425,8 @@ uint16_t lv_btnmatrix_get_focused_btn(const lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
lv_btnmatrix_ext_t * ext = obj->ext_attr;;
|
||||
return ext->btn_id_focused;
|
||||
lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj;;
|
||||
return btnm->btn_id_focused;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -456,23 +440,23 @@ const char * lv_btnmatrix_get_btn_text(const lv_obj_t * obj, uint16_t btn_id)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
lv_btnmatrix_ext_t * ext = obj->ext_attr;;
|
||||
if(btn_id > ext->btn_cnt) return NULL;
|
||||
lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj;;
|
||||
if(btn_id > btnm->btn_cnt) return NULL;
|
||||
|
||||
uint16_t txt_i = 0;
|
||||
uint16_t btn_i = 0;
|
||||
|
||||
/* Search the text of ext->btn_pr the buttons text in the map
|
||||
/* Search the text of btnm->btn_pr the buttons text in the map
|
||||
* Skip "\n"-s*/
|
||||
while(btn_i != btn_id) {
|
||||
btn_i++;
|
||||
txt_i++;
|
||||
if(strcmp(ext->map_p[txt_i], "\n") == 0) txt_i++;
|
||||
if(strcmp(btnm->map_p[txt_i], "\n") == 0) txt_i++;
|
||||
}
|
||||
|
||||
if(btn_i == ext->btn_cnt) return NULL;
|
||||
if(btn_i == btnm->btn_cnt) return NULL;
|
||||
|
||||
return ext->map_p[txt_i];
|
||||
return btnm->map_p[txt_i];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -487,10 +471,10 @@ bool lv_btnmatrix_get_btn_ctrl(lv_obj_t * obj, uint16_t btn_id, lv_btnmatrix_ctr
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
lv_btnmatrix_ext_t * ext = obj->ext_attr;;
|
||||
if(btn_id >= ext->btn_cnt) return false;
|
||||
lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj;;
|
||||
if(btn_id >= btnm->btn_cnt) return false;
|
||||
|
||||
return (ext->ctrl_bits[btn_id] & ctrl) ? true : false;
|
||||
return (btnm->ctrl_bits[btn_id] & ctrl) ? true : false;
|
||||
}
|
||||
|
||||
|
||||
@@ -503,35 +487,9 @@ bool lv_btnmatrix_get_one_checked(const lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
lv_btnmatrix_ext_t * ext = obj->ext_attr;;
|
||||
lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj;;
|
||||
|
||||
return ext->one_check;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the align attribute
|
||||
* @param obj pointer to a btnmatrix object
|
||||
* @return LV_LABEL_ALIGN_LEFT, LV_LABEL_ALIGN_RIGHT or LV_LABEL_ALIGN_CENTER
|
||||
*/
|
||||
lv_label_align_t lv_btnmatrix_get_align(const lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
lv_btnmatrix_ext_t * ext = obj->ext_attr;;
|
||||
|
||||
lv_label_align_t align = ext->align;
|
||||
|
||||
if(align == LV_LABEL_ALIGN_AUTO) {
|
||||
#if LV_USE_BIDI
|
||||
lv_bidi_dir_t base_dir = lv_obj_get_base_dir(obj);
|
||||
if(base_dir == LV_BIDI_DIR_RTL) align = LV_LABEL_ALIGN_RIGHT;
|
||||
else align = LV_LABEL_ALIGN_LEFT;
|
||||
#else
|
||||
align = LV_LABEL_ALIGN_LEFT;
|
||||
#endif
|
||||
}
|
||||
|
||||
return align;
|
||||
return btnm->one_check;
|
||||
}
|
||||
|
||||
/**********************
|
||||
@@ -547,16 +505,16 @@ static void lv_btnmatrix_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv
|
||||
|
||||
LV_LOG_TRACE("button matrix create started");
|
||||
|
||||
lv_btnmatrix_ext_t * ext = obj->ext_attr;
|
||||
ext->btn_cnt = 0;
|
||||
ext->btn_id_pr = LV_BTNMATRIX_BTN_NONE;
|
||||
ext->btn_id_focused = LV_BTNMATRIX_BTN_NONE;
|
||||
ext->btn_id_act = LV_BTNMATRIX_BTN_NONE;
|
||||
ext->button_areas = NULL;
|
||||
ext->ctrl_bits = NULL;
|
||||
ext->map_p = NULL;
|
||||
ext->recolor = 0;
|
||||
ext->one_check = 0;
|
||||
lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj;
|
||||
btnm->btn_cnt = 0;
|
||||
btnm->btn_id_pr = LV_BTNMATRIX_BTN_NONE;
|
||||
btnm->btn_id_focused = LV_BTNMATRIX_BTN_NONE;
|
||||
btnm->btn_id_act = LV_BTNMATRIX_BTN_NONE;
|
||||
btnm->button_areas = NULL;
|
||||
btnm->ctrl_bits = NULL;
|
||||
btnm->map_p = NULL;
|
||||
btnm->recolor = 0;
|
||||
btnm->one_check = 0;
|
||||
|
||||
/*Init the new button matrix object*/
|
||||
if(copy == NULL) {
|
||||
@@ -565,9 +523,9 @@ static void lv_btnmatrix_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv
|
||||
}
|
||||
/*Copy an existing object*/
|
||||
else {
|
||||
lv_btnmatrix_ext_t * copy_ext = copy->ext_attr;
|
||||
lv_btnmatrix_set_map(obj, copy_ext->map_p);
|
||||
lv_btnmatrix_set_ctrl_map(obj, copy_ext->ctrl_bits);
|
||||
lv_btnmatrix_t * copy_btnm = (lv_btnmatrix_t *) copy;
|
||||
lv_btnmatrix_set_map(obj, copy_btnm->map_p);
|
||||
lv_btnmatrix_set_ctrl_map(obj, copy_btnm->ctrl_bits);
|
||||
}
|
||||
|
||||
|
||||
@@ -578,8 +536,8 @@ static void lv_btnmatrix_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv
|
||||
static void lv_btnmatrix_destructor(lv_obj_t * obj)
|
||||
{
|
||||
|
||||
// lv_mem_free(ext->button_areas);
|
||||
// lv_mem_free(ext->ctrl_bits);
|
||||
// lv_mem_free(btnm->button_areas);
|
||||
// lv_mem_free(btnm->ctrl_bits);
|
||||
}
|
||||
/**
|
||||
* Handle the drawing related tasks of the button matrix
|
||||
@@ -600,8 +558,8 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * obj, const lv_area_t * cli
|
||||
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
lv_obj.design_cb(obj, clip_area, mode);
|
||||
|
||||
lv_btnmatrix_ext_t * ext = obj->ext_attr;;
|
||||
if(ext->btn_cnt == 0) return LV_DESIGN_RES_OK;
|
||||
lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj;
|
||||
if(btnm->btn_cnt == 0) return LV_DESIGN_RES_OK;
|
||||
|
||||
obj->style_list.skip_trans = 1;
|
||||
|
||||
@@ -612,11 +570,11 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * obj, const lv_area_t * cli
|
||||
|
||||
uint16_t btn_i = 0;
|
||||
uint16_t txt_i = 0;
|
||||
lv_txt_flag_t txt_flag = LV_TXT_FLAG_NONE;
|
||||
if(ext->recolor) txt_flag |= LV_TXT_FLAG_RECOLOR;
|
||||
lv_label_align_t align = lv_btnmatrix_get_align(obj);
|
||||
if(align == LV_LABEL_ALIGN_CENTER) txt_flag |= LV_TXT_FLAG_CENTER;
|
||||
if(align == LV_LABEL_ALIGN_RIGHT) txt_flag |= LV_TXT_FLAG_RIGHT;
|
||||
lv_text_flag_t txt_flag = LV_TEXT_FLAG_NONE;
|
||||
if(btnm->recolor) txt_flag |= LV_TEXT_FLAG_RECOLOR;
|
||||
lv_text_align_t align = lv_obj_get_style_text_align(obj, LV_PART_ITEMS);
|
||||
if(align == LV_TEXT_ALIGN_CENTER) txt_flag |= LV_TEXT_FLAG_CENTER;
|
||||
if(align == LV_TEXT_ALIGN_RIGHT) txt_flag |= LV_TEXT_FLAG_RIGHT;
|
||||
|
||||
lv_draw_rect_dsc_t draw_rect_def_dsc;
|
||||
lv_draw_label_dsc_t draw_label_def_dsc;
|
||||
@@ -629,8 +587,8 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * obj, const lv_area_t * cli
|
||||
obj->style_list.skip_trans = 1;
|
||||
lv_draw_rect_dsc_init(&draw_rect_def_dsc);
|
||||
lv_draw_label_dsc_init(&draw_label_def_dsc);
|
||||
lv_obj_init_draw_rect_dsc(obj, LV_PART_ITEM, &draw_rect_def_dsc);
|
||||
lv_obj_init_draw_label_dsc(obj, LV_PART_ITEM, &draw_label_def_dsc);
|
||||
lv_obj_init_draw_rect_dsc(obj, LV_PART_ITEMS, &draw_rect_def_dsc);
|
||||
lv_obj_init_draw_label_dsc(obj, LV_PART_ITEMS, &draw_label_def_dsc);
|
||||
draw_label_def_dsc.flag = txt_flag;
|
||||
obj->style_list.skip_trans = 0;
|
||||
obj->state = state_ori;
|
||||
@@ -645,38 +603,38 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * obj, const lv_area_t * cli
|
||||
char * txt_ap = _lv_mem_buf_get(txt_ap_size);
|
||||
#endif
|
||||
|
||||
for(btn_i = 0; btn_i < ext->btn_cnt; btn_i++, txt_i++) {
|
||||
for(btn_i = 0; btn_i < btnm->btn_cnt; btn_i++, txt_i++) {
|
||||
/*Search the next valid text in the map*/
|
||||
while(strcmp(ext->map_p[txt_i], "\n") == 0) {
|
||||
while(strcmp(btnm->map_p[txt_i], "\n") == 0) {
|
||||
txt_i++;
|
||||
}
|
||||
|
||||
/*Skip hidden buttons*/
|
||||
if(button_is_hidden(ext->ctrl_bits[btn_i])) continue;
|
||||
if(button_is_hidden(btnm->ctrl_bits[btn_i])) continue;
|
||||
|
||||
/*Get the state of the button*/
|
||||
lv_draw_rect_dsc_t * draw_rect_dsc_act;
|
||||
lv_draw_label_dsc_t * draw_label_dsc_act;
|
||||
lv_state_t btn_state = LV_STATE_DEFAULT;
|
||||
if(button_get_checked(ext->ctrl_bits[btn_i])) btn_state |= LV_STATE_CHECKED;
|
||||
if(button_is_inactive(ext->ctrl_bits[btn_i])) btn_state |= LV_STATE_DISABLED;
|
||||
if(btn_i == ext->btn_id_pr) btn_state |= LV_STATE_PRESSED;
|
||||
if(btn_i == ext->btn_id_focused) {
|
||||
if(button_get_checked(btnm->ctrl_bits[btn_i])) btn_state |= LV_STATE_CHECKED;
|
||||
if(button_is_inactive(btnm->ctrl_bits[btn_i])) btn_state |= LV_STATE_DISABLED;
|
||||
if(btn_i == btnm->btn_id_pr) btn_state |= LV_STATE_PRESSED;
|
||||
if(btn_i == btnm->btn_id_focused) {
|
||||
btn_state |= LV_STATE_FOCUSED;
|
||||
if(state_ori & LV_STATE_EDITED) btn_state |= LV_STATE_EDITED;
|
||||
}
|
||||
|
||||
/*Get the button's area*/
|
||||
lv_area_copy(&btn_area, &ext->button_areas[btn_i]);
|
||||
lv_area_copy(&btn_area, &btnm->button_areas[btn_i]);
|
||||
btn_area.x1 += area_obj.x1;
|
||||
btn_area.y1 += area_obj.y1;
|
||||
btn_area.x2 += area_obj.x1;
|
||||
btn_area.y2 += area_obj.y1;
|
||||
|
||||
/*Use the custom drawer if any*/
|
||||
if(ext->custom_drawer_cb) {
|
||||
if(btnm->custom_drawer_cb) {
|
||||
obj->state = btn_state;
|
||||
bool drawn = ext->custom_drawer_cb(obj, btn_i, &btn_area, clip_area);
|
||||
bool drawn = btnm->custom_drawer_cb(obj, btn_i, &btn_area, clip_area);
|
||||
obj->state = state_ori;
|
||||
if(drawn) continue;
|
||||
}
|
||||
@@ -693,8 +651,8 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * obj, const lv_area_t * cli
|
||||
obj->state = btn_state;
|
||||
lv_draw_rect_dsc_init(&draw_rect_tmp_dsc);
|
||||
lv_draw_label_dsc_init(&draw_label_tmp_dsc);
|
||||
lv_obj_init_draw_rect_dsc(obj, LV_PART_ITEM, &draw_rect_tmp_dsc);
|
||||
lv_obj_init_draw_label_dsc(obj, LV_PART_ITEM, &draw_label_tmp_dsc);
|
||||
lv_obj_init_draw_rect_dsc(obj, LV_PART_ITEMS, &draw_rect_tmp_dsc);
|
||||
lv_obj_init_draw_label_dsc(obj, LV_PART_ITEMS, &draw_label_tmp_dsc);
|
||||
draw_label_tmp_dsc.flag = txt_flag;
|
||||
draw_rect_dsc_act = &draw_rect_tmp_dsc;
|
||||
draw_label_dsc_act = &draw_label_tmp_dsc;
|
||||
@@ -720,7 +678,7 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * obj, const lv_area_t * cli
|
||||
const lv_font_t * font = draw_label_dsc_act->font;
|
||||
lv_coord_t letter_space = draw_label_dsc_act->letter_space;
|
||||
lv_coord_t line_space = draw_label_dsc_act->line_space;
|
||||
const char * txt = ext->map_p[txt_i];
|
||||
const char * txt = btnm->map_p[txt_i];
|
||||
|
||||
#if LV_USE_ARABIC_PERSIAN_CHARS
|
||||
/*Get the size of the Arabic text and process it*/
|
||||
@@ -770,21 +728,21 @@ static lv_res_t lv_btnmatrix_signal(lv_obj_t * obj, lv_signal_t sign, void * par
|
||||
res = lv_obj.signal_cb(obj, sign, param);
|
||||
if(res != LV_RES_OK) return res;
|
||||
|
||||
lv_btnmatrix_ext_t * ext = obj->ext_attr;;
|
||||
lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj;
|
||||
lv_point_t p;
|
||||
|
||||
if(sign == LV_SIGNAL_STYLE_CHG) {
|
||||
lv_btnmatrix_set_map(obj, ext->map_p);
|
||||
lv_btnmatrix_set_map(obj, btnm->map_p);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_COORD_CHG) {
|
||||
if(param &&
|
||||
(lv_obj_get_width(obj) != lv_area_get_width(param) || lv_obj_get_height(obj) != lv_area_get_height(param)))
|
||||
{
|
||||
lv_btnmatrix_set_map(obj, ext->map_p);
|
||||
lv_btnmatrix_set_map(obj, btnm->map_p);
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_PRESSED) {
|
||||
invalidate_button_area(obj, ext->btn_id_pr);
|
||||
invalidate_button_area(obj, btnm->btn_id_pr);
|
||||
|
||||
lv_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
||||
if(indev_type == LV_INDEV_TYPE_POINTER || indev_type == LV_INDEV_TYPE_BUTTON) {
|
||||
@@ -794,28 +752,28 @@ static lv_res_t lv_btnmatrix_signal(lv_obj_t * obj, lv_signal_t sign, void * par
|
||||
btn_pr = get_button_from_point(obj, &p);
|
||||
/*Handle the case where there is no button there*/
|
||||
if(btn_pr != LV_BTNMATRIX_BTN_NONE) {
|
||||
if(button_is_inactive(ext->ctrl_bits[btn_pr]) == false &&
|
||||
button_is_hidden(ext->ctrl_bits[btn_pr]) == false) {
|
||||
invalidate_button_area(obj, ext->btn_id_pr) /*Invalidate the old area*/;
|
||||
ext->btn_id_pr = btn_pr;
|
||||
ext->btn_id_act = btn_pr;
|
||||
invalidate_button_area(obj, ext->btn_id_pr); /*Invalidate the new area*/
|
||||
if(button_is_inactive(btnm->ctrl_bits[btn_pr]) == false &&
|
||||
button_is_hidden(btnm->ctrl_bits[btn_pr]) == false) {
|
||||
invalidate_button_area(obj, btnm->btn_id_pr) /*Invalidate the old area*/;
|
||||
btnm->btn_id_pr = btn_pr;
|
||||
btnm->btn_id_act = btn_pr;
|
||||
invalidate_button_area(obj, btnm->btn_id_pr); /*Invalidate the new area*/
|
||||
}
|
||||
}
|
||||
}
|
||||
#if LV_USE_GROUP
|
||||
else if(indev_type == LV_INDEV_TYPE_KEYPAD || (indev_type == LV_INDEV_TYPE_ENCODER &&
|
||||
lv_group_get_editing(lv_obj_get_group(obj)))) {
|
||||
ext->btn_id_pr = ext->btn_id_focused;
|
||||
invalidate_button_area(obj, ext->btn_id_focused);
|
||||
btnm->btn_id_pr = btnm->btn_id_focused;
|
||||
invalidate_button_area(obj, btnm->btn_id_focused);
|
||||
}
|
||||
#endif
|
||||
|
||||
if(ext->btn_id_pr != LV_BTNMATRIX_BTN_NONE) {
|
||||
if(button_is_click_trig(ext->ctrl_bits[ext->btn_id_pr]) == false &&
|
||||
button_is_inactive(ext->ctrl_bits[ext->btn_id_pr]) == false &&
|
||||
button_is_hidden(ext->ctrl_bits[ext->btn_id_pr]) == false) {
|
||||
uint32_t b = ext->btn_id_pr;
|
||||
if(btnm->btn_id_pr != LV_BTNMATRIX_BTN_NONE) {
|
||||
if(button_is_click_trig(btnm->ctrl_bits[btnm->btn_id_pr]) == false &&
|
||||
button_is_inactive(btnm->ctrl_bits[btnm->btn_id_pr]) == false &&
|
||||
button_is_hidden(btnm->ctrl_bits[btnm->btn_id_pr]) == false) {
|
||||
uint32_t b = btnm->btn_id_pr;
|
||||
res = lv_event_send(obj, LV_EVENT_VALUE_CHANGED, &b);
|
||||
}
|
||||
}
|
||||
@@ -830,21 +788,21 @@ static lv_res_t lv_btnmatrix_signal(lv_obj_t * obj, lv_signal_t sign, void * par
|
||||
lv_indev_get_point(indev, &p);
|
||||
btn_pr = get_button_from_point(obj, &p);
|
||||
/*Invalidate to old and the new areas*/
|
||||
if(btn_pr != ext->btn_id_pr) {
|
||||
if(ext->btn_id_pr != LV_BTNMATRIX_BTN_NONE) {
|
||||
invalidate_button_area(obj, ext->btn_id_pr);
|
||||
if(btn_pr != btnm->btn_id_pr) {
|
||||
if(btnm->btn_id_pr != LV_BTNMATRIX_BTN_NONE) {
|
||||
invalidate_button_area(obj, btnm->btn_id_pr);
|
||||
}
|
||||
|
||||
ext->btn_id_pr = btn_pr;
|
||||
ext->btn_id_act = btn_pr;
|
||||
btnm->btn_id_pr = btn_pr;
|
||||
btnm->btn_id_act = btn_pr;
|
||||
|
||||
lv_indev_reset_long_press(param); /*Start the log press time again on the new button*/
|
||||
if(btn_pr != LV_BTNMATRIX_BTN_NONE &&
|
||||
button_is_inactive(ext->ctrl_bits[btn_pr]) == false &&
|
||||
button_is_hidden(ext->ctrl_bits[btn_pr]) == false) {
|
||||
button_is_inactive(btnm->ctrl_bits[btn_pr]) == false &&
|
||||
button_is_hidden(btnm->ctrl_bits[btn_pr]) == false) {
|
||||
invalidate_button_area(obj, btn_pr);
|
||||
/* Send VALUE_CHANGED for the newly pressed button */
|
||||
if(button_is_click_trig(ext->ctrl_bits[btn_pr]) == false) {
|
||||
if(button_is_click_trig(btnm->ctrl_bits[btn_pr]) == false) {
|
||||
uint32_t b = btn_pr;
|
||||
lv_event_send(obj, LV_EVENT_VALUE_CHANGED, &b);
|
||||
}
|
||||
@@ -852,51 +810,51 @@ static lv_res_t lv_btnmatrix_signal(lv_obj_t * obj, lv_signal_t sign, void * par
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_RELEASED) {
|
||||
if(ext->btn_id_pr != LV_BTNMATRIX_BTN_NONE) {
|
||||
if(btnm->btn_id_pr != LV_BTNMATRIX_BTN_NONE) {
|
||||
/*Toggle the button if enabled*/
|
||||
if(button_is_tgl_enabled(ext->ctrl_bits[ext->btn_id_pr]) &&
|
||||
!button_is_inactive(ext->ctrl_bits[ext->btn_id_pr])) {
|
||||
if(button_get_checked(ext->ctrl_bits[ext->btn_id_pr]) && !ext->one_check) {
|
||||
ext->ctrl_bits[ext->btn_id_pr] &= (~LV_BTNMATRIX_CTRL_CHECKED);
|
||||
if(button_is_tgl_enabled(btnm->ctrl_bits[btnm->btn_id_pr]) &&
|
||||
!button_is_inactive(btnm->ctrl_bits[btnm->btn_id_pr])) {
|
||||
if(button_get_checked(btnm->ctrl_bits[btnm->btn_id_pr]) && !btnm->one_check) {
|
||||
btnm->ctrl_bits[btnm->btn_id_pr] &= (~LV_BTNMATRIX_CTRL_CHECKED);
|
||||
}
|
||||
else {
|
||||
ext->ctrl_bits[ext->btn_id_pr] |= LV_BTNMATRIX_CTRL_CHECKED;
|
||||
btnm->ctrl_bits[btnm->btn_id_pr] |= LV_BTNMATRIX_CTRL_CHECKED;
|
||||
}
|
||||
if(ext->one_check) make_one_button_checked(obj, ext->btn_id_pr);
|
||||
if(btnm->one_check) make_one_button_checked(obj, btnm->btn_id_pr);
|
||||
}
|
||||
|
||||
/*Invalidate to old pressed area*/;
|
||||
invalidate_button_area(obj, ext->btn_id_pr);
|
||||
invalidate_button_area(obj, ext->btn_id_focused);
|
||||
invalidate_button_area(obj, btnm->btn_id_pr);
|
||||
invalidate_button_area(obj, btnm->btn_id_focused);
|
||||
|
||||
lv_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
||||
if(indev_type == LV_INDEV_TYPE_KEYPAD || indev_type == LV_INDEV_TYPE_ENCODER) {
|
||||
ext->btn_id_focused = ext->btn_id_pr;
|
||||
btnm->btn_id_focused = btnm->btn_id_pr;
|
||||
}
|
||||
|
||||
ext->btn_id_pr = LV_BTNMATRIX_BTN_NONE;
|
||||
btnm->btn_id_pr = LV_BTNMATRIX_BTN_NONE;
|
||||
|
||||
if(button_is_click_trig(ext->ctrl_bits[ext->btn_id_act]) == true &&
|
||||
button_is_inactive(ext->ctrl_bits[ext->btn_id_act]) == false &&
|
||||
button_is_hidden(ext->ctrl_bits[ext->btn_id_act]) == false) {
|
||||
uint32_t b = ext->btn_id_act;
|
||||
if(button_is_click_trig(btnm->ctrl_bits[btnm->btn_id_act]) == true &&
|
||||
button_is_inactive(btnm->ctrl_bits[btnm->btn_id_act]) == false &&
|
||||
button_is_hidden(btnm->ctrl_bits[btnm->btn_id_act]) == false) {
|
||||
uint32_t b = btnm->btn_id_act;
|
||||
res = lv_event_send(obj, LV_EVENT_VALUE_CHANGED, &b);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_LONG_PRESS_REP) {
|
||||
if(ext->btn_id_act != LV_BTNMATRIX_BTN_NONE) {
|
||||
if(button_is_repeat_disabled(ext->ctrl_bits[ext->btn_id_act]) == false &&
|
||||
button_is_inactive(ext->ctrl_bits[ext->btn_id_act]) == false &&
|
||||
button_is_hidden(ext->ctrl_bits[ext->btn_id_act]) == false) {
|
||||
uint32_t b = ext->btn_id_act;
|
||||
if(btnm->btn_id_act != LV_BTNMATRIX_BTN_NONE) {
|
||||
if(button_is_repeat_disabled(btnm->ctrl_bits[btnm->btn_id_act]) == false &&
|
||||
button_is_inactive(btnm->ctrl_bits[btnm->btn_id_act]) == false &&
|
||||
button_is_hidden(btnm->ctrl_bits[btnm->btn_id_act]) == false) {
|
||||
uint32_t b = btnm->btn_id_act;
|
||||
res = lv_event_send(obj, LV_EVENT_VALUE_CHANGED, &b);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_PRESS_LOST) {
|
||||
ext->btn_id_pr = LV_BTNMATRIX_BTN_NONE;
|
||||
ext->btn_id_act = LV_BTNMATRIX_BTN_NONE;
|
||||
btnm->btn_id_pr = LV_BTNMATRIX_BTN_NONE;
|
||||
btnm->btn_id_act = LV_BTNMATRIX_BTN_NONE;
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_FOCUS) {
|
||||
@@ -914,110 +872,110 @@ static lv_res_t lv_btnmatrix_signal(lv_obj_t * obj, lv_signal_t sign, void * par
|
||||
/*In navigation mode don't select any button but in edit mode select the fist*/
|
||||
if(lv_group_get_editing(lv_obj_get_group(obj))) {
|
||||
uint32_t b = 0;
|
||||
while(button_is_hidden(ext->ctrl_bits[b]) || button_is_inactive(ext->ctrl_bits[b])) b++;
|
||||
ext->btn_id_focused = b;
|
||||
ext->btn_id_act = b;
|
||||
while(button_is_hidden(btnm->ctrl_bits[b]) || button_is_inactive(btnm->ctrl_bits[b])) b++;
|
||||
btnm->btn_id_focused = b;
|
||||
btnm->btn_id_act = b;
|
||||
}
|
||||
else {
|
||||
ext->btn_id_focused = LV_BTNMATRIX_BTN_NONE;
|
||||
btnm->btn_id_focused = LV_BTNMATRIX_BTN_NONE;
|
||||
}
|
||||
}
|
||||
else if(indev_type == LV_INDEV_TYPE_KEYPAD) {
|
||||
uint32_t b = 0;
|
||||
while(button_is_hidden(ext->ctrl_bits[b]) || button_is_inactive(ext->ctrl_bits[b])) {
|
||||
while(button_is_hidden(btnm->ctrl_bits[b]) || button_is_inactive(btnm->ctrl_bits[b])) {
|
||||
b++;
|
||||
}
|
||||
ext->btn_id_focused = b;
|
||||
ext->btn_id_act = b;
|
||||
btnm->btn_id_focused = b;
|
||||
btnm->btn_id_act = b;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
else if(sign == LV_SIGNAL_DEFOCUS || sign == LV_SIGNAL_LEAVE) {
|
||||
if(ext->btn_id_focused != LV_BTNMATRIX_BTN_NONE) invalidate_button_area(obj, ext->btn_id_focused);
|
||||
if(ext->btn_id_pr != LV_BTNMATRIX_BTN_NONE) invalidate_button_area(obj, ext->btn_id_pr);
|
||||
ext->btn_id_focused = LV_BTNMATRIX_BTN_NONE;
|
||||
ext->btn_id_pr = LV_BTNMATRIX_BTN_NONE;
|
||||
ext->btn_id_act = LV_BTNMATRIX_BTN_NONE;
|
||||
if(btnm->btn_id_focused != LV_BTNMATRIX_BTN_NONE) invalidate_button_area(obj, btnm->btn_id_focused);
|
||||
if(btnm->btn_id_pr != LV_BTNMATRIX_BTN_NONE) invalidate_button_area(obj, btnm->btn_id_pr);
|
||||
btnm->btn_id_focused = LV_BTNMATRIX_BTN_NONE;
|
||||
btnm->btn_id_pr = LV_BTNMATRIX_BTN_NONE;
|
||||
btnm->btn_id_act = LV_BTNMATRIX_BTN_NONE;
|
||||
}
|
||||
else if(sign == LV_SIGNAL_CONTROL) {
|
||||
#if LV_USE_GROUP
|
||||
char c = *((char *)param);
|
||||
if(c == LV_KEY_RIGHT) {
|
||||
if(ext->btn_id_focused == LV_BTNMATRIX_BTN_NONE) ext->btn_id_focused = 0;
|
||||
else ext->btn_id_focused++;
|
||||
if(ext->btn_id_focused >= ext->btn_cnt) ext->btn_id_focused = 0;
|
||||
if(btnm->btn_id_focused == LV_BTNMATRIX_BTN_NONE) btnm->btn_id_focused = 0;
|
||||
else btnm->btn_id_focused++;
|
||||
if(btnm->btn_id_focused >= btnm->btn_cnt) btnm->btn_id_focused = 0;
|
||||
|
||||
while(button_is_hidden(ext->ctrl_bits[ext->btn_id_focused]) || button_is_inactive(ext->ctrl_bits[ext->btn_id_focused])) {
|
||||
ext->btn_id_focused++;
|
||||
if(ext->btn_id_focused >= ext->btn_cnt) ext->btn_id_focused = 0;
|
||||
while(button_is_hidden(btnm->ctrl_bits[btnm->btn_id_focused]) || button_is_inactive(btnm->ctrl_bits[btnm->btn_id_focused])) {
|
||||
btnm->btn_id_focused++;
|
||||
if(btnm->btn_id_focused >= btnm->btn_cnt) btnm->btn_id_focused = 0;
|
||||
}
|
||||
|
||||
ext->btn_id_act = ext->btn_id_focused;
|
||||
btnm->btn_id_act = btnm->btn_id_focused;
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
else if(c == LV_KEY_LEFT) {
|
||||
if(ext->btn_id_focused == LV_BTNMATRIX_BTN_NONE) ext->btn_id_focused = 0;
|
||||
if(ext->btn_id_focused > 0) ext->btn_id_focused--;
|
||||
if(btnm->btn_id_focused == LV_BTNMATRIX_BTN_NONE) btnm->btn_id_focused = 0;
|
||||
if(btnm->btn_id_focused > 0) btnm->btn_id_focused--;
|
||||
|
||||
while(button_is_hidden(ext->ctrl_bits[ext->btn_id_focused]) || button_is_inactive(ext->ctrl_bits[ext->btn_id_focused])) {
|
||||
if(ext->btn_id_focused > 0) ext->btn_id_focused--;
|
||||
else ext->btn_id_focused = ext->btn_cnt - 1;
|
||||
while(button_is_hidden(btnm->ctrl_bits[btnm->btn_id_focused]) || button_is_inactive(btnm->ctrl_bits[btnm->btn_id_focused])) {
|
||||
if(btnm->btn_id_focused > 0) btnm->btn_id_focused--;
|
||||
else btnm->btn_id_focused = btnm->btn_cnt - 1;
|
||||
}
|
||||
|
||||
ext->btn_id_act = ext->btn_id_focused;
|
||||
btnm->btn_id_act = btnm->btn_id_focused;
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
else if(c == LV_KEY_DOWN) {
|
||||
lv_coord_t col_gap = LV_MATH_MAX(lv_obj_get_style_margin_left(obj, LV_BTNMATRIX_PART_BTN), lv_obj_get_style_margin_right(obj, LV_BTNMATRIX_PART_BTN));
|
||||
|
||||
/*Find the area below the the current*/
|
||||
if(ext->btn_id_focused == LV_BTNMATRIX_BTN_NONE) {
|
||||
ext->btn_id_focused = 0;
|
||||
if(btnm->btn_id_focused == LV_BTNMATRIX_BTN_NONE) {
|
||||
btnm->btn_id_focused = 0;
|
||||
}
|
||||
else {
|
||||
uint16_t area_below;
|
||||
lv_coord_t pr_center =
|
||||
ext->button_areas[ext->btn_id_focused].x1 + (lv_area_get_width(&ext->button_areas[ext->btn_id_focused]) >> 1);
|
||||
btnm->button_areas[btnm->btn_id_focused].x1 + (lv_area_get_width(&btnm->button_areas[btnm->btn_id_focused]) >> 1);
|
||||
|
||||
for(area_below = ext->btn_id_focused; area_below < ext->btn_cnt; area_below++) {
|
||||
if(ext->button_areas[area_below].y1 > ext->button_areas[ext->btn_id_focused].y1 &&
|
||||
pr_center >= ext->button_areas[area_below].x1 &&
|
||||
pr_center <= ext->button_areas[area_below].x2 + col_gap &&
|
||||
button_is_inactive(ext->ctrl_bits[area_below]) == false &&
|
||||
button_is_hidden(ext->ctrl_bits[area_below]) == false) {
|
||||
for(area_below = btnm->btn_id_focused; area_below < btnm->btn_cnt; area_below++) {
|
||||
if(btnm->button_areas[area_below].y1 > btnm->button_areas[btnm->btn_id_focused].y1 &&
|
||||
pr_center >= btnm->button_areas[area_below].x1 &&
|
||||
pr_center <= btnm->button_areas[area_below].x2 + col_gap &&
|
||||
button_is_inactive(btnm->ctrl_bits[area_below]) == false &&
|
||||
button_is_hidden(btnm->ctrl_bits[area_below]) == false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(area_below < ext->btn_cnt) ext->btn_id_focused = area_below;
|
||||
if(area_below < btnm->btn_cnt) btnm->btn_id_focused = area_below;
|
||||
}
|
||||
ext->btn_id_act = ext->btn_id_focused;
|
||||
btnm->btn_id_act = btnm->btn_id_focused;
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
else if(c == LV_KEY_UP) {
|
||||
lv_coord_t col_gap = LV_MATH_MAX(lv_obj_get_style_margin_left(obj, LV_BTNMATRIX_PART_BTN), lv_obj_get_style_margin_right(obj, LV_BTNMATRIX_PART_BTN));
|
||||
/*Find the area below the the current*/
|
||||
if(ext->btn_id_focused == LV_BTNMATRIX_BTN_NONE) {
|
||||
ext->btn_id_focused = 0;
|
||||
if(btnm->btn_id_focused == LV_BTNMATRIX_BTN_NONE) {
|
||||
btnm->btn_id_focused = 0;
|
||||
}
|
||||
else {
|
||||
int16_t area_above;
|
||||
lv_coord_t pr_center =
|
||||
ext->button_areas[ext->btn_id_focused].x1 + (lv_area_get_width(&ext->button_areas[ext->btn_id_focused]) >> 1);
|
||||
btnm->button_areas[btnm->btn_id_focused].x1 + (lv_area_get_width(&btnm->button_areas[btnm->btn_id_focused]) >> 1);
|
||||
|
||||
for(area_above = ext->btn_id_focused; area_above >= 0; area_above--) {
|
||||
if(ext->button_areas[area_above].y1 < ext->button_areas[ext->btn_id_focused].y1 &&
|
||||
pr_center >= ext->button_areas[area_above].x1 - col_gap &&
|
||||
pr_center <= ext->button_areas[area_above].x2 &&
|
||||
button_is_inactive(ext->ctrl_bits[area_above]) == false &&
|
||||
button_is_hidden(ext->ctrl_bits[area_above]) == false) {
|
||||
for(area_above = btnm->btn_id_focused; area_above >= 0; area_above--) {
|
||||
if(btnm->button_areas[area_above].y1 < btnm->button_areas[btnm->btn_id_focused].y1 &&
|
||||
pr_center >= btnm->button_areas[area_above].x1 - col_gap &&
|
||||
pr_center <= btnm->button_areas[area_above].x2 &&
|
||||
button_is_inactive(btnm->ctrl_bits[area_above]) == false &&
|
||||
button_is_hidden(btnm->ctrl_bits[area_above]) == false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(area_above >= 0) ext->btn_id_focused = area_above;
|
||||
if(area_above >= 0) btnm->btn_id_focused = area_above;
|
||||
}
|
||||
ext->btn_id_act = ext->btn_id_focused;
|
||||
btnm->btn_id_act = btnm->btn_id_focused;
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
#endif
|
||||
@@ -1048,30 +1006,30 @@ static void allocate_btn_areas_and_controls(const lv_obj_t * obj, const char **
|
||||
i++;
|
||||
}
|
||||
|
||||
lv_btnmatrix_ext_t * ext = obj->ext_attr;;
|
||||
lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj;;
|
||||
|
||||
/*Do not allocate memory for the same amount of buttons*/
|
||||
if(btn_cnt == ext->btn_cnt) return;
|
||||
if(btn_cnt == btnm->btn_cnt) return;
|
||||
|
||||
|
||||
if(ext->button_areas != NULL) {
|
||||
lv_mem_free(ext->button_areas);
|
||||
ext->button_areas = NULL;
|
||||
if(btnm->button_areas != NULL) {
|
||||
lv_mem_free(btnm->button_areas);
|
||||
btnm->button_areas = NULL;
|
||||
}
|
||||
if(ext->ctrl_bits != NULL) {
|
||||
lv_mem_free(ext->ctrl_bits);
|
||||
ext->ctrl_bits = NULL;
|
||||
if(btnm->ctrl_bits != NULL) {
|
||||
lv_mem_free(btnm->ctrl_bits);
|
||||
btnm->ctrl_bits = NULL;
|
||||
}
|
||||
|
||||
ext->button_areas = lv_mem_alloc(sizeof(lv_area_t) * btn_cnt);
|
||||
LV_ASSERT_MEM(ext->button_areas);
|
||||
ext->ctrl_bits = lv_mem_alloc(sizeof(lv_btnmatrix_ctrl_t) * btn_cnt);
|
||||
LV_ASSERT_MEM(ext->ctrl_bits);
|
||||
if(ext->button_areas == NULL || ext->ctrl_bits == NULL) btn_cnt = 0;
|
||||
btnm->button_areas = lv_mem_alloc(sizeof(lv_area_t) * btn_cnt);
|
||||
LV_ASSERT_MEM(btnm->button_areas);
|
||||
btnm->ctrl_bits = lv_mem_alloc(sizeof(lv_btnmatrix_ctrl_t) * btn_cnt);
|
||||
LV_ASSERT_MEM(btnm->ctrl_bits);
|
||||
if(btnm->button_areas == NULL || btnm->ctrl_bits == NULL) btn_cnt = 0;
|
||||
|
||||
_lv_memset_00(ext->ctrl_bits, sizeof(lv_btnmatrix_ctrl_t) * btn_cnt);
|
||||
_lv_memset_00(btnm->ctrl_bits, sizeof(lv_btnmatrix_ctrl_t) * btn_cnt);
|
||||
|
||||
ext->btn_cnt = btn_cnt;
|
||||
btnm->btn_cnt = btn_cnt;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1125,7 +1083,7 @@ static uint16_t get_button_from_point(lv_obj_t * obj, lv_point_t * p)
|
||||
{
|
||||
lv_area_t obj_cords;
|
||||
lv_area_t btn_area;
|
||||
lv_btnmatrix_ext_t * ext = obj->ext_attr;;
|
||||
lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj;;
|
||||
uint16_t i;
|
||||
lv_obj_get_coords(obj, &obj_cords);
|
||||
|
||||
@@ -1148,8 +1106,8 @@ static uint16_t get_button_from_point(lv_obj_t * obj, lv_point_t * p)
|
||||
ptop = LV_MATH_MIN(ptop, BTN_EXTRA_CLICK_AREA_MAX);
|
||||
pbottom = LV_MATH_MIN(pbottom, BTN_EXTRA_CLICK_AREA_MAX);
|
||||
|
||||
for(i = 0; i < ext->btn_cnt; i++) {
|
||||
lv_area_copy(&btn_area, &ext->button_areas[i]);
|
||||
for(i = 0; i < btnm->btn_cnt; i++) {
|
||||
lv_area_copy(&btn_area, &btnm->button_areas[i]);
|
||||
if(btn_area.x1 <= pleft) btn_area.x1 += obj_cords.x1 - LV_MATH_MIN(pleft, BTN_EXTRA_CLICK_AREA_MAX);
|
||||
else btn_area.x1 += obj_cords.x1 - pcol;
|
||||
|
||||
@@ -1169,7 +1127,7 @@ static uint16_t get_button_from_point(lv_obj_t * obj, lv_point_t * p)
|
||||
}
|
||||
}
|
||||
|
||||
if(i == ext->btn_cnt) i = LV_BTNMATRIX_BTN_NONE;
|
||||
if(i == btnm->btn_cnt) i = LV_BTNMATRIX_BTN_NONE;
|
||||
|
||||
return i;
|
||||
}
|
||||
@@ -1181,8 +1139,8 @@ static void invalidate_button_area(const lv_obj_t * obj, uint16_t btn_idx)
|
||||
lv_area_t btn_area;
|
||||
lv_area_t obj_area;
|
||||
|
||||
lv_btnmatrix_ext_t * ext = obj->ext_attr;;
|
||||
lv_area_copy(&btn_area, &ext->button_areas[btn_idx]);
|
||||
lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj;;
|
||||
lv_area_copy(&btn_area, &btnm->button_areas[btn_idx]);
|
||||
lv_obj_get_coords(obj, &obj_area);
|
||||
|
||||
/* Convert relative coordinates to absolute */
|
||||
|
||||
@@ -49,8 +49,7 @@ typedef bool (*lv_btnmatrix_btn_drawer_cb_t)(lv_obj_t * btnm, uint32_t btn_id, c
|
||||
|
||||
/*Data of button matrix*/
|
||||
typedef struct {
|
||||
/*No inherited ext.*/ /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
lv_obj_t obj;
|
||||
const char ** map_p; /*Pointer to the current map*/
|
||||
lv_area_t * button_areas; /*Array of areas of buttons*/
|
||||
lv_btnmatrix_ctrl_t * ctrl_bits; /*Array of control bytes*/
|
||||
@@ -61,8 +60,7 @@ typedef struct {
|
||||
uint16_t btn_id_act; /*Index of the active button (being pressed/released etc) or LV_BTNMATRIX_BTN_NONE */
|
||||
uint8_t recolor : 1; /*Enable button recoloring*/
|
||||
uint8_t one_check : 1; /*Single button toggled at once*/
|
||||
uint8_t align : 2; /*Align type from 'lv_label_align_t'*/
|
||||
} lv_btnmatrix_ext_t;
|
||||
} lv_btnmatrix_t;
|
||||
|
||||
|
||||
extern const lv_obj_class_t lv_btnmatrix;
|
||||
@@ -170,13 +168,6 @@ void lv_btnmatrix_set_btn_width(lv_obj_t * btnm, uint16_t btn_id, uint8_t width)
|
||||
*/
|
||||
void lv_btnmatrix_set_one_checked(lv_obj_t * btnm, bool one_chk);
|
||||
|
||||
/**
|
||||
* Set the align of the texts (left, right or center)
|
||||
* @param btnm pointer to a btnmatrix object
|
||||
* @param align LV_LABEL_ALIGN_LEFT, LV_LABEL_ALIGN_RIGHT or LV_LABEL_ALIGN_CENTER
|
||||
*/
|
||||
void lv_btnmatrix_set_text_align(lv_obj_t * btnm, lv_label_align_t align);
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
@@ -244,12 +235,6 @@ bool lv_btnmatrix_get_btn_ctrl(lv_obj_t * btnm, uint16_t btn_id, lv_btnmatrix_ct
|
||||
*/
|
||||
bool lv_btnmatrix_get_one_checked(const lv_obj_t * btnm);
|
||||
|
||||
/**
|
||||
* Get the align attribute
|
||||
* @param btnm pointer to a btnmatrix object
|
||||
* @return LV_LABEL_ALIGN_LEFT, LV_LABEL_ALIGN_RIGHT or LV_LABEL_ALIGN_CENTER
|
||||
*/
|
||||
lv_label_align_t lv_btnmatrix_get_align(const lv_obj_t * btnm);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
||||
@@ -766,11 +766,11 @@ void lv_canvas_draw_rect(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord
|
||||
* @param max_w max width of the text. The text will be wrapped to fit into this size
|
||||
* @param label_draw_dsc pointer to a valid label descriptor `lv_draw_label_dsc_t`
|
||||
* @param txt text to display
|
||||
* @param align align of the text (`LV_LABEL_ALIGN_LEFT/RIGHT/CENTER`)
|
||||
* @param align align of the text (`LV_TEXT_ALIGN_LEFT/RIGHT/CENTER`)
|
||||
*/
|
||||
void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t max_w,
|
||||
lv_draw_label_dsc_t * label_draw_dsc,
|
||||
const char * txt, lv_label_align_t align)
|
||||
const char * txt, lv_text_align_t align)
|
||||
{
|
||||
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
|
||||
|
||||
@@ -815,17 +815,17 @@ void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord
|
||||
|
||||
lv_txt_flag_t flag;
|
||||
switch(align) {
|
||||
case LV_LABEL_ALIGN_LEFT:
|
||||
flag = LV_TXT_FLAG_NONE;
|
||||
case LV_TEXT_ALIGN_LEFT:
|
||||
flag = LV_TEXT_FLAG_NONE;
|
||||
break;
|
||||
case LV_LABEL_ALIGN_RIGHT:
|
||||
flag = LV_TXT_FLAG_RIGHT;
|
||||
case LV_TEXT_ALIGN_RIGHT:
|
||||
flag = LV_TEXT_FLAG_RIGHT;
|
||||
break;
|
||||
case LV_LABEL_ALIGN_CENTER:
|
||||
flag = LV_TXT_FLAG_CENTER;
|
||||
case LV_TEXT_ALIGN_CENTER:
|
||||
flag = LV_TEXT_FLAG_CENTER;
|
||||
break;
|
||||
default:
|
||||
flag = LV_TXT_FLAG_NONE;
|
||||
flag = LV_TEXT_FLAG_NONE;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -194,11 +194,11 @@ void lv_canvas_draw_rect(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord
|
||||
* @param max_w max width of the text. The text will be wrapped to fit into this size
|
||||
* @param label_draw_dsc pointer to a valid label descriptor `lv_draw_label_dsc_t`
|
||||
* @param txt text to display
|
||||
* @param align align of the text (`LV_LABEL_ALIGN_LEFT/RIGHT/CENTER`)
|
||||
* @param align align of the text (`LV_TEXT_ALIGN_LEFT/RIGHT/CENTER`)
|
||||
*/
|
||||
void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t max_w,
|
||||
lv_draw_label_dsc_t * label_draw_dsc,
|
||||
const char * txt, lv_label_align_t align);
|
||||
const char * txt, lv_text_align_t align);
|
||||
|
||||
/**
|
||||
* Draw an image on the canvas
|
||||
|
||||
@@ -1596,7 +1596,7 @@ static void draw_y_ticks(lv_obj_t * obj, const lv_area_t * mask, uint8_t which_a
|
||||
/* reserve appropriate area */
|
||||
lv_point_t size;
|
||||
_lv_txt_get_size(&size, buf, label_dsc.font, label_dsc.letter_space, label_dsc.line_space,
|
||||
LV_COORD_MAX, LV_TXT_FLAG_CENTER);
|
||||
LV_COORD_MAX, LV_TEXT_FLAG_CENTER);
|
||||
|
||||
/* set the area at some distance of the major tick len left of the tick */
|
||||
/* changed to explicit member initialization to allow compilation as c++ */
|
||||
@@ -1710,7 +1710,7 @@ static void draw_x_ticks(lv_obj_t * obj, const lv_area_t * mask)
|
||||
/* reserve appropriate area */
|
||||
lv_point_t size;
|
||||
_lv_txt_get_size(&size, buf, label_dsc.font, label_dsc.letter_space, label_dsc.line_space,
|
||||
LV_COORD_MAX, LV_TXT_FLAG_CENTER);
|
||||
LV_COORD_MAX, LV_TEXT_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 + label_dist), (p2.x + size.x / 2),
|
||||
|
||||
@@ -27,14 +27,21 @@
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void lv_checkbox_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy);
|
||||
static void lv_checkbox_destructor(void * obj);
|
||||
static void lv_checkbox_destructor(lv_obj_t * obj);
|
||||
static lv_design_res_t lv_checkbox_design(lv_obj_t * obj, const lv_area_t * clip_area, lv_design_mode_t mode);
|
||||
static lv_res_t lv_checkbox_signal(lv_obj_t * obj, lv_signal_t sign, void * param);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
lv_checkbox_class_t lv_checkbox;
|
||||
const lv_obj_class_t lv_checkbox = {
|
||||
.constructor = lv_checkbox_constructor,
|
||||
.destructor = lv_checkbox_destructor,
|
||||
.signal_cb = lv_checkbox_signal,
|
||||
.design_cb = lv_checkbox_design,
|
||||
.instance_size = sizeof(lv_checkbox_t),
|
||||
.base_class = &lv_obj
|
||||
};
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@@ -52,23 +59,7 @@ lv_checkbox_class_t lv_checkbox;
|
||||
*/
|
||||
lv_obj_t * lv_checkbox_create(lv_obj_t * parent, const lv_obj_t * copy)
|
||||
{
|
||||
LV_LOG_TRACE("check box create started");
|
||||
|
||||
if(!lv_checkbox._inited) {
|
||||
LV_CLASS_INIT(lv_checkbox, lv_obj);
|
||||
lv_checkbox.constructor = lv_checkbox_constructor;
|
||||
lv_checkbox.destructor = lv_checkbox_destructor;
|
||||
lv_checkbox.design_cb = lv_checkbox_design;
|
||||
lv_checkbox.signal_cb = lv_checkbox_signal;
|
||||
}
|
||||
|
||||
lv_obj_t * obj = lv_class_new(&lv_checkbox);
|
||||
lv_checkbox.constructor(obj, parent, copy);
|
||||
|
||||
lv_obj_create_finish(obj, parent, copy);
|
||||
|
||||
LV_LOG_INFO("check box created");
|
||||
return obj;
|
||||
return lv_obj_create_from_class(&lv_checkbox, parent, copy);
|
||||
}
|
||||
|
||||
/*=====================
|
||||
@@ -145,7 +136,7 @@ static void lv_checkbox_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_
|
||||
LV_LOG_TRACE("lv_checkbox create started");
|
||||
|
||||
LV_CLASS_CONSTRUCTOR_BEGIN(obj, lv_checkbox)
|
||||
lv_checkbox.base_p->constructor(obj, parent, copy);
|
||||
lv_obj.constructor(obj, parent, copy);
|
||||
|
||||
lv_checkbox_t * cb = (lv_checkbox_t *) obj;
|
||||
/*Create the ancestor basic object*/
|
||||
@@ -159,7 +150,7 @@ static void lv_checkbox_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_
|
||||
lv_obj_set_size(obj, LV_SIZE_AUTO, LV_SIZE_AUTO);
|
||||
}
|
||||
else {
|
||||
const lv_checkbox_t * copy_ext = (const lv_checkbox_t *)copy;
|
||||
// const lv_checkbox_t * copy_ext = (const lv_checkbox_t *)copy;
|
||||
}
|
||||
|
||||
|
||||
@@ -167,7 +158,7 @@ static void lv_checkbox_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_
|
||||
LV_LOG_INFO("lv_checkbox created");
|
||||
}
|
||||
|
||||
static void lv_checkbox_destructor(void * obj)
|
||||
static void lv_checkbox_destructor(lv_obj_t * obj)
|
||||
{
|
||||
// lv_checkbox_t * bar = obj;
|
||||
//
|
||||
@@ -179,7 +170,7 @@ static void lv_checkbox_destructor(void * obj)
|
||||
|
||||
// bar->class_p->base_p->destructor(obj);
|
||||
}
|
||||
|
||||
int cnt = 0;
|
||||
/**
|
||||
* Handle the drawing related tasks of the check box
|
||||
* @param cb pointer to a check box object
|
||||
@@ -194,10 +185,10 @@ static lv_design_res_t lv_checkbox_design(lv_obj_t * obj, const lv_area_t * clip
|
||||
{
|
||||
/* A label never covers an area */
|
||||
if(mode == LV_DESIGN_COVER_CHK)
|
||||
return lv_checkbox.base_p->design_cb(obj, clip_area, mode);
|
||||
return lv_obj.design_cb(obj, clip_area, mode);
|
||||
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
/*Draw the background*/
|
||||
lv_checkbox.base_p->design_cb(obj, clip_area, mode);
|
||||
lv_obj.design_cb(obj, clip_area, mode);
|
||||
|
||||
lv_checkbox_t * cb = (lv_checkbox_t *) obj;
|
||||
|
||||
@@ -206,8 +197,7 @@ 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 marker_rightm = lv_obj_get_style_margin_right(obj, LV_PART_MARKER);
|
||||
lv_coord_t bg_colp = lv_obj_get_style_pad_column(obj, LV_PART_MAIN);
|
||||
|
||||
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);
|
||||
@@ -217,15 +207,24 @@ static lv_design_res_t lv_checkbox_design(lv_obj_t * obj, const lv_area_t * clip
|
||||
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);
|
||||
|
||||
if(tranf_h == 2) {
|
||||
lv_coord_t tranf_h2 = lv_obj_get_style_transform_height(obj, LV_PART_MARKER);
|
||||
}
|
||||
cnt++;
|
||||
if(cnt == 2) {
|
||||
cnt = 100;
|
||||
}
|
||||
|
||||
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.x1 = obj->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.y1 = obj->coords.y1 + bg_topp;
|
||||
marker_area.y2 = marker_area.y1 + font_h + marker_topp + marker_bottomp - 1;
|
||||
|
||||
printf("%d, %d\n", tranf_h, 0);
|
||||
lv_area_t marker_area_transf;
|
||||
lv_area_copy(&marker_area_transf, &marker_area);
|
||||
marker_area_transf.x1 -= tranf_w;
|
||||
@@ -238,7 +237,7 @@ static lv_design_res_t lv_checkbox_design(lv_obj_t * obj, const lv_area_t * clip
|
||||
lv_coord_t letter_space = lv_obj_get_style_text_letter_space(obj, LV_PART_MAIN);
|
||||
|
||||
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_txt_get_size(&txt_size, cb->txt, font, letter_space, line_space, LV_COORD_MAX, LV_TEXT_FLAG_NONE);
|
||||
|
||||
lv_draw_label_dsc_t txt_dsc;
|
||||
lv_draw_label_dsc_init(&txt_dsc);
|
||||
@@ -246,15 +245,15 @@ static lv_design_res_t lv_checkbox_design(lv_obj_t * obj, const lv_area_t * clip
|
||||
|
||||
lv_coord_t y_ofs = (lv_area_get_height(&marker_area) - font_h) / 2;
|
||||
lv_area_t txt_area;
|
||||
txt_area.x1 = marker_area.x2 + marker_rightm;
|
||||
txt_area.x1 = marker_area.x2 + bg_colp;
|
||||
txt_area.x2 = txt_area.x1 + txt_size.x;
|
||||
txt_area.y1 = cb->coords.y1 + bg_topp + y_ofs;
|
||||
txt_area.y1 = obj->coords.y1 + bg_topp + y_ofs;
|
||||
txt_area.y2 = txt_area.y1 + txt_size.y;
|
||||
|
||||
lv_draw_label(&txt_area, clip_area, &txt_dsc, cb->txt, NULL);
|
||||
|
||||
} else {
|
||||
lv_checkbox.base_p->design_cb(obj, clip_area, mode);
|
||||
lv_obj.design_cb(obj, clip_area, mode);
|
||||
}
|
||||
|
||||
return LV_DESIGN_RES_OK;
|
||||
@@ -270,7 +269,7 @@ static lv_res_t lv_checkbox_signal(lv_obj_t * obj, lv_signal_t sign, void * para
|
||||
{
|
||||
lv_res_t res;
|
||||
/* Include the ancient signal function */
|
||||
res = lv_checkbox.base_p->signal_cb(obj, sign, param);
|
||||
res = lv_obj.signal_cb(obj, sign, param);
|
||||
if(res != LV_RES_OK) return res;
|
||||
|
||||
if (sign == LV_SIGNAL_GET_SELF_SIZE) {
|
||||
@@ -283,19 +282,19 @@ static lv_res_t lv_checkbox_signal(lv_obj_t * obj, lv_signal_t sign, void * para
|
||||
lv_coord_t letter_space = lv_obj_get_style_text_letter_space(obj, LV_PART_MAIN);
|
||||
|
||||
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_txt_get_size(&txt_size, cb->txt, font, letter_space, line_space, LV_COORD_MAX, LV_TEXT_FLAG_NONE);
|
||||
|
||||
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 bg_colp = lv_obj_get_style_pad_column(obj, LV_PART_MAIN);
|
||||
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;
|
||||
marker_size.x = font_h + marker_leftp + marker_rightp;
|
||||
marker_size.y = font_h + marker_topp + marker_bottomp;
|
||||
|
||||
p->x = marker_size.x + txt_size.x;
|
||||
p->x = marker_size.x + txt_size.x + bg_colp;
|
||||
p->y = LV_MATH_MAX(marker_size.y, txt_size.y);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
|
||||
|
||||
@@ -18,11 +18,6 @@ extern "C" {
|
||||
|
||||
#if LV_USE_CHECKBOX != 0
|
||||
|
||||
/*Testing of dependencies*/
|
||||
#if LV_USE_LABEL == 0
|
||||
#error "lv_cb: lv_label is required. Enable it in lv_conf.h (LV_USE_LABEL 1) "
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
@@ -31,22 +26,13 @@ extern "C" {
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
|
||||
LV_CLASS_DECLARE_START(lv_checkbox, lv_obj);
|
||||
|
||||
#define _lv_checkbox_constructor void (*constructor)(struct _lv_obj_t * obj, struct _lv_obj_t * parent, const struct _lv_obj_t * copy)
|
||||
|
||||
#define _lv_checkbox_data \
|
||||
_lv_obj_data \
|
||||
char * txt; \
|
||||
typedef struct {
|
||||
lv_obj_t obj;
|
||||
char * txt;
|
||||
uint32_t static_txt :1;
|
||||
}lv_checkbox_t;
|
||||
|
||||
#define _lv_checkbox_class_dsc \
|
||||
_lv_obj_class_dsc
|
||||
|
||||
LV_CLASS_DECLARE_END(lv_checkbox, lv_obj);
|
||||
|
||||
extern lv_checkbox_class_t lv_checkbox;
|
||||
extern const lv_obj_class_t lv_checkbox;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
|
||||
@@ -567,7 +567,7 @@ void lv_dropdown_open(lv_obj_t * dropdown_obj)
|
||||
}
|
||||
}
|
||||
|
||||
if(lv_label_get_align(label) == LV_LABEL_ALIGN_RIGHT) {
|
||||
if(lv_label_get_align(label) == LV_TEXT_ALIGN_RIGHT) {
|
||||
lv_obj_set_x(label, lv_obj_get_width_fit(dropdown->list) - lv_obj_get_width(label));
|
||||
}
|
||||
}
|
||||
@@ -1042,10 +1042,10 @@ static void draw_box_label(lv_obj_t * dropdown_obj, const lv_area_t * clip_area,
|
||||
lv_obj_t * label = get_label(dropdown_obj);
|
||||
if(label == NULL) return;
|
||||
|
||||
lv_label_align_t align = lv_label_get_align(label);
|
||||
lv_text_align_t align = lv_label_get_align(label);
|
||||
|
||||
if(align == LV_LABEL_ALIGN_CENTER) label_dsc.flag |= LV_TXT_FLAG_CENTER;
|
||||
else if(align == LV_LABEL_ALIGN_RIGHT) label_dsc.flag |= LV_TXT_FLAG_RIGHT;
|
||||
if(align == LV_TEXT_ALIGN_CENTER) label_dsc.flag |= LV_TEXT_FLAG_CENTER;
|
||||
else if(align == LV_TEXT_ALIGN_RIGHT) label_dsc.flag |= LV_TEXT_FLAG_RIGHT;
|
||||
|
||||
lv_coord_t font_h = lv_font_get_line_height(label_dsc.font);
|
||||
|
||||
|
||||
@@ -549,7 +549,7 @@ static void lv_gauge_draw_labels(lv_obj_t * gauge, const lv_area_t * mask)
|
||||
lv_area_t label_cord;
|
||||
lv_point_t label_size;
|
||||
_lv_txt_get_size(&label_size, scale_txt, label_dsc.font, label_dsc.letter_space, label_dsc.line_space,
|
||||
LV_COORD_MAX, LV_TXT_FLAG_NONE);
|
||||
LV_COORD_MAX, LV_TEXT_FLAG_NONE);
|
||||
|
||||
/*Draw the label*/
|
||||
label_cord.x1 = x - label_size.x / 2;
|
||||
|
||||
@@ -206,7 +206,7 @@ void lv_img_set_src(lv_obj_t * img, const void * src_img)
|
||||
lv_coord_t line_space = lv_obj_get_style_text_line_space(img, LV_IMG_PART_MAIN);
|
||||
lv_point_t size;
|
||||
_lv_txt_get_size(&size, src_img, font, letter_space, line_space,
|
||||
LV_COORD_MAX, LV_TXT_FLAG_NONE);
|
||||
LV_COORD_MAX, LV_TEXT_FLAG_NONE);
|
||||
header.w = size.x;
|
||||
header.h = size.y;
|
||||
}
|
||||
|
||||
@@ -494,7 +494,7 @@ static void refr_img(lv_obj_t * imgbtn)
|
||||
if(lv_img_src_get_type(src) == LV_IMG_SRC_SYMBOL) {
|
||||
const lv_font_t * font = lv_obj_get_style_text_font(imgbtn, LV_IMGBTN_PART_MAIN);
|
||||
header.h = lv_font_get_line_height(font);
|
||||
header.w = _lv_txt_get_width(src, (uint16_t)strlen(src), font, 0, LV_TXT_FLAG_NONE);
|
||||
header.w = _lv_txt_get_width(src, (uint16_t)strlen(src), font, 0, LV_TEXT_FLAG_NONE);
|
||||
header.always_zero = 0;
|
||||
header.cf = LV_IMG_CF_ALPHA_1BIT;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -50,18 +50,8 @@ enum {
|
||||
};
|
||||
typedef uint8_t lv_label_long_mode_t;
|
||||
|
||||
/** Label align policy*/
|
||||
enum {
|
||||
LV_LABEL_ALIGN_LEFT, /**< Align text to left */
|
||||
LV_LABEL_ALIGN_CENTER, /**< Align text to center */
|
||||
LV_LABEL_ALIGN_RIGHT, /**< Align text to right */
|
||||
LV_LABEL_ALIGN_AUTO, /**< Use LEFT or RIGHT depending on the direction of the text (LTR/RTL)*/
|
||||
};
|
||||
typedef uint8_t lv_label_align_t;
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
lv_obj_t obj;
|
||||
char * text;
|
||||
union {
|
||||
char * tmp_ptr; /* Pointer to the allocated memory containing the character replaced by dots*/
|
||||
@@ -69,10 +59,6 @@ typedef struct {
|
||||
} dot;
|
||||
uint32_t dot_end; /*The real text length, used in dot mode*/
|
||||
|
||||
#if LV_USE_ANIMATION
|
||||
uint32_t anim_speed;
|
||||
#endif
|
||||
|
||||
#if LV_LABEL_LONG_TXT_HINT
|
||||
lv_draw_label_hint_t hint;
|
||||
#endif
|
||||
@@ -84,11 +70,10 @@ typedef struct {
|
||||
lv_point_t offset; /*Text draw position offset*/
|
||||
lv_label_long_mode_t long_mode : 3; /*Determinate what to do with the long texts*/
|
||||
uint8_t static_txt : 1; /*Flag to indicate the text is static*/
|
||||
uint8_t align : 2; /*Align type from 'lv_label_align_t'*/
|
||||
uint8_t recolor : 1; /*Enable in-line letter re-coloring*/
|
||||
uint8_t expand : 1; /*Ignore real width (used by the library with LV_LABEL_LONG_SROLL)*/
|
||||
uint8_t dot_tmp_alloc : 1; /*1: dot_tmp has been allocated;.0: dot_tmp directly holds up to 4 bytes of characters */
|
||||
}lv_label_ext_t;
|
||||
}lv_label_t;
|
||||
|
||||
extern const lv_obj_class_t lv_label;
|
||||
|
||||
@@ -140,13 +125,6 @@ void lv_label_set_text_static(lv_obj_t * label, const char * text);
|
||||
*/
|
||||
void lv_label_set_long_mode(lv_obj_t * label, lv_label_long_mode_t long_mode);
|
||||
|
||||
/**
|
||||
* Set the align of the label (left or center)
|
||||
* @param label pointer to a label object
|
||||
* @param align 'LV_LABEL_ALIGN_LEFT' or 'LV_LABEL_ALIGN_LEFT'
|
||||
*/
|
||||
void lv_label_set_align(lv_obj_t * label, lv_label_align_t align);
|
||||
|
||||
/**
|
||||
* Enable the recoloring by in-line commands
|
||||
* @param label pointer to a label object
|
||||
@@ -154,13 +132,6 @@ void lv_label_set_align(lv_obj_t * label, lv_label_align_t align);
|
||||
*/
|
||||
void lv_label_set_recolor(lv_obj_t * label, bool en);
|
||||
|
||||
/**
|
||||
* Set the label's animation speed in LV_LABEL_LONG_SROLL/SROLL_CIRC modes
|
||||
* @param label pointer to a label object
|
||||
* @param anim_speed speed of animation in px/sec unit
|
||||
*/
|
||||
void lv_label_set_anim_speed(lv_obj_t * label, uint16_t anim_speed);
|
||||
|
||||
/**
|
||||
* @brief Set the selection start index.
|
||||
* @param label pointer to a label object.
|
||||
@@ -196,9 +167,9 @@ lv_label_long_mode_t lv_label_get_long_mode(const lv_obj_t * label);
|
||||
/**
|
||||
* Get the align attribute
|
||||
* @param label pointer to a label object
|
||||
* @return LV_LABEL_ALIGN_LEFT or LV_LABEL_ALIGN_CENTER
|
||||
* @return LV_TEXT_ALIGN_LEFT or LV_TEXT_ALIGN_CENTER
|
||||
*/
|
||||
lv_label_align_t lv_label_get_align(const lv_obj_t * label);
|
||||
lv_text_align_t lv_label_get_align(const lv_obj_t * label);
|
||||
|
||||
/**
|
||||
* Get the recoloring attribute
|
||||
|
||||
@@ -150,9 +150,9 @@ void lv_roller_set_options(lv_obj_t * obj, const char * options, lv_roller_mode_
|
||||
/**
|
||||
* Set the align of the roller's options (left or center)
|
||||
* @param roller - pointer to a roller object
|
||||
* @param align - one of lv_label_align_t values (left, right, center)
|
||||
* @param align - one of lv_text_align_t values (left, right, center)
|
||||
*/
|
||||
void lv_roller_set_label_align(lv_obj_t * obj, lv_label_align_t align)
|
||||
void lv_roller_set_label_align(lv_obj_t * obj, lv_text_align_t align)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
@@ -317,11 +317,11 @@ uint16_t lv_roller_get_option_cnt(const lv_obj_t * obj)
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get the align attribute. Default alignment after _create is LV_LABEL_ALIGN_CENTER
|
||||
* Get the align attribute. Default alignment after _create is LV_TEXT_ALIGN_CENTER
|
||||
* @param roller pointer to a roller object
|
||||
* @return LV_LABEL_ALIGN_LEFT, LV_LABEL_ALIGN_RIGHT or LV_LABEL_ALIGN_CENTER
|
||||
* @return LV_TEXT_ALIGN_LEFT, LV_TEXT_ALIGN_RIGHT or LV_TEXT_ALIGN_CENTER
|
||||
*/
|
||||
lv_label_align_t lv_roller_get_label_align(const lv_obj_t * obj)
|
||||
lv_text_align_t lv_roller_get_label_align(const lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
@@ -366,7 +366,7 @@ static void lv_roller_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_ob
|
||||
lv_obj_set_width(obj, LV_SIZE_AUTO);
|
||||
|
||||
lv_obj_t * label = lv_roller_label_create(obj, NULL);
|
||||
lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
|
||||
lv_label_set_align(label, LV_TEXT_ALIGN_CENTER);
|
||||
lv_roller_set_options(obj, "Option 1\nOption 2\nOption 3\nOption 4\nOption 5", LV_ROLLER_MODE_NORMAL);
|
||||
lv_roller_set_visible_row_count(obj, 3);
|
||||
}
|
||||
@@ -476,19 +476,19 @@ static lv_design_res_t lv_roller_design(lv_obj_t * obj, const lv_area_t * clip_a
|
||||
area_ok = _lv_area_intersect(&mask_sel, clip_area, &rect_area);
|
||||
if(area_ok) {
|
||||
lv_obj_t * label = get_label(obj);
|
||||
lv_label_align_t label_align = lv_roller_get_label_align(obj);
|
||||
lv_text_align_t label_align = lv_roller_get_label_align(obj);
|
||||
|
||||
if(LV_LABEL_ALIGN_CENTER == label_align) {
|
||||
label_dsc.flag |= LV_TXT_FLAG_CENTER;
|
||||
if(LV_TEXT_ALIGN_CENTER == label_align) {
|
||||
label_dsc.flag |= LV_TEXT_FLAG_CENTER;
|
||||
}
|
||||
else if(LV_LABEL_ALIGN_RIGHT == label_align) {
|
||||
label_dsc.flag |= LV_TXT_FLAG_RIGHT;
|
||||
else if(LV_TEXT_ALIGN_RIGHT == label_align) {
|
||||
label_dsc.flag |= LV_TEXT_FLAG_RIGHT;
|
||||
}
|
||||
|
||||
/*Get the size of the "selected text"*/
|
||||
lv_point_t res_p;
|
||||
_lv_txt_get_size(&res_p, lv_label_get_text(label), label_dsc.font, label_dsc.letter_space, label_dsc.line_space,
|
||||
lv_obj_get_width(obj), LV_TXT_FLAG_EXPAND);
|
||||
lv_obj_get_width(obj), LV_TEXT_FLAG_EXPAND);
|
||||
|
||||
/*Move the selected label proportionally with the background label*/
|
||||
lv_coord_t roller_h = lv_obj_get_height(obj);
|
||||
@@ -514,7 +514,7 @@ static lv_design_res_t lv_roller_design(lv_obj_t * obj, const lv_area_t * clip_a
|
||||
label_sel_area.x2 = label->coords.x2;
|
||||
label_sel_area.y2 = label_sel_area.y1 + res_p.y;
|
||||
|
||||
label_dsc.flag |= LV_TXT_FLAG_EXPAND;
|
||||
label_dsc.flag |= LV_TEXT_FLAG_EXPAND;
|
||||
lv_draw_label(&label_sel_area, &mask_sel, &label_dsc, lv_label_get_text(label), NULL);
|
||||
}
|
||||
|
||||
@@ -734,15 +734,15 @@ static void refr_position(lv_obj_t * obj, lv_anim_enable_t anim_en)
|
||||
anim_en = LV_ANIM_OFF;
|
||||
#endif
|
||||
|
||||
lv_label_align_t align = lv_label_get_align(label);
|
||||
lv_text_align_t align = lv_label_get_align(label);
|
||||
switch(align) {
|
||||
case LV_LABEL_ALIGN_CENTER:
|
||||
case LV_TEXT_ALIGN_CENTER:
|
||||
lv_obj_set_x(label, (lv_obj_get_width_fit(obj) - lv_obj_get_width(label)) / 2);
|
||||
break;
|
||||
case LV_LABEL_ALIGN_RIGHT:
|
||||
case LV_TEXT_ALIGN_RIGHT:
|
||||
lv_obj_set_x(label, lv_obj_get_width_fit(obj) - lv_obj_get_width(label));
|
||||
break;
|
||||
case LV_LABEL_ALIGN_LEFT:
|
||||
case LV_TEXT_ALIGN_LEFT:
|
||||
lv_obj_set_x(label, 0);
|
||||
break;
|
||||
}
|
||||
@@ -915,7 +915,7 @@ static lv_coord_t get_selected_label_width(const lv_obj_t * obj)
|
||||
lv_coord_t letter_space = lv_obj_get_style_text_letter_space(obj, LV_PART_HIGHLIGHT);
|
||||
const char * txt = lv_label_get_text(label);
|
||||
lv_point_t size;
|
||||
_lv_txt_get_size(&size, txt, font, letter_space, 0, LV_COORD_MAX, LV_TXT_FLAG_NONE);
|
||||
_lv_txt_get_size(&size, txt, font, letter_space, 0, LV_COORD_MAX, LV_TEXT_FLAG_NONE);
|
||||
return size.x;
|
||||
}
|
||||
|
||||
|
||||
@@ -98,9 +98,9 @@ void lv_roller_set_options(lv_obj_t * roller, const char * options, lv_roller_mo
|
||||
/**
|
||||
* Set the align of the roller's options (left, right or center[default])
|
||||
* @param roller - pointer to a roller object
|
||||
* @param align - one of lv_label_align_t values (left, right, center)
|
||||
* @param align - one of lv_text_align_t values (left, right, center)
|
||||
*/
|
||||
void lv_roller_set_label_align(lv_obj_t * roller, lv_label_align_t align);
|
||||
void lv_roller_set_label_align(lv_obj_t * roller, lv_text_align_t align);
|
||||
|
||||
/**
|
||||
* Set the selected option
|
||||
@@ -150,11 +150,11 @@ uint16_t lv_roller_get_option_cnt(const lv_obj_t * roller);
|
||||
void lv_roller_get_selected_str(const lv_obj_t * roller, char * buf, uint32_t buf_size);
|
||||
|
||||
/**
|
||||
* Get the align attribute. Default alignment after _create is LV_LABEL_ALIGN_CENTER
|
||||
* Get the align attribute. Default alignment after _create is LV_TEXT_ALIGN_CENTER
|
||||
* @param roller pointer to a roller object
|
||||
* @return LV_LABEL_ALIGN_LEFT, LV_LABEL_ALIGN_RIGHT or LV_LABEL_ALIGN_CENTER
|
||||
* @return LV_TEXT_ALIGN_LEFT, LV_TEXT_ALIGN_RIGHT or LV_TEXT_ALIGN_CENTER
|
||||
*/
|
||||
lv_label_align_t lv_roller_get_label_align(const lv_obj_t * roller);
|
||||
lv_text_align_t lv_roller_get_label_align(const lv_obj_t * roller);
|
||||
|
||||
/**
|
||||
* Get the options of a roller
|
||||
|
||||
@@ -48,7 +48,8 @@ const lv_obj_class_t lv_slider = {
|
||||
.destructor = lv_slider_destructor,
|
||||
.signal_cb = lv_slider_signal,
|
||||
.design_cb = lv_slider_design,
|
||||
.ext_size = sizeof(lv_slider_ext_t),
|
||||
.instance_size = sizeof(lv_slider_t),
|
||||
.base_class = &lv_bar
|
||||
};
|
||||
|
||||
/**********************
|
||||
@@ -88,9 +89,9 @@ lv_obj_t * lv_slider_create(lv_obj_t * parent, const lv_obj_t * copy)
|
||||
bool lv_slider_is_dragged(const lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
lv_slider_ext_t * ext = obj->ext_attr;
|
||||
lv_slider_t * slider = (lv_slider_t *)obj;
|
||||
|
||||
return ext->dragging ? true : false;
|
||||
return slider->dragging ? true : false;
|
||||
}
|
||||
|
||||
/**********************
|
||||
@@ -103,12 +104,12 @@ static void lv_slider_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_ob
|
||||
|
||||
lv_bar.constructor(obj, parent, copy);
|
||||
|
||||
lv_slider_ext_t * ext = obj->ext_attr;
|
||||
lv_slider_t * slider = (lv_slider_t *)obj;
|
||||
|
||||
/*Initialize the allocated 'slider' */
|
||||
ext->value_to_set = NULL;
|
||||
ext->dragging = 0;
|
||||
ext->left_knob_focus = 0;
|
||||
slider->value_to_set = NULL;
|
||||
slider->dragging = 0;
|
||||
slider->left_knob_focus = 0;
|
||||
|
||||
/*Init the new slider slider*/
|
||||
if(copy == NULL) {
|
||||
@@ -117,9 +118,9 @@ static void lv_slider_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_ob
|
||||
lv_obj_set_ext_click_area(obj, lv_dpx(5), lv_dpx(5), lv_dpx(5), lv_dpx(5));
|
||||
lv_obj_set_height(obj, LV_DPI / 15);
|
||||
} else {
|
||||
lv_slider_ext_t * copy_ext = copy->ext_attr;
|
||||
lv_area_copy(&ext->left_knob_area, ©_ext->left_knob_area);
|
||||
lv_area_copy(&ext->right_knob_area, ©_ext->right_knob_area);
|
||||
lv_slider_t * copy_slider = (lv_slider_t * ) copy;
|
||||
lv_area_copy(&slider->left_knob_area, ©_slider->left_knob_area);
|
||||
lv_area_copy(&slider->right_knob_area, ©_slider->right_knob_area);
|
||||
}
|
||||
|
||||
LV_CLASS_CONSTRUCTOR_END(obj, lv_slider)
|
||||
@@ -131,7 +132,7 @@ static void lv_slider_destructor(lv_obj_t * obj)
|
||||
//
|
||||
// _lv_obj_reset_style_list_no_refr(obj, LV_PART_KNOB);
|
||||
//
|
||||
// ext->class_p->base_p->destructor(obj);
|
||||
// slider->class_p->base_p->destructor(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,10 +154,10 @@ static lv_design_res_t lv_slider_design(lv_obj_t * obj, const lv_area_t * clip_a
|
||||
/*Draw the object*/
|
||||
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
/* The ancestor design function will draw the background and the indicator.
|
||||
* It also sets ext->bar.indic_area*/
|
||||
* It also sets slider->bar.indic_area*/
|
||||
lv_bar.design_cb(obj, clip_area, mode);
|
||||
|
||||
lv_slider_ext_t * ext = obj->ext_attr;
|
||||
lv_slider_t * slider = (lv_slider_t *)obj;
|
||||
lv_bidi_dir_t base_dir = lv_obj_get_base_dir(obj);
|
||||
|
||||
lv_coord_t objw = lv_obj_get_width(obj);
|
||||
@@ -164,54 +165,54 @@ static lv_design_res_t lv_slider_design(lv_obj_t * obj, const lv_area_t * clip_a
|
||||
bool hor = objw >= objh ? true : false;
|
||||
lv_coord_t knob_size = hor ? objh : objw;
|
||||
bool sym = false;
|
||||
if(ext->bar.type == LV_BAR_TYPE_SYMMETRICAL && ext->bar.min_value < 0 && ext->bar.max_value > 0) sym = true;
|
||||
if(slider->bar.type == LV_BAR_TYPE_SYMMETRICAL && slider->bar.min_value < 0 && slider->bar.max_value > 0) sym = true;
|
||||
|
||||
lv_area_t knob_area;
|
||||
|
||||
/*Horizontal*/
|
||||
if(hor) {
|
||||
if(!sym) {
|
||||
knob_area.x1 = LV_SLIDER_KNOB_COORD(hor, base_dir == LV_BIDI_DIR_RTL, ext->bar.indic_area);
|
||||
knob_area.x1 = LV_SLIDER_KNOB_COORD(hor, base_dir == LV_BIDI_DIR_RTL, slider->bar.indic_area);
|
||||
}
|
||||
else {
|
||||
if(ext->bar.cur_value >= 0) {
|
||||
knob_area.x1 = LV_SLIDER_KNOB_COORD(hor, base_dir == LV_BIDI_DIR_RTL, ext->bar.indic_area);
|
||||
if(slider->bar.cur_value >= 0) {
|
||||
knob_area.x1 = LV_SLIDER_KNOB_COORD(hor, base_dir == LV_BIDI_DIR_RTL, slider->bar.indic_area);
|
||||
}
|
||||
else {
|
||||
knob_area.x1 = LV_SLIDER_KNOB_COORD(hor, base_dir != LV_BIDI_DIR_RTL, ext->bar.indic_area);
|
||||
knob_area.x1 = LV_SLIDER_KNOB_COORD(hor, base_dir != LV_BIDI_DIR_RTL, slider->bar.indic_area);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*Vertical*/
|
||||
else {
|
||||
if(!sym) {
|
||||
knob_area.y1 = ext->bar.indic_area.y1;
|
||||
knob_area.y1 = slider->bar.indic_area.y1;
|
||||
}
|
||||
else {
|
||||
if(ext->bar.cur_value >= 0) {
|
||||
knob_area.y1 = ext->bar.indic_area.y1;
|
||||
if(slider->bar.cur_value >= 0) {
|
||||
knob_area.y1 = slider->bar.indic_area.y1;
|
||||
}
|
||||
else {
|
||||
knob_area.y1 = ext->bar.indic_area.y2;
|
||||
knob_area.y1 = slider->bar.indic_area.y2;
|
||||
}
|
||||
}
|
||||
}
|
||||
lv_slider_position_knob(obj, &knob_area, knob_size, hor);
|
||||
|
||||
lv_area_copy(&ext->right_knob_area, &knob_area);
|
||||
lv_area_copy(&slider->right_knob_area, &knob_area);
|
||||
lv_slider_draw_knob(obj, &knob_area, clip_area);
|
||||
|
||||
if(lv_slider_get_type(obj) == LV_SLIDER_TYPE_RANGE) {
|
||||
/* Draw a second knob for the start_value side */
|
||||
if(hor) {
|
||||
knob_area.x1 = LV_SLIDER_KNOB_COORD(hor, base_dir != LV_BIDI_DIR_RTL, ext->bar.indic_area);
|
||||
knob_area.x1 = LV_SLIDER_KNOB_COORD(hor, base_dir != LV_BIDI_DIR_RTL, slider->bar.indic_area);
|
||||
}
|
||||
else {
|
||||
knob_area.y1 = ext->bar.indic_area.y2;
|
||||
knob_area.y1 = slider->bar.indic_area.y2;
|
||||
}
|
||||
lv_slider_position_knob(obj, &knob_area, knob_size, hor);
|
||||
|
||||
lv_area_copy(&ext->left_knob_area, &knob_area);
|
||||
lv_area_copy(&slider->left_knob_area, &knob_area);
|
||||
lv_slider_draw_knob(obj, &knob_area, clip_area);
|
||||
}
|
||||
}
|
||||
@@ -238,7 +239,7 @@ static lv_res_t lv_slider_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
||||
res = lv_bar.signal_cb(obj, sign, param);
|
||||
if(res != LV_RES_OK) return res;
|
||||
|
||||
lv_slider_ext_t * ext = obj->ext_attr;
|
||||
lv_slider_t * slider = (lv_slider_t *)obj;
|
||||
lv_slider_type_t type = lv_slider_get_type(obj);
|
||||
|
||||
/* Advanced hit testing: react only on dragging the knob(s) */
|
||||
@@ -246,20 +247,20 @@ static lv_res_t lv_slider_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
||||
lv_hit_test_info_t * info = param;
|
||||
|
||||
/* Ordinary slider: was the knob area hit? */
|
||||
info->result = _lv_area_is_point_on(&ext->right_knob_area, info->point, 0);
|
||||
info->result = _lv_area_is_point_on(&slider->right_knob_area, info->point, 0);
|
||||
|
||||
/* There's still a change we have a hit, if we have another knob */
|
||||
if((info->result == false) && (type == LV_SLIDER_TYPE_RANGE)) {
|
||||
info->result = _lv_area_is_point_on(&ext->left_knob_area, info->point, 0);
|
||||
info->result = _lv_area_is_point_on(&slider->left_knob_area, info->point, 0);
|
||||
}
|
||||
}
|
||||
|
||||
lv_point_t p;
|
||||
|
||||
if(sign == LV_SIGNAL_PRESSED) {
|
||||
ext->dragging = true;
|
||||
slider->dragging = true;
|
||||
if(type == LV_SLIDER_TYPE_NORMAL || type == LV_SLIDER_TYPE_SYMMETRICAL) {
|
||||
ext->value_to_set = &ext->bar.cur_value;
|
||||
slider->value_to_set = &slider->bar.cur_value;
|
||||
}
|
||||
else if(type == LV_SLIDER_TYPE_RANGE) {
|
||||
lv_indev_get_point(param, &p);
|
||||
@@ -268,44 +269,44 @@ static lv_res_t lv_slider_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
||||
|
||||
lv_coord_t dist_left, dist_right;
|
||||
if(hor) {
|
||||
if((base_dir != LV_BIDI_DIR_RTL && p.x > ext->right_knob_area.x2) || (base_dir == LV_BIDI_DIR_RTL &&
|
||||
p.x < ext->right_knob_area.x1)) {
|
||||
ext->value_to_set = &ext->bar.cur_value;
|
||||
if((base_dir != LV_BIDI_DIR_RTL && p.x > slider->right_knob_area.x2) || (base_dir == LV_BIDI_DIR_RTL &&
|
||||
p.x < slider->right_knob_area.x1)) {
|
||||
slider->value_to_set = &slider->bar.cur_value;
|
||||
}
|
||||
else if((base_dir != LV_BIDI_DIR_RTL && p.x < ext->left_knob_area.x1) || (base_dir == LV_BIDI_DIR_RTL &&
|
||||
p.x > ext->left_knob_area.x2)) {
|
||||
ext->value_to_set = &ext->bar.start_value;
|
||||
else if((base_dir != LV_BIDI_DIR_RTL && p.x < slider->left_knob_area.x1) || (base_dir == LV_BIDI_DIR_RTL &&
|
||||
p.x > slider->left_knob_area.x2)) {
|
||||
slider->value_to_set = &slider->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);
|
||||
dist_left = LV_MATH_ABS((slider->left_knob_area.x1 + (slider->left_knob_area.x2 - slider->left_knob_area.x1) / 2) - p.x);
|
||||
dist_right = LV_MATH_ABS((slider->right_knob_area.x1 + (slider->right_knob_area.x2 - slider->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;
|
||||
if(dist_right < dist_left)slider->value_to_set = &slider->bar.cur_value;
|
||||
else slider->value_to_set = &slider->bar.start_value;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(p.y < ext->right_knob_area.y1) {
|
||||
ext->value_to_set = &ext->bar.cur_value;
|
||||
if(p.y < slider->right_knob_area.y1) {
|
||||
slider->value_to_set = &slider->bar.cur_value;
|
||||
}
|
||||
else if(p.y > ext->left_knob_area.y2) {
|
||||
ext->value_to_set = &ext->bar.start_value;
|
||||
else if(p.y > slider->left_knob_area.y2) {
|
||||
slider->value_to_set = &slider->bar.start_value;
|
||||
}
|
||||
else {
|
||||
/* Calculate the distance from each knob */
|
||||
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);
|
||||
dist_left = LV_MATH_ABS((slider->left_knob_area.y1 + (slider->left_knob_area.y2 - slider->left_knob_area.y1) / 2) - p.y);
|
||||
dist_right = LV_MATH_ABS((slider->right_knob_area.y1 + (slider->right_knob_area.y2 - slider->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;
|
||||
if(dist_right < dist_left)slider->value_to_set = &slider->bar.cur_value;
|
||||
else slider->value_to_set = &slider->bar.start_value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_PRESSING && ext->value_to_set != NULL) {
|
||||
else if(sign == LV_SIGNAL_PRESSING && slider->value_to_set != NULL) {
|
||||
if(lv_indev_get_type(param) != LV_INDEV_TYPE_POINTER) return res;
|
||||
|
||||
lv_indev_get_point(param, &p);
|
||||
@@ -319,10 +320,10 @@ static lv_res_t lv_slider_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
||||
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);
|
||||
|
||||
int32_t range = ext->bar.max_value - ext->bar.min_value;
|
||||
int32_t range = slider->bar.max_value - slider->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;
|
||||
int16_t real_max_value = slider->bar.max_value;
|
||||
int16_t real_min_value = slider->bar.min_value;
|
||||
|
||||
if(w >= h) {
|
||||
lv_coord_t indic_w = w - bg_left - bg_right;
|
||||
@@ -333,28 +334,28 @@ static lv_res_t lv_slider_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
||||
new_value = p.x - (obj->coords.x1 + bg_left); /*Make the point relative to the indicator*/
|
||||
}
|
||||
new_value = (new_value * range) / indic_w;
|
||||
new_value += ext->bar.min_value;
|
||||
new_value += slider->bar.min_value;
|
||||
}
|
||||
else {
|
||||
lv_coord_t indic_h = h - bg_bottom - bg_top;
|
||||
new_value = p.y - (obj->coords.y2 + bg_bottom); /*Make the point relative to the indicator*/
|
||||
new_value = (-new_value * range) / indic_h;
|
||||
new_value += ext->bar.min_value;
|
||||
new_value += slider->bar.min_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;
|
||||
if(slider->value_to_set == &slider->bar.start_value) {
|
||||
real_max_value = slider->bar.cur_value;
|
||||
}
|
||||
else {
|
||||
real_min_value = ext->bar.start_value;
|
||||
real_min_value = slider->bar.start_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(*ext->value_to_set != new_value) {
|
||||
*ext->value_to_set = new_value;
|
||||
if(*slider->value_to_set != new_value) {
|
||||
*slider->value_to_set = new_value;
|
||||
lv_obj_invalidate(obj);
|
||||
res = lv_event_send(obj, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
if(res != LV_RES_OK) return res;
|
||||
@@ -362,8 +363,8 @@ static lv_res_t lv_slider_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
||||
|
||||
}
|
||||
else if(sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_PRESS_LOST) {
|
||||
ext->dragging = false;
|
||||
ext->value_to_set = NULL;
|
||||
slider->dragging = false;
|
||||
slider->value_to_set = NULL;
|
||||
|
||||
#if LV_USE_GROUP
|
||||
/*Leave edit mode if released. (No need to wait for LONG_PRESS) */
|
||||
@@ -373,9 +374,9 @@ static lv_res_t lv_slider_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
||||
if(indev_type == LV_INDEV_TYPE_ENCODER) {
|
||||
if(editing) {
|
||||
if(lv_slider_get_type(slider) == LV_SLIDER_TYPE_RANGE) {
|
||||
if(ext->left_knob_focus == 0) ext->left_knob_focus = 1;
|
||||
if(slider->left_knob_focus == 0) slider->left_knob_focus = 1;
|
||||
else {
|
||||
ext->left_knob_focus = 0;
|
||||
slider->left_knob_focus = 0;
|
||||
lv_group_set_editing(g, false);
|
||||
}
|
||||
}
|
||||
@@ -388,7 +389,7 @@ static lv_res_t lv_slider_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
||||
|
||||
}
|
||||
else if(sign == LV_SIGNAL_FOCUS) {
|
||||
ext->left_knob_focus = 0;
|
||||
slider->left_knob_focus = 0;
|
||||
}
|
||||
else if(sign == LV_SIGNAL_COORD_CHG) {
|
||||
/* The knob size depends on slider size.
|
||||
@@ -423,14 +424,14 @@ static lv_res_t lv_slider_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
||||
char c = *((char *)param);
|
||||
|
||||
if(c == LV_KEY_RIGHT || c == LV_KEY_UP) {
|
||||
if(!ext->left_knob_focus) lv_slider_set_value(slider, lv_slider_get_value(slider) + 1, LV_ANIM_ON);
|
||||
if(!slider->left_knob_focus) lv_slider_set_value(slider, lv_slider_get_value(slider) + 1, LV_ANIM_ON);
|
||||
else lv_slider_set_left_value(slider, lv_slider_get_left_value(slider) + 1, LV_ANIM_ON);
|
||||
|
||||
res = lv_event_send(slider, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
if(res != LV_RES_OK) return res;
|
||||
}
|
||||
else if(c == LV_KEY_LEFT || c == LV_KEY_DOWN) {
|
||||
if(!ext->left_knob_focus) lv_slider_set_value(slider, lv_slider_get_value(slider) - 1, LV_ANIM_ON);
|
||||
if(!slider->left_knob_focus) lv_slider_set_value(slider, lv_slider_get_value(slider) - 1, LV_ANIM_ON);
|
||||
else lv_slider_set_left_value(slider, lv_slider_get_left_value(slider) - 1, LV_ANIM_ON);
|
||||
|
||||
res = lv_event_send(slider, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
|
||||
@@ -41,13 +41,13 @@ enum {
|
||||
typedef uint8_t lv_slider_type_t;
|
||||
|
||||
typedef struct {
|
||||
lv_bar_ext_t bar; /*Add the ancestor's type first*/
|
||||
lv_bar_t bar; /*Add the ancestor's type first*/
|
||||
lv_area_t left_knob_area;
|
||||
lv_area_t right_knob_area;
|
||||
int16_t * value_to_set; /* Which bar value to set */
|
||||
uint8_t dragging : 1; /*1: the slider is being dragged*/
|
||||
uint8_t left_knob_focus : 1; /*1: with encoder now the right knob can be adjusted*/
|
||||
}lv_slider_ext_t;
|
||||
}lv_slider_t;
|
||||
|
||||
extern const lv_obj_class_t lv_slider;
|
||||
|
||||
@@ -101,16 +101,6 @@ static inline void lv_slider_set_range(lv_obj_t * slider, int16_t min, int16_t m
|
||||
lv_bar_set_range(slider, min, max);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the animation time of the slider
|
||||
* @param slider pointer to a bar object
|
||||
* @param anim_time the animation time in milliseconds.
|
||||
*/
|
||||
static inline void lv_slider_set_anim_time(lv_obj_t * slider, uint16_t anim_time)
|
||||
{
|
||||
lv_bar_set_anim_time(slider, anim_time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make the slider symmetric to zero. The indicator will grow from zero instead of the minimum
|
||||
* position.
|
||||
@@ -178,15 +168,6 @@ static inline int16_t lv_slider_get_max_value(const lv_obj_t * slider)
|
||||
*/
|
||||
bool lv_slider_is_dragged(const lv_obj_t * slider);
|
||||
|
||||
/**
|
||||
* Get the animation time of the slider
|
||||
* @param slider pointer to a slider object
|
||||
* @return the animation time in milliseconds.
|
||||
*/
|
||||
static inline uint16_t lv_slider_get_anim_time(lv_obj_t * slider)
|
||||
{
|
||||
return lv_bar_get_anim_time(slider);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether the slider is symmetric or not.
|
||||
@@ -196,12 +177,9 @@ static inline uint16_t lv_slider_get_anim_time(lv_obj_t * slider)
|
||||
static inline lv_slider_type_t lv_slider_get_type(lv_obj_t * slider)
|
||||
{
|
||||
lv_bar_type_t type = lv_bar_get_type(slider);
|
||||
if(type == LV_BAR_TYPE_SYMMETRICAL)
|
||||
return LV_SLIDER_TYPE_SYMMETRICAL;
|
||||
else if(type == LV_BAR_TYPE_CUSTOM)
|
||||
return LV_SLIDER_TYPE_RANGE;
|
||||
else
|
||||
return LV_SLIDER_TYPE_NORMAL;
|
||||
if(type == LV_BAR_TYPE_SYMMETRICAL) return LV_SLIDER_TYPE_SYMMETRICAL;
|
||||
else if(type == LV_BAR_TYPE_CUSTOM)return LV_SLIDER_TYPE_RANGE;
|
||||
else return LV_SLIDER_TYPE_NORMAL;
|
||||
}
|
||||
|
||||
/**********************
|
||||
|
||||
@@ -101,13 +101,13 @@ void lv_table_set_cell_value(lv_obj_t * table, uint16_t row, uint16_t col, const
|
||||
/*Initialize the format byte*/
|
||||
else {
|
||||
lv_bidi_dir_t base_dir = lv_obj_get_base_dir(table);
|
||||
if(base_dir == LV_BIDI_DIR_LTR) format.s.align = LV_LABEL_ALIGN_LEFT;
|
||||
else if(base_dir == LV_BIDI_DIR_RTL) format.s.align = LV_LABEL_ALIGN_RIGHT;
|
||||
if(base_dir == LV_BIDI_DIR_LTR) format.s.align = LV_TEXT_ALIGN_LEFT;
|
||||
else if(base_dir == LV_BIDI_DIR_RTL) format.s.align = LV_TEXT_ALIGN_RIGHT;
|
||||
else if(base_dir == LV_BIDI_DIR_AUTO)
|
||||
#if LV_USE_BIDI
|
||||
format.s.align = _lv_bidi_detect_base_dir(txt);
|
||||
#else
|
||||
format.s.align = LV_LABEL_ALIGN_LEFT;
|
||||
format.s.align = LV_TEXT_ALIGN_LEFT;
|
||||
#endif
|
||||
format.s.right_merge = 0;
|
||||
format.s.crop = 0;
|
||||
@@ -167,13 +167,13 @@ void lv_table_set_cell_value_fmt(lv_obj_t * table, uint16_t row, uint16_t col, c
|
||||
/*Initialize the format byte*/
|
||||
else {
|
||||
lv_bidi_dir_t base_dir = lv_obj_get_base_dir(table);
|
||||
if(base_dir == LV_BIDI_DIR_LTR) format.s.align = LV_LABEL_ALIGN_LEFT;
|
||||
else if(base_dir == LV_BIDI_DIR_RTL) format.s.align = LV_LABEL_ALIGN_RIGHT;
|
||||
if(base_dir == LV_BIDI_DIR_LTR) format.s.align = LV_TEXT_ALIGN_LEFT;
|
||||
else if(base_dir == LV_BIDI_DIR_RTL) format.s.align = LV_TEXT_ALIGN_RIGHT;
|
||||
else if(base_dir == LV_BIDI_DIR_AUTO)
|
||||
#if LV_USE_BIDI
|
||||
format.s.align = _lv_bidi_detect_base_dir(fmt);
|
||||
#else
|
||||
format.s.align = LV_LABEL_ALIGN_LEFT;
|
||||
format.s.align = LV_TEXT_ALIGN_LEFT;
|
||||
#endif
|
||||
format.s.right_merge = 0;
|
||||
format.s.crop = 0;
|
||||
@@ -318,9 +318,9 @@ void lv_table_set_col_width(lv_obj_t * table, uint16_t col_id, lv_coord_t w)
|
||||
* @param table pointer to a Table object
|
||||
* @param row id of the row [0 .. row_cnt -1]
|
||||
* @param col id of the column [0 .. col_cnt -1]
|
||||
* @param align LV_LABEL_ALIGN_LEFT or LV_LABEL_ALIGN_CENTER or LV_LABEL_ALIGN_RIGHT
|
||||
* @param align LV_TEXT_ALIGN_LEFT or LV_TEXT_ALIGN_CENTER or LV_TEXT_ALIGN_RIGHT
|
||||
*/
|
||||
void lv_table_set_cell_align(lv_obj_t * table, uint16_t row, uint16_t col, lv_label_align_t align)
|
||||
void lv_table_set_cell_align(lv_obj_t * table, uint16_t row, uint16_t col, lv_text_align_t align)
|
||||
{
|
||||
LV_ASSERT_OBJ(table, LV_OBJX_NAME);
|
||||
|
||||
@@ -503,22 +503,22 @@ lv_coord_t lv_table_get_col_width(lv_obj_t * table, uint16_t col_id)
|
||||
* @param table pointer to a Table object
|
||||
* @param row id of the row [0 .. row_cnt -1]
|
||||
* @param col id of the column [0 .. col_cnt -1]
|
||||
* @return LV_LABEL_ALIGN_LEFT (default in case of error) or LV_LABEL_ALIGN_CENTER or
|
||||
* LV_LABEL_ALIGN_RIGHT
|
||||
* @return LV_TEXT_ALIGN_LEFT (default in case of error) or LV_TEXT_ALIGN_CENTER or
|
||||
* LV_TEXT_ALIGN_RIGHT
|
||||
*/
|
||||
lv_label_align_t lv_table_get_cell_align(lv_obj_t * table, uint16_t row, uint16_t col)
|
||||
lv_text_align_t lv_table_get_cell_align(lv_obj_t * table, uint16_t row, uint16_t col)
|
||||
{
|
||||
LV_ASSERT_OBJ(table, LV_OBJX_NAME);
|
||||
|
||||
lv_table_ext_t * ext = table->ext_attr;
|
||||
if(row >= ext->row_cnt || col >= ext->col_cnt) {
|
||||
LV_LOG_WARN("lv_table_set_cell_align: invalid row or column");
|
||||
return LV_LABEL_ALIGN_LEFT; /*Just return with something*/
|
||||
return LV_TEXT_ALIGN_LEFT; /*Just return with something*/
|
||||
}
|
||||
uint32_t cell = row * ext->col_cnt + col;
|
||||
|
||||
if(ext->cell_data[cell] == NULL)
|
||||
return LV_LABEL_ALIGN_LEFT; /*Just return with something*/
|
||||
return LV_TEXT_ALIGN_LEFT; /*Just return with something*/
|
||||
else {
|
||||
lv_table_cell_format_t format;
|
||||
format.format_byte = ext->cell_data[cell][0];
|
||||
@@ -533,7 +533,7 @@ lv_label_align_t lv_table_get_cell_align(lv_obj_t * table, uint16_t row, uint16_
|
||||
* @param col id of the column [0 .. col_cnt -1]
|
||||
* @return true: text crop enabled; false: disabled
|
||||
*/
|
||||
lv_label_align_t lv_table_get_cell_crop(lv_obj_t * table, uint16_t row, uint16_t col)
|
||||
lv_text_align_t lv_table_get_cell_crop(lv_obj_t * table, uint16_t row, uint16_t col)
|
||||
{
|
||||
LV_ASSERT_OBJ(table, LV_OBJX_NAME);
|
||||
|
||||
@@ -768,7 +768,7 @@ static lv_design_res_t lv_table_design(lv_obj_t * table, const lv_area_t * clip_
|
||||
}
|
||||
else {
|
||||
format.s.right_merge = 0;
|
||||
format.s.align = LV_LABEL_ALIGN_LEFT;
|
||||
format.s.align = LV_TEXT_ALIGN_LEFT;
|
||||
format.s.crop = 1;
|
||||
}
|
||||
|
||||
@@ -842,8 +842,8 @@ static lv_design_res_t lv_table_design(lv_obj_t * table, const lv_area_t * clip_
|
||||
txt_area.y2 = cell_area.y2 - cell_bottom;
|
||||
|
||||
/*Align the content to the middle if not cropped*/
|
||||
if(format.s.crop == 0) txt_flags = LV_TXT_FLAG_NONE;
|
||||
else txt_flags = LV_TXT_FLAG_EXPAND;
|
||||
if(format.s.crop == 0) txt_flags = LV_TEXT_FLAG_NONE;
|
||||
else txt_flags = LV_TEXT_FLAG_EXPAND;
|
||||
|
||||
_lv_txt_get_size(&txt_size, ext->cell_data[cell] + 1, label_dsc_base.font,
|
||||
label_dsc_base.letter_space, label_dsc_base.line_space,
|
||||
@@ -858,14 +858,14 @@ static lv_design_res_t lv_table_design(lv_obj_t * table, const lv_area_t * clip_
|
||||
|
||||
switch(format.s.align) {
|
||||
default:
|
||||
case LV_LABEL_ALIGN_LEFT:
|
||||
label_dsc_base.flag |= LV_TXT_FLAG_NONE;
|
||||
case LV_TEXT_ALIGN_LEFT:
|
||||
label_dsc_base.flag |= LV_TEXT_FLAG_NONE;
|
||||
break;
|
||||
case LV_LABEL_ALIGN_RIGHT:
|
||||
label_dsc_base.flag |= LV_TXT_FLAG_RIGHT;
|
||||
case LV_TEXT_ALIGN_RIGHT:
|
||||
label_dsc_base.flag |= LV_TEXT_FLAG_RIGHT;
|
||||
break;
|
||||
case LV_LABEL_ALIGN_CENTER:
|
||||
label_dsc_base.flag |= LV_TXT_FLAG_CENTER;
|
||||
case LV_TEXT_ALIGN_CENTER:
|
||||
label_dsc_base.flag |= LV_TEXT_FLAG_CENTER;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -995,7 +995,7 @@ static lv_coord_t get_row_height(lv_obj_t * table, uint16_t row_id, const lv_fon
|
||||
txt_w -= cell_left + cell_right;
|
||||
|
||||
_lv_txt_get_size(&txt_size, ext->cell_data[cell] + 1, font,
|
||||
letter_space, line_space, txt_w, LV_TXT_FLAG_NONE);
|
||||
letter_space, line_space, txt_w, LV_TEXT_FLAG_NONE);
|
||||
|
||||
h_max = LV_MATH_MAX(txt_size.y + cell_top + cell_bottom, h_max);
|
||||
cell += col_merge;
|
||||
|
||||
@@ -124,9 +124,9 @@ void lv_table_set_col_width(lv_obj_t * table, uint16_t col_id, lv_coord_t w);
|
||||
* @param table pointer to a Table object
|
||||
* @param row id of the row [0 .. row_cnt -1]
|
||||
* @param col id of the column [0 .. col_cnt -1]
|
||||
* @param align LV_LABEL_ALIGN_LEFT or LV_LABEL_ALIGN_CENTER or LV_LABEL_ALIGN_RIGHT
|
||||
* @param align LV_TEXT_ALIGN_LEFT or LV_TEXT_ALIGN_CENTER or LV_TEXT_ALIGN_RIGHT
|
||||
*/
|
||||
void lv_table_set_cell_align(lv_obj_t * table, uint16_t row, uint16_t col, lv_label_align_t align);
|
||||
void lv_table_set_cell_align(lv_obj_t * table, uint16_t row, uint16_t col, lv_text_align_t align);
|
||||
|
||||
/**
|
||||
* Set the cell crop. (Don't adjust the height of the cell according to its content)
|
||||
@@ -183,25 +183,6 @@ uint16_t lv_table_get_col_cnt(lv_obj_t * table);
|
||||
*/
|
||||
lv_coord_t lv_table_get_col_width(lv_obj_t * table, uint16_t col_id);
|
||||
|
||||
/**
|
||||
* Get the text align of a cell
|
||||
* @param table pointer to a Table object
|
||||
* @param row id of the row [0 .. row_cnt -1]
|
||||
* @param col id of the column [0 .. col_cnt -1]
|
||||
* @return LV_LABEL_ALIGN_LEFT (default in case of error) or LV_LABEL_ALIGN_CENTER or
|
||||
* LV_LABEL_ALIGN_RIGHT
|
||||
*/
|
||||
lv_label_align_t lv_table_get_cell_align(lv_obj_t * table, uint16_t row, uint16_t col);
|
||||
|
||||
/**
|
||||
* Get the type of a cell
|
||||
* @param table pointer to a Table object
|
||||
* @param row id of the row [0 .. row_cnt -1]
|
||||
* @param col id of the column [0 .. col_cnt -1]
|
||||
* @return 1,2,3 or 4
|
||||
*/
|
||||
lv_label_align_t lv_table_get_cell_type(lv_obj_t * table, uint16_t row, uint16_t col);
|
||||
|
||||
/**
|
||||
* Get the crop property of a cell
|
||||
* @param table pointer to a Table object
|
||||
@@ -209,7 +190,7 @@ lv_label_align_t lv_table_get_cell_type(lv_obj_t * table, uint16_t row, uint16_t
|
||||
* @param col id of the column [0 .. col_cnt -1]
|
||||
* @return true: text crop enabled; false: disabled
|
||||
*/
|
||||
lv_label_align_t lv_table_get_cell_crop(lv_obj_t * table, uint16_t row, uint16_t col);
|
||||
bool lv_table_get_cell_crop(lv_obj_t * table, uint16_t row, uint16_t col);
|
||||
|
||||
/**
|
||||
* Get the cell merge attribute.
|
||||
|
||||
@@ -696,7 +696,7 @@ void lv_textarea_set_one_line(lv_obj_t * ta, bool en)
|
||||
|
||||
lv_textarea_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
if(ext->one_line == en) return;
|
||||
lv_label_align_t old_align = lv_label_get_align(ext->label);
|
||||
lv_text_align_t old_align = lv_label_get_align(ext->label);
|
||||
|
||||
if(en) {
|
||||
const lv_font_t * font = lv_obj_get_style_text_font(ta, LV_TEXTAREA_PART_MAIN);
|
||||
@@ -721,12 +721,12 @@ void lv_textarea_set_one_line(lv_obj_t * ta, bool en)
|
||||
|
||||
/**
|
||||
* Set the alignment of the text area.
|
||||
* In one line mode the text can be scrolled only with `LV_LABEL_ALIGN_LEFT`.
|
||||
* In one line mode the text can be scrolled only with `LV_TEXT_ALIGN_LEFT`.
|
||||
* This function should be called if the size of text area changes.
|
||||
* @param ta pointer to a text are object
|
||||
* @param align the desired alignment from `lv_label_align_t`. (LV_LABEL_ALIGN_LEFT/CENTER/RIGHT)
|
||||
* @param align the desired alignment from `lv_text_align_t`. (LV_TEXT_ALIGN_LEFT/CENTER/RIGHT)
|
||||
*/
|
||||
void lv_textarea_set_text_align(lv_obj_t * ta, lv_label_align_t align)
|
||||
void lv_textarea_set_text_align(lv_obj_t * ta, lv_text_align_t align)
|
||||
{
|
||||
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||
|
||||
@@ -737,7 +737,7 @@ void lv_textarea_set_text_align(lv_obj_t * ta, lv_label_align_t align)
|
||||
}
|
||||
else {
|
||||
/*Normal left align. Just let the text expand*/
|
||||
if(align == LV_LABEL_ALIGN_LEFT) {
|
||||
if(align == LV_TEXT_ALIGN_LEFT) {
|
||||
lv_label_set_long_mode(label, LV_LABEL_LONG_EXPAND);
|
||||
lv_label_set_align(label, align);
|
||||
}
|
||||
@@ -1528,7 +1528,7 @@ static void refr_cursor_area(lv_obj_t * ta)
|
||||
|
||||
/*If the cursor is out of the text (most right) draw it to the next line*/
|
||||
if(letter_pos.x + ext->label->coords.x1 + letter_w > ext->label->coords.x2 && ext->one_line == 0 &&
|
||||
lv_label_get_align(ext->label) != LV_LABEL_ALIGN_RIGHT) {
|
||||
lv_label_get_align(ext->label) != LV_TEXT_ALIGN_RIGHT) {
|
||||
letter_pos.x = 0;
|
||||
letter_pos.y += letter_h + line_space;
|
||||
|
||||
@@ -1721,17 +1721,17 @@ static void draw_placeholder(lv_obj_t * ta, const lv_area_t * clip_area)
|
||||
lv_draw_label_dsc_init(&ph_dsc);
|
||||
lv_obj_init_draw_label_dsc(ta, LV_TEXTAREA_PART_PLACEHOLDER, &ph_dsc);
|
||||
switch(lv_label_get_align(ext->label)) {
|
||||
case LV_LABEL_ALIGN_CENTER:
|
||||
ph_dsc.flag |= LV_TXT_FLAG_CENTER;
|
||||
case LV_TEXT_ALIGN_CENTER:
|
||||
ph_dsc.flag |= LV_TEXT_FLAG_CENTER;
|
||||
break;
|
||||
case LV_LABEL_ALIGN_RIGHT:
|
||||
ph_dsc.flag |= LV_TXT_FLAG_RIGHT;
|
||||
case LV_TEXT_ALIGN_RIGHT:
|
||||
ph_dsc.flag |= LV_TEXT_FLAG_RIGHT;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if(ext->one_line) ph_dsc.flag |= LV_TXT_FLAG_EXPAND;
|
||||
if(ext->one_line) ph_dsc.flag |= LV_TEXT_FLAG_EXPAND;
|
||||
|
||||
lv_coord_t left = lv_obj_get_style_pad_left(ta, LV_TEXTAREA_PART_MAIN);
|
||||
lv_coord_t top = lv_obj_get_style_pad_top(ta, LV_TEXTAREA_PART_MAIN);
|
||||
|
||||
@@ -179,12 +179,12 @@ void lv_textarea_set_one_line(lv_obj_t * ta, bool en);
|
||||
|
||||
/**
|
||||
* Set the alignment of the text area.
|
||||
* In one line mode the text can be scrolled only with `LV_LABEL_ALIGN_LEFT`.
|
||||
* In one line mode the text can be scrolled only with `LV_TEXT_ALIGN_LEFT`.
|
||||
* This function should be called if the size of text area changes.
|
||||
* @param ta pointer to a text are object
|
||||
* @param align the desired alignment from `lv_label_align_t`. (LV_LABEL_ALIGN_LEFT/CENTER/RIGHT)
|
||||
* @param align the desired alignment from `lv_text_align_t`. (LV_TEXT_ALIGN_LEFT/CENTER/RIGHT)
|
||||
*/
|
||||
void lv_textarea_set_text_align(lv_obj_t * ta, lv_label_align_t align);
|
||||
void lv_textarea_set_text_align(lv_obj_t * ta, lv_text_align_t align);
|
||||
|
||||
/**
|
||||
* Set a list of characters. Only these characters will be accepted by the text area
|
||||
|
||||
Reference in New Issue
Block a user