// File: /workspace/github_c_makefile_star2_O1/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 $0x98, %rsp
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r14
testl %edx, %edx
je 0xbb66
cmpl $0x1, %ebp
je 0xba58
cmpl $0x2, %ebp
jne 0xbdac
movq 0x548a5(%rip), %rax     # 0x602e0
movzbl %bpl, %edx
movq %r14, %rdi
movq %rbx, %rsi
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rax
movq %r14, %rdi
callq 0x6ad8
movq %rax, %r12
movq %r14, %rdi
callq 0x69cc
movl %eax, %r15d
movb 0x66(%r12), %al
testb $0x3, %al
je 0xbc0f
movq %r14, %rdi
xorl %esi, %esi
callq 0xbf18
movq %rax, %r13
movq 0x28(%rax), %rax
movzbl 0x10(%rax), %eax
movq 0x50(%r12), %rcx
movzwl 0x22(%rcx), %ecx
leaq 0x30(%rsp), %rdx
movw %cx, 0x2(%rdx)
movzwl 0x32(%r13), %esi
addl %esi, %eax
movzwl 0x62(%r12), %edi
imulw %ax, %di
movl %esi, %r8d
shrl $0xf, %r8d
addl %esi, %r8d
movswl %r8w, %esi
sarl %esi
subl %esi, %ecx
addl %edi, %ecx
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 0x48(%rsp), %rdi
movq %rbx, %rsi
callq 0x2865e
testb %al, %al
je 0xbd9c
movb %r15b, 0x2f(%rsp)
movq %r14, %rdi
movl $0x1, %esi
callq 0xbf18
movq %rax, %r15
leaq 0x50(%rsp), %rdi
movq %r13, %rsi
callq 0x798d
movzwl 0x20(%r15), %eax
leaq 0x50(%rsp), %rcx
movw %ax, 0x20(%rcx)
movb 0x34(%r15), %al
movb %al, 0x34(%rcx)
movq %r14, %rdi
callq 0x6ad8
movq 0x50(%rax), %rdi
testq %rdi, %rdi
je 0xbcbc
callq 0x1a1ff
cmpb $0x1, %al
sete %cl
shlb $0x2, %cl
cmpb $0x2, %al
movzbl %cl, %eax
movl $0x8, %r13d
cmovnel %eax, %r13d
jmp 0xbcbf
movzbl %bpl, %edx
movq %r14, %rdi
movq %rbx, %rsi
callq *0x5476a(%rip)          # 0x602e0
movq %r14, %rdi
callq 0x6ad8
movq %rax, %r15
movq %r14, %rdi
callq 0x69cc
testb $0x3, 0x66(%r15)
je 0xbdac
movl %eax, %ebp
movq %r14, %rdi
xorl %esi, %esi
callq 0xbf18
movq 0x28(%rax), %rcx
movzbl 0x10(%rcx), %ecx
movq 0x50(%r15), %rdx
movzwl 0x22(%rdx), %edx
leaq 0x50(%rsp), %rdi
movw %dx, 0x2(%rdi)
movzwl 0x32(%rax), %eax
addl %eax, %ecx
movzwl 0x62(%r15), %esi
imulw %cx, %si
movl %eax, %r8d
shrl $0xf, %r8d
addl %eax, %r8d
movswl %r8w, %eax
sarl %eax
subl %eax, %edx
addl %esi, %edx
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 0x365ac
jmp 0xbdac
testb $0x4, %al
je 0xbd9c
movb %r15b, 0x2f(%rsp)
movq %r14, %rdi
xorl %esi, %esi
callq 0xbf18
movq %rax, %r13
movq 0x28(%rax), %rax
movq %rax, 0x38(%rsp)
movq %r14, %rdi
xorl %esi, %esi
callq 0xbf18
movq %rax, %r15
movq 0x38(%rsp), %rax
movzbl 0x10(%rax), %eax
movl %eax, 0x44(%rsp)
leaq 0x50(%rsp), %rdi
movq %r13, 0x38(%rsp)
movq %r13, %rsi
callq 0x798d
movzwl 0x20(%r15), %eax
leaq 0x50(%rsp), %rcx
movw %ax, 0x20(%rcx)
movb 0x34(%r15), %al
movb %al, 0x34(%rcx)
movq 0x28(%r15), %rdx
leaq 0x33649(%rip), %rdi     # 0x3f2c7
movl $0x3, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x2ab49
movl %eax, %r15d
movq 0x50(%r12), %rdi
callq 0x1a1ff
cmpb $0x2, %al
jne 0xbd0d
movq 0x38(%rsp), %rcx
movzwl 0x1a(%rcx), %eax
addw 0x20(%r14), %ax
movw %ax, 0x30(%rsp)
addl %eax, %r15d
movw %r15w, 0x34(%rsp)
jmp 0xbd28
movb $0x4, %r13b
movq 0x50(%r12), %rdi
leaq 0x20(%rdi), %r15
callq 0x1a239
movq %rax, %r12
movq %r14, %rdi
callq 0x4abc
movzbl %al, %eax
movl %eax, 0x18(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movzbl 0x2f(%rsp), %ecx
movzbl %r13b, %r9d
leaq 0x48(%rsp), %rsi
leaq 0x50(%rsp), %rdx
movq %r15, %rdi
movq %r12, %r8
jmp 0xbd97
movzwl 0x24(%r14), %eax
movq 0x38(%rsp), %rcx
subw 0x1c(%rcx), %ax
movw %ax, 0x34(%rsp)
subl %r15d, %eax
movw %ax, 0x30(%rsp)
movzwl 0x32(%rcx), %eax
addw 0x22(%r14), %ax
leaq 0x30(%rsp), %rdx
movw %ax, 0x2(%rdx)
movzwl 0x44(%rsp), %ecx
addl %eax, %ecx
movw %cx, 0x6(%rdx)
leaq 0x48(%rsp), %rdi
movq %rbx, %rsi
callq 0x2865e
testb %al, %al
movb 0x2f(%rsp), %r15b
je 0xbd9c
movq %r14, %rdi
callq 0x4abc
movzbl %al, %eax
movl %eax, 0x18(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movzbl %r15b, %ecx
leaq 0x33542(%rip), %r8      # 0x3f2c7
leaq 0x30(%rsp), %rdi
leaq 0x48(%rsp), %rsi
leaq 0x50(%rsp), %rdx
xorl %r9d, %r9d
callq 0x3a034
movzbl %bpl, %edx
movq %r14, %rdi
movq %rbx, %rsi
callq *0x54534(%rip)          # 0x602e0
movb $0x1, %al
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq