// File: /workspace/github_c_makefile_star2_O2/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_tabview.c
// Function: lv_tabview_create
lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy)
{
    LV_LOG_TRACE("tab view create started");

    /*Create the ancestor of tab*/
    lv_obj_t * new_tabview = lv_obj_create(par, copy);
    LV_ASSERT_MEM(new_tabview);
    if(new_tabview == NULL) return NULL;
    if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_tabview);

    /*Allocate the tab type specific extended data*/
    lv_tabview_ext_t * ext = lv_obj_allocate_ext_attr(new_tabview, sizeof(lv_tabview_ext_t));
    LV_ASSERT_MEM(ext);
    if(ext == NULL) return NULL;

    /*Initialize the allocated 'ext' */
    ext->drag_hor     = 0;
    ext->draging      = 0;
    ext->scroll_ver   = 0;
    ext->slide_enable = 1;
    ext->tab_cur      = 0;
    ext->point_last.x = 0;
    ext->point_last.y = 0;
    ext->content      = NULL;
    ext->indic        = NULL;
    ext->btns         = NULL;
    ext->btns_pos     = LV_TABVIEW_BTNS_POS_TOP;
#if LV_USE_ANIMATION
    ext->anim_time = LV_TABVIEW_DEF_ANIM_TIME;
#endif
    ext->btns_hide = 0;

    /*The signal and design functions are not copied so set them here*/
    lv_obj_set_signal_cb(new_tabview, lv_tabview_signal);

    /*Init the new tab tab*/
    if(copy == NULL) {
        ext->tab_name_ptr = lv_mem_alloc(sizeof(char *));
        LV_ASSERT_MEM(ext->tab_name_ptr);
        if(ext->tab_name_ptr == NULL) return NULL;
        ext->tab_name_ptr[0] = "";
        ext->tab_cnt         = 0;

        /* Set a size which fits into the parent.
         * Don't use `par` directly because if the tabview is created on a page it is moved to the
         * scrollable so the parent has changed */
        lv_obj_set_size(new_tabview, lv_obj_get_width_fit(lv_obj_get_parent(new_tabview)),
                        lv_obj_get_height_fit(lv_obj_get_parent(new_tabview)));

        ext->content = lv_cont_create(new_tabview, NULL);
        ext->btns    = lv_btnm_create(new_tabview, NULL);
        ext->indic   = lv_obj_create(ext->btns, NULL);

        lv_obj_set_height(ext->btns, 3 * LV_DPI / 4);
        lv_btnm_set_map(ext->btns, tab_def);
        lv_obj_set_event_cb(ext->btns, tab_btnm_event_cb);

        lv_obj_set_width(ext->indic, LV_DPI);
        lv_obj_align(ext->indic, ext->btns, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
        lv_obj_set_click(ext->indic, false);

        lv_cont_set_fit2(ext->content, LV_FIT_TIGHT, LV_FIT_NONE);
        lv_cont_set_layout(ext->content, LV_LAYOUT_ROW_T);
        lv_cont_set_style(ext->content, LV_CONT_STYLE_MAIN, &lv_style_transp_tight);
        lv_obj_set_height(ext->content, lv_obj_get_height(new_tabview) - lv_obj_get_height(ext->btns));
        lv_obj_align(ext->content, ext->btns, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);

        /*Set the default styles*/
        lv_theme_t * th = lv_theme_get_current();
        if(th) {
            lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BG, th->style.tabview.bg);
            lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_INDIC, th->style.tabview.indic);
            lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_BG, th->style.tabview.btn.bg);
            lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_REL, th->style.tabview.btn.rel);
            lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_PR, th->style.tabview.btn.pr);
            lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_TGL_REL, th->style.tabview.btn.tgl_rel);
            lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_TGL_PR, th->style.tabview.btn.tgl_pr);
        } else {
            lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BG, &lv_style_plain);
            lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_BG, &lv_style_pretty);//transp);
            lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_INDIC, &lv_style_plain_color);
        }
    }
    /*Copy an existing tab view*/
    else {
        lv_tabview_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
        ext->point_last.x           = 0;
        ext->point_last.y           = 0;
        ext->btns                   = lv_btnm_create(new_tabview, copy_ext->btns);
        ext->indic                  = lv_obj_create(ext->btns, copy_ext->indic);
        ext->content                = lv_cont_create(new_tabview, copy_ext->content);
#if LV_USE_ANIMATION
        ext->anim_time = copy_ext->anim_time;
#endif

        ext->tab_name_ptr = lv_mem_alloc(sizeof(char *));
        LV_ASSERT_MEM(ext->tab_name_ptr);
        if(ext->tab_name_ptr == NULL) return NULL;
        ext->tab_name_ptr[0] = "";
        lv_btnm_set_map(ext->btns, ext->tab_name_ptr);

        uint16_t i;
        lv_obj_t * new_tab;
        lv_obj_t * copy_tab;
        for(i = 0; i < copy_ext->tab_cnt; i++) {
            new_tab  = lv_tabview_add_tab(new_tabview, copy_ext->tab_name_ptr[i]);
            copy_tab = lv_tabview_get_tab(copy, i);
            lv_page_set_style(new_tab, LV_PAGE_STYLE_BG, lv_page_get_style(copy_tab, LV_PAGE_STYLE_BG));
            lv_page_set_style(new_tab, LV_PAGE_STYLE_SCRL, lv_page_get_style(copy_tab, LV_PAGE_STYLE_SCRL));
            lv_page_set_style(new_tab, LV_PAGE_STYLE_SB, lv_page_get_style(copy_tab, LV_PAGE_STYLE_SB));
        }

        /*Refresh the style with new signal function*/
        lv_obj_refresh_style(new_tabview);
    }

    LV_LOG_INFO("tab view created");

    return new_tabview;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r15
