// File: /workspace/github_c_makefile_star2_O1/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 *0x54b22(%rip)          # 0x602d0
movl %eax, %ebx
cmpb $0x1, %al
jne 0xb966
cmpb $0x7, %bpl
jne 0xb7d5
leaq 0x33b06(%rip), %rsi     # 0x3f2cb
movq %r12, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x6bf5
movq %r14, %rdi
callq 0x6ad8
cmpb $0x13, %bpl
ja 0xb966
movq %rax, %r15
movzbl %bpl, %eax
leaq 0x33a67(%rip), %rcx     # 0x3f25c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq $0x0, 0x50(%r15)
jmp 0xb966
movzbl (%r12), %eax
movl %eax, %ecx
andb $-0x2, %cl
cmpb $0x12, %cl
jne 0xb8dc
movb 0x66(%r15), %al
testb $0x1, %al
jne 0xb839
orb $0x1, %al
movb %al, 0x66(%r15)
movq %r14, %rdi
movl $0x1, %esi
callq 0xc07f
movzwl 0x62(%r15), %eax
leal 0x1(%rax), %ecx
movzwl 0x60(%r15), %edx
cmpl %edx, %ecx
jae 0xb966
incl %eax
movw %ax, 0x62(%r15)
jmp 0xb917
movb $0x1, (%r12)
jmp 0xb966
movq 0x50(%r15), %rdi
callq 0x1a1ff
cmpb $0x2, %al
ja 0xb890
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 0x576d
movq %r14, %rdi
xorl %esi, %esi
jmp 0xb961
movq %r14, %rdi
callq 0xc6e5
jmp 0xb966
movq %r14, %rdi
callq 0x4ea3
movq %rax, %rdi
callq 0x2b2b
movl %eax, %ebp
callq 0x3784
movq %rax, %rdi
callq 0x378c
movb 0x66(%r15), %cl
cmpb $0x4, %al
jne 0xb943
testb %bpl, %bpl
jne 0xb948
andb $-0x2, %cl
movb %cl, 0x66(%r15)
jmp 0xb937
cmpl $0x11, %eax
je 0xb8eb
cmpl $0x1b, %eax
je 0xb929
cmpl $0x14, %eax
jne 0xb966
movb 0x66(%r15), %al
testb $0x1, %al
jne 0xb906
orb $0x1, %al
movb %al, 0x66(%r15)
movq %r14, %rdi
movl $0x1, %esi
callq 0xc07f
movzwl 0x62(%r15), %eax
testw %ax, %ax
je 0xb966
decl %eax
movw %ax, 0x62(%r15)
movq %r14, %rdi
callq 0xc244
movq %r14, %rdi
callq 0x4c36
jmp 0xb966
movb 0x66(%r15), %al
testb $0x1, %al
je 0xb966
andb $-0x2, %al
movb %al, 0x66(%r15)
movzwl 0x64(%r15), %eax
movw %ax, 0x62(%r15)
jmp 0xb959
testb $0x1, %cl
jne 0xb966
orb $0x1, %cl
movb %cl, 0x66(%r15)
movzwl 0x62(%r15), %eax
movw %ax, 0x64(%r15)
movq %r14, %rdi
movl $0x1, %esi
callq 0xc07f
movl %ebx, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq