// File: /workspace/github_c_makefile_star2_O3/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_page.c
// Function: lv_page_scrollable_signal
static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, void * param)
{
    lv_res_t res;

    /* Include the ancient signal function */
    res = ancestor_signal(scrl, sign, param);
    if(res != LV_RES_OK) return res;
    if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, "");

    lv_obj_t * page               = lv_obj_get_parent(scrl);
    const lv_style_t * page_style = lv_obj_get_style(page);
    lv_page_ext_t * page_ext      = lv_obj_get_ext_attr(page);

    if(sign == LV_SIGNAL_CORD_CHG) {
        /*Limit the position of the scrollable object to be always visible
         * (Do not let its edge inner then its parent respective edge)*/
        lv_coord_t new_x = lv_obj_get_x(scrl);
        lv_coord_t new_y = lv_obj_get_y(scrl);
        bool refr_x      = false;
        bool refr_y      = false;
        lv_area_t page_coords;
        lv_area_t scrl_coords;
        lv_obj_get_coords(scrl, &scrl_coords);
        lv_obj_get_coords(page, &page_coords);

        lv_area_t * ori_coords = (lv_area_t *)param;
        lv_coord_t diff_x      = scrl->coords.x1 - ori_coords->x1;
        lv_coord_t diff_y      = scrl->coords.y1 - ori_coords->y1;
        lv_coord_t hpad        = page_style->body.padding.left + page_style->body.padding.right;
        lv_coord_t vpad        = page_style->body.padding.top + page_style->body.padding.bottom;
        lv_obj_t * page_parent = lv_obj_get_parent(page);

        lv_indev_t * indev = lv_indev_get_act();
        lv_point_t drag_vect;
        lv_indev_get_vect(indev, &drag_vect);

        /* Start the scroll propagation if there is drag vector on the indev, but the drag is not
         * started yet and the scrollable is in a corner. It will enable the scroll propagation only
         * when a new scroll begins and not when the scrollable is already being scrolled.*/
        if(page_ext->scroll_prop && page_ext->scroll_prop_ip == 0 && lv_indev_is_dragging(indev) == false) {
            if(((drag_vect.y > 0 && scrl_coords.y1 == page_coords.y1 + page_style->body.padding.top) ||
                (drag_vect.y < 0 && scrl_coords.y2 == page_coords.y2 - page_style->body.padding.bottom)) &&
               ((drag_vect.x > 0 && scrl_coords.x1 == page_coords.x1 + page_style->body.padding.left) ||
                (drag_vect.x < 0 && scrl_coords.x2 == page_coords.x2 - page_style->body.padding.right))) {

                if(lv_obj_get_parent(page_parent) != NULL) { /*Do not propagate the scroll to a screen*/
                    page_ext->scroll_prop_ip = 1;
                }
            }
        }

        /*scrollable width smaller then page width? -> align to left*/
        if(lv_area_get_width(&scrl_coords) + hpad <= lv_area_get_width(&page_coords)) {
            if(scrl_coords.x1 != page_coords.x1 + page_style->body.padding.left) {
                new_x  = page_style->body.padding.left;
                refr_x = true;
            }
        } else {
            /*If the scroll propagation is in progress revert the original coordinates (don't let
             * the page scroll)*/
            if(page_ext->scroll_prop_ip) {
                if(drag_vect.x == diff_x) { /*`scrl` is bouncing: drag pos. it somewhere and here it
                                               is reverted. Handle only the pos. because of drag*/
                    new_x  = ori_coords->x1 - page_coords.x1;
                    refr_x = true;
                }
            }
            /*The edges of the scrollable can not be in the page (minus hpad) */
            else if(scrl_coords.x2 < page_coords.x2 - page_style->body.padding.right) {
                new_x = lv_area_get_width(&page_coords) - lv_area_get_width(&scrl_coords) -
                        page_style->body.padding.right; /* Right align */
                refr_x = true;
#if LV_USE_ANIMATION
                if(page_ext->edge_flash.enabled && page_ext->edge_flash.left_ip == 0 &&
                   page_ext->edge_flash.right_ip == 0 && page_ext->edge_flash.top_ip == 0 &&
                   page_ext->edge_flash.bottom_ip == 0) {
                    lv_page_start_edge_flash(page);
                    page_ext->edge_flash.right_ip = 1;
                }
#endif
            } else if(scrl_coords.x1 > page_coords.x1 + page_style->body.padding.left) {
                new_x  = page_style->body.padding.left; /*Left align*/
                refr_x = true;
#if LV_USE_ANIMATION
                if(page_ext->edge_flash.enabled && page_ext->edge_flash.left_ip == 0 &&
                   page_ext->edge_flash.right_ip == 0 && page_ext->edge_flash.top_ip == 0 &&
                   page_ext->edge_flash.bottom_ip == 0) {
                    lv_page_start_edge_flash(page);
                    page_ext->edge_flash.left_ip = 1;
                }
#endif
            }
        }

        /*scrollable height smaller then page height? -> align to top*/
        if(lv_area_get_height(&scrl_coords) + vpad <= lv_area_get_height(&page_coords)) {
            if(scrl_coords.y1 != page_coords.y1 + page_style->body.padding.top) {
                new_y  = page_style->body.padding.top;
                refr_y = true;
            }
        } else {
            /*If the scroll propagation is in progress revert the original coordinates (don't let
             * the page scroll)*/
            if(page_ext->scroll_prop_ip) {
                if(drag_vect.y == diff_y) { /*`scrl` is bouncing: drag pos. it somewhere and here it
                                               is reverted. Handle only the pos. because of drag*/
                    new_y  = ori_coords->y1 - page_coords.y1;
                    refr_y = true;
                }
            }
            /*The edges of the scrollable can not be in the page (minus vpad) */
            else if(scrl_coords.y2 < page_coords.y2 - page_style->body.padding.bottom) {
                new_y = lv_area_get_height(&page_coords) - lv_area_get_height(&scrl_coords) -
                        page_style->body.padding.bottom; /* Bottom align */
                refr_y = true;
#if LV_USE_ANIMATION
                if(page_ext->edge_flash.enabled && page_ext->edge_flash.left_ip == 0 &&
                   page_ext->edge_flash.right_ip == 0 && page_ext->edge_flash.top_ip == 0 &&
                   page_ext->edge_flash.bottom_ip == 0) {
                    lv_page_start_edge_flash(page);
                    page_ext->edge_flash.bottom_ip = 1;
                }
#endif
            } else if(scrl_coords.y1 > page_coords.y1 + page_style->body.padding.top) {
                new_y  = page_style->body.padding.top; /*Top align*/
                refr_y = true;
#if LV_USE_ANIMATION
                if(page_ext->edge_flash.enabled && page_ext->edge_flash.left_ip == 0 &&
                   page_ext->edge_flash.right_ip == 0 && page_ext->edge_flash.top_ip == 0 &&
                   page_ext->edge_flash.bottom_ip == 0) {
                    lv_page_start_edge_flash(page);
                    page_ext->edge_flash.top_ip = 1;
                }
#endif
            }
        }

        if(refr_x || refr_y) {
            lv_obj_set_pos(scrl, new_x, new_y);

            if(page_ext->scroll_prop_ip) {
                if(refr_y) lv_obj_set_y(page_parent, lv_obj_get_y(page_parent) + diff_y);
                if(refr_x) lv_obj_set_x(page_parent, lv_obj_get_x(page_parent) + diff_x);
            }
        }

        lv_page_sb_refresh(page);
    } else if(sign == LV_SIGNAL_DRAG_END) {

        /*Scroll propagation is finished on drag end*/
        page_ext->scroll_prop_ip = 0;

        /*Hide scrollbars if required*/
        if(page_ext->sb.mode == LV_SB_MODE_DRAG) {
            lv_disp_t * disp = lv_obj_get_disp(page);
            lv_area_t sb_area_tmp;
            if(page_ext->sb.hor_draw) {
                lv_area_copy(&sb_area_tmp, &page_ext->sb.hor_area);
                sb_area_tmp.x1 += page->coords.x1;
                sb_area_tmp.y1 += page->coords.y1;
                sb_area_tmp.x2 += page->coords.x1;
                sb_area_tmp.y2 += page->coords.y1;
                lv_inv_area(disp, &sb_area_tmp);
                page_ext->sb.hor_draw = 0;
            }
            if(page_ext->sb.ver_draw) {
                lv_area_copy(&sb_area_tmp, &page_ext->sb.ver_area);
                sb_area_tmp.x1 += page->coords.x1;
                sb_area_tmp.y1 += page->coords.y1;
                sb_area_tmp.x2 += page->coords.x1;
                sb_area_tmp.y2 += page->coords.y1;
                lv_inv_area(disp, &sb_area_tmp);
                page_ext->sb.ver_draw = 0;
            }
        }
    }

    return res;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdx, %r13
