You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
268 lines
13 KiB
268 lines
13 KiB
/*
|
|
* Copyright 2023 NXP
|
|
* NXP Confidential and Proprietary. This software is owned or controlled by NXP and may only be used strictly in
|
|
* accordance with the applicable license terms. By expressly accepting such terms or by downloading, installing,
|
|
* activating and/or otherwise using the software, you are agreeing that you have read, and that you agree to
|
|
* comply with and are bound by, such license terms. If you do not agree to be bound by the applicable license
|
|
* terms, then you may not retain, install, activate or otherwise use the software.
|
|
*/
|
|
|
|
|
|
/*********************
|
|
* INCLUDES
|
|
*********************/
|
|
#include <stdio.h>
|
|
#include "lvgl.h"
|
|
#include "custom.h"
|
|
#include <guider/generated/events_init.h>
|
|
#include <guider/generated/gui_guider.h>
|
|
#include <guider/generated/widgets_init.h>
|
|
#include <ui_data_labels.h>
|
|
/*********************
|
|
* DEFINES
|
|
*********************/
|
|
|
|
/**********************
|
|
* TYPEDEFS
|
|
**********************/
|
|
//lv_obj_t *screen_list_inf;
|
|
/**********************
|
|
* STATIC PROTOTYPES
|
|
**********************/
|
|
|
|
/**********************
|
|
* STATIC VARIABLES
|
|
**********************/
|
|
|
|
/**
|
|
* Create a demo application
|
|
*/
|
|
int16_t Work_row = -1;
|
|
int16_t Work_step_row = -1;
|
|
// 绘图回调
|
|
static void table_style_cb(lv_event_t *e)
|
|
{
|
|
lv_event_code_t code = lv_event_get_code(e);
|
|
lv_obj_t *table = lv_event_get_target(e);
|
|
|
|
if (code == LV_EVENT_DRAW_PART_BEGIN) {
|
|
lv_obj_draw_part_dsc_t *dsc = lv_event_get_param(e);
|
|
// 检查是否是单元格绘制
|
|
if (dsc->part == LV_PART_ITEMS && dsc->id < LV_TABLE_CELL_NONE) {
|
|
uint16_t row = dsc->id / lv_table_get_col_cnt(table);
|
|
//uint16_t col = dsc->id % lv_table_get_col_cnt(table);
|
|
if (row == 0) { // 表头
|
|
dsc->rect_dsc->bg_opa = LV_OPA_COVER;
|
|
dsc->rect_dsc->bg_color = lv_color_hex(0xd5dee6);
|
|
dsc->label_dsc->color = lv_color_hex(0x000000);
|
|
dsc->label_dsc->font = &lv_font_simsun_30;
|
|
}// 如果是选中行,绘制蓝色背景
|
|
else if ((row == Work_row)&&(table == guider_ui.screen_list_inf)) {
|
|
dsc->rect_dsc->bg_color = lv_color_hex(0x007185); // 蓝色背景
|
|
dsc->rect_dsc->bg_opa = LV_OPA_COVER;
|
|
dsc->label_dsc->color = lv_color_hex(0xFFFFFF); // 白色文字
|
|
dsc->label_dsc->font = &lv_font_simsun_24;
|
|
}
|
|
else if ((table == guider_ui.screen_w_list)&&(row == Work_step_row)) {
|
|
dsc->rect_dsc->bg_color = lv_color_hex(0x007185); // 蓝色背景
|
|
dsc->rect_dsc->bg_opa = LV_OPA_COVER;
|
|
dsc->label_dsc->color = lv_color_hex(0xFFFFFF); // 白色文字
|
|
dsc->label_dsc->font = &lv_font_simsun_24;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
static void table_step_cb(lv_event_t *e)
|
|
{
|
|
lv_event_code_t code = lv_event_get_code(e);
|
|
lv_obj_t *table = lv_event_get_target(e);
|
|
|
|
if (code == LV_EVENT_DRAW_PART_BEGIN) {
|
|
lv_obj_draw_part_dsc_t *dsc = lv_event_get_param(e);
|
|
// 检查是否是单元格绘制
|
|
if (dsc->part == LV_PART_ITEMS && dsc->id < LV_TABLE_CELL_NONE) {
|
|
uint16_t row = dsc->id / lv_table_get_col_cnt(table);
|
|
//uint16_t col = dsc->id % lv_table_get_col_cnt(table);
|
|
if (row == Work_step_row) {
|
|
dsc->rect_dsc->bg_color = lv_color_hex(0x007185); // 蓝色背景
|
|
dsc->rect_dsc->bg_opa = LV_OPA_COVER;
|
|
dsc->label_dsc->color = lv_color_hex(0xFFFFFF); // 白色文字
|
|
dsc->label_dsc->font = &lv_font_simsun_24;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//点击事件回调
|
|
char value_W[32] = {0};
|
|
static void table_click_event_cb(lv_event_t *e) {
|
|
lv_obj_t *table = lv_event_get_target(e);
|
|
lv_indev_t *indev = lv_indev_get_act();
|
|
|
|
if (indev == NULL) return;
|
|
char sql[64] = {0};
|
|
|
|
// 获取点击坐标
|
|
lv_point_t point;
|
|
lv_indev_get_point(indev, &point);
|
|
|
|
// 获取 table 区域
|
|
lv_area_t table_area;
|
|
lv_obj_get_coords(table, &table_area);
|
|
|
|
// 计算相对 Y 坐标
|
|
int32_t rel_y = point.y - table_area.y1;
|
|
|
|
//通过内容高度和行数计算行高
|
|
uint16_t row_cnt = lv_table_get_row_cnt(table);
|
|
if (row_cnt == 0) return;
|
|
|
|
// 获取表格内容区域高度(减去边框和padding)
|
|
int32_t border_width = lv_obj_get_style_border_width(table, LV_PART_MAIN);
|
|
int32_t pad_top = lv_obj_get_style_pad_top(table, LV_PART_MAIN);
|
|
int32_t pad_bottom = lv_obj_get_style_pad_bottom(table, LV_PART_MAIN);
|
|
int32_t content_h = table_area.y2 - table_area.y1 - border_width * 2 - pad_top - pad_bottom;
|
|
|
|
// 计算行高
|
|
int32_t row_h = content_h / row_cnt;
|
|
if (row_h <= 0) return;
|
|
|
|
// 计算行号
|
|
int16_t row = rel_y / row_h;
|
|
if (row >= 0 && row < row_cnt) {
|
|
lv_obj_invalidate(table);
|
|
//rt_kprintf("row: %d", row);
|
|
}
|
|
Work_row=-1;
|
|
Work_step_row=-1;
|
|
//获得来源表
|
|
if(table == guider_ui.screen_list_inf)//总览信息/工艺信息
|
|
{
|
|
Work_row = row;// 写入行号
|
|
rt_snprintf(value_W, sizeof(value_W),lv_table_get_cell_value(guider_ui.screen_list_inf, row, 0));
|
|
Work_Program_step_ui(value_W);
|
|
}
|
|
else if(table == guider_ui.screen_w_list){//步骤信息
|
|
Work_step_row = row;// 写入行号
|
|
if(value_W[0] == '\0') return;
|
|
rt_snprintf(sql, sizeof(sql),"%s' AND Step = '%s'",value_W,lv_table_get_cell_value(guider_ui.screen_w_list, row, 0));
|
|
Work_Program_stepINF_ui(sql);
|
|
}
|
|
}
|
|
|
|
// 初始化样式
|
|
void table_style_init(lv_obj_t *container)
|
|
{
|
|
//lv_obj_add_event_cb(container, table_style_cb, LV_EVENT_DRAW_PART_BEGIN, NULL);
|
|
lv_obj_add_event_cb(container, table_click_event_cb, LV_EVENT_CLICKED, NULL);
|
|
|
|
lv_obj_set_pos(container, 0, 0);
|
|
lv_obj_set_scrollbar_mode(container, LV_SCROLLBAR_MODE_OFF);
|
|
|
|
//Write style for screen_list_inf, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
|
|
lv_obj_set_style_pad_top(container, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
|
|
lv_obj_set_style_pad_bottom(container, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
|
|
lv_obj_set_style_pad_left(container, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
|
|
lv_obj_set_style_pad_right(container, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
|
|
lv_obj_set_style_bg_opa(container, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
|
|
lv_obj_set_style_bg_color(container, lv_color_hex(0xffffff), LV_PART_MAIN|LV_STATE_DEFAULT);
|
|
lv_obj_set_style_bg_grad_dir(container, LV_GRAD_DIR_NONE, LV_PART_MAIN|LV_STATE_DEFAULT);
|
|
lv_obj_set_style_border_width(container, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
|
|
lv_obj_set_style_radius(container, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
|
|
lv_obj_set_style_shadow_width(container, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
|
|
|
|
//Write style for screen_list_inf, Part: LV_PART_ITEMS, State: LV_STATE_DEFAULT.
|
|
lv_obj_set_style_text_color(container, lv_color_hex(0x393c41), LV_PART_ITEMS|LV_STATE_DEFAULT);
|
|
lv_obj_set_style_text_font(container, &lv_font_simsun_24, LV_PART_ITEMS|LV_STATE_DEFAULT);
|
|
lv_obj_set_style_text_opa(container, 255, LV_PART_ITEMS|LV_STATE_DEFAULT);
|
|
lv_obj_set_style_text_align(container, LV_TEXT_ALIGN_CENTER, LV_PART_ITEMS|LV_STATE_DEFAULT);
|
|
lv_obj_set_style_bg_opa(container, 0, LV_PART_ITEMS|LV_STATE_DEFAULT);
|
|
lv_obj_set_style_border_width(container, 3, LV_PART_ITEMS|LV_STATE_DEFAULT);
|
|
lv_obj_set_style_border_opa(container, 255, LV_PART_ITEMS|LV_STATE_DEFAULT);
|
|
lv_obj_set_style_border_color(container, lv_color_hex(0xd5dee6), LV_PART_ITEMS|LV_STATE_DEFAULT);
|
|
lv_obj_set_style_border_side(container, LV_BORDER_SIDE_FULL, LV_PART_ITEMS|LV_STATE_DEFAULT);
|
|
lv_obj_set_style_pad_top(container, 10, LV_PART_ITEMS|LV_STATE_DEFAULT);
|
|
lv_obj_set_style_pad_bottom(container, 10, LV_PART_ITEMS|LV_STATE_DEFAULT);
|
|
lv_obj_set_style_pad_left(container, 10, LV_PART_ITEMS|LV_STATE_DEFAULT);
|
|
lv_obj_set_style_pad_right(container, 10, LV_PART_ITEMS|LV_STATE_DEFAULT);
|
|
|
|
lv_obj_set_style_text_color(container, lv_color_hex(0xFFFFFF), LV_PART_ITEMS|LV_STATE_CHECKED);
|
|
lv_obj_set_style_text_font(container, &lv_font_simsun_24, LV_PART_ITEMS|LV_STATE_CHECKED);
|
|
lv_obj_set_style_text_opa(container, 255, LV_PART_ITEMS|LV_STATE_CHECKED);
|
|
lv_obj_set_style_text_align(container, LV_TEXT_ALIGN_CENTER, LV_PART_ITEMS|LV_STATE_CHECKED);
|
|
lv_obj_set_style_bg_opa(container, 255, LV_PART_ITEMS|LV_STATE_CHECKED);
|
|
lv_obj_set_style_bg_color(container, lv_color_hex(0x007185), LV_PART_ITEMS|LV_STATE_CHECKED);
|
|
lv_obj_set_style_border_width(container, 0, LV_PART_ITEMS|LV_STATE_CHECKED);
|
|
lv_obj_set_style_border_opa(container, 0, LV_PART_ITEMS|LV_STATE_CHECKED);
|
|
lv_obj_set_style_pad_top(container, 10, LV_PART_ITEMS|LV_STATE_CHECKED);
|
|
lv_obj_set_style_pad_bottom(container, 10, LV_PART_ITEMS|LV_STATE_CHECKED);
|
|
lv_obj_set_style_pad_left(container, 10, LV_PART_ITEMS|LV_STATE_CHECKED);
|
|
lv_obj_set_style_pad_right(container, 10, LV_PART_ITEMS|LV_STATE_CHECKED);
|
|
}
|
|
|
|
void custom_init(lv_ui *ui)
|
|
{
|
|
lv_obj_clear_flag(lv_tabview_get_content(ui->screen_tabview), LV_OBJ_FLAG_SCROLLABLE);//禁止左右滑动
|
|
lv_obj_clear_flag(lv_tabview_get_content(ui->screen_w_io), LV_OBJ_FLAG_SCROLLABLE);//禁止左右滑动
|
|
|
|
lv_obj_set_style_pad_all(ui->screen_tabview_tab_1, 0, LV_PART_MAIN);
|
|
lv_obj_set_style_pad_all(ui->screen_tabview_tab_2, 0, LV_PART_MAIN);
|
|
lv_obj_set_style_pad_all(ui->screen_tabview_tab_3, 0, LV_PART_MAIN);
|
|
lv_obj_set_style_pad_all(ui->screen_tabview_tab_4, 0, LV_PART_MAIN);
|
|
lv_obj_set_style_pad_all(ui->screen_w_io_tab_1, 0, LV_PART_MAIN);
|
|
lv_obj_set_scroll_dir(ui->screen_w_io_tab_1, LV_DIR_NONE);
|
|
lv_obj_set_style_pad_all(ui->screen_w_io_tab_2, 0, LV_PART_MAIN);
|
|
lv_obj_set_scroll_dir(ui->screen_w_io_tab_2, LV_DIR_NONE);
|
|
lv_obj_set_style_pad_all(ui->screen_w_io_tab_3, 0, LV_PART_MAIN);
|
|
lv_obj_set_scroll_dir(ui->screen_w_io_tab_3, LV_DIR_NONE);
|
|
lv_obj_set_style_pad_all(ui->screen_w_io_tab_4, 0, LV_PART_MAIN);
|
|
lv_obj_set_scroll_dir(ui->screen_w_io_tab_4, LV_DIR_NONE);
|
|
|
|
//工单页面的工艺信息列表
|
|
guider_ui.screen_list_inf = lv_table_create(guider_ui.screen_inf_list);
|
|
table_style_init(guider_ui.screen_list_inf);
|
|
lv_obj_add_event_cb(guider_ui.screen_list_inf, table_style_cb, LV_EVENT_DRAW_PART_BEGIN, NULL);
|
|
lv_table_set_col_cnt(guider_ui.screen_list_inf,2);
|
|
lv_table_set_col_width(guider_ui.screen_list_inf, 0, 350);
|
|
lv_table_set_col_width(guider_ui.screen_list_inf, 1, 360);
|
|
lv_table_set_cell_value(guider_ui.screen_list_inf,0,0,"工单");
|
|
lv_table_set_cell_value(guider_ui.screen_list_inf,0,1,"工艺");
|
|
|
|
//工单页面的步骤列表
|
|
guider_ui.screen_w_list_NAME = lv_table_create(guider_ui.screen_tabview_tab_1);
|
|
lv_obj_set_pos(guider_ui.screen_w_list_NAME, 0, 0);
|
|
lv_obj_set_size(guider_ui.screen_w_list_NAME, 300, 50);
|
|
table_style_init(guider_ui.screen_w_list_NAME);
|
|
lv_obj_add_event_cb(guider_ui.screen_w_list_NAME, table_style_cb, LV_EVENT_DRAW_PART_BEGIN, NULL);
|
|
lv_table_set_row_cnt(guider_ui.screen_w_list_NAME,1);
|
|
lv_table_set_col_width(guider_ui.screen_w_list_NAME, 0, 50);
|
|
lv_table_set_col_width(guider_ui.screen_w_list_NAME, 1, 250);
|
|
lv_table_set_cell_value(guider_ui.screen_w_list_NAME,0,0,"步");
|
|
lv_table_set_cell_value(guider_ui.screen_w_list_NAME,0,1,"工艺");
|
|
|
|
guider_ui.screen_w_list = lv_table_create(guider_ui.screen_step_list);
|
|
table_style_init(guider_ui.screen_w_list);
|
|
lv_obj_add_event_cb(guider_ui.screen_w_list, table_step_cb, LV_EVENT_DRAW_PART_BEGIN, NULL);
|
|
lv_table_set_col_cnt(guider_ui.screen_w_list,2);
|
|
lv_table_set_row_cnt(guider_ui.screen_w_list,2);
|
|
lv_table_set_col_width(guider_ui.screen_w_list, 0, 50);
|
|
lv_table_set_col_width(guider_ui.screen_w_list, 1, 250);
|
|
lv_obj_set_style_height(guider_ui.screen_w_list, 100, LV_PART_ITEMS | LV_STATE_DEFAULT);
|
|
lv_obj_set_style_min_height(guider_ui.screen_w_list, 100, LV_PART_ITEMS | LV_STATE_DEFAULT);
|
|
lv_obj_set_style_max_height(guider_ui.screen_w_list, 100, LV_PART_ITEMS | LV_STATE_DEFAULT);
|
|
|
|
//工单页面的信息
|
|
lv_obj_set_size(guider_ui.screen_text_inf, 550, 230);
|
|
lv_label_set_text(guider_ui.screen_text_inf,"");
|
|
|
|
//运行页面的步骤列表
|
|
guider_ui.screen_run_step = lv_table_create(guider_ui.screen_cont_p);
|
|
table_style_init(guider_ui.screen_run_step);
|
|
lv_obj_add_event_cb(guider_ui.screen_run_step, table_style_cb, LV_EVENT_DRAW_PART_BEGIN, NULL);
|
|
lv_table_set_row_cnt(guider_ui.screen_run_step,1);
|
|
lv_table_set_col_width(guider_ui.screen_run_step, 0, 80);
|
|
lv_table_set_col_width(guider_ui.screen_run_step, 1, 370);
|
|
lv_table_set_cell_value(guider_ui.screen_run_step,0,0,"步");
|
|
lv_table_set_cell_value(guider_ui.screen_run_step,0,1,"工艺");
|
|
/* Add your codes here */
|
|
}
|
|
|
|
|