/* * Copyright 2025 NXP * NXP 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. */ #include "events_init.h" #include #include "lvgl.h" #if LV_USE_GUIDER_SIMULATOR && LV_USE_FREEMASTER #include "freemaster_client.h" #endif #include "guider_customer_fonts.h" #include "../custom/custom.h" #include "../custom/lv_conf_ext.h" static void set_global_font_for_tabview(lv_obj_t * tabview, const lv_font_t * font) { static lv_style_t style; lv_style_init(&style); lv_style_set_text_font(&style, font); // 设置指定的字体[^1] lv_obj_add_style(tabview, &style, LV_PART_MAIN | LV_STATE_DEFAULT); // 应用于主要部分 } void screen_home_init(lv_ui *ui) { #ifdef USE_CUSTOM_CODE lv_obj_set_style_text_font(ui->screen_home_table_1, lv_ft_MHEIGB[24].font, LV_PART_ITEMS|LV_STATE_DEFAULT); lv_obj_set_style_text_font(ui->screen_home_btnm_1, lv_ft_MHEIGB[24].font, LV_PART_ITEMS|LV_STATE_DEFAULT); // lv_obj_t *tab_btns = lv_tabview_get_tab_btns(ui->screen_home_tabview_2); // set_global_font_for_tabview(tab_btns, lv_ft_MHEIGB[24].font); // // 设置标签栏的字体样式 // lv_obj_set_style_text_font(tab_btns, lv_ft_MHEIGB[24].font, LV_PART_ITEMS | LV_STATE_DEFAULT); // lv_btnmatrix_set_btn_width(ui->screen_home_btnm_1, 0, LV_SIZE_CONTENT); // 设置所有按钮宽度自适应 #endif lv_table_set_col_width(ui->screen_home_table_1,0,60); } static void screen_logo_btn_1_event_handler (lv_event_t *e) { lv_event_code_t code = lv_event_get_code(e); switch (code) { case LV_EVENT_CLICKED: { ui_load_scr_animation(&guider_ui, &guider_ui.screen_home, guider_ui.screen_home_del, &guider_ui.screen_logo_del, setup_scr_screen_home, LV_SCR_LOAD_ANIM_NONE, 200, 200, false, true); screen_home_init(&guider_ui); break; } default: break; } } void events_init_screen_logo (lv_ui *ui) { lv_obj_add_event_cb(ui->screen_logo_btn_1, screen_logo_btn_1_event_handler, LV_EVENT_ALL, ui); } static void screen_home_tabview_1_event_handler (lv_event_t *e) { lv_event_code_t code = lv_event_get_code(e); switch (code) { case LV_EVENT_CLICKED: { lv_obj_add_flag(guider_ui.screen_home_win_1, LV_OBJ_FLAG_HIDDEN); break; } default: break; } } static void screen_home_btn_1_event_handler (lv_event_t *e) { lv_event_code_t code = lv_event_get_code(e); switch (code) { case LV_EVENT_CLICKED: { lv_obj_clear_flag(guider_ui.screen_home_win_1, LV_OBJ_FLAG_HIDDEN); break; } default: break; } } static void screen_home_btnm_1_event_handler (lv_event_t *e) { lv_event_code_t code = lv_event_get_code(e); switch (code) { case LV_EVENT_CLICKED: { lv_obj_t * obj = lv_event_get_target(e); uint32_t id = lv_btnmatrix_get_selected_btn(obj); switch (id) { case (0): { lv_obj_clear_flag(guider_ui.screen_home_win_1, LV_OBJ_FLAG_HIDDEN); break; } case (1): { lv_led_set_color(guider_ui.screen_home_led_1, lv_color_hex(0xff0000)); break; } case (2): { lv_led_set_color(guider_ui.screen_home_led_1, lv_color_hex(0x00ff55)); break; } default: break; } break; } default: break; } } static void screen_home_win_1_item0_event_handler (lv_event_t *e) { lv_event_code_t code = lv_event_get_code(e); switch (code) { case LV_EVENT_CLICKED: { lv_obj_add_flag(guider_ui.screen_home_win_1, LV_OBJ_FLAG_HIDDEN); break; } default: break; } } void events_init_screen_home (lv_ui *ui) { lv_obj_add_event_cb(ui->screen_home_tabview_1, screen_home_tabview_1_event_handler, LV_EVENT_ALL, ui); lv_obj_add_event_cb(ui->screen_home_btn_1, screen_home_btn_1_event_handler, LV_EVENT_ALL, ui); lv_obj_add_event_cb(ui->screen_home_btnm_1, screen_home_btnm_1_event_handler, LV_EVENT_ALL, ui); lv_obj_add_event_cb(ui->screen_home_win_1_item0, screen_home_win_1_item0_event_handler, LV_EVENT_ALL, ui); } void events_init(lv_ui *ui) { }