// File: /workspace/github_c_makefile_star2_O3/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 %r12
pushq %rbx
movq %rdx, %r12
movl %esi, %r15d
movq %rdi, %r14
leal -0x10(%r15), %eax
movzbl %r15b, %ebp
cmpb $0x3, %al
jae 0xea09
movq %r14, %rdi
callq 0x6af7
movq %rax, %r15
movb $0x1, %bl
cmpl $0xf, %ebp
jle 0xea3e
cmpl $0x10, %ebp
je 0xea59
cmpl $0x11, %ebp
je 0xea94
cmpl $0x12, %ebp
jne 0xeb1a
movzbl (%r12), %eax
movl %eax, %ecx
andb $-0x2, %cl
cmpb $0x12, %cl
jne 0xeb25
movzwl 0x62(%r15), %eax
incl %eax
movzwl 0x60(%r15), %ecx
cmpl %ecx, %eax
jae 0xeb1a
movzwl 0x64(%r15), %ebp
jmp 0xeb40
movq %r14, %rdi
movl %ebp, %esi
movq %r12, %rdx
callq *0x51901(%rip)          # 0x60318
movl %eax, %ebx
cmpb $0x1, %al
jne 0xeb1a
cmpb $0x7, %r15b
jne 0xe9a7
leaq 0x30ba2(%rip), %rsi     # 0x3f5d0
movq %r12, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x6c02
cmpl $0x2, %ebp
je 0xeaaf
cmpl $0x4, %ebp
jne 0xeb1a
movq %r14, %rdi
callq 0xf2f0
jmp 0xeb10
movq %r14, %rdi
callq 0x4ed1
movq %rax, %rdi
callq 0x2b0b
movl %eax, %ebp
callq 0x378a
movq %rax, %rdi
callq 0x3792
movzwl 0x62(%r15), %ecx
cmpb $0x4, %al
jne 0xea8a
testb %bpl, %bpl
je 0xeb57
movw %cx, 0x64(%r15)
jmp 0xeb1a
movzwl 0x64(%r15), %eax
cmpw %ax, 0x62(%r15)
je 0xeb1a
movw %ax, 0x62(%r15)
movq %r14, %rdi
movl $0x1, %esi
jmp 0xeb15
movq %r14, %rdi
callq 0x566d
movzwl 0x4(%r12), %ecx
subw (%r12), %cx
incl %ecx
cmpw %cx, %ax
jne 0xeae4
movq %r14, %rdi
callq 0x5697
movzwl 0x6(%r12), %ecx
subw 0x2(%r12), %cx
incl %ecx
cmpw %cx, %ax
je 0xeb1a
movq %r14, %rdi
callq 0xf2f0
movq %r14, %rdi
callq 0x2695e
leaq -0x95e2(%rip), %rsi     # 0x5519
movq %rax, %rdi
callq 0x29c44
movzwl 0x62(%r15), %esi
movq %r14, %rdi
callq 0xc112
movq %r14, %rdi
xorl %esi, %esi
callq 0xf4cb
movl %ebx, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x14, %eax
je 0xeb2f
cmpl $0x11, %eax
jne 0xeb1a
movzwl 0x62(%r15), %eax
testw %ax, %ax
je 0xeb1a
movzwl 0x64(%r15), %ebp
decl %eax
movzwl %ax, %esi
movq %r14, %rdi
movl $0x1, %edx
callq 0xf395
movw %bp, 0x64(%r15)
jmp 0xeb1a
movzwl 0x64(%r15), %eax
cmpw %ax, %cx
jne 0xeaa0
jmp 0xeb1a