PopupLayoutProtocol

public protocol PopupLayoutProtocol

The PopupLayoutProtocol protocol exposes the methods and properties of an underlying GdkPopupLayout instance. The default implementation of these can be found in the protocol extension below. For a concrete class that implements these methods and properties, see PopupLayout. Alternatively, use PopupLayoutRef as a lighweight, unowned reference if you already have an instance you just want to use.

The GdkPopupLayout struct contains information that is necessary position a [interfaceGdk.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 [methodGdk.Popup.get_position_x], [methodGdk.Popup.get_position_y], [methodGdk.Popup.get_rect_anchor] and [methodGdk.Popup.get_surface_anchor] after the popup has been presented. This can be used to adjust the rendering. For example, [classGtk.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.

  • ptr

    Untyped pointer to the underlying GdkPopupLayout instance.

    Declaration

    Swift

    var ptr: UnsafeMutableRawPointer! { get }
  • popup_layout_ptr Default implementation

    Typed pointer to the underlying GdkPopupLayout instance.

    Default Implementation

    Return the stored, untyped pointer as a typed pointer to the GdkPopupLayout instance.

    Declaration

    Swift

    var popup_layout_ptr: UnsafeMutablePointer<GdkPopupLayout>! { get }
  • Required Initialiser for types conforming to PopupLayoutProtocol

    Declaration

    Swift

    init(raw: UnsafeMutableRawPointer)

PopupLayout Record: PopupLayoutProtocol extension (methods and fields)

  • copy() Extension method

    Makes a copy of layout.

    Declaration

    Swift

    @inlinable
    func copy() -> PopupLayoutRef!
  • equal(other:) Extension method

    Check whether layout and other has identical layout properties.

    Declaration

    Swift

    @inlinable
    func equal<PopupLayoutT>(other: PopupLayoutT) -> Bool where PopupLayoutT : PopupLayoutProtocol
  • getAnchorHints() Extension method

    Get the GdkAnchorHints.

    Declaration

    Swift

    @inlinable
    func getAnchorHints() -> AnchorHints
  • getAnchorRect() Extension method

    Get the anchor rectangle.

    Declaration

    Swift

    @inlinable
    func getAnchorRect() -> RectangleRef!
  • getOffset(dx:dy:) Extension method

    Retrieves the offset for the anchor rectangle.

    Declaration

    Swift

    @inlinable
    func getOffset(dx: UnsafeMutablePointer<gint>!, dy: UnsafeMutablePointer<gint>!)
  • getRectAnchor() Extension method

    Returns the anchor position on the anchor rectangle.

    Declaration

    Swift

    @inlinable
    func getRectAnchor() -> GdkGravity
  • Obtains the shadow widths of this layout.

    Declaration

    Swift

    @inlinable
    func getShadowWidth(left: UnsafeMutablePointer<gint>!, right: UnsafeMutablePointer<gint>!, top: UnsafeMutablePointer<gint>!, bottom: UnsafeMutablePointer<gint>!)
  • getSurfaceAnchor() Extension method

    Returns the anchor position on the popup surface.

    Declaration

    Swift

    @inlinable
    func getSurfaceAnchor() -> GdkGravity
  • ref() Extension method

    Increases the reference count of value.

    Declaration

    Swift

    @discardableResult
    @inlinable
    func ref() -> PopupLayoutRef!
  • set(anchorHints:) Extension method

    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, GDK_ANCHOR_FLIP_X will replace GDK_GRAVITY_NORTH_WEST with GDK_GRAVITY_NORTH_EAST and vice versa if surface extends beyond the left or right edges of the monitor.

    Declaration

    Swift

    @inlinable
    func set(anchorHints: AnchorHints)
  • set(anchorRect:) Extension method

    Set the anchor rectangle.

    Declaration

    Swift

    @inlinable
    func set<RectangleT>(anchorRect: RectangleT) where RectangleT : RectangleProtocol
  • setOffset(dx:dy:) Extension method

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

    Declaration

    Swift

    @inlinable
    func setOffset(dx: Int, dy: Int)
  • setRect(anchor:) Extension method

    Set the anchor on the anchor rectangle.

    Declaration

    Swift

    @inlinable
    func setRect(anchor: GdkGravity)
  • 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.

    Declaration

    Swift

    @inlinable
    func setShadowWidth(left: Int, right: Int, top: Int, bottom: Int)
  • setSurface(anchor:) Extension method

    Set the anchor on the popup surface.

    Declaration

    Swift

    @inlinable
    func setSurface(anchor: GdkGravity)
  • unref() Extension method

    Decreases the reference count of value.

    Declaration

    Swift

    @inlinable
    func unref()
  • anchorHints Extension method

    Get the GdkAnchorHints.

    Declaration

    Swift

    @inlinable
    var anchorHints: AnchorHints { get nonmutating set }
  • anchorRect Extension method

    Get the anchor rectangle.

    Declaration

    Swift

    @inlinable
    var anchorRect: RectangleRef! { get nonmutating set }
  • rectAnchor Extension method

    Returns the anchor position on the anchor rectangle.

    Declaration

    Swift

    @inlinable
    var rectAnchor: GdkGravity { get nonmutating set }
  • surfaceAnchor Extension method

    Returns the anchor position on the popup surface.

    Declaration

    Swift

    @inlinable
    var surfaceAnchor: GdkGravity { get nonmutating set }