Merge branch 'master' of https://github.com/Adam-Cosner/libcosmic
This commit is contained in:
commit
8021271524
7 changed files with 49 additions and 60 deletions
|
|
@ -852,8 +852,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),
|
||||
|
||||
|
|
@ -546,20 +536,17 @@ impl iced_container::Catalog for Theme {
|
|||
|
||||
Container::Secondary => Container::secondary(cosmic),
|
||||
|
||||
Container::Dropdown => {
|
||||
let theme = self.cosmic();
|
||||
|
||||
iced_container::Style {
|
||||
icon_color: None,
|
||||
text_color: None,
|
||||
background: Some(iced::Background::Color(theme.primary.base.into())),
|
||||
border: Border {
|
||||
radius: cosmic.corner_radii.radius_xs.into(),
|
||||
..Default::default()
|
||||
},
|
||||
shadow: Shadow::default(),
|
||||
}
|
||||
}
|
||||
Container::Dropdown => iced_container::Style {
|
||||
icon_color: None,
|
||||
text_color: None,
|
||||
background: Some(iced::Background::Color(cosmic.bg_component_color().into())),
|
||||
border: Border {
|
||||
color: cosmic.bg_component_divider().into(),
|
||||
width: 1.0,
|
||||
radius: cosmic.corner_radii.radius_s.into(),
|
||||
},
|
||||
shadow: Shadow::default(),
|
||||
},
|
||||
|
||||
Container::Tooltip => iced_container::Style {
|
||||
icon_color: None,
|
||||
|
|
|
|||
|
|
@ -156,21 +156,21 @@ impl<'a, Message: 'a> Overlay<'a, Message> {
|
|||
style,
|
||||
} = menu;
|
||||
|
||||
let mut container = Container::new(Scrollable::new(List {
|
||||
options,
|
||||
icons,
|
||||
hovered_option,
|
||||
selected_option,
|
||||
on_selected,
|
||||
on_option_hovered,
|
||||
text_size,
|
||||
text_line_height,
|
||||
padding,
|
||||
}));
|
||||
|
||||
container = container
|
||||
.padding(padding)
|
||||
.class(crate::style::Container::Dropdown);
|
||||
let mut container = Container::new(Scrollable::new(
|
||||
Container::new(List {
|
||||
options,
|
||||
icons,
|
||||
hovered_option,
|
||||
selected_option,
|
||||
on_selected,
|
||||
on_option_hovered,
|
||||
text_size,
|
||||
text_line_height,
|
||||
padding,
|
||||
})
|
||||
.padding(padding),
|
||||
))
|
||||
.class(crate::style::Container::Dropdown);
|
||||
|
||||
state.tree.diff(&mut container as &mut dyn Widget<_, _, _>);
|
||||
|
||||
|
|
|
|||
|
|
@ -152,20 +152,20 @@ impl<'a, Message: 'a> Overlay<'a, Message> {
|
|||
style,
|
||||
} = menu;
|
||||
|
||||
let mut container = Container::new(Scrollable::new(InnerList {
|
||||
options,
|
||||
hovered_option,
|
||||
selected_option,
|
||||
on_selected,
|
||||
on_option_hovered,
|
||||
padding,
|
||||
text_size,
|
||||
text_line_height,
|
||||
}));
|
||||
|
||||
container = container
|
||||
.padding(padding)
|
||||
.class(crate::style::Container::Dropdown);
|
||||
let mut container = Container::new(Scrollable::new(
|
||||
Container::new(InnerList {
|
||||
options,
|
||||
hovered_option,
|
||||
selected_option,
|
||||
on_selected,
|
||||
on_option_hovered,
|
||||
padding,
|
||||
text_size,
|
||||
text_line_height,
|
||||
})
|
||||
.padding(padding),
|
||||
))
|
||||
.class(crate::style::Container::Dropdown);
|
||||
|
||||
state.tree.diff(&mut container as &mut dyn Widget<_, _, _>);
|
||||
|
||||
|
|
|
|||
|
|
@ -299,7 +299,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) {
|
||||
|
|
|
|||
|
|
@ -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