// File: /workspace/github_c_makefile_star2_O1/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 %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %r12d
movq %rdi, %r15
callq *0x51273(%rip)          # 0x60310
movl %eax, %ebp
cmpb $0x1, %al
jne 0xf1e3
callq 0x3784
movq %rax, %r13
movl $0xffffffff, 0x4(%rsp)  # imm = 0xFFFFFFFF
movq %r15, %rdi
callq 0x4abf
movq %rax, %rbx
movq %rax, %rdi
callq 0x6ad8
movq 0x50(%rax), %rdi
testq %rdi, %rdi
je 0xf184
movq %rax, %r14
callq 0x6697
cmpb $0x8, %r12b
je 0xf1c0
movzbl %r12b, %ecx
cmpl $0xb, %ecx
je 0xf188
cmpl $0xf, %ecx
jne 0xf1cf
movq 0x28(%rax), %rcx
movzbl 0x10(%rcx), %ecx
movq 0x50(%r14), %rdx
movzwl 0x22(%rdx), %edx
movswl 0x22(%rbx), %esi
subl %esi, %edx
movzwl 0x32(%rax), %eax
addl %eax, %ecx
movswl 0x26(%rbx), %edi
subl %esi, %edi
movl %edi, %esi
shrl $0x1f, %esi
addl %edi, %esi
sarl %esi
movswl %dx, %edx
movl %eax, %edi
shrl $0xf, %edi
addl %eax, %edi
movswl %di, %eax
sarl %eax
subl %edx, %eax
addl %esi, %eax
movswl %cx, %ecx
cltd
idivl %ecx
xorl %ecx, %ecx
testl %eax, %eax
cmovgl %eax, %ecx
movl %ecx, 0x4(%rsp)
movzwl 0x60(%r14), %eax
cmpl %eax, %ecx
jb 0xf15d
decl %eax
movl %eax, 0x4(%rsp)
leaq 0x4(%rsp), %rdx
movzwl (%rdx), %eax
movw %ax, 0x62(%r14)
movw %ax, 0x64(%r14)
movq %rbx, %rdi
movl $0xe, %esi
callq 0x4fea
movl %eax, %ebp
cmpb $0x1, %al
je 0xf1cf
jmp 0xf1e3
xorl %ebp, %ebp
jmp 0xf1e3
movq %r13, %rdi
callq 0x3863
testb %al, %al
jne 0xf1cf
movzwl 0x62(%r14), %eax
movl %eax, 0x4(%rsp)
movq %rbx, %rdi
callq 0x4ea3
movq %rax, %r14
movq %rax, %rdi
callq 0x2b2b
testb %al, %al
je 0xf1cf
movq %r14, %rdi
xorl %esi, %esi
callq 0x27ad
jmp 0xf1cf
leaq -0x9cc6(%rip), %rsi     # 0x5501
movq %r15, %rdi
callq 0x295b1
cmpl $-0x1, 0x4(%rsp)
je 0xf1e3
movq %rbx, %rdi
movl $0x1, %esi
callq 0xf56f
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq