pub struct PopupLayout { /* private fields */ }
Expand description
The PopupLayout
struct contains information that is
necessary position a Popup
relative to its parent.
The positioning requires a negotiation with the windowing system, since it depends on external constraints, such as the position of the parent surface, and the screen dimensions.
The basic ingredients are a rectangle on the parent surface, and the anchor on both that rectangle and the popup. The anchors specify a side or corner to place next to each other.
For cases where placing the anchors next to each other would make the popup extend offscreen, the layout includes some hints for how to resolve this problem. The hints may suggest to flip the anchor position to the other side, or to ‘slide’ the popup along a side, or to resize it.
These hints may be combined.
Ultimatively, it is up to the windowing system to determine the position
and size of the popup. You can learn about the result by calling
PopupExt::position_x()
, PopupExt::position_y()
,
PopupExt::rect_anchor()
and PopupExt::surface_anchor()
after the popup has been presented. This can be used to adjust the rendering.
For example, GtkPopover changes its arrow position
accordingly. But you have to be careful avoid changing the size of the popover,
or it has to be presented again.
GLib type: Shared boxed type with reference counted clone semantics.
Implementations§
Source§impl PopupLayout
impl PopupLayout
Sourcepub fn as_ptr(&self) -> *mut GdkPopupLayout
pub fn as_ptr(&self) -> *mut GdkPopupLayout
Return the inner pointer to the underlying C value.
Sourcepub unsafe fn from_glib_ptr_borrow(ptr: &*mut GdkPopupLayout) -> &Self
pub unsafe fn from_glib_ptr_borrow(ptr: &*mut GdkPopupLayout) -> &Self
Borrows the underlying C value.
Source§impl PopupLayout
impl PopupLayout
Sourcepub fn new(
anchor_rect: &Rectangle,
rect_anchor: Gravity,
surface_anchor: Gravity,
) -> PopupLayout
pub fn new( anchor_rect: &Rectangle, rect_anchor: Gravity, surface_anchor: Gravity, ) -> PopupLayout
Create a popup layout description.
Used together with PopupExt::present()
to describe how a popup
surface should be placed and behave on-screen.
@anchor_rect is relative to the top-left corner of the surface’s parent. @rect_anchor and @surface_anchor determine anchor points on @anchor_rect and surface to pin together.
The position of @anchor_rect’s anchor point can optionally be offset using
set_offset()
, which is equivalent to offsetting the
position of surface.
§anchor_rect
the anchor Rectangle
to align @surface with
§rect_anchor
the point on @anchor_rect to align with @surface’s anchor point
§surface_anchor
the point on @surface to align with @rect’s anchor point
§Returns
newly created instance of PopupLayout
pub fn copy(&self) -> PopupLayout
Sourcepub fn anchor_hints(&self) -> AnchorHints
pub fn anchor_hints(&self) -> AnchorHints
Sourcepub fn anchor_rect(&self) -> Rectangle
pub fn anchor_rect(&self) -> Rectangle
Sourcepub fn rect_anchor(&self) -> Gravity
pub fn rect_anchor(&self) -> Gravity
Sourcepub fn surface_anchor(&self) -> Gravity
pub fn surface_anchor(&self) -> Gravity
Sourcepub fn set_anchor_hints(&self, anchor_hints: AnchorHints)
pub fn set_anchor_hints(&self, anchor_hints: AnchorHints)
Set new anchor hints.
The set @anchor_hints determines how @surface will be moved
if the anchor points cause it to move off-screen. For example,
AnchorHints::FLIP_X
will replace Gravity::NorthWest
with
Gravity::NorthEast
and vice versa if @surface extends
beyond the left or right edges of the monitor.
§anchor_hints
the new AnchorHints
Sourcepub fn set_anchor_rect(&self, anchor_rect: &Rectangle)
pub fn set_anchor_rect(&self, anchor_rect: &Rectangle)
Sourcepub fn set_offset(&self, dx: i32, dy: i32)
pub fn set_offset(&self, dx: i32, dy: i32)
Sourcepub fn set_rect_anchor(&self, anchor: Gravity)
pub fn set_rect_anchor(&self, anchor: Gravity)
Sourcepub fn set_shadow_width(&self, left: i32, right: i32, top: i32, bottom: i32)
Available on crate feature v4_2
only.
pub fn set_shadow_width(&self, left: i32, right: i32, top: i32, bottom: i32)
v4_2
only.Sets the shadow width of the popup.
The shadow width corresponds to the part of the computed surface size that would consist of the shadow margin surrounding the window, would there be any.
§left
width of the left part of the shadow
§right
width of the right part of the shadow
§top
height of the top part of the shadow
§bottom
height of the bottom part of the shadow
Sourcepub fn set_surface_anchor(&self, anchor: Gravity)
pub fn set_surface_anchor(&self, anchor: Gravity)
Trait Implementations§
Source§impl Clone for PopupLayout
impl Clone for PopupLayout
Source§impl Debug for PopupLayout
impl Debug for PopupLayout
Source§impl From<PopupLayout> for Value
impl From<PopupLayout> for Value
Source§fn from(s: PopupLayout) -> Self
fn from(s: PopupLayout) -> Self
Source§impl HasParamSpec for PopupLayout
impl HasParamSpec for PopupLayout
type ParamSpec = ParamSpecBoxed
Source§type SetValue = PopupLayout
type SetValue = PopupLayout
type BuilderFn = fn(_: &str) -> ParamSpecBoxedBuilder<'_, PopupLayout>
fn param_spec_builder() -> Self::BuilderFn
Source§impl Hash for PopupLayout
impl Hash for PopupLayout
Source§impl Ord for PopupLayout
impl Ord for PopupLayout
Source§fn cmp(&self, other: &PopupLayout) -> Ordering
fn cmp(&self, other: &PopupLayout) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for PopupLayout
impl PartialEq for PopupLayout
Source§impl PartialOrd for PopupLayout
impl PartialOrd for PopupLayout
Source§impl StaticType for PopupLayout
impl StaticType for PopupLayout
Source§fn static_type() -> Type
fn static_type() -> Type
Self
.impl Eq for PopupLayout
Auto Trait Implementations§
impl Freeze for PopupLayout
impl RefUnwindSafe for PopupLayout
impl !Send for PopupLayout
impl !Sync for PopupLayout
impl Unpin for PopupLayout
impl UnwindSafe for PopupLayout
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)