From f305623998ac6318f0ade1c9d36b356bec8c0036 Mon Sep 17 00:00:00 2001 From: Olaf Wintermann Date: Thu, 18 Jun 2026 19:25:53 +0200 Subject: [PATCH] add toolbar button to toggle note maximized status --- application/src/main.rs | 8 ++++++++ application/src/notebook.rs | 22 +++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/application/src/main.rs b/application/src/main.rs index 12aa03c..6ad759c 100644 --- a/application/src/main.rs +++ b/application/src/main.rs @@ -151,12 +151,20 @@ fn create_toolbar(app: &AppContext) { 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(); }); diff --git a/application/src/notebook.rs b/application/src/notebook.rs index 9c5ca4b..a5f7d02 100644 --- a/application/src/notebook.rs +++ b/application/src/notebook.rs @@ -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, + #[bind("notebook_dual_view")] + pub view: UiInteger, + #[bind("notes")] pub notes: UiList } @@ -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 = 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) { -- 2.52.0