callq 0x42c9
movq %rax, %rbx
movq %rax, %rdi
callq 0x7994
testb %al, %al
je 0x1001c
testq %rbx, %rbx
je 0x10207
cmpq $0x0, 0x4e4b9(%rip)     # 0x5e330
jne 0xfe88
movq %rbx, %rdi
callq 0x66db
movq %rax, 0x4e4a8(%rip)     # 0x5e330
pushq $0x30
popq %rsi
movq %rbx, %rdi
callq 0x6146
movq %rax, %r14
movq %rax, %rdi
callq 0x7994
testb %al, %al
je 0x1002d
testq %r14, %r14
je 0x10207
movb 0x2a(%r14), %al
andw $0x0, 0x24(%r14)
andl $0x0, 0x20(%r14)
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
andq $0x0, 0x10(%r14)
movw $0x12c, 0x28(%r14)      # imm = 0x12C
andb $-0x80, %al
incb %al
movb %al, 0x2a(%r14)
leaq 0x398(%rip), %rsi       # 0x10278
movq %rbx, %rdi
callq 0x60e6
testq %r15, %r15
je 0x1003e
movq %r15, %rdi
callq 0x6747
movq %rax, %r12
andl $0x0, 0x20(%r14)
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x1f420
movq %rax, (%r14)
movq 0x8(%r12), %rsi
movq %rax, %rdi
callq 0x42c9
movq %rax, 0x8(%r14)
movq 0x10(%r12), %rsi
movq %rbx, %rdi
callq 0x209c8
movq %rax, 0x10(%r14)
movzwl 0x28(%r12), %eax
movw %ax, 0x28(%r14)
pushq $0x8
popq %rdi
callq 0x279f9
movq %rax, 0x18(%r14)
movq %rax, %rdi
callq 0x7994
movq 0x18(%r14), %rsi
testb %al, %al
je 0x1021b
testq %rsi, %rsi
je 0x10207
leaq 0x2f4d9(%rip), %rax     # 0x3f445
movq %rax, (%rsi)
movq (%r14), %rdi
movq 0x18(%r14), %rsi
callq 0x1fe53
xorl %ecx, %ecx
movzwl 0x26(%r12), %eax
cmpq %rax, %rcx
jae 0x10229
movq 0x18(%r12), %rax
movq (%rax,%rcx,8), %rsi
movq %rbx, %rdi
movq %rcx, (%rsp)
callq 0x105b6
movq %rax, %r13
movzwl (%rsp), %esi
movq %r15, %rdi
callq 0x108f6
movq %rax, %rbp
movq %rax, %rdi
xorl %esi, %esi
callq 0x24149
movq %r13, %rdi
xorl %esi, %esi
movq %rax, %rdx
callq 0x24089
movq %rbp, %rdi
movq %r15, %r14
movq %r12, %r15
movq %rbx, %r12
pushq $0x1
popq %rbx
movl %ebx, %esi
callq 0x24149
movq %r13, %rdi
movl %ebx, %esi
movq %r12, %rbx
movq %r15, %r12
movq %r14, %r15
movq %rax, %rdx
callq 0x24089
movq %rbp, %rdi
pushq $0x2
popq %rbp
movl %ebp, %esi
callq 0x24149
movq %r13, %rdi
movl %ebp, %esi
movq %rax, %rdx
callq 0x24089
movq (%rsp), %rcx
incq %rcx
jmp 0xff7d
leaq 0x2b01d(%rip), %rdi     # 0x3b040
movq %rbx, %rsi
callq 0x7b01
jmp 0x1002b
leaq 0x2b00c(%rip), %rdi     # 0x3b040
movq %r14, %rsi
callq 0x7b01
jmp 0x1003c
pushq $0x8
popq %rdi
callq 0x279f9
movq %rax, 0x18(%r14)
movq %rax, %rdi
callq 0x7994
movq 0x18(%r14), %rsi
testb %al, %al
je 0x10233
testq %rsi, %rsi
je 0x10207
leaq 0x2f3d7(%rip), %rax     # 0x3f445
movq %rax, (%rsi)
andw $0x0, 0x26(%r14)
movq %rbx, %rdi
callq 0x47bc
movq %rax, %rdi
callq 0x63d0
movl %eax, %ebp
movq %rbx, %rdi
callq 0x47bc
movq %rax, %rdi
callq 0x6418
movswl %bp, %esi
movswl %ax, %edx
movq %rbx, %rdi
callq 0x520e
movq %rbx, %rdi
xorl %esi, %esi
callq 0x209c8
movq %rax, 0x10(%r14)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1f420
movq %rax, (%r14)
movq %rax, %rdi
xorl %esi, %esi
callq 0x42c9
movq %rax, 0x8(%r14)
movq (%r14), %rdi
pushq $0x4b
popq %rsi
callq 0x53e6
movq (%r14), %rdi
leaq 0x4149b(%rip), %rsi     # 0x51580
callq 0x1fe53
movq (%r14), %rdi
leaq 0x33a(%rip), %rsi       # 0x1042e
callq 0x5fce
movq 0x8(%r14), %rdi
pushq $0x64
popq %rsi
callq 0x53a8
movq (%r14), %rsi
movq 0x8(%r14), %rdi
pushq $0x4
popq %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x5424
movq 0x8(%r14), %rdi
xorl %esi, %esi
callq 0x5c6f
movq 0x10(%r14), %rdi
callq 0x104bf
movq 0x10(%r14), %rdi
pushq $0x5
popq %rsi
callq 0x20bca
movq 0x10(%r14), %rdi
leaq 0x4df84(%rip), %rsi     # 0x5e0c8
callq 0x5a3d
movq 0x10(%r14), %r15
movq %rbx, %rdi
callq 0x5332
movl %eax, %ebp
movq (%r14), %rdi
callq 0x5332
subl %eax, %ebp
movswl %bp, %esi
movq %r15, %rdi
callq 0x53e6
movq (%r14), %rsi
movq 0x10(%r14), %rdi
pushq $0xc
popq %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x5424
callq 0x2be75
testq %rax, %rax
je 0x10241
movq %rax, %r14
movq 0x2c0(%rax), %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x104ce
movq 0x2c8(%r14), %rdx
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x104ce
movq 0x2d0(%r14), %rdx
pushq $0x2
popq %rsi
movq %rbx, %rdi
callq 0x104ce
movq 0x2d8(%r14), %rdx
pushq $0x3
popq %rsi
movq %rbx, %rdi
callq 0x104ce
movq 0x2e0(%r14), %rdx
pushq $0x4
popq %rsi
movq %rbx, %rdi
callq 0x104ce
movq 0x2e8(%r14), %rdx
pushq $0x5
popq %rsi
movq %rbx, %rdi
callq 0x104ce
movq 0x2f0(%r14), %rdx
pushq $0x6
jmp 0x1026d
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2ae1e(%rip), %rdi     # 0x3b040
callq 0x7b01
jmp 0x10227
movq %rbx, %rdi
callq 0x5ae7
jmp 0x10209
leaq 0x2ae06(%rip), %rdi     # 0x3b040
callq 0x7b01
jmp 0x1023f
leaq 0x4dcd0(%rip), %rdx     # 0x5df18
movq %rbx, %rdi
xorl %esi, %esi
callq 0x104ce
leaq 0x4dd4f(%rip), %rdx     # 0x5dfa8
pushq $0x2
popq %rsi
movq %rbx, %rdi
callq 0x104ce
leaq 0x4dcf5(%rip), %rdx     # 0x5df60
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x104ce
jmp 0x10209