gi-gtk4-4.0.12: Gtk 4.x bindings

Copyright | Will Thompson and Iñaki García Etxebarria
License | LGPL-2.1
Maintainer | Iñaki García Etxebarria
Safe Haskell | None
Language | Haskell2010

GI.Gtk.Objects.Overlay

Contents

- Exported types
- Methods
  - addOverlay
  - getChild
  - getClipOverlay
  - getMeasureOverlay
  - new
  - removeOverlay
  - setChild
  - setClipOverlay
  - setMeasureOverlay
- Properties
  - child
- Signals
  - getChildPosition

Description

Places “overlay” widgets on top of a single main child.

<picture> <source srcset="overlay-dark.png" media="(prefers-color-scheme: dark)"> <img alt="An example GtkOverlay" src="overlay.png"> </picture>

The position of each overlay widget is determined by its Widget:halign and Widget:valign properties. E.g. a widget with both alignments set to `AlignStart` will be placed at the top left corner of the `GtkOverlay` container, whereas an overlay with halign set to `AlignCenter` and valign set to `AlignEnd` will be placed a the bottom edge of the `GtkOverlay`, horizontally centered. The position can be adjusted by setting the margin properties of the child to non-zero values.

More complicated placement of overlays is possible by connecting to the Overlay::getChildPosition signal.

An overlay’s minimum and natural sizes are those of its main child. The sizes of overlay children are not considered when measuring these preferred sizes.

# GtkOverlay as GtkBuildable

The `GtkOverlay` implementation of the `GtkBuildable` interface supports placing a child as an overlay by specifying “overlay” as the “type” attribute of a `<child>` element.

# CSS nodes

`GtkOverlay` has a single CSS node with the name “overlay”. Overlay children whose alignments cause them to be positioned at an edge get the style classes “.left”, “.right”, “.top”, and/or “.bottom” according to their position.

Synopsis

- newtype Overlay = Overlay (ManagedPtr Overlay)
- class (GObject o, IsDescendantOf Overlay o) => IsOverlay o
- toOverlay :: (MonadIO m, IsOverlay o) => o -> m Overlay
- overlayAddOverlay :: (HasCallStack, MonadIO m, IsOverlay a, IsWidget b) => a -> b -> m ()
- overlayGetChild :: (HasCallStack, MonadIO m, IsOverlay a) => a -> m (Maybe Widget)
- overlayGetClipOverlay :: (HasCallStack, MonadIO m, IsOverlay a, IsWidget b) => a -> b -> m Bool
- overlayGetMeasureOverlay :: (HasCallStack, MonadIO m, IsOverlay a, IsWidget b) => a -> b -> m Bool
- overlayNew :: (HasCallStack, MonadIO m) => m Overlay
- overlayRemoveOverlay :: (HasCallStack, MonadIO m, IsOverlay a, IsWidget b) => a -> b -> m ()
- overlaySetChild :: (HasCallStack, MonadIO m, IsOverlay a, IsWidget b) => a -> Maybe b -> m ()
- overlaySetClipOverlay :: (HasCallStack, MonadIO m, IsOverlay a, IsWidget b) => a -> b -> Bool -> m ()
- overlaySetMeasureOverlay :: (HasCallStack, MonadIO m, IsOverlay a, IsWidget b) => a -> b -> Bool -> m ()
- clearOverlayChild :: (MonadIO m, IsOverlay o) => o -> m ()
- constructOverlayChild :: (IsOverlay o, MonadIO m, IsWidget a) => a -> m (GValueConstruct o)
- getOverlayChild :: (MonadIO m, IsOverlay o) => o -> m (Maybe Widget)
- setOverlayChild :: (MonadIO m, IsOverlay o, IsWidget a) => o -> a -> m ()
- type OverlayGetChildPositionCallback = Widget -> IO (Bool, Rectangle)
- afterOverlayGetChildPosition :: (IsOverlay a, MonadIO m) => a -> ((?self :: a) => OverlayGetChildPositionCallback) -> m SignalHandlerId
- onOverlayGetChildPosition :: (IsOverlay a, MonadIO m) => a -> ((?self :: a) => OverlayGetChildPositionCallback) -> m SignalHandlerId

# Exported types

newtype Overlay Source #

Memory-managed wrapper type.

Constructors

Overlay (ManagedPtr Overlay) |

#### Instances

Instances details

Eq Overlay Source # |
Instance details Defined in GI.Gtk.Objects.Overlay Methods (==) :: Overlay -> Overlay -> Bool Source # (/=) :: Overlay -> Overlay -> Bool Source #
GObject Overlay Source # |
Instance details Defined in GI.Gtk.Objects.Overlay
ManagedPtrNewtype Overlay Source # |
Instance details Defined in GI.Gtk.Objects.Overlay Methods toManagedPtr :: Overlay -> ManagedPtr Overlay Source #
TypedObject Overlay Source # |
Instance details Defined in GI.Gtk.Objects.Overlay Methods glibType :: IO GType Source #
HasParentTypes Overlay Source # |
Instance details Defined in GI.Gtk.Objects.Overlay
IsGValue (Maybe Overlay) Source # | Convert `Overlay` to and from `GValue`. See `toGValue` and `fromGValue`.
Instance details Defined in GI.Gtk.Objects.Overlay Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> Maybe Overlay -> IO () Source # gvalueGet_ :: Ptr GValue -> IO (Maybe Overlay) Source #
type ParentTypes Overlay Source # |
Instance details Defined in GI.Gtk.Objects.Overlay type ParentTypes Overlay = '[Widget, Object, Accessible, Buildable, ConstraintTarget]

