Make nav bar more compact
This commit is contained in:
parent
518e791593
commit
4fbf3e4663
3 changed files with 51 additions and 18 deletions
32
Cargo.lock
generated
32
Cargo.lock
generated
|
|
@ -956,7 +956,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmic-config"
|
name = "cosmic-config"
|
||||||
version = "0.1.0"
|
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 = [
|
dependencies = [
|
||||||
"atomicwrites",
|
"atomicwrites",
|
||||||
"cosmic-config-derive",
|
"cosmic-config-derive",
|
||||||
|
|
@ -970,7 +970,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmic-config-derive"
|
name = "cosmic-config-derive"
|
||||||
version = "0.1.0"
|
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 = [
|
dependencies = [
|
||||||
"quote",
|
"quote",
|
||||||
"syn 1.0.109",
|
"syn 1.0.109",
|
||||||
|
|
@ -1043,7 +1043,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmic-theme"
|
name = "cosmic-theme"
|
||||||
version = "0.1.0"
|
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 = [
|
dependencies = [
|
||||||
"almost",
|
"almost",
|
||||||
"cosmic-config",
|
"cosmic-config",
|
||||||
|
|
@ -2399,7 +2399,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced"
|
name = "iced"
|
||||||
version = "0.10.0"
|
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 = [
|
dependencies = [
|
||||||
"iced_accessibility",
|
"iced_accessibility",
|
||||||
"iced_core",
|
"iced_core",
|
||||||
|
|
@ -2414,7 +2414,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_accessibility"
|
name = "iced_accessibility"
|
||||||
version = "0.1.0"
|
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 = [
|
dependencies = [
|
||||||
"accesskit",
|
"accesskit",
|
||||||
"accesskit_winit",
|
"accesskit_winit",
|
||||||
|
|
@ -2423,7 +2423,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_core"
|
name = "iced_core"
|
||||||
version = "0.10.0"
|
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 = [
|
dependencies = [
|
||||||
"bitflags 1.3.2",
|
"bitflags 1.3.2",
|
||||||
"instant",
|
"instant",
|
||||||
|
|
@ -2437,7 +2437,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_futures"
|
name = "iced_futures"
|
||||||
version = "0.7.0"
|
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 = [
|
dependencies = [
|
||||||
"futures",
|
"futures",
|
||||||
"iced_core",
|
"iced_core",
|
||||||
|
|
@ -2450,7 +2450,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_graphics"
|
name = "iced_graphics"
|
||||||
version = "0.9.0"
|
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 = [
|
dependencies = [
|
||||||
"bitflags 1.3.2",
|
"bitflags 1.3.2",
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
|
|
@ -2468,7 +2468,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_renderer"
|
name = "iced_renderer"
|
||||||
version = "0.1.0"
|
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 = [
|
dependencies = [
|
||||||
"iced_graphics",
|
"iced_graphics",
|
||||||
"iced_tiny_skia",
|
"iced_tiny_skia",
|
||||||
|
|
@ -2481,7 +2481,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_runtime"
|
name = "iced_runtime"
|
||||||
version = "0.1.1"
|
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 = [
|
dependencies = [
|
||||||
"iced_core",
|
"iced_core",
|
||||||
"iced_futures",
|
"iced_futures",
|
||||||
|
|
@ -2491,7 +2491,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_style"
|
name = "iced_style"
|
||||||
version = "0.9.0"
|
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 = [
|
dependencies = [
|
||||||
"iced_core",
|
"iced_core",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
|
|
@ -2501,7 +2501,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_tiny_skia"
|
name = "iced_tiny_skia"
|
||||||
version = "0.1.0"
|
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 = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"cosmic-text 0.9.0",
|
"cosmic-text 0.9.0",
|
||||||
|
|
@ -2519,7 +2519,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_wgpu"
|
name = "iced_wgpu"
|
||||||
version = "0.11.1"
|
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 = [
|
dependencies = [
|
||||||
"bitflags 1.3.2",
|
"bitflags 1.3.2",
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
|
|
@ -2541,7 +2541,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_widget"
|
name = "iced_widget"
|
||||||
version = "0.1.3"
|
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 = [
|
dependencies = [
|
||||||
"iced_renderer",
|
"iced_renderer",
|
||||||
"iced_runtime",
|
"iced_runtime",
|
||||||
|
|
@ -2555,7 +2555,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_winit"
|
name = "iced_winit"
|
||||||
version = "0.10.0"
|
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 = [
|
dependencies = [
|
||||||
"iced_graphics",
|
"iced_graphics",
|
||||||
"iced_runtime",
|
"iced_runtime",
|
||||||
|
|
@ -2853,7 +2853,7 @@ checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libcosmic"
|
name = "libcosmic"
|
||||||
version = "0.1.0"
|
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 = [
|
dependencies = [
|
||||||
"apply",
|
"apply",
|
||||||
"ashpd",
|
"ashpd",
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ features = ["syntect", "vi"]
|
||||||
|
|
||||||
[dependencies.libcosmic]
|
[dependencies.libcosmic]
|
||||||
git = "https://github.com/pop-os/libcosmic"
|
git = "https://github.com/pop-os/libcosmic"
|
||||||
|
branch = "customizable-nav-bar"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["tokio", "winit", "wgpu"]
|
features = ["tokio", "winit", "wgpu"]
|
||||||
#path = "../libcosmic"
|
#path = "../libcosmic"
|
||||||
|
|
|
||||||
36
src/main.rs
36
src/main.rs
|
|
@ -11,9 +11,9 @@ use cosmic::{
|
||||||
widget::{row, text},
|
widget::{row, text},
|
||||||
window, Alignment, Length, Point,
|
window, Alignment, Length, Point,
|
||||||
},
|
},
|
||||||
style,
|
style, theme,
|
||||||
widget::{self, button, icon, nav_bar, segmented_button, view_switcher},
|
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 cosmic_text::{Cursor, Edit, Family, FontSystem, SwashCache, SyntaxSystem, ViMode};
|
||||||
use std::{
|
use std::{
|
||||||
|
|
@ -539,6 +539,38 @@ impl Application for App {
|
||||||
(app, command)
|
(app, command)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The default nav_bar widget needs to be condensed for cosmic-edit
|
||||||
|
fn nav_bar(&self) -> Option<Element<message::Message<Self::Message>>> {
|
||||||
|
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> {
|
fn nav_model(&self) -> Option<&nav_bar::Model> {
|
||||||
Some(&self.nav_model)
|
Some(&self.nav_model)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue