Package ch.bailu.gtk.gdk
Class PopupLayout
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.type.Record
ch.bailu.gtk.gdk.PopupLayout
- All Implemented Interfaces:
PointerInterface
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, [class@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.
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, [class@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.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionPopupLayout
(Rectangle anchor_rect, int rect_anchor, int surface_anchor) Create a popup layout description.PopupLayout
(PointerContainer pointer) -
Method Summary
Modifier and TypeMethodDescriptioncopy()
Makes a copy of @layout.boolean
equal
(PopupLayout other) Check whether @layout and @other has identical layout properties.int
Get the `GdkAnchorHints`.Get the anchor rectangle.static ClassHandler
static int
void
Retrieves the offset for the anchor rectangle.static long
static TypeSystem.TypeSize
int
Returns the anchor position on the anchor rectangle.void
getShadowWidth
(Int left, Int right, Int top, Int bottom) Obtains the shadow widths of this layout.int
Returns the anchor position on the popup surface.static long
static TypeSystem.TypeSize
ref()
Increases the reference count of @value.void
setAnchorHints
(int anchor_hints) Set new anchor hints.void
setAnchorRect
(Rectangle anchor_rect) Set the anchor rectangle.void
setOffset
(int dx, int dy) Offset the position of the anchor rectangle with the given delta.void
setRectAnchor
(int anchor) Set the anchor on the anchor rectangle.void
setShadowWidth
(int left, int right, int top, int bottom) Sets the shadow width of the popup.void
setSurfaceAnchor
(int anchor) Set the anchor on the popup surface.void
unref()
Decreases the reference count of @value.Methods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Constructor Details
-
PopupLayout
-
PopupLayout
Create a popup layout description.
Used together with [method@Gdk.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
[method@Gdk.PopupLayout.set_offset], which is equivalent to offsetting the
position of surface.- Parameters:
anchor_rect
- the anchor `GdkRectangle` to align @surface withrect_anchor
- the point on @anchor_rect to align with @surface's anchor pointsurface_anchor
- the point on @surface to align with @rect's anchor point
-
-
Method Details
-
getClassHandler
-
copy
Makes a copy of @layout.- Returns:
- a copy of @layout.
-
equal
Check whether @layout and @other has identical layout properties.- Parameters:
other
- another `GdkPopupLayout`- Returns:
- %TRUE if @layout and @other have identical layout properties, otherwise %FALSE.
-
getAnchorHints
public int getAnchorHints()Get the `GdkAnchorHints`.- Returns:
- the `GdkAnchorHints`
-
getAnchorRect
Get the anchor rectangle.- Returns:
- The anchor rectangle
-
getOffset
Retrieves the offset for the anchor rectangle.- Parameters:
dx
- return location for the delta X coordinatedy
- return location for the delta Y coordinate
-
getRectAnchor
public int getRectAnchor()Returns the anchor position on the anchor rectangle.- Returns:
- the anchor on the anchor rectangle.
-
getShadowWidth
public void getShadowWidth(@Nonnull Int left, @Nonnull Int right, @Nonnull Int top, @Nonnull Int bottom) Obtains the shadow widths of this layout.- Parameters:
left
- return location for the left shadow widthright
- return location for the right shadow widthtop
- return location for the top shadow widthbottom
- return location for the bottom shadow width
-
getSurfaceAnchor
public int getSurfaceAnchor()Returns the anchor position on the popup surface.- Returns:
- the anchor on the popup surface.
-
ref
Increases the reference count of @value.- Returns:
- the same @layout
-
setAnchorHints
public void setAnchorHints(int anchor_hints) 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:
anchor_hints
- the new `GdkAnchorHints`
-
setAnchorRect
Set the anchor rectangle.- Parameters:
anchor_rect
- the new anchor rectangle
-
setOffset
public void setOffset(int dx, int dy) Offset the position of the anchor rectangle with the given delta.- Parameters:
dx
- x delta to offset the anchor rectangle withdy
- y delta to offset the anchor rectangle with
-
setRectAnchor
public void setRectAnchor(int anchor) Set the anchor on the anchor rectangle.- Parameters:
anchor
- the new rect anchor
-
setShadowWidth
public void setShadowWidth(int left, int right, int top, int bottom) 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
- width of the left part of the shadowright
- width of the right part of the shadowtop
- height of the top part of the shadowbottom
- height of the bottom part of the shadow
-
setSurfaceAnchor
public void setSurfaceAnchor(int anchor) Set the anchor on the popup surface.- Parameters:
anchor
- the new popup surface anchor
-
unref
public void unref()Decreases the reference count of @value. -
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-