// File: /workspace/github_c_makefile_star2_O3/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_ddlist.c
// Function: lv_ddlist_design
static bool lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * mask, lv_design_mode_t mode)
{
    /*Return false if the object is not covers the mask_p area*/
    if(mode == LV_DESIGN_COVER_CHK) {
        return ancestor_design(ddlist, mask, mode);
    }
    /*Draw the object*/
    else if(mode == LV_DESIGN_DRAW_MAIN) {
        ancestor_design(ddlist, mask, mode);

        lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
        lv_opa_t opa_scale    = lv_obj_get_opa_scale(ddlist);
        /*If the list is opened draw a rectangle under the selected item*/
        if(ext->opened != 0 || ext->force_sel) {
            const lv_style_t * style = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_BG);
            const lv_font_t * font   = style->text.font;
            lv_coord_t font_h        = lv_font_get_line_height(font);

            /*Draw the selected*/
            lv_area_t rect_area;
            rect_area.y1 = ext->label->coords.y1;
            rect_area.y1 += ext->sel_opt_id * (font_h + style->text.line_space);
            rect_area.y1 -= style->text.line_space / 2;

            rect_area.y2 = rect_area.y1 + font_h + style->text.line_space - 1;
            rect_area.x1 = ddlist->coords.x1;
            rect_area.x2 = ddlist->coords.x2;

            lv_draw_rect(&rect_area, mask, ext->sel_style, opa_scale);
        }
    }
    /*Post draw when the children are drawn*/
    else if(mode == LV_DESIGN_DRAW_POST) {
        /*Redraw the text on the selected area with a different color*/
        lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
        lv_opa_t opa_scale    = lv_obj_get_opa_scale(ddlist);

        /*Redraw only in opened state*/
        if(ext->opened || ext->force_sel) {
            const lv_style_t * style = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_BG);
            const lv_font_t * font   = style->text.font;
            lv_coord_t font_h        = lv_font_get_line_height(font);

            lv_area_t area_sel;
            area_sel.y1 = ext->label->coords.y1;
            area_sel.y1 += ext->sel_opt_id * (font_h + style->text.line_space);
            area_sel.y1 -= style->text.line_space / 2;

            area_sel.y2 = area_sel.y1 + font_h + style->text.line_space - 1;
            area_sel.x1 = ddlist->coords.x1;
            area_sel.x2 = ddlist->coords.x2;
            lv_area_t mask_sel;
            bool area_ok;
            area_ok = lv_area_intersect(&mask_sel, mask, &area_sel);
            if(area_ok) {
                const lv_style_t * sel_style = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_SEL);
                lv_style_t new_style;
                lv_style_copy(&new_style, style);
                new_style.text.color = sel_style->text.color;
                new_style.text.opa   = sel_style->text.opa;
                lv_txt_flag_t flag   = lv_ddlist_get_txt_flag(ddlist);
                lv_draw_label(&ext->label->coords, &mask_sel, &new_style, opa_scale, lv_label_get_text(ext->label),
                              flag, NULL, NULL, NULL, lv_obj_get_base_dir(ddlist));
            }
        }

        /*Add a down symbol in ddlist when closed*/
        else {
            /*Draw a arrow in ddlist if enabled*/
            if(ext->draw_arrow) {
                const lv_style_t * style     = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_BG);
                const lv_font_t * font       = style->text.font;
                const lv_style_t * sel_style = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_BG);
                lv_coord_t font_h            = lv_font_get_line_height(font);
                lv_style_t new_style;
                lv_style_copy(&new_style, style);
                new_style.text.color = sel_style->text.color;
                new_style.text.opa   = sel_style->text.opa;
                lv_area_t area_arrow;
                lv_coord_t arrow_width = lv_txt_get_width(LV_SYMBOL_DOWN, (uint16_t)strlen(LV_SYMBOL_DOWN), sel_style->text.font, 0, 0);
                if(lv_label_get_align(ext->label) != LV_LABEL_ALIGN_RIGHT) {
                    area_arrow.x2 = ddlist->coords.x2 - style->body.padding.right;
                    area_arrow.x1 = area_arrow.x2 - arrow_width;
                } else {
                    area_arrow.x1 = ddlist->coords.x1 + style->body.padding.left;
                    area_arrow.x2 = area_arrow.x1 + arrow_width;
                }

                area_arrow.y1 = ddlist->coords.y1 + style->text.line_space;
                area_arrow.y2 = area_arrow.y1 + font_h;

                lv_area_t mask_arrow;
                bool area_ok;
                area_ok = lv_area_intersect(&mask_arrow, mask, &area_arrow);
                if(area_ok) {
                    /*Use a down arrow in ddlist, you can replace it with yourcustom symbol*/
                    lv_draw_label(&area_arrow, &mask_arrow, &new_style, opa_scale, LV_SYMBOL_DOWN, LV_TXT_FLAG_NONE,
                                  NULL, NULL, NULL, lv_obj_get_base_dir(ddlist));
                }
            }
        }
        /*Draw the scrollbar in the ancestor page design function*/
        ancestor_design(ddlist, mask, mode);
    }

    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rsi, %rbx
