add examples + refactoring
This commit is contained in:
@@ -1,39 +1,44 @@
|
||||
//#include "../../lv_examples.h"
|
||||
//
|
||||
///**
|
||||
// * A simple grid
|
||||
// */
|
||||
//void lv_example_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);
|
||||
// }
|
||||
//}
|
||||
//
|
||||
#include "../../../lvgl.h"
|
||||
|
||||
#if LV_USE_GRID
|
||||
|
||||
|
||||
/**
|
||||
* A simple grid
|
||||
*/
|
||||
void lv_example_grid_1(void)
|
||||
{
|
||||
static lv_coord_t col_dsc[3] = {70, 70, 70};
|
||||
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);
|
||||
|
||||
/*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_layout(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_STRETCH, col, 1,
|
||||
LV_GRID_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);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,59 +1,68 @@
|
||||
//#include "../../lv_examples.h"
|
||||
//
|
||||
///**
|
||||
// * Demonstrate cell placement and span
|
||||
// */
|
||||
//void lv_example_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");
|
||||
//}
|
||||
//
|
||||
#include "../../../lvgl.h"
|
||||
|
||||
#if LV_USE_GRID
|
||||
|
||||
|
||||
/**
|
||||
* Demonstrate cell placement and span
|
||||
*/
|
||||
void lv_example_grid_2(void)
|
||||
{
|
||||
static lv_coord_t col_dsc[3] = {70, 70, 70};
|
||||
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);
|
||||
|
||||
/*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_layout(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_CONTENT, LV_SIZE_CONTENT);
|
||||
lv_obj_set_grid_cell(obj, LV_GRID_START, 0, 1,
|
||||
LV_GRID_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_CONTENT, LV_SIZE_CONTENT);
|
||||
lv_obj_set_grid_cell(obj, LV_GRID_START, 1, 1,
|
||||
LV_GRID_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_CONTENT, LV_SIZE_CONTENT);
|
||||
lv_obj_set_grid_cell(obj, LV_GRID_START, 2, 1,
|
||||
LV_GRID_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_CONTENT, LV_SIZE_CONTENT);
|
||||
lv_obj_set_grid_cell(obj, LV_GRID_STRETCH, 1, 2,
|
||||
LV_GRID_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_CONTENT, LV_SIZE_CONTENT);
|
||||
lv_obj_set_grid_cell(obj, LV_GRID_STRETCH, 0, 1,
|
||||
LV_GRID_STRETCH, 1, 2);
|
||||
label = lv_label_create(obj, NULL);
|
||||
lv_label_set_text(label, "c0\nr1-2");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,45 +1,49 @@
|
||||
//#include "../../lv_examples.h"
|
||||
//
|
||||
///**
|
||||
// * 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[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);
|
||||
// }
|
||||
//}
|
||||
//
|
||||
#include "../../../lvgl.h"
|
||||
|
||||
#if LV_USE_GRID
|
||||
|
||||
/**
|
||||
* 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[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] = {40, LV_GRID_FR(1), 40};
|
||||
|
||||
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_layout(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_STRETCH, col, 1,
|
||||
LV_GRID_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);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,41 +1,45 @@
|
||||
//#include "../../lv_examples.h"
|
||||
//
|
||||
///**
|
||||
// * Demonstrate track placement
|
||||
// */
|
||||
//void lv_example_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);
|
||||
// }
|
||||
//}
|
||||
//
|
||||
#include "../../../lvgl.h"
|
||||
|
||||
#if LV_USE_GRID
|
||||
|
||||
/**
|
||||
* Demonstrate track placement
|
||||
*/
|
||||
void lv_example_grid_4(void)
|
||||
{
|
||||
static lv_coord_t col_dsc[3] = {60, 60, 60};
|
||||
static lv_coord_t row_dsc[3] = {40, 40, 40};
|
||||
|
||||
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_layout(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_STRETCH, col, 1,
|
||||
LV_GRID_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);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,41 +1,67 @@
|
||||
//#include "../../lv_examples.h"
|
||||
//
|
||||
///**
|
||||
// * Demonstrate margin in grid
|
||||
// */
|
||||
//void lv_example_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);
|
||||
// }
|
||||
//}
|
||||
//
|
||||
#include "../../../lvgl.h"
|
||||
|
||||
#if LV_USE_GRID
|
||||
|
||||
static void row_gap_anim(lv_obj_t * obj, lv_anim_value_t v)
|
||||
{
|
||||
lv_obj_set_style_pad_row(obj, LV_PART_MAIN, LV_STATE_DEFAULT, v);
|
||||
}
|
||||
|
||||
static void column_gap_anim(lv_obj_t * obj, lv_anim_value_t v)
|
||||
{
|
||||
lv_obj_set_style_pad_column(obj, LV_PART_MAIN, LV_STATE_DEFAULT, v);
|
||||
}
|
||||
/**
|
||||
* Demonstrate margin in grid
|
||||
*/
|
||||
void lv_example_grid_5(void)
|
||||
{
|
||||
|
||||
/*60x60 cells*/
|
||||
static lv_coord_t col_dsc[3] = {60, 60, 60};
|
||||
static lv_coord_t row_dsc[3] = {40, 40, 40};
|
||||
|
||||
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_layout(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_STRETCH, col, 1,
|
||||
LV_GRID_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);
|
||||
}
|
||||
|
||||
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, (lv_anim_exec_xcb_t) 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, (lv_anim_exec_xcb_t) column_gap_anim);
|
||||
lv_anim_set_time(&a, 3000);
|
||||
lv_anim_set_playback_time(&a, 3000);
|
||||
lv_anim_start(&a);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,43 +1,44 @@
|
||||
//#include "../../lv_examples.h"
|
||||
//
|
||||
///**
|
||||
// * Demonstrate RTL direction on grid
|
||||
// */
|
||||
//void lv_example_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);
|
||||
// }
|
||||
//}
|
||||
//
|
||||
#include "../../../lvgl.h"
|
||||
|
||||
#if LV_USE_GRID
|
||||
|
||||
/**
|
||||
* Demonstrate RTL direction on grid
|
||||
*/
|
||||
void lv_example_grid_6(void)
|
||||
{
|
||||
|
||||
static lv_coord_t col_dsc[3] = {60, 60, 60};
|
||||
static lv_coord_t row_dsc[3] = {40, 40, 40};
|
||||
|
||||
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_base_dir(cont, LV_BIDI_DIR_RTL);
|
||||
lv_obj_set_layout(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_STRETCH, col, 1,
|
||||
LV_GRID_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);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user