add lv_components as src/extra and minor fixes
This commit is contained in:
37
examples/layouts/flex/lv_flex_example.h
Normal file
37
examples/layouts/flex/lv_flex_example.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* @file lv_ex_flex.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_EX_FLEX_H
|
||||
#define LV_EX_FLEX_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_EX_FLEX_H*/
|
||||
43
examples/layouts/flex/lv_flex_example_1.c
Normal file
43
examples/layouts/flex/lv_flex_example_1.c
Normal file
@@ -0,0 +1,43 @@
|
||||
//#include "../../lv_examples.h"
|
||||
//
|
||||
///**
|
||||
// * A simple row and a column layout with flexbox
|
||||
// */
|
||||
//void lv_ex_flex_1(void)
|
||||
//{
|
||||
// /*Create a container with ROW flex direction*/
|
||||
// lv_obj_t * cont_row = lv_obj_create(lv_scr_act(), NULL);
|
||||
// lv_obj_set_size(cont_row, 300, 75);
|
||||
// lv_obj_align(cont_row, NULL, LV_ALIGN_IN_TOP_MID, 0, 5);
|
||||
// lv_obj_set_flex_dir(cont_row, LV_FLEX_DIR_ROW);
|
||||
// lv_obj_set_flex_gap(cont_row, 10);
|
||||
//
|
||||
// /*Create a container with COLUMN flex direction*/
|
||||
// lv_obj_t * cont_col = lv_obj_create(lv_scr_act(), NULL);
|
||||
// lv_obj_set_size(cont_col, 200, 150);
|
||||
// lv_obj_align(cont_col, cont_row, LV_ALIGN_OUT_BOTTOM_MID, 0, 5);
|
||||
// lv_obj_set_flex_dir(cont_col, LV_FLEX_DIR_COLUMN);
|
||||
// lv_obj_set_flex_gap(cont_col, 10);
|
||||
//
|
||||
// uint32_t i;
|
||||
// for(i = 0; i < 10; i++) {
|
||||
// /*Add items to the row*/
|
||||
// lv_obj_t * obj1 = lv_obj_create(cont_row, NULL);
|
||||
// lv_obj_set_size(obj1, 100, LV_COORD_PCT(100));
|
||||
// lv_obj_set_flex_item(obj1, true);
|
||||
//
|
||||
// lv_obj_t * label1 = lv_label_create(obj1, NULL);
|
||||
// lv_label_set_text_fmt(label1, "Item: %d", i);
|
||||
// lv_obj_align(label1, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
//
|
||||
// /*Add items to the column*/
|
||||
// lv_obj_t * obj2 = lv_obj_create(cont_col, NULL);
|
||||
// lv_obj_set_size(obj2, LV_COORD_PCT(100), LV_SIZE_AUTO);
|
||||
// lv_obj_set_flex_item(obj2, true);
|
||||
//
|
||||
// lv_obj_t * label3 = lv_label_create(obj2, NULL);
|
||||
// lv_label_set_text_fmt(label3, "Item: %d", i);
|
||||
// lv_obj_align(label3, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
// }
|
||||
//}
|
||||
//
|
||||
24
examples/layouts/flex/lv_flex_example_2.c
Normal file
24
examples/layouts/flex/lv_flex_example_2.c
Normal file
@@ -0,0 +1,24 @@
|
||||
//#include "../../lv_examples.h"
|
||||
//
|
||||
///**
|
||||
// * Arrange items in column with wrap and place the row to get even space around them.
|
||||
// */
|
||||
//void lv_ex_flex_2(void)
|
||||
//{
|
||||
// lv_obj_t * cont = lv_obj_create(lv_scr_act(), NULL);
|
||||
// lv_obj_set_size(cont, 300, 220);
|
||||
// lv_obj_align(cont, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
// lv_obj_set_flex_dir(cont, LV_FLEX_DIR_COLUMN_WRAP);
|
||||
// lv_obj_set_flex_place(cont, LV_FLEX_PLACE_START, LV_FLEX_PLACE_START);
|
||||
//
|
||||
// uint32_t i;
|
||||
// for(i = 0; i < 3; i++) {
|
||||
// lv_obj_t * obj = lv_obj_create(cont, NULL);
|
||||
// lv_obj_set_flex_item_place(obj, LV_FLEX_PLACE_STRETCH);
|
||||
// lv_obj_set_size(obj, 70, LV_SIZE_AUTO);
|
||||
//
|
||||
// lv_obj_t * label = lv_label_create(obj, NULL);
|
||||
// lv_label_set_text_fmt(label, "%d", i);
|
||||
// }
|
||||
//}
|
||||
//
|
||||
30
examples/layouts/flex/lv_flex_example_3.c
Normal file
30
examples/layouts/flex/lv_flex_example_3.c
Normal file
@@ -0,0 +1,30 @@
|
||||
//#include "../../lv_examples.h"
|
||||
//
|
||||
///**
|
||||
// * Arrange items in a row and demonstrate flex grow.
|
||||
// */
|
||||
//void lv_ex_flex_3(void)
|
||||
//{
|
||||
// lv_obj_t * cont = lv_obj_create(lv_scr_act(), NULL);
|
||||
// lv_obj_set_size(cont, 300, 220);
|
||||
// lv_obj_align(cont, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
// lv_obj_set_flex_dir(cont, LV_FLEX_DIR_ROW);
|
||||
//
|
||||
// lv_obj_t * obj;
|
||||
// obj = lv_obj_create(cont, NULL);
|
||||
// lv_obj_set_size(obj, 20, 20); /*Fix size*/
|
||||
// lv_obj_set_flex_item(obj, true);
|
||||
//
|
||||
// obj = lv_obj_create(cont, NULL);
|
||||
// lv_obj_set_size(obj, LV_FLEX_GROW(1), 30); /*1 portion from the free space*/
|
||||
// lv_obj_set_flex_item(obj, true);
|
||||
//
|
||||
// obj = lv_obj_create(cont, NULL);
|
||||
// lv_obj_set_size(obj, LV_FLEX_GROW(2), 40); /*2 portion from the free space*/
|
||||
// lv_obj_set_flex_item(obj, true);
|
||||
//
|
||||
// obj = lv_obj_create(cont, NULL);
|
||||
// lv_obj_set_size(obj, 20, 20); /*Fix size. It is flushed to the right by the "grow" items*/
|
||||
// lv_obj_set_flex_item(obj, true);
|
||||
//}
|
||||
//
|
||||
24
examples/layouts/flex/lv_flex_example_4.c
Normal file
24
examples/layouts/flex/lv_flex_example_4.c
Normal file
@@ -0,0 +1,24 @@
|
||||
//#include "../../lv_examples.h"
|
||||
//
|
||||
///**
|
||||
// * Reverse the order of flex items
|
||||
// */
|
||||
//void lv_ex_flex_4(void)
|
||||
//{
|
||||
// lv_obj_t * cont = lv_obj_create(lv_scr_act(), NULL);
|
||||
// lv_obj_set_size(cont, 300, 220);
|
||||
// lv_obj_align(cont, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
// lv_obj_set_flex_dir(cont, LV_FLEX_DIR_COLUMN_WRAP_REVERSE);
|
||||
// lv_obj_set_flex_gap(cont, 10);
|
||||
//
|
||||
// uint32_t i;
|
||||
// for(i = 0; i < 20; i++) {
|
||||
// lv_obj_t * obj = lv_obj_create(cont, NULL);
|
||||
// lv_obj_set_size(obj, 100, LV_SIZE_AUTO);
|
||||
// lv_obj_set_flex_item(obj, true);
|
||||
//
|
||||
// lv_obj_t * label = lv_label_create(obj, NULL);
|
||||
// lv_label_set_text_fmt(label, "Item: %d", i);
|
||||
// }
|
||||
//}
|
||||
//
|
||||
28
examples/layouts/flex/lv_flex_example_5.c
Normal file
28
examples/layouts/flex/lv_flex_example_5.c
Normal file
@@ -0,0 +1,28 @@
|
||||
//#include "../../lv_examples.h"
|
||||
//
|
||||
///**
|
||||
// * Demonstrate the effect of margin on flex item
|
||||
// */
|
||||
//void lv_ex_flex_5(void)
|
||||
//{
|
||||
// lv_obj_t * cont = lv_obj_create(lv_scr_act(), NULL);
|
||||
// lv_obj_set_size(cont, 300, 220);
|
||||
// lv_obj_align(cont, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
// lv_obj_set_flex_dir(cont, LV_FLEX_DIR_ROW_WRAP);
|
||||
//
|
||||
// uint32_t i;
|
||||
// for(i = 0; i < 20; i++) {
|
||||
// lv_obj_t * obj = lv_obj_create(cont, NULL);
|
||||
// lv_obj_set_size(obj, 100, LV_SIZE_AUTO);
|
||||
// lv_obj_set_flex_item(obj, true);
|
||||
//
|
||||
// /*Set margin on every side*/
|
||||
// if(i == 4) {
|
||||
// lv_obj_set_style_local_margin_all(obj, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 20);
|
||||
// }
|
||||
//
|
||||
// lv_obj_t * label = lv_label_create(obj, NULL);
|
||||
// lv_label_set_text_fmt(label, "Item:%d", i);
|
||||
// }
|
||||
//}
|
||||
//
|
||||
25
examples/layouts/flex/lv_flex_example_6.c
Normal file
25
examples/layouts/flex/lv_flex_example_6.c
Normal file
@@ -0,0 +1,25 @@
|
||||
//#include "../../lv_examples.h"
|
||||
//
|
||||
///**
|
||||
// * RTL base direction changes order of the items.
|
||||
// */
|
||||
//void lv_ex_flex_6(void)
|
||||
//{
|
||||
// lv_obj_t * cont = lv_obj_create(lv_scr_act(), NULL);
|
||||
// lv_obj_set_base_dir(cont, LV_BIDI_DIR_RTL);
|
||||
// lv_obj_set_size(cont, 300, 220);
|
||||
// lv_obj_align(cont, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
// lv_obj_set_flex_dir(cont, LV_FLEX_DIR_COLUMN_WRAP);
|
||||
//
|
||||
// uint32_t i;
|
||||
// for(i = 0; i < 20; i++) {
|
||||
// lv_obj_t * obj = lv_obj_create(cont, NULL);
|
||||
// lv_obj_set_size(obj, 80, LV_SIZE_AUTO);
|
||||
// lv_obj_set_flex_item(obj, true);
|
||||
//
|
||||
// lv_obj_t * label = lv_label_create(obj, NULL);
|
||||
// lv_label_set_text_fmt(label, "%d", i);
|
||||
// lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
// }
|
||||
//}
|
||||
//
|
||||
37
examples/layouts/grid/lv_grid_example.h
Normal file
37
examples/layouts/grid/lv_grid_example.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* @file lv_ex_grid.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_EX_GRID_H
|
||||
#define LV_EX_GRID_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_EX_GRID_H*/
|
||||
39
examples/layouts/grid/lv_grid_example_1.c
Normal file
39
examples/layouts/grid/lv_grid_example_1.c
Normal file
@@ -0,0 +1,39 @@
|
||||
//#include "../../lv_examples.h"
|
||||
//
|
||||
///**
|
||||
// * A simple grid
|
||||
// */
|
||||
//void lv_ex_grid_1(void)
|
||||
//{
|
||||
// static lv_coord_t col_dsc[3] = {80, 80, 80};
|
||||
// static lv_coord_t row_dsc[3] = {60, 60, 60};
|
||||
//
|
||||
// static lv_grid_t grid;
|
||||
// lv_grid_init(&grid);
|
||||
// lv_grid_set_template(&grid, col_dsc, 3, row_dsc, 3);
|
||||
//
|
||||
// /*Create a container with grid*/
|
||||
// lv_obj_t * cont = lv_obj_create(lv_scr_act(), NULL);
|
||||
// lv_obj_set_size(cont, 300, 220);
|
||||
// lv_obj_align(cont, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
// lv_obj_set_grid(cont, &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_obj_create(cont, NULL);
|
||||
// /* 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_CELL_STRETCH(col, 1), LV_GRID_CELL_STRETCH(row, 1));
|
||||
//
|
||||
// label = lv_label_create(obj, NULL);
|
||||
// lv_label_set_text_fmt(label, "c%d, r%d", col, row);
|
||||
// lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
// }
|
||||
//}
|
||||
//
|
||||
59
examples/layouts/grid/lv_grid_example_2.c
Normal file
59
examples/layouts/grid/lv_grid_example_2.c
Normal file
@@ -0,0 +1,59 @@
|
||||
//#include "../../lv_examples.h"
|
||||
//
|
||||
///**
|
||||
// * Demonstrate cell placement and span
|
||||
// */
|
||||
//void lv_ex_grid_2(void)
|
||||
//{
|
||||
// static lv_coord_t col_dsc[3] = {80, 80, 80};
|
||||
// static lv_coord_t row_dsc[3] = {60, 60, 60};
|
||||
//
|
||||
// static lv_grid_t grid;
|
||||
// lv_grid_init(&grid);
|
||||
// lv_grid_set_template(&grid, col_dsc, 3, row_dsc, 3);
|
||||
//
|
||||
// /*Create a container with grid*/
|
||||
// lv_obj_t * cont = lv_obj_create(lv_scr_act(), NULL);
|
||||
// lv_obj_set_size(cont, 300, 220);
|
||||
// lv_obj_align(cont, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
// lv_obj_set_grid(cont, &grid);
|
||||
//
|
||||
// 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, NULL);
|
||||
// lv_obj_set_size(obj, LV_SIZE_AUTO, LV_SIZE_AUTO);
|
||||
// lv_obj_set_grid_cell(obj, LV_GRID_CELL_START(0, 1), LV_GRID_CELL_START(0, 1));
|
||||
// label = lv_label_create(obj, NULL);
|
||||
// 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, NULL);
|
||||
// lv_obj_set_size(obj, LV_SIZE_AUTO, LV_SIZE_AUTO);
|
||||
// lv_obj_set_grid_cell(obj, LV_GRID_CELL_START(1, 1), LV_GRID_CELL_CENTER(0, 1));
|
||||
// label = lv_label_create(obj, NULL);
|
||||
// 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, NULL);
|
||||
// lv_obj_set_size(obj, LV_SIZE_AUTO, LV_SIZE_AUTO);
|
||||
// lv_obj_set_grid_cell(obj, LV_GRID_CELL_START(2, 1), LV_GRID_CELL_END(0, 1));
|
||||
// label = lv_label_create(obj, NULL);
|
||||
// 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, NULL);
|
||||
// lv_obj_set_size(obj, LV_SIZE_AUTO, LV_SIZE_AUTO);
|
||||
// lv_obj_set_grid_cell(obj, LV_GRID_CELL_STRETCH(1, 2), LV_GRID_CELL_STRETCH(1, 1));
|
||||
// label = lv_label_create(obj, NULL);
|
||||
// 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, NULL);
|
||||
// lv_obj_set_size(obj, LV_SIZE_AUTO, LV_SIZE_AUTO);
|
||||
// lv_obj_set_grid_cell(obj, LV_GRID_CELL_STRETCH(0, 1), LV_GRID_CELL_STRETCH(1, 2));
|
||||
// label = lv_label_create(obj, NULL);
|
||||
// lv_label_set_text(label, "c0\nr1-2");
|
||||
//}
|
||||
//
|
||||
45
examples/layouts/grid/lv_grid_example_3.c
Normal file
45
examples/layouts/grid/lv_grid_example_3.c
Normal file
@@ -0,0 +1,45 @@
|
||||
//#include "../../lv_examples.h"
|
||||
//
|
||||
///**
|
||||
// * Demonstrate grid's "free unit"
|
||||
// */
|
||||
//void lv_ex_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[3] = {60, LV_GRID_FR(1), LV_GRID_FR(2)};
|
||||
//
|
||||
// /* Row 1: fix width 60 px
|
||||
// * Row 2: 1 unit from the remaining free space
|
||||
// * Row 3: fix width 60 px */
|
||||
// static lv_coord_t row_dsc[3] = {60, LV_GRID_FR(1), 60};
|
||||
//
|
||||
// static lv_grid_t grid;
|
||||
// lv_grid_init(&grid);
|
||||
// lv_grid_set_template(&grid, col_dsc, 3, row_dsc, 3);
|
||||
//
|
||||
// /*Create a container with grid*/
|
||||
// lv_obj_t * cont = lv_obj_create(lv_scr_act(), NULL);
|
||||
// lv_obj_set_size(cont, 300, 220);
|
||||
// lv_obj_align(cont, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
// lv_obj_set_grid(cont, &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_obj_create(cont, NULL);
|
||||
// /* 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_CELL_STRETCH(col, 1), LV_GRID_CELL_STRETCH(row, 1));
|
||||
//
|
||||
// label = lv_label_create(obj, NULL);
|
||||
// lv_label_set_text_fmt(label, "%d,%d", col, row);
|
||||
// lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
// }
|
||||
//}
|
||||
//
|
||||
41
examples/layouts/grid/lv_grid_example_4.c
Normal file
41
examples/layouts/grid/lv_grid_example_4.c
Normal file
@@ -0,0 +1,41 @@
|
||||
//#include "../../lv_examples.h"
|
||||
//
|
||||
///**
|
||||
// * Demonstrate track placement
|
||||
// */
|
||||
//void lv_ex_grid_4(void)
|
||||
//{
|
||||
// static lv_coord_t col_dsc[3] = {60, 60, 60};
|
||||
// static lv_coord_t row_dsc[3] = {50, 50, 50};
|
||||
//
|
||||
// static lv_grid_t grid;
|
||||
// lv_grid_init(&grid);
|
||||
// lv_grid_set_template(&grid, col_dsc, 3, row_dsc, 3);
|
||||
//
|
||||
// /*Add space between the columns and move the rows to the bottom (end)*/
|
||||
// lv_grid_set_place(&grid, LV_GRID_SPACE_BETWEEN, LV_GRID_END);
|
||||
//
|
||||
// /*Create a container with grid*/
|
||||
// lv_obj_t * cont = lv_obj_create(lv_scr_act(), NULL);
|
||||
// lv_obj_set_size(cont, 300, 220);
|
||||
// lv_obj_align(cont, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
// lv_obj_set_grid(cont, &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_obj_create(cont, NULL);
|
||||
// /* 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_CELL_STRETCH(col, 1), LV_GRID_CELL_STRETCH(row, 1));
|
||||
//
|
||||
// label = lv_label_create(obj, NULL);
|
||||
// lv_label_set_text_fmt(label, "%d,%d", col, row);
|
||||
// lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
// }
|
||||
//}
|
||||
//
|
||||
41
examples/layouts/grid/lv_grid_example_5.c
Normal file
41
examples/layouts/grid/lv_grid_example_5.c
Normal file
@@ -0,0 +1,41 @@
|
||||
//#include "../../lv_examples.h"
|
||||
//
|
||||
///**
|
||||
// * Demonstrate margin in grid
|
||||
// */
|
||||
//void lv_ex_grid_5(void)
|
||||
//{
|
||||
//
|
||||
// /*60x60 cells*/
|
||||
// static lv_coord_t col_dsc[3] = {100, 60, 60};
|
||||
// static lv_coord_t row_dsc[3] = {60, 60, 60};
|
||||
//
|
||||
// static lv_grid_t grid;
|
||||
// lv_grid_init(&grid);
|
||||
// lv_grid_set_template(&grid, col_dsc, 3, row_dsc, 3);
|
||||
//
|
||||
// /*Create a container with grid*/
|
||||
// lv_obj_t * cont = lv_obj_create(lv_scr_act(), NULL);
|
||||
// lv_obj_set_size(cont, 300, 220);
|
||||
// lv_obj_align(cont, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
// lv_obj_set_grid(cont, &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_obj_create(cont, NULL);
|
||||
// lv_obj_set_grid_cell(obj, LV_GRID_CELL_START(col, 1), LV_GRID_CELL_START(row, 1));
|
||||
// lv_obj_set_size(obj, 55, 55);
|
||||
// if(i == 1) {
|
||||
// lv_obj_set_style_local_margin_all(obj, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 5);
|
||||
// }
|
||||
// label = lv_label_create(obj, NULL);
|
||||
// lv_label_set_text_fmt(label, "%d,%d", col, row);
|
||||
// lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
// }
|
||||
//}
|
||||
//
|
||||
43
examples/layouts/grid/lv_grid_example_6.c
Normal file
43
examples/layouts/grid/lv_grid_example_6.c
Normal file
@@ -0,0 +1,43 @@
|
||||
//#include "../../lv_examples.h"
|
||||
//
|
||||
///**
|
||||
// * Demonstrate RTL direction on grid
|
||||
// */
|
||||
//void lv_ex_grid_6(void)
|
||||
//{
|
||||
//
|
||||
// static lv_coord_t col_dsc[3] = {100, 60, 60};
|
||||
// static lv_coord_t row_dsc[3] = {60, 60, 60};
|
||||
//
|
||||
// static lv_grid_t grid;
|
||||
// lv_grid_init(&grid);
|
||||
// lv_grid_set_template(&grid, col_dsc, 3, row_dsc, 3);
|
||||
//
|
||||
// /*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(), NULL);
|
||||
// lv_obj_set_size(cont, 300, 220);
|
||||
// lv_obj_align(cont, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
// lv_obj_set_base_dir(cont, LV_BIDI_DIR_RTL);
|
||||
// lv_obj_set_grid(cont, &grid);
|
||||
//
|
||||
// lv_obj_t * label;
|
||||
// lv_obj_t * obj;
|
||||
// uint32_t i;
|
||||
// for(i = 0; i < 3; i++) {
|
||||
// uint8_t col = i % 3;
|
||||
// uint8_t row = i / 3;
|
||||
//
|
||||
// obj = lv_obj_create(cont, NULL);
|
||||
// /* 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_CELL_STRETCH(col, 1), LV_GRID_CELL_START(row, 1));
|
||||
// lv_obj_set_size(obj, 55, 55);
|
||||
//
|
||||
// label = lv_label_create(obj, NULL);
|
||||
// lv_label_set_text_fmt(label, "%d,%d", col, row);
|
||||
// lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
// }
|
||||
//}
|
||||
//
|
||||
Reference in New Issue
Block a user