Redesigned the tabs and its colors, sizes and positions
This commit is contained in:
1 parent
0f442e84e5
commit
da752bcfd7
2 files changed
+465
-1388
No files matched your search
+389
-1345
File diff suppressed because it is too large.
Load diff
+76
-43
@@ -14,6 +14,15 @@ use iced::{Border, Color, Theme};
|
||||
|
||||
/// Accent red used for destructive/close affordances in both themes.
|
||||
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)]
|
||||
pub enum Preference {
|
||||
@@ -96,20 +105,24 @@ pub(crate) fn config_path() -> Option<PathBuf> {
|
||||
}
|
||||
|
||||
/// Style for the top menubar.
|
||||
pub fn menubar(theme: &Theme) -> container::Style {
|
||||
let palette = theme.extended_palette();
|
||||
|
||||
pub fn menubar(_theme: &Theme) -> container::Style {
|
||||
container::Style {
|
||||
background: Some(palette.background.weak.color.into()),
|
||||
border: Border {
|
||||
color: palette.background.strong.color,
|
||||
width: 1.0,
|
||||
radius: 0.0.into(),
|
||||
},
|
||||
background: Some(TAB_INACTIVE_BG.into()),
|
||||
..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.
|
||||
pub fn menu(theme: &Theme) -> container::Style {
|
||||
let mut style = container::rounded_box(theme);
|
||||
@@ -117,21 +130,51 @@ pub fn menu(theme: &Theme) -> container::Style {
|
||||
style
|
||||
}
|
||||
|
||||
/// Style for a tab in the menubar; active tabs sit on the base surface.
|
||||
pub fn tab(theme: &Theme, active: bool) -> container::Style {
|
||||
let palette = theme.extended_palette();
|
||||
|
||||
/// Style for a tab in the menubar; active tabs sit on the content surface.
|
||||
/// The active outline is drawn separately so it has no bottom edge.
|
||||
pub fn tab(_theme: &Theme, active: bool) -> 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 {
|
||||
color: palette.background.strong.color,
|
||||
width: if active { 1.0 } else { 0.0 },
|
||||
radius: 3.0.into(),
|
||||
color: Color::TRANSPARENT,
|
||||
width: 0.0,
|
||||
radius: Radius {
|
||||
top_left: 3.0,
|
||||
top_right: 3.0,
|
||||
bottom_right: 0.0,
|
||||
bottom_left: 0.0,
|
||||
},
|
||||
},
|
||||
..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.
|
||||
pub fn selected_option(theme: &Theme, _status: button::Status) -> button::Style {
|
||||
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 {
|
||||
button::Style {
|
||||
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.
|
||||
pub fn selectable_row(theme: &Theme, status: button::Status, selected: bool) -> button::Style {
|
||||
if selected {
|
||||
@@ -294,7 +312,7 @@ pub fn settings_frame(theme: &Theme) -> container::Style {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::Preference;
|
||||
use super::{Preference, Theme};
|
||||
|
||||
#[test]
|
||||
fn preference_round_trips_through_text() {
|
||||
@@ -303,4 +321,19 @@ mod tests {
|
||||
}
|
||||
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())
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user