// File: /workspace/github_c_makefile_star2_O1/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_list.c
// Function: lv_list_signal
static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
{
    lv_res_t res;

    /* Include the ancient signal function */
    res = ancestor_page_signal(list, 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);

    if(sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_PRESSING ||
       sign == LV_SIGNAL_LONG_PRESS || sign == LV_SIGNAL_LONG_PRESS_REP) {
#if LV_USE_GROUP
        /*If pressed/released etc by a KEYPAD or ENCODER delegate signal to the button*/
        lv_indev_t * indev         = lv_indev_get_act();
        lv_indev_type_t indev_type = lv_indev_get_type(indev);
        if(indev_type == LV_INDEV_TYPE_KEYPAD ||
           (indev_type == LV_INDEV_TYPE_ENCODER && lv_group_get_editing(lv_obj_get_group(list)))) {
            /*Get the 'pressed' button*/
            lv_obj_t * btn = NULL;
            btn            = lv_list_get_prev_btn(list, btn);
            while(btn != NULL) {
                if(lv_btn_get_state(btn) == LV_BTN_STATE_PR) break;
                btn = lv_list_get_prev_btn(list, btn);
            }
            lv_list_ext_t * ext = lv_obj_get_ext_attr(list);

            /*The page receives the key presses so the events should be propagated to the selected
             * button*/
            if(btn) {
                if(sign == LV_SIGNAL_PRESSED) {
                    res = lv_event_send(btn, LV_EVENT_PRESSED, NULL);
                } else if(sign == LV_SIGNAL_PRESSING) {
                    res = lv_event_send(btn, LV_EVENT_PRESSING, NULL);
                } else if(sign == LV_SIGNAL_LONG_PRESS) {
                    res = lv_event_send(btn, LV_EVENT_LONG_PRESSED, NULL);
                } else if(sign == LV_SIGNAL_LONG_PRESS_REP) {
                    res = lv_event_send(btn, LV_EVENT_LONG_PRESSED_REPEAT, NULL);
                } else if(sign == LV_SIGNAL_RELEASED) {
#if LV_USE_GROUP
                    ext->last_sel = btn;
#endif
                    if(indev->proc.long_pr_sent == 0) {
                        res = lv_event_send(btn, LV_EVENT_SHORT_CLICKED, NULL);
                    }
                    if(lv_indev_is_dragging(indev) == false && res == LV_RES_OK) {
                        res = lv_event_send(btn, LV_EVENT_CLICKED, NULL);
                    }
                    if(res == LV_RES_OK) {
                        res = lv_event_send(btn, LV_EVENT_RELEASED, NULL);
                    }
                }
            }
        }
#endif
    } else if(sign == LV_SIGNAL_FOCUS) {

#if LV_USE_GROUP
        lv_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
        /*With ENCODER select the first button only in edit mode*/
        if(indev_type == LV_INDEV_TYPE_ENCODER) {
            lv_group_t * g = lv_obj_get_group(list);
            if(lv_group_get_editing(g)) {
                lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
                if(ext->last_sel) {
                    /* Select the    last used button */
                    lv_list_set_btn_selected(list, ext->last_sel);
                } else {
                    /*Get the first button and mark it as selected*/
                    lv_list_set_btn_selected(list, lv_list_get_next_btn(list, NULL));
                }
            } else {
                lv_list_set_btn_selected(list, NULL);
            }
        }
        /*Else select the clicked button*/
        else {
            /*Mark the last clicked button (if any) as selected because it triggered the focus*/
            lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
            if(ext->last_clicked_btn) {
                lv_list_set_btn_selected(list, ext->last_clicked_btn);
                ext->last_clicked_btn = NULL;

            } else {
                if(ext->last_sel) {
                    /* Select the last used button */
                    lv_list_set_btn_selected(list, ext->last_sel);
                } else {
                    /*Get the first button and mark it as selected*/
                    lv_list_set_btn_selected(list, lv_list_get_next_btn(list, NULL));
                }
            }
        }
#endif
    } else if(sign == LV_SIGNAL_DEFOCUS) {

#if LV_USE_GROUP
        /*De-select the selected btn*/
        lv_list_set_btn_selected(list, NULL);
        lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
        ext->last_clicked_btn    = NULL; /*button click will be set if click happens before focus*/
        ext->selected_btn   = NULL;
#endif
    } else if(sign == LV_SIGNAL_GET_EDITABLE) {
        bool * editable = (bool *)param;
        *editable       = true;
    } else if(sign == LV_SIGNAL_CONTROL) {

#if LV_USE_GROUP
        char c = *((char *)param);
        if(c == LV_KEY_RIGHT || c == LV_KEY_DOWN) {
            lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
            /*If there is a valid selected button the make the previous selected*/
            if(ext->selected_btn) {
                lv_obj_t * btn_prev = lv_list_get_next_btn(list, ext->selected_btn);
                if(btn_prev) lv_list_set_btn_selected(list, btn_prev);
            }
            /*If there is no selected button the make the first selected*/
            else {
                lv_obj_t * btn = lv_list_get_next_btn(list, NULL);
                if(btn)
                    lv_list_set_btn_selected(list,
                                             btn); /*If there are no buttons on the list then there is no first button*/
            }
        } else if(c == LV_KEY_LEFT || c == LV_KEY_UP) {
            lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
            /*If there is a valid selected button the make the next selected*/
            if(ext->selected_btn != NULL) {
                lv_obj_t * btn_next = lv_list_get_prev_btn(list, ext->selected_btn);
                if(btn_next) lv_list_set_btn_selected(list, btn_next);
            }
            /*If there is no selected button the make the first selected*/
            else {
                lv_obj_t * btn = lv_list_get_next_btn(list, NULL);
                if(btn) lv_list_set_btn_selected(list, btn);
            }
        }
#endif
    }
    return res;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r15
movl %esi, %ebp
movq %rdi, %r14
callq *0x448ed(%rip)          # 0x603b8
movl %eax, %ebx
cmpb $0x1, %al
jne 0x1bd63
movzbl %bpl, %r13d
leal -0x7(%r13), %eax
cmpl $0xc, %eax
ja 0x1bd63
leaq 0x23c57(%rip), %rcx     # 0x3f744
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
callq 0x3784
movq %rax, %r12
movq %rax, %rdi
callq 0x378c
cmpb $0x2, %al
je 0x1bb2e
movzbl %al, %eax
cmpl $0x4, %eax
jne 0x1bd63
movq %r14, %rdi
callq 0x4ea3
movq %rax, %rdi
callq 0x2b2b
testb %al, %al
je 0x1bd63
movq %r14, %rdi
xorl %esi, %esi
callq 0x1c5a9
movq %rax, %r15
testq %rax, %rax
sete %bpl
je 0x1bb58
movq %r15, %rdi
callq 0x136de
cmpb $0x1, %al
je 0x1bb58
movq %r14, %rdi
movq %r15, %rsi
jmp 0x1bb33
movq %r14, %rdi
callq 0x6ad8
testb %bpl, %bpl
jne 0x1bd63
addl $-0x8, %r13d
cmpl $0x5, %r13d
ja 0x1bd63
leaq 0x23bfa(%rip), %rcx     # 0x3f778
movslq (%rcx,%r13,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
movq %r15, %rdi
xorl %esi, %esi
jmp 0x1bd28
callq 0x3784
movq %rax, %rdi
callq 0x378c
movq %r14, %rdi
cmpb $0x4, %al
jne 0x1bc40
callq 0x4ea3
movq %rax, %rdi
callq 0x2b2b
testb %al, %al
je 0x1bcb1
movq %r14, %rdi
callq 0x6ad8
movq 0x88(%rax), %rsi
jmp 0x1bd44
movq %r14, %rdi
xorl %esi, %esi
callq 0x1c404
movq %r14, %rdi
callq 0x6ad8
xorps %xmm0, %xmm0
movups %xmm0, 0x90(%rax)
jmp 0x1bd63
movb $0x1, (%r15)
jmp 0x1bd63
leaq 0x23bd5(%rip), %rsi     # 0x3f7d8
movq %r15, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6bf5
movzbl (%r15), %eax
movl %eax, %ecx
andb $-0x2, %cl
cmpb $0x12, %cl
jne 0x1bc70
movq %r14, %rdi
callq 0x6ad8
movq 0x90(%rax), %rsi
movq %r14, %rdi
testq %rsi, %rsi
jne 0x1bc9e
jmp 0x1bc9c
callq 0x6ad8
movq %rax, %r15
movq 0x98(%rax), %rsi
testq %rsi, %rsi
je 0x1bd3d
movq %r14, %rdi
callq 0x1c404
movq $0x0, 0x98(%r15)
jmp 0x1bd63
cmpl $0x14, %eax
je 0x1bc7e
cmpl $0x11, %eax
jne 0x1bd63
movq %r14, %rdi
callq 0x6ad8
movq 0x90(%rax), %rsi
movq %r14, %rdi
testq %rsi, %rsi
je 0x1bc9c
callq 0x1c5a9
jmp 0x1bca3
xorl %esi, %esi
callq 0x1be72
testq %rax, %rax
jne 0x1bd58
jmp 0x1bd63
movq %r14, %rdi
xorl %esi, %esi
jmp 0x1bd5e
movq %r15, 0x88(%rax)
testb $0x1, 0x78(%r12)
jne 0x1bcdb
movq %r15, %rdi
movl $0x3, %esi
xorl %edx, %edx
callq 0x4fea
movl %eax, %ebx
movq %r12, %rdi
callq 0x3863
testb %al, %al
jne 0x1bcfd
cmpb $0x1, %bl
jne 0x1bcfd
movq %r15, %rdi
movl $0x6, %esi
xorl %edx, %edx
callq 0x4fea
movl %eax, %ebx
cmpb $0x1, %bl
jne 0x1bd63
movq %r15, %rdi
movl $0x7, %esi
jmp 0x1bd28
movq %r15, %rdi
movl $0x1, %esi
jmp 0x1bd28
movq %r15, %rdi
movl $0x4, %esi
jmp 0x1bd28
movq %r15, %rdi
movl $0x5, %esi
xorl %edx, %edx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4fea
movq 0x88(%r15), %rsi
testq %rsi, %rsi
je 0x1bd4e
movq %r14, %rdi
jmp 0x1bd5e
movq %r14, %rdi
xorl %esi, %esi
callq 0x1be72
movq %r14, %rdi
movq %rax, %rsi
callq 0x1c404
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq