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)
|
Message::Cosmic(cosmic::Message::ToggleNavBarCondensed)
|
||||||
} else {
|
} else {
|
||||||
Message::Cosmic(cosmic::Message::ToggleNavBar)
|
Message::Cosmic(cosmic::Message::ToggleNavBar)
|
||||||
})
|
});
|
||||||
.class(crate::theme::Button::HeaderBar);
|
|
||||||
|
|
||||||
header = header.start(toggle);
|
header = header.start(toggle);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,13 +14,13 @@ use crate::{
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub enum Button {
|
pub enum Button {
|
||||||
AppletIcon,
|
AppletIcon,
|
||||||
|
AppletMenu,
|
||||||
Custom {
|
Custom {
|
||||||
active: Box<dyn Fn(bool, &crate::Theme) -> Style>,
|
active: Box<dyn Fn(bool, &crate::Theme) -> Style>,
|
||||||
disabled: Box<dyn Fn(&crate::Theme) -> Style>,
|
disabled: Box<dyn Fn(&crate::Theme) -> Style>,
|
||||||
hovered: Box<dyn Fn(bool, &crate::Theme) -> Style>,
|
hovered: Box<dyn Fn(bool, &crate::Theme) -> Style>,
|
||||||
pressed: Box<dyn Fn(bool, &crate::Theme) -> Style>,
|
pressed: Box<dyn Fn(bool, &crate::Theme) -> Style>,
|
||||||
},
|
},
|
||||||
AppletMenu,
|
|
||||||
Destructive,
|
Destructive,
|
||||||
HeaderBar,
|
HeaderBar,
|
||||||
Icon,
|
Icon,
|
||||||
|
|
@ -31,6 +31,7 @@ pub enum Button {
|
||||||
MenuFolder,
|
MenuFolder,
|
||||||
MenuItem,
|
MenuItem,
|
||||||
MenuRoot,
|
MenuRoot,
|
||||||
|
NavToggle,
|
||||||
#[default]
|
#[default]
|
||||||
Standard,
|
Standard,
|
||||||
Suggested,
|
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) {
|
if matches!(style, Button::IconVertical) {
|
||||||
corner_radii = &cosmic.corner_radii.radius_m;
|
corner_radii = &cosmic.corner_radii.radius_m;
|
||||||
if selected {
|
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);
|
let (background, text, icon) = color(&cosmic.icon_button);
|
||||||
appearance.background = Some(Background::Color(background));
|
appearance.background = Some(Background::Color(background));
|
||||||
|
|
|
||||||
|
|
@ -528,17 +528,7 @@ impl iced_container::Catalog for Theme {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Container::ContextDrawer => {
|
Container::ContextDrawer => Container::primary(cosmic),
|
||||||
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::Background => Container::background(cosmic),
|
Container::Background => Container::background(cosmic),
|
||||||
|
|
||||||
|
|
@ -546,20 +536,17 @@ impl iced_container::Catalog for Theme {
|
||||||
|
|
||||||
Container::Secondary => Container::secondary(cosmic),
|
Container::Secondary => Container::secondary(cosmic),
|
||||||
|
|
||||||
Container::Dropdown => {
|
Container::Dropdown => iced_container::Style {
|
||||||
let theme = self.cosmic();
|
|
||||||
|
|
||||||
iced_container::Style {
|
|
||||||
icon_color: None,
|
icon_color: None,
|
||||||
text_color: None,
|
text_color: None,
|
||||||
background: Some(iced::Background::Color(theme.primary.base.into())),
|
background: Some(iced::Background::Color(cosmic.bg_component_color().into())),
|
||||||
border: Border {
|
border: Border {
|
||||||
radius: cosmic.corner_radii.radius_xs.into(),
|
color: cosmic.bg_component_divider().into(),
|
||||||
..Default::default()
|
width: 1.0,
|
||||||
|
radius: cosmic.corner_radii.radius_s.into(),
|
||||||
},
|
},
|
||||||
shadow: Shadow::default(),
|
shadow: Shadow::default(),
|
||||||
}
|
},
|
||||||
}
|
|
||||||
|
|
||||||
Container::Tooltip => iced_container::Style {
|
Container::Tooltip => iced_container::Style {
|
||||||
icon_color: None,
|
icon_color: None,
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,8 @@ impl<'a, Message: 'a> Overlay<'a, Message> {
|
||||||
style,
|
style,
|
||||||
} = menu;
|
} = menu;
|
||||||
|
|
||||||
let mut container = Container::new(Scrollable::new(List {
|
let mut container = Container::new(Scrollable::new(
|
||||||
|
Container::new(List {
|
||||||
options,
|
options,
|
||||||
icons,
|
icons,
|
||||||
hovered_option,
|
hovered_option,
|
||||||
|
|
@ -166,10 +167,9 @@ impl<'a, Message: 'a> Overlay<'a, Message> {
|
||||||
text_size,
|
text_size,
|
||||||
text_line_height,
|
text_line_height,
|
||||||
padding,
|
padding,
|
||||||
}));
|
})
|
||||||
|
.padding(padding),
|
||||||
container = container
|
))
|
||||||
.padding(padding)
|
|
||||||
.class(crate::style::Container::Dropdown);
|
.class(crate::style::Container::Dropdown);
|
||||||
|
|
||||||
state.tree.diff(&mut container as &mut dyn Widget<_, _, _>);
|
state.tree.diff(&mut container as &mut dyn Widget<_, _, _>);
|
||||||
|
|
|
||||||
|
|
@ -152,7 +152,8 @@ impl<'a, Message: 'a> Overlay<'a, Message> {
|
||||||
style,
|
style,
|
||||||
} = menu;
|
} = menu;
|
||||||
|
|
||||||
let mut container = Container::new(Scrollable::new(InnerList {
|
let mut container = Container::new(Scrollable::new(
|
||||||
|
Container::new(InnerList {
|
||||||
options,
|
options,
|
||||||
hovered_option,
|
hovered_option,
|
||||||
selected_option,
|
selected_option,
|
||||||
|
|
@ -161,10 +162,9 @@ impl<'a, Message: 'a> Overlay<'a, Message> {
|
||||||
padding,
|
padding,
|
||||||
text_size,
|
text_size,
|
||||||
text_line_height,
|
text_line_height,
|
||||||
}));
|
})
|
||||||
|
.padding(padding),
|
||||||
container = container
|
))
|
||||||
.padding(padding)
|
|
||||||
.class(crate::style::Container::Dropdown);
|
.class(crate::style::Container::Dropdown);
|
||||||
|
|
||||||
state.tree.diff(&mut container as &mut dyn Widget<_, _, _>);
|
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);
|
let mut end = std::mem::take(&mut self.end);
|
||||||
|
|
||||||
// Also packs the window controls at the very 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());
|
end.push(self.window_controls());
|
||||||
|
|
||||||
let height = match self.density.unwrap_or_else(crate::config::header_size) {
|
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 {
|
NavBarToggle {
|
||||||
active: false,
|
active: false,
|
||||||
on_toggle: None,
|
on_toggle: None,
|
||||||
class: crate::theme::Button::Text,
|
class: crate::theme::Button::NavToggle,
|
||||||
selected: false,
|
selected: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue