GuiGuider1.6.1按钮问题

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

GuiGuider1.6.1按钮问题

2,423 Views
RayC02
Contributor II

我的按钮点击事件是修改容器的可见性为显示,但是他的优先级应该是大于按钮动画,如何改为先显示按钮被点击的动画再去执行事件修改容器可见性。

0 Kudos
Reply
8 Replies

2,388 Views
WenbinYuan
NXP Employee
NXP Employee

Hi @RayC02 ,

Please try to use Released as the event Trigger of Button which control the Container, hope this way could help you.

Best Regards,

Wenbin

0 Kudos
Reply

2,377 Views
RayC02
Contributor II
I tried. It didn't work. It's a matter of priorities
0 Kudos
Reply

2,364 Views
WenbinYuan
NXP Employee
NXP Employee

Hi @RayC02,

as your discription, this action is limited by LVGL Event  mechanism, the event callback will be operated immediately once the trigger is sent.

You could try to write a costom event callback for this Button, such as using animation to do the operation after some delay.

Best Regards,

Wenbin

0 Kudos
Reply

2,359 Views
RayC02
Contributor II
Thanks for the Pointers, but I would like to know how to write using animation to perform operations after a delay of some time? I can't find a function for the button to trigger the animation
0 Kudos
Reply

2,352 Views
WenbinYuan
NXP Employee
NXP Employee

Hi @RayC02,

For example, you could write animation declaration in Event custom code area:

EventCustomCode.pngwith the code like:

lv_anim_t change_op;
lv_anim_init(&change_op);
lv_anim_set_exec_cb(&change_op, anim_opa_cb);
lv_anim_set_values(&change_op, lv_obj_get_style_bg_opa(guider_ui.screen_1_cont_1, 0), 0);
lv_anim_set_time(&change_op, 100);
lv_anim_set_delay(&change_op, 200);
lv_anim_set_var(&change_op, guider_ui.screen_1_cont_1);
lv_anim_start(&change_op);

and then decalare the anim-opa-cb in custom.c/h

void anim_opa_cb(void * var, int32_t v)
{
    lv_obj_set_style_bg_opa(var, v, LV_PART_MAIN);
}

 

Hope this could help you.

Best Regards,

Wenbin

0 Kudos
Reply

2,344 Views
RayC02
Contributor II

Thank you for your answer. It's a good plan. However, my container uses flag to select visibility, you see this comment section of the code is the function I need to implement, clear its hidden attribute. I tried your code, but it still didn't meet my requirements. Is there any other way?

By the way,I've also tried replacing this code (lv_obj_get_style_bg_opa(guider_ui.screen_function_1, 0))with the following lv_obj_clear_flag code, but it doesn't work. 

RayC02_0-1701678652416.png

 

0 Kudos
Reply

2,334 Views
WenbinYuan
NXP Employee
NXP Employee

Hi @RayC02,

Please try to modify the callback function to:

void anim_opa_cb(void * var, int32_t v)
{
    if (v == 0) {
        lv_obj_clear_flag(var, LV_OBJ_FLAG_HIDDEN);
    }
}

 and also change the animation code:

lv_anim_set_values(&change_op, 1, 0);

 

Best Regards,

Wenbin

0 Kudos
Reply

2,332 Views
RayC02
Contributor II
Thank you very much for your answer, which successfully solved my problem.Do you have any QQ groups or other contact information in China? If you have any questions, I can contact you more conveniently
0 Kudos
Reply