Update LVGL to v9.1.0
This commit is contained in:
@@ -1,35 +1,35 @@
|
||||
A simple row and a column layout with flexbox
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""
|
||||
---------------------------------------------
|
||||
|
||||
.. lv_example:: layouts/flex/lv_example_flex_1
|
||||
:language: c
|
||||
|
||||
Arrange items in rows with wrap and even spacing
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
------------------------------------------------
|
||||
|
||||
.. lv_example:: layouts/flex/lv_example_flex_2
|
||||
:language: c
|
||||
|
||||
Demonstrate flex grow
|
||||
"""""""""""""""""""""""
|
||||
---------------------
|
||||
|
||||
.. lv_example:: layouts/flex/lv_example_flex_3
|
||||
:language: c
|
||||
|
||||
Demonstrate flex grow.
|
||||
"""""""""""""""""""""""
|
||||
----------------------
|
||||
|
||||
.. lv_example:: layouts/flex/lv_example_flex_4
|
||||
:language: c
|
||||
|
||||
Demonstrate column and row gap style properties
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
-----------------------------------------------
|
||||
|
||||
.. lv_example:: layouts/flex/lv_example_flex_5
|
||||
:language: c
|
||||
|
||||
RTL base direction changes order of the items
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""
|
||||
---------------------------------------------
|
||||
|
||||
.. lv_example:: layouts/flex/lv_example_flex_6
|
||||
:language: c
|
||||
|
||||
@@ -7,13 +7,13 @@
|
||||
void lv_example_flex_1(void)
|
||||
{
|
||||
/*Create a container with ROW flex direction*/
|
||||
lv_obj_t * cont_row = lv_obj_create(lv_scr_act());
|
||||
lv_obj_t * cont_row = lv_obj_create(lv_screen_active());
|
||||
lv_obj_set_size(cont_row, 300, 75);
|
||||
lv_obj_align(cont_row, LV_ALIGN_TOP_MID, 0, 5);
|
||||
lv_obj_set_flex_flow(cont_row, LV_FLEX_FLOW_ROW);
|
||||
|
||||
/*Create a container with COLUMN flex direction*/
|
||||
lv_obj_t * cont_col = lv_obj_create(lv_scr_act());
|
||||
lv_obj_t * cont_col = lv_obj_create(lv_screen_active());
|
||||
lv_obj_set_size(cont_col, 200, 150);
|
||||
lv_obj_align_to(cont_col, cont_row, LV_ALIGN_OUT_BOTTOM_MID, 0, 5);
|
||||
lv_obj_set_flex_flow(cont_col, LV_FLEX_FLOW_COLUMN);
|
||||
@@ -24,15 +24,15 @@ void lv_example_flex_1(void)
|
||||
lv_obj_t * label;
|
||||
|
||||
/*Add items to the row*/
|
||||
obj = lv_btn_create(cont_row);
|
||||
obj = lv_button_create(cont_row);
|
||||
lv_obj_set_size(obj, 100, LV_PCT(100));
|
||||
|
||||
label = lv_label_create(obj);
|
||||
lv_label_set_text_fmt(label, "Item: %u", i);
|
||||
lv_label_set_text_fmt(label, "Item: %"LV_PRIu32"", i);
|
||||
lv_obj_center(label);
|
||||
|
||||
/*Add items to the column*/
|
||||
obj = lv_btn_create(cont_col);
|
||||
obj = lv_button_create(cont_col);
|
||||
lv_obj_set_size(obj, LV_PCT(100), LV_SIZE_CONTENT);
|
||||
|
||||
label = lv_label_create(obj);
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
#
|
||||
# A simple row and a column layout with flexbox
|
||||
#
|
||||
|
||||
# Create a container with ROW flex direction
|
||||
cont_row = lv.obj(lv.scr_act())
|
||||
cont_row.set_size(300, 75)
|
||||
cont_row.align(lv.ALIGN.TOP_MID, 0, 5)
|
||||
cont_row.set_flex_flow(lv.FLEX_FLOW.ROW)
|
||||
|
||||
# Create a container with COLUMN flex direction
|
||||
cont_col = lv.obj(lv.scr_act())
|
||||
cont_col.set_size(200, 150)
|
||||
cont_col.align_to(cont_row, lv.ALIGN.OUT_BOTTOM_MID, 0, 5)
|
||||
cont_col.set_flex_flow(lv.FLEX_FLOW.COLUMN)
|
||||
|
||||
for i in range(10):
|
||||
# Add items to the row
|
||||
obj = lv.btn(cont_row)
|
||||
obj.set_size(100, lv.pct(100))
|
||||
|
||||
label = lv.label(obj)
|
||||
label.set_text("Item: {:d}".format(i))
|
||||
label.center()
|
||||
|
||||
# Add items to the column
|
||||
obj = lv.btn(cont_col)
|
||||
obj.set_size(lv.pct(100), lv.SIZE.CONTENT)
|
||||
|
||||
label = lv.label(obj)
|
||||
label.set_text("Item: {:d}".format(i))
|
||||
label.center()
|
||||
|
||||
@@ -12,7 +12,7 @@ void lv_example_flex_2(void)
|
||||
lv_style_set_flex_main_place(&style, LV_FLEX_ALIGN_SPACE_EVENLY);
|
||||
lv_style_set_layout(&style, LV_LAYOUT_FLEX);
|
||||
|
||||
lv_obj_t * cont = lv_obj_create(lv_scr_act());
|
||||
lv_obj_t * cont = lv_obj_create(lv_screen_active());
|
||||
lv_obj_set_size(cont, 300, 220);
|
||||
lv_obj_center(cont);
|
||||
lv_obj_add_style(cont, &style, 0);
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
#
|
||||
# Arrange items in rows with wrap and place the items to get even space around them.
|
||||
#
|
||||
style = lv.style_t()
|
||||
style.init()
|
||||
style.set_flex_flow(lv.FLEX_FLOW.ROW_WRAP)
|
||||
style.set_flex_main_place(lv.FLEX_ALIGN.SPACE_EVENLY)
|
||||
style.set_layout(lv.LAYOUT_FLEX.value)
|
||||
|
||||
cont = lv.obj(lv.scr_act())
|
||||
cont.set_size(300, 220)
|
||||
cont.center()
|
||||
cont.add_style(style, 0)
|
||||
|
||||
for i in range(8):
|
||||
obj = lv.obj(cont)
|
||||
obj.set_size(70, lv.SIZE.CONTENT)
|
||||
|
||||
label = lv.label(obj)
|
||||
label.set_text("{:d}".format(i))
|
||||
label.center()
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
void lv_example_flex_3(void)
|
||||
{
|
||||
lv_obj_t * cont = lv_obj_create(lv_scr_act());
|
||||
lv_obj_t * cont = lv_obj_create(lv_screen_active());
|
||||
lv_obj_set_size(cont, 300, 220);
|
||||
lv_obj_center(cont);
|
||||
lv_obj_set_flex_flow(cont, LV_FLEX_FLOW_ROW);
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
#
|
||||
# Demonstrate flex grow.
|
||||
#
|
||||
|
||||
cont = lv.obj(lv.scr_act())
|
||||
cont.set_size(300, 220)
|
||||
cont.center()
|
||||
cont.set_flex_flow(lv.FLEX_FLOW.ROW)
|
||||
|
||||
obj = lv.obj(cont)
|
||||
obj.set_size(40, 40) # Fix size
|
||||
|
||||
obj = lv.obj(cont)
|
||||
obj.set_height(40)
|
||||
obj.set_flex_grow(1) # 1 portion from the free space
|
||||
|
||||
obj = lv.obj(cont)
|
||||
obj.set_height(40)
|
||||
obj.set_flex_grow(2) # 2 portion from the free space
|
||||
|
||||
obj = lv.obj(cont)
|
||||
obj.set_size(40, 40) # Fix size. It is flushed to the right by the "grow" items
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
void lv_example_flex_4(void)
|
||||
{
|
||||
|
||||
lv_obj_t * cont = lv_obj_create(lv_scr_act());
|
||||
lv_obj_t * cont = lv_obj_create(lv_screen_active());
|
||||
lv_obj_set_size(cont, 300, 220);
|
||||
lv_obj_center(cont);
|
||||
lv_obj_set_flex_flow(cont, LV_FLEX_FLOW_COLUMN_REVERSE);
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
#
|
||||
# Reverse the order of flex items
|
||||
#
|
||||
cont = lv.obj(lv.scr_act())
|
||||
cont.set_size(300, 220)
|
||||
cont.center()
|
||||
cont.set_flex_flow(lv.FLEX_FLOW.COLUMN_REVERSE)
|
||||
|
||||
for i in range(6):
|
||||
obj = lv.obj(cont)
|
||||
obj.set_size(100, 50)
|
||||
|
||||
label = lv.label(obj)
|
||||
label.set_text("Item: " + str(i))
|
||||
label.center()
|
||||
|
||||
@@ -16,7 +16,7 @@ static void column_gap_anim(void * obj, int32_t v)
|
||||
*/
|
||||
void lv_example_flex_5(void)
|
||||
{
|
||||
lv_obj_t * cont = lv_obj_create(lv_scr_act());
|
||||
lv_obj_t * cont = lv_obj_create(lv_screen_active());
|
||||
lv_obj_set_size(cont, 300, 220);
|
||||
lv_obj_center(cont);
|
||||
lv_obj_set_flex_flow(cont, LV_FLEX_FLOW_ROW_WRAP);
|
||||
@@ -38,13 +38,13 @@ void lv_example_flex_5(void)
|
||||
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_set_duration(&a, 500);
|
||||
lv_anim_set_playback_duration(&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_set_duration(&a, 3000);
|
||||
lv_anim_set_playback_duration(&a, 3000);
|
||||
lv_anim_start(&a);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
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 the effect of column and row gap style properties
|
||||
#
|
||||
|
||||
cont = lv.obj(lv.scr_act())
|
||||
cont.set_size(300, 220)
|
||||
cont.center()
|
||||
cont.set_flex_flow(lv.FLEX_FLOW.ROW_WRAP)
|
||||
|
||||
for i in range(9):
|
||||
obj = lv.obj(cont)
|
||||
obj.set_size(70, lv.SIZE.CONTENT)
|
||||
|
||||
label = lv.label(obj)
|
||||
label.set_text(str(i))
|
||||
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(3000)
|
||||
a_col.set_playback_time(3000)
|
||||
a_col.set_custom_exec_cb(lambda a,val: column_gap_anim(cont,val))
|
||||
|
||||
lv.anim_t.start(a_col)
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
void lv_example_flex_6(void)
|
||||
{
|
||||
lv_obj_t * cont = lv_obj_create(lv_scr_act());
|
||||
lv_obj_t * cont = lv_obj_create(lv_screen_active());
|
||||
lv_obj_set_style_base_dir(cont, LV_BASE_DIR_RTL, 0);
|
||||
lv_obj_set_size(cont, 300, 220);
|
||||
lv_obj_center(cont);
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
#
|
||||
# RTL base direction changes order of the items.
|
||||
# Also demonstrate how horizontal scrolling works with RTL.
|
||||
#
|
||||
|
||||
cont = lv.obj(lv.scr_act())
|
||||
cont.set_style_base_dir(lv.BASE_DIR.RTL,0)
|
||||
cont.set_size(300, 220)
|
||||
cont.center()
|
||||
cont.set_flex_flow(lv.FLEX_FLOW.ROW_WRAP)
|
||||
|
||||
for i in range(20):
|
||||
obj = lv.obj(cont)
|
||||
obj.set_size(70, lv.SIZE.CONTENT)
|
||||
|
||||
label = lv.label(obj)
|
||||
label.set_text(str(i))
|
||||
label.center()
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
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"
|
||||
""""""""""""""""""""""""""""""
|
||||
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
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
*/
|
||||
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};
|
||||
static int32_t col_dsc[] = {70, 70, 70, LV_GRID_TEMPLATE_LAST};
|
||||
static int32_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_t * cont = lv_obj_create(lv_screen_active());
|
||||
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);
|
||||
@@ -25,7 +25,7 @@ void lv_example_grid_1(void)
|
||||
uint8_t col = i % 3;
|
||||
uint8_t row = i / 3;
|
||||
|
||||
obj = lv_btn_create(cont);
|
||||
obj = lv_button_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,
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
#
|
||||
# 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()
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
#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};
|
||||
static int32_t col_dsc[] = {70, 70, 70, LV_GRID_TEMPLATE_LAST};
|
||||
static int32_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_t * cont = lv_obj_create(lv_screen_active());
|
||||
lv_obj_set_grid_dsc_array(cont, col_dsc, row_dsc);
|
||||
lv_obj_set_size(cont, 300, 220);
|
||||
lv_obj_center(cont);
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
#
|
||||
# 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")
|
||||
@@ -9,15 +9,15 @@ 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};
|
||||
static int32_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};
|
||||
static int32_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_t * cont = lv_obj_create(lv_screen_active());
|
||||
lv_obj_set_size(cont, 300, 220);
|
||||
lv_obj_center(cont);
|
||||
lv_obj_set_grid_dsc_array(cont, col_dsc, row_dsc);
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
#
|
||||
# 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()
|
||||
|
||||
@@ -6,14 +6,13 @@
|
||||
*/
|
||||
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};
|
||||
|
||||
static int32_t col_dsc[] = {60, 60, 60, LV_GRID_TEMPLATE_LAST};
|
||||
static int32_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_t * cont = lv_obj_create(lv_screen_active());
|
||||
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);
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
#
|
||||
# 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()
|
||||
|
||||
@@ -18,11 +18,11 @@ 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};
|
||||
static int32_t col_dsc[] = {60, 60, 60, LV_GRID_TEMPLATE_LAST};
|
||||
static int32_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_t * cont = lv_obj_create(lv_screen_active());
|
||||
lv_obj_set_size(cont, 300, 220);
|
||||
lv_obj_center(cont);
|
||||
lv_obj_set_grid_dsc_array(cont, col_dsc, row_dsc);
|
||||
@@ -49,15 +49,14 @@ void lv_example_grid_5(void)
|
||||
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_set_duration(&a, 500);
|
||||
lv_anim_set_playback_duration(&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_set_duration(&a, 3000);
|
||||
lv_anim_set_playback_duration(&a, 3000);
|
||||
lv_anim_start(&a);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
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)
|
||||
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
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};
|
||||
static int32_t col_dsc[] = {60, 60, 60, LV_GRID_TEMPLATE_LAST};
|
||||
static int32_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_t * cont = lv_obj_create(lv_screen_active());
|
||||
lv_obj_set_size(cont, 300, 220);
|
||||
lv_obj_center(cont);
|
||||
lv_obj_set_style_base_dir(cont, LV_BASE_DIR_RTL, 0);
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
#
|
||||
# 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()
|
||||
|
||||
Reference in New Issue
Block a user