package ocgtk

  1. Overview
  2. Docs
OCaml bindings for GTK 4

Install

dune-project
 Dependency

Authors

Maintainers

Sources

v0.1-preview2.tar.gz
sha256=4e50fdb5093136a10fc8ffbe388e44cbcb70d52f8afdd48863ec7e22580ff054

doc/ocgtk.gdk/Ocgtk_gdk/Gdk/Wrappers/Popup_layout/index.html

Module Wrappers.Popup_layout

type t = [ `popup_layout ] Gobject.obj

The `GdkPopupLayout` struct contains information that is necessary position a iface@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(popup-anchors.png)

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(popup-flip.png)

!Sliding popups(popup-slide.png)

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 method@Gdk.Popup.get_position_x, method@Gdk.Popup.get_position_y, method@Gdk.Popup.get_rect_anchor and method@Gdk.Popup.get_surface_anchor after the popup has been presented. This can be used to adjust the rendering. For example, GtkPopover(../gtk4/class.Popover.html) 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.

val new_ : [ `rectangle ] Gobject.obj -> Gdk_enums.gravity -> Gdk_enums.gravity -> t

Create a new PopupLayout

val set_surface_anchor : t -> Gdk_enums.gravity -> unit

Set the anchor on the popup surface.

val set_shadow_width : t -> int -> int -> int -> int -> unit

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.

val set_rect_anchor : t -> Gdk_enums.gravity -> unit

Set the anchor on the anchor rectangle.

val set_offset : t -> int -> int -> unit

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

val set_anchor_rect : t -> [ `rectangle ] Gobject.obj -> unit

Set the anchor rectangle.

val set_anchor_hints : t -> Gdk_enums.anchorhints -> unit

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.

val ref : t -> t

Increases the reference count of @value.

val get_surface_anchor : t -> Gdk_enums.gravity

Returns the anchor position on the popup surface.

val get_shadow_width : t -> int * int * int * int

Obtains the shadow widths of this layout.

val get_rect_anchor : t -> Gdk_enums.gravity

Returns the anchor position on the anchor rectangle.

val get_offset : t -> int * int

Retrieves the offset for the anchor rectangle.

val get_anchor_rect : t -> [ `rectangle ] Gobject.obj

Get the anchor rectangle.

val get_anchor_hints : t -> Gdk_enums.anchorhints

Get the `GdkAnchorHints`.

val equal : t -> t -> bool

Check whether @layout and @other has identical layout properties.

val get_type : unit -> Gobject.Type.t