fix: corner radius setting match style
This commit is contained in:
parent
94d2c18a23
commit
46c717fd57
4 changed files with 80 additions and 14 deletions
|
|
@ -82,7 +82,9 @@ impl<Message: Clone + 'static> ContextMenu<'_, Message> {
|
|||
) {
|
||||
if self.window_id != window::Id::NONE && self.on_surface_action.is_some() {
|
||||
use crate::surface::action::{LiveSettings, destroy_popup};
|
||||
use crate::widget::menu::Menu;
|
||||
use crate::theme::THEME;
|
||||
use crate::widget::menu::{Menu, StyleSheet as _};
|
||||
use iced_runtime::platform_specific::wayland::CornerRadius;
|
||||
use iced_runtime::platform_specific::wayland::popup::{
|
||||
SctkPopupSettings, SctkPositioner,
|
||||
};
|
||||
|
|
@ -185,9 +187,22 @@ impl<Message: Clone + 'static> ContextMenu<'_, Message> {
|
|||
..Default::default()
|
||||
};
|
||||
let parent = self.window_id;
|
||||
let t = THEME.lock().unwrap();
|
||||
let styling = t.appearance(&crate::theme::menu_bar::MenuBarStyle::Default, false);
|
||||
drop(t);
|
||||
let rad = styling.menu_border_radius;
|
||||
|
||||
shell.publish((self.on_surface_action.as_ref().unwrap())(
|
||||
crate::surface::action::simple_popup(
|
||||
|| LiveSettings::default(),
|
||||
move || LiveSettings {
|
||||
corners: Some(CornerRadius {
|
||||
top_left: rad[0] as u32,
|
||||
top_right: rad[1] as u32,
|
||||
bottom_left: rad[2] as u32,
|
||||
bottom_right: rad[3] as u32,
|
||||
}),
|
||||
..Default::default()
|
||||
},
|
||||
move || SctkPopupSettings {
|
||||
parent,
|
||||
id,
|
||||
|
|
|
|||
|
|
@ -385,9 +385,13 @@ where
|
|||
my_state: &mut MenuBarState,
|
||||
) {
|
||||
if self.window_id != window::Id::NONE && self.on_surface_action.is_some() {
|
||||
use crate::surface::action::{LiveSettings, destroy_popup};
|
||||
use iced_runtime::platform_specific::wayland::popup::{
|
||||
SctkPopupSettings, SctkPositioner,
|
||||
use crate::{
|
||||
surface::action::{LiveSettings, destroy_popup},
|
||||
theme::THEME,
|
||||
};
|
||||
use iced_runtime::platform_specific::wayland::{
|
||||
CornerRadius,
|
||||
popup::{SctkPopupSettings, SctkPositioner},
|
||||
};
|
||||
|
||||
let surface_action = self.on_surface_action.as_ref().unwrap();
|
||||
|
|
@ -500,8 +504,22 @@ where
|
|||
..Default::default()
|
||||
};
|
||||
let parent = self.window_id;
|
||||
|
||||
let t = THEME.lock().unwrap();
|
||||
let styling = t.appearance(&crate::theme::menu_bar::MenuBarStyle::Default, false);
|
||||
drop(t);
|
||||
let rad = styling.menu_border_radius;
|
||||
|
||||
shell.publish((surface_action)(crate::surface::action::simple_popup(
|
||||
|| LiveSettings::default(),
|
||||
move || LiveSettings {
|
||||
corners: Some(CornerRadius {
|
||||
top_left: rad[0] as u32,
|
||||
top_right: rad[1] as u32,
|
||||
bottom_left: rad[2] as u32,
|
||||
bottom_right: rad[3] as u32,
|
||||
}),
|
||||
..Default::default()
|
||||
},
|
||||
move || SctkPopupSettings {
|
||||
parent,
|
||||
id,
|
||||
|
|
|
|||
|
|
@ -986,11 +986,12 @@ impl<Message: std::clone::Clone + 'static> Widget<Message, crate::Theme, crate::
|
|||
if matches!(WINDOWING_SYSTEM.get(), Some(WindowingSystem::Wayland))
|
||||
&& let Some((new_root, new_ms)) = new_root
|
||||
{
|
||||
use iced_runtime::platform_specific::wayland::popup::{
|
||||
SctkPopupSettings, SctkPositioner,
|
||||
use iced_runtime::platform_specific::wayland::{
|
||||
CornerRadius,
|
||||
popup::{SctkPopupSettings, SctkPositioner},
|
||||
};
|
||||
|
||||
use crate::surface::action::LiveSettings;
|
||||
use crate::{surface::action::LiveSettings, theme::THEME};
|
||||
let overlay_offset = Point::ORIGIN - viewport.position();
|
||||
|
||||
let overlay_cursor = cursor.position().unwrap_or_default() - overlay_offset;
|
||||
|
|
@ -1104,9 +1105,23 @@ impl<Message: std::clone::Clone + 'static> Widget<Message, crate::Theme, crate::
|
|||
// disable slide_x if it is set in the default
|
||||
positioner.constraint_adjustment &= !(1 << 0);
|
||||
let parent = self.window_id;
|
||||
|
||||
let t = THEME.lock().unwrap();
|
||||
let styling = t.appearance(&crate::theme::menu_bar::MenuBarStyle::Default, false);
|
||||
drop(t);
|
||||
let rad = styling.menu_border_radius;
|
||||
|
||||
shell.publish((self.on_surface_action.as_ref().unwrap())(
|
||||
crate::surface::action::simple_popup(
|
||||
|| LiveSettings::default(),
|
||||
move || LiveSettings {
|
||||
corners: Some(CornerRadius {
|
||||
top_left: rad[0] as u32,
|
||||
top_right: rad[1] as u32,
|
||||
bottom_left: rad[2] as u32,
|
||||
bottom_right: rad[3] as u32,
|
||||
}),
|
||||
..Default::default()
|
||||
},
|
||||
move || SctkPopupSettings {
|
||||
parent,
|
||||
id: popup_id,
|
||||
|
|
|
|||
|
|
@ -941,9 +941,13 @@ where
|
|||
let my_state = state.menu_state.clone();
|
||||
|
||||
if self.window_id != window::Id::NONE {
|
||||
use crate::surface::action::{LiveSettings, destroy_popup};
|
||||
use iced_runtime::platform_specific::wayland::popup::{
|
||||
SctkPopupSettings, SctkPositioner,
|
||||
use crate::{
|
||||
surface::action::{LiveSettings, destroy_popup},
|
||||
widget::menu::StyleSheet,
|
||||
};
|
||||
use iced_runtime::platform_specific::wayland::{
|
||||
CornerRadius,
|
||||
popup::{SctkPopupSettings, SctkPositioner},
|
||||
};
|
||||
|
||||
let Some(surface_action) = self.on_surface_action.as_ref() else {
|
||||
|
|
@ -1074,6 +1078,12 @@ where
|
|||
..Default::default()
|
||||
};
|
||||
let parent = self.window_id;
|
||||
|
||||
let t = THEME.lock().unwrap();
|
||||
let styling = t.appearance(&crate::theme::menu_bar::MenuBarStyle::Default, false);
|
||||
drop(t);
|
||||
let rad = styling.menu_border_radius;
|
||||
|
||||
/// Used to create a popup message from within a widget.
|
||||
#[cfg(all(feature = "wayland", target_os = "linux", feature = "winit"))]
|
||||
#[must_use]
|
||||
|
|
@ -1113,7 +1123,15 @@ where
|
|||
)
|
||||
}
|
||||
shell.publish((surface_action)(simple_popup(
|
||||
LiveSettings::default,
|
||||
move || LiveSettings {
|
||||
corners: Some(CornerRadius {
|
||||
top_left: rad[0] as u32,
|
||||
top_right: rad[1] as u32,
|
||||
bottom_left: rad[2] as u32,
|
||||
bottom_right: rad[3] as u32,
|
||||
}),
|
||||
..Default::default()
|
||||
},
|
||||
move || SctkPopupSettings {
|
||||
parent,
|
||||
id,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue