]> uap-core.de Git - note.git/commitdiff
add toolbar button to toggle note maximized status main
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Thu, 18 Jun 2026 17:25:53 +0000 (19:25 +0200)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Thu, 18 Jun 2026 17:25:53 +0000 (19:25 +0200)
application/src/main.rs
application/src/notebook.rs

index 12aa03c86a2b9802ff405856f9be77f1cf52e5eb..6ad759c147dbda390b32c098d5baaa559a4fab65 100644 (file)
@@ -151,12 +151,20 @@ fn create_toolbar(app: &AppContext<MainWindow>) {
     app.toolbar_item("go_back").icon(UiIconSet::GoBack.as_str()).action("go_back").create();
     app.toolbar_item("go_forward").icon(UiIconSet::GoForward.as_str()).action("go_forward").create();
     app.toolbar_item("new_note").icon(UiIconSet::NewDocument.as_str()).action("new_note").states(&[AppStates::NoteEnableNew as i32]).create();
+    app.toolbar_content_toggleitem("note_maximize")
+        .icon0(UiIconSet::ViewFullscreen.as_str())
+        .icon1(UiIconSet::ViewRestore.as_str())
+        .varname("notebook_dual_view")
+        .action("notebook_view_changed")
+        .create();
 
     app.toolbar_add_default("new_notebook", ToolbarItemPosition::SidebarLeft);
     app.toolbar_add_default("go_back", ToolbarItemPosition::Left);
     app.toolbar_add_default("go_forward", ToolbarItemPosition::Left);
     app.toolbar_add_default("new_note", ToolbarItemPosition::Left);
 
+    app.toolbar_add_default("note_maximize", ToolbarItemPosition::RightPanelRight);
+
     app.toolbar_appmenu(|menu|{
         menu.item("New Window").onclick(|_| new_app_window() ).create();
     });
index 9c5ca4b9bba051eb43246025c4989d0c73b19509..a5f7d02597dd71ab529314e8e1d10d29017bf4ae 100644 (file)
@@ -33,6 +33,7 @@ use ui_rs::{action, ui_actions, UiModel};
 use ui_rs::ui::*;
 
 use entity::note::{Model as Note};
+use crate::AppStates;
 use crate::backend::{BackendHandle, BroadcastMessage, NoteId, NoteTitleUpdate, NoteUpdate};
 use crate::note::new_note_id;
 use crate::window::NavigationItem;
@@ -52,6 +53,9 @@ pub struct Notebook {
 
     pub selected_note: Option<NoteSelection>,
 
+    #[bind("notebook_dual_view")]
+    pub view: UiInteger,
+
     #[bind("notes")]
     pub notes: UiList<NoteItem>
 }
@@ -66,6 +70,7 @@ impl Notebook {
             broadcast_rx: backend.btx.subscribe(),
             collection_id: id,
             selected_note: None,
+            view: Default::default(),
             notes: Default::default()
         }
     }
@@ -131,7 +136,7 @@ impl Notebook {
             NoteSelectFrom::ListSelection(s) => {
                 let index = s.selected_index()?;
                 if self.is_current_selection(&self.get_note_id(index)) {
-                    return None
+                    return Some(())
                 }
                 self.detach_current_note();
                 let note = s.selected_element_mut(self.notes.data_mut())?;
@@ -141,7 +146,7 @@ impl Notebook {
             NoteSelectFrom::NavigationItem(nav) => {
                 let index = self.find_note(&nav.note_id?)?;
                 if self.is_current_selection(&self.get_note_id(index)) {
-                    return None
+                    return Some(())
                 }
                 self.detach_current_note();
                 self.notes.select_with_event(index as i32, false);
@@ -193,6 +198,7 @@ impl Notebook {
         if let EventType::ListSelection(s) = event.event_type {
             let result = self.select_note_from(NoteSelectFrom::ListSelection(s), true);
             obj.splitview_set_visible(0, false);
+            self.view.set(1);
             // in case select_note_from didn't return a result, the note was already selected
             // and no new navigation item was added
             if result.is_none() {
@@ -204,7 +210,7 @@ impl Notebook {
                 };
 
                 let arg: Box<dyn Any> = Box::new(nav);
-                obj.ctx.call_action_with_parameter("navigation", arg);
+                obj.ctx.call_action_with_parameter("navigate_to_note", arg);
             }
         }
 
@@ -235,6 +241,16 @@ impl Notebook {
 
         self.select_note_from(NoteSelectFrom::NavigationItem(nav.clone()), false);
         obj.splitview_set_visible(0, !nav.note_maximized);
+        self.view.set(nav.note_maximized as i64);
+    }
+
+    #[action]
+    pub fn notebook_view_changed(&mut self, event: &mut ActionEvent) {
+        let Some(obj) = &mut event.obj else {
+            return;
+        };
+
+        obj.splitview_set_visible(0, event.intval == 0);
     }
 
     pub fn update_note_title(&mut self, update: &NoteTitleUpdate) {