fix: sharp corners & window state handling
This commit is contained in:
parent
27f591e5aa
commit
03f07d2f1e
5 changed files with 56 additions and 9 deletions
2
iced
2
iced
|
|
@ -1 +1 @@
|
|||
Subproject commit 788be2f7825b648ec3ce33697c6e675a7b7265ec
|
||||
Subproject commit f581f19f897e1ccc4393c8867d4ae3ed532742b4
|
||||
|
|
@ -426,6 +426,12 @@ where
|
|||
) => {
|
||||
return Some(Action::SuggestedBounds(b));
|
||||
}
|
||||
#[cfg(feature = "wayland")]
|
||||
wayland::Event::Window(iced::event::wayland::WindowEvent::WindowState(
|
||||
s,
|
||||
)) => {
|
||||
return Some(Action::WindowState(id, s));
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
|
@ -588,6 +594,7 @@ impl<T: Application> Cosmic<T> {
|
|||
fn cosmic_update(&mut self, message: Action) -> iced::Task<crate::Action<T::Message>> {
|
||||
match message {
|
||||
Action::WindowMaximized(id, maximized) => {
|
||||
#[cfg(not(feature = "wayland"))]
|
||||
if self
|
||||
.app
|
||||
.core()
|
||||
|
|
@ -635,6 +642,24 @@ impl<T: Application> Cosmic<T> {
|
|||
| WindowState::TILED_BOTTOM,
|
||||
);
|
||||
}
|
||||
if self.app.core().sync_window_border_radii_to_theme() {
|
||||
use iced_runtime::platform_specific::wayland::CornerRadius;
|
||||
use iced_winit::platform_specific::commands::corner_radius::corner_radius;
|
||||
|
||||
let theme = THEME.lock().unwrap();
|
||||
let t = theme.cosmic();
|
||||
let radii = t.radius_s().map(|x| if x < 4.0 { x } else { x + 4.0 });
|
||||
let cur_rad = CornerRadius {
|
||||
top_left: radii[0].round() as u32,
|
||||
top_right: radii[1].round() as u32,
|
||||
bottom_right: radii[2].round() as u32,
|
||||
bottom_left: radii[3].round() as u32,
|
||||
};
|
||||
let rounded = !self.app.core().window.sharp_corners;
|
||||
return Task::batch(vec![
|
||||
corner_radius(id, rounded.then_some(cur_rad)).discard(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "wayland")]
|
||||
|
|
|
|||
|
|
@ -759,16 +759,25 @@ impl<App: Application> ApplicationExt for App {
|
|||
header
|
||||
.apply(container)
|
||||
.class(crate::theme::Container::custom(move |theme| {
|
||||
let cosmic = theme.cosmic();
|
||||
container::Style {
|
||||
background: Some(iced::Background::Color(
|
||||
theme.cosmic().background.base.into(),
|
||||
cosmic.background.base.into(),
|
||||
)),
|
||||
border: iced::Border {
|
||||
radius: [
|
||||
window_corner_radius[0] - 1.0,
|
||||
window_corner_radius[1] - 1.0,
|
||||
theme.cosmic().radius_0()[2],
|
||||
theme.cosmic().radius_0()[3],
|
||||
if sharp_corners {
|
||||
cosmic.radius_0()[0]
|
||||
} else {
|
||||
window_corner_radius[0] - 1.0
|
||||
},
|
||||
if sharp_corners {
|
||||
cosmic.radius_0()[1]
|
||||
} else {
|
||||
window_corner_radius[1] - 1.0
|
||||
},
|
||||
cosmic.radius_0()[2],
|
||||
cosmic.radius_0()[3],
|
||||
]
|
||||
.into(),
|
||||
..Default::default()
|
||||
|
|
|
|||
|
|
@ -395,6 +395,7 @@ pub enum Container<'a> {
|
|||
Dropdown,
|
||||
HeaderBar {
|
||||
focused: bool,
|
||||
sharp_corners: bool,
|
||||
},
|
||||
List,
|
||||
Primary,
|
||||
|
|
@ -507,7 +508,10 @@ impl iced_container::Catalog for Theme {
|
|||
}
|
||||
}
|
||||
|
||||
Container::HeaderBar { focused } => {
|
||||
Container::HeaderBar {
|
||||
focused,
|
||||
sharp_corners,
|
||||
} => {
|
||||
let (icon_color, text_color) = if *focused {
|
||||
(
|
||||
Color::from(cosmic.accent_text_color()),
|
||||
|
|
@ -526,8 +530,16 @@ impl iced_container::Catalog for Theme {
|
|||
background: Some(iced::Background::Color(cosmic.background.base.into())),
|
||||
border: Border {
|
||||
radius: [
|
||||
window_corner_radius[0],
|
||||
window_corner_radius[1],
|
||||
if *sharp_corners {
|
||||
cosmic.corner_radii.radius_0[0]
|
||||
} else {
|
||||
window_corner_radius[0]
|
||||
},
|
||||
if *sharp_corners {
|
||||
cosmic.corner_radii.radius_0[1]
|
||||
} else {
|
||||
window_corner_radius[1]
|
||||
},
|
||||
cosmic.corner_radii.radius_0[2],
|
||||
cosmic.corner_radii.radius_0[3],
|
||||
]
|
||||
|
|
|
|||
|
|
@ -409,6 +409,7 @@ impl<'a, Message: Clone + 'static> HeaderBar<'a, Message> {
|
|||
.apply(widget::container)
|
||||
.class(crate::theme::Container::HeaderBar {
|
||||
focused: self.focused,
|
||||
sharp_corners: self.maximized,
|
||||
})
|
||||
.center_y(Length::Shrink)
|
||||
.apply(widget::mouse_area);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue