api(align) save align in style and handle x/y according to it
This commit is contained in:
@@ -10,7 +10,6 @@ static void btn_event_cb(lv_obj_t * btn, lv_event_t event)
|
||||
/*Get the first child of the button which is the label and change its text*/
|
||||
lv_obj_t * label = lv_obj_get_child(btn, 0);
|
||||
lv_label_set_text_fmt(label, "Button: %d", cnt);
|
||||
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +25,7 @@ void lv_example_get_started_1(void)
|
||||
|
||||
lv_obj_t * label = lv_label_create(btn); /*Add a label to the button*/
|
||||
lv_label_set_text(label, "Button"); /*Set the labels text*/
|
||||
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_center(label);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -46,7 +46,7 @@ void lv_example_get_started_2(void)
|
||||
|
||||
lv_obj_t * label = lv_label_create(btn); /*Add a label to the button*/
|
||||
lv_label_set_text(label, "Button"); /*Set the labels text*/
|
||||
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_center(label);
|
||||
|
||||
/*Create an other button and use the red style too*/
|
||||
lv_obj_t * btn2 = lv_btn_create(lv_scr_act());
|
||||
@@ -60,7 +60,7 @@ void lv_example_get_started_2(void)
|
||||
|
||||
label = lv_label_create(btn2); /*Add a label to the button*/
|
||||
lv_label_set_text(label, "Button 2"); /*Set the labels text*/
|
||||
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_center(label);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,7 +8,7 @@ static void slider_event_cb(lv_obj_t * slider, lv_event_t event)
|
||||
if(event == LV_EVENT_VALUE_CHANGED) {
|
||||
/*Refresh the text*/
|
||||
lv_label_set_text_fmt(label, "%d", lv_slider_get_value(slider));
|
||||
lv_obj_align(label, slider, LV_ALIGN_OUT_TOP_MID, 0, -15); /*Align below the slider*/
|
||||
lv_obj_align_to(label, slider, LV_ALIGN_OUT_TOP_MID, 0, -15); /*Align below the slider*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,14 +19,14 @@ void lv_example_get_started_3(void)
|
||||
{
|
||||
/*Create a slider in the center of the display*/
|
||||
lv_obj_t * slider = lv_slider_create(lv_scr_act());
|
||||
lv_obj_set_width(slider, 200); /*Set the width*/
|
||||
lv_obj_align(slider, NULL, LV_ALIGN_CENTER, 0, 0); /*Align to the center of the parent (screen)*/
|
||||
lv_obj_add_event_cb(slider, slider_event_cb, NULL); /*Assign an event function*/
|
||||
lv_obj_set_width(slider, 200); /*Set the width*/
|
||||
lv_obj_center(slider); /*Align to the center of the parent (screen)*/
|
||||
lv_obj_add_event_cb(slider, slider_event_cb, NULL); /*Assign an event function*/
|
||||
|
||||
/*Create a label below the slider*/
|
||||
label = lv_label_create(lv_scr_act());
|
||||
lv_label_set_text(label, "0");
|
||||
lv_obj_align(label, slider, LV_ALIGN_OUT_TOP_MID, 0, -15); /*Align below the slider*/
|
||||
lv_obj_align_to(label, slider, LV_ALIGN_OUT_TOP_MID, 0, -15); /*Align below the slider*/
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user