fix(menu): styling

Also improves the styling of resize indicators, and removes the unnecessary `.density()` method call for the SSD header.
This commit is contained in:
Vukašin Vojinović 2024-09-28 13:58:51 +02:00 committed by Victoria Brekenfeld
parent be38da47e9
commit b7a34bdd1e
11 changed files with 70 additions and 81 deletions

58
Cargo.lock generated
View file

@ -869,7 +869,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/#af68a3f660402b850dfd00041372d964d3b098d7" source = "git+https://github.com/pop-os/libcosmic/#5306649be1cfb6c384da11e2ab25cafc4be79b14"
dependencies = [ dependencies = [
"atomicwrites", "atomicwrites",
"calloop 0.14.1", "calloop 0.14.1",
@ -888,7 +888,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/#af68a3f660402b850dfd00041372d964d3b098d7" source = "git+https://github.com/pop-os/libcosmic/#5306649be1cfb6c384da11e2ab25cafc4be79b14"
dependencies = [ dependencies = [
"quote", "quote",
"syn 1.0.109", "syn 1.0.109",
@ -923,7 +923,7 @@ dependencies = [
[[package]] [[package]]
name = "cosmic-text" name = "cosmic-text"
version = "0.12.1" version = "0.12.1"
source = "git+https://github.com/pop-os/cosmic-text.git#e8f567cf5b456dfab749a575c257acaa36f622d9" source = "git+https://github.com/pop-os/cosmic-text.git#4fe90bb6126c22f589b46768d7754d65ae300c5e"
dependencies = [ dependencies = [
"bitflags 2.6.0", "bitflags 2.6.0",
"fontdb", "fontdb",
@ -946,7 +946,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/#af68a3f660402b850dfd00041372d964d3b098d7" source = "git+https://github.com/pop-os/libcosmic/#5306649be1cfb6c384da11e2ab25cafc4be79b14"
dependencies = [ dependencies = [
"almost", "almost",
"cosmic-config", "cosmic-config",
@ -1062,7 +1062,7 @@ version = "0.19.0"
source = "git+https://github.com/gfx-rs/wgpu?rev=20fda69#20fda698341efbdc870b8027d6d49f5bf3f36109" source = "git+https://github.com/gfx-rs/wgpu?rev=20fda69#20fda698341efbdc870b8027d6d49f5bf3f36109"
dependencies = [ dependencies = [
"bitflags 2.6.0", "bitflags 2.6.0",
"libloading 0.7.4", "libloading 0.8.5",
"winapi", "winapi",
] ]
@ -1197,7 +1197,7 @@ version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "330c60081dcc4c72131f8eb70510f1ac07223e5d4163db481a04a0befcffa412" checksum = "330c60081dcc4c72131f8eb70510f1ac07223e5d4163db481a04a0befcffa412"
dependencies = [ dependencies = [
"libloading 0.7.4", "libloading 0.8.5",
] ]
[[package]] [[package]]
@ -2140,7 +2140,7 @@ dependencies = [
"bitflags 2.6.0", "bitflags 2.6.0",
"com", "com",
"libc", "libc",
"libloading 0.7.4", "libloading 0.8.5",
"thiserror", "thiserror",
"widestring", "widestring",
"winapi", "winapi",
@ -2290,7 +2290,7 @@ dependencies = [
[[package]] [[package]]
name = "iced" name = "iced"
version = "0.12.0" version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic/#a962865230f3b9ecba40c0c09e9c279e832c9f10" source = "git+https://github.com/pop-os/libcosmic/#5306649be1cfb6c384da11e2ab25cafc4be79b14"
dependencies = [ dependencies = [
"dnd", "dnd",
"iced_core", "iced_core",
@ -2306,7 +2306,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_core" name = "iced_core"
version = "0.12.0" version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic/#a962865230f3b9ecba40c0c09e9c279e832c9f10" source = "git+https://github.com/pop-os/libcosmic/#5306649be1cfb6c384da11e2ab25cafc4be79b14"
dependencies = [ dependencies = [
"bitflags 2.6.0", "bitflags 2.6.0",
"dnd", "dnd",
@ -2326,7 +2326,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_futures" name = "iced_futures"
version = "0.12.0" version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic/#a962865230f3b9ecba40c0c09e9c279e832c9f10" source = "git+https://github.com/pop-os/libcosmic/#5306649be1cfb6c384da11e2ab25cafc4be79b14"
dependencies = [ dependencies = [
"futures", "futures",
"iced_core", "iced_core",
@ -2338,7 +2338,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_graphics" name = "iced_graphics"
version = "0.12.0" version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic/#a962865230f3b9ecba40c0c09e9c279e832c9f10" source = "git+https://github.com/pop-os/libcosmic/#5306649be1cfb6c384da11e2ab25cafc4be79b14"
dependencies = [ dependencies = [
"bitflags 2.6.0", "bitflags 2.6.0",
"bytemuck", "bytemuck",
@ -2362,7 +2362,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_renderer" name = "iced_renderer"
version = "0.12.0" version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic/#a962865230f3b9ecba40c0c09e9c279e832c9f10" source = "git+https://github.com/pop-os/libcosmic/#5306649be1cfb6c384da11e2ab25cafc4be79b14"
dependencies = [ dependencies = [
"iced_graphics", "iced_graphics",
"iced_tiny_skia", "iced_tiny_skia",
@ -2374,7 +2374,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_runtime" name = "iced_runtime"
version = "0.12.0" version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic/#a962865230f3b9ecba40c0c09e9c279e832c9f10" source = "git+https://github.com/pop-os/libcosmic/#5306649be1cfb6c384da11e2ab25cafc4be79b14"
dependencies = [ dependencies = [
"dnd", "dnd",
"iced_core", "iced_core",
@ -2386,7 +2386,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_style" name = "iced_style"
version = "0.12.0" version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic/#a962865230f3b9ecba40c0c09e9c279e832c9f10" source = "git+https://github.com/pop-os/libcosmic/#5306649be1cfb6c384da11e2ab25cafc4be79b14"
dependencies = [ dependencies = [
"iced_core", "iced_core",
"once_cell", "once_cell",
@ -2396,7 +2396,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_tiny_skia" name = "iced_tiny_skia"
version = "0.12.0" version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic/#a962865230f3b9ecba40c0c09e9c279e832c9f10" source = "git+https://github.com/pop-os/libcosmic/#5306649be1cfb6c384da11e2ab25cafc4be79b14"
dependencies = [ dependencies = [
"bytemuck", "bytemuck",
"cosmic-text", "cosmic-text",
@ -2413,7 +2413,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_wgpu" name = "iced_wgpu"
version = "0.12.0" version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic/#a962865230f3b9ecba40c0c09e9c279e832c9f10" source = "git+https://github.com/pop-os/libcosmic/#5306649be1cfb6c384da11e2ab25cafc4be79b14"
dependencies = [ dependencies = [
"as-raw-xcb-connection", "as-raw-xcb-connection",
"bitflags 2.6.0", "bitflags 2.6.0",
@ -2442,7 +2442,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_widget" name = "iced_widget"
version = "0.12.0" version = "0.12.0"
source = "git+https://github.com/pop-os/libcosmic/#a962865230f3b9ecba40c0c09e9c279e832c9f10" source = "git+https://github.com/pop-os/libcosmic/#5306649be1cfb6c384da11e2ab25cafc4be79b14"
dependencies = [ dependencies = [
"dnd", "dnd",
"iced_renderer", "iced_renderer",
@ -2759,7 +2759,7 @@ checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c"
[[package]] [[package]]
name = "libcosmic" name = "libcosmic"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic/#af68a3f660402b850dfd00041372d964d3b098d7" source = "git+https://github.com/pop-os/libcosmic/#5306649be1cfb6c384da11e2ab25cafc4be79b14"
dependencies = [ dependencies = [
"apply", "apply",
"chrono", "chrono",
@ -2786,6 +2786,7 @@ dependencies = [
"tracing", "tracing",
"unicode-segmentation", "unicode-segmentation",
"url", "url",
"ustr",
] ]
[[package]] [[package]]
@ -5397,6 +5398,19 @@ dependencies = [
"percent-encoding", "percent-encoding",
] ]
[[package]]
name = "ustr"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e904a2279a4a36d2356425bb20be271029cc650c335bc82af8bfae30085a3d0"
dependencies = [
"ahash",
"byteorder",
"lazy_static",
"parking_lot 0.12.3",
"serde",
]
[[package]] [[package]]
name = "usvg" name = "usvg"
version = "0.37.0" version = "0.37.0"
@ -5772,7 +5786,7 @@ dependencies = [
"js-sys", "js-sys",
"log", "log",
"naga", "naga",
"parking_lot 0.11.2", "parking_lot 0.12.3",
"profiling", "profiling",
"raw-window-handle", "raw-window-handle",
"smallvec", "smallvec",
@ -5799,7 +5813,7 @@ dependencies = [
"log", "log",
"naga", "naga",
"once_cell", "once_cell",
"parking_lot 0.11.2", "parking_lot 0.12.3",
"profiling", "profiling",
"raw-window-handle", "raw-window-handle",
"rustc-hash", "rustc-hash",
@ -5833,13 +5847,13 @@ dependencies = [
"js-sys", "js-sys",
"khronos-egl", "khronos-egl",
"libc", "libc",
"libloading 0.7.4", "libloading 0.8.5",
"log", "log",
"metal", "metal",
"naga", "naga",
"objc", "objc",
"once_cell", "once_cell",
"parking_lot 0.11.2", "parking_lot 0.12.3",
"profiling", "profiling",
"range-alloc", "range-alloc",
"raw-window-handle", "raw-window-handle",

View file

@ -86,10 +86,10 @@ impl Program for ResizeIndicatorInternal {
} else { } else {
"go-down-symbolic" "go-down-symbolic"
}) })
.size(32) .size(20)
.prefer_svg(true) .prefer_svg(true)
.apply(container) .apply(container)
.padding(2) .padding(8)
.style(icon_container_style()) .style(icon_container_style())
.width(Length::Shrink) .width(Length::Shrink)
.apply(container) .apply(container)
@ -106,10 +106,10 @@ impl Program for ResizeIndicatorInternal {
} else { } else {
"go-next-symbolic" "go-next-symbolic"
}) })
.size(32) .size(20)
.prefer_svg(true) .prefer_svg(true)
.apply(container) .apply(container)
.padding(4) .padding(8)
.style(icon_container_style()) .style(icon_container_style())
.width(Length::Shrink) .width(Length::Shrink)
.apply(container) .apply(container)
@ -120,23 +120,11 @@ impl Program for ResizeIndicatorInternal {
horizontal_space(36).into() horizontal_space(36).into()
}, },
row(vec![ row(vec![
text(&self.shortcut1) text::heading(&self.shortcut1).into(),
.font(cosmic::font::FONT_SEMIBOLD) text::body(fl!("grow-window")).into(),
.size(14)
.into(),
text(fl!("grow-window"))
.font(cosmic::font::FONT)
.size(14)
.into(),
horizontal_space(40).into(), horizontal_space(40).into(),
text(&self.shortcut2) text::heading(&self.shortcut2).into(),
.font(cosmic::font::FONT_SEMIBOLD) text::body(fl!("shrink-window")).into(),
.size(14)
.into(),
text(fl!("shrink-window"))
.font(cosmic::font::FONT)
.size(14)
.into(),
]) ])
.apply(container) .apply(container)
.center_x() .center_x()
@ -158,10 +146,10 @@ impl Program for ResizeIndicatorInternal {
} else { } else {
"go-previous-symbolic" "go-previous-symbolic"
}) })
.size(32) .size(20)
.prefer_svg(true) .prefer_svg(true)
.apply(container) .apply(container)
.padding(4) .padding(8)
.style(icon_container_style()) .style(icon_container_style())
.height(Length::Shrink) .height(Length::Shrink)
.apply(container) .apply(container)
@ -181,10 +169,10 @@ impl Program for ResizeIndicatorInternal {
} else { } else {
"go-up-symbolic" "go-up-symbolic"
}) })
.size(32) .size(20)
.prefer_svg(true) .prefer_svg(true)
.apply(container) .apply(container)
.padding(4) .padding(8)
.style(icon_container_style()) .style(icon_container_style())
.width(Length::Shrink) .width(Length::Shrink)
.apply(container) .apply(container)

View file

@ -158,7 +158,7 @@ impl<Message: TabMessage + 'static> Tab<Message> {
id, id,
app_icon: from_name(app_id.into()).size(16).icon(), app_icon: from_name(app_id.into()).size(16).icon(),
title: title.into(), title: title.into(),
font: cosmic::font::FONT, font: cosmic::font::default(),
close_message: None, close_message: None,
press_message: None, press_message: None,
right_click_message: None, right_click_message: None,

View file

@ -39,7 +39,7 @@ impl TabText {
TabText { TabText {
width: Length::Shrink, width: Length::Shrink,
height: Length::Shrink, height: Length::Shrink,
font: cosmic::font::DEFAULT, font: cosmic::font::default(),
font_size: 14.0, font_size: 14.0,
selected, selected,
text, text,

View file

@ -134,7 +134,7 @@ where
} else { } else {
TabBackgroundTheme::ActiveDeactivated TabBackgroundTheme::ActiveDeactivated
}) })
.font(cosmic::font::FONT_SEMIBOLD) .font(cosmic::font::semibold())
.active() .active()
} else if i.checked_sub(1) == Some(active) { } else if i.checked_sub(1) == Some(active) {
tab.rule_style(rule).non_active() tab.rule_style(rule).non_active()

View file

@ -39,10 +39,7 @@ impl Program for StackHoverInternal {
.icon() .icon()
.into(), .into(),
horizontal_space(16).into(), horizontal_space(16).into(),
text(fl!("stack-windows")) text::title3(fl!("stack-windows")).into(),
.font(cosmic::font::FONT)
.size(24)
.into(),
]) ])
.align_items(Alignment::Center) .align_items(Alignment::Center)
.apply(container) .apply(container)

View file

@ -35,10 +35,7 @@ impl Program for SwapIndicatorInternal {
.icon() .icon()
.into(), .into(),
horizontal_space(16).into(), horizontal_space(16).into(),
text(fl!("swap-windows")) text::title3(fl!("swap-windows")).into(),
.font(cosmic::font::FONT)
.size(24)
.into(),
]) ])
.align_items(Alignment::Center) .align_items(Alignment::Center)
.apply(container) .apply(container)

View file

@ -11,10 +11,7 @@ use crate::{
}, },
}; };
use calloop::LoopHandle; use calloop::LoopHandle;
use cosmic::{ use cosmic::iced::{Color, Command};
config::Density,
iced::{Color, Command},
};
use smithay::{ use smithay::{
backend::{ backend::{
input::KeyState, input::KeyState,
@ -503,7 +500,6 @@ impl Program for CosmicWindowInternal {
.on_drag(Message::DragStart) .on_drag(Message::DragStart)
.on_close(Message::Close) .on_close(Message::Close)
.focused(self.window.is_activated(false)) .focused(self.window.is_activated(false))
.density(Density::Compact)
.on_double_click(Message::Maximize) .on_double_click(Message::Maximize)
.on_right_click(Message::Menu); .on_right_click(Message::Menu);

View file

@ -5,11 +5,11 @@ use std::sync::{
use calloop::LoopHandle; use calloop::LoopHandle;
use cosmic::{ use cosmic::{
iced::Background, iced::{Alignment, Background},
iced_core::{alignment::Horizontal, Border, Length, Pixels, Rectangle as IcedRectangle}, iced_core::{alignment::Horizontal, Border, Length, Rectangle as IcedRectangle},
iced_widget::{self, horizontal_rule, text::Appearance as TextAppearance, Column, Row}, iced_widget::{self, text::Appearance as TextAppearance, Column, Row},
theme, theme,
widget::{button, horizontal_space, icon::from_name, text}, widget::{button, divider, horizontal_space, icon::from_name, text},
Apply as _, Command, Apply as _, Command,
}; };
use smithay::{ use smithay::{
@ -348,13 +348,10 @@ impl Program for ContextMenu {
Column::with_children(self.items.iter().enumerate().map(|(idx, item)| { Column::with_children(self.items.iter().enumerate().map(|(idx, item)| {
match item { match item {
Item::Separator => horizontal_rule(1) Item::Separator => divider::horizontal::light().into(),
.style(theme::Rule::LightDivider)
.width(mode)
.into(),
Item::Submenu { title, .. } => Row::with_children(vec![ Item::Submenu { title, .. } => Row::with_children(vec![
horizontal_space(16).into(), horizontal_space(16).into(),
text(title).width(mode).into(), text::body(title).width(mode).into(),
from_name("go-next-symbolic") from_name("go-next-symbolic")
.size(16) .size(16)
.prefer_svg(true) .prefer_svg(true)
@ -363,7 +360,8 @@ impl Program for ContextMenu {
]) ])
.spacing(8) .spacing(8)
.width(width) .width(width)
.padding([8, 24]) .padding([8, 16])
.align_items(Alignment::Center)
.apply(|row| item::SubmenuItem::new(row, idx)) .apply(|row| item::SubmenuItem::new(row, idx))
.style(theme::Button::MenuItem) .style(theme::Button::MenuItem)
.into(), .into(),
@ -387,7 +385,7 @@ impl Program for ContextMenu {
} else { } else {
horizontal_space(16).into() horizontal_space(16).into()
}, },
text(title) text::body(title)
.width(mode) .width(mode)
.style(if *disabled { .style(if *disabled {
theme::Text::Custom(|theme| { theme::Text::Custom(|theme| {
@ -401,12 +399,11 @@ impl Program for ContextMenu {
theme::Text::Default theme::Text::Default
}) })
.into(), .into(),
horizontal_space(16).into(),
]; ];
if let Some(shortcut) = shortcut.as_ref() { if let Some(shortcut) = shortcut.as_ref() {
components.push( components.push(
text(shortcut) text::body(shortcut)
.line_height(Pixels(20.))
.size(14)
.horizontal_alignment(Horizontal::Right) .horizontal_alignment(Horizontal::Right)
.width(Length::Shrink) .width(Length::Shrink)
.style(theme::Text::Custom(|theme| { .style(theme::Text::Custom(|theme| {
@ -419,14 +416,14 @@ impl Program for ContextMenu {
.into(), .into(),
); );
} }
components.push(horizontal_space(16).into());
Row::with_children(components) Row::with_children(components)
.spacing(8) .spacing(8)
.width(mode) .width(mode)
.align_items(Alignment::Center)
.apply(button::custom) .apply(button::custom)
.width(width) .width(width)
.padding([8, 24]) .padding([8, 16])
.on_press_maybe((!disabled).then_some(Message::ItemPressed(idx))) .on_press_maybe((!disabled).then_some(Message::ItemPressed(idx)))
.style(theme::Button::MenuItem) .style(theme::Button::MenuItem)
.into() .into()

View file

@ -3707,7 +3707,7 @@ impl Shell {
cosmic::icon_theme::set_default(toolkit.icon_theme.clone()); cosmic::icon_theme::set_default(toolkit.icon_theme.clone());
} }
let mut container = cosmic::config::COSMIC_TK.lock().unwrap(); let mut container = cosmic::config::COSMIC_TK.write().unwrap();
if &*container != &toolkit { if &*container != &toolkit {
*container = toolkit; *container = toolkit;
drop(container); drop(container);

View file

@ -180,7 +180,7 @@ impl<P: Program + Send + Clone + 'static> Clone for IcedElementInternal<P> {
} }
let mut renderer = cosmic::Renderer::TinySkia(IcedGraphicsRenderer::new( let mut renderer = cosmic::Renderer::TinySkia(IcedGraphicsRenderer::new(
Backend::new(), Backend::new(),
cosmic::font::DEFAULT, cosmic::font::default(),
Pixels(16.0), Pixels(16.0),
)); ));
let mut debug = Debug::new(); let mut debug = Debug::new();
@ -246,7 +246,7 @@ impl<P: Program + Send + 'static> IcedElement<P> {
let size = size.into(); let size = size.into();
let mut renderer = cosmic::Renderer::TinySkia(IcedGraphicsRenderer::new( let mut renderer = cosmic::Renderer::TinySkia(IcedGraphicsRenderer::new(
Backend::new(), Backend::new(),
cosmic::font::DEFAULT, cosmic::font::default(),
Pixels(16.0), Pixels(16.0),
)); ));
let mut debug = Debug::new(); let mut debug = Debug::new();