movl %esi, %r15d
movq %rdi, %r12
callq *0x3ad86(%rip)          # 0x60468
movl %eax, %ebx
cmpb $0x1, %al
jne 0x25bad
cmpb $0x7, %r15b
jne 0x2570f
leaq 0x1dec4(%rip), %rsi     # 0x435bd
movq %r13, %rdi
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6c02
movq %r12, %rdi
callq 0x4ab5
movq %rax, %r14
movq %rax, %rdi
callq 0x66b6
movq %rax, %rbp
movq %r14, %rdi
callq 0x6af7
movb $0x1, %bl
cmpb $0xf, %r15b
je 0x2586b
movzbl %r15b, %ecx
cmpl $0x2, %ecx
jne 0x25bad
movq %r12, %rdi
movq %rax, 0x28(%rsp)
callq 0x4bdd
movl %eax, 0x4c(%rsp)
movq %r12, %rdi
callq 0x4c15
movl %eax, 0x34(%rsp)
leaq 0x20(%rsp), %rsi
movq %r12, %rdi
callq 0x542b
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x542b
movzwl 0x20(%r12), %eax
movzwl 0x22(%r12), %ecx
subw (%r13), %ax
movl %eax, 0x48(%rsp)
subw 0x2(%r13), %cx
movl %ecx, 0x44(%rsp)
movzwl 0x18(%rbp), %eax
movq %r14, %rdi
movzwl 0x1c(%rbp), %r14d
addw 0x1a(%rbp), %r14w
addw 0x16(%rbp), %ax
movw %ax, 0xe(%rsp)
movq %rdi, 0x38(%rsp)
callq 0x4ab5
movq %rax, 0x50(%rsp)
callq 0x378a
movq %rax, %r15
leaq 0x1c(%rsp), %rsi
movq %rax, %rdi
callq 0x3884
movq 0x28(%rsp), %r11
movb 0x4a(%r11), %al
andb $0x3, %al
cmpb $0x1, %al
jne 0x2593c
movq %r15, %rdi
callq 0x3869
movq 0x28(%rsp), %r11
testb %al, %al
jne 0x2593c
cmpw $0x0, 0x1e(%rsp)
jle 0x25906
movswl 0x22(%rsp), %eax
movswl 0x12(%rsp), %ecx
movswl 0x16(%rbp), %edx
addl %ecx, %edx
cmpl %eax, %edx
jne 0x2593c
cmpw $0x0, 0x1c(%rsp)
jle 0x25922
movswl 0x20(%rsp), %eax
movswl 0x10(%rsp), %ecx
movswl 0x1a(%rbp), %edx
addl %ecx, %edx
cmpl %eax, %edx
jne 0x2593c
movq 0x50(%rsp), %rdi
callq 0x4ab5
movq 0x28(%rsp), %r11
testq %rax, %rax
je 0x2593c
orb $0x2, 0x4a(%r11)
jmp 0x2593c
andb $-0x3, 0x4a(%rax)
movb 0x28(%rax), %cl
andb $0x1c, %cl
cmpb $0x8, %cl
jne 0x25bad
movq %r14, %rdi
movq %rax, %r12
callq 0x5061
movq %r12, %rcx
movq %rax, %r15
movb 0x28(%r12), %al
testb $0x1, %al
je 0x258cc
movq 0x20(%r14), %xmm0
pshufd $0x50, %xmm0, %xmm0     # xmm0 = xmm0[0,0,1,1]
movq 0x18(%rcx), %xmm1
paddw %xmm0, %xmm1
leaq 0x10(%rsp), %rsi
movq %xmm1, (%rsi)
movq %r15, %rdi
callq 0x7170
movq %r12, %rcx
movb 0x28(%r12), %al
andb $-0x2, %al
movb %al, 0x28(%r12)
testb $0x2, %al
je 0x25bad
movq 0x20(%r14), %xmm0
pshufd $0x50, %xmm0, %xmm0     # xmm0 = xmm0[0,0,1,1]
movq 0x20(%rcx), %xmm1
paddw %xmm0, %xmm1
leaq 0x10(%rsp), %rsi
movq %xmm1, (%rsi)
movq %r15, %rdi
movq %rcx, %r14
callq 0x7170
andb $-0x3, 0x28(%r14)
jmp 0x25bad
jns 0x2593c
movswl 0x26(%rsp), %eax
movswl 0x16(%rsp), %ecx
movswl 0x18(%rbp), %edx
subl %edx, %ecx
cmpl %eax, %ecx
je 0x25825
jmp 0x2593c
jns 0x2593c
movswl 0x24(%rsp), %eax
movswl 0x14(%rsp), %ecx
movswl 0x1c(%rbp), %edx
subl %edx, %ecx
cmpl %eax, %ecx
je 0x25849
movswl 0x20(%rsp), %eax
movswl 0x24(%rsp), %edi
movl %edi, %ecx
subl %eax, %ecx
leal 0x1(%rcx), %edx
movswl %dx, %edx
movswl %r14w, %r9d
addl %edx, %r9d
movswl 0x10(%rsp), %edx
movswl 0x14(%rsp), %r8d
movl %r8d, %esi
subl %edx, %esi
leal 0x1(%rsi), %r10d
movswl %r10w, %r10d
cmpl %r10d, %r9d
jle 0x259c6
testb $0x2, 0x4a(%r11)
movl 0x4c(%rsp), %r10d
jne 0x25a83
movswl 0x1c(%rbp), %r9d
subl %r9d, %r8d
cmpl %edi, %r8d
jle 0x25ac2
addl %r9d, %ecx
subl %ecx, %esi
movl %esi, %r10d
movb 0x40(%r11), %al
andb $0x1f, %al
movb $0x1, %r15b
cmpb $0x1, %al
jne 0x259db
movq 0x38(%rsp), %rdi
movl %r10d, %r14d
callq 0x27028
movl %r14d, %r10d
movq 0x28(%rsp), %r11
orb $0x8, 0x40(%r11)
jmp 0x259db
movswl 0x1a(%rbp), %ecx
addl %ecx, %edx
cmpl %eax, %edx
setne %r15b
movl 0x4c(%rsp), %r10d
cmovnel %ecx, %r10d
movzwl 0xe(%rsp), %edi
movswl 0x22(%rsp), %eax
movswl 0x26(%rsp), %esi
movl %esi, %ecx
subl %eax, %ecx
leal 0x1(%rcx), %edx
movswl %dx, %edx
movswl %di, %r8d
addl %edx, %r8d
movswl 0x12(%rsp), %edx
movswl 0x16(%rsp), %edi
movl %edi, %r14d
subl %edx, %r14d
leal 0x1(%r14), %r9d
movswl %r9w, %r9d
cmpl %r9d, %r8d
jle 0x25a69
testb $0x2, 0x4a(%r11)
jne 0x25aa7
movswl 0x18(%rbp), %r8d
subl %r8d, %edi
cmpl %esi, %edi
jle 0x25afb
addl %r8d, %ecx
subl %ecx, %r14d
movb 0x40(%r11), %al
andb $0x1f, %al
movb $0x1, %bpl
cmpb $0x1, %al
jne 0x25b43
movq 0x38(%rsp), %rdi
movl %r10d, %r13d
callq 0x27028
movl %r13d, %r10d
movq 0x28(%rsp), %r11
orb $0x4, 0x40(%r11)
jmp 0x25b43
movswl 0x16(%rbp), %ecx
addl %ecx, %edx
cmpl %eax, %edx
setne %bpl
movl 0x34(%rsp), %eax
cmovnel %ecx, %eax
movl %eax, %ecx
jmp 0x25b36
movl 0x48(%rsp), %eax
cmpw %ax, 0x1c(%rsp)
movzwl 0xe(%rsp), %edi
jne 0x25bbe
movzwl (%r13), %r10d
subl %edx, %r10d
movb $0x1, %r15b
jmp 0x259e0
movl 0x44(%rsp), %eax
cmpw %ax, 0x1e(%rsp)
jne 0x25b30
movzwl 0x2(%r13), %r14d
subl %edx, %r14d
movb $0x1, %bpl
jmp 0x25b43
movswl 0x1a(%rbp), %r14d
addl %r14d, %edx
cmpl %eax, %edx
jge 0x25bc6
movb 0x40(%r11), %al
andb $0x1f, %al
movb $0x1, %r15b
cmpb $0x1, %al
jne 0x25af3
movq 0x38(%rsp), %rdi
callq 0x27028
movq 0x28(%rsp), %r11
orb $0x10, 0x40(%r11)
movl %r14d, %r10d
jmp 0x259db
movswl 0x16(%rbp), %r14d
addl %r14d, %edx
cmpl %eax, %edx
jge 0x25b30
movb 0x40(%r11), %al
andb $0x1f, %al
movb $0x1, %bpl
cmpb $0x1, %al
jne 0x25b43
movq 0x38(%rsp), %rdi
movl %r10d, %r13d
callq 0x27028
movl %r13d, %r10d
movq 0x28(%rsp), %r11
orb $0x2, 0x40(%r11)
jmp 0x25b43
xorl %ebp, %ebp
movl 0x34(%rsp), %ecx
movl %r15d, %eax
orb %bpl, %al
movl %ecx, %r14d
cmpb $0x1, %al
jne 0x25ba3
movswl %r10w, %esi
movswl %r14w, %edx
movq %r12, %rdi
movq %r11, %r14
callq 0x4ad8
testb $0x2, 0x4a(%r14)
je 0x25ba3
testb %bpl, %bpl
je 0x25b80
movq 0x50(%rsp), %r14
movq %r14, %rdi
callq 0x4c15
movl 0x44(%rsp), %ecx
addl %eax, %ecx
movswl %cx, %esi
movq %r14, %rdi
callq 0x5519
testb %r15b, %r15b
je 0x25ba3
movq 0x50(%rsp), %r14
movq %r14, %rdi
callq 0x4bdd
movl 0x48(%rsp), %ecx
addl %eax, %ecx
movswl %cx, %esi
movq %r14, %rdi
callq 0x54db
movq 0x38(%rsp), %rdi
callq 0x26538
movl %ebx, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r15d, %r15d
jmp 0x259e0
xorl %r15d, %r15d
jmp 0x259db