Gjsify LogoGjsify Logo

The GdkPopupLayout struct contains information that is necessary position a [ifaceGdk.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.

record

Hierarchy

  • PopupLayout

Index

Constructors

  • 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.

    Parameters

    • anchorRect: Gdk.Rectangle

      the anchor GdkRectangle to align surface with

    • rectAnchor: Gdk.Gravity

      the point on anchor_rect to align with surface's anchor point

    • surfaceAnchor: Gdk.Gravity

      the point on surface to align with rect's anchor point

    Returns PopupLayout

Properties

name: string

Methods

  • Check whether layout and other has identical layout properties.

    Parameters

    Returns boolean

  • getOffset(): [number, number]
  • Retrieves the offset for the anchor rectangle.

    Returns [number, number]

  • getShadowWidth(): [number, number, number, number]
  • Obtains the shadow widths of this layout.

    Returns [number, number, number, number]

  • 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.

    Parameters

    Returns void

  • setOffset(dx: number, dy: number): void
  • Offset the position of the anchor rectangle with the given delta.

    Parameters

    • dx: number

      x delta to offset the anchor rectangle with

    • dy: number

      y delta to offset the anchor rectangle with

    Returns void

  • setShadowWidth(left: number, right: number, top: number, bottom: number): void
  • 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.

    Parameters

    • left: number

      width of the left part of the shadow

    • right: number

      width of the right part of the shadow

    • top: number

      height of the top part of the shadow

    • bottom: number

      height of the bottom part of the shadow

    Returns void

  • unref(): void
  • 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.

    Parameters

    • anchorRect: Gdk.Rectangle

      the anchor GdkRectangle to align surface with

    • rectAnchor: Gdk.Gravity

      the point on anchor_rect to align with surface's anchor point

    • surfaceAnchor: Gdk.Gravity

      the point on surface to align with rect's anchor point

    Returns PopupLayout

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method