class (GObject o, IsDescendantOf Overlay o) => IsOverlay o Source #

Type class for types which can be safely cast to `Overlay`, for instance with `toOverlay`.

#### Instances

Instances details

(GObject o, IsDescendantOf Overlay o) => IsOverlay o Source # |
Instance details Defined in GI.Gtk.Objects.Overlay

toOverlay :: (MonadIO m, IsOverlay o) => o -> m Overlay Source #

Cast to `Overlay`, for types for which this is known to be safe. For general casts, use `castTo`.

# Methods

### Click to display all available methods, including inherited ones

Expand

#### Methods

actionSetEnabled, activate, activateAction, activateDefault, addController, addCssClass, addMnemonicLabel, addOverlay, addTickCallback, allocate, announce, bindProperty, bindPropertyFull, childFocus, computeBounds, computeExpand, computePoint, computeTransform, contains, createPangoContext, createPangoLayout, disposeTemplate, dragCheckThreshold, errorBell, forceFloating, freezeNotify, getv, grabFocus, hasCssClass, hasDefault, hasFocus, hasVisibleFocus, hide, inDestruction, initTemplate, insertActionGroup, insertAfter, insertBefore, isAncestor, isDrawable, isFloating, isFocus, isSensitive, isVisible, keynavFailed, listMnemonicLabels, map, measure, mnemonicActivate, notify, notifyByPspec, observeChildren, observeControllers, pick, queueAllocate, queueDraw, queueResize, realize, ref, refSink, removeController, removeCssClass, removeMnemonicLabel, removeOverlay, removeTickCallback, resetProperty, resetRelation, resetState, runDispose, shouldLayout, show, sizeAllocate, snapshotChild, stealData, stealQdata, thawNotify, translateCoordinates, triggerTooltipQuery, unmap, unparent, unrealize, unref, unsetStateFlags, updateNextAccessibleSibling, updatePlatformState, updateProperty, updateRelation, updateState, watchClosure.

#### Getters

getAccessibleId, getAccessibleParent, getAccessibleRole, getAllocatedBaseline, getAllocatedHeight, getAllocatedWidth, getAllocation, getAncestor, getAtContext, getBaseline, getBounds, getBuildableId, getCanFocus, getCanTarget, getChild, getChildVisible, getClipOverlay, getClipboard, getColor, getCssClasses, getCssName, getCursor, getData, getDirection, getDisplay, getFirstAccessibleChild, getFirstChild, getFocusChild, getFocusOnClick, getFocusable, getFontMap, getFontOptions, getFrameClock, getHalign, getHasTooltip, getHeight, getHexpand, getHexpandSet, getLastChild, getLayoutManager, getLimitEvents, getMapped, getMarginBottom, getMarginEnd, getMarginStart, getMarginTop, getMeasureOverlay, getName, getNative, getNextAccessibleSibling, getNextSibling, getOpacity, getOverflow, getPangoContext, getParent, getPlatformState, getPreferredSize, getPrevSibling, getPrimaryClipboard, getProperty, getQdata, getRealized, getReceivesDefault, getRequestMode, getRoot, getScaleFactor, getSensitive, getSettings, getSize, getSizeRequest, getStateFlags, getStyleContext, getTemplateChild, getTooltipMarkup, getTooltipText, getValign, getVexpand, getVexpandSet, getVisible, getWidth.

#### Setters

setAccessibleParent, setCanFocus, setCanTarget, setChild, setChildVisible, setClipOverlay, setCssClasses, setCursor, setCursorFromName, setData, setDataFull, setDirection, setFocusChild, setFocusOnClick, setFocusable, setFontMap, setFontOptions, setHalign, setHasTooltip, setHexpand, setHexpandSet, setLayoutManager, setLimitEvents, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setMeasureOverlay, setName, setOpacity, setOverflow, setParent, setProperty, setReceivesDefault, setSensitive, setSizeRequest, setStateFlags, setTooltipMarkup, setTooltipText, setValign, setVexpand, setVexpandSet, setVisible.

## addOverlay

overlayAddOverlay Source #

Arguments

:: (HasCallStack, MonadIO m, IsOverlay a, IsWidget b) |
=> a | `overlay`: a `GtkOverlay`
-> b | `widget`: a `GtkWidget` to be added to the container
-> m () |

Adds `widget` to `overlay`.

The widget will be stacked on top of the main widget added with `overlaySetChild`.

The position at which `widget` is placed is determined from its Widget:halign and Widget:valign properties.

## getChild

overlayGetChild Source #

