Redesigned the tabs and its colors, sizes and positions
Moorly CI / linux-build (push) Successful in 3m30s
Moorly CI / windows-build (push) Successful in 6m57s

This commit is contained in:
Squid committed 2026-11-06 20:15:07 +01:00
1 parent 0f442e84e5
commit da752bcfd7
2 files changed
+465 -1388

No files matched your search

+389 -1345
View File
File diff suppressed because it is too large. Load diff
+76 -43
View File
@@ -14,6 +14,15 @@ use iced::{Border, Color, Theme};
/// Accent red used for destructive/close affordances in both themes. /// Accent red used for destructive/close affordances in both themes.
pub const DANGER: Color = Color::from_rgb8(0xff, 0x3b, 0x30); pub const DANGER: Color = Color::from_rgb8(0xff, 0x3b, 0x30);
/// Accent blue used for the active tab outline.
pub const ACTIVE_TAB: Color = Color::from_rgb8(0x60, 0x82, 0xB6);
/// Highlight for the selected settings section.
pub const SETTINGS_ACTIVE: Color = Color::from_rgb8(0x5D, 0x3F, 0xD3);
/// Tab bar surfaces: the active tab merges with the content area below.
pub const TAB_ACTIVE_BG: Color = Color::from_rgb8(0x19, 0x19, 0x19);
pub const TAB_INACTIVE_BG: Color = Color::from_rgb8(0x13, 0x13, 0x13);
/// Text and icons drawn on the dark tab bar.
pub const TAB_TEXT: Color = Color::from_rgb8(0xe6, 0xe6, 0xe6);
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)] #[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub enum Preference { pub enum Preference {
@@ -96,20 +105,24 @@ pub(crate) fn config_path() -> Option<PathBuf> {
} }
/// Style for the top menubar. /// Style for the top menubar.
pub fn menubar(theme: &Theme) -> container::Style { pub fn menubar(_theme: &Theme) -> container::Style {
let palette = theme.extended_palette();
container::Style { container::Style {
background: Some(palette.background.weak.color.into()), background: Some(TAB_INACTIVE_BG.into()),
border: Border {
color: palette.background.strong.color,
width: 1.0,
radius: 0.0.into(),
},
..container::Style::default() ..container::Style::default()
} }
} }
/// Style for buttons that sit directly on the dark menubar.
pub fn menubar_button(theme: &Theme, status: button::Status) -> button::Style {
let mut style = button::text(theme, status);
style.text_color = if matches!(status, button::Status::Disabled) {
TAB_TEXT.scale_alpha(0.4)
} else {
TAB_TEXT
};
style
}
/// Style for dropdown menu panels. /// Style for dropdown menu panels.
pub fn menu(theme: &Theme) -> container::Style { pub fn menu(theme: &Theme) -> container::Style {
let mut style = container::rounded_box(theme); let mut style = container::rounded_box(theme);
@@ -117,21 +130,51 @@ pub fn menu(theme: &Theme) -> container::Style {
style style
} }
/// Style for a tab in the menubar; active tabs sit on the base surface. /// Style for a tab in the menubar; active tabs sit on the content surface.
pub fn tab(theme: &Theme, active: bool) -> container::Style { /// The active outline is drawn separately so it has no bottom edge.
let palette = theme.extended_palette(); pub fn tab(_theme: &Theme, active: bool) -> container::Style {
container::Style { container::Style {
background: active.then(|| palette.background.base.color.into()), background: Some(if active {
TAB_ACTIVE_BG.into()
} else {
TAB_INACTIVE_BG.into()
}),
border: Border { border: Border {
color: palette.background.strong.color, color: Color::TRANSPARENT,
width: if active { 1.0 } else { 0.0 }, width: 0.0,
radius: 3.0.into(), radius: Radius {
top_left: 3.0,
top_right: 3.0,
bottom_right: 0.0,
bottom_left: 0.0,
},
}, },
..container::Style::default() ..container::Style::default()
} }
} }
/// Style for the active tab's thin top/left/right outline.
pub fn tab_outline(_theme: &Theme) -> container::Style {
container::Style {
background: Some(ACTIVE_TAB.into()),
..container::Style::default()
}
}
/// Style for the selected settings section in the settings menu.
pub fn settings_active(_theme: &Theme, _status: button::Status) -> button::Style {
button::Style {
background: Some(SETTINGS_ACTIVE.into()),
text_color: Color::WHITE,
border: Border {
color: SETTINGS_ACTIVE,
width: 1.0,
radius: 4.0.into(),
},
..button::Style::default()
}
}
/// Style for the currently selected option in a group of choice buttons. /// Style for the currently selected option in a group of choice buttons.
pub fn selected_option(theme: &Theme, _status: button::Status) -> button::Style { pub fn selected_option(theme: &Theme, _status: button::Status) -> button::Style {
let palette = theme.extended_palette(); let palette = theme.extended_palette();
@@ -172,15 +215,6 @@ pub fn positive_option(theme: &Theme, status: button::Status) -> button::Style {
}) })
} }
/// Style for a destructive/cancelling action button (red).
pub fn danger_option(theme: &Theme, status: button::Status) -> button::Style {
let danger = theme.extended_palette().danger;
filled_option(match status {
button::Status::Hovered | button::Status::Pressed => danger.strong,
_ => danger.base,
})
}
fn filled_option(pair: iced::theme::palette::Pair) -> button::Style { fn filled_option(pair: iced::theme::palette::Pair) -> button::Style {
button::Style { button::Style {
background: Some(pair.color.into()), background: Some(pair.color.into()),
@@ -194,22 +228,6 @@ fn filled_option(pair: iced::theme::palette::Pair) -> button::Style {
} }
} }
/// Style for the password eye button while the password is revealed.
pub fn revealed_eye(theme: &Theme, status: button::Status) -> button::Style {
let palette = theme.extended_palette();
button::Style {
background: None,
text_color: palette.background.base.text,
border: Border {
color: palette.primary.base.color,
width: 1.0,
radius: 4.0.into(),
},
..button::text(theme, status)
}
}
/// Style for a selectable list row; the selected one gets a tinted background. /// Style for a selectable list row; the selected one gets a tinted background.
pub fn selectable_row(theme: &Theme, status: button::Status, selected: bool) -> button::Style { pub fn selectable_row(theme: &Theme, status: button::Status, selected: bool) -> button::Style {
if selected { if selected {
@@ -294,7 +312,7 @@ pub fn settings_frame(theme: &Theme) -> container::Style {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::Preference; use super::{Preference, Theme};
#[test] #[test]
fn preference_round_trips_through_text() { fn preference_round_trips_through_text() {
@@ -303,4 +321,19 @@ mod tests {
} }
assert_eq!(Preference::parse("unknown"), None); assert_eq!(Preference::parse("unknown"), None);
} }
#[test]
fn active_tabs_are_visually_distinct() {
let theme = Theme::Light;
let active = super::tab(&theme, true);
let inactive = super::tab(&theme, false);
assert_ne!(active.background, inactive.background);
assert_eq!(active.border.width, 0.0);
assert_eq!(inactive.border.width, 0.0);
assert_eq!(
super::tab_outline(&theme).background,
Some(super::ACTIVE_TAB.into())
);
}
} }