Class PopupLayout
- All Implemented Interfaces:
Proxy
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.
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.
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
Popup.getPositionX(), Popup.getPositionY(),
Popup.getRectAnchor() and Popup.getSurfaceAnchor()
after the popup has been presented. This can be used to adjust the rendering.
For example, GtkPopover 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.
-
Constructor Summary
ConstructorsConstructorDescriptionPopupLayout(MemorySegment address) Create a PopupLayout proxy instance for the provided memory address.PopupLayout(Rectangle anchorRect, Gravity rectAnchor, Gravity surfaceAnchor) Create a popup layout description. -
Method Summary
Modifier and TypeMethodDescriptioncopy()Makes a copy oflayout.booleanequal(PopupLayout other) Check whether this PopupLayout andotherhas identical layout properties.Get the anchor hints.Get the anchor rectangle.voidRetrieves the offset for the anchor rectangle.Returns the anchor position on the anchor rectangle.voidObtains the shadow widths of this layout.Returns the anchor position on the popup surface.static @Nullable TypegetType()Get the GType of the PopupLayout classref()Increases the reference count ofvalue.voidsetAnchorHints(Set<AnchorHints> anchorHints) Set new anchor hints.voidsetAnchorHints(AnchorHints... anchorHints) Set new anchor hints.voidsetAnchorRect(Rectangle anchorRect) Set the anchor rectangle.voidsetOffset(int dx, int dy) Offset the position of the anchor rectangle with the given delta.voidsetRectAnchor(Gravity anchor) Set the anchor on the anchor rectangle.voidsetShadowWidth(int left, int right, int top, int bottom) Sets the shadow width of the popup.voidsetSurfaceAnchor(Gravity anchor) Set the anchor on the popup surface.voidunref()Decreases the reference count ofvalue.Methods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
PopupLayout
Create a PopupLayout proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
PopupLayout
Create a popup layout description.Used together with
Popup.present(int, int, org.gnome.gdk.PopupLayout)to describe how a popup surface should be placed and behave on-screen.anchorRectis relative to the top-left corner of the surface's parent.rectAnchorandsurfaceAnchordetermine anchor points onanchorRectand surface to pin together.The position of
anchorRect'sanchor point can optionally be offset usingsetOffset(int, int), which is equivalent to offsetting the position of surface.- Parameters:
anchorRect- the anchor rectangle to alignsurfacewithrectAnchor- the point onanchorRectto align withsurface'sanchor pointsurfaceAnchor- the point onsurfaceto align withrect'sanchor point
-
-
Method Details
-
getType
-
copy
-
equal
Check whether this PopupLayout andotherhas identical layout properties.- Parameters:
other- another popup layout- Returns:
- true if this PopupLayout and
otherhave identical layout properties, otherwise false.
-
getAnchorHints
-
getAnchorRect
-
getOffset
-
getRectAnchor
Returns the anchor position on the anchor rectangle.- Returns:
- the anchor on the anchor rectangle.
-
getShadowWidth
public void getShadowWidth(Out<Integer> left, Out<Integer> right, Out<Integer> top, Out<Integer> 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- Since:
- 4.2
-
getSurfaceAnchor
Returns the anchor position on the popup surface.- Returns:
- the anchor on the popup surface.
-
ref
-
setAnchorHints
Set new anchor hints.The set
anchorHintsdetermines howsurfacewill be moved if the anchor points cause it to move off-screen. For example,GDK_ANCHOR_FLIP_Xwill replaceGDK_GRAVITY_NORTH_WESTwithGDK_GRAVITY_NORTH_EASTand vice versa ifsurfaceextends beyond the left or right edges of the monitor.- Parameters:
anchorHints- the new anchor hints
-
setAnchorHints
Set new anchor hints.The set
anchorHintsdetermines howsurfacewill be moved if the anchor points cause it to move off-screen. For example,GDK_ANCHOR_FLIP_Xwill replaceGDK_GRAVITY_NORTH_WESTwithGDK_GRAVITY_NORTH_EASTand vice versa ifsurfaceextends beyond the left or right edges of the monitor.- Parameters:
anchorHints- the new anchor hints
-
setAnchorRect
Set the anchor rectangle.- Parameters:
anchorRect- 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
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- Since:
- 4.2
-
setSurfaceAnchor
Set the anchor on the popup surface.- Parameters:
anchor- the new popup surface anchor
-
unref
public void unref()Decreases the reference count ofvalue.
-