#include "ui_cont.h"

lv_obj_t *g_cont;
const int16_t ContXY_Size[4] = {-5, 0, 490, 320};
lv_style_t style_line;
lv_obj_t *line[5];

static lv_point_t line_points[][5] =
    {
        {8, 3, 480, 3},     //--
        {480, 3, 480, 317}, //  |
        {480, 317, 8, 317}, //__
        {8, 317, 8, 3},     // |
        {8, 42, 480, 42},
};

lv_fit_t fit = LV_LAYOUT_OFF;       // LV_FIT_TIGHT;//起始的自适应方式
lv_layout_t layout = LV_LAYOUT_OFF; // LV_LAYOUT_COL_L;//LV_LAYOUT_CENTER;//起始的布局方式

lv_obj_t * ui_cont_creat(lv_obj_t *scr , lv_color_t color)
{
    g_cont = lv_cont_create(scr, NULL);                             // 创建容器
    lv_obj_set_pos(g_cont, ContXY_Size[0], ContXY_Size[1]); // 设置坐标
    lv_obj_set_size(g_cont, ContXY_Size[2], ContXY_Size[3]);
    lv_cont_set_fit4(g_cont, LV_FIT_NONE, fit, LV_FIT_NONE, fit);
    lv_cont_set_layout(g_cont, layout);                                                           // 先设置容器布局方式,禁止自动布局
    lv_obj_set_style_local_bg_opa(g_cont, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_100);        // LV_OPA_0);      //设置背景透明
    lv_obj_set_style_local_border_opa(g_cont, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP); // 设置边框透明
    lv_obj_set_style_local_bg_color(g_cont, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color);
}



lv_obj_t *  ui_get_cont()
{
    return g_cont;
}

void    ui_cont_clean()
{
    lv_obj_clean(g_cont);
}

void    Draw_counteara()
{
    lv_style_reset(&style_line); // lv_style_init(&style_line);
    lv_style_set_line_width(&style_line, LV_STATE_DEFAULT, 3);
    lv_style_set_line_color(&style_line, LV_STATE_DEFAULT, LV_COLOR_BLUE);
    lv_style_set_line_rounded(&style_line, LV_STATE_DEFAULT, true);

    /*Create a line and apply the new style*/
    u8 i ;
    for (i = 0; i < 4; i++)
    {
        line[i] = lv_line_create(ui_get_cont(), NULL);
        lv_line_set_points(line[i], line_points[i], 2); /*Set the points*/
        lv_obj_add_style(line[i], LV_LINE_PART_MAIN, &style_line);
        lv_obj_align(line[i], NULL, LV_ALIGN_IN_TOP_LEFT, 0, 0);
    }
}

void  Draw_pagepath(lv_obj_t * pathlabel, char * text)
{
        lv_style_reset(&style_line);
    // lv_style_init(&style_line);
    lv_style_set_line_width(&style_line, LV_STATE_DEFAULT, 4);
    lv_style_set_line_color(&style_line, LV_STATE_DEFAULT, Default_HZ_color); // LV_COLOR_MAKE(0xdf, 0xdf, 0xff));
    lv_style_set_line_rounded(&style_line, LV_STATE_DEFAULT, true);

    line[4] = lv_line_create(ui_get_cont(), NULL);
    lv_line_set_points(line[4], line_points[4], 2);            /*Set the points*/
    lv_obj_add_style(line[4], LV_LINE_PART_MAIN, &style_line); /*Set the points*/
    lv_obj_align(line[4], NULL, LV_ALIGN_IN_TOP_LEFT, 0, 0);

    pathlabel = lv_label_create(ui_get_cont(), NULL);
    lv_obj_set_style_local_text_font(pathlabel, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, &GBhzk22);
    lv_obj_set_style_local_text_color(pathlabel, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, Default_HZ_color); // 设置颜色
    // lv_label_set_text(labeldis[LAB_STAL],"/菜单/参数设置");
    lv_label_set_text(pathlabel,text);
    lv_obj_set_pos(pathlabel, 12, 10); // 设置坐标
}