class Gdk::PopupLayout


The Gdk::PopupLayout struct contains information that is necessary position a Gdk::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 Gdk::Popup#position_x, Gdk::Popup#position_y, Gdk::Popup#rect_anchor and Gdk::Popup#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.

Defined in:



Class Method Summary

Instance Method Summary

Constructor Detail

def : Gdk::Rectangle, rect_anchor : Gdk::Gravity, surface_anchor : Gdk::Gravity) : self #

def : Pointer(Void), transfer : GICrystal::Transfer) #

Class Method Detail

def self.g_type : UInt64 #

Returns the type id (GType) registered in GLib type system.

Instance Method Detail

def anchor_hints : Gdk::AnchorHints #

def anchor_hints=(anchor_hints : Gdk::AnchorHints) : Nil #

def anchor_rect : Gdk::Rectangle #

def anchor_rect=(anchor_rect : Gdk::Rectangle) : Nil #

def copy : Gdk::PopupLayout #

def equal(other : Gdk::PopupLayout) : Bool #

def finalize #

def offset(dx : Int32, dy : Int32) : Nil #

def rect_anchor : Gdk::Gravity #

def rect_anchor=(anchor : Gdk::Gravity) : Nil #

def ref : Gdk::PopupLayout #

def set_offset(dx : Int32, dy : Int32) : Nil #

def set_shadow_width(left : Int32, right : Int32, top : Int32, bottom : Int32) : Nil #

def shadow_width(left : Int32, right : Int32, top : Int32, bottom : Int32) : Nil #

def surface_anchor : Gdk::Gravity #

def surface_anchor=(anchor : Gdk::Gravity) : Nil #

def to_unsafe : Pointer(Void) #

def unref : Nil #