// File: /workspace/github_c_makefile_star2_O2/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_roller.c
// Function: lv_roller_scrl_signal
static lv_res_t lv_roller_scrl_signal(lv_obj_t * roller_scrl, lv_signal_t sign, void * param)
{
    lv_res_t res;

    /* Include the ancient signal function */
    res = ancestor_scrl_signal(roller_scrl, sign, param);
    if(res != LV_RES_OK) return res;

    lv_indev_t * indev    = lv_indev_get_act();
    int32_t id            = -1;
    lv_obj_t * roller     = lv_obj_get_parent(roller_scrl);
    lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);

    if(ext->ddlist.label == NULL)
        return LV_RES_INV; /*On delete the ddlist signal deletes the label so nothing left to do
                              here*/

    const lv_style_t * style_label = lv_obj_get_style(ext->ddlist.label);
    const lv_font_t * font         = style_label->text.font;
    lv_coord_t font_h              = lv_font_get_line_height(font);

    if(sign == LV_SIGNAL_DRAG_END) {
        /*If dragged then align the list to have an element in the middle*/
        lv_coord_t label_y1   = ext->ddlist.label->coords.y1 - roller->coords.y1;
        lv_coord_t label_unit = font_h + style_label->text.line_space;
        lv_coord_t mid        = (roller->coords.y2 - roller->coords.y1) / 2;

        id = (mid - label_y1 + style_label->text.line_space / 2) / label_unit;

        if(id < 0) id = 0;
        if(id >= ext->ddlist.option_cnt) id = ext->ddlist.option_cnt - 1;

        ext->ddlist.sel_opt_id     = id;
        ext->ddlist.sel_opt_id_ori = id;
        res                        = lv_event_send(roller, LV_EVENT_VALUE_CHANGED, &id);
        if(res != LV_RES_OK) return res;
    }
    /*If picked an option by clicking then set it*/
    else if(sign == LV_SIGNAL_RELEASED) {
        if(!lv_indev_is_dragging(indev)) {
            id = ext->ddlist.sel_opt_id;
#if LV_USE_GROUP
            /*In edit mode go to navigate mode if an option is selected*/
            lv_group_t * g = lv_obj_get_group(roller);
            bool editing   = lv_group_get_editing(g);
            if(editing) lv_group_set_editing(g, false);
#endif
        }
    } else if(sign == LV_SIGNAL_PRESSED) {
#if LV_USE_ANIMATION
        lv_anim_del(roller_scrl, (lv_anim_exec_xcb_t)lv_obj_set_y);
#endif
    }

    /*Position the scrollable according to the new selected option*/
    if(id != -1) {
        refr_position(roller, true);
    }

    return res;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movl %esi, %ebp
movq %rdi, %r15
callq *0x4fdf0(%rip)          # 0x5e310
cmpb $0x1, %al
jne 0xe65c
callq 0x35b3
movq %rax, %r12
movq %r15, %rdi
callq 0x47bc
movq %rax, %rbx
movq %rax, %rdi
callq 0x6747
movq 0x50(%rax), %rdi
testq %rdi, %rdi
je 0xe604
movq %rax, %r14
callq 0x6316
cmpb $0x8, %bpl
je 0xe64b
movzbl %bpl, %ecx
cmpl $0xb, %ecx
je 0xe608
cmpl $0xf, %ecx
jne 0xe65a
movq 0x28(%rax), %rcx
movzbl 0x10(%rcx), %edi
movq 0x50(%r14), %rcx
movzwl 0x22(%rcx), %r8d
movswl 0x22(%rbx), %edx
subl %edx, %r8d
movzwl 0x32(%rax), %ecx
addl %ecx, %edi
movswl 0x26(%rbx), %eax
subl %edx, %eax
pushq $0x2
popq %rsi
cltd
idivl %esi
movl %eax, %esi
movswl %r8w, %r8d
movw $0x2, %r9w
movl %ecx, %eax
cwtd
idivw %r9w
cwtl
subl %r8d, %eax
addl %esi, %eax
movswl %di, %ecx
cltd
idivl %ecx
xorl %ecx, %ecx
testl %eax, %eax
cmovgl %eax, %ecx
movl %ecx, 0xc(%rsp)
movzwl 0x60(%r14), %eax
cmpl %eax, %ecx
jb 0xe5dd
decl %eax
movl %eax, 0xc(%rsp)
movl %eax, %ecx
movw %cx, 0x62(%r14)
movw %cx, 0x64(%r14)
pushq $0xe
popq %rsi
leaq 0xc(%rsp), %rdx
movq %rbx, %rdi
callq 0x4caf
cmpb $0x1, %al
jne 0xe65c
cmpl $-0x1, 0xc(%rsp)
jne 0xe63e
jmp 0xe65a
xorl %eax, %eax
jmp 0xe65c
movq %r12, %rdi
callq 0x3691
testb %al, %al
jne 0xe65a
movzwl 0x62(%r14), %eax
movl %eax, 0xc(%rsp)
movq %rbx, %rdi
callq 0x4b8e
movq %rax, %r14
movq %rax, %rdi
callq 0x2aaa
testb %al, %al
je 0xe63e
movq %r14, %rdi
xorl %esi, %esi
callq 0x275c
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xe9c3
jmp 0xe65a
leaq -0x9482(%rip), %rsi     # 0x51d0
movq %r15, %rdi
callq 0x27715
movb $0x1, %al
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq