Skip to content

Commit

Permalink
Refactor Desk module to use Event_code_type for event handling; updat…
Browse files Browse the repository at this point in the history
…e Home event sending method
  • Loading branch information
AlixANNERAUD committed Dec 19, 2024
1 parent 74d1c85 commit 5119549
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
26 changes: 15 additions & 11 deletions Modules/Executables/Shell/Graphical/src/Desk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()
Expand Down Expand Up @@ -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,
Expand All @@ -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();
Expand All @@ -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);
Expand All @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion Modules/Executables/Shell/Graphical/src/Home.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

0 comments on commit 5119549

Please sign in to comment.