diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-06-01 15:41:47 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-06-01 15:41:47 +1000 |
| commit | dd27c3530432ea0b09f01e604bf577f31d8ef841 (patch) | |
| tree | bbf86cf81a78f0ff0b07f31f1c390db473f26fd3 /lib/lvgl/examples/layouts/grid | |
| parent | 6fd588e970470b15936187980829916d0dbe77bb (diff) | |
| download | tangara-fw-dd27c3530432ea0b09f01e604bf577f31d8ef841.tar.gz | |
convert lvgl from submodule to a plain old directory
Diffstat (limited to 'lib/lvgl/examples/layouts/grid')
| m--------- | lib/lvgl | 0 | ||||
| -rw-r--r-- | lib/lvgl/examples/layouts/grid/index.rst | 37 | ||||
| -rw-r--r-- | lib/lvgl/examples/layouts/grid/lv_example_grid.h | 43 | ||||
| -rw-r--r-- | lib/lvgl/examples/layouts/grid/lv_example_grid_1.c | 40 | ||||
| -rw-r--r-- | lib/lvgl/examples/layouts/grid/lv_example_grid_1.py | 29 | ||||
| -rw-r--r-- | lib/lvgl/examples/layouts/grid/lv_example_grid_2.c | 63 | ||||
| -rw-r--r-- | lib/lvgl/examples/layouts/grid/lv_example_grid_2.py | 52 | ||||
| -rw-r--r-- | lib/lvgl/examples/layouts/grid/lv_example_grid_3.c | 44 | ||||
| -rw-r--r-- | lib/lvgl/examples/layouts/grid/lv_example_grid_3.py | 36 | ||||
| -rw-r--r-- | lib/lvgl/examples/layouts/grid/lv_example_grid_4.c | 41 | ||||
| -rw-r--r-- | lib/lvgl/examples/layouts/grid/lv_example_grid_4.py | 32 | ||||
| -rw-r--r-- | lib/lvgl/examples/layouts/grid/lv_example_grid_5.c | 63 | ||||
| -rw-r--r-- | lib/lvgl/examples/layouts/grid/lv_example_grid_5.py | 52 | ||||
| -rw-r--r-- | lib/lvgl/examples/layouts/grid/lv_example_grid_6.c | 39 | ||||
| -rw-r--r-- | lib/lvgl/examples/layouts/grid/lv_example_grid_6.py | 27 |
15 files changed, 598 insertions, 0 deletions
diff --git a/lib/lvgl b/lib/lvgl deleted file mode 160000 -Subproject 0732400e7b564dd0e7dc4a924619d8e19c5b23a diff --git a/lib/lvgl/examples/layouts/grid/index.rst b/lib/lvgl/examples/layouts/grid/index.rst new file mode 100644 index 00000000..fca02189 --- /dev/null +++ b/lib/lvgl/examples/layouts/grid/index.rst @@ -0,0 +1,37 @@ +A simple grid +""""""""""""""" + +.. lv_example:: layouts/grid/lv_example_grid_1 + :language: c + +Demonstrate cell placement and span +""""""""""""""""""""""""""""""""""""""""""""""""" + +.. lv_example:: layouts/grid/lv_example_grid_2 + :language: c + +Demonstrate grid's "free unit" +"""""""""""""""""""""""""""""" + +.. lv_example:: layouts/grid/lv_example_grid_3 + :language: c + +Demonstrate track placement +""""""""""""""""""""""""""" + +.. lv_example:: layouts/grid/lv_example_grid_4 + :language: c + +Demonstrate column and row gap +"""""""""""""""""""""""""""""" + +.. lv_example:: layouts/grid/lv_example_grid_5 + :language: c + +Demonstrate RTL direction on grid +"""""""""""""""""""""""""""""""""" + +.. lv_example:: layouts/grid/lv_example_grid_6 + :language: c + + diff --git a/lib/lvgl/examples/layouts/grid/lv_example_grid.h b/lib/lvgl/examples/layouts/grid/lv_example_grid.h new file mode 100644 index 00000000..c0b8bae5 --- /dev/null +++ b/lib/lvgl/examples/layouts/grid/lv_example_grid.h @@ -0,0 +1,43 @@ +/** + * @file lv_example_grid.h + * + */ + +#ifndef LV_EXAMPLE_GRID_H +#define LV_EXAMPLE_GRID_H + +#ifdef __cplusplus +extern "C" { +#endif + +/********************* + * INCLUDES + *********************/ + +/********************* + * DEFINES + *********************/ + +/********************** + * TYPEDEFS + **********************/ + +/********************** + * GLOBAL PROTOTYPES + **********************/ +void lv_example_grid_1(void); +void lv_example_grid_2(void); +void lv_example_grid_3(void); +void lv_example_grid_4(void); +void lv_example_grid_5(void); +void lv_example_grid_6(void); + +/********************** + * MACROS + **********************/ + +#ifdef __cplusplus +} /*extern "C"*/ +#endif + +#endif /*LV_EXAMPLE_GRID_H*/ diff --git a/lib/lvgl/examples/layouts/grid/lv_example_grid_1.c b/lib/lvgl/examples/layouts/grid/lv_example_grid_1.c new file mode 100644 index 00000000..47fbf74a --- /dev/null +++ b/lib/lvgl/examples/layouts/grid/lv_example_grid_1.c @@ -0,0 +1,40 @@ +#include "../../lv_examples.h" +#if LV_USE_GRID && LV_BUILD_EXAMPLES + +/** + * A simple grid + */ +void lv_example_grid_1(void) +{ + static lv_coord_t col_dsc[] = {70, 70, 70, LV_GRID_TEMPLATE_LAST}; + static lv_coord_t row_dsc[] = {50, 50, 50, LV_GRID_TEMPLATE_LAST}; + + /*Create a container with grid*/ + lv_obj_t * cont = lv_obj_create(lv_scr_act()); + 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); + + lv_obj_t * label; + lv_obj_t * obj; + + uint32_t i; + for(i = 0; i < 9; i++) { + uint8_t col = i % 3; + uint8_t row = i / 3; + + obj = lv_btn_create(cont); + /*Stretch the cell horizontally and vertically too + *Set span to 1 to make the cell 1 column/row sized*/ + lv_obj_set_grid_cell(obj, LV_GRID_ALIGN_STRETCH, col, 1, + LV_GRID_ALIGN_STRETCH, row, 1); + + label = lv_label_create(obj); + lv_label_set_text_fmt(label, "c%d, r%d", col, row); + lv_obj_center(label); + } +} + +#endif diff --git a/lib/lvgl/examples/layouts/grid/lv_example_grid_1.py b/lib/lvgl/examples/layouts/grid/lv_example_grid_1.py new file mode 100644 index 00000000..433ffc67 --- /dev/null +++ b/lib/lvgl/examples/layouts/grid/lv_example_grid_1.py @@ -0,0 +1,29 @@ +# +# A simple grid +# + +col_dsc = [70, 70, 70, lv.GRID_TEMPLATE.LAST] +row_dsc = [50, 50, 50, lv.GRID_TEMPLATE.LAST] + +# Create a container with grid +cont = lv.obj(lv.scr_act()) +cont.set_style_grid_column_dsc_array(col_dsc, 0) +cont.set_style_grid_row_dsc_array(row_dsc, 0) +cont.set_size(300, 220) +cont.center() +cont.set_layout(lv.LAYOUT_GRID.value) + +for i in range(9): + col = i % 3 + row = i // 3 + + obj = lv.btn(cont) + # Stretch the cell horizontally and vertically too + # Set span to 1 to make the cell 1 column/row sized + obj.set_grid_cell(lv.GRID_ALIGN.STRETCH, col, 1, + lv.GRID_ALIGN.STRETCH, row, 1) + + label = lv.label(obj) + label.set_text("c" +str(col) + "r" +str(row)) + label.center() + diff --git a/lib/lvgl/examples/layouts/grid/lv_example_grid_2.c b/lib/lvgl/examples/layouts/grid/lv_example_grid_2.c new file mode 100644 index 00000000..f992c57a --- /dev/null +++ b/lib/lvgl/examples/layouts/grid/lv_example_grid_2.c @@ -0,0 +1,63 @@ +#include "../../lv_examples.h" +#if LV_USE_GRID && LV_BUILD_EXAMPLES + + +/** + * Demonstrate cell placement and span + */ +void lv_example_grid_2(void) +{ + static lv_coord_t col_dsc[] = {70, 70, 70, LV_GRID_TEMPLATE_LAST}; + static lv_coord_t row_dsc[] = {50, 50, 50, LV_GRID_TEMPLATE_LAST}; + + /*Create a container with grid*/ + lv_obj_t * cont = lv_obj_create(lv_scr_act()); + lv_obj_set_grid_dsc_array(cont, col_dsc, row_dsc); + lv_obj_set_size(cont, 300, 220); + lv_obj_center(cont); + + lv_obj_t * label; + lv_obj_t * obj; + + /*Cell to 0;0 and align to to the start (left/top) horizontally and vertically too*/ + obj = lv_obj_create(cont); + lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT); + lv_obj_set_grid_cell(obj, LV_GRID_ALIGN_START, 0, 1, + LV_GRID_ALIGN_START, 0, 1); + label = lv_label_create(obj); + lv_label_set_text(label, "c0, r0"); + + /*Cell to 1;0 and align to to the start (left) horizontally and center vertically too*/ + obj = lv_obj_create(cont); + lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT); + lv_obj_set_grid_cell(obj, LV_GRID_ALIGN_START, 1, 1, + LV_GRID_ALIGN_CENTER, 0, 1); + label = lv_label_create(obj); + lv_label_set_text(label, "c1, r0"); + + /*Cell to 2;0 and align to to the start (left) horizontally and end (bottom) vertically too*/ + obj = lv_obj_create(cont); + lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT); + lv_obj_set_grid_cell(obj, LV_GRID_ALIGN_START, 2, 1, + LV_GRID_ALIGN_END, 0, 1); + label = lv_label_create(obj); + lv_label_set_text(label, "c2, r0"); + + /*Cell to 1;1 but 2 column wide (span = 2).Set width and height to stretched.*/ + obj = lv_obj_create(cont); + lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT); + lv_obj_set_grid_cell(obj, LV_GRID_ALIGN_STRETCH, 1, 2, + LV_GRID_ALIGN_STRETCH, 1, 1); + label = lv_label_create(obj); + lv_label_set_text(label, "c1-2, r1"); + + /*Cell to 0;1 but 2 rows tall (span = 2).Set width and height to stretched.*/ + obj = lv_obj_create(cont); + lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT); + lv_obj_set_grid_cell(obj, LV_GRID_ALIGN_STRETCH, 0, 1, + LV_GRID_ALIGN_STRETCH, 1, 2); + label = lv_label_create(obj); + lv_label_set_text(label, "c0\nr1-2"); +} + +#endif diff --git a/lib/lvgl/examples/layouts/grid/lv_example_grid_2.py b/lib/lvgl/examples/layouts/grid/lv_example_grid_2.py new file mode 100644 index 00000000..c713406a --- /dev/null +++ b/lib/lvgl/examples/layouts/grid/lv_example_grid_2.py @@ -0,0 +1,52 @@ +# +# Demonstrate cell placement and span +# + +col_dsc = [70, 70, 70, lv.GRID_TEMPLATE.LAST] +row_dsc = [50, 50, 50, lv.GRID_TEMPLATE.LAST] + +# Create a container with grid +cont = lv.obj(lv.scr_act()) +cont.set_grid_dsc_array(col_dsc, row_dsc) +cont.set_size(300, 220) +cont.center() + +# Cell to 0;0 and align to the start (left/top) horizontally and vertically too +obj = lv.obj(cont) +obj.set_size(lv.SIZE.CONTENT, lv.SIZE.CONTENT) +obj.set_grid_cell(lv.GRID_ALIGN.START, 0, 1, + lv.GRID_ALIGN.START, 0, 1) +label = lv.label(obj) +label.set_text("c0, r0") + +# Cell to 1;0 and align to the start (left) horizontally and center vertically too +obj = lv.obj(cont) +obj.set_size(lv.SIZE.CONTENT, lv.SIZE.CONTENT) +obj.set_grid_cell(lv.GRID_ALIGN.START, 1, 1, + lv.GRID_ALIGN.CENTER, 0, 1) +label = lv.label(obj) +label.set_text("c1, r0") + +# Cell to 2;0 and align to the start (left) horizontally and end (bottom) vertically too +obj = lv.obj(cont) +obj.set_size(lv.SIZE.CONTENT, lv.SIZE.CONTENT) +obj.set_grid_cell(lv.GRID_ALIGN.START, 2, 1, + lv.GRID_ALIGN.END, 0, 1) +label = lv.label(obj) +label.set_text("c2, r0") + +# Cell to 1;1 but 2 column wide (span = 2).Set width and height to stretched. +obj = lv.obj(cont) +obj.set_size(lv.SIZE.CONTENT, lv.SIZE.CONTENT) +obj.set_grid_cell(lv.GRID_ALIGN.STRETCH, 1, 2, + lv.GRID_ALIGN.STRETCH, 1, 1) +label = lv.label(obj) +label.set_text("c1-2, r1") + +# Cell to 0;1 but 2 rows tall (span = 2).Set width and height to stretched. +obj = lv.obj(cont) +obj.set_size(lv.SIZE.CONTENT, lv.SIZE.CONTENT) +obj.set_grid_cell(lv.GRID_ALIGN.STRETCH, 0, 1, + lv.GRID_ALIGN.STRETCH, 1, 2) +label = lv.label(obj) +label.set_text("c0\nr1-2") diff --git a/lib/lvgl/examples/layouts/grid/lv_example_grid_3.c b/lib/lvgl/examples/layouts/grid/lv_example_grid_3.c new file mode 100644 index 00000000..17e4dd90 --- /dev/null +++ b/lib/lvgl/examples/layouts/grid/lv_example_grid_3.c @@ -0,0 +1,44 @@ +#include "../../lv_examples.h" +#if LV_USE_GRID && LV_BUILD_EXAMPLES + +/** + * Demonstrate grid's "free unit" + */ +void lv_example_grid_3(void) +{ + /*Column 1: fix width 60 px + *Column 2: 1 unit from the remaining free space + *Column 3: 2 unit from the remaining free space*/ + static lv_coord_t col_dsc[] = {60, LV_GRID_FR(1), LV_GRID_FR(2), LV_GRID_TEMPLATE_LAST}; + + /*Row 1: fix width 50 px + *Row 2: 1 unit from the remaining free space + *Row 3: fix width 50 px*/ + static lv_coord_t row_dsc[] = {50, LV_GRID_FR(1), 50, LV_GRID_TEMPLATE_LAST}; + + /*Create a container with grid*/ + 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_dsc_array(cont, col_dsc, row_dsc); + + lv_obj_t * label; + lv_obj_t * obj; + uint32_t i; + for(i = 0; i < 9; i++) { + uint8_t col = i % 3; + uint8_t row = i / 3; + + obj = lv_obj_create(cont); + /*Stretch the cell horizontally and vertically too + *Set span to 1 to make the cell 1 column/row sized*/ + lv_obj_set_grid_cell(obj, LV_GRID_ALIGN_STRETCH, col, 1, + LV_GRID_ALIGN_STRETCH, row, 1); + + label = lv_label_create(obj); + lv_label_set_text_fmt(label, "%d,%d", col, row); + lv_obj_center(label); + } +} + +#endif diff --git a/lib/lvgl/examples/layouts/grid/lv_example_grid_3.py b/lib/lvgl/examples/layouts/grid/lv_example_grid_3.py new file mode 100644 index 00000000..e820bdac --- /dev/null +++ b/lib/lvgl/examples/layouts/grid/lv_example_grid_3.py @@ -0,0 +1,36 @@ +# +# Demonstrate grid's "free unit" +# + +# Column 1: fix width 60 px +# Column 2: 1 unit from the remaining free space +# Column 3: 2 unit from the remaining free space + +col_dsc = [60, lv.grid_fr(1), lv.grid_fr(2), lv.GRID_TEMPLATE.LAST] + +# Row 1: fix width 60 px +# Row 2: 1 unit from the remaining free space +# Row 3: fix width 60 px + +row_dsc = [40, lv.grid_fr(1), 40, lv.GRID_TEMPLATE.LAST] + +# Create a container with grid +cont = lv.obj(lv.scr_act()) +cont.set_size(300, 220) +cont.center() +cont.set_grid_dsc_array(col_dsc, row_dsc) + +for i in range(9): + col = i % 3 + row = i // 3 + + obj = lv.obj(cont) + # Stretch the cell horizontally and vertically too + # Set span to 1 to make the cell 1 column/row sized + obj.set_grid_cell(lv.GRID_ALIGN.STRETCH, col, 1, + lv.GRID_ALIGN.STRETCH, row, 1) + + label = lv.label(obj) + label.set_text("%d,%d"%(col, row)) + label.center() + diff --git a/lib/lvgl/examples/layouts/grid/lv_example_grid_4.c b/lib/lvgl/examples/layouts/grid/lv_example_grid_4.c new file mode 100644 index 00000000..51414779 --- /dev/null +++ b/lib/lvgl/examples/layouts/grid/lv_example_grid_4.c @@ -0,0 +1,41 @@ +#include "../../lv_examples.h" +#if LV_USE_GRID && LV_BUILD_EXAMPLES + +/** + * Demonstrate track placement + */ +void lv_example_grid_4(void) +{ + static lv_coord_t col_dsc[] = {60, 60, 60, LV_GRID_TEMPLATE_LAST}; + static lv_coord_t row_dsc[] = {45, 45, 45, LV_GRID_TEMPLATE_LAST}; + + + /*Add space between the columns and move the rows to the bottom (end)*/ + + /*Create a container with grid*/ + lv_obj_t * cont = lv_obj_create(lv_scr_act()); + lv_obj_set_grid_align(cont, LV_GRID_ALIGN_SPACE_BETWEEN, LV_GRID_ALIGN_END); + lv_obj_set_grid_dsc_array(cont, col_dsc, row_dsc); + lv_obj_set_size(cont, 300, 220); + lv_obj_center(cont); + + lv_obj_t * label; + lv_obj_t * obj; + uint32_t i; + for(i = 0; i < 9; i++) { + uint8_t col = i % 3; + uint8_t row = i / 3; + + obj = lv_obj_create(cont); + /*Stretch the cell horizontally and vertically too + *Set span to 1 to make the cell 1 column/row sized*/ + lv_obj_set_grid_cell(obj, LV_GRID_ALIGN_STRETCH, col, 1, + LV_GRID_ALIGN_STRETCH, row, 1); + + label = lv_label_create(obj); + lv_label_set_text_fmt(label, "%d,%d", col, row); + lv_obj_center(label); + } +} + +#endif diff --git a/lib/lvgl/examples/layouts/grid/lv_example_grid_4.py b/lib/lvgl/examples/layouts/grid/lv_example_grid_4.py new file mode 100644 index 00000000..cc2185b7 --- /dev/null +++ b/lib/lvgl/examples/layouts/grid/lv_example_grid_4.py @@ -0,0 +1,32 @@ +# +# Demonstrate track placement +# + +col_dsc = [60, 60, 60, lv.GRID_TEMPLATE.LAST] +row_dsc = [40, 40, 40, lv.GRID_TEMPLATE.LAST] + + +# Add space between the columns and move the rows to the bottom (end) + +# Create a container with grid +cont = lv.obj(lv.scr_act()) +cont.set_grid_align(lv.GRID_ALIGN.SPACE_BETWEEN, lv.GRID_ALIGN.END) +cont.set_grid_dsc_array(col_dsc, row_dsc) +cont.set_size(300, 220) +cont.center() + + +for i in range(9): + col = i % 3 + row = i // 3 + + obj = lv.obj(cont) + # Stretch the cell horizontally and vertically too + # Set span to 1 to make the cell 1 column/row sized + obj.set_grid_cell(lv.GRID_ALIGN.STRETCH, col, 1, + lv.GRID_ALIGN.STRETCH, row, 1) + + label = lv.label(obj) + label.set_text("{:d}{:d}".format(col, row)) + label.center() + diff --git a/lib/lvgl/examples/layouts/grid/lv_example_grid_5.c b/lib/lvgl/examples/layouts/grid/lv_example_grid_5.c new file mode 100644 index 00000000..af96ff82 --- /dev/null +++ b/lib/lvgl/examples/layouts/grid/lv_example_grid_5.c @@ -0,0 +1,63 @@ +#include "../../lv_examples.h" +#if LV_USE_GRID && LV_BUILD_EXAMPLES + +static void row_gap_anim(void * obj, int32_t v) +{ + lv_obj_set_style_pad_row(obj, v, 0); +} + +static void column_gap_anim(void * obj, int32_t v) +{ + lv_obj_set_style_pad_column(obj, v, 0); +} + +/** + * Demonstrate column and row gap + */ +void lv_example_grid_5(void) +{ + + /*60x60 cells*/ + static lv_coord_t col_dsc[] = {60, 60, 60, LV_GRID_TEMPLATE_LAST}; + static lv_coord_t row_dsc[] = {45, 45, 45, LV_GRID_TEMPLATE_LAST}; + + /*Create a container with grid*/ + 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_dsc_array(cont, col_dsc, row_dsc); + + lv_obj_t * label; + lv_obj_t * obj; + uint32_t i; + for(i = 0; i < 9; i++) { + uint8_t col = i % 3; + uint8_t row = i / 3; + + obj = lv_obj_create(cont); + lv_obj_set_grid_cell(obj, LV_GRID_ALIGN_STRETCH, col, 1, + LV_GRID_ALIGN_STRETCH, row, 1); + label = lv_label_create(obj); + lv_label_set_text_fmt(label, "%d,%d", col, row); + lv_obj_center(label); + } + + lv_anim_t a; + lv_anim_init(&a); + lv_anim_set_var(&a, cont); + lv_anim_set_values(&a, 0, 10); + lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE); + + lv_anim_set_exec_cb(&a, row_gap_anim); + lv_anim_set_time(&a, 500); + lv_anim_set_playback_time(&a, 500); + lv_anim_start(&a); + + lv_anim_set_exec_cb(&a, column_gap_anim); + lv_anim_set_time(&a, 3000); + lv_anim_set_playback_time(&a, 3000); + lv_anim_start(&a); +} + +#endif + diff --git a/lib/lvgl/examples/layouts/grid/lv_example_grid_5.py b/lib/lvgl/examples/layouts/grid/lv_example_grid_5.py new file mode 100644 index 00000000..83f500b8 --- /dev/null +++ b/lib/lvgl/examples/layouts/grid/lv_example_grid_5.py @@ -0,0 +1,52 @@ +def row_gap_anim(obj, v): + obj.set_style_pad_row(v, 0) + +def column_gap_anim(obj, v): + obj.set_style_pad_column(v, 0) + +# +# Demonstrate column and row gap +# + +# 60x60 cells +col_dsc = [60, 60, 60, lv.GRID_TEMPLATE.LAST] +row_dsc = [40, 40, 40, lv.GRID_TEMPLATE.LAST] + +# Create a container with grid +cont = lv.obj(lv.scr_act()) +cont.set_size(300, 220) +cont.center() +cont.set_grid_dsc_array(col_dsc, row_dsc) + +for i in range(9): + col = i % 3 + row = i // 3 + + obj = lv.obj(cont) + obj.set_grid_cell(lv.GRID_ALIGN.STRETCH, col, 1, + lv.GRID_ALIGN.STRETCH, row, 1) + label = lv.label(obj) + label.set_text("{:d},{:d}".format(col, row)) + label.center() + + a_row = lv.anim_t() + a_row.init() + a_row.set_var(cont) + a_row.set_values(0, 10) + a_row.set_repeat_count(lv.ANIM_REPEAT.INFINITE) + a_row.set_time(500) + a_row.set_playback_time(500) + a_row. set_custom_exec_cb(lambda a,val: row_gap_anim(cont,val)) + lv.anim_t.start(a_row) + + a_col = lv.anim_t() + a_col.init() + a_col.set_var(cont) + a_col.set_values(0, 10) + a_col.set_repeat_count(lv.ANIM_REPEAT.INFINITE) + a_col.set_time(500) + a_col.set_playback_time(500) + a_col. set_custom_exec_cb(lambda a,val: column_gap_anim(cont,val)) + lv.anim_t.start(a_col) + + diff --git a/lib/lvgl/examples/layouts/grid/lv_example_grid_6.c b/lib/lvgl/examples/layouts/grid/lv_example_grid_6.c new file mode 100644 index 00000000..1c06c980 --- /dev/null +++ b/lib/lvgl/examples/layouts/grid/lv_example_grid_6.c @@ -0,0 +1,39 @@ +#include "../../lv_examples.h" +#if LV_USE_GRID && LV_BUILD_EXAMPLES + +/** + * Demonstrate RTL direction on grid + */ +void lv_example_grid_6(void) +{ + + static lv_coord_t col_dsc[] = {60, 60, 60, LV_GRID_TEMPLATE_LAST}; + static lv_coord_t row_dsc[] = {45, 45, 45, LV_GRID_TEMPLATE_LAST}; + + /*Create a container with grid*/ + lv_obj_t * cont = lv_obj_create(lv_scr_act()); + lv_obj_set_size(cont, 300, 220); + lv_obj_center(cont); + lv_obj_set_style_base_dir(cont, LV_BASE_DIR_RTL, 0); + lv_obj_set_grid_dsc_array(cont, col_dsc, row_dsc); + + lv_obj_t * label; + lv_obj_t * obj; + uint32_t i; + for(i = 0; i < 9; i++) { + uint8_t col = i % 3; + uint8_t row = i / 3; + + obj = lv_obj_create(cont); + /*Stretch the cell horizontally and vertically too + *Set span to 1 to make the cell 1 column/row sized*/ + lv_obj_set_grid_cell(obj, LV_GRID_ALIGN_STRETCH, col, 1, + LV_GRID_ALIGN_STRETCH, row, 1); + + label = lv_label_create(obj); + lv_label_set_text_fmt(label, "%d,%d", col, row); + lv_obj_center(label); + } +} + +#endif diff --git a/lib/lvgl/examples/layouts/grid/lv_example_grid_6.py b/lib/lvgl/examples/layouts/grid/lv_example_grid_6.py new file mode 100644 index 00000000..436c6e4c --- /dev/null +++ b/lib/lvgl/examples/layouts/grid/lv_example_grid_6.py @@ -0,0 +1,27 @@ +# +# Demonstrate RTL direction on grid +# +col_dsc = [60, 60, 60, lv.GRID_TEMPLATE.LAST] +row_dsc = [40, 40, 40, lv.GRID_TEMPLATE.LAST] + +# Create a container with grid +cont = lv.obj(lv.scr_act()) +cont.set_size(300, 220) +cont.center() +cont.set_style_base_dir(lv.BASE_DIR.RTL,0) +cont.set_grid_dsc_array(col_dsc, row_dsc) + +for i in range(9): + col = i % 3 + row = i // 3 + + obj = lv.obj(cont) + # Stretch the cell horizontally and vertically too + # Set span to 1 to make the cell 1 column/row sized + obj.set_grid_cell(lv.GRID_ALIGN.STRETCH, col, 1, + lv.GRID_ALIGN.STRETCH, row, 1) + + label = lv.label(obj) + label.set_text("{:d},{:d}".format(col, row)) + label.center() + |
