// File: /workspace/github_c_makefile_star2_O2/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_roller.c
// Function: lv_roller_signal
static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * param)
{
    lv_res_t res = LV_RES_OK;

    /*Don't let the drop down list to handle the control signals. It works differently*/
    if(sign != LV_SIGNAL_CONTROL && sign != LV_SIGNAL_FOCUS && sign != LV_SIGNAL_DEFOCUS) {
        /* Include the ancient signal function */
        res = ancestor_signal(roller, sign, param);
        if(res != LV_RES_OK) return res;
    }
    if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);

    lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);

    if(sign == LV_SIGNAL_STYLE_CHG) {
        refr_height(roller);

        refr_position(roller, false);
    } else if(sign == LV_SIGNAL_CORD_CHG) {

        if(lv_obj_get_width(roller) != lv_area_get_width(param) ||
           lv_obj_get_height(roller) != lv_area_get_height(param)) {

            refr_height(roller);
#if LV_USE_ANIMATION
            lv_anim_del(lv_page_get_scrl(roller), (lv_anim_exec_xcb_t)lv_obj_set_y);
#endif
            lv_ddlist_set_selected(roller, ext->ddlist.sel_opt_id);
            refr_position(roller, false);
        }
    } else if(sign == LV_SIGNAL_FOCUS) {
#if LV_USE_GROUP
        lv_group_t * g             = lv_obj_get_group(roller);
        bool editing               = lv_group_get_editing(g);
        lv_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());

        /*Encoders need special handling*/
        if(indev_type == LV_INDEV_TYPE_ENCODER) {
            /*In navigate mode revert the original value*/
            if(!editing) {
                if(ext->ddlist.sel_opt_id != ext->ddlist.sel_opt_id_ori) {
                    ext->ddlist.sel_opt_id = ext->ddlist.sel_opt_id_ori;
                    refr_position(roller, true);
                }
            }
            /*Save the current state when entered to edit mode*/
            else {
                ext->ddlist.sel_opt_id_ori = ext->ddlist.sel_opt_id;
            }
        } else {
            ext->ddlist.sel_opt_id_ori = ext->ddlist.sel_opt_id; /*Save the current value. Used to revert this state if
                                                                    ENER wont't be pressed*/
        }
#endif
    } else if(sign == LV_SIGNAL_DEFOCUS) {
#if LV_USE_GROUP
        /*Revert the original state*/
        if(ext->ddlist.sel_opt_id != ext->ddlist.sel_opt_id_ori) {
            ext->ddlist.sel_opt_id = ext->ddlist.sel_opt_id_ori;
            refr_position(roller, true);
        }
#endif
    } else if(sign == LV_SIGNAL_CONTROL) {
        char c = *((char *)param);
        if(c == LV_KEY_RIGHT || c == LV_KEY_DOWN) {
            if(ext->ddlist.sel_opt_id + 1 < ext->ddlist.option_cnt) {
                uint16_t ori_id = ext->ddlist.sel_opt_id_ori; /*lv_roller_set_selceted will overwrite this*/
                lv_roller_set_selected(roller, ext->ddlist.sel_opt_id + 1, true);
                ext->ddlist.sel_opt_id_ori = ori_id;
            }
        } else if(c == LV_KEY_LEFT || c == LV_KEY_UP) {
            if(ext->ddlist.sel_opt_id > 0) {
                uint16_t ori_id = ext->ddlist.sel_opt_id_ori; /*lv_roller_set_selceted will overwrite this*/
                lv_roller_set_selected(roller, ext->ddlist.sel_opt_id - 1, true);
                ext->ddlist.sel_opt_id_ori = ori_id;
            }
        }
    }

    return res;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r12
movl %esi, %r13d
movq %rdi, %r14
leal -0x10(%r13), %eax
movzbl %r13b, %ebp
cmpb $0x3, %al
jae 0xdf0f
movq %r14, %rdi
callq 0x6747
movq %rax, %r15
movb $0x1, %bl
cmpb $0x2, %r13b
je 0xdfd3
cmpl $0x12, %ebp
je 0xdf4a
cmpl $0x10, %ebp
je 0xdf9b
cmpl $0x11, %ebp
je 0xdf7b
cmpl $0x4, %ebp
jne 0xe03e
movq %r14, %rdi
callq 0xe7f2
jmp 0xe034
movq %r14, %rdi
movl %ebp, %esi
movq %r12, %rdx
callq *0x503fb(%rip)          # 0x5e318
movl %eax, %ebx
cmpb $0x1, %al
jne 0xe03e
cmpb $0x7, %r13b
jne 0xdecb
leaq 0x2d5fc(%rip), %rsi     # 0x3b530
movq %r12, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x684b
movzbl (%r12), %eax
movl %eax, %ecx
andb $-0x2, %cl
cmpb $0x12, %cl
jne 0xe04f
movzwl 0x62(%r15), %eax
incl %eax
movzwl 0x60(%r15), %ecx
cmpl %ecx, %eax
jae 0xe03e
movzwl 0x64(%r15), %ebp
jmp 0xe06a
movzwl 0x64(%r15), %eax
cmpw %ax, 0x62(%r15)
je 0xe03e
movw %ax, 0x62(%r15)
pushq $0x1
popq %rsi
movq %r14, %rdi
jmp 0xe039
movq %r14, %rdi
callq 0x4b8e
movq %rax, %rdi
callq 0x2aaa
movl %eax, %ebp
callq 0x35b3
movq %rax, %rdi
callq 0x35bb
movzwl 0x62(%r15), %ecx
cmpb $0x4, %al
jne 0xdfcc
testb %bpl, %bpl
je 0xe07f
movw %cx, 0x64(%r15)
jmp 0xe03e
movq %r14, %rdi
callq 0x5308
movzwl 0x4(%r12), %ecx
subw (%r12), %cx
incl %ecx
cmpw %cx, %ax
jne 0xe008
movq %r14, %rdi
callq 0x5332
movzwl 0x6(%r12), %ecx
subw 0x2(%r12), %cx
incl %ecx
cmpw %cx, %ax
je 0xe03e
movq %r14, %rdi
callq 0xe7f2
movq %r14, %rdi
callq 0x245d9
leaq -0x8e4f(%rip), %rsi     # 0x51d0
movq %rax, %rdi
callq 0x27715
movzwl 0x62(%r15), %esi
movq %r14, %rdi
callq 0xb749
movq %r14, %rdi
xorl %esi, %esi
callq 0xe9c3
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x14, %eax
je 0xe059
cmpl $0x11, %eax
jne 0xe03e
movzwl 0x62(%r15), %eax
testw %ax, %ax
je 0xe03e
movzwl 0x64(%r15), %ebp
decl %eax
movzwl %ax, %esi
pushq $0x1
popq %rdx
movq %r14, %rdi
callq 0xe897
movw %bp, 0x64(%r15)
jmp 0xe03e
movzwl 0x64(%r15), %eax
cmpw %ax, %cx
jne 0xdf8b
jmp 0xe03e