Struct gdk4::PopupLayout[][src]

pub struct PopupLayout(_);
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.

Popup anchors

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.

Flipping popups

Sliding popups

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, Gtk::Popover 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.

Implementations

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

Makes a copy of self.

Returns

a copy of self.

Get the anchor rectangle.

Returns

The anchor rectangle

Returns the anchor position on the anchor rectangle.

Returns

the anchor on the anchor rectangle.

This is supported on crate feature v4_2 only.

Obtains the shadow widths of this layout.

Returns
left

return location for the left shadow width

return location for the right shadow width

top

return location for the top shadow width

bottom

return location for the bottom shadow width

Returns the anchor position on the popup surface.

Returns

the anchor on the popup surface.

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

Set the anchor rectangle.

anchor_rect

the new anchor rectangle

Offset the position of the anchor rectangle with the given delta.

dx

x delta to offset the anchor rectangle with

dy

y delta to offset the anchor rectangle with

Set the anchor on the anchor rectangle.

anchor

the new rect anchor

This is supported on crate feature 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

Set the anchor on the popup surface.

anchor

the new popup surface anchor

Retrieves the offset for the anchor rectangle.

Returns
dx

return location for the delta X coordinate

dy

return location for the delta Y coordinate

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Returns the type identifier of Self.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.