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

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

    lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
    lv_obj_t * child;
    if(sign == LV_SIGNAL_CHILD_CHG) { /*Automatically move children to the scrollable object*/
        const lv_style_t * style_bg = lv_page_get_style(page, LV_PAGE_STYLE_BG);
        const lv_style_t * style_scrl = lv_page_get_style(page, LV_PAGE_STYLE_SCRL);
        lv_fit_t fit_left        = lv_page_get_scrl_fit_left(page);
        lv_fit_t fit_right        = lv_page_get_scrl_fit_right(page);
        lv_fit_t fit_top         = lv_page_get_scrl_fit_top(page);
        child                    = lv_obj_get_child(page, NULL);
        while(child != NULL) {
            if(lv_obj_is_protected(child, LV_PROTECT_PARENT) == false) {
                lv_obj_t * tmp = child;
                child          = lv_obj_get_child(page, child); /*Get the next child before move this*/

                /* Reposition the child to take padding into account (Only if it's on (0;0) or (widht;height) coordinates now)
                 * It's required to keep new the object on the same coordinate if FIT is enabled.*/
                if((tmp->coords.x1 == page->coords.x1) && (fit_left == LV_FIT_TIGHT || fit_left == LV_FIT_FILL)) {
                    tmp->coords.x1 += style_scrl->body.padding.left;
                    tmp->coords.x2 += style_scrl->body.padding.left;
                }
                else if((tmp->coords.x2 == page->coords.x2) && (fit_right == LV_FIT_TIGHT || fit_right == LV_FIT_FILL)) {
                    tmp->coords.x1 -= style_scrl->body.padding.right + style_bg->body.padding.right;
                    tmp->coords.x2 -= style_scrl->body.padding.right + style_bg->body.padding.right;
                }
                if((tmp->coords.y1 == page->coords.y1) && (fit_top == LV_FIT_TIGHT || fit_top == LV_FIT_FILL)) {
                    tmp->coords.y1 += style_scrl->body.padding.top;
                    tmp->coords.y2 += style_scrl->body.padding.top;
                }
                lv_obj_set_parent(tmp, ext->scrl);
            } else {
                child = lv_obj_get_child(page, child);
            }
        }
    } else if(sign == LV_SIGNAL_STYLE_CHG) {
        ext->scrl->signal_cb(ext->scrl, LV_SIGNAL_CORD_CHG, &ext->scrl->coords);

        /*The scrollbars are important only if they are visible now*/
        if(ext->sb.hor_draw || ext->sb.ver_draw) lv_page_sb_refresh(page);

        /*Refresh the ext. size because the scrollbars might be positioned out of the page*/
        lv_obj_refresh_ext_draw_pad(page);
    } else if(sign == LV_SIGNAL_CORD_CHG) {
        /*Refresh the scrollbar and notify the scrl if the size is changed*/
        if(ext->scrl != NULL && (lv_obj_get_width(page) != lv_area_get_width(param) ||
                                 lv_obj_get_height(page) != lv_area_get_height(param))) {
            /*If no hor_fit enabled set the scrollable's width to the page's width*/
            ext->scrl->signal_cb(ext->scrl, LV_SIGNAL_CORD_CHG, &ext->scrl->coords);

            /*The scrollbars are important only if they are visible now*/
            if(ext->sb.hor_draw || ext->sb.ver_draw) lv_page_sb_refresh(page);
        }
    } else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
        /*Ensure ext. size for the scrollbars if they are out of the page*/
        if(page->ext_draw_pad < (-ext->sb.style->body.padding.right))
            page->ext_draw_pad = -ext->sb.style->body.padding.right;
        if(page->ext_draw_pad < (-ext->sb.style->body.padding.bottom))
            page->ext_draw_pad = -ext->sb.style->body.padding.bottom;
    } else if(sign == LV_SIGNAL_CONTROL) {
        uint32_t c = *((uint32_t *)param);

        if(c == LV_KEY_DOWN) {
            lv_page_scroll_ver(page, -lv_obj_get_height(page) / 4);
        } else if(c == LV_KEY_UP) {
            lv_page_scroll_ver(page, lv_obj_get_height(page) / 4);
        } else if(c == LV_KEY_RIGHT) {
            /*If the page can't be scrolled horizontally because it's not wide enough then scroll it
             * vertically*/
            if(lv_page_get_scrl_width(page) <= lv_obj_get_width(page))
                lv_page_scroll_ver(page, -lv_obj_get_height(page) / 4);
            else
                lv_page_scroll_hor(page, -lv_obj_get_width(page) / 4);
        } else if(c == LV_KEY_LEFT) {
            /*If the page can't be scrolled horizontally because it's not wide enough then scroll it
             * vertically*/
            if(lv_page_get_scrl_width(page) <= lv_obj_get_width(page))
                lv_page_scroll_ver(page, lv_obj_get_height(page) / 4);
            else
                lv_page_scroll_hor(page, lv_obj_get_width(page) / 4);
        }
    } else if(sign == LV_SIGNAL_GET_EDITABLE) {
        bool * editable = (bool *)param;
        *editable       = true;
    }

    return res;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %r15
movl %esi, %ebp
movq %rdi, %r14
callq *0x3aa75(%rip)          # 0x5e468
movl %eax, %ebx
cmpb $0x1, %al
jne 0x23d31
cmpb $0x7, %bpl
jne 0x23a20
leaq 0x180be(%rip), %rsi     # 0x3bac8
movq %r15, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x684b
movq %r14, %rdi
callq 0x6747
movq %rax, 0x10(%rsp)
movzbl %bpl, %eax
movb $0x1, %bl
leal -0x1(%rax), %ecx
cmpl $0x5, %ecx
ja 0x23b98
leaq 0x1803a(%rip), %rax     # 0x3ba80
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movq %r14, %rdi
xorl %esi, %esi
callq 0x24149
movq %rax, 0x20(%rsp)
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x24149
movq %rax, 0x18(%rsp)
movq %r14, %rdi
callq 0x245d9
movq %rax, %rdi
callq 0x20d3a
movl %eax, %ebp
movq %r14, %rdi
callq 0x245d9
movq %rax, %rdi
callq 0x20d69
movl %eax, %r15d
movq %r14, %rdi
callq 0x245d9
movq %rax, %rdi
callq 0x20d96
movl %eax, %r13d
movq %r14, %rdi
xorl %esi, %esi
callq 0x4e4d
movq %rax, %r12
andb $-0x3, %bpl
movb %bpl, 0xf(%rsp)
andb $-0x3, %r15b
movb %r15b, 0xd(%rsp)
andb $-0x3, %r13b
movb %r13b, 0xe(%rsp)
pushq $0x2
popq %rbp
testq %r12, %r12
je 0x23d31
movq %r12, %r15
movq %r12, %rdi
movl %ebp, %esi
callq 0x66ab
movl %eax, %r13d
movq %r14, %rdi
movq %r12, %rsi
callq 0x4e4d
movq %rax, %r12
testb %r13b, %r13b
jne 0x23ad1
movzwl 0x20(%r15), %eax
cmpw 0x20(%r14), %ax
jne 0x23b27
cmpb $0x1, 0xf(%rsp)
jne 0x23b27
movq 0x18(%rsp), %rcx
movzwl 0x1a(%rcx), %ecx
addl %ecx, %eax
movw %ax, 0x20(%r15)
addw %cx, 0x24(%r15)
jmp 0x23b5a
movzwl 0x24(%r15), %ecx
cmpw 0x24(%r14), %cx
jne 0x23b5a
cmpb $0x1, 0xd(%rsp)
jne 0x23b5a
movq 0x20(%rsp), %rdx
movzwl 0x1c(%rdx), %edx
movq 0x18(%rsp), %rsi
addw 0x1c(%rsi), %dx
subl %edx, %eax
movw %ax, 0x20(%r15)
subl %edx, %ecx
movw %cx, 0x24(%r15)
movzwl 0x22(%r15), %eax
cmpw 0x22(%r14), %ax
jne 0x23b82
cmpb $0x1, 0xe(%rsp)
jne 0x23b82
movq 0x18(%rsp), %rcx
movzwl 0x16(%rcx), %ecx
addl %ecx, %eax
movw %ax, 0x22(%r15)
addw %cx, 0x26(%r15)
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rsi
movq %r15, %rdi
callq 0x4eff
jmp 0x23ad1
cmpl $0x12, %eax
je 0x23c8a
cmpl $0x13, %eax
jne 0x23d31
movb $0x1, (%r15)
jmp 0x23d31
movswl 0x5c(%r14), %eax
movq 0x10(%rsp), %rcx
movq 0x10(%rcx), %rcx
movswl 0x1c(%rcx), %edx
negl %edx
cmpl %edx, %eax
jge 0x23bd3
movw %dx, 0x5c(%r14)
movswl %dx, %eax
movswl 0x18(%rcx), %ecx
negl %ecx
cmpl %ecx, %eax
jge 0x23d31
movw %cx, 0x5c(%r14)
jmp 0x23d31
movq 0x10(%rsp), %rax
cmpq $0x0, 0x8(%rax)
je 0x23d31
movq %r14, %rdi
callq 0x5308
movzwl 0x4(%r15), %ecx
subw (%r15), %cx
incl %ecx
cmpw %cx, %ax
jne 0x23c30
movq %r14, %rdi
callq 0x5332
movzwl 0x6(%r15), %ecx
subw 0x2(%r15), %cx
incl %ecx
cmpw %cx, %ax
je 0x23d31
movq 0x10(%rsp), %r15
movq 0x8(%r15), %rdi
leaq 0x20(%rdi), %rdx
pushq $0x2
popq %rsi
callq *0x30(%rdi)
testb $0x3, 0x28(%r15)
je 0x23d31
movq %r14, %rdi
callq 0x241b6
jmp 0x23d31
movq 0x10(%rsp), %r15
movq 0x8(%r15), %rdi
leaq 0x20(%rdi), %rdx
pushq $0x2
popq %rsi
callq *0x30(%rdi)
testb $0x3, 0x28(%r15)
je 0x23c7d
movq %r14, %rdi
callq 0x241b6
movq %r14, %rdi
callq 0x617f
jmp 0x23d31
movl (%r15), %eax
addl $-0x11, %eax
cmpl $0x3, %eax
ja 0x23d31
leaq 0x17df8(%rip), %rcx     # 0x3ba98
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r14, %rdi
callq 0x24d34
movl %eax, %ebp
movq %r14, %rdi
callq 0x5308
cmpw %ax, %bp
jle 0x23cd0
movq %r14, %rdi
callq 0x5308
cwtd
movw $0xfffc, %cx            # imm = 0xFFFC
jmp 0x23d05
movq %r14, %rdi
callq 0x5332
cwtd
movw $0xfffc, %cx            # imm = 0xFFFC
jmp 0x23d23
movq %r14, %rdi
callq 0x24d34
movl %eax, %ebp
movq %r14, %rdi
callq 0x5308
cmpw %ax, %bp
jle 0x23d15
movq %r14, %rdi
callq 0x5308
cwtd
movw $0x4, %cx
idivw %cx
movswl %ax, %esi
movq %r14, %rdi
callq 0x24bd5
jmp 0x23d31
movq %r14, %rdi
callq 0x5332
cwtd
movw $0x4, %cx
idivw %cx
movswl %ax, %esi
movq %r14, %rdi
callq 0x24c34
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq