mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-27 11:35:38 +08:00
api(align) save align in style and handle x/y according to it
This commit is contained in:
@@ -9,13 +9,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_set_size(cont_row, 300, 75);
|
||||
lv_obj_align(cont_row, NULL, LV_ALIGN_IN_TOP_MID, 0, 5);
|
||||
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_set_size(cont_col, 200, 150);
|
||||
lv_obj_align(cont_col, cont_row, LV_ALIGN_OUT_BOTTOM_MID, 0, 5);
|
||||
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);
|
||||
|
||||
uint32_t i;
|
||||
@@ -29,7 +29,7 @@ void lv_example_flex_1(void)
|
||||
|
||||
label = lv_label_create(obj);
|
||||
lv_label_set_text_fmt(label, "Item: %d", i);
|
||||
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_center(label);
|
||||
|
||||
/*Add items to the column*/
|
||||
obj = lv_obj_create(cont_col);
|
||||
@@ -37,7 +37,7 @@ void lv_example_flex_1(void)
|
||||
|
||||
label = lv_label_create(obj);
|
||||
lv_label_set_text_fmt(label, "Item: %d", i);
|
||||
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_center(label);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ void lv_example_flex_2(void)
|
||||
|
||||
lv_obj_t * cont = lv_obj_create(lv_scr_act());
|
||||
lv_obj_set_size(cont, 300, 220);
|
||||
lv_obj_align(cont, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_center(cont);
|
||||
lv_obj_add_style(cont, LV_PART_MAIN, LV_STATE_DEFAULT, &style);
|
||||
|
||||
uint32_t i;
|
||||
@@ -24,6 +24,7 @@ void lv_example_flex_2(void)
|
||||
|
||||
lv_obj_t * label = lv_label_create(obj);
|
||||
lv_label_set_text_fmt(label, "%d", i);
|
||||
lv_obj_center(label);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ void lv_example_flex_3(void)
|
||||
{
|
||||
lv_obj_t * cont = lv_obj_create(lv_scr_act());
|
||||
lv_obj_set_size(cont, 300, 220);
|
||||
lv_obj_align(cont, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_center(cont);
|
||||
lv_obj_set_flex_flow(cont, LV_FLEX_FLOW_ROW);
|
||||
|
||||
lv_obj_t * obj;
|
||||
|
||||
@@ -9,7 +9,7 @@ void lv_example_flex_4(void)
|
||||
|
||||
lv_obj_t * cont = lv_obj_create(lv_scr_act());
|
||||
lv_obj_set_size(cont, 300, 220);
|
||||
lv_obj_align(cont, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_center(cont);
|
||||
lv_obj_set_flex_flow(cont, LV_FLEX_FLOW_COLUMN_REVERSE);
|
||||
|
||||
uint32_t i;
|
||||
@@ -19,6 +19,7 @@ void lv_example_flex_4(void)
|
||||
|
||||
lv_obj_t * label = lv_label_create(obj);
|
||||
lv_label_set_text_fmt(label, "Item: %d", i);
|
||||
lv_obj_center(label);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ void lv_example_flex_5(void)
|
||||
{
|
||||
lv_obj_t * cont = lv_obj_create(lv_scr_act());
|
||||
lv_obj_set_size(cont, 300, 220);
|
||||
lv_obj_align(cont, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_center(cont);
|
||||
lv_obj_set_flex_flow(cont, LV_FLEX_FLOW_ROW_WRAP);
|
||||
|
||||
uint32_t i;
|
||||
@@ -28,7 +28,7 @@ void lv_example_flex_5(void)
|
||||
|
||||
lv_obj_t * label = lv_label_create(obj);
|
||||
lv_label_set_text_fmt(label, "%d", i);
|
||||
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_center(label);
|
||||
}
|
||||
|
||||
lv_anim_t a;
|
||||
|
||||
@@ -10,7 +10,7 @@ void lv_example_flex_6(void)
|
||||
lv_obj_t * cont = lv_obj_create(lv_scr_act());
|
||||
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_center(cont);
|
||||
lv_obj_set_flex_flow(cont, LV_FLEX_FLOW_ROW_WRAP);
|
||||
|
||||
uint32_t i;
|
||||
@@ -20,7 +20,7 @@ void lv_example_flex_6(void)
|
||||
|
||||
lv_obj_t * label = lv_label_create(obj);
|
||||
lv_label_set_text_fmt(label, "%d", i);
|
||||
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_center(label);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user