Skip to content

Commit e645dee

Browse files
git-f0xmmstick
authored andcommitted
fix(header_bar): increase compact height
Increases Compact header height to 40 (from 36), to better accommodate larger widgets (e.g. the search bar). This makes it distinct from the SSD header, which is now addressed by the `_` match case. Also makes the horizontal header padding fixed at 8, so that the app window padding can also be 8.
1 parent 228eb4d commit e645dee

File tree

8 files changed

+37
-29
lines changed

8 files changed

+37
-29
lines changed

cosmic-theme/src/model/density.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
use crate::Spacing;
22
use serde::{Deserialize, Serialize};
33

4+
/// Density options for the Cosmic theme
45
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
56
pub enum Density {
7+
/// Lower padding/spacing of elements
68
Compact,
9+
/// Higher padding/spacing of elements
710
Spacious,
11+
/// Standard padding/spacing of elements
812
#[default]
913
Standard,
1014
}
Lines changed: 10 additions & 0 deletions
Loading

res/icons/navbar-open-symbolic.svg

Lines changed: 8 additions & 0 deletions
Loading

src/app/core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
use std::collections::HashMap;
55

6-
use crate::{config::CosmicTk, widget::nav_bar};
6+
use crate::widget::nav_bar;
77
use cosmic_config::CosmicConfigEntry;
88
use cosmic_theme::ThemeMode;
99
use iced::window;

src/app/mod.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ pub mod message {
4848
pub use self::command::Command;
4949
pub use self::core::Core;
5050
pub use self::settings::Settings;
51-
use crate::config::interface_density;
52-
use crate::cosmic_theme::Density;
5351
use crate::prelude::*;
5452
use crate::theme::THEME;
5553
use crate::widget::{context_drawer, horizontal_space, id_container, menu, nav_bar, popover};
@@ -654,11 +652,6 @@ impl<App: Application> ApplicationExt for App {
654652
.focused_window()
655653
.is_some_and(|i| i == self.main_window_id());
656654

657-
let padding = match interface_density() {
658-
Density::Compact => 2,
659-
_ => 8,
660-
};
661-
662655
let content_row = crate::widget::row::with_children({
663656
let mut widgets = Vec::with_capacity(4);
664657

@@ -739,7 +732,7 @@ impl<App: Application> ApplicationExt for App {
739732
let content: Element<_> = if core.window.content_container {
740733
content_row
741734
.apply(crate::widget::container)
742-
.padding([0, padding, padding, padding])
735+
.padding([0, 8, 8, 8])
743736
.width(iced::Length::Fill)
744737
.height(iced::Length::Fill)
745738
.style(crate::theme::Container::WindowBackground)

src/widget/header_bar.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -277,10 +277,10 @@ impl<'a, Message: Clone + 'static> HeaderBar<'a, Message> {
277277
end.push(widget::horizontal_space(Length::Fixed(12.0)).into());
278278
end.push(self.window_controls());
279279

280-
let (height, padding) = match self.density.unwrap_or_else(crate::config::header_size) {
281-
Density::Compact => (36.0, 2.0),
282-
Density::Spacious => (48.0, 8.0),
283-
Density::Standard => (48.0, 8.0),
280+
let height = match self.density.unwrap_or_else(crate::config::header_size) {
281+
Density::Compact => 40.0,
282+
Density::Spacious => 48.0,
283+
Density::Standard => 48.0,
284284
};
285285

286286
// Creates the headerbar widget.
@@ -316,8 +316,8 @@ impl<'a, Message: Clone + 'static> HeaderBar<'a, Message> {
316316
)
317317
.align_items(iced::Alignment::Center)
318318
.height(Length::Fixed(height))
319-
.padding(padding)
320-
.spacing(padding)
319+
.padding([0, 8])
320+
.spacing(8)
321321
.apply(widget::container)
322322
.style(crate::theme::Container::HeaderBar {
323323
focused: self.focused,
@@ -387,13 +387,6 @@ impl<'a, Message: Clone + 'static> HeaderBar<'a, Message> {
387387
}};
388388
}
389389

390-
let density = self.density.unwrap_or_else(crate::config::header_size);
391-
let spacing = if matches!(density, Density::Compact) {
392-
2
393-
} else {
394-
8
395-
};
396-
397390
widget::row::with_capacity(3)
398391
.push_maybe(
399392
self.on_minimize
@@ -410,7 +403,7 @@ impl<'a, Message: Clone + 'static> HeaderBar<'a, Message> {
410403
.take()
411404
.map(|m| icon!("window-close-symbolic", 16, m)),
412405
)
413-
.spacing(spacing)
406+
.spacing(8)
414407
.apply(widget::container)
415408
.height(Length::Fill)
416409
.center_y()

src/widget/nav_bar_toggle.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ impl<'a, Message: 'static + Clone> From<NavBarToggle<Message>> for Element<'a, M
2929
fn from(nav_bar_toggle: NavBarToggle<Message>) -> Self {
3030
let icon = if nav_bar_toggle.active {
3131
widget::icon::from_svg_bytes(
32-
&include_bytes!("../../res/icons/close-menu-symbolic.svg")[..],
32+
&include_bytes!("../../res/icons/navbar-open-symbolic.svg")[..],
3333
)
3434
.symbolic(true)
3535
} else {
3636
widget::icon::from_svg_bytes(
37-
&include_bytes!("../../res/icons/open-menu-symbolic.svg")[..],
37+
&include_bytes!("../../res/icons/navbar-closed-symbolic.svg")[..],
3838
)
3939
.symbolic(true)
4040
};

src/widget/text_input/input.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ where
101101
let spacing = THEME.lock().unwrap().cosmic().space_xxs();
102102

103103
TextInput::new(placeholder, value)
104-
.padding([0, spacing, 0, spacing])
104+
.padding([0, spacing])
105105
.style(crate::theme::TextInput::Search)
106106
.leading_icon(
107107
crate::widget::icon::from_name("system-search-symbolic")
@@ -125,7 +125,7 @@ where
125125
{
126126
let spacing = THEME.lock().unwrap().cosmic().space_xxs();
127127
let mut input = TextInput::new(placeholder, value)
128-
.padding([0, spacing, 0, spacing])
128+
.padding([0, spacing])
129129
.style(crate::theme::TextInput::Default)
130130
.leading_icon(
131131
crate::widget::icon::from_name("system-lock-screen-symbolic")
@@ -170,7 +170,7 @@ where
170170

171171
TextInput::new(placeholder, value)
172172
.style(crate::theme::TextInput::Inline)
173-
.padding([spacing, spacing, spacing, spacing])
173+
.padding(spacing)
174174
}
175175

176176
#[cfg(feature = "wayland")]
@@ -246,7 +246,7 @@ where
246246
select_on_focus: false,
247247
font: None,
248248
width: Length::Fill,
249-
padding: [spacing, spacing, spacing, spacing].into(),
249+
padding: spacing.into(),
250250
size: None,
251251
helper_size: 10.0,
252252
helper_line_height: text::LineHeight::Absolute(14.0.into()),

0 commit comments

Comments
 (0)