Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
GI.Adw.Objects.BreakpointBin
Description
A widget that changes layout based on available size.
<picture> <source srcset="breakpoint-bin-dark.png" media="(prefers-color-scheme: dark)"> <img src="breakpoint-bin.png" alt="breakpoint-bin"> </picture>
AdwBreakpointBin
provides a way to use breakpoints without [classwindow
],
[classapplicationWindow
] or [classdialog
]. It can be useful for limiting
breakpoints to a single page and similar purposes. Most applications
shouldn't need it.
AdwBreakpointBin
is similar to [classbin
]. It has one child, set via the
[propertybreakpointBin
:child] property.
When AdwBreakpointBin
is resized, its child widget can rearrange its layout
at specific thresholds.
The thresholds and layout changes are defined via [classbreakpoint
] objects.
They can be added using [methodbreakpointBin
.add_breakpoint].
Each breakpoint has a condition, specifying the bin's size and/or aspect
ratio, and setters that automatically set object properties when that
happens. The signalbreakpoint
[apply] and signalbreakpoint
[unapply] can
be used instead for more complex scenarios.
Breakpoints are only allowed to modify widgets inside the AdwBreakpointBin
,
but not on the AdwBreakpointBin
itself or any other widgets.
If multiple breakpoints can be used for the current size, the last one is
always picked. The current breakpoint can be tracked using the
[propertybreakpointBin
:current-breakpoint] property.
If none of the breakpoints can be used, that property will be set to NULL
,
and the original property values will be used instead.
Minimum Size
Adding a breakpoint to AdwBreakpointBin
will result in it having no minimum
size. The Widget:widthRequest and
Widget:heightRequest properties must always be set when using
breakpoints, indicating the smallest size you want to support.
The minimum size and breakpoint conditions must be carefully selected so that the child widget completely fits. If it doesn't, it will overflow and a warning message will be printed.
When choosing minimum size, consider translations and text scale factor changes. Make sure to leave enough space for text labels, and enable ellipsizing or wrapping if they might not fit.
For Label
this can be done via Label:ellipsize, or
via Label:wrap together with Label:wrapMode.
For buttons, use Button:canShrink, MenuButton:canShrink, SplitButton:canShrink, or ButtonContent:canShrink.
Example
c code
GtkWidget *bin, *child; AdwBreakpoint *breakpoint; bin = adw_breakpoint_bin_new (); gtk_widget_set_size_request (bin, 150, 150); child = gtk_label_new ("Wide"); gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END); gtk_widget_add_css_class (child, "title-1"); adw_breakpoint_bin_set_child (ADW_BREAKPOINT_BIN (bin), child); breakpoint = adw_breakpoint_new (adw_breakpoint_condition_parse ("max-width: 200px")); adw_breakpoint_add_setters (breakpoint, G_OBJECT (child), "label", "Narrow", NULL); adw_breakpoint_bin_add_breakpoint (ADW_BREAKPOINT_BIN (bin), breakpoint);
The bin has a single label inside it, displaying "Wide". When the bin's width is smaller than or equal to 200px, it changes to "Narrow".
AdwBreakpointBin
as GtkBuildable
AdwBreakpointBin
allows adding AdwBreakpoint
objects as children.
Example of an AdwBreakpointBin
UI definition:
xml code
<object class="AdwBreakpointBin"> <property name="width-request">150</property> <property name="height-request">150</property> <property name="child"> <object class="GtkLabel" id="child"> <property name="label">Wide</property> <property name="ellipsize">end</property> <style> <class name="title-1"/> </style> </object> </property> <child> <object class="AdwBreakpoint"> <condition>max-width: 200px</condition> <setter object="child" property="label">Narrow</setter> </object> </child> </object>
See [classbreakpoint
] documentation for details.
Since: 1.4
Synopsis
- newtype BreakpointBin = BreakpointBin (ManagedPtr BreakpointBin)
- class (GObject o, IsDescendantOf BreakpointBin o) => IsBreakpointBin o
- toBreakpointBin :: (MonadIO m, IsBreakpointBin o) => o -> m BreakpointBin
- breakpointBinAddBreakpoint :: (HasCallStack, MonadIO m, IsBreakpointBin a, IsBreakpoint b) => a -> b -> m ()
- breakpointBinGetChild :: (HasCallStack, MonadIO m, IsBreakpointBin a) => a -> m (Maybe Widget)
- breakpointBinGetCurrentBreakpoint :: (HasCallStack, MonadIO m, IsBreakpointBin a) => a -> m (Maybe Breakpoint)
- breakpointBinNew :: (HasCallStack, MonadIO m) => m BreakpointBin
- breakpointBinRemoveBreakpoint :: (HasCallStack, MonadIO m, IsBreakpointBin a, IsBreakpoint b) => a -> b -> m ()
- breakpointBinSetChild :: (HasCallStack, MonadIO m, IsBreakpointBin a, IsWidget b) => a -> Maybe b -> m ()
- clearBreakpointBinChild :: (MonadIO m, IsBreakpointBin o) => o -> m ()
- constructBreakpointBinChild :: (IsBreakpointBin o, MonadIO m, IsWidget a) => a -> m (GValueConstruct o)
- getBreakpointBinChild :: (MonadIO m, IsBreakpointBin o) => o -> m (Maybe Widget)
- setBreakpointBinChild :: (MonadIO m, IsBreakpointBin o, IsWidget a) => o -> a -> m ()
- getBreakpointBinCurrentBreakpoint :: (MonadIO m, IsBreakpointBin o) => o -> m (Maybe Breakpoint)
Exported types
newtype BreakpointBin Source #
Memory-managed wrapper type.
Constructors
BreakpointBin (ManagedPtr BreakpointBin) |
Instances
class (GObject o, IsDescendantOf BreakpointBin o) => IsBreakpointBin o Source #
Type class for types which can be safely cast to BreakpointBin
, for instance with toBreakpointBin
.
Instances
(GObject o, IsDescendantOf BreakpointBin o) => IsBreakpointBin o Source # | |
Defined in GI.Adw.Objects.BreakpointBin |
toBreakpointBin :: (MonadIO m, IsBreakpointBin o) => o -> m BreakpointBin Source #
Cast to BreakpointBin
, 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
Methods
actionSetEnabled, activate, activateAction, activateDefault, addBreakpoint, addController, addCssClass, addMnemonicLabel, 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, removeBreakpoint, removeController, removeCssClass, removeMnemonicLabel, removeTickCallback, resetProperty, resetRelation, resetState, runDispose, shouldLayout, show, sizeAllocate, snapshotChild, stealData, stealQdata, thawNotify, translateCoordinates, triggerTooltipQuery, unmap, unparent, unrealize, unref, unsetStateFlags, updateNextAccessibleSibling, updateProperty, updateRelation, updateState, watchClosure.
Getters
getAccessibleParent, getAccessibleRole, getAllocatedBaseline, getAllocatedHeight, getAllocatedWidth, getAllocation, getAncestor, getAtContext, getBaseline, getBounds, getBuildableId, getCanFocus, getCanTarget, getChild, getChildVisible, getClipboard, getColor, getCssClasses, getCssName, getCurrentBreakpoint, getCursor, getData, getDirection, getDisplay, getFirstAccessibleChild, getFirstChild, getFocusChild, getFocusOnClick, getFocusable, getFontMap, getFontOptions, getFrameClock, getHalign, getHasTooltip, getHeight, getHexpand, getHexpandSet, getLastChild, getLayoutManager, getMapped, getMarginBottom, getMarginEnd, getMarginStart, getMarginTop, 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, setCssClasses, setCursor, setCursorFromName, setData, setDataFull, setDirection, setFocusChild, setFocusOnClick, setFocusable, setFontMap, setFontOptions, setHalign, setHasTooltip, setHexpand, setHexpandSet, setLayoutManager, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setName, setOpacity, setOverflow, setParent, setProperty, setReceivesDefault, setSensitive, setSizeRequest, setStateFlags, setTooltipMarkup, setTooltipText, setValign, setVexpand, setVexpandSet, setVisible.
addBreakpoint
breakpointBinAddBreakpoint Source #
Arguments
:: (HasCallStack, MonadIO m, IsBreakpointBin a, IsBreakpoint b) | |
=> a |
|
-> b |
|
-> m () |
Adds breakpoint
to self
.
Since: 1.4
getChild
breakpointBinGetChild Source #
Arguments
:: (HasCallStack, MonadIO m, IsBreakpointBin a) | |
=> a |
|
-> m (Maybe Widget) | Returns: the child widget of |
Gets the child widget of self
.
Since: 1.4
getCurrentBreakpoint
breakpointBinGetCurrentBreakpoint Source #
Arguments
:: (HasCallStack, MonadIO m, IsBreakpointBin a) | |
=> a |
|
-> m (Maybe Breakpoint) | Returns: the current breakpoint |
Gets the current breakpoint.
Since: 1.4
new
Arguments
:: (HasCallStack, MonadIO m) | |
=> m BreakpointBin | Returns: the newly created |
Creates a new AdwBreakpointBin
.
Since: 1.4
removeBreakpoint
breakpointBinRemoveBreakpoint Source #
Arguments
:: (HasCallStack, MonadIO m, IsBreakpointBin a, IsBreakpoint b) | |
=> a |
|
-> b |
|
-> m () |
Removes breakpoint
from self
.
Since: 1.5
setChild
breakpointBinSetChild Source #
Arguments
:: (HasCallStack, MonadIO m, IsBreakpointBin a, IsWidget b) | |
=> a |
|
-> Maybe b |
|
-> m () |
Sets the child widget of self
.
Since: 1.4
Properties
child
The child widget.
Since: 1.4
clearBreakpointBinChild :: (MonadIO m, IsBreakpointBin o) => o -> m () Source #
Set the value of the “child
” property to Nothing
.
When overloading is enabled, this is equivalent to
clear
#child
constructBreakpointBinChild :: (IsBreakpointBin 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
.
getBreakpointBinChild :: (MonadIO m, IsBreakpointBin o) => o -> m (Maybe Widget) Source #
Get the value of the “child
” property.
When overloading is enabled, this is equivalent to
get
breakpointBin #child
setBreakpointBinChild :: (MonadIO m, IsBreakpointBin o, IsWidget a) => o -> a -> m () Source #
Set the value of the “child
” property.
When overloading is enabled, this is equivalent to
set
breakpointBin [ #child:=
value ]
currentBreakpoint
The current breakpoint.
Since: 1.4
getBreakpointBinCurrentBreakpoint :: (MonadIO m, IsBreakpointBin o) => o -> m (Maybe Breakpoint) Source #
Get the value of the “current-breakpoint
” property.
When overloading is enabled, this is equivalent to
get
breakpointBin #currentBreakpoint