Arguments

:: (HasCallStack, MonadIO m, IsOverlay a) |
=> a | `overlay`: a `GtkOverlay`
-> m (Maybe Widget) | Returns: the child widget of `overlay`

Gets the child widget of `overlay`.

## getClipOverlay

overlayGetClipOverlay Source #

Arguments

:: (HasCallStack, MonadIO m, IsOverlay a, IsWidget b) |
=> a | `overlay`: a `GtkOverlay`
-> b | `widget`: an overlay child of `GtkOverlay`
-> m Bool | Returns: whether the widget is clipped within the parent.

Gets whether `widget` should be clipped within the parent.

## getMeasureOverlay

overlayGetMeasureOverlay Source #

Arguments

:: (HasCallStack, MonadIO m, IsOverlay a, IsWidget b) |
=> a | `overlay`: a `GtkOverlay`
-> b | `widget`: an overlay child of `GtkOverlay`
-> m Bool | Returns: whether the widget is measured

Gets whether `widget`'s size is included in the measurement of `overlay`.

## new

overlayNew Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> m Overlay | Returns: a new `GtkOverlay` object.

Creates a new `GtkOverlay`.

## removeOverlay

overlayRemoveOverlay Source #

Arguments

:: (HasCallStack, MonadIO m, IsOverlay a, IsWidget b) |
=> a | `overlay`: a `GtkOverlay`
-> b | `widget`: a `GtkWidget` to be removed
-> m () |

Removes an overlay that was added with `overlayAddOverlay`.

## setChild

overlaySetChild Source #

Arguments

:: (HasCallStack, MonadIO m, IsOverlay a, IsWidget b) |
=> a | `overlay`: a `GtkOverlay`
-> Maybe b | `child`: the child widget
-> m () |

Sets the child widget of `overlay`.

## setClipOverlay

overlaySetClipOverlay Source #

Arguments

:: (HasCallStack, MonadIO m, IsOverlay a, IsWidget b) |
=> a | `overlay`: a `GtkOverlay`
-> b | `widget`: an overlay child of `GtkOverlay`
-> Bool | `clipOverlay`: whether the child should be clipped
-> m () |

Sets whether `widget` should be clipped within the parent.

## setMeasureOverlay

overlaySetMeasureOverlay Source #

Arguments

:: (HasCallStack, MonadIO m, IsOverlay a, IsWidget b) |
=> a | `overlay`: a `GtkOverlay`
-> b | `widget`: an overlay child of `GtkOverlay`
-> Bool | `measure`: whether the child should be measured
-> m () |

Sets whether `widget` is included in the measured size of `overlay`.

The overlay will request the size of the largest child that has this property set to `True`. Children who are not included may be drawn outside of `overlay`'s allocation if they are too large.

# Properties

## child

The main child widget.

clearOverlayChild :: (MonadIO m, IsOverlay o) => o -> m () Source #

Set the value of the “`child`” property to `Nothing`. When overloading is enabled, this is equivalent to

    clear #child

constructOverlayChild :: (IsOverlay o, MonadIO m, IsWidget a) => a -> m (GValueConstruct o) Source #

Construct a `GValueConstruct` with valid value for the “`child`” property. This is rarely needed directly, but it is used by `new`.

getOverlayChild :: (MonadIO m, IsOverlay o) => o -> m (Maybe Widget) Source #

Get the value of the “`child`” property. When overloading is enabled, this is equivalent to

    get overlay #child

setOverlayChild :: (MonadIO m, IsOverlay o, IsWidget a) => o -> a -> m () Source #

Set the value of the “`child`” property. When overloading is enabled, this is equivalent to

    set overlay [ #child := value ]

# Signals

## getChildPosition

type OverlayGetChildPositionCallback Source #

Arguments

= Widget | `widget`: the child widget to position
-> IO (Bool, Rectangle) | Returns: `True` if the `allocation` has been filled

Emitted to determine the position and size of any overlay child widgets.

A handler for this signal should fill `allocation` with the desired position and size for `widget`, relative to the 'main' child of `overlay`.

The default handler for this signal uses the `widget`'s halign and valign properties to determine the position and gives the widget its natural size (except that an alignment of `AlignFill` will cause the overlay to be full-width/height). If the main child is a `GtkScrolledWindow`, the overlays are placed relative to its contents.

afterOverlayGetChildPosition :: (IsOverlay a, MonadIO m) => a -> ((?self :: a) => OverlayGetChildPositionCallback) -> m SignalHandlerId Source #

Connect a signal handler for the getChildPosition signal, to be run after the default handler. When overloading is enabled, this is equivalent to

    after overlay #getChildPosition callback

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit `?self` parameter. Note that this requires activating the `ImplicitParams` GHC extension.

onOverlayGetChildPosition :: (IsOverlay a, MonadIO m) => a -> ((?self :: a) => OverlayGetChildPositionCallback) -> m SignalHandlerId Source #

Connect a signal handler for the getChildPosition signal, to be run before the default handler. When overloading is enabled, this is equivalent to

    on overlay #getChildPosition callback