Fix context drawer when it is an overlay

This commit is contained in:
Jeremy Soller 2024-09-21 07:47:37 -06:00
parent ddb678ca69
commit 7d7c6fa71a
No known key found for this signature in database
GPG key ID: D02FD439211AF56F

View file

@ -669,21 +669,41 @@ impl<App: Application> ApplicationExt for App {
widgets.push(horizontal_space(Length::Fixed(8.0)).into()); widgets.push(horizontal_space(Length::Fixed(8.0)).into());
} }
widgets.push(self.view().map(Message::App)); let main_content = self.view().map(Message::App);
//TODO: reduce duplication
if core.window.context_is_overlay {
if let Some(context) = self.context_drawer() {
widgets.push(
context_drawer(
&core.window.context_title,
Message::Cosmic(cosmic::Message::ContextDrawer(false)),
main_content,
context.map(Message::App),
)
.apply(|drawer| {
Element::from(id_container(
drawer,
iced_core::id::Id::new("COSMIC_context_drawer"),
))
}),
);
} else {
widgets.push(main_content);
}
} else {
widgets.push(main_content);
if let Some(context) = self.context_drawer() { if let Some(context) = self.context_drawer() {
widgets.push( widgets.push(
context_drawer( context_drawer(
&core.window.context_title, &core.window.context_title,
Message::Cosmic(cosmic::Message::ContextDrawer(false)), Message::Cosmic(cosmic::Message::ContextDrawer(false)),
//TODO: this is a hack to allow toggling overlay //TODO: this is a hack to allow toggling overlay
horizontal_space(if core.window.context_is_overlay { horizontal_space(
Length::Shrink
} else {
//TODO: this width must be synced with the context drawer width //TODO: this width must be synced with the context drawer width
// Manual spacing must be used due to state workarounds below // Manual spacing must be used due to state workarounds below
Length::Fixed(480.0 + 8.0) Length::Fixed(480.0 + 8.0),
}), ),
context.map(Message::App), context.map(Message::App),
) )
.apply(|drawer| { .apply(|drawer| {
@ -698,6 +718,7 @@ impl<App: Application> ApplicationExt for App {
widgets.push(horizontal_space(Length::Shrink).into()); widgets.push(horizontal_space(Length::Shrink).into());
} }
} }
}
widgets widgets
}); });