movq %rdi, %r14
testl %edx, %edx
je 0xbac2
cmpl $0x1, %edx
je 0xb9c3
cmpl $0x2, %edx
jne 0xbcdf
movq 0x5493b(%rip), %rax     # 0x602e0
movq %r14, %rdi
movq %rbx, %rsi
movl $0x2, %edx
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rax
movq %r14, %rdi
callq 0x6af7
movq %rax, %r15
movq %r14, %rdi
callq 0x69eb
movl %eax, %ebp
movb 0x66(%r15), %al
testb $0x3, %al
je 0xbb61
movq %r14, %rdi
xorl %esi, %esi
callq 0xbe51
movq %rax, %r12
movq 0x28(%rax), %rax
movzbl 0x10(%rax), %eax
movq 0x50(%r15), %rcx
movzwl 0x22(%rcx), %ecx
movzwl 0x32(%r12), %edx
addl %edx, %eax
movzwl 0x62(%r15), %esi
imulw %ax, %si
movl %edx, %edi
shrl $0xf, %edi
addl %edx, %edi
movswl %di, %edx
sarl %edx
subl %edx, %ecx
addl %esi, %ecx
leaq 0x38(%rsp), %rdx
movw %cx, 0x2(%rdx)
addl %ecx, %eax
decl %eax
movw %ax, 0x6(%rdx)
movzwl 0x20(%r14), %eax
movw %ax, (%rdx)
movzwl 0x24(%r14), %eax
movw %ax, 0x4(%rdx)
leaq 0x30(%rsp), %rdi
movq %rbx, %rsi
callq 0x28d24
testb %al, %al
je 0xbcce
movb %bpl, 0x2b(%rsp)
movq %r14, %rdi
movl $0x1, %esi
callq 0xbe51
movq %rax, %r13
leaq 0x40(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
callq 0x799d
movzwl 0x20(%r13), %eax
movw %ax, 0x20(%rbp)
movb 0x34(%r13), %al
movb %al, 0x34(%rbp)
movq %r14, %rdi
callq 0x6af7
movq 0x50(%rax), %rdi
testq %rdi, %rdi
je 0xbbf1
callq 0x1a9c6
cmpb $0x1, %al
sete %cl
shlb $0x2, %cl
cmpb $0x2, %al
movzbl %cl, %eax
movl $0x8, %ebp
cmovnel %eax, %ebp
jmp 0xbbf4
movq %r14, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq *0x54810(%rip)          # 0x602e0
movq %r14, %rdi
callq 0x6af7
movq %rax, %r15
movq %r14, %rdi
callq 0x69eb
testb $0x3, 0x66(%r15)
je 0xbcdf
movl %eax, %ebp
movq %r14, %rdi
xorl %esi, %esi
callq 0xbe51
movq 0x28(%rax), %rcx
movzbl 0x10(%rcx), %ecx
movq 0x50(%r15), %rdx
movzwl 0x22(%rdx), %edx
movzwl 0x32(%rax), %eax
addl %eax, %ecx
movzwl 0x62(%r15), %esi
imulw %cx, %si
movl %eax, %edi
shrl $0xf, %edi
addl %eax, %edi
movswl %di, %eax
sarl %eax
subl %eax, %edx
addl %esi, %edx
leaq 0x40(%rsp), %rdi
movw %dx, 0x2(%rdi)
leal (%rcx,%rdx), %eax
decl %eax
movw %ax, 0x6(%rdi)
movzwl 0x20(%r14), %eax
movw %ax, (%rdi)
movzwl 0x24(%r14), %eax
movw %ax, 0x4(%rdi)
movq 0x58(%r15), %rdx
movzbl %bpl, %ecx
movq %rbx, %rsi
callq 0x36968
jmp 0xbcdf
testb $0x4, %al
je 0xbcce
movb %bpl, 0x2b(%rsp)
movq %r14, %rdi
xorl %esi, %esi
callq 0xbe51
movq %rax, %r12
movq 0x28(%rax), %rbp
movq %r14, %rdi
xorl %esi, %esi
callq 0xbe51
movq %rax, %r13
movzbl 0x10(%rbp), %eax
movl %eax, 0x2c(%rsp)
leaq 0x40(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
callq 0x799d
movzwl 0x20(%r13), %eax
movw %ax, 0x20(%rbp)
movb 0x34(%r13), %al
movb %al, 0x34(%rbp)
movq 0x28(%r13), %rdx
leaq 0x337b8(%rip), %rdi     # 0x3f377
movl $0x3, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x2b2a4
movl %eax, %r13d
movq 0x50(%r15), %rdi
callq 0x1a9c6
cmpb $0x2, %al
jne 0xbc41
movzwl 0x1a(%r12), %eax
addw 0x20(%r14), %ax
addl %eax, %r13d
movl %r13d, %ecx
jmp 0xbc51
movb $0x4, %bpl
movq 0x50(%r15), %rdi
leaq 0x20(%rdi), %r15
callq 0x1aa00
movq %rax, %r12
movq %r14, %rdi
callq 0x4ab2
movzbl %al, %eax
movl %eax, 0x18(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movzbl 0x2b(%rsp), %ecx
movzbl %bpl, %r9d
leaq 0x30(%rsp), %rsi
leaq 0x40(%rsp), %rdx
movq %r15, %rdi
movq %r12, %r8
jmp 0xbcc9
movzwl 0x24(%r14), %ecx
subw 0x1c(%r12), %cx
movl %ecx, %eax
subl %r13d, %eax
movb 0x2b(%rsp), %bpl
leaq 0x38(%rsp), %rdx
movw %ax, (%rdx)
movw %cx, 0x4(%rdx)
movzwl 0x32(%r12), %eax
addw 0x22(%r14), %ax
movw %ax, 0x2(%rdx)
movzwl 0x2c(%rsp), %ecx
addl %eax, %ecx
movw %cx, 0x6(%rdx)
leaq 0x30(%rsp), %rdi
movq %rbx, %rsi
callq 0x28d24
testb %al, %al
je 0xbcce
movq %r14, %rdi
callq 0x4ab2
movzbl %al, %eax
movl %eax, 0x18(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movzbl %bpl, %ecx
leaq 0x336c0(%rip), %r8      # 0x3f377
leaq 0x38(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x40(%rsp), %rdx
xorl %r9d, %r9d
callq 0x3a5ac
movq %r14, %rdi
movq %rbx, %rsi
movl $0x1, %edx
callq *0x54601(%rip)          # 0x602e0
movb $0x1, %al
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq