layout update

This commit is contained in:
Gabor Kiss-Vamosi
2021-01-04 17:26:09 +01:00
parent 68b27f6077
commit 9c55d77617
19 changed files with 120 additions and 133 deletions
+1
View File
@@ -14,6 +14,7 @@
- fix(textarea) buffer overflow in password mode with UTF-8 characters - fix(textarea) buffer overflow in password mode with UTF-8 characters
- fix(textarea) cursor position after hiding character in password mode - fix(textarea) cursor position after hiding character in password mode
- fix(linemeter) draw critical lines with correct color - fix(linemeter) draw critical lines with correct color
- fix(lv_conf_internal) be sure Kconfig defines are always uppercase
## v7.8.1 (Plannad at 15.12.2020) ## v7.8.1 (Plannad at 15.12.2020)
+17 -21
View File
@@ -28,8 +28,8 @@ typedef struct {
* STATIC PROTOTYPES * STATIC PROTOTYPES
**********************/ **********************/
static void flex_update(lv_obj_t * cont, lv_obj_t * item); static void flex_update(lv_obj_t * cont, lv_obj_t * item);
static int32_t find_track_end(lv_obj_t * cont, int32_t item_start_id, lv_coord_t max_main_size, track_t * t); static int32_t find_track_end(lv_obj_t * cont, int32_t item_start_id, lv_coord_t item_gap, lv_coord_t max_main_size, track_t * t);
static void children_repos(lv_obj_t * cont, int32_t item_first_id, int32_t item_last_id, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t max_main_size, track_t * t); static void children_repos(lv_obj_t * cont, int32_t item_first_id, int32_t item_last_id, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t max_main_size, lv_coord_t item_gap, track_t * t);
static void place_content(lv_flex_place_t place, lv_coord_t max_size, lv_coord_t content_size, lv_coord_t item_cnt, lv_coord_t * start_pos, lv_coord_t * gap); static void place_content(lv_flex_place_t place, lv_coord_t max_size, lv_coord_t content_size, lv_coord_t item_cnt, lv_coord_t * start_pos, lv_coord_t * gap);
static lv_obj_t * get_next_item(lv_obj_t * cont, bool rev, int32_t * item_id); static lv_obj_t * get_next_item(lv_obj_t * cont, bool rev, int32_t * item_id);
@@ -101,12 +101,6 @@ void lv_flex_set_place(lv_flex_t * flex, lv_flex_place_t item_main_place, lv_fle
flex->item_cross_place = item_cross_place; flex->item_cross_place = item_cross_place;
} }
void lv_flex_set_gap(lv_flex_t * flex, lv_coord_t main_gap, lv_coord_t cross_gap)
{
flex->item_gap = main_gap;
flex->track_gap = cross_gap;
}
/*===================== /*=====================
* Getter functions * Getter functions
*====================*/ *====================*/
@@ -118,6 +112,8 @@ static void flex_update(lv_obj_t * cont, lv_obj_t * item)
bool rtl = lv_obj_get_base_dir(cont) == LV_BIDI_DIR_RTL ? true : false; bool rtl = lv_obj_get_base_dir(cont) == LV_BIDI_DIR_RTL ? true : false;
bool row = f->dir == LV_FLEX_FLOW_ROW ? true : false; bool row = f->dir == LV_FLEX_FLOW_ROW ? true : false;
lv_coord_t track_gap = row ? lv_obj_get_style_pad_column(cont, LV_PART_MAIN) : lv_obj_get_style_pad_row(cont, LV_PART_MAIN);
lv_coord_t item_gap = !row ? lv_obj_get_style_pad_column(cont, LV_PART_MAIN) : lv_obj_get_style_pad_row(cont, LV_PART_MAIN);
/*Count the grow units and free space*/ /*Count the grow units and free space*/
lv_coord_t max_main_size = (row ? lv_obj_get_width_fit(cont) : lv_obj_get_height_fit(cont)); lv_coord_t max_main_size = (row ? lv_obj_get_width_fit(cont) : lv_obj_get_height_fit(cont));
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_y = cont->coords.y1 + lv_obj_get_style_pad_top(cont, LV_PART_MAIN) - lv_obj_get_scroll_y(cont);
@@ -148,13 +144,13 @@ static void flex_update(lv_obj_t * cont, lv_obj_t * item)
track_t t; track_t t;
while(track_first_item < cont->spec_attr->child_cnt && track_first_item >= 0) { while(track_first_item < cont->spec_attr->child_cnt && track_first_item >= 0) {
/*Search the first item of the next row */ /*Search the first item of the next row */
next_track_first_item = find_track_end(cont, track_first_item, max_main_size, &t); next_track_first_item = find_track_end(cont, track_first_item, max_main_size, item_gap, &t);
total_track_cross_size += t.track_cross_size + f->track_gap; total_track_cross_size += t.track_cross_size + track_gap;
track_cnt++; track_cnt++;
track_first_item = next_track_first_item; track_first_item = next_track_first_item;
} }
if(track_cnt) total_track_cross_size -= f->track_gap; /*No gap after the last track*/ if(track_cnt) total_track_cross_size -= track_gap; /*No gap after the last track*/
/* Place the tracks to get the start position /* Place the tracks to get the start position
* If the the height of the tracks is larger than the available space * If the the height of the tracks is larger than the available space
@@ -174,18 +170,18 @@ static void flex_update(lv_obj_t * cont, lv_obj_t * item)
while(track_first_item < cont->spec_attr->child_cnt && track_first_item >= 0) { while(track_first_item < cont->spec_attr->child_cnt && track_first_item >= 0) {
track_t t; track_t t;
/*Search the first item of the next row */ /*Search the first item of the next row */
next_track_first_item = find_track_end(cont, track_first_item, max_main_size, &t); next_track_first_item = find_track_end(cont, track_first_item, max_main_size, item_gap, &t);
if(rtl && !row) { if(rtl && !row) {
*cross_pos -= t.track_cross_size; *cross_pos -= t.track_cross_size;
} }
children_repos(cont, track_first_item, next_track_first_item, abs_x, abs_y, max_main_size, &t); children_repos(cont, track_first_item, next_track_first_item, abs_x, abs_y, max_main_size, item_gap, &t);
track_first_item = next_track_first_item; track_first_item = next_track_first_item;
if(rtl && !row) { if(rtl && !row) {
*cross_pos -= gap + f->track_gap; *cross_pos -= gap + track_gap;
} else { } else {
*cross_pos += t.track_cross_size + gap + f->track_gap; *cross_pos += t.track_cross_size + gap + track_gap;
} }
} }
LV_ASSERT_MEM_INTEGRITY(); LV_ASSERT_MEM_INTEGRITY();
@@ -195,7 +191,7 @@ static void flex_update(lv_obj_t * cont, lv_obj_t * item)
* STATIC FUNCTIONS * STATIC FUNCTIONS
**********************/ **********************/
static int32_t find_track_end(lv_obj_t * cont, int32_t item_start_id, lv_coord_t max_main_size, track_t * t) static int32_t find_track_end(lv_obj_t * cont, int32_t item_start_id, lv_coord_t max_main_size, lv_coord_t item_gap, track_t * t)
{ {
const lv_flex_t * f = cont->spec_attr->layout_dsc; const lv_flex_t * f = cont->spec_attr->layout_dsc;
@@ -219,7 +215,7 @@ static int32_t find_track_end(lv_obj_t * cont, int32_t item_start_id, lv_coord_t
grow_sum += _LV_FLEX_GET_GROW(main_size); grow_sum += _LV_FLEX_GET_GROW(main_size);
grow_item_cnt++; grow_item_cnt++;
} else { } else {
lv_coord_t item_size = get_main_size(item) + f->item_gap; lv_coord_t item_size = get_main_size(item) + item_gap;
if(f->wrap && t->track_main_size + item_size > max_main_size) break; if(f->wrap && t->track_main_size + item_size > max_main_size) break;
t->track_main_size += item_size; t->track_main_size += item_size;
} }
@@ -230,11 +226,11 @@ static int32_t find_track_end(lv_obj_t * cont, int32_t item_start_id, lv_coord_t
t->item_cnt++; t->item_cnt++;
} }
if(t->track_main_size > 0) t->track_main_size -= f->item_gap; /*There is no gap after the last item*/ if(t->track_main_size > 0) t->track_main_size -= item_gap; /*There is no gap after the last item*/
if(grow_item_cnt && grow_sum) { if(grow_item_cnt && grow_sum) {
lv_coord_t s = max_main_size - t->track_main_size; lv_coord_t s = max_main_size - t->track_main_size;
s -= grow_item_cnt * f->item_gap; s -= grow_item_cnt * item_gap;
t->grow_unit = s / grow_sum; t->grow_unit = s / grow_sum;
t->track_main_size = max_main_size; /*If there is at least one "grow item" the track takes the full space*/ t->track_main_size = max_main_size; /*If there is at least one "grow item" the track takes the full space*/
} else { } else {
@@ -255,7 +251,7 @@ static int32_t find_track_end(lv_obj_t * cont, int32_t item_start_id, lv_coord_t
} }
static void children_repos(lv_obj_t * cont, int32_t item_first_id, int32_t item_last_id, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t max_main_size, track_t * t) static void children_repos(lv_obj_t * cont, int32_t item_first_id, int32_t item_last_id, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t max_main_size, lv_coord_t item_gap, track_t * t)
{ {
const lv_flex_t * f = cont->spec_attr->layout_dsc; const lv_flex_t * f = cont->spec_attr->layout_dsc;
@@ -318,7 +314,7 @@ static void children_repos(lv_obj_t * cont, int32_t item_first_id, int32_t item_
} }
if(!(row && rtl)) { if(!(row && rtl)) {
main_pos += area_get_main_size(&item->coords) + f->item_gap + place_gap; main_pos += area_get_main_size(&item->coords) + item_gap + place_gap;
} }
item = get_next_item(cont, f->rev, &item_first_id); item = get_next_item(cont, f->rev, &item_first_id);
} }
-2
View File
@@ -57,8 +57,6 @@ typedef enum {
typedef struct { typedef struct {
lv_layout_update_cb_t update_cb; /*The first element must be the update callback*/ lv_layout_update_cb_t update_cb; /*The first element must be the update callback*/
lv_coord_t item_gap;
lv_coord_t track_gap;
uint32_t dir :2; uint32_t dir :2;
uint32_t wrap :1; uint32_t wrap :1;
uint32_t rev :1; uint32_t rev :1;
+9 -11
View File
@@ -71,13 +71,6 @@ void lv_grid_set_place(lv_grid_t * grid, uint8_t col_place, uint8_t row_place)
grid->row_place = row_place; grid->row_place = row_place;
} }
void lv_grid_set_gap(lv_grid_t * grid, lv_coord_t col_gap, uint8_t row_gap)
{
grid->col_gap = col_gap;
grid->row_gap = row_gap;
}
void lv_obj_set_grid_cell(lv_obj_t * obj, lv_coord_t col_pos, lv_coord_t row_pos) void lv_obj_set_grid_cell(lv_obj_t * obj, lv_coord_t col_pos, lv_coord_t row_pos)
{ {
lv_obj_set_pos(obj, col_pos, row_pos); lv_obj_set_pos(obj, col_pos, row_pos);
@@ -172,14 +165,17 @@ static void calc(struct _lv_obj_t * cont, _lv_grid_calc_t * calc_out)
calc_rows(cont, calc_out); calc_rows(cont, calc_out);
calc_cols(cont, calc_out); calc_cols(cont, calc_out);
lv_coord_t col_gap = lv_obj_get_style_pad_column(cont, LV_PART_MAIN);
lv_coord_t row_gap = lv_obj_get_style_pad_row(cont, LV_PART_MAIN);
bool rev = lv_obj_get_base_dir(cont) == LV_BIDI_DIR_RTL ? true : false; bool rev = lv_obj_get_base_dir(cont) == LV_BIDI_DIR_RTL ? true : false;
bool auto_w = cont->w_set == LV_SIZE_AUTO ? true : false; bool auto_w = cont->w_set == LV_SIZE_AUTO ? true : false;
lv_coord_t cont_w = lv_obj_get_width_fit(cont); lv_coord_t cont_w = lv_obj_get_width_fit(cont);
calc_out->grid_w = grid_place(cont_w, auto_w, g->col_place, g->col_gap, calc_out->col_num, calc_out->w, calc_out->x, rev); calc_out->grid_w = grid_place(cont_w, auto_w, g->col_place, col_gap, calc_out->col_num, calc_out->w, calc_out->x, rev);
bool auto_h = cont->h_set == LV_SIZE_AUTO ? true : false; bool auto_h = cont->h_set == LV_SIZE_AUTO ? true : false;
lv_coord_t cont_h = lv_obj_get_height_fit(cont); lv_coord_t cont_h = lv_obj_get_height_fit(cont);
calc_out->grid_h = grid_place(cont_h, auto_h, g->row_place, g->row_gap, calc_out->row_num, calc_out->h, calc_out->y, false); calc_out->grid_h = grid_place(cont_h, auto_h, g->row_place, row_gap, calc_out->row_num, calc_out->h, calc_out->y, false);
LV_ASSERT_MEM_INTEGRITY(); LV_ASSERT_MEM_INTEGRITY();
} }
@@ -220,7 +216,8 @@ static void calc_cols(lv_obj_t * cont, _lv_grid_calc_t * c)
} }
} }
cont_w -= grid->col_gap * (c->col_num - 1); lv_coord_t col_gap = lv_obj_get_style_pad_column(cont, LV_PART_MAIN);
cont_w -= col_gap * (c->col_num - 1);
lv_coord_t free_w = cont_w - grid_w; lv_coord_t free_w = cont_w - grid_w;
for(i = 0; i < c->col_num; i++) { for(i = 0; i < c->col_num; i++) {
@@ -259,7 +256,8 @@ static void calc_rows(lv_obj_t * cont, _lv_grid_calc_t * c)
} }
} }
lv_coord_t cont_h = lv_obj_get_height_fit(cont) - grid->row_gap * (grid->row_dsc_len - 1); lv_coord_t row_gap = lv_obj_get_style_pad_row(cont, LV_PART_MAIN);
lv_coord_t cont_h = lv_obj_get_height_fit(cont) - row_gap * (grid->row_dsc_len - 1);
lv_coord_t free_h = cont_h - grid_h; lv_coord_t free_h = cont_h - grid_h;
for(i = 0; i < grid->row_dsc_len; i++) { for(i = 0; i < grid->row_dsc_len; i++) {
-2
View File
@@ -62,8 +62,6 @@ typedef struct {
const lv_coord_t * row_dsc; const lv_coord_t * row_dsc;
uint8_t col_dsc_len; uint8_t col_dsc_len;
uint8_t row_dsc_len; uint8_t row_dsc_len;
lv_coord_t col_gap;
lv_coord_t row_gap;
uint8_t col_place; uint8_t col_place;
uint8_t row_place; uint8_t row_place;
}lv_grid_t; }lv_grid_t;
+16 -13
View File
@@ -218,22 +218,26 @@ void lv_deinit(void)
*/ */
lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy) lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
{ {
lv_obj_t * obj = lv_mem_alloc(sizeof(lv_obj_t)); return lv_obj_create_from_class(&lv_obj, parent, copy);
_lv_memset_00(obj, sizeof(lv_obj_t));
obj->class_p = &lv_obj;
lv_obj.constructor(obj, parent, copy);
lv_obj_create_finish(obj, parent, copy);
return obj;
} }
lv_obj_t * lv_obj_create_from_class(lv_obj_class_t * class, lv_obj_t * parent, const lv_obj_t * copy)
void lv_obj_create_finish(lv_obj_t * obj, 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));
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); if(!copy) lv_theme_apply(obj);
// else lv_style_list_copy(&checkbox->style_indic, &checkbox_copy->style_indic); // else lv_style_list_copy(&checkbox->style_indic, &checkbox_copy->style_indic);
return obj;
} }
/** /**
@@ -1832,8 +1836,7 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
*s = LV_MATH_MAX(*s, d); *s = LV_MATH_MAX(*s, d);
} }
else if(sign == LV_SIGNAL_STYLE_CHG) { else if(sign == LV_SIGNAL_STYLE_CHG) {
/* Padding might have changed so the layout should be recalculated /* Padding might have changed so the layout should be recalculated*/
* If margin has also changed the parent's layout also needs to be updated but it's done in CHILD_CHG signal*/
lv_obj_update_layout(obj, NULL); lv_obj_update_layout(obj, NULL);
/*Reposition non grid objects on by one*/ /*Reposition non grid objects on by one*/
+3
View File
@@ -300,6 +300,9 @@ void lv_deinit(void);
lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy); lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy);
void lv_obj_create_finish(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); void lv_obj_create_finish(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy);
lv_obj_t * lv_obj_create_from_class(lv_obj_class_t * class, lv_obj_t * parent, const lv_obj_t * copy);
/** /**
* Delete 'obj' and all of its children * Delete 'obj' and all of its children
* @param obj pointer to an object to delete * @param obj pointer to an object to delete
+1
View File
@@ -49,6 +49,7 @@ void lv_obj_update_layout(lv_obj_t * cont, lv_obj_t * item)
{ {
if(cont->spec_attr == NULL) return; if(cont->spec_attr == NULL) return;
if(cont->spec_attr->layout_dsc == NULL) return; if(cont->spec_attr->layout_dsc == NULL) return;
if(cont->spec_attr->child_cnt == 0) return;
const lv_layout_base_t * layout = cont->spec_attr->layout_dsc; const lv_layout_base_t * layout = cont->spec_attr->layout_dsc;
if(layout->update_cb == NULL) return; if(layout->update_cb == NULL) return;
-1
View File
@@ -425,7 +425,6 @@ void _lv_obj_refresh_style(lv_obj_t * obj,lv_style_prop_t prop)
lv_obj_invalidate(obj); lv_obj_invalidate(obj);
if(prop == LV_STYLE_PROP_ALL || (prop & LV_STYLE_PROP_LAYOUT_REFR)) { if(prop == LV_STYLE_PROP_ALL || (prop & LV_STYLE_PROP_LAYOUT_REFR)) {
lv_signal_send(obj, LV_SIGNAL_STYLE_CHG, NULL); lv_signal_send(obj, LV_SIGNAL_STYLE_CHG, NULL);
lv_signal_send(obj->parent, LV_SIGNAL_CHILD_CHG, obj);
lv_obj_invalidate(obj); lv_obj_invalidate(obj);
} else if(prop & LV_STYLE_PROP_EXT_DRAW) { } else if(prop & LV_STYLE_PROP_EXT_DRAW) {
_lv_obj_refresh_ext_draw_pad(obj); _lv_obj_refresh_ext_draw_pad(obj);
+6
View File
@@ -244,6 +244,12 @@ static inline lv_coord_t lv_obj_get_style_pad_left(const struct _lv_obj_t * obj,
static inline lv_coord_t lv_obj_get_style_pad_right(const struct _lv_obj_t * obj, uint32_t part) { static inline lv_coord_t lv_obj_get_style_pad_right(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_RIGHT); return v.num; } lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_RIGHT); return v.num; }
static inline lv_coord_t lv_obj_get_style_pad_row(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_ROW); return v.num; }
static inline lv_coord_t lv_obj_get_style_pad_column(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_COLUMN); return v.num; }
static inline lv_color_t lv_obj_get_style_bg_color(const struct _lv_obj_t * obj, uint32_t part) { static inline lv_color_t lv_obj_get_style_bg_color(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_COLOR); return v.color; } lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_COLOR); return v.color; }
+24 -2
View File
@@ -71,7 +71,7 @@ void lv_style_init(lv_style_t * style)
uint16_t lv_style_register_prop(bool inherit) uint16_t lv_style_register_prop(bool inherit)
{ {
static uint16_t act_id = (uint16_t)_LV_STYLE_LAST_BUIL_IN_PROP; static uint16_t act_id = (uint16_t)_LV_STYLE_LAST_BUILT_IN_PROP;
act_id++; act_id++;
if(inherit) return act_id | LV_STYLE_PROP_INHERIT; if(inherit) return act_id | LV_STYLE_PROP_INHERIT;
else return act_id; else return act_id;
@@ -444,10 +444,20 @@ static void set_prop(lv_style_t * style, lv_style_prop_t prop, lv_style_value_t
} else { } else {
_alloc_ext(style); _alloc_ext(style);
style->ext->pad_right = value.num; style->ext->pad_right = value.num;
style->ext->pad_right = 1; style->ext->has.pad_right = 1;
style->pad_right = 0; style->pad_right = 0;
} }
break; break;
case LV_STYLE_PAD_ROW:
_alloc_ext(style);
style->ext->pad_row = value.num;
style->ext->has.pad_row = 1;
break;
case LV_STYLE_PAD_COLUMN:
_alloc_ext(style);
style->ext->pad_column = value.num;
style->ext->has.pad_column = 1;
break;
case LV_STYLE_BG_COLOR: case LV_STYLE_BG_COLOR:
id= style->dont_index ? 0 : alloc_index_color(value); id= style->dont_index ? 0 : alloc_index_color(value);
@@ -862,6 +872,12 @@ static bool get_prop(const lv_style_t * style, lv_style_prop_t prop, lv_style_va
if(style->pad_right) { value->num = buf_num[style->pad_right]; return true; } if(style->pad_right) { value->num = buf_num[style->pad_right]; return true; }
if(style->ext && style->ext->has.pad_top) { value->num = style->ext->pad_right; return true; } if(style->ext && style->ext->has.pad_top) { value->num = style->ext->pad_right; return true; }
break; break;
case LV_STYLE_PAD_ROW:
if(style->ext && style->ext->has.pad_row) { value->num = style->ext->pad_row; return true; }
break;
case LV_STYLE_PAD_COLUMN:
if(style->ext && style->ext->has.pad_column) { value->num = style->ext->pad_column; return true; }
break;
case LV_STYLE_BG_COLOR: case LV_STYLE_BG_COLOR:
case LV_STYLE_BG_COLOR_FILTERED: case LV_STYLE_BG_COLOR_FILTERED:
@@ -1109,6 +1125,12 @@ static bool remove_prop(lv_style_t * style, lv_style_prop_t prop)
style->pad_right = 0; style->pad_right = 0;
if(style->ext) style->ext->has.pad_right = 0; if(style->ext) style->ext->has.pad_right = 0;
break; break;
case LV_STYLE_PAD_ROW:
if(style->ext) style->ext->has.pad_row = 0;
break;
case LV_STYLE_PAD_COLUMN:
if(style->ext) style->ext->has.pad_column = 0;
break;
case LV_STYLE_BG_COLOR: case LV_STYLE_BG_COLOR:
style->bg_color = 0; style->bg_color = 0;
+13 -2
View File
@@ -98,6 +98,8 @@ typedef enum {
LV_STYLE_PAD_BOTTOM = 21 | LV_STYLE_PROP_LAYOUT_REFR, LV_STYLE_PAD_BOTTOM = 21 | LV_STYLE_PROP_LAYOUT_REFR,
LV_STYLE_PAD_LEFT = 22 | LV_STYLE_PROP_LAYOUT_REFR, LV_STYLE_PAD_LEFT = 22 | LV_STYLE_PROP_LAYOUT_REFR,
LV_STYLE_PAD_RIGHT = 23 | LV_STYLE_PROP_LAYOUT_REFR, LV_STYLE_PAD_RIGHT = 23 | LV_STYLE_PROP_LAYOUT_REFR,
LV_STYLE_PAD_ROW = 24 | LV_STYLE_PROP_LAYOUT_REFR,
LV_STYLE_PAD_COLUMN = 25 | LV_STYLE_PROP_LAYOUT_REFR,
LV_STYLE_BG_COLOR = 30, LV_STYLE_BG_COLOR = 30,
LV_STYLE_BG_COLOR_FILTERED = 30 | LV_STYLE_PROP_FILTER, LV_STYLE_BG_COLOR_FILTERED = 30 | LV_STYLE_PROP_FILTER,
@@ -162,8 +164,7 @@ typedef enum {
LV_STYLE_CONTENT_OFS_X = 102 | LV_STYLE_PROP_EXT_DRAW, LV_STYLE_CONTENT_OFS_X = 102 | LV_STYLE_PROP_EXT_DRAW,
LV_STYLE_CONTENT_OFS_Y = 103 | LV_STYLE_PROP_EXT_DRAW, LV_STYLE_CONTENT_OFS_Y = 103 | LV_STYLE_PROP_EXT_DRAW,
_LV_STYLE_LAST_BUILT_IN_PROP = 128,
_LV_STYLE_LAST_BUIL_IN_PROP,
LV_STYLE_PROP_ALL = 0xFFFF LV_STYLE_PROP_ALL = 0xFFFF
}lv_style_prop_t; }lv_style_prop_t;
@@ -204,6 +205,8 @@ typedef struct {
int8_t pad_bottom; int8_t pad_bottom;
int8_t pad_left; int8_t pad_left;
int8_t pad_right; int8_t pad_right;
int8_t pad_row;
int8_t pad_column;
int8_t border_width; int8_t border_width;
uint8_t outline_width; uint8_t outline_width;
uint8_t outline_pad; uint8_t outline_pad;
@@ -266,6 +269,8 @@ typedef struct {
uint32_t pad_bottom:1; uint32_t pad_bottom:1;
uint32_t pad_left:1; uint32_t pad_left:1;
uint32_t pad_right:1; uint32_t pad_right:1;
uint32_t pad_row:1;
uint32_t pad_column:1;
uint32_t border_width:1; uint32_t border_width:1;
uint32_t outline_width:1; uint32_t outline_width:1;
uint32_t outline_pad:1; uint32_t outline_pad:1;
@@ -449,6 +454,12 @@ static inline void lv_style_set_pad_left(lv_style_t * style, lv_coord_t value) {
static inline void lv_style_set_pad_right(lv_style_t * style, lv_coord_t value) { static inline void lv_style_set_pad_right(lv_style_t * style, lv_coord_t value) {
lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_PAD_RIGHT, v); } lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_PAD_RIGHT, v); }
static inline void lv_style_set_pad_row(lv_style_t * style, lv_coord_t value) {
lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_PAD_ROW, v); }
static inline void lv_style_set_pad_column(lv_style_t * style, lv_coord_t value) {
lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_PAD_COLUMN, v); }
static inline void lv_style_set_bg_color(lv_style_t * style, lv_color_t value) { static inline void lv_style_set_bg_color(lv_style_t * style, lv_color_t value) {
lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_BG_COLOR, v); } lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_BG_COLOR, v); }
+3 -12
View File
@@ -83,7 +83,6 @@ typedef struct {
**********************/ **********************/
#if LV_MEM_CUSTOM == 0 #if LV_MEM_CUSTOM == 0
static uint8_t * work_mem; static uint8_t * work_mem;
static lv_mem_ent_t * last_ent;
#endif #endif
static uint32_t zero_mem; /*Give the address of this variable if 0 byte should be allocated*/ static uint32_t zero_mem; /*Give the address of this variable if 0 byte should be allocated*/
@@ -336,21 +335,15 @@ void lv_mem_defrag(void)
lv_mem_ent_t * e_free; lv_mem_ent_t * e_free;
lv_mem_ent_t * e_next; lv_mem_ent_t * e_next;
e_free = ent_get_next(NULL); e_free = ent_get_next(NULL);
last_ent = NULL;
while(1) { while(1) {
/*Search the next free entry*/ /*Search the next free entry*/
while(e_free != NULL) { while(e_free != NULL) {
if(e_free->header.s.used != 0) { if(e_free->header.s.used != 0) e_free = ent_get_next(e_free);
e_free = ent_get_next(e_free); else break;
}
else {
break;
}
} }
if(e_free == NULL) return; if(e_free == NULL) return;
if(last_ent == NULL) last_ent = e_free;
/*Joint the following free entries to the free*/ /*Joint the following free entries to the free*/
e_next = ent_get_next(e_free); e_next = ent_get_next(e_free);
@@ -797,8 +790,7 @@ static void * alloc_core(size_t size)
{ {
void * alloc = NULL; void * alloc = NULL;
// lv_mem_ent_t * e = NULL; lv_mem_ent_t * e = NULL;
lv_mem_ent_t * e = last_ent;
/* Search for a appropriate entry*/ /* Search for a appropriate entry*/
if(e == NULL) e = ent_get_next(NULL); if(e == NULL) e = ent_get_next(NULL);
@@ -812,7 +804,6 @@ static void * alloc_core(size_t size)
/* End if the alloc. is successful*/ /* End if the alloc. is successful*/
} while(alloc == NULL); } while(alloc == NULL);
last_ent = e;
return alloc; return alloc;
} }
+1 -13
View File
@@ -77,20 +77,8 @@ const lv_obj_class_t lv_bar = {
*/ */
lv_obj_t * lv_bar_create(lv_obj_t * parent, const lv_obj_t * copy) lv_obj_t * lv_bar_create(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));
obj->class_p = &lv_bar;
if(obj->class_p->ext_size) { return lv_obj_create_from_class(&lv_bar, parent, copy);
obj->ext_attr = lv_mem_alloc(sizeof(lv_bar_ext_t));
_lv_memset_00(obj->ext_attr, sizeof(lv_bar_ext_t));
}
lv_bar.constructor(obj, parent, copy);
lv_obj_create_finish(obj, parent, copy);
return obj;
} }
/*===================== /*=====================
+22 -19
View File
@@ -32,12 +32,20 @@
* STATIC PROTOTYPES * STATIC PROTOTYPES
**********************/ **********************/
static void lv_btn_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); static void lv_btn_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy);
static void lv_btn_destructor(void * obj); static void lv_btn_destructor(lv_obj_t * obj);
static lv_design_res_t lv_btn_design(lv_obj_t * bar, const lv_area_t * clip_area, lv_design_mode_t mode);
static lv_res_t lv_btn_signal(lv_obj_t * bar, lv_signal_t sign, void * param);
/********************** /**********************
* STATIC VARIABLES * STATIC VARIABLES
**********************/ **********************/
lv_btn_class_t lv_btn; const lv_obj_class_t lv_btn = {
.constructor = lv_btn_constructor,
.destructor = lv_btn_destructor,
.signal_cb = lv_btn_signal,
.design_cb = lv_btn_design,
.ext_size = 0,
};
/********************** /**********************
@@ -57,21 +65,8 @@ lv_btn_class_t lv_btn;
*/ */
lv_obj_t * lv_btn_create(lv_obj_t * parent, const lv_obj_t * copy) lv_obj_t * lv_btn_create(lv_obj_t * parent, const lv_obj_t * copy)
{ {
if(!lv_btn._inited) {
LV_CLASS_INIT(lv_btn, lv_obj);
lv_btn.constructor = lv_btn_constructor;
lv_btn.destructor = lv_btn_destructor;
}
lv_obj_t * obj = lv_class_new(&lv_btn);
lv_btn.constructor(obj, parent, copy);
lv_obj_create_finish(obj, parent, copy);
LV_LOG_TRACE("button create started"); LV_LOG_TRACE("button create started");
return obj; return lv_obj_create_from_class(&lv_btn, parent, copy);
} }
/*===================== /*=====================
@@ -91,7 +86,7 @@ static void lv_btn_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t
LV_LOG_TRACE("lv_btn create started"); LV_LOG_TRACE("lv_btn create started");
LV_CLASS_CONSTRUCTOR_BEGIN(obj, lv_btn) LV_CLASS_CONSTRUCTOR_BEGIN(obj, lv_btn)
lv_btn.base_p->constructor(obj, parent, copy); lv_obj.constructor(obj, parent, copy);
lv_obj_set_size(obj, LV_DPI, LV_DPI / 3); lv_obj_set_size(obj, LV_DPI, LV_DPI / 3);
lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE); lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE);
@@ -101,7 +96,7 @@ static void lv_btn_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t
LV_LOG_INFO("btn created"); LV_LOG_INFO("btn created");
} }
static void lv_btn_destructor(void * obj) static void lv_btn_destructor(lv_obj_t * obj)
{ {
// lv_bar_t * bar = obj; // lv_bar_t * bar = obj;
// //
@@ -111,7 +106,15 @@ static void lv_btn_destructor(void * obj)
// lv_anim_del(&bar->start_value_anim, NULL); // lv_anim_del(&bar->start_value_anim, NULL);
//#endif //#endif
lv_btn.base_p->destructor(obj); // lv_btn.base_p->destructor(obj);
}
static lv_design_res_t lv_btn_design(lv_obj_t * obj, const lv_area_t * clip_area, lv_design_mode_t mode)
{
return lv_obj.design_cb(obj, clip_area, mode);
} }
static lv_res_t lv_btn_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
{
return lv_obj.signal_cb(obj, sign, param);
}
#endif #endif
+3 -11
View File
@@ -27,19 +27,11 @@ extern "C" {
* TYPEDEFS * TYPEDEFS
**********************/ **********************/
LV_CLASS_DECLARE_START(lv_btn, lv_obj); typedef struct {
#define _lv_btn_constructor void (*constructor)(struct _lv_obj_t * obj, struct _lv_obj_t * parent, const struct _lv_obj_t * copy) }lv_btn_ext_t;
#define _lv_btn_data \ extern const lv_obj_class_t lv_btn;
_lv_obj_data \
#define _lv_btn_class_dsc \
_lv_obj_class_dsc \
LV_CLASS_DECLARE_END(lv_btn, lv_obj);
extern lv_btn_class_t lv_btn;
/********************** /**********************
-5
View File
@@ -32,7 +32,6 @@
**********************/ **********************/
static lv_res_t lv_btnmatrix_signal(lv_obj_t * btnm, lv_signal_t sign, void * param); static lv_res_t lv_btnmatrix_signal(lv_obj_t * btnm, lv_signal_t sign, void * param);
static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * clip_area, lv_design_mode_t mode); static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * clip_area, lv_design_mode_t mode);
static lv_style_list_t * lv_btnmatrix_get_style(lv_obj_t * btnm, uint8_t part);
static uint8_t get_button_width(lv_btnmatrix_ctrl_t ctrl_bits); static uint8_t get_button_width(lv_btnmatrix_ctrl_t ctrl_bits);
static bool button_is_hidden(lv_btnmatrix_ctrl_t ctrl_bits); static bool button_is_hidden(lv_btnmatrix_ctrl_t ctrl_bits);
@@ -98,10 +97,6 @@ lv_obj_t * lv_btnmatrix_create(lv_obj_t * par, const lv_obj_t * copy)
ext->map_p = NULL; ext->map_p = NULL;
ext->recolor = 0; ext->recolor = 0;
ext->one_check = 0; ext->one_check = 0;
lv_style_list_init(&ext->style_btn);
lv_style_list_init(&ext->style_btn2);
ext->style_btn.ignore_trans = 1;
ext->style_btn2.ignore_trans = 1;
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_cb(btnm); if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_cb(btnm);
-2
View File
@@ -53,8 +53,6 @@ typedef struct {
const char ** map_p; /*Pointer to the current map*/ const char ** map_p; /*Pointer to the current map*/
lv_area_t * button_areas; /*Array of areas of buttons*/ lv_area_t * button_areas; /*Array of areas of buttons*/
lv_btnmatrix_ctrl_t * ctrl_bits; /*Array of control bytes*/ lv_btnmatrix_ctrl_t * ctrl_bits; /*Array of control bytes*/
lv_style_list_t style_btn; /*Styles of buttons in each state*/
lv_style_list_t style_btn2; /*Styles of buttons in each state with LV_BTNMATRIX_CTRL_TYPE_2 control*/
uint16_t btn_cnt; /*Number of button in 'map_p'(Handled by the library)*/ uint16_t btn_cnt; /*Number of button in 'map_p'(Handled by the library)*/
uint16_t btn_id_pr; /*Index of the currently pressed button or LV_BTNMATRIX_BTN_NONE*/ uint16_t btn_id_pr; /*Index of the currently pressed button or LV_BTNMATRIX_BTN_NONE*/
uint16_t btn_id_focused; /*Index of the currently focused button or LV_BTNMATRIX_BTN_NONE*/ uint16_t btn_id_focused; /*Index of the currently focused button or LV_BTNMATRIX_BTN_NONE*/
+1 -17
View File
@@ -68,24 +68,8 @@ const lv_obj_class_t lv_slider = {
*/ */
lv_obj_t * lv_slider_create(lv_obj_t * parent, const lv_obj_t * copy) lv_obj_t * lv_slider_create(lv_obj_t * parent, const lv_obj_t * copy)
{ {
LV_LOG_TRACE("slider create started");
lv_obj_t * obj = lv_mem_alloc(sizeof(lv_obj_t)); return lv_obj_create_from_class(&lv_slider, parent, copy);
_lv_memset_00(obj, sizeof(lv_obj_t));
obj->class_p = &lv_slider;
if(obj->class_p->ext_size) {
obj->ext_attr = lv_mem_alloc(sizeof(lv_slider_ext_t));
_lv_memset_00(obj->ext_attr, sizeof(lv_slider_ext_t));
}
lv_slider.constructor(obj, parent, copy);
lv_obj_create_finish(obj, parent, copy);
LV_LOG_INFO("slider created");
return obj;
} }
/*===================== /*=====================