From b64f58998fe20d77454ff8010a500d3b816a9dc1 Mon Sep 17 00:00:00 2001 From: Olaf Wintermann Date: Thu, 21 May 2026 19:36:08 +0200 Subject: [PATCH] extend UiSourceList API --- ui-rs/src/ui/toolkit.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/ui-rs/src/ui/toolkit.rs b/ui-rs/src/ui/toolkit.rs index fdbdc5e..60c08e8 100644 --- a/ui-rs/src/ui/toolkit.rs +++ b/ui-rs/src/ui/toolkit.rs @@ -718,6 +718,18 @@ impl UiSourceList { } } + pub fn len(&self) -> usize { + self.sublists.len() + } + + pub fn get(&self, index: usize) -> Option<&SubList> { + self.sublists.get(index) + } + + pub fn get_mut(&mut self, index: usize) -> Option<&mut SubList> { + self.sublists.get_mut(index) + } + pub fn push(&mut self, sublist: SubList) { unsafe { ui_list_append(self.ptr, sublist.handle as *mut c_void); @@ -759,6 +771,19 @@ impl UiSourceList { } } +impl std::ops::Index for UiSourceList { + type Output = SubList; + + fn index(&self, index: usize) -> &Self::Output { + &self.sublists[index] + } +} + +impl std::ops::IndexMut for UiSourceList { + fn index_mut(&mut self, index: usize) -> &mut Self::Output { + &mut self.sublists[index] + } +} /* -------------------------------- List -------------------------------- */ -- 2.47.3