1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-28 07:03:00 +08:00

lv_obj_set_parent: reposition according to base dir

This commit is contained in:
Gabor Kiss-Vamosi 2019-10-17 06:10:08 +02:00
parent 51226f7bfb
commit dbaaaa31a6
2 changed files with 18 additions and 3 deletions

View File

@ -579,15 +579,29 @@ void lv_obj_set_parent(lv_obj_t * obj, lv_obj_t * parent)
lv_obj_invalidate(obj);
lv_obj_t * old_par = obj->par;
lv_point_t old_pos;
old_pos.x = lv_obj_get_x(obj);
old_pos.y = lv_obj_get_y(obj);
lv_obj_t * old_par = obj->par;
lv_bidi_dir_t new_base_dir = lv_obj_get_base_dir(parent);
if(new_base_dir != LV_BIDI_DIR_RTL) {
old_pos.x = lv_obj_get_x(obj);
} else {
old_pos.x = old_par->coords.x2 - obj->coords.x2;
}
lv_ll_chg_list(&obj->par->child_ll, &parent->child_ll, obj, true);
obj->par = parent;
lv_obj_set_pos(obj, old_pos.x, old_pos.y);
if(new_base_dir != LV_BIDI_DIR_RTL) {
lv_obj_set_pos(obj, old_pos.x, old_pos.y);
} else {
/*Align to the right in case of RTL base dir*/
lv_coord_t new_x = lv_obj_get_width(parent) - old_pos.x - lv_obj_get_width(obj);
lv_obj_set_pos(obj, new_x , old_pos.y);
}
/*Notify the original parent because one of its children is lost*/
old_par->signal_cb(old_par, LV_SIGNAL_CHILD_CHG, NULL);

View File

@ -162,6 +162,7 @@ void lv_style_init(void)
lv_style_pretty_color.body.main_color = lv_color_make(0x6b, 0x9a, 0xc7);
lv_style_pretty_color.body.grad_color = lv_color_make(0x2b, 0x59, 0x8b);
lv_style_pretty_color.body.border.color = lv_color_make(0x15, 0x2c, 0x42);
// lv_style_pretty_color.body.padding.right = LV_DPI /2;
/*Transparent style*/
lv_style_copy(&lv_style_transp, &lv_style_plain);