fix(style): use radius_s for nav bar toggle
This commit is contained in:
parent
75a11b3c84
commit
2d06ec4226
5 changed files with 35 additions and 27 deletions
|
|
@ -703,11 +703,14 @@ impl<App: Application> ApplicationExt for App {
|
|||
.focused_window()
|
||||
.is_some_and(|i| Some(i) == self.core().main_window_id());
|
||||
|
||||
// Offset for the window border
|
||||
let window_padding = if sharp_corners { 8 } else { 7 };
|
||||
|
||||
let main_content_padding = if content_container {
|
||||
if nav_bar_active {
|
||||
[0, 8, 8, 0]
|
||||
[0, window_padding, window_padding, 0]
|
||||
} else {
|
||||
[0, 8, 8, 8]
|
||||
[0, window_padding, window_padding, window_padding]
|
||||
}
|
||||
} else {
|
||||
[0, 0, 0, 0]
|
||||
|
|
@ -721,7 +724,11 @@ impl<App: Application> ApplicationExt for App {
|
|||
.nav_bar()
|
||||
.map(|nav| id_container(nav, iced_core::id::Id::new("COSMIC_nav_bar")))
|
||||
{
|
||||
widgets.push(container(nav).padding([0, 8, 8, 8]).into());
|
||||
widgets.push(
|
||||
container(nav)
|
||||
.padding([0, window_padding, window_padding, window_padding])
|
||||
.into(),
|
||||
);
|
||||
true
|
||||
} else {
|
||||
false
|
||||
|
|
@ -753,7 +760,7 @@ impl<App: Application> ApplicationExt for App {
|
|||
})
|
||||
.apply(container)
|
||||
.padding(if content_container {
|
||||
[0, 8, 8, 0]
|
||||
[0, window_padding, window_padding, 0]
|
||||
} else {
|
||||
[0, 0, 0, 0]
|
||||
})
|
||||
|
|
@ -801,7 +808,7 @@ impl<App: Application> ApplicationExt for App {
|
|||
})
|
||||
.apply(container)
|
||||
.padding(if content_container {
|
||||
[0, 8, 8, 0]
|
||||
[0, window_padding, window_padding, 0]
|
||||
} else {
|
||||
[0, 0, 0, 0]
|
||||
})
|
||||
|
|
@ -818,10 +825,14 @@ impl<App: Application> ApplicationExt for App {
|
|||
});
|
||||
let content_col = crate::widget::column::with_capacity(2)
|
||||
.push(content_row)
|
||||
.push_maybe(
|
||||
self.footer()
|
||||
.map(|footer| container(footer.map(Message::App)).padding([0, 8, 8, 8])),
|
||||
);
|
||||
.push_maybe(self.footer().map(|footer| {
|
||||
container(footer.map(Message::App)).padding([
|
||||
0,
|
||||
window_padding,
|
||||
window_padding,
|
||||
window_padding,
|
||||
])
|
||||
}));
|
||||
let content: Element<_> = if core.window.content_container {
|
||||
content_col
|
||||
.apply(container)
|
||||
|
|
@ -840,6 +851,7 @@ impl<App: Application> ApplicationExt for App {
|
|||
let mut header = crate::widget::header_bar()
|
||||
.focused(focused)
|
||||
.title(&core.window.header_title)
|
||||
.horizontal_padding(window_padding)
|
||||
.on_drag(Message::Cosmic(cosmic::Message::Drag))
|
||||
.on_right_click(Message::Cosmic(cosmic::Message::ShowWindowMenu))
|
||||
.on_double_click(Message::Cosmic(cosmic::Message::Maximize));
|
||||
|
|
@ -852,8 +864,7 @@ impl<App: Application> ApplicationExt for App {
|
|||
Message::Cosmic(cosmic::Message::ToggleNavBarCondensed)
|
||||
} else {
|
||||
Message::Cosmic(cosmic::Message::ToggleNavBar)
|
||||
})
|
||||
.class(crate::theme::Button::HeaderBar);
|
||||
});
|
||||
|
||||
header = header.start(toggle);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,13 +14,13 @@ use crate::{
|
|||
#[derive(Default)]
|
||||
pub enum Button {
|
||||
AppletIcon,
|
||||
AppletMenu,
|
||||
Custom {
|
||||
active: Box<dyn Fn(bool, &crate::Theme) -> Style>,
|
||||
disabled: Box<dyn Fn(&crate::Theme) -> Style>,
|
||||
hovered: Box<dyn Fn(bool, &crate::Theme) -> Style>,
|
||||
pressed: Box<dyn Fn(bool, &crate::Theme) -> Style>,
|
||||
},
|
||||
AppletMenu,
|
||||
Destructive,
|
||||
HeaderBar,
|
||||
Icon,
|
||||
|
|
@ -31,6 +31,7 @@ pub enum Button {
|
|||
MenuFolder,
|
||||
MenuItem,
|
||||
MenuRoot,
|
||||
NavToggle,
|
||||
#[default]
|
||||
Standard,
|
||||
Suggested,
|
||||
|
|
@ -73,7 +74,7 @@ pub fn appearance(
|
|||
}
|
||||
}
|
||||
|
||||
Button::Icon | Button::IconVertical | Button::HeaderBar => {
|
||||
Button::Icon | Button::IconVertical | Button::HeaderBar | Button::NavToggle => {
|
||||
if matches!(style, Button::IconVertical) {
|
||||
corner_radii = &cosmic.corner_radii.radius_m;
|
||||
if selected {
|
||||
|
|
@ -82,6 +83,9 @@ pub fn appearance(
|
|||
)));
|
||||
}
|
||||
}
|
||||
if matches!(style, Button::NavToggle) {
|
||||
corner_radii = &cosmic.corner_radii.radius_s;
|
||||
}
|
||||
|
||||
let (background, text, icon) = color(&cosmic.icon_button);
|
||||
appearance.background = Some(Background::Color(background));
|
||||
|
|
|
|||
|
|
@ -528,17 +528,7 @@ impl iced_container::Catalog for Theme {
|
|||
}
|
||||
}
|
||||
|
||||
Container::ContextDrawer => {
|
||||
let mut appearance = Container::primary(cosmic);
|
||||
|
||||
appearance.shadow = Shadow {
|
||||
color: cosmic.shade.into(),
|
||||
offset: Vector::new(0.0, 0.0),
|
||||
blur_radius: 16.0,
|
||||
};
|
||||
|
||||
appearance
|
||||
}
|
||||
Container::ContextDrawer => Container::primary(cosmic),
|
||||
|
||||
Container::Background => Container::background(cosmic),
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ pub fn header_bar<'a, Message>() -> HeaderBar<'a, Message> {
|
|||
center: Vec::new(),
|
||||
end: Vec::new(),
|
||||
density: None,
|
||||
horizontal_padding: 8,
|
||||
focused: false,
|
||||
on_double_click: None,
|
||||
}
|
||||
|
|
@ -74,6 +75,9 @@ pub struct HeaderBar<'a, Message> {
|
|||
#[setters(strip_option)]
|
||||
density: Option<Density>,
|
||||
|
||||
/// Horizontal padding of the headerbar
|
||||
horizontal_padding: u16,
|
||||
|
||||
/// Focused state of the window
|
||||
focused: bool,
|
||||
}
|
||||
|
|
@ -299,7 +303,6 @@ impl<'a, Message: Clone + 'static> HeaderBar<'a, Message> {
|
|||
let mut end = std::mem::take(&mut self.end);
|
||||
|
||||
// Also packs the window controls at the very end.
|
||||
end.push(widget::horizontal_space().width(Length::Fixed(12.0)).into());
|
||||
end.push(self.window_controls());
|
||||
|
||||
let height = match self.density.unwrap_or_else(crate::config::header_size) {
|
||||
|
|
@ -343,7 +346,7 @@ impl<'a, Message: Clone + 'static> HeaderBar<'a, Message> {
|
|||
)
|
||||
.align_y(iced::Alignment::Center)
|
||||
.height(Length::Fixed(height))
|
||||
.padding([0, 8])
|
||||
.padding([0, self.horizontal_padding])
|
||||
.spacing(8)
|
||||
.apply(widget::container)
|
||||
.class(crate::theme::Container::HeaderBar {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ pub fn nav_bar_toggle<Message>() -> NavBarToggle<Message> {
|
|||
NavBarToggle {
|
||||
active: false,
|
||||
on_toggle: None,
|
||||
class: crate::theme::Button::Text,
|
||||
class: crate::theme::Button::NavToggle,
|
||||
selected: false,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue