From: Olaf Wintermann Date: Thu, 21 May 2026 18:04:10 +0000 (+0200) Subject: implement SubList event type X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;h=HEAD;p=note.git implement SubList event type --- diff --git a/application/src/notebook.rs b/application/src/notebook.rs index 80df474..a601006 100644 --- a/application/src/notebook.rs +++ b/application/src/notebook.rs @@ -1,4 +1,4 @@ -use ui_rs::{action, ui_actions, UiModel}; +use ui_rs::{ui_actions, UiModel}; use ui_rs::ui::*; use entity::note::Model as Note; diff --git a/application/src/window.rs b/application/src/window.rs index d1bd531..9f4810e 100644 --- a/application/src/window.rs +++ b/application/src/window.rs @@ -125,7 +125,9 @@ pub fn create_window(app: &App, ctx: &AppContext) -> UiObject { pub obj: &'a mut UiObject, @@ -59,7 +59,7 @@ pub enum EventType<'a> { ListSelection(&'a ListSelection), ListElement, Dnd, - SubList, + SubList(&'a mut SubListEvent), FileList } @@ -75,7 +75,7 @@ enum EventTypeData { ListSelection(ListSelection), ListElement, Dnd, - SubList, + SubList(SubListEvent), FileList } @@ -106,6 +106,21 @@ fn get_event_data(e: *const ffi::UiEvent) -> EventTypeData { 8 => { EventTypeData::ListSelection( ListSelection::from_ptr(ptr.cast()) ) } + 9 => { + // list elm + EventTypeData::Null + } + 10 => { + // dnd + EventTypeData::Null + } + 11 => { + EventTypeData::SubList(SubListEvent::from_ptr(ptr.cast())) + } + 12 => { + // filelist + EventTypeData::Null + } _ => EventTypeData::Null } } @@ -120,10 +135,10 @@ fn get_event_type<'a>(data: &'a mut EventTypeData) -> EventType<'a> { EventTypeData::TextValue(t) => EventType::TextValue( t ), EventTypeData::DoubleValue(d) => EventType::DoubleValue( d ), EventTypeData::RangeValue(r) => EventType::RangeValue( r ), - EventTypeData::ListSelection(s) => EventType::ListSelection( s), + EventTypeData::ListSelection(s) => EventType::ListSelection( s ), EventTypeData::ListElement => EventType::ListElement, EventTypeData::Dnd => EventType::Dnd, - EventTypeData::SubList => EventType::SubList, + EventTypeData::SubList(s) => EventType::SubList( s ), EventTypeData::FileList => EventType::FileList, } } @@ -205,6 +220,26 @@ pub extern "C" fn action_event_wrapper(e: *const ffi::UiEvent, data: *mut c_v } } + +pub struct SubListEvent { + /// SubList index + pub sublist_index: usize, + /// Row index (inside the sublist) or -1 if this is an event for the header item + pub row_index: i32, +} + +impl SubListEvent { + pub fn from_ptr(ptr: *const UiSubListEventData) -> SubListEvent { + unsafe { + SubListEvent { + sublist_index: ui_sublist_event_get_sublist_index(ptr) as usize, + row_index: ui_sublist_event_get_row_index(ptr) + } + } + } +} + + extern "C" { fn ui_event_get_obj(event: *const UiEvent) -> *mut ffi::UiObject; fn ui_event_get_windowdata(event: *const UiEvent) -> *const c_void; @@ -213,4 +248,7 @@ extern "C" { fn ui_event_get_eventdatatype(event: *const UiEvent) -> i32; fn ui_event_get_int(event: *const UiEvent) -> i32; fn ui_event_get_set(event: *const UiEvent) -> i32; + + fn ui_sublist_event_get_sublist_index(event: *const UiSubListEventData) -> i32; + fn ui_sublist_event_get_row_index(event: *const UiSubListEventData) -> i32; } \ No newline at end of file diff --git a/ui-rs/src/ui/ffi.rs b/ui-rs/src/ui/ffi.rs index cc48d34..c2a2858 100644 --- a/ui-rs/src/ui/ffi.rs +++ b/ui-rs/src/ui/ffi.rs @@ -46,6 +46,11 @@ pub struct UiEvent { _private: [u8; 0], } +#[repr(C)] +pub struct UiSubListEventData { + _private: [u8; 0], +} + #[repr(C)] pub struct UiText { _private: [u8; 0], diff --git a/ui-rs/src/ui/toolkit.rs b/ui-rs/src/ui/toolkit.rs index 60c08e8..917f948 100644 --- a/ui-rs/src/ui/toolkit.rs +++ b/ui-rs/src/ui/toolkit.rs @@ -718,6 +718,10 @@ impl UiSourceList { } } + pub fn data(&self) -> &Vec> { + &self.sublists + } + pub fn len(&self) -> usize { self.sublists.len() }