From 52f1b0979e534b62e343e2cea4e1e30be41e0bf7 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 13 Apr 2021 13:23:52 +0200 Subject: [PATCH] fix(grid) rename column/row_template to column/row_dsc_array to add more meaning for binding generators --- examples/layouts/grid/lv_example_grid_1.c | 4 +- examples/layouts/grid/lv_example_grid_2.c | 2 +- examples/layouts/grid/lv_example_grid_3.c | 2 +- examples/layouts/grid/lv_example_grid_4.c | 2 +- examples/layouts/grid/lv_example_grid_5.c | 2 +- examples/layouts/grid/lv_example_grid_6.c | 2 +- src/extra/layouts/grid/lv_grid.c | 46 +++++++++++------------ src/extra/layouts/grid/lv_grid.h | 41 ++++++++++---------- 8 files changed, 49 insertions(+), 52 deletions(-) diff --git a/examples/layouts/grid/lv_example_grid_1.c b/examples/layouts/grid/lv_example_grid_1.c index 1fed58371..05ddcb4af 100644 --- a/examples/layouts/grid/lv_example_grid_1.c +++ b/examples/layouts/grid/lv_example_grid_1.c @@ -11,8 +11,8 @@ void lv_example_grid_1(void) /*Create a container with grid*/ lv_obj_t * cont = lv_obj_create(lv_scr_act()); - lv_obj_set_style_grid_column_template(cont, col_dsc, 0); - lv_obj_set_style_grid_row_template(cont, row_dsc, 0); + lv_obj_set_style_grid_column_dsc_array(cont, col_dsc, 0); + lv_obj_set_style_grid_row_dsc_array(cont, row_dsc, 0); lv_obj_set_size(cont, 300, 220); lv_obj_center(cont); lv_obj_set_layout(cont, LV_LAYOUT_GRID); diff --git a/examples/layouts/grid/lv_example_grid_2.c b/examples/layouts/grid/lv_example_grid_2.c index 69db45aaf..09cd34c79 100644 --- a/examples/layouts/grid/lv_example_grid_2.c +++ b/examples/layouts/grid/lv_example_grid_2.c @@ -12,7 +12,7 @@ void lv_example_grid_2(void) /*Create a container with grid*/ lv_obj_t * cont = lv_obj_create(lv_scr_act()); - lv_obj_set_grid_template(cont, col_dsc, row_dsc); + lv_obj_set_grid_dsc_array(cont, col_dsc, row_dsc); lv_obj_set_size(cont, 300, 220); lv_obj_center(cont); diff --git a/examples/layouts/grid/lv_example_grid_3.c b/examples/layouts/grid/lv_example_grid_3.c index 8f886af6b..82cf2831a 100644 --- a/examples/layouts/grid/lv_example_grid_3.c +++ b/examples/layouts/grid/lv_example_grid_3.c @@ -20,7 +20,7 @@ void lv_example_grid_3(void) lv_obj_t * cont = lv_obj_create(lv_scr_act()); lv_obj_set_size(cont, 300, 220); lv_obj_center(cont); - lv_obj_set_grid_template(cont, col_dsc, row_dsc); + lv_obj_set_grid_dsc_array(cont, col_dsc, row_dsc); lv_obj_t * label; lv_obj_t * obj; diff --git a/examples/layouts/grid/lv_example_grid_4.c b/examples/layouts/grid/lv_example_grid_4.c index 4cf291668..55076c492 100644 --- a/examples/layouts/grid/lv_example_grid_4.c +++ b/examples/layouts/grid/lv_example_grid_4.c @@ -15,7 +15,7 @@ void lv_example_grid_4(void) /*Create a container with grid*/ lv_obj_t * cont = lv_obj_create(lv_scr_act()); lv_obj_set_grid_place(cont, LV_GRID_SPACE_BETWEEN, LV_GRID_END); - lv_obj_set_grid_template(cont, col_dsc, row_dsc); + lv_obj_set_grid_dsc_array(cont, col_dsc, row_dsc); lv_obj_set_size(cont, 300, 220); lv_obj_center(cont); diff --git a/examples/layouts/grid/lv_example_grid_5.c b/examples/layouts/grid/lv_example_grid_5.c index 25a8df5c1..5623f7170 100644 --- a/examples/layouts/grid/lv_example_grid_5.c +++ b/examples/layouts/grid/lv_example_grid_5.c @@ -25,7 +25,7 @@ void lv_example_grid_5(void) lv_obj_t * cont = lv_obj_create(lv_scr_act()); lv_obj_set_size(cont, 300, 220); lv_obj_center(cont); - lv_obj_set_grid_template(cont, col_dsc, row_dsc); + lv_obj_set_grid_dsc_array(cont, col_dsc, row_dsc); lv_obj_t * label; lv_obj_t * obj; diff --git a/examples/layouts/grid/lv_example_grid_6.c b/examples/layouts/grid/lv_example_grid_6.c index 32371c7ae..666adb4c4 100644 --- a/examples/layouts/grid/lv_example_grid_6.c +++ b/examples/layouts/grid/lv_example_grid_6.c @@ -15,7 +15,7 @@ void lv_example_grid_6(void) lv_obj_set_size(cont, 300, 220); lv_obj_center(cont); lv_obj_set_base_dir(cont, LV_BIDI_DIR_RTL); - lv_obj_set_grid_template(cont, col_dsc, row_dsc); + lv_obj_set_grid_dsc_array(cont, col_dsc, row_dsc); lv_obj_t * label; lv_obj_t * obj; diff --git a/src/extra/layouts/grid/lv_grid.c b/src/extra/layouts/grid/lv_grid.c index 2be81fe3c..171b3144d 100644 --- a/src/extra/layouts/grid/lv_grid.c +++ b/src/extra/layouts/grid/lv_grid.c @@ -57,24 +57,24 @@ static void item_repos(lv_obj_t * item, _lv_grid_calc_t * c, item_repos_hint_t * 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); static uint32_t count_tracks(const lv_coord_t * templ); -static inline const lv_coord_t * get_col_templ(lv_obj_t * obj) {return lv_obj_get_style_grid_column_template(obj, LV_PART_MAIN); } -static inline const lv_coord_t * get_row_templ(lv_obj_t * obj) {return lv_obj_get_style_grid_row_template(obj, LV_PART_MAIN); } -static inline uint8_t get_col_pos(lv_obj_t * obj) {return lv_obj_get_style_grid_cell_column_pos(obj, LV_PART_MAIN); } -static inline uint8_t get_row_pos(lv_obj_t * obj) {return lv_obj_get_style_grid_cell_row_pos(obj, LV_PART_MAIN); } -static inline uint8_t get_col_span(lv_obj_t * obj) {return lv_obj_get_style_grid_cell_column_span(obj, LV_PART_MAIN); } -static inline uint8_t get_row_span(lv_obj_t * obj) {return lv_obj_get_style_grid_cell_row_span(obj, LV_PART_MAIN); } -static inline uint8_t get_cell_col_place(lv_obj_t * obj) {return lv_obj_get_style_grid_cell_x_place(obj, LV_PART_MAIN); } -static inline uint8_t get_cell_row_place(lv_obj_t * obj) {return lv_obj_get_style_grid_cell_y_place(obj, LV_PART_MAIN); } -static inline uint8_t get_grid_col_place(lv_obj_t * obj) {return lv_obj_get_style_grid_column_place(obj, LV_PART_MAIN); } -static inline uint8_t get_grid_row_place(lv_obj_t * obj) {return lv_obj_get_style_grid_row_place(obj, LV_PART_MAIN); } +static inline const lv_coord_t * get_col_dsc(lv_obj_t * obj) {return lv_obj_get_style_grid_column_dsc_array(obj, 0); } +static inline const lv_coord_t * get_row_dsc(lv_obj_t * obj) {return lv_obj_get_style_grid_row_dsc_array(obj, 0); } +static inline uint8_t get_col_pos(lv_obj_t * obj) {return lv_obj_get_style_grid_cell_column_pos(obj, 0); } +static inline uint8_t get_row_pos(lv_obj_t * obj) {return lv_obj_get_style_grid_cell_row_pos(obj, 0); } +static inline uint8_t get_col_span(lv_obj_t * obj) {return lv_obj_get_style_grid_cell_column_span(obj, 0); } +static inline uint8_t get_row_span(lv_obj_t * obj) {return lv_obj_get_style_grid_cell_row_span(obj, 0); } +static inline uint8_t get_cell_col_place(lv_obj_t * obj) {return lv_obj_get_style_grid_cell_x_place(obj, 0); } +static inline uint8_t get_cell_row_place(lv_obj_t * obj) {return lv_obj_get_style_grid_cell_y_place(obj, 0); } +static inline uint8_t get_grid_col_place(lv_obj_t * obj) {return lv_obj_get_style_grid_column_place(obj, 0); } +static inline uint8_t get_grid_row_place(lv_obj_t * obj) {return lv_obj_get_style_grid_row_place(obj, 0); } /********************** * GLOBAL VARIABLES **********************/ uint32_t LV_LAYOUT_GRID; -lv_style_prop_t LV_STYLE_GRID_COL_TEMPLATE; -lv_style_prop_t LV_STYLE_GRID_COL_PLACE; -lv_style_prop_t LV_STYLE_GRID_ROW_TEMPLATE; +lv_style_prop_t LV_STYLE_GRID_COLUMN_DSC_ARRAY; +lv_style_prop_t LV_STYLE_GRID_COLUMN_PLACE; +lv_style_prop_t LV_STYLE_GRID_ROW_DSC_ARRAY; lv_style_prop_t LV_STYLE_GRID_ROW_PLACE; lv_style_prop_t LV_STYLE_GRID_CELL_COL_POS; lv_style_prop_t LV_STYLE_GRID_CELL_COL_SPAN; @@ -100,9 +100,9 @@ void lv_grid_init(void) { LV_LAYOUT_GRID = lv_layout_register(grid_update); - LV_STYLE_GRID_COL_TEMPLATE = lv_style_register_prop() | LV_STYLE_PROP_LAYOUT_REFR; - LV_STYLE_GRID_ROW_TEMPLATE = lv_style_register_prop() | LV_STYLE_PROP_LAYOUT_REFR; - LV_STYLE_GRID_COL_PLACE = lv_style_register_prop() | LV_STYLE_PROP_LAYOUT_REFR; + LV_STYLE_GRID_COLUMN_DSC_ARRAY = lv_style_register_prop() | LV_STYLE_PROP_LAYOUT_REFR; + LV_STYLE_GRID_ROW_DSC_ARRAY = lv_style_register_prop() | LV_STYLE_PROP_LAYOUT_REFR; + LV_STYLE_GRID_COLUMN_PLACE = lv_style_register_prop() | LV_STYLE_PROP_LAYOUT_REFR; LV_STYLE_GRID_ROW_PLACE = lv_style_register_prop() | LV_STYLE_PROP_LAYOUT_REFR; LV_STYLE_GRID_CELL_ROW_SPAN = lv_style_register_prop() | LV_STYLE_PROP_LAYOUT_REFR; @@ -113,10 +113,10 @@ void lv_grid_init(void) LV_STYLE_GRID_CELL_ROW_PLACE = lv_style_register_prop() | LV_STYLE_PROP_LAYOUT_REFR; } -void lv_obj_set_grid_template(lv_obj_t * obj, const lv_coord_t * col_templ, const lv_coord_t * row_templ) +void lv_obj_set_grid_dsc_array(lv_obj_t * obj, const lv_coord_t col_dsc[], const lv_coord_t row_dsc[]) { - lv_obj_set_style_grid_column_template(obj, col_templ, 0); - lv_obj_set_style_grid_row_template(obj, row_templ, 0); + lv_obj_set_style_grid_column_dsc_array(obj, col_dsc, 0); + lv_obj_set_style_grid_row_dsc_array(obj, row_dsc, 0); lv_obj_set_style_layout(obj, LV_LAYOUT_GRID, 0); } @@ -150,8 +150,8 @@ static void grid_update(lv_obj_t * cont) { LV_LOG_INFO("update %p container", cont); - const lv_coord_t * col_templ = get_col_templ(cont); - const lv_coord_t * row_templ = get_row_templ(cont); + const lv_coord_t * col_templ = get_col_dsc(cont); + const lv_coord_t * row_templ = get_row_dsc(cont); if(col_templ == NULL || row_templ == NULL) return; _lv_grid_calc_t c; @@ -231,7 +231,7 @@ static void calc_free(_lv_grid_calc_t * calc) static void calc_cols(lv_obj_t * cont, _lv_grid_calc_t * c) { - const lv_coord_t * col_templ = get_col_templ(cont); + const lv_coord_t * col_templ = get_col_dsc(cont); lv_coord_t cont_w = lv_obj_get_width_fit(cont); c->col_num = count_tracks(col_templ); @@ -295,7 +295,7 @@ static void calc_cols(lv_obj_t * cont, _lv_grid_calc_t * c) static void calc_rows(lv_obj_t * cont, _lv_grid_calc_t * c) { uint32_t i; - const lv_coord_t * row_templ = get_row_templ(cont); + const lv_coord_t * row_templ = get_row_dsc(cont); c->row_num = count_tracks(row_templ); c->y = lv_mem_buf_get(sizeof(lv_coord_t) * c->row_num); c->h = lv_mem_buf_get(sizeof(lv_coord_t) * c->row_num); diff --git a/src/extra/layouts/grid/lv_grid.h b/src/extra/layouts/grid/lv_grid.h index f7cfe46cc..c2c37a9f2 100644 --- a/src/extra/layouts/grid/lv_grid.h +++ b/src/extra/layouts/grid/lv_grid.h @@ -50,9 +50,9 @@ typedef enum { **********************/ extern uint32_t LV_LAYOUT_GRID; -extern lv_style_prop_t LV_STYLE_GRID_COL_TEMPLATE; -extern lv_style_prop_t LV_STYLE_GRID_COL_PLACE; -extern lv_style_prop_t LV_STYLE_GRID_ROW_TEMPLATE; +extern lv_style_prop_t LV_STYLE_GRID_COLUMN_DSC_ARRAY; +extern lv_style_prop_t LV_STYLE_GRID_COLUMN_PLACE; +extern lv_style_prop_t LV_STYLE_GRID_ROW_DSC_ARRAY; extern lv_style_prop_t LV_STYLE_GRID_ROW_PLACE; extern lv_style_prop_t LV_STYLE_GRID_CELL_COL_POS; extern lv_style_prop_t LV_STYLE_GRID_CELL_COL_SPAN; @@ -67,7 +67,7 @@ extern lv_style_prop_t LV_STYLE_GRID_CELL_ROW_PLACE; void lv_grid_init(void); -void lv_obj_set_grid_template(lv_obj_t * obj, const lv_coord_t * col_templ, const lv_coord_t * row_templ); +void lv_obj_set_grid_dsc_array(lv_obj_t * obj, const lv_coord_t col_templ[], const lv_coord_t row_templ[]); void lv_obj_set_grid_place(lv_obj_t * obj, lv_grid_place_t hor_place, lv_grid_place_t ver_place); @@ -92,20 +92,20 @@ static inline lv_coord_t lv_grid_fr(uint8_t x) return LV_GRID_FR(x); } -static inline void lv_style_set_grid_row_template(lv_style_t * style, const lv_coord_t value[]) +static inline void lv_style_set_grid_row_dsc_array(lv_style_t * style, const lv_coord_t value[]) { lv_style_value_t v = { .ptr = (const void *)value }; - lv_style_set_prop(style, LV_STYLE_GRID_ROW_TEMPLATE, v); + lv_style_set_prop(style, LV_STYLE_GRID_ROW_DSC_ARRAY, v); } -static inline void lv_style_set_grid_column_template(lv_style_t * style, const lv_coord_t value[]) +static inline void lv_style_set_grid_column_dsc_array(lv_style_t * style, const lv_coord_t value[]) { lv_style_value_t v = { .ptr = (const void *)value }; - lv_style_set_prop(style, LV_STYLE_GRID_COL_TEMPLATE, v); + lv_style_set_prop(style, LV_STYLE_GRID_COLUMN_DSC_ARRAY, v); } static inline void lv_style_set_grid_row_place(lv_style_t * style, lv_grid_place_t value) @@ -121,7 +121,7 @@ static inline void lv_style_set_grid_col_place(lv_style_t * style, lv_grid_place lv_style_value_t v = { .num = (lv_grid_place_t)value }; - lv_style_set_prop(style, LV_STYLE_GRID_COL_PLACE, v); + lv_style_set_prop(style, LV_STYLE_GRID_COLUMN_PLACE, v); } @@ -173,20 +173,20 @@ static inline void lv_style_set_grid_cell_y_place(lv_style_t * style, lv_coord_t lv_style_set_prop(style, LV_STYLE_GRID_CELL_ROW_PLACE, v); } -static inline void lv_obj_set_style_grid_row_template(lv_obj_t * obj, const lv_coord_t value[], lv_style_selector_t selector) +static inline void lv_obj_set_style_grid_row_dsc_array(lv_obj_t * obj, const lv_coord_t value[], lv_style_selector_t selector) { lv_style_value_t v = { .ptr = (const void *)value }; - lv_obj_set_local_style_prop(obj,LV_STYLE_GRID_ROW_TEMPLATE, v, selector); + lv_obj_set_local_style_prop(obj,LV_STYLE_GRID_ROW_DSC_ARRAY, v, selector); } -static inline void lv_obj_set_style_grid_column_template(lv_obj_t * obj, const lv_coord_t value[], lv_style_selector_t selector) +static inline void lv_obj_set_style_grid_column_dsc_array(lv_obj_t * obj, const lv_coord_t value[], lv_style_selector_t selector) { lv_style_value_t v = { .ptr = (const void *)value }; - lv_obj_set_local_style_prop(obj, LV_STYLE_GRID_COL_TEMPLATE, v, selector); + lv_obj_set_local_style_prop(obj, LV_STYLE_GRID_COLUMN_DSC_ARRAY, v, selector); } @@ -203,7 +203,7 @@ static inline void lv_obj_set_style_grid_column_place(lv_obj_t * obj, lv_grid_pl lv_style_value_t v = { .num = (int32_t) value }; - lv_obj_set_local_style_prop(obj, LV_STYLE_GRID_COL_PLACE, v, selector); + lv_obj_set_local_style_prop(obj, LV_STYLE_GRID_COLUMN_PLACE, v, selector); } @@ -255,18 +255,15 @@ static inline void lv_obj_set_style_grid_cell_y_place(lv_obj_t * obj, lv_coord_t lv_obj_set_local_style_prop(obj, LV_STYLE_GRID_CELL_ROW_PLACE, v, selector); } - - - -static inline const lv_coord_t * lv_obj_get_style_grid_row_template(const struct _lv_obj_t * obj, uint32_t part) +static inline const lv_coord_t * lv_obj_get_style_grid_row_dsc_array(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_GRID_ROW_TEMPLATE); + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_GRID_ROW_DSC_ARRAY); return (const lv_coord_t *)v.ptr; } -static inline const lv_coord_t * lv_obj_get_style_grid_column_template(const struct _lv_obj_t * obj, uint32_t part) +static inline const lv_coord_t * lv_obj_get_style_grid_column_dsc_array(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_GRID_COL_TEMPLATE); + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_GRID_COLUMN_DSC_ARRAY); return (const lv_coord_t *)v.ptr; } @@ -278,7 +275,7 @@ static inline lv_grid_place_t lv_obj_get_style_grid_row_place(const struct _lv_o static inline lv_grid_place_t lv_obj_get_style_grid_column_place(const struct _lv_obj_t * obj, uint32_t part) { - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_GRID_COL_PLACE); + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_GRID_COLUMN_PLACE); return (lv_grid_place_t)v.num; }