diff --git a/Cargo.lock b/Cargo.lock index 9304222..0bb2cfb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -956,7 +956,7 @@ dependencies = [ [[package]] name = "cosmic-config" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#d1537b4c39bc48b020c9965c0c862207d0060889" +source = "git+https://github.com/pop-os/libcosmic?branch=customizable-nav-bar#5e850a6f88c6b6647d9b6e322fd0bb0399d2f2a6" dependencies = [ "atomicwrites", "cosmic-config-derive", @@ -970,7 +970,7 @@ dependencies = [ [[package]] name = "cosmic-config-derive" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#d1537b4c39bc48b020c9965c0c862207d0060889" +source = "git+https://github.com/pop-os/libcosmic?branch=customizable-nav-bar#5e850a6f88c6b6647d9b6e322fd0bb0399d2f2a6" dependencies = [ "quote", "syn 1.0.109", @@ -1043,7 +1043,7 @@ dependencies = [ [[package]] name = "cosmic-theme" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#d1537b4c39bc48b020c9965c0c862207d0060889" +source = "git+https://github.com/pop-os/libcosmic?branch=customizable-nav-bar#5e850a6f88c6b6647d9b6e322fd0bb0399d2f2a6" dependencies = [ "almost", "cosmic-config", @@ -2399,7 +2399,7 @@ dependencies = [ [[package]] name = "iced" version = "0.10.0" -source = "git+https://github.com/pop-os/libcosmic#d1537b4c39bc48b020c9965c0c862207d0060889" +source = "git+https://github.com/pop-os/libcosmic?branch=customizable-nav-bar#5e850a6f88c6b6647d9b6e322fd0bb0399d2f2a6" dependencies = [ "iced_accessibility", "iced_core", @@ -2414,7 +2414,7 @@ dependencies = [ [[package]] name = "iced_accessibility" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#d1537b4c39bc48b020c9965c0c862207d0060889" +source = "git+https://github.com/pop-os/libcosmic?branch=customizable-nav-bar#5e850a6f88c6b6647d9b6e322fd0bb0399d2f2a6" dependencies = [ "accesskit", "accesskit_winit", @@ -2423,7 +2423,7 @@ dependencies = [ [[package]] name = "iced_core" version = "0.10.0" -source = "git+https://github.com/pop-os/libcosmic#d1537b4c39bc48b020c9965c0c862207d0060889" +source = "git+https://github.com/pop-os/libcosmic?branch=customizable-nav-bar#5e850a6f88c6b6647d9b6e322fd0bb0399d2f2a6" dependencies = [ "bitflags 1.3.2", "instant", @@ -2437,7 +2437,7 @@ dependencies = [ [[package]] name = "iced_futures" version = "0.7.0" -source = "git+https://github.com/pop-os/libcosmic#d1537b4c39bc48b020c9965c0c862207d0060889" +source = "git+https://github.com/pop-os/libcosmic?branch=customizable-nav-bar#5e850a6f88c6b6647d9b6e322fd0bb0399d2f2a6" dependencies = [ "futures", "iced_core", @@ -2450,7 +2450,7 @@ dependencies = [ [[package]] name = "iced_graphics" version = "0.9.0" -source = "git+https://github.com/pop-os/libcosmic#d1537b4c39bc48b020c9965c0c862207d0060889" +source = "git+https://github.com/pop-os/libcosmic?branch=customizable-nav-bar#5e850a6f88c6b6647d9b6e322fd0bb0399d2f2a6" dependencies = [ "bitflags 1.3.2", "bytemuck", @@ -2468,7 +2468,7 @@ dependencies = [ [[package]] name = "iced_renderer" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#d1537b4c39bc48b020c9965c0c862207d0060889" +source = "git+https://github.com/pop-os/libcosmic?branch=customizable-nav-bar#5e850a6f88c6b6647d9b6e322fd0bb0399d2f2a6" dependencies = [ "iced_graphics", "iced_tiny_skia", @@ -2481,7 +2481,7 @@ dependencies = [ [[package]] name = "iced_runtime" version = "0.1.1" -source = "git+https://github.com/pop-os/libcosmic#d1537b4c39bc48b020c9965c0c862207d0060889" +source = "git+https://github.com/pop-os/libcosmic?branch=customizable-nav-bar#5e850a6f88c6b6647d9b6e322fd0bb0399d2f2a6" dependencies = [ "iced_core", "iced_futures", @@ -2491,7 +2491,7 @@ dependencies = [ [[package]] name = "iced_style" version = "0.9.0" -source = "git+https://github.com/pop-os/libcosmic#d1537b4c39bc48b020c9965c0c862207d0060889" +source = "git+https://github.com/pop-os/libcosmic?branch=customizable-nav-bar#5e850a6f88c6b6647d9b6e322fd0bb0399d2f2a6" dependencies = [ "iced_core", "once_cell", @@ -2501,7 +2501,7 @@ dependencies = [ [[package]] name = "iced_tiny_skia" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#d1537b4c39bc48b020c9965c0c862207d0060889" +source = "git+https://github.com/pop-os/libcosmic?branch=customizable-nav-bar#5e850a6f88c6b6647d9b6e322fd0bb0399d2f2a6" dependencies = [ "bytemuck", "cosmic-text 0.9.0", @@ -2519,7 +2519,7 @@ dependencies = [ [[package]] name = "iced_wgpu" version = "0.11.1" -source = "git+https://github.com/pop-os/libcosmic#d1537b4c39bc48b020c9965c0c862207d0060889" +source = "git+https://github.com/pop-os/libcosmic?branch=customizable-nav-bar#5e850a6f88c6b6647d9b6e322fd0bb0399d2f2a6" dependencies = [ "bitflags 1.3.2", "bytemuck", @@ -2541,7 +2541,7 @@ dependencies = [ [[package]] name = "iced_widget" version = "0.1.3" -source = "git+https://github.com/pop-os/libcosmic#d1537b4c39bc48b020c9965c0c862207d0060889" +source = "git+https://github.com/pop-os/libcosmic?branch=customizable-nav-bar#5e850a6f88c6b6647d9b6e322fd0bb0399d2f2a6" dependencies = [ "iced_renderer", "iced_runtime", @@ -2555,7 +2555,7 @@ dependencies = [ [[package]] name = "iced_winit" version = "0.10.0" -source = "git+https://github.com/pop-os/libcosmic#d1537b4c39bc48b020c9965c0c862207d0060889" +source = "git+https://github.com/pop-os/libcosmic?branch=customizable-nav-bar#5e850a6f88c6b6647d9b6e322fd0bb0399d2f2a6" dependencies = [ "iced_graphics", "iced_runtime", @@ -2853,7 +2853,7 @@ checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" [[package]] name = "libcosmic" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#d1537b4c39bc48b020c9965c0c862207d0060889" +source = "git+https://github.com/pop-os/libcosmic?branch=customizable-nav-bar#5e850a6f88c6b6647d9b6e322fd0bb0399d2f2a6" dependencies = [ "apply", "ashpd", diff --git a/Cargo.toml b/Cargo.toml index 31bbd4c..3540b10 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,6 +29,7 @@ features = ["syntect", "vi"] [dependencies.libcosmic] git = "https://github.com/pop-os/libcosmic" +branch = "customizable-nav-bar" default-features = false features = ["tokio", "winit", "wgpu"] #path = "../libcosmic" diff --git a/src/main.rs b/src/main.rs index e745584..628bf35 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,9 +11,9 @@ use cosmic::{ widget::{row, text}, window, Alignment, Length, Point, }, - style, + style, theme, widget::{self, button, icon, nav_bar, segmented_button, view_switcher}, - Application, ApplicationExt, Element, + Application, ApplicationExt, Apply, Element, }; use cosmic_text::{Cursor, Edit, Family, FontSystem, SwashCache, SyntaxSystem, ViMode}; use std::{ @@ -539,6 +539,38 @@ impl Application for App { (app, command) } + // The default nav_bar widget needs to be condensed for cosmic-edit + fn nav_bar(&self) -> Option>> { + if !self.core().nav_bar_active() { + return None; + } + + let nav_model = self.nav_model()?; + + let mut nav = segmented_button::vertical(nav_model) + .button_height(24) + .button_padding([16, 4, 16, 4]) + .button_spacing(4) + .on_activate(|entity| message::cosmic(cosmic::app::cosmic::Message::NavBar(entity))) + .spacing(0) + .style(theme::SegmentedButton::ViewSwitcher) + .apply(widget::container) + .padding([8, 16]) + .width(Length::Fill); + + if !self.core().is_condensed() { + nav = nav.max_width(300); + } + + Some( + nav.apply(widget::scrollable) + .apply(widget::container) + .height(Length::Fill) + .style(theme::Container::custom(nav_bar::nav_bar_style)) + .into(), + ) + } + fn nav_model(&self) -> Option<&nav_bar::Model> { Some(&self.nav_model) }