fix: opaque menu for overlay
This commit is contained in:
parent
f04437cee5
commit
f5fc392ba4
3 changed files with 21 additions and 7 deletions
|
|
@ -31,7 +31,7 @@ pub trait StyleSheet {
|
|||
type Style: Default;
|
||||
|
||||
/// Produces the [`Appearance`] of a menu bar and its menus.
|
||||
fn appearance(&self, style: &Self::Style) -> Appearance;
|
||||
fn appearance(&self, style: &Self::Style, is_overlay: bool) -> Appearance;
|
||||
}
|
||||
|
||||
/// The style of a menu bar and its menus
|
||||
|
|
@ -54,7 +54,7 @@ impl From<fn(&Theme) -> Appearance> for MenuBarStyle {
|
|||
impl StyleSheet for fn(&Theme) -> Appearance {
|
||||
type Style = Theme;
|
||||
|
||||
fn appearance(&self, style: &Self::Style) -> Appearance {
|
||||
fn appearance(&self, style: &Self::Style, _is_overlay: bool) -> Appearance {
|
||||
(self)(style)
|
||||
}
|
||||
}
|
||||
|
|
@ -62,9 +62,9 @@ impl StyleSheet for fn(&Theme) -> Appearance {
|
|||
impl StyleSheet for Theme {
|
||||
type Style = MenuBarStyle;
|
||||
|
||||
fn appearance(&self, style: &Self::Style) -> Appearance {
|
||||
fn appearance(&self, style: &Self::Style, is_overlay: bool) -> Appearance {
|
||||
let cosmic = self.cosmic();
|
||||
let component = &cosmic.background(self.transparent).component;
|
||||
let component = &cosmic.background(!is_overlay && self.transparent).component;
|
||||
let mut bg = component.base;
|
||||
|
||||
match style {
|
||||
|
|
@ -77,7 +77,7 @@ impl StyleSheet for Theme {
|
|||
background_expand: [1; 4],
|
||||
path: component.hover.into(),
|
||||
},
|
||||
MenuBarStyle::Custom(c) => c.appearance(self),
|
||||
MenuBarStyle::Custom(c) => c.appearance(self, is_overlay),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -715,7 +715,21 @@ where
|
|||
|
||||
// draw path highlight
|
||||
if self.path_highlight.is_some() {
|
||||
let styling = theme.appearance(&self.style);
|
||||
let mut is_overlay = true;
|
||||
#[cfg(all(
|
||||
feature = "multi-window",
|
||||
feature = "wayland",
|
||||
target_os = "linux",
|
||||
feature = "winit",
|
||||
feature = "surface-message"
|
||||
))]
|
||||
if matches!(WINDOWING_SYSTEM.get(), Some(WindowingSystem::Wayland))
|
||||
&& self.on_surface_action.is_some()
|
||||
&& self.window_id != window::Id::NONE
|
||||
{
|
||||
is_overlay = true;
|
||||
};
|
||||
let styling = theme.appearance(&self.style, is_overlay);
|
||||
if let Some(active) = state.active_root.first() {
|
||||
let active_bounds = layout
|
||||
.children()
|
||||
|
|
|
|||
|
|
@ -742,7 +742,7 @@ impl<'b, Message: Clone + 'static> Menu<'b, Message> {
|
|||
Rectangle::new(Point::ORIGIN, Size::INFINITE)
|
||||
};
|
||||
|
||||
let styling = theme.appearance(&self.style);
|
||||
let styling = theme.appearance(&self.style, self.is_overlay);
|
||||
let roots = active_root.iter().skip(1).fold(
|
||||
&self.menu_roots[active_root[0]].children,
|
||||
|mt, next_active_root| &mt[*next_active_root].children,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue