// File: /workspace/github_c_makefile_star2_O1/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 $0x48, %rsp
movq %rdx, %rbp
movl %esi, %r15d
movq %rdi, %r12
callq *0x3b482(%rip)          # 0x60468
movl %eax, %ebx
cmpb $0x1, %al
jne 0x254cc
cmpb $0x7, %r15b
jne 0x25013
leaq 0x1e3d0(%rip), %rsi     # 0x433cd
movq %rbp, %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6bf5
movq %r12, %rdi
callq 0x4abf
movq %rax, %r14
movq %rax, %rdi
callq 0x6697
movq %rax, %r13
movq %r14, %rdi
callq 0x6ad8
cmpb $0xf, %r15b
je 0x25219
movzbl %r15b, %ecx
cmpl $0x2, %ecx
jne 0x254cc
movq %r12, %rdi
movq %rax, 0x28(%rsp)
callq 0x4bc6
movl %eax, 0x4(%rsp)
movq %r12, %rdi
callq 0x4bfe
movl %eax, 0x34(%rsp)
leaq 0x20(%rsp), %rsi
movq %r12, %rdi
callq 0x5427
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x5427
movzwl 0x20(%r12), %eax
movzwl 0x22(%r12), %ecx
subw (%rbp), %ax
movl %eax, 0x3c(%rsp)
subw 0x2(%rbp), %cx
movl %ecx, 0x38(%rsp)
movzwl 0x18(%r13), %eax
movq %r14, %rdi
movzwl 0x1c(%r13), %r14d
addw 0x1a(%r13), %r14w
addw 0x16(%r13), %ax
movw %ax, 0x2(%rsp)
movq %rdi, 0x10(%rsp)
callq 0x4abf
movq %rax, 0x40(%rsp)
callq 0x3784
movq %rax, %r15
leaq 0x1c(%rsp), %rsi
movq %rax, %rdi
callq 0x387e
movq 0x28(%rsp), %r11
movb 0x4a(%r11), %al
andb $0x3, %al
cmpb $0x1, %al
jne 0x2518e
movq %r15, %rdi
callq 0x3863
movq 0x28(%rsp), %r11
testb %al, %al
jne 0x2518e
movzwl 0x1e(%rsp), %eax
testw %ax, %ax
jle 0x25122
movswl 0x22(%rsp), %ecx
movswl 0xa(%rsp), %edx
movswl 0x16(%r13), %esi
addl %edx, %esi
cmpl %ecx, %esi
je 0x2513c
testw %ax, %ax
jns 0x2518e
movswl 0x26(%rsp), %eax
movswl 0xe(%rsp), %ecx
movswl 0x18(%r13), %edx
subl %edx, %ecx
cmpl %eax, %ecx
jne 0x2518e
movzwl 0x1c(%rsp), %eax
testw %ax, %ax
jle 0x2515b
movswl 0x20(%rsp), %ecx
movswl 0x8(%rsp), %edx
movswl 0x1a(%r13), %esi
addl %edx, %esi
cmpl %ecx, %esi
je 0x25175
testw %ax, %ax
jns 0x2518e
movswl 0x24(%rsp), %eax
movswl 0xc(%rsp), %ecx
movswl 0x1c(%r13), %edx
subl %edx, %ecx
cmpl %eax, %ecx
jne 0x2518e
movq 0x40(%rsp), %rdi
callq 0x4abf
movq 0x28(%rsp), %r11
testq %rax, %rax
je 0x2518e
orb $0x2, 0x4a(%r11)
movswl 0x24(%rsp), %esi
movswl 0x20(%rsp), %eax
movl %esi, %ecx
subl %eax, %ecx
incl %ecx
movswl %cx, %edx
movswl %r14w, %r9d
addl %edx, %r9d
movswl 0xc(%rsp), %r8d
movswl 0x8(%rsp), %edx
movl %r8d, %edi
subl %edx, %edi
incl %edi
movswl %di, %r10d
cmpl %r10d, %r9d
jle 0x252bf
testb $0x2, 0x4a(%r11)
movq 0x10(%rsp), %r14
jne 0x2537d
movswl 0x1c(%r13), %r9d
subl %r9d, %r8d
cmpl %esi, %r8d
jle 0x253c2
addl %r9d, %ecx
subl %ecx, %edi
movl %edi, 0x4(%rsp)
movb 0x40(%r11), %al
andb $0x1f, %al
movb $0x1, %r15b
cmpb $0x1, %al
jne 0x252dc
movq %r14, %rdi
callq 0x26952
movq 0x28(%rsp), %r11
orb $0x8, 0x40(%r11)
jmp 0x252dc
andb $-0x3, 0x4a(%rax)
movb 0x28(%rax), %cl
andb $0x1c, %cl
cmpb $0x8, %cl
jne 0x254cc
movq %r14, %rdi
movq %rax, %r15
callq 0x5033
movq %r15, %rdx
movq %rax, %r12
testb $0x1, 0x28(%r15)
je 0x2527a
movq 0x18(%rdx), %rax
leaq 0x8(%rsp), %rsi
movq %rax, (%rsi)
movl 0x20(%r14), %ecx
addl %ecx, %eax
movw %ax, (%rsi)
movzwl 0x22(%r14), %eax
addw %ax, 0x2(%rsi)
addw %cx, 0x4(%rsi)
addw %ax, 0x6(%rsi)
movq %r12, %rdi
callq 0x7184
movq %r15, %rdx
andb $-0x2, 0x28(%r15)
testb $0x2, 0x28(%rdx)
je 0x254cc
movq 0x20(%rdx), %rax
leaq 0x8(%rsp), %rsi
movq %rax, (%rsi)
movl 0x20(%r14), %ecx
addl %ecx, %eax
movw %ax, (%rsi)
movzwl 0x22(%r14), %eax
addw %ax, 0x2(%rsi)
addw %cx, 0x4(%rsi)
addw %ax, 0x6(%rsi)
movq %r12, %rdi
movq %rdx, %r14
callq 0x7184
andb $-0x3, 0x28(%r14)
jmp 0x254cc
movswl 0x1a(%r13), %ecx
addl %ecx, %edx
cmpl %eax, %edx
setne %r15b
movl 0x4(%rsp), %eax
cmovnel %ecx, %eax
movl %eax, 0x4(%rsp)
movq 0x10(%rsp), %r14
movzwl 0x2(%rsp), %edi
movswl 0x26(%rsp), %esi
movswl 0x22(%rsp), %eax
movl %esi, %ecx
subl %eax, %ecx
incl %ecx
movswl %cx, %edx
movswl %di, %r9d
addl %edx, %r9d
movswl 0xe(%rsp), %r8d
movswl 0xa(%rsp), %edx
movl %r8d, %edi
subl %edx, %edi
incl %edi
movswl %di, %r10d
cmpl %r10d, %r9d
jle 0x25362
testb $0x2, 0x4a(%r11)
jne 0x253a3
movswl 0x18(%r13), %r9d
subl %r9d, %r8d
cmpl %esi, %r8d
jle 0x253f9
addl %r9d, %ecx
subl %ecx, %edi
movl %edi, %r13d
movb 0x40(%r11), %al
andb $0x1f, %al
movb $0x1, %bpl
cmpb $0x1, %al
jne 0x25458
movq %r14, %rdi
callq 0x26952
movq 0x28(%rsp), %r11
orb $0x4, 0x40(%r11)
jmp 0x25458
movswl 0x16(%r13), %ecx
addl %ecx, %edx
cmpl %eax, %edx
setne %bpl
movl 0x34(%rsp), %r13d
cmovnel %ecx, %r13d
jmp 0x25458
movl 0x3c(%rsp), %eax
cmpw %ax, 0x1c(%rsp)
movzwl 0x2(%rsp), %edi
jne 0x25438
movzwl (%rbp), %eax
subl %edx, %eax
movl %eax, 0x4(%rsp)
movb $0x1, %r15b
jmp 0x252e1
movl 0x38(%rsp), %eax
cmpw %ax, 0x1e(%rsp)
jne 0x25440
movzwl 0x2(%rbp), %r13d
subl %edx, %r13d
movb $0x1, %bpl
jmp 0x25458
movswl 0x1a(%r13), %r14d
addl %r14d, %edx
cmpl %eax, %edx
jge 0x25444
movb 0x40(%r11), %al
andb $0x1f, %al
movb $0x1, %r15b
cmpb $0x1, %al
jne 0x253ef
movq 0x10(%rsp), %rdi
callq 0x26952
movq 0x28(%rsp), %r11
orb $0x10, 0x40(%r11)
movl %r14d, 0x4(%rsp)
jmp 0x252d7
movswl 0x16(%r13), %r14d
addl %r14d, %edx
cmpl %eax, %edx
jge 0x2544c
movb 0x40(%r11), %al
andb $0x1f, %al
movb $0x1, %bpl
cmpb $0x1, %al
jne 0x254dd
movq 0x10(%rsp), %r13
movq %r13, %rdi
callq 0x26952
movq 0x28(%rsp), %r11
orb $0x2, 0x40(%r11)
movl %r14d, %eax
movq %r13, %r14
movl %eax, %r13d
jmp 0x25458
xorl %r15d, %r15d
jmp 0x252e1
xorl %ebp, %ebp
jmp 0x25453
xorl %r15d, %r15d
jmp 0x252d7
xorl %ebp, %ebp
movq 0x10(%rsp), %r14
movl 0x34(%rsp), %r13d
movl %r15d, %eax
orb %bpl, %al
cmpb $0x1, %al
jne 0x254c4
movswl 0x4(%rsp), %esi
movswl %r13w, %edx
movq %r12, %rdi
movq %r11, %r12
callq 0x4ae2
testb $0x2, 0x4a(%r12)
je 0x254c4
testb %bpl, %bpl
je 0x254a1
movq 0x40(%rsp), %r12
movq %r12, %rdi
callq 0x4bfe
movl 0x38(%rsp), %ecx
addl %eax, %ecx
movswl %cx, %esi
movq %r12, %rdi
callq 0x5501
testb %r15b, %r15b
je 0x254c4
movq 0x40(%rsp), %r15
movq %r15, %rdi
callq 0x4bc6
movl 0x3c(%rsp), %ecx
addl %eax, %ecx
movswl %cx, %esi
movq %r15, %rdi
callq 0x54c3
movq %r14, %rdi
callq 0x25e4c
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %r14d, %r13d
movq 0x10(%rsp), %r14
jmp 0x25458