Skip to content

Commit

Permalink
fix(header_bar): increase compact height
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
git-f0x authored and mmstick committed Oct 3, 2024
1 parent 228eb4d commit e645dee
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 29 deletions.
4 changes: 4 additions & 0 deletions cosmic-theme/src/model/density.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
use crate::Spacing;
use serde::{Deserialize, Serialize};

/// Density options for the Cosmic theme
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
pub enum Density {
/// Lower padding/spacing of elements
Compact,
/// Higher padding/spacing of elements
Spacious,
/// Standard padding/spacing of elements
#[default]
Standard,
}
Expand Down
10 changes: 10 additions & 0 deletions res/icons/navbar-closed-symbolic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions res/icons/navbar-open-symbolic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/app/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use std::collections::HashMap;

use crate::{config::CosmicTk, widget::nav_bar};
use crate::widget::nav_bar;
use cosmic_config::CosmicConfigEntry;
use cosmic_theme::ThemeMode;
use iced::window;
Expand Down
9 changes: 1 addition & 8 deletions src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ pub mod message {
pub use self::command::Command;
pub use self::core::Core;
pub use self::settings::Settings;
use crate::config::interface_density;
use crate::cosmic_theme::Density;
use crate::prelude::*;
use crate::theme::THEME;
use crate::widget::{context_drawer, horizontal_space, id_container, menu, nav_bar, popover};
Expand Down Expand Up @@ -654,11 +652,6 @@ impl<App: Application> ApplicationExt for App {
.focused_window()
.is_some_and(|i| i == self.main_window_id());

let padding = match interface_density() {
Density::Compact => 2,
_ => 8,
};

let content_row = crate::widget::row::with_children({
let mut widgets = Vec::with_capacity(4);

Expand Down Expand Up @@ -739,7 +732,7 @@ impl<App: Application> ApplicationExt for App {
let content: Element<_> = if core.window.content_container {
content_row
.apply(crate::widget::container)
.padding([0, padding, padding, padding])
.padding([0, 8, 8, 8])
.width(iced::Length::Fill)
.height(iced::Length::Fill)
.style(crate::theme::Container::WindowBackground)
Expand Down
21 changes: 7 additions & 14 deletions src/widget/header_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,10 @@ impl<'a, Message: Clone + 'static> HeaderBar<'a, Message> {
end.push(widget::horizontal_space(Length::Fixed(12.0)).into());
end.push(self.window_controls());

let (height, padding) = match self.density.unwrap_or_else(crate::config::header_size) {
Density::Compact => (36.0, 2.0),
Density::Spacious => (48.0, 8.0),
Density::Standard => (48.0, 8.0),
let height = match self.density.unwrap_or_else(crate::config::header_size) {
Density::Compact => 40.0,
Density::Spacious => 48.0,
Density::Standard => 48.0,
};

// Creates the headerbar widget.
Expand Down Expand Up @@ -316,8 +316,8 @@ impl<'a, Message: Clone + 'static> HeaderBar<'a, Message> {
)
.align_items(iced::Alignment::Center)
.height(Length::Fixed(height))
.padding(padding)
.spacing(padding)
.padding([0, 8])
.spacing(8)
.apply(widget::container)
.style(crate::theme::Container::HeaderBar {
focused: self.focused,
Expand Down Expand Up @@ -387,13 +387,6 @@ impl<'a, Message: Clone + 'static> HeaderBar<'a, Message> {
}};
}

let density = self.density.unwrap_or_else(crate::config::header_size);
let spacing = if matches!(density, Density::Compact) {
2
} else {
8
};

widget::row::with_capacity(3)
.push_maybe(
self.on_minimize
Expand All @@ -410,7 +403,7 @@ impl<'a, Message: Clone + 'static> HeaderBar<'a, Message> {
.take()
.map(|m| icon!("window-close-symbolic", 16, m)),
)
.spacing(spacing)
.spacing(8)
.apply(widget::container)
.height(Length::Fill)
.center_y()
Expand Down
4 changes: 2 additions & 2 deletions src/widget/nav_bar_toggle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ impl<'a, Message: 'static + Clone> From<NavBarToggle<Message>> for Element<'a, M
fn from(nav_bar_toggle: NavBarToggle<Message>) -> Self {
let icon = if nav_bar_toggle.active {
widget::icon::from_svg_bytes(
&include_bytes!("../../res/icons/close-menu-symbolic.svg")[..],
&include_bytes!("../../res/icons/navbar-open-symbolic.svg")[..],
)
.symbolic(true)
} else {
widget::icon::from_svg_bytes(
&include_bytes!("../../res/icons/open-menu-symbolic.svg")[..],
&include_bytes!("../../res/icons/navbar-closed-symbolic.svg")[..],
)
.symbolic(true)
};
Expand Down
8 changes: 4 additions & 4 deletions src/widget/text_input/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ where
let spacing = THEME.lock().unwrap().cosmic().space_xxs();

TextInput::new(placeholder, value)
.padding([0, spacing, 0, spacing])
.padding([0, spacing])
.style(crate::theme::TextInput::Search)
.leading_icon(
crate::widget::icon::from_name("system-search-symbolic")
Expand All @@ -125,7 +125,7 @@ where
{
let spacing = THEME.lock().unwrap().cosmic().space_xxs();
let mut input = TextInput::new(placeholder, value)
.padding([0, spacing, 0, spacing])
.padding([0, spacing])
.style(crate::theme::TextInput::Default)
.leading_icon(
crate::widget::icon::from_name("system-lock-screen-symbolic")
Expand Down Expand Up @@ -170,7 +170,7 @@ where

TextInput::new(placeholder, value)
.style(crate::theme::TextInput::Inline)
.padding([spacing, spacing, spacing, spacing])
.padding(spacing)
}

#[cfg(feature = "wayland")]
Expand Down Expand Up @@ -246,7 +246,7 @@ where
select_on_focus: false,
font: None,
width: Length::Fill,
padding: [spacing, spacing, spacing, spacing].into(),
padding: spacing.into(),
size: None,
helper_size: 10.0,
helper_line_height: text::LineHeight::Absolute(14.0.into()),
Expand Down

0 comments on commit e645dee

Please sign in to comment.