1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00
This commit is contained in:
Gabor Kiss-Vamosi 2021-02-07 21:32:43 +01:00
parent 063d17d842
commit c43259814a
20 changed files with 141 additions and 135 deletions

View File

@ -3,7 +3,7 @@
void lv_ex_spinner_1(void)
{
/*Create a Preloader object*/
/*Create a spinner*/
lv_obj_t * spinner = lv_spinner_create(lv_scr_act(), 1000, 60);
lv_obj_set_size(spinner, 100, 100);
lv_obj_align(spinner, NULL, LV_ALIGN_CENTER, 0, 0);

View File

@ -5,14 +5,13 @@ void lv_ex_tabview_1(void)
{
/*Create a Tab view object*/
lv_obj_t *tabview;
tabview = lv_tabview_create(lv_scr_act(), LV_DIR_TOP, 50);
tabview = lv_tabview_create(lv_scr_act(), LV_DIR_RIGHT, 50);
/*Add 3 tabs (the tabs are page (lv_page) and can be scrolled*/
lv_obj_t *tab1 = lv_tabview_add_tab(tabview, "Tab 1");
lv_obj_t *tab2 = lv_tabview_add_tab(tabview, "Tab 2");
lv_obj_t *tab3 = lv_tabview_add_tab(tabview, "Tab 3");
/*Add content to the tabs*/
lv_obj_t * label = lv_label_create(tab1, NULL);
lv_label_set_text(label, "This the first tab\n\n"

View File

@ -165,18 +165,18 @@ static void flex_update(lv_obj_t * cont, lv_obj_t * item)
lv_coord_t abs_y = cont->coords.y1 + lv_obj_get_style_pad_top(cont, LV_PART_MAIN) - lv_obj_get_scroll_y(cont);
lv_coord_t abs_x = cont->coords.x1 + lv_obj_get_style_pad_left(cont, LV_PART_MAIN) - lv_obj_get_scroll_x(cont);
lv_flex_place_t cross_place = f->track_cross_place;
lv_flex_place_t track_cross_place = f->track_cross_place;
lv_coord_t * cross_pos = (row ? &abs_y : &abs_x);
if((row && cont->h_set == LV_SIZE_CONTENT) ||
(!row && cont->w_set == LV_SIZE_CONTENT))
{
cross_place = LV_FLEX_PLACE_START;
track_cross_place = LV_FLEX_PLACE_START;
}
if(rtl && !row) {
if(cross_place == LV_FLEX_PLACE_START) cross_place = LV_FLEX_PLACE_END;
else if(cross_place == LV_FLEX_PLACE_END) cross_place = LV_FLEX_PLACE_START;
if(track_cross_place == LV_FLEX_PLACE_START) track_cross_place = LV_FLEX_PLACE_END;
else if(track_cross_place == LV_FLEX_PLACE_END) track_cross_place = LV_FLEX_PLACE_START;
}
lv_coord_t total_track_cross_size = 0;
@ -185,7 +185,7 @@ static void flex_update(lv_obj_t * cont, lv_obj_t * item)
int32_t track_first_item;
int32_t next_track_first_item;
if(cross_place != LV_FLEX_PLACE_START) {
if(track_cross_place != LV_FLEX_PLACE_START) {
track_first_item = f->rev ? cont->spec_attr->child_cnt - 1 : 0;
track_t t;
while(track_first_item < cont->spec_attr->child_cnt && track_first_item >= 0) {
@ -203,7 +203,7 @@ static void flex_update(lv_obj_t * cont, lv_obj_t * item)
* always use the gap = 0 and start position = 0 to avoid unintuitive scrolling*/
lv_coord_t max_cross_size = (row ? lv_obj_get_height_fit(cont) : lv_obj_get_width_fit(cont));
if(total_track_cross_size < max_cross_size) {
place_content(cross_place, max_cross_size, total_track_cross_size, track_cnt, cross_pos, &gap);
place_content(track_cross_place, max_cross_size, total_track_cross_size, track_cnt, cross_pos, &gap);
}
}
@ -267,13 +267,14 @@ static int32_t find_track_end(lv_obj_t * cont, int32_t item_start_id, lv_coord_t
grow_item_cnt++;
} else {
lv_coord_t item_size = get_main_size(item) + item_gap;
if(wrap && t->track_main_size + item_size > max_main_size) break;
if(wrap && t->track_main_size + item_size > max_main_size + item_gap) break;
t->track_main_size += item_size;
}
t->track_cross_size = LV_MAX(get_cross_size(item), t->track_cross_size);
t->item_cnt++;
}
item_id += f->rev ? -1 : +1;
if(item_id < 0) break;
item = lv_obj_get_child(cont, item_id);
}

View File

@ -51,6 +51,13 @@ static void calc_rows(lv_obj_t * cont, _lv_grid_calc_t * c);
static void item_repos(lv_obj_t * item, _lv_grid_calc_t * c, item_repos_hint_t * hint);
static lv_coord_t grid_place(lv_coord_t cont_size, bool auto_size, uint8_t place, lv_coord_t gap, uint32_t track_num, lv_coord_t * size_array, lv_coord_t * pos_array, bool reverse);
/**********************
* GLOBAL VARIABLES
**********************/
const static lv_coord_t grid_12_template[12] = {LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1),
LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1)};
const lv_grid_t grid_12 = {.base.update_cb = grid_update, .col_dsc = grid_12_template, .col_dsc_len = 12, .row_dsc = grid_12_template, .row_dsc_len = 12};
/**********************
* STATIC VARIABLES
**********************/

View File

@ -118,6 +118,7 @@ static inline lv_coord_t lv_grid_fr(uint8_t x)
/**********************
* GLOBAL VARIABLES
**********************/
extern const lv_grid_t grid_12;
/**********************
* MACROS

View File

@ -457,7 +457,7 @@ lv_theme_t * lv_theme_default_init(lv_color_t color_primary, lv_color_t color_se
/* This trick is required only to avoid the garbage collection of
* styles' data if LVGL is used in a binding (e.g. Micropython)
* In a general case styles could be simple `static lv_style_t my style` variables*/
* In a general case styles could be in simple `static lv_style_t my_style...` variables*/
if(!inited) {
LV_GC_ROOT(_lv_theme_default_styles) = lv_mem_alloc(sizeof(my_theme_styles_t));
styles = (my_theme_styles_t *)LV_GC_ROOT(_lv_theme_default_styles);
@ -466,9 +466,9 @@ lv_theme_t * lv_theme_default_init(lv_color_t color_primary, lv_color_t color_se
theme.color_primary = color_primary;
theme.color_secondary = color_secondary;
theme.font_small = font_small;
theme.font_small = font_normal;
theme.font_small = font_large;
theme.font_small = font_extra_large;
theme.font_normal = font_normal;
theme.font_large = font_large;
theme.font_extra_large = font_extra_large;
theme.apply_cb = theme_apply;
style_init();
@ -493,7 +493,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
if(lv_obj_check_type(obj, &lv_obj)) {
#if LV_USE_TABVIEW
lv_obj_t * parent = lv_obj_get_parent(obj);
/*Tabvew content area*/
/*Tabview content area*/
if(lv_obj_check_type(parent, &lv_tabview)) {
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->bg_color_gray);
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->pad_gap);

View File

@ -66,9 +66,9 @@ lv_obj_t * lv_spinner_create(lv_obj_t * par, uint32_t time, uint32_t arc_length)
lv_anim_set_values(&a, 0, 360);
lv_anim_start(&a);
lv_arc_set_bg_angles(spinner, 0, 360);
lv_arc_set_angles(spinner, 0, arc_length);
lv_arc_set_angle_ofs(spinner, 270 - arc_length / 2);
lv_arc_set_bg_angles(spinner, 0, 360);
lv_arc_set_rotation(spinner, 270 - arc_length / 2);
return spinner;
}

View File

@ -67,28 +67,28 @@ lv_obj_t * lv_tabview_add_tab(lv_obj_t * obj, const char * name)
const char ** new_map;
/*top or bottom dir*/
// if(lv_obj_get_flex_dir(tv) == LV_FLEX_DIR_COLUMN) {
if(tabview->tab_pos & LV_DIR_VER) {
new_map = lv_mem_alloc((tab_id + 1) * sizeof(const char *));
lv_memcpy_small(new_map, old_map, sizeof(const char *) * (tab_id - 1));
new_map[tab_id - 1] = lv_mem_alloc(strlen(name) + 1);
strcpy((char *)new_map[tab_id - 1], name);
new_map[tab_id] = "";
// }
// /*left or right dir*/
// else {
// new_map = lv_mem_alloc((tab_id * 2) * sizeof(const char *));
// lv_memcpy_small(new_map, old_map, sizeof(const char *) * tab_id * 2);
// if(ext->tab_cnt == 0) {
// new_map[0] = lv_mem_alloc(strlen(name) + 1);
// strcpy((char *)new_map[0], name);
// new_map[1] = "";
// } else {
// new_map[tab_id * 2 - 3] = "\n";
// new_map[tab_id * 2 - 2] = lv_mem_alloc(strlen(name) + 1);
// new_map[tab_id * 2 - 1] = "";
// strcpy((char *)new_map[(tab_id * 2) - 2], name);
// }
// }
}
/*left or right dir*/
else {
new_map = lv_mem_alloc((tab_id * 2) * sizeof(const char *));
lv_memcpy_small(new_map, old_map, sizeof(const char *) * tab_id * 2);
if(tabview->tab_cnt == 0) {
new_map[0] = lv_mem_alloc(strlen(name) + 1);
strcpy((char *)new_map[0], name);
new_map[1] = "";
} else {
new_map[tab_id * 2 - 3] = "\n";
new_map[tab_id * 2 - 2] = lv_mem_alloc(strlen(name) + 1);
new_map[tab_id * 2 - 1] = "";
strcpy((char *)new_map[(tab_id * 2) - 2], name);
}
}
lv_btnmatrix_set_map(btns, new_map);
lv_mem_free(old_map);
@ -147,29 +147,30 @@ static void lv_tabview_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_o
{
lv_tabview_t * tabview = (lv_tabview_t *) obj;
// lv_flex_flow_t flex_dir;
// switch(tab_pos) {
// case LV_DIR_TOP:
// flex_dir = LV_FLEX_DIR_COLUMN;
// break;
// case LV_DIR_BOTTOM:
// flex_dir = LV_FLEX_DIR_COLUMN_REVERSE;
// break;
// case LV_DIR_LEFT:
// flex_dir = LV_FLEX_DIR_ROW;
// break;
// case LV_DIR_RIGHT:
// flex_dir = LV_FLEX_DIR_ROW_REVERSE;
// break;
// }
tabview->tab_pos = tabpos_create;
lv_flex_init(&tabview->flex);
switch(tabview->tab_pos) {
case LV_DIR_TOP:
lv_flex_set_flow(&tabview->flex, LV_FLEX_FLOW_COLUMN);
break;
case LV_DIR_BOTTOM:
lv_flex_set_flow(&tabview->flex, LV_FLEX_FLOW_COLUMN_REVERSE);
break;
case LV_DIR_LEFT:
lv_flex_set_flow(&tabview->flex, LV_FLEX_FLOW_ROW);
break;
case LV_DIR_RIGHT:
lv_flex_set_flow(&tabview->flex, LV_FLEX_FLOW_ROW_REVERSE);
break;
}
lv_obj_set_size(obj, LV_COORD_PCT(100), LV_COORD_PCT(100));
lv_obj_set_layout(obj, &lv_flex_stacked);
lv_obj_set_layout(obj, &tabview->flex);
lv_obj_t * btnm;
lv_obj_t * cont;
btnm = lv_btnmatrix_create(obj, NULL);
cont = lv_obj_create(obj, NULL);
@ -183,16 +184,16 @@ static void lv_tabview_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_o
lv_obj_add_event_cb(cont, cont_event_cb, NULL);
lv_obj_set_scrollbar_mode(cont, LV_SCROLLBAR_MODE_OFF);
switch(tabpos_create) {
switch(tabview->tab_pos) {
case LV_DIR_TOP:
case LV_DIR_LEFT:
case LV_DIR_BOTTOM:
lv_obj_set_size(btnm, LV_COORD_PCT(100), tabsize_create);
lv_obj_set_width(cont, LV_COORD_PCT(100));
lv_obj_set_flex_grow(cont, 1);
break;
case LV_DIR_BOTTOM:
case LV_DIR_LEFT:
case LV_DIR_RIGHT:
lv_obj_set_size(btnm, LV_COORD_PCT(100), tabsize_create);
lv_obj_set_size(btnm, tabsize_create, LV_COORD_PCT(100));
lv_obj_set_height(cont, LV_COORD_PCT(100));
lv_obj_set_flex_grow(cont, 1);
break;

View File

@ -28,8 +28,10 @@ extern "C" {
typedef struct
{
lv_obj_t obj;
lv_flex_t flex;
uint16_t tab_cnt;
uint16_t tab_cur;
lv_dir_t tab_pos;
}lv_tabview_t;
extern const lv_obj_class_t lv_tabview;

View File

@ -58,6 +58,19 @@ lv_obj_t * lv_obj_create_from_class(const lv_obj_class_t * class_p, lv_obj_t * p
return obj;
}
void lv_obj_destruct(lv_obj_t * obj)
{
if(obj->class_p->destructor_cb) obj->class_p->destructor_cb(obj);
if(obj->class_p->base_class) {
/*Don't let the descendant methods run during constructing the ancestor type*/
obj->class_p = obj->class_p->base_class;
/*Call the base class's destructor too*/
lv_obj_destruct(obj);
}
}
lv_res_t lv_obj_signal_base(const lv_obj_class_t * class_p, struct _lv_obj_t * obj, lv_signal_t sign, void * param)
{

View File

@ -187,8 +187,8 @@ void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_co
lv_coord_t ptop = lv_obj_get_style_pad_top(parent, LV_PART_MAIN);
switch(align) {
case LV_ALIGN_CENTER:
x = lv_obj_get_width_fit(base) / 2 - lv_obj_get_width(obj) / 2;
y = lv_obj_get_height_fit(base) / 2 - lv_obj_get_height(obj) / 2;
x = lv_obj_get_width(base) / 2 - lv_obj_get_width(obj) / 2 - pleft;
y = lv_obj_get_height(base) / 2 - lv_obj_get_height(obj) / 2- ptop;
break;
case LV_ALIGN_IN_TOP_LEFT:
x = 0;

View File

@ -124,6 +124,10 @@ void lv_obj_remove_style(lv_obj_t * obj, uint32_t part, uint32_t state, lv_style
continue;
}
if(obj->style_list.styles[i].is_trans) {
trans_del(obj, part, LV_STYLE_PROP_ALL, NULL);
}
if(obj->style_list.styles[i].is_local || obj->style_list.styles[i].is_trans) {
lv_style_reset(obj->style_list.styles[i].style);
lv_mem_free(obj->style_list.styles[i].style);
@ -143,7 +147,6 @@ void lv_obj_remove_style(lv_obj_t * obj, uint32_t part, uint32_t state, lv_style
/* The style from the current `i` index is removed, so `i` points to the next style.
* Therefore it doesn't needs to be incremented*/
}
if(deleted) {
lv_obj_refresh_style(obj, LV_STYLE_PROP_ALL);
}
@ -827,12 +830,12 @@ static bool trans_del(lv_obj_t * obj, uint8_t part, lv_style_prop_t prop, trans_
/*'tr' might be deleted, so get the next object while 'tr' is valid*/
tr_prev = _lv_ll_get_prev(&LV_GC_ROOT(_lv_obj_style_trans_ll), tr);
if(tr->obj == obj && (part == tr->part || part == LV_PART_ANY) && (prop == tr->prop || prop == 0xFF)) {
if(tr->obj == obj && (part == tr->part || part == LV_PART_ANY) && (prop == tr->prop || prop == LV_STYLE_PROP_ALL)) {
/* Remove the transitioned property from trans. style
* to allow changing it by normal styles*/
uint32_t i;
for(i = 0; i < obj->style_list.style_cnt; i++) {
if(obj->style_list.styles[i].is_trans && (part == 0xff || obj->style_list.styles[i].part == part)) {
if(obj->style_list.styles[i].is_trans && (part == LV_PART_ANY || obj->style_list.styles[i].part == part)) {
lv_style_remove_prop(obj->style_list.styles[i].style, tr->prop);
lv_anim_del(tr, NULL);
_lv_ll_remove(&LV_GC_ROOT(_lv_obj_style_trans_ll), tr);

View File

@ -29,6 +29,7 @@
* GLOBAL PROTOTYPES
**********************/
void lv_event_mark_deleted(lv_obj_t * obj);
void lv_obj_destruct(lv_obj_t * obj);
/**********************
* STATIC PROTOTYPES
@ -335,7 +336,18 @@ static void obj_del_core(lv_obj_t * obj)
indev = lv_indev_get_next(indev);
}
/* All children deleted.
* Now clean up the object specific data*/
obj->class_p->destructor_cb(obj);
/* All children deleted. Now clean up the object specific data*/
lv_obj_destruct(obj);
/*Remove the object from the child list of its parent*/
uint32_t id = lv_obj_get_child_id(obj);
uint32_t i;
for(i = id; i < obj->parent->spec_attr->child_cnt - 1; i++) {
obj->parent->spec_attr->children[i] = obj->parent->spec_attr->children[i + 1];
}
obj->parent->spec_attr->child_cnt--;
lv_mem_realloc(obj->parent->spec_attr->children, obj->parent->spec_attr->child_cnt * sizeof(lv_obj_t *));
/*Free the object itself*/
lv_mem_free(obj);
}

View File

@ -20,6 +20,8 @@
*********************/
#define MY_CLASS &lv_arc
#define VALUE_UNSET INT16_MIN
/**********************
* TYPEDEFS
**********************/
@ -266,15 +268,15 @@ void lv_arc_set_bg_angles(lv_obj_t * obj, uint16_t start, uint16_t end)
/**
* Set the rotation for the whole arc
* @param arc pointer to an arc object
* @param angle_ofs rotation angle
* @param rotation rotation angle
*/
void lv_arc_set_angle_ofs(lv_obj_t * obj, uint16_t angle_ofs)
void lv_arc_set_rotation(lv_obj_t * obj, uint16_t rotation)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
lv_arc_t * arc = (lv_arc_t *)obj;
arc->angle_ofs = angle_ofs;
arc->rotation = rotation;
lv_obj_invalidate(obj);
}
@ -490,13 +492,13 @@ static void lv_arc_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t
/*Create the ancestor of arc*/
/*Initialize the allocated 'ext' */
arc->angle_ofs = 0;
arc->rotation = 0;
arc->bg_angle_start = 135;
arc->bg_angle_end = 45;
arc->indic_angle_start = 135;
arc->indic_angle_end = 270;
arc->type = LV_ARC_TYPE_NORMAL;
arc->value = -1;
arc->value = VALUE_UNSET;
arc->min_close = 1;
arc->min_value = 0;
arc->max_value = 100;
@ -511,7 +513,6 @@ 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_DEF / 10);
lv_arc_set_value(obj,arc->min_value);
}
/*Copy an existing arc*/
else {
@ -568,8 +569,8 @@ static lv_draw_res_t lv_arc_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv
lv_draw_arc_dsc_init(&arc_dsc);
lv_obj_init_draw_arc_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->rotation,
arc->bg_angle_end + arc->rotation, clip_area,
&arc_dsc);
}
@ -584,8 +585,8 @@ static lv_draw_res_t lv_arc_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv
lv_draw_arc_dsc_init(&arc_dsc);
lv_obj_init_draw_arc_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->rotation,
arc->indic_angle_end +arc->rotation, clip_area,
&arc_dsc);
}
@ -660,7 +661,7 @@ static lv_res_t lv_arc_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
}
angle = lv_atan2(p.y, p.x);
angle -=arc->angle_ofs;
angle -=arc->rotation;
angle -=arc->bg_angle_start; /*Make the angle relative to the start angle*/
if(angle < 0) angle += 360;
@ -760,8 +761,8 @@ static void inv_arc_area(lv_obj_t * obj, uint16_t start_angle, uint16_t end_angl
/*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->rotation;
end_angle +=arc->rotation;
if(start_angle >= 360) start_angle -= 360;
if(end_angle >= 360) end_angle -= 360;
@ -903,7 +904,7 @@ static void get_knob_area(lv_obj_t * obj, const lv_point_t * center, lv_coord_t
lv_coord_t indic_width_half = indic_width / 2;
r -= indic_width_half;
uint16_t angle =arc->angle_ofs;
uint16_t angle =arc->rotation;
if(arc->type == LV_ARC_TYPE_NORMAL) {
angle +=arc->indic_angle_end;
}
@ -938,6 +939,9 @@ static void value_update(lv_obj_t * obj)
LV_ASSERT_OBJ(obj, MY_CLASS);
lv_arc_t * arc = (lv_arc_t *)obj;
/*If the value is still not set to any value do not update*/
if(arc->value == VALUE_UNSET) return;
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;

View File

@ -36,7 +36,7 @@ typedef uint8_t lv_arc_type_t;
typedef struct {
lv_obj_t obj;
uint16_t angle_ofs;
uint16_t rotation;
uint16_t indic_angle_start;
uint16_t indic_angle_end;
uint16_t bg_angle_start;
@ -123,7 +123,7 @@ void lv_arc_set_bg_angles(lv_obj_t * arc, uint16_t start, uint16_t end);
* @param arc pointer to an arc object
* @param rotation_angle rotation angle
*/
void lv_arc_set_angle_ofs(lv_obj_t * arc, uint16_t rotation_angle);
void lv_arc_set_rotation(lv_obj_t * arc, uint16_t rotation);
/**
* Set the type of arc.

View File

@ -43,7 +43,6 @@ const lv_obj_class_t lv_btn = {
lv_obj_t * lv_btn_create(lv_obj_t * parent, const lv_obj_t * copy)
{
LV_LOG_TRACE("button create started");
return lv_obj_create_from_class(&lv_btn, parent, copy);
}

View File

@ -411,16 +411,6 @@ static void lv_btnmatrix_destructor(lv_obj_t * obj)
btnm->ctrl_bits = NULL;
}
/**
* Handle the drawing related tasks of the button matrix
* @param obj pointer to a button matrix object
* @param clip_area the object will be drawn only in this area
* @param mode LV_DRAW_COVER_CHK: only check if the object fully covers the 'mask_p' area
* (return 'true' if yes)
* LV_DRAW_DRAW: draw the object (always return 'true')
* LV_DRAW_DRAW_POST: drawing after every children are drawn
* @param return an element of `lv_draw_res_t`
*/
static lv_draw_res_t lv_btnmatrix_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode)
{
if(mode == LV_DRAW_MODE_COVER_CHECK) {
@ -526,7 +516,7 @@ static lv_draw_res_t lv_btnmatrix_draw(lv_obj_t * obj, const lv_area_t * clip_ar
hook_dsc.id = btn_i;
lv_event_send(obj,LV_EVENT_DRAW_PART_BEGIN, &hook_dsc);
// /*Remove borders on the edges if `LV_BORDER_SIDE_INTERNAL`*/
/*Remove borders on the edges if `LV_BORDER_SIDE_INTERNAL`*/
if(draw_rect_dsc_act.border_side & LV_BORDER_SIDE_INTERNAL) {
draw_rect_dsc_act.border_side = LV_BORDER_SIDE_FULL;
if(btn_area.x1 == obj->coords.x1 + pleft) draw_rect_dsc_act.border_side &= ~LV_BORDER_SIDE_LEFT;
@ -580,13 +570,6 @@ static lv_draw_res_t lv_btnmatrix_draw(lv_obj_t * obj, const lv_area_t * clip_ar
return LV_DRAW_RES_OK;
}
/**
* Signal function of the button matrix
* @param obj pointer to a button matrix object
* @param sign a signal type from lv_signal_t enum
* @param param pointer to a signal specific variable
* @return LV_RES_OK: the object is not deleted in the function; LV_RES_INV: the object is deleted
*/
static lv_res_t lv_btnmatrix_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
{
lv_res_t res;

View File

@ -733,30 +733,13 @@ static void lv_label_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj
static void lv_label_destructor(lv_obj_t * obj)
{
// lv_label_dot_tmp_free(label->dot_...);
// lv_label_dot_tmp_free(label->text);
lv_label_t * label = (lv_label_t *)obj;
// lv_bar_t * bar = obj;
//
// _lv_obj_reset_style_list_no_refr(obj, LV_PART_INDICATOR);
//#if LV_USE_ANIMATION
// lv_anim_del(&bar->cur_value_anim, NULL);
// lv_anim_del(&bar->start_value_anim, NULL);
//#endif
// bar->class_p->base_p->destructor(obj);
lv_label_dot_tmp_free(obj);
if(!label->static_txt) lv_mem_free(label->text);
label->text = NULL;
}
/**
* Handle the drawing related tasks of the labels
* @param label pointer to a label object
* @param clip_area the object will be drawn only in this area
* @param mode LV_DRAW_COVER_CHK: only check if the object fully covers the 'mask_p' area
* (return 'true' if yes)
* LV_DRAW_DRAW: draw the object (always return 'true')
* LV_DRAW_DRAW_POST: drawing after every children are drawn
* @param return an element of `lv_draw_res_t`
*/
static lv_draw_res_t lv_label_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode)
{
/* A label never covers an area */

View File

@ -72,7 +72,7 @@ lv_meter_scale_t * lv_meter_add_scale(lv_obj_t * obj)
_lv_ll_init(&scale->indicator_ll, sizeof(lv_meter_indicator_t));
scale->angle_range = 270;
scale->angle_ofs = 90 + (360 - scale->angle_range) / 2;
scale->rotation = 90 + (360 - scale->angle_range) / 2;
scale->min = 0;
scale->max = 100;
scale->tick_cnt = 6;
@ -102,12 +102,12 @@ void lv_meter_set_scale_major_ticks(lv_obj_t * obj, lv_meter_scale_t * scale, ui
lv_obj_invalidate(obj);
}
void lv_meter_set_scale_range(lv_obj_t * obj, lv_meter_scale_t * scale, int32_t min, int32_t max, uint32_t angle_range, uint32_t angle_ofs)
void lv_meter_set_scale_range(lv_obj_t * obj, lv_meter_scale_t * scale, int32_t min, int32_t max, uint32_t angle_range, uint32_t rotation)
{
scale->min = min;
scale->max = max;
scale->angle_range = angle_range;
scale->angle_ofs = angle_ofs;
scale->rotation = rotation;
lv_obj_invalidate(obj);
}
@ -210,8 +210,6 @@ void lv_meter_set_indicator_end_value(lv_obj_t * obj, lv_meter_indicator_t * ind
static void lv_meter_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy)
{
LV_LOG_TRACE("line meter create started");
lv_obj_construct_base(obj, parent, copy);
lv_meter_t * meter = (lv_meter_t *) obj;
@ -317,8 +315,8 @@ static void draw_arcs(lv_obj_t * obj, const lv_area_t * clip_area, const lv_area
arc_dsc.width = indic->arc.width;
arc_dsc.opa = indic->opa > LV_OPA_MAX ? opa_main : (opa_main * indic->opa) >> 8;
int32_t start_angle = lv_map(indic->start_value, scale->min, scale->max, scale->angle_ofs, scale->angle_ofs + scale->angle_range);
int32_t end_angle = lv_map(indic->end_value, scale->min, scale->max, scale->angle_ofs, scale->angle_ofs + scale->angle_range);
int32_t start_angle = lv_map(indic->start_value, scale->min, scale->max, scale->rotation, scale->rotation + scale->angle_range);
int32_t end_angle = lv_map(indic->end_value, scale->min, scale->max, scale->rotation, scale->rotation + scale->angle_range);
lv_draw_arc(scale_center.x, scale_center.y, r_out + indic->arc.r_mod, start_angle, end_angle, clip_area, &arc_dsc);
}
}
@ -431,12 +429,12 @@ static void draw_lines_and_labels(lv_obj_t * obj, const lv_area_t * clip_area, c
int32_t angle_rem = angle_upscale & 0xFF;
/*Interpolate sine and cos*/
int32_t sin_low = lv_trigo_sin(angle_low + scale->angle_ofs);
int32_t sin_high = lv_trigo_sin(angle_high + scale->angle_ofs);
int32_t sin_low = lv_trigo_sin(angle_low + scale->rotation);
int32_t sin_high = lv_trigo_sin(angle_high + scale->rotation);
int32_t sin_mid = (sin_low * (256 - angle_rem) + sin_high * angle_rem) >> 8;
int32_t cos_low = lv_trigo_cos(angle_low + scale->angle_ofs);
int32_t cos_high = lv_trigo_cos(angle_high + scale->angle_ofs);
int32_t cos_low = lv_trigo_cos(angle_low + scale->rotation);
int32_t cos_high = lv_trigo_cos(angle_high + scale->rotation);
int32_t cos_mid = (cos_low * (256 - angle_rem) + cos_high * angle_rem) >> 8;
lv_point_t p_outer;
@ -516,7 +514,7 @@ static void draw_needles(lv_obj_t * obj, const lv_area_t * clip_area, const lv_a
lv_meter_indicator_t * indic;
_LV_LL_READ_BACK(&scale->indicator_ll, indic) {
if(indic->type == LV_METER_INDICATOR_TYPE_NEEDLE_LINE) {
int32_t angle = lv_map(indic->end_value, scale->min, scale->max, scale->angle_ofs, scale->angle_ofs + scale->angle_range);
int32_t angle = lv_map(indic->end_value, scale->min, scale->max, scale->rotation, scale->rotation + scale->angle_range);
lv_coord_t r_out = r_edge + scale->r_mod + indic->needle_line.r_mod;
lv_point_t p_end;
p_end.y = (lv_trigo_sin(angle) * (r_out)) / LV_TRIGO_SIN_MAX + scale_center.y;
@ -528,7 +526,7 @@ static void draw_needles(lv_obj_t * obj, const lv_area_t * clip_area, const lv_a
}
else if(indic->type == LV_METER_INDICATOR_TYPE_NEEDLE_IMG) {
int32_t angle = lv_map(indic->end_value, scale->min, scale->max, scale->angle_ofs, scale->angle_ofs + scale->angle_range);
int32_t angle = lv_map(indic->end_value, scale->min, scale->max, scale->rotation, scale->rotation + scale->angle_range);
lv_img_header_t info;
lv_img_decoder_get_info(indic->needle_img.src, &info);
lv_area_t a;

View File

@ -84,7 +84,7 @@ typedef struct {
int32_t max;
int16_t r_mod;
uint16_t angle_range;
int16_t angle_ofs;
int16_t rotation;
}lv_meter_scale_t;
/*Data of line meter*/
@ -151,9 +151,9 @@ void lv_meter_set_scale_major_ticks(lv_obj_t * obj, lv_meter_scale_t * scale, ui
* @param min the minimum value
* @param max the maximal value
* @param angle_range the angular range of the scale
* @param angle_ofs the angular offset from 3 o'clock position (clock-wise)
* @param rotation the angular offset from the 3 o'clock position (clock-wise)
*/
void lv_meter_set_scale_range(lv_obj_t * obj, lv_meter_scale_t * scale, int32_t min, int32_t max, uint32_t angle_range, uint32_t angle_ofs);
void lv_meter_set_scale_range(lv_obj_t * obj, lv_meter_scale_t * scale, int32_t min, int32_t max, uint32_t angle_range, uint32_t rotation);
/*=====================
* Add indicator