pub struct PopupConfig {
pub width: u32,
pub height: Option<u32>,
pub anchor_rect: Rect,
pub anchor: PopupAnchor,
pub gravity: PopupGravity,
pub offset: (i32, i32),
pub grab: bool,
pub background_color: Color,
}Expand description
Configuration for an xdg popup anchored to a parent surface.
The compositor positions the popup relative to anchor_rect (parent
surface coordinates) and adjusts it to stay on screen (flip/slide).
spawn_popup(
bar_surface_id,
PopupConfig::new(250)
.anchor_rect(button_rect)
.anchor(PopupAnchor::Bottom)
.gravity(PopupGravity::Bottom)
.grab(),
move || menu_widget(),
);Fields§
§width: u32Popup width in logical pixels.
height: Option<u32>Popup height in logical pixels. None (the default) sizes the popup
to its content: the widget is laid out at the given width before the
popup is created, and repositioned when its content height changes
(submenus expanding, lists growing). Content using height(fill())
resolves to the screen-height cap — give such popups an explicit
height instead.
anchor_rect: RectRectangle the popup anchors to, in parent surface coordinates.
anchor: PopupAnchorWhich point of the anchor rect to attach to.
gravity: PopupGravityWhich direction the popup grows.
offset: (i32, i32)Extra offset from the anchor point.
grab: boolTake an input grab: clicking outside dismisses the popup (menu
semantics). The compositor reports the dismissal reactively — see
PopupHandle::dismissed.
background_color: ColorBackground color of the popup surface.
Implementations§
Source§impl PopupConfig
impl PopupConfig
Sourcepub fn new(width: u32) -> Self
pub fn new(width: u32) -> Self
Create a popup configuration with the given width; the height sizes
to the content (see PopupConfig::height to fix it instead).
Sourcepub fn height(self, height: u32) -> Self
pub fn height(self, height: u32) -> Self
Fix the popup height instead of sizing it to the content.
Sourcepub fn anchor_rect(self, rect: Rect) -> Self
pub fn anchor_rect(self, rect: Rect) -> Self
Set the rectangle the popup anchors to (parent surface coordinates).
Typically a widget’s bounds from a crate::widget_ref::WidgetRef.
Sourcepub fn anchor(self, anchor: PopupAnchor) -> Self
pub fn anchor(self, anchor: PopupAnchor) -> Self
Set which point of the anchor rect the popup attaches to.
Sourcepub fn gravity(self, gravity: PopupGravity) -> Self
pub fn gravity(self, gravity: PopupGravity) -> Self
Set which direction the popup grows.
Sourcepub fn background_color(self, color: Color) -> Self
pub fn background_color(self, color: Color) -> Self
Set the background color of the popup surface.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PopupConfig
impl RefUnwindSafe for PopupConfig
impl Send for PopupConfig
impl Sync for PopupConfig
impl Unpin for PopupConfig
impl UnsafeUnpin for PopupConfig
impl UnwindSafe for PopupConfig
Blanket Implementations§
Source§impl<T, M, S> Animate<T, M> for Swhere
T: Clone + 'static,
S: IntoSignal<T, M>,
impl<T, M, S> Animate<T, M> for Swhere
T: Clone + 'static,
S: IntoSignal<T, M>,
Source§fn transition(self, transition: impl Into<TransitionConfig>) -> Animated<T>
fn transition(self, transition: impl Into<TransitionConfig>) -> Animated<T>
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.