Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Popups are positioned relative to their parent surface. The GdkPopupLayout struct contains information that is necessary to do so.
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
popupGetPositionX
, popupGetPositionY
,
popupGetRectAnchor
and popupGetSurfaceAnchor
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.
Synopsis
- newtype PopupLayout = PopupLayout (ManagedPtr PopupLayout)
- popupLayoutCopy :: (HasCallStack, MonadIO m) => PopupLayout -> m PopupLayout
- popupLayoutEqual :: (HasCallStack, MonadIO m) => PopupLayout -> PopupLayout -> m Bool
- popupLayoutGetAnchorHints :: (HasCallStack, MonadIO m) => PopupLayout -> m [AnchorHints]
- popupLayoutGetAnchorRect :: (HasCallStack, MonadIO m) => PopupLayout -> m Rectangle
- popupLayoutGetOffset :: (HasCallStack, MonadIO m) => PopupLayout -> m (Int32, Int32)
- popupLayoutGetRectAnchor :: (HasCallStack, MonadIO m) => PopupLayout -> m Gravity
- popupLayoutGetSurfaceAnchor :: (HasCallStack, MonadIO m) => PopupLayout -> m Gravity
- popupLayoutNew :: (HasCallStack, MonadIO m) => Rectangle -> Gravity -> Gravity -> m PopupLayout
- popupLayoutRef :: (HasCallStack, MonadIO m) => PopupLayout -> m PopupLayout
- popupLayoutSetAnchorHints :: (HasCallStack, MonadIO m) => PopupLayout -> [AnchorHints] -> m ()
- popupLayoutSetAnchorRect :: (HasCallStack, MonadIO m) => PopupLayout -> Rectangle -> m ()
- popupLayoutSetOffset :: (HasCallStack, MonadIO m) => PopupLayout -> Int32 -> Int32 -> m ()
- popupLayoutSetRectAnchor :: (HasCallStack, MonadIO m) => PopupLayout -> Gravity -> m ()
- popupLayoutSetSurfaceAnchor :: (HasCallStack, MonadIO m) => PopupLayout -> Gravity -> m ()
- popupLayoutUnref :: (HasCallStack, MonadIO m) => PopupLayout -> m ()
Exported types
newtype PopupLayout Source #
Memory-managed wrapper type.
PopupLayout (ManagedPtr PopupLayout) |
Instances
Eq PopupLayout Source # | |
Defined in GI.Gdk.Structs.PopupLayout (==) :: PopupLayout -> PopupLayout -> Bool # (/=) :: PopupLayout -> PopupLayout -> Bool # | |
GBoxed PopupLayout Source # | |
Defined in GI.Gdk.Structs.PopupLayout | |
ManagedPtrNewtype PopupLayout Source # | |
Defined in GI.Gdk.Structs.PopupLayout toManagedPtr :: PopupLayout -> ManagedPtr PopupLayout | |
TypedObject PopupLayout Source # | |
Defined in GI.Gdk.Structs.PopupLayout | |
HasParentTypes PopupLayout Source # | |
Defined in GI.Gdk.Structs.PopupLayout | |
IsGValue (Maybe PopupLayout) Source # | Convert |
Defined in GI.Gdk.Structs.PopupLayout gvalueGType_ :: IO GType gvalueSet_ :: Ptr GValue -> Maybe PopupLayout -> IO () gvalueGet_ :: Ptr GValue -> IO (Maybe PopupLayout) | |
type ParentTypes PopupLayout Source # | |
Defined in GI.Gdk.Structs.PopupLayout |
Methods
Click to display all available methods, including inherited ones
Methods
Getters
getAnchorHints, getAnchorRect, getOffset, getRectAnchor, getSurfaceAnchor.
Setters
setAnchorHints, setAnchorRect, setOffset, setRectAnchor, setSurfaceAnchor.
copy
:: (HasCallStack, MonadIO m) | |
=> PopupLayout |
|
-> m PopupLayout | Returns: a copy of |
Create a new PopupLayout
and copy the contents of layout
into it.
equal
:: (HasCallStack, MonadIO m) | |
=> PopupLayout |
|
-> PopupLayout |
|
-> m Bool | Returns: |
Check whether layout
and other
has identical layout properties.
getAnchorHints
popupLayoutGetAnchorHints Source #
:: (HasCallStack, MonadIO m) | |
=> PopupLayout |
|
-> m [AnchorHints] | Returns: the |
Get the AnchorHints
.
getAnchorRect
popupLayoutGetAnchorRect Source #
:: (HasCallStack, MonadIO m) | |
=> PopupLayout |
|
-> m Rectangle | Returns: The anchor rectangle. |
Get the anchor rectangle.
getOffset
:: (HasCallStack, MonadIO m) | |
=> PopupLayout |
|
-> m (Int32, Int32) |
Retrieves the offset for the anchor rectangle.
getRectAnchor
popupLayoutGetRectAnchor Source #
:: (HasCallStack, MonadIO m) | |
=> PopupLayout |
|
-> m Gravity | Returns: the anchor on the anchor rectangle. |
Returns the anchor position on the anchor rectangle.
getSurfaceAnchor
popupLayoutGetSurfaceAnchor Source #
:: (HasCallStack, MonadIO m) | |
=> PopupLayout |
|
-> m Gravity | Returns: the anchor on the popup surface. |
Returns the anchor position on the popup surface.
new
:: (HasCallStack, MonadIO m) | |
=> Rectangle |
|
-> Gravity |
|
-> Gravity |
|
-> m PopupLayout | Returns: newly created instance of |
Create a popup layout description. Used together with popupPresent
to describe how a popup surface should be placed and behave on-screen.
anchorRect
is relative to the top-left corner of the surface's parent.
rectAnchor
and surfaceAnchor
determine anchor points on anchorRect
and surface to pin together.
The position of anchorRect
's anchor point can optionally be offset using
popupLayoutSetOffset
, which is equivalent to offsetting the
position of surface.
ref
:: (HasCallStack, MonadIO m) | |
=> PopupLayout |
|
-> m PopupLayout | Returns: the same |
Increases the reference count of value
.
setAnchorHints
popupLayoutSetAnchorHints Source #
:: (HasCallStack, MonadIO m) | |
=> PopupLayout |
|
-> [AnchorHints] |
|
-> m () |
Set new anchor hints.
The set anchorHints
determines how surface
will be moved if the anchor
points cause it to move off-screen. For example, AnchorHintsFlipX
will
replace GravityNorthWest
with GravityNorthEast
and vice versa
if surface
extends beyond the left or right edges of the monitor.
setAnchorRect
popupLayoutSetAnchorRect Source #
:: (HasCallStack, MonadIO m) | |
=> PopupLayout |
|
-> Rectangle |
|
-> m () |
Set the anchor rectangle.
setOffset
:: (HasCallStack, MonadIO m) | |
=> PopupLayout |
|
-> Int32 |
|
-> Int32 |
|
-> m () |
Offset the position of the anchor rectangle with the given delta.
setRectAnchor
popupLayoutSetRectAnchor Source #
:: (HasCallStack, MonadIO m) | |
=> PopupLayout |
|
-> Gravity |
|
-> m () |
Set the anchor on the anchor rectangle.
setSurfaceAnchor
popupLayoutSetSurfaceAnchor Source #
:: (HasCallStack, MonadIO m) | |
=> PopupLayout |
|
-> Gravity |
|
-> m () |
Set the anchor on the popup surface.
unref
:: (HasCallStack, MonadIO m) | |
=> PopupLayout |
|
-> m () |
Decreases the reference count of value
.