From 9e1fc3fa4f4adc800e5a8d0e997be57e11959b9a Mon Sep 17 00:00:00 2001 From: Olaf Wintermann Date: Fri, 12 Jun 2026 16:47:51 +0200 Subject: [PATCH] add extended splitview window API --- application/src/notebook.rs | 7 +++++++ application/src/window.rs | 5 +++-- ui-rs/src/ui/window.rs | 39 ++++++++++++++++++++++++++++++++++++- 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/application/src/notebook.rs b/application/src/notebook.rs index 8b8cbf3..43a0370 100644 --- a/application/src/notebook.rs +++ b/application/src/notebook.rs @@ -143,6 +143,13 @@ impl Notebook { } } + #[action] + pub fn note_activated(&mut self, event: &ActionEvent) { + if let EventType::ListSelection(s) = event.event_type { + self.select_note_from(NoteSelectFrom::ListSelection(s)); + } + } + #[action] pub fn new_note(&mut self, _event: &ActionEvent) { println!("new note"); diff --git a/application/src/window.rs b/application/src/window.rs index a524561..8fc9aee 100644 --- a/application/src/window.rs +++ b/application/src/window.rs @@ -28,7 +28,7 @@ use std::any::Any; use ui_rs::{action, ui_actions, UiModel}; use ui_rs::ui::*; -use crate::App; +use crate::{App, AppStates}; use entity::collection::{Model as Collection, Node}; use crate::backend::{BackendHandle, BroadcastMessage, NoteId}; use crate::newnotebook::new_notebook_dialog; @@ -189,7 +189,7 @@ pub fn create_window(app: &App, ctx: &AppContext) -> UiObject) -> UiObject toolkit::UiObject { ui_window_fullscreen(self.ptr, fullscreen as c_int); } } -} + + // split_window specific API + + pub fn splitview_set_pos(&mut self, pos: u32) { + unsafe { + ui_splitview_window_set_pos(self.ptr, pos as c_int); + } + } + + pub fn splitview_get_pos(&self) -> u32 { + unsafe { + ui_splitview_window_get_pos(self.ptr) as u32 + } + } + + pub fn splitview_set_visible(&mut self, pane: u32, visible: bool) { + unsafe { + ui_splitview_window_set_visible(self.ptr, pane as c_int, visible as c_int); + } + } + } /* ---------------------------------- main windows ---------------------------------- */ @@ -126,6 +146,17 @@ where F: FnOnce(&mut toolkit::UiObject, &mut T) { obj } +pub fn splitview_window_set_default_pos(pos: u32) { + unsafe { + ui_splitview_window_set_default_pos(pos as c_int); + } +} + +pub fn splitview_window_use_property(enable: bool) { + unsafe { + ui_splitview_window_use_property(enable as c_int); + } +} impl AppContext { pub fn window(&self, title: &str, data: T, create_ui: F) -> toolkit::UiObject @@ -469,6 +500,12 @@ extern "C" { fn ui_splitview_window(title: *const c_char, sidebar: c_int) -> *mut UiObject; fn ui_simple_window(title: *const c_char) -> *mut UiObject; + fn ui_splitview_window_set_pos(obj: *mut ffi::UiObject, pos: c_int); + fn ui_splitview_window_get_pos(obj: *mut ffi::UiObject) -> c_int; + fn ui_splitview_window_set_default_pos(pos: c_int); + fn ui_splitview_window_use_property(enable: c_int); + fn ui_splitview_window_set_visible(obj: *mut ffi::UiObject, pane: c_int, visible: c_int); + fn ui_dialog_create(parent: *mut UiObject, args: *mut UiDialogArgs); fn ui_dialog_window_create(parent: *mut UiObject, args: *mut UiDialogWindowArgs) -> *mut UiObject; -- 2.52.0