PopupLayoutRef

public struct PopupLayoutRef : PopupLayoutProtocol

The PopupLayoutRef type acts as a lightweight Swift reference to an underlying GdkPopupLayout instance. It exposes methods that can operate on this data type through PopupLayoutProtocol conformance. Use PopupLayoutRef only as an unowned reference to an existing 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!

PopupLayout Record

  • Designated initialiser from the underlying C data type

    Declaration

    Swift

    @inlinable
    init(_ p: UnsafeMutablePointer<GdkPopupLayout>)
  • Designated initialiser from a constant pointer to the underlying C data type

    Declaration

    Swift

    @inlinable
    init(_ p: UnsafePointer<GdkPopupLayout>)
  • Conditional initialiser from an optional pointer to the underlying C data type

    Declaration

    Swift

    @inlinable
    init!(_ maybePointer: UnsafeMutablePointer<GdkPopupLayout>?)
  • Conditional initialiser from an optional, non-mutable pointer to the underlying C data type

    Declaration

    Swift

    @inlinable
    init!(_ maybePointer: UnsafePointer<GdkPopupLayout>?)
  • Conditional initialiser from an optional gpointer

    Declaration

    Swift

    @inlinable
    init!(gpointer g: gpointer?)
  • Conditional initialiser from an optional, non-mutable gconstpointer

    Declaration

    Swift

    @inlinable
    init!(gconstpointer g: gconstpointer?)
  • Reference intialiser for a related type that implements PopupLayoutProtocol

    Declaration

    Swift

    @inlinable
    init<T>(_ other: T) where T : PopupLayoutProtocol
  • Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to PopupLayoutProtocol.

    Declaration

    Swift

    @inlinable
    init<T>(cPointer: UnsafeMutablePointer<T>)
  • Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to PopupLayoutProtocol.

    Declaration

    Swift

    @inlinable
    init<T>(constPointer: UnsafePointer<T>)
  • Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to PopupLayoutProtocol.

    Declaration

    Swift

    @inlinable
    init(mutating 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
    init(raw: UnsafeMutableRawPointer)
  • Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to PopupLayoutProtocol.

    Declaration

    Swift

    @inlinable
    init(opaquePointer: OpaquePointer)
  • 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
    init<RectangleT>(anchorRect: RectangleT, rectAnchor: GdkGravity, surfaceAnchor: GdkGravity) where RectangleT : RectangleProtocol