// File: /workspace/github_c_makefile_star2_O3/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 *0x54bb8(%rip)          # 0x602d0
movl %eax, %ebx
cmpb $0x1, %al
jne 0xb8d2
cmpb $0x7, %bpl
jne 0xb73f
leaq 0x33c4c(%rip), %rsi     # 0x3f37b
movq %r12, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x6c02
movq %r14, %rdi
callq 0x6af7
movb $0x1, %bl
cmpb $0x13, %bpl
ja 0xb8d2
movq %rax, %r15
movzbl %bpl, %eax
leaq 0x33bab(%rip), %rcx     # 0x3f30c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq $0x0, 0x50(%r15)
jmp 0xb8d2
movzbl (%r12), %eax
movl %eax, %ecx
andb $-0x2, %cl
cmpb $0x12, %cl
jne 0xb848
movb 0x66(%r15), %al
testb $0x1, %al
jne 0xb7a5
orb $0x1, %al
movb %al, 0x66(%r15)
movq %r14, %rdi
movl $0x1, %esi
callq 0xbfb8
movzwl 0x62(%r15), %eax
leal 0x1(%rax), %ecx
movzwl 0x60(%r15), %edx
cmpl %edx, %ecx
jae 0xb8d2
incl %eax
movw %ax, 0x62(%r15)
jmp 0xb883
movb $0x1, (%r12)
jmp 0xb8d2
movq 0x50(%r15), %rdi
callq 0x1a9c6
cmpb $0x2, %al
ja 0xb7fc
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 0x5789
movq %r14, %rdi
xorl %esi, %esi
jmp 0xb8cd
movq %r14, %rdi
callq 0xc61e
jmp 0xb8d2
movq %r14, %rdi
callq 0x4ed1
movq %rax, %rdi
callq 0x2b0b
movl %eax, %ebp
callq 0x378a
movq %rax, %rdi
callq 0x3792
movb 0x66(%r15), %cl
cmpb $0x4, %al
jne 0xb8af
testb %bpl, %bpl
jne 0xb8b4
andb $-0x2, %cl
movb %cl, 0x66(%r15)
jmp 0xb8a3
cmpl $0x11, %eax
je 0xb857
cmpl $0x1b, %eax
je 0xb895
cmpl $0x14, %eax
jne 0xb8d2
movb 0x66(%r15), %al
testb $0x1, %al
jne 0xb872
orb $0x1, %al
movb %al, 0x66(%r15)
movq %r14, %rdi
movl $0x1, %esi
callq 0xbfb8
movzwl 0x62(%r15), %eax
testw %ax, %ax
je 0xb8d2
decl %eax
movw %ax, 0x62(%r15)
movq %r14, %rdi
callq 0xc17d
movq %r14, %rdi
callq 0x4c4d
jmp 0xb8d2
movb 0x66(%r15), %al
testb $0x1, %al
je 0xb8d2
andb $-0x2, %al
movb %al, 0x66(%r15)
movzwl 0x64(%r15), %eax
movw %ax, 0x62(%r15)
jmp 0xb8c5
testb $0x1, %cl
jne 0xb8d2
orb $0x1, %cl
movb %cl, 0x66(%r15)
movzwl 0x62(%r15), %eax
movw %ax, 0x64(%r15)
movq %r14, %rdi
movl $0x1, %esi
callq 0xbfb8
movl %ebx, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq