// File: /workspace/github_c_makefile_star2_O2/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_ddlist.c
// Function: lv_ddlist_signal
static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * param)
{
    lv_res_t res;
    /* Include the ancient signal function */
    res = ancestor_signal(ddlist, 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_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);

    if(sign == LV_SIGNAL_STYLE_CHG) {
        lv_ddlist_refr_size(ddlist, 0);
    } else if(sign == LV_SIGNAL_BASE_DIR_CHG) {
        lv_label_align_t align = lv_label_get_align(ext->label);
        switch(align) {
            case LV_LABEL_ALIGN_LEFT: lv_obj_align(ext->label, NULL, LV_ALIGN_IN_LEFT_MID, 0, 0); break;
            case LV_LABEL_ALIGN_CENTER: lv_obj_align(ext->label, NULL, LV_ALIGN_CENTER, 0, 0); break;
            case LV_LABEL_ALIGN_RIGHT: lv_obj_align(ext->label, NULL, LV_ALIGN_IN_RIGHT_MID, 0, 0); break;
        }

        lv_ddlist_refr_size(ddlist, 0);
    } else if(sign == LV_SIGNAL_CLEANUP) {
        ext->label = NULL;
    } else if(sign == LV_SIGNAL_FOCUS) {
#if LV_USE_GROUP
        lv_group_t * g             = lv_obj_get_group(ddlist);
        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) {
            /*Open the list if editing*/
            if(editing) {
                ext->opened         = true;
                ext->sel_opt_id_ori = ext->sel_opt_id;
                lv_ddlist_refr_size(ddlist, true);
            }
            /*Close the lift if navigating*/
            else {
                ext->opened     = false;
                ext->sel_opt_id = ext->sel_opt_id_ori;
                lv_ddlist_refr_size(ddlist, true);
            }
        } else {
            /*Open the list if closed*/
            if(!ext->opened) {
                ext->opened         = true;
                ext->sel_opt_id_ori = ext->sel_opt_id; /*Save the current value. Used to revert this
                                                          state if ENER wont't be pressed*/
                lv_ddlist_refr_size(ddlist, true);
            }
        }
#endif
    } else if(sign == LV_SIGNAL_RELEASED) {
        release_handler(ddlist);
    } else if(sign == LV_SIGNAL_DEFOCUS) {
        if(ext->opened) {
            ext->opened     = false;
            ext->sel_opt_id = ext->sel_opt_id_ori;
            lv_ddlist_refr_size(ddlist, true);
        }
    } else if(sign == LV_SIGNAL_CONTROL) {
        char c = *((char *)param);
        if(c == LV_KEY_RIGHT || c == LV_KEY_DOWN) {
            if(!ext->opened) {
                ext->opened = 1;
                lv_ddlist_refr_size(ddlist, true);
            }

            if(ext->sel_opt_id + 1 < ext->option_cnt) {
                ext->sel_opt_id++;
                lv_ddlist_pos_current_option(ddlist);
                lv_obj_invalidate(ddlist);
            }
        } else if(c == LV_KEY_LEFT || c == LV_KEY_UP) {
            if(!ext->opened) {
                ext->opened = 1;
                lv_ddlist_refr_size(ddlist, true);
            }
            if(ext->sel_opt_id > 0) {
                ext->sel_opt_id--;
                lv_ddlist_pos_current_option(ddlist);
                lv_obj_invalidate(ddlist);
            }
        } else if(c == LV_KEY_ESC) {
            if(ext->opened) {
                ext->opened     = 0;
                ext->sel_opt_id = ext->sel_opt_id_ori;
                lv_ddlist_refr_size(ddlist, true);
            }
        }
    } else if(sign == LV_SIGNAL_GET_EDITABLE) {
        bool * editable = (bool *)param;
        *editable       = true;
    }

    return res;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %r12
movl %esi, %ebp
movq %rdi, %r14
callq *0x53539(%rip)          # 0x5e2d0
movl %eax, %ebx
cmpb $0x1, %al
jne 0xaf48
cmpb $0x7, %bpl
jne 0xadbe
leaq 0x3052d(%rip), %rsi     # 0x3b2db
movq %r12, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x684b
movq %r14, %rdi
callq 0x6747
movb $0x1, %bl
cmpb $0x13, %bpl
ja 0xaf48
movq %rax, %r15
movzbl %bpl, %eax
leaq 0x3048c(%rip), %rcx     # 0x3b26c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
andq $0x0, 0x50(%r15)
jmp 0xaf48
movzbl (%r12), %eax
movl %eax, %ecx
andb $-0x2, %cl
cmpb $0x12, %cl
jne 0xaec2
movb 0x66(%r15), %al
testb $0x1, %al
jne 0xae1f
orb $0x1, %al
movb %al, 0x66(%r15)
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0xb5f7
movzwl 0x62(%r15), %eax
leal 0x1(%rax), %ecx
movzwl 0x60(%r15), %edx
cmpl %edx, %ecx
jae 0xaf48
incl %eax
movw %ax, 0x62(%r15)
jmp 0xaefb
movb $0x1, (%r12)
jmp 0xaf48
movq 0x50(%r15), %rdi
callq 0x18d7f
cmpb $0x2, %al
ja 0xae76
shlb $0x3, %al
movl $0x80007, %edx          # imm = 0x80007
movl %eax, %ecx
shrl %cl, %edx
movq 0x50(%r15), %rdi
movzbl %dl, %edx
xorl %esi, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x5424
movq %r14, %rdi
xorl %esi, %esi
jmp 0xaf43
movq %r14, %rdi
callq 0xbc1a
jmp 0xaf48
movq %r14, %rdi
callq 0x4b8e
movq %rax, %rdi
callq 0x2aaa
movl %eax, %ebp
callq 0x35b3
movq %rax, %rdi
callq 0x35bb
movb 0x66(%r15), %cl
cmpb $0x4, %al
jne 0xaf27
testb %bpl, %bpl
jne 0xaf2c
andb $-0x2, %cl
movb %cl, 0x66(%r15)
jmp 0xaf1b
cmpl $0x11, %eax
je 0xaed1
cmpl $0x1b, %eax
je 0xaf0d
cmpl $0x14, %eax
jne 0xaf48
movb 0x66(%r15), %al
testb $0x1, %al
jne 0xaeea
orb $0x1, %al
movb %al, 0x66(%r15)
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0xb5f7
movzwl 0x62(%r15), %eax
testw %ax, %ax
je 0xaf48
decl %eax
movw %ax, 0x62(%r15)
movq %r14, %rdi
callq 0xb7b4
movq %r14, %rdi
callq 0x493a
jmp 0xaf48
movb 0x66(%r15), %al
testb $0x1, %al
je 0xaf48
andb $-0x2, %al
movb %al, 0x66(%r15)
movzwl 0x64(%r15), %eax
movw %ax, 0x62(%r15)
jmp 0xaf3d
testb $0x1, %cl
jne 0xaf48
orb $0x1, %cl
movb %cl, 0x66(%r15)
movzwl 0x62(%r15), %eax
movw %ax, 0x64(%r15)
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0xb5f7
movl %ebx, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq