0
点赞
收藏
分享

微信扫一扫

LVGL-page控件

目标践行者 2022-03-12 阅读 70
c#

page的子对象

1、控件创建时会发送信号给它的父对象:

lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)

{

……

    /*Send a signal to the parent to notify it about the new child*/
    if(parent != NULL) {
        parent->signal_cb(parent, LV_SIGNAL_CHILD_CHG, new_obj);

        /*Invalidate the area if not screen created*/
        lv_obj_invalidate(new_obj);
    }

……

}

2、如果父对象是page时,子对像的父会被更改为page的扩展属性里面对像(ext->scrl)。这个对像就是个遮罩。

static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)

{

……

        child = lv_obj_get_child(page, NULL);
        while(child != NULL) {
            if(lv_obj_is_protected(child, LV_PROTECT_PARENT) == false) {
                lv_obj_t * tmp = child;
                child          = lv_obj_get_child(page, child); /*Get the next child before move this*/

                /* Reposition the child to take padding into account
                 * It's required to keep new the object on the same coordinate if FIT is enabled.*/
                if((tmp->coords.x1 == page->coords.x1)  &&
                   (fit_left == LV_FIT_TIGHT || fit_left == LV_FIT_MAX) &&
                   base_dir != LV_BIDI_DIR_RTL) {
                    tmp->coords.x1 += scrl_left;
                    tmp->coords.x2 += scrl_left;
                }
                else if((tmp->coords.x2 == page->coords.x2) &&
                        (fit_right == LV_FIT_TIGHT || fit_right == LV_FIT_MAX)
                        && base_dir == LV_BIDI_DIR_RTL) {
                    tmp->coords.x1 -= scrl_right;
                    tmp->coords.x2 -= scrl_right;
                }
                if((tmp->coords.y1 == page->coords.y1) && (fit_top == LV_FIT_TIGHT || fit_top == LV_FIT_MAX)) {
                    tmp->coords.y1 += scrl_top;
                    tmp->coords.y2 += scrl_top;
                }

                lv_obj_set_parent(tmp, ext->scrl);

            }
            else {
                child = lv_obj_get_child(page, child);
            }
        }

……

}

举报

相关推荐

0 条评论