PopupLayout

open class PopupLayout : PopupLayoutProtocol

The PopupLayout type acts as a reference-counted owner of an underlying GdkPopupLayout instance. It provides the methods that can operate on this data type through PopupLayoutProtocol conformance. Use PopupLayout as a strong reference or owner of a GdkPopupLayout instance.

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.
    

    For type-safe access, use the generated, typed pointer popup_layout_ptr property instead.

    Declaration

    Swift

    public let ptr: UnsafeMutableRawPointer!
  • Designated initialiser from the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the PopupLayout instance.

    Declaration

    Swift

    @inlinable
    public init(_ op: UnsafeMutablePointer<GdkPopupLayout>)

    Parameters

    op

    pointer to the underlying object

  • Designated initialiser from a constant pointer to the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the PopupLayout instance.

    Declaration

    Swift

    @inlinable
    public init(_ op: UnsafePointer<GdkPopupLayout>)

    Parameters

    op

    pointer to the underlying object

  • Optional initialiser from a non-mutating gpointer to the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the PopupLayout instance.

    Declaration

    Swift

    @inlinable
    public init!(gpointer op: gpointer?)

    Parameters

    op

    gpointer to the underlying object

  • Optional initialiser from a non-mutating gconstpointer to the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the PopupLayout instance.

    Declaration

    Swift

    @inlinable
    public init!(gconstpointer op: gconstpointer?)

    Parameters

    op

    pointer to the underlying object

  • Optional initialiser from a constant pointer to the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the PopupLayout instance.

    Declaration

    Swift

    @inlinable
    public init!(_ op: UnsafePointer<GdkPopupLayout>?)

    Parameters

    op

    pointer to the underlying object

  • Optional initialiser from the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the PopupLayout instance.

    Declaration

    Swift

    @inlinable
    public init!(_ op: UnsafeMutablePointer<GdkPopupLayout>?)

    Parameters

    op

    pointer to the underlying object

  • Designated initialiser from the underlying C data type. Will retain GdkPopupLayout. i.e., ownership is transferred to the PopupLayout instance.

    Declaration

    Swift

    @inlinable
    public init(retaining op: UnsafeMutablePointer<GdkPopupLayout>)

    Parameters

    op

    pointer to the underlying object

  • Reference intialiser for a related type that implements PopupLayoutProtocol Will retain GdkPopupLayout.

    Declaration

    Swift

    @inlinable
    public init<T>(_ other: T) where T : PopupLayoutProtocol

    Parameters

    other

    an instance of a related type that implements PopupLayoutProtocol

  • Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to PopupLayoutProtocol.

    Declaration

    Swift

    @inlinable
    public init<T>(cPointer p: UnsafeMutablePointer<T>)

    Parameters

    cPointer

    pointer to the underlying object

  • Unsafe typed, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to PopupLayoutProtocol.

    Declaration

    Swift

    @inlinable
    public init<T>(retainingCPointer cPointer: UnsafeMutablePointer<T>)

    Parameters

    cPointer

    pointer to the underlying object

  • Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to PopupLayoutProtocol.

    Declaration

    Swift

    @inlinable
    public init(raw p: UnsafeRawPointer)

    Parameters

    p

    raw pointer to the underlying object

  • Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to PopupLayoutProtocol.

    Declaration

    Swift

    @inlinable
    public init(retainingRaw raw: UnsafeRawPointer)
  • Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to PopupLayoutProtocol.

    Declaration

    Swift

    @inlinable
    public required init(raw p: UnsafeMutableRawPointer)

    Parameters

    p

    mutable raw pointer to the underlying object

  • Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to PopupLayoutProtocol.

    Declaration

    Swift

    @inlinable
    public init(retainingRaw raw: UnsafeMutableRawPointer)

    Parameters

    raw

    mutable raw pointer to the underlying object

  • Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to PopupLayoutProtocol.

    Declaration

    Swift

    @inlinable
    public init(opaquePointer p: OpaquePointer)

    Parameters

    p

    opaque pointer to the underlying object

  • Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to PopupLayoutProtocol.

    Declaration

    Swift

    @inlinable
    public init(retainingOpaquePointer p: OpaquePointer)

    Parameters

    p

    opaque pointer to the underlying object

  • Create a popup layout description.

    Used together with [methodGdk.Popup.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 [methodGdk.PopupLayout.set_offset], which is equivalent to offsetting the position of surface.

    Declaration

    Swift

    @inlinable
    public init<RectangleT>(anchorRect: RectangleT, rectAnchor: GdkGravity, surfaceAnchor: GdkGravity) where RectangleT : RectangleProtocol