// File: /workspace/github_c_makefile_star2_O2/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 0xb12c
cmpl $0x1, %edx
je 0xb034
cmpl $0x2, %edx
jne 0xb33b
movq 0x532c8(%rip), %rax     # 0x5e2e0
pushq $0x2
popq %rdx
movq %r14, %rdi
movq %rbx, %rsi
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rax
movq %r14, %rdi
callq 0x6747
movq %rax, %r15
movq %r14, %rdi
callq 0x6649
movl %eax, %ebp
movb 0x66(%r15), %al
testb $0x3, %al
je 0xb1c7
movq %r14, %rdi
xorl %esi, %esi
callq 0xb4ce
movq %rax, %r12
movq 0x28(%rax), %rax
movzbl 0x10(%rax), %ecx
movq 0x50(%r15), %rsi
movzwl 0x32(%r12), %eax
addl %eax, %ecx
movzwl 0x62(%r15), %edi
imulw %cx, %di
movw $0xfffe, %r8w           # imm = 0xFFFE
cwtd
idivw %r8w
addw 0x22(%rsi), %ax
addl %edi, %eax
leaq 0x38(%rsp), %rdx
movw %ax, 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 0x26880
testb %al, %al
je 0xb32c
movb %bpl, 0x2b(%rsp)
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0xb4ce
movq %rax, %r13
leaq 0x40(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
callq 0x74d4
movzwl 0x20(%r13), %eax
movw %ax, 0x20(%rbp)
movb 0x34(%r13), %al
movb %al, 0x34(%rbp)
movq %r14, %rdi
callq 0x6747
movq 0x50(%rax), %rdi
testq %rdi, %rdi
je 0xb255
callq 0x18d7f
cmpb $0x1, %al
sete %cl
shlb $0x2, %cl
cmpb $0x2, %al
movzbl %cl, %eax
pushq $0x8
popq %rbp
cmovnel %eax, %ebp
jmp 0xb258
movq %r14, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq *0x531a6(%rip)          # 0x5e2e0
movq %r14, %rdi
callq 0x6747
movq %rax, %r15
movq %r14, %rdi
callq 0x6649
testb $0x3, 0x66(%r15)
je 0xb33b
movl %eax, %ebp
movq %r14, %rdi
xorl %esi, %esi
callq 0xb4ce
movq 0x28(%rax), %rcx
movzbl 0x10(%rcx), %ecx
movq 0x50(%r15), %rsi
movzwl 0x32(%rax), %eax
addl %eax, %ecx
movzwl 0x62(%r15), %edi
imulw %cx, %di
movw $0xfffe, %r8w           # imm = 0xFFFE
cwtd
idivw %r8w
addw 0x22(%rsi), %ax
addl %edi, %eax
leaq 0x40(%rsp), %rdi
movw %ax, 0x2(%rdi)
addl %ecx, %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 0x336d4
jmp 0xb33b
testb $0x4, %al
je 0xb32c
movb %bpl, 0x2b(%rsp)
movq %r14, %rdi
xorl %esi, %esi
callq 0xb4ce
movq %rax, %r12
movq 0x28(%rax), %rbp
movq %r14, %rdi
xorl %esi, %esi
callq 0xb4ce
movq %rax, %r13
movzbl 0x10(%rbp), %eax
movl %eax, 0x2c(%rsp)
leaq 0x40(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
callq 0x74d4
movzwl 0x20(%r13), %eax
movw %ax, 0x20(%rbp)
movb 0x34(%r13), %al
movb %al, 0x34(%rbp)
movq 0x28(%r13), %rdx
leaq 0x300b2(%rip), %rdi     # 0x3b2d7
pushq $0x3
popq %rsi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x28bb3
movl %eax, %r13d
movq 0x50(%r15), %rdi
callq 0x18d7f
cmpb $0x2, %al
jne 0xb2a2
movzwl 0x1a(%r12), %eax
addw 0x20(%r14), %ax
addl %eax, %r13d
movl %r13d, %ecx
jmp 0xb2b2
movb $0x4, %bpl
movq 0x50(%r15), %rdi
leaq 0x20(%rdi), %r15
callq 0x18db9
movq %rax, %r12
movq %r14, %rdi
callq 0x47b9
movzbl %al, %eax
movl %eax, 0x18(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rsp)
andq $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 0xb327
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 0x26880
testb %al, %al
je 0xb32c
movq %r14, %rdi
callq 0x47b9
movzbl %al, %eax
movl %eax, 0x18(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rsp)
andq $0x0, 0x10(%rsp)
movzbl %bpl, %ecx
leaq 0x2ffc2(%rip), %r8      # 0x3b2d7
leaq 0x38(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x40(%rsp), %rdx
xorl %r9d, %r9d
callq 0x3699c
pushq $0x1
popq %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq *0x52fa5(%rip)          # 0x5e2e0
movb $0x1, %al
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq