]> uap-core.de Git - note.git/commitdiff
add extended splitview window API
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Fri, 12 Jun 2026 14:47:51 +0000 (16:47 +0200)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Fri, 12 Jun 2026 14:47:51 +0000 (16:47 +0200)
application/src/notebook.rs
application/src/window.rs
ui-rs/src/ui/window.rs

index 8b8cbf3fca9339872efb18e1aa91a77453c16e75..43a03709bad099680b29a278dd1429afd7d2a1de 100644 (file)
@@ -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");
index a52456140ea44d4f241573491b2a5890e800fae7..8fc9aeeab81c2b3f5591ca0cf0681967e35f2109 100644 (file)
@@ -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<MainWindow>) -> UiObject<MainWi
         init_window_data(data, app);
         data.obj = obj.obj_ref();
         
-        
+        obj.ctx.set_state(AppStates::NoteEnableNew as i32);
 
         obj.sidebar_builder().create(|obj|{
             obj.sourcelist(|b|{
@@ -230,6 +230,7 @@ pub fn create_window(app: &App, ctx: &AppContext<MainWindow>) -> UiObject<MainWi
                 .fill(true)
                 .getvalue(notelist_getvalue)
                 .onselection_action("note_selected")
+                .onactivate_action("note_activated")
                 .create();
         });
 
index 1c6a43708a2aae722e205816d1d2728c8710d56b..b0df4658599572f47bad7b1dafd598d139bddfaa 100644 (file)
@@ -75,7 +75,27 @@ impl<T> toolkit::UiObject<T> {
             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<T>, &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<T: UiModel + UiActions> AppContext<T> {
     pub fn window<F>(&self, title: &str, data: T, create_ui: F) -> toolkit::UiObject<T>
@@ -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;