/* Set a new parent for an object. Its relative position will be the same.  */
void lv_obj_set_parent(lv_obj_t *obj, lv_obj_t *parent)
/* Set a new parent for an object. Its relative position will be the same.  */
void lv_obj_set_parent(lv_obj_t *obj, lv_obj_t *parent)
{
    if(obj->par == NULL) {
        LV_LOG_WARN("Can't set the parent of a screen");
        return;
    }
    if(parent == NULL) {
        LV_LOG_WARN("Can't set parent == NULL to an object");
        return;
    }
    lv_obj_invalidate(obj);
    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_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);
    old_par->signal_cb(old_par, LV_SIGNAL_CHILD_CHG, NULL);
    parent->signal_cb(parent, LV_SIGNAL_CHILD_CHG, obj);
    lv_obj_invalidate(obj);
}