2021-04-08 13:07:48 +02:00
|
|
|
#include "../../lv_examples.h"
|
2021-02-14 14:56:34 +01:00
|
|
|
#if LV_USE_FLEX && LV_BUILD_EXAMPLES
|
2021-02-12 14:22:48 +01:00
|
|
|
|
2021-02-22 20:27:46 +01:00
|
|
|
static void row_gap_anim(void * obj, int32_t v)
|
2021-02-12 14:22:48 +01:00
|
|
|
{
|
2021-03-31 19:57:14 +02:00
|
|
|
lv_obj_set_style_pad_row(obj, v, 0);
|
2021-02-12 14:22:48 +01:00
|
|
|
}
|
|
|
|
|
2021-02-22 20:27:46 +01:00
|
|
|
static void column_gap_anim(void * obj, int32_t v)
|
2021-02-12 14:22:48 +01:00
|
|
|
{
|
2021-03-31 19:57:14 +02:00
|
|
|
lv_obj_set_style_pad_column(obj, v, 0);
|
2021-02-12 14:22:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Demonstrate the effect of column and row gap style properties
|
|
|
|
*/
|
|
|
|
void lv_example_flex_5(void)
|
|
|
|
{
|
2021-03-25 13:36:50 +01:00
|
|
|
lv_obj_t * cont = lv_obj_create(lv_scr_act());
|
2021-02-12 14:22:48 +01:00
|
|
|
lv_obj_set_size(cont, 300, 220);
|
2021-03-25 16:14:17 +01:00
|
|
|
lv_obj_center(cont);
|
2021-03-23 20:51:39 +01:00
|
|
|
lv_obj_set_flex_flow(cont, LV_FLEX_FLOW_ROW_WRAP);
|
2021-02-12 14:22:48 +01:00
|
|
|
|
|
|
|
uint32_t i;
|
|
|
|
for(i = 0; i < 9; i++) {
|
2021-03-25 13:36:50 +01:00
|
|
|
lv_obj_t * obj = lv_obj_create(cont);
|
2021-02-12 14:22:48 +01:00
|
|
|
lv_obj_set_size(obj, 70, LV_SIZE_CONTENT);
|
|
|
|
|
2021-03-25 13:36:50 +01:00
|
|
|
lv_obj_t * label = lv_label_create(obj);
|
2021-02-12 14:22:48 +01:00
|
|
|
lv_label_set_text_fmt(label, "%d", i);
|
2021-03-25 16:14:17 +01:00
|
|
|
lv_obj_center(label);
|
2021-02-12 14:22:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2021-02-22 20:27:46 +01:00
|
|
|
lv_anim_set_exec_cb(&a, row_gap_anim);
|
2021-02-12 14:22:48 +01:00
|
|
|
lv_anim_set_time(&a, 500);
|
|
|
|
lv_anim_set_playback_time(&a, 500);
|
|
|
|
lv_anim_start(&a);
|
|
|
|
|
2021-02-22 20:27:46 +01:00
|
|
|
lv_anim_set_exec_cb(&a, column_gap_anim);
|
2021-02-12 14:22:48 +01:00
|
|
|
lv_anim_set_time(&a, 3000);
|
|
|
|
lv_anim_set_playback_time(&a, 3000);
|
|
|
|
lv_anim_start(&a);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|