From 5119549f8789977417c86123bad47f29834d4429 Mon Sep 17 00:00:00 2001 From: Alix ANNERAUD Date: Thu, 19 Dec 2024 23:01:32 +0100 Subject: [PATCH] Refactor Desk module to use Event_code_type for event handling; update Home event sending method --- .../Executables/Shell/Graphical/src/Desk.rs | 26 +++++++++++-------- .../Executables/Shell/Graphical/src/Home.rs | 2 +- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/Modules/Executables/Shell/Graphical/src/Desk.rs b/Modules/Executables/Shell/Graphical/src/Desk.rs index 947a703..23dc0f7 100644 --- a/Modules/Executables/Shell/Graphical/src/Desk.rs +++ b/Modules/Executables/Shell/Graphical/src/Desk.rs @@ -3,7 +3,7 @@ use crate::{ Icon::Create_icon, }; -use Graphics::{Color_type, Point_type, Window_type, LVGL}; +use Graphics::{Color_type, Event_code_type, Point_type, Window_type, LVGL}; pub struct Desk_type { Window: Window_type, @@ -28,7 +28,7 @@ impl Desk_type { const Dock_icon_size: Point_type = Point_type::New(32, 32); const Drawer_icon_size: Point_type = Point_type::New(48, 48); - pub const Home_event: u32 = LVGL::lv_event_code_t_LV_EVENT_LAST + 1; + pub const Home_event: Event_code_type = Event_code_type::Custom_1; pub fn Get_window_object(&self) -> *mut LVGL::lv_obj_t { self.Window.Get_object() @@ -190,7 +190,7 @@ impl Desk_type { pub fn Event_handler(&mut self) { while let Some(Event) = self.Window.Pop_event() { - match Event.Code { + match Event.Get_code() { Self::Home_event => unsafe { LVGL::lv_tileview_set_tile_by_index( self.Tile_view, @@ -199,8 +199,8 @@ impl Desk_type { LVGL::lv_anim_enable_t_LV_ANIM_ON, ); }, - LVGL::lv_event_code_t_LV_EVENT_VALUE_CHANGED => { - if Event.Target == self.Tile_view { + Event_code_type::Value_changed => { + if Event.Get_target() == self.Tile_view { unsafe { if LVGL::lv_tileview_get_tile_active(self.Tile_view) == self.Desk_tile { let _Lock = Graphics::Get_instance().Lock().unwrap(); @@ -212,9 +212,11 @@ impl Desk_type { } } } - LVGL::lv_event_code_t_LV_EVENT_PRESSED => { - if Event.Target == self.Main_button - || unsafe { LVGL::lv_obj_get_parent(Event.Target) == self.Main_button } + Event_code_type::Pressed => { + if Event.Get_target() == self.Main_button + || unsafe { + LVGL::lv_obj_get_parent(Event.Get_target()) == self.Main_button + } { unsafe { LVGL::lv_obj_add_state(self.Main_button, LVGL::LV_STATE_PRESSED as u16); @@ -226,9 +228,11 @@ impl Desk_type { } } } - LVGL::lv_event_code_t_LV_EVENT_RELEASED => { - if Event.Target == self.Main_button - || unsafe { LVGL::lv_obj_get_parent(Event.Target) == self.Main_button } + Event_code_type::Released => { + if Event.Get_target() == self.Main_button + || unsafe { + LVGL::lv_obj_get_parent(Event.Get_target()) == self.Main_button + } { const State: u16 = LVGL::LV_STATE_PRESSED as u16; diff --git a/Modules/Executables/Shell/Graphical/src/Home.rs b/Modules/Executables/Shell/Graphical/src/Home.rs index 0871668..7bbdc99 100644 --- a/Modules/Executables/Shell/Graphical/src/Home.rs +++ b/Modules/Executables/Shell/Graphical/src/Home.rs @@ -88,6 +88,6 @@ unsafe extern "C" fn Handle_released(Event: *mut LVGL::lv_event_t) { LVGL::lv_obj_remove_flag(Desk, LVGL::lv_obj_flag_t_LV_OBJ_FLAG_HIDDEN); LVGL::lv_obj_move_foreground(Desk); - LVGL::lv_obj_send_event(Desk, Desk_type::Home_event, null_mut()); + LVGL::lv_obj_send_event(Desk, Desk_type::Home_event.Into_LVGL_code(), null_mut()); } }