chore: update selectable text menu corner radius

This commit is contained in:
Ashley Wulber 2026-07-20 14:46:35 -04:00 • committed by Michael Murphy
parent b0b9bf16f4
commit 324ef6e905
2 changed files with 25 additions and 3 deletions

View file

@ -544,11 +544,11 @@ where
// `app.update()` and create them through the normal popup pipeline. // `app.update()` and create them through the normal popup pipeline.
#[cfg(all(wayland_platform, target_os = "linux"))] #[cfg(all(wayland_platform, target_os = "linux"))]
for req in crate::widget::text_context_menu::take_popup_requests() { for req in crate::widget::text_context_menu::take_popup_requests() {
let (settings, view) = let (live_settings, settings, view) =
crate::widget::text_context_menu::into_popup_view::<T::Message>(req); crate::widget::text_context_menu::into_popup_view::<T::Message>(req);
task = task.chain(self.get_popup( task = task.chain(self.get_popup(
settings, settings,
Box::new(|_| LiveSettings::default()), Box::new(move |_| live_settings),
Some(Box::new(move |_| view())), Some(Box::new(move |_| view())),
)); ));
} }

View file

@ -15,8 +15,14 @@
//! the context menu as a native popup surface. //! the context menu as a native popup surface.
pub use iced_core::widget::text::HasSelectableText; pub use iced_core::widget::text::HasSelectableText;
#[cfg(wayland_platform)]
use iced_runtime::platform_specific::wayland::CornerRadius;
#[cfg(wayland_platform)]
use crate::surface::action::LiveSettings;
use crate::widget::RcElementWrapper; use crate::widget::RcElementWrapper;
#[cfg(wayland_platform)]
use crate::widget::menu::StyleSheet;
use crate::widget::menu::{ use crate::widget::menu::{
self, CloseCondition, ItemHeight, ItemWidth, Menu, MenuBarState, PathHighlight, menu_roots_diff, self, CloseCondition, ItemHeight, ItemWidth, Menu, MenuBarState, PathHighlight, menu_roots_diff,
}; };
@ -59,6 +65,7 @@ use iced_runtime::platform_specific::wayland::popup::SctkPopupSettings;
/// through the normal `get_popup()` Task + `surface_views` pipeline. /// through the normal `get_popup()` Task + `surface_views` pipeline.
#[cfg(wayland_platform)] #[cfg(wayland_platform)]
pub(crate) struct PopupRequest { pub(crate) struct PopupRequest {
live_settings: LiveSettings,
settings: SctkPopupSettings, settings: SctkPopupSettings,
menu: Menu<'static, TextCtxAction>, menu: Menu<'static, TextCtxAction>,
selected_text: Option<String>, selected_text: Option<String>,
@ -93,6 +100,7 @@ pub(crate) fn take_popup_requests() -> Vec<PopupRequest> {
pub(crate) fn into_popup_view<Message: Clone + 'static>( pub(crate) fn into_popup_view<Message: Clone + 'static>(
req: PopupRequest, req: PopupRequest,
) -> ( ) -> (
LiveSettings,
SctkPopupSettings, SctkPopupSettings,
Box<dyn Fn() -> crate::Element<'static, crate::Action<Message>> + Send + Sync>, Box<dyn Fn() -> crate::Element<'static, crate::Action<Message>> + Send + Sync>,
) { ) {
@ -101,6 +109,7 @@ pub(crate) fn into_popup_view<Message: Clone + 'static>(
menu, menu,
selected_text, selected_text,
pending_action, pending_action,
live_settings,
} = req; } = req;
let view = Box::new(move || { let view = Box::new(move || {
@ -114,7 +123,7 @@ pub(crate) fn into_popup_view<Message: Clone + 'static>(
.map(crate::action::app) .map(crate::action::app)
}); });
(settings, view) (live_settings, settings, view)
} }
#[cfg(wayland_platform)] #[cfg(wayland_platform)]
@ -589,12 +598,25 @@ pub(crate) fn create_text_context_popup(
input_zone: None, input_zone: None,
}; };
let t = crate::theme::THEME.lock().unwrap();
let styling = t.appearance(&crate::theme::menu_bar::MenuBarStyle::Default, false);
drop(t);
let rad = styling.menu_border_radius;
PENDING_POPUP_REQUESTS.with(|q| { PENDING_POPUP_REQUESTS.with(|q| {
q.borrow_mut().push(PopupRequest { q.borrow_mut().push(PopupRequest {
settings, settings,
menu: popup_menu, menu: popup_menu,
selected_text, selected_text,
pending_action: pending_action.clone(), pending_action: pending_action.clone(),
live_settings: 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()
},
}); });
}); });
wake_runtime(); wake_runtime();