// File: /workspace/github_c_makefile_star2_O3/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 *0x51308(%rip)          # 0x60310
cmpb $0x1, %al
jne 0xf143
callq 0x378a
movq %rax, %r12
movq %r15, %rdi
callq 0x4ab5
movq %rax, %rbx
movq %rax, %rdi
callq 0x6af7
movq 0x50(%rax), %rdi
testq %rdi, %rdi
je 0xf0e9
movq %rax, %r14
callq 0x66b6
cmpb $0x8, %bpl
je 0xf132
movzbl %bpl, %ecx
cmpl $0xb, %ecx
je 0xf0ed
cmpl $0xf, %ecx
jne 0xf141
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, 0xc(%rsp)
movzwl 0x60(%r14), %eax
cmpl %eax, %ecx
jb 0xf0c0
decl %eax
movl %eax, 0xc(%rsp)
movl %eax, %ecx
movw %cx, 0x62(%r14)
movw %cx, 0x64(%r14)
leaq 0xc(%rsp), %rdx
movq %rbx, %rdi
movl $0xe, %esi
callq 0x5018
cmpb $0x1, %al
jne 0xf143
cmpl $-0x1, 0xc(%rsp)
jne 0xf123
jmp 0xf141
xorl %eax, %eax
jmp 0xf143
movq %r12, %rdi
callq 0x3869
testb %al, %al
jne 0xf141
movzwl 0x62(%r14), %eax
movl %eax, 0xc(%rsp)
movq %rbx, %rdi
callq 0x4ed1
movq %rax, %r14
movq %rax, %rdi
callq 0x2b0b
testb %al, %al
je 0xf123
movq %r14, %rdi
xorl %esi, %esi
callq 0x27a6
movq %rbx, %rdi
movl $0x1, %esi
callq 0xf4cb
jmp 0xf141
leaq -0x9c20(%rip), %rsi     # 0x5519
movq %r15, %rdi
callq 0x29c44
movb $0x1, %al
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq