Class WrapLayout
- All Implemented Interfaces:
Proxy
,Orientable
AdwWrapLayout
is similar to BoxLayout
, but can wrap lines when
the widgets cannot fit otherwise. Unlike FlowBox
, the children
aren't arranged into a grid and behave more like words in a wrapping label.
Like GtkBoxLayout
, AdwWrapLayout
is orientable and has spacing:
WrapLayout:child-spacing
between children in the same line;WrapLayout:line-spacing
between lines.
Note
Unlike GtkBoxLayout
, AdwWrapLayout
cannot follow the CSS
border-spacing
property.
Use the [property@WrapLayout:natural-line-length] property to determine the
layout's natural size, e.g. when using it in a [class@Gtk.Popover].
Normally, a horizontal AdwWrapLayout
wraps left to right and top to bottom
for left-to-right languages. Both of these directions can be reversed, using
the [property@WrapLayout:pack-direction] and
[property@WrapLayout:wrap-reverse] properties. Additionally, the alignment
of each line can be controlled with the [property@WrapLayout:align] property.
Lines can be justified using the [property@WrapLayout:justify] property,
filling the entire line by either increasing child size or spacing depending
on the value. Set [property@WrapLayout:justify-last-line] to justify the last
line as well.
By default, AdwWrapLayout
wraps as soon as the previous line cannot fit
any more children without shrinking them past their natural size. Set
[property@WrapLayout:wrap-policy] to [enum@Adw.WrapPolicy.MINIMUM] to only
wrap once all the children in the previous line have been shrunk to their
minimum size.
To make each line take the same amount of space, set
[property@WrapLayout:line-homogeneous] to TRUE
.
Spacing and natural line length can scale with the text scale factor, use the
[property@WrapLayout:child-spacing-unit],
[property@WrapLayout:line-spacing-unit] and/or
[property@WrapLayout:natural-line-length-unit] properties to enable that
behavior.
See [class@WrapBox].
- Since:
- 1.7
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
WrapLayout.Builder<B extends WrapLayout.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static class
Nested classes/interfaces inherited from class org.gnome.gtk.LayoutManager
LayoutManager.LayoutManagerClass, LayoutManager.LayoutManagerImpl
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
Nested classes/interfaces inherited from interface org.gnome.gtk.Orientable
Orientable.OrientableIface, Orientable.OrientableImpl
-
Field Summary
Fields inherited from class io.github.jwharm.javagi.base.ProxyInstance
address
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new WrapLayout.WrapLayout
(MemorySegment address) Create a WrapLayout proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected WrapLayout
asParent()
Returns this instance as if it were its parent type.static WrapLayout.Builder
<? extends WrapLayout.Builder> builder()
AWrapLayout.Builder
object constructs aWrapLayout
with the specified properties.float
getAlign()
Gets the alignment of the children within each line.int
Gets spacing between widgets on the same line.Gets the length unit for child spacing.Gets whether and how each complete line is stretched to fill the entire widget.boolean
Gets whether the last line should be stretched to fill the entire widget.boolean
Gets whether all lines should take the same amount of space.int
Gets the spacing between lines.Gets the length unit for line spacing.int
Gets the natural size for each line.Gets the length unit for line spacing.Gets the direction children are packed in each line.static Type
getType()
Get the GType of the WrapLayout classGets the policy for line wrapping.boolean
Gets whether wrap direction is reversed.void
setAlign
(float align) Sets the alignment of the children within each line.void
setChildSpacing
(int childSpacing) Sets the spacing between widgets on the same line.void
Sets the length unit for child spacing.void
setJustify
(JustifyMode justify) Sets whether and how each complete line should be stretched to fill the entire widget.void
setJustifyLastLine
(boolean justifyLastLine) Sets whether the last line should be stretched to fill the entire widget.void
setLineHomogeneous
(boolean homogeneous) Sets whether all lines should take the same amount of space.void
setLineSpacing
(int lineSpacing) Sets the spacing between lines.void
setLineSpacingUnit
(LengthUnit unit) Sets the length unit for line spacing.void
setNaturalLineLength
(int naturalLineLength) Sets the natural size for each line.void
Sets the length unit for natural line length.void
setPackDirection
(PackDirection packDirection) Sets the direction children are packed in each line.void
setWrapPolicy
(WrapPolicy wrapPolicy) Sets the policy for line wrapping.void
setWrapReverse
(boolean wrapReverse) Sets whether wrap direction should be reversed.Methods inherited from class org.gnome.gtk.LayoutManager
allocate, createLayoutChild, getLayoutChild, getMemoryLayout, getRequestMode, getRequestMode, getWidget, layoutChanged, measure, root, unroot
Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newv, notify_, notify_, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.gnome.gtk.Orientable
getOrientation, setOrientation
-
Constructor Details
-
WrapLayout
Create a WrapLayout proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
WrapLayout
public WrapLayout()Creates a new WrapLayout.
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type.- Overrides:
asParent
in classLayoutManager
-
getAlign
public float getAlign()Gets the alignment of the children within each line.- Returns:
- the child alignment
- Since:
- 1.7
-
getChildSpacing
public int getChildSpacing()Gets spacing between widgets on the same line.- Returns:
- spacing between widgets on the same line
- Since:
- 1.7
-
getChildSpacingUnit
Gets the length unit for child spacing.- Returns:
- the length unit
- Since:
- 1.7
-
getJustify
Gets whether and how each complete line is stretched to fill the entire widget.- Returns:
- the justify mode
- Since:
- 1.7
-
getJustifyLastLine
public boolean getJustifyLastLine()Gets whether the last line should be stretched to fill the entire widget.- Returns:
- whether the last line is justified
- Since:
- 1.7
-
getLineHomogeneous
public boolean getLineHomogeneous()Gets whether all lines should take the same amount of space.- Returns:
- whether lines should be homogeneous
- Since:
- 1.7
-
getLineSpacing
public int getLineSpacing()Gets the spacing between lines.- Returns:
- the line spacing
- Since:
- 1.7
-
getLineSpacingUnit
Gets the length unit for line spacing.- Returns:
- the length unit
- Since:
- 1.7
-
getNaturalLineLength
public int getNaturalLineLength()Gets the natural size for each line.- Returns:
- the natural length
- Since:
- 1.7
-
getNaturalLineLengthUnit
Gets the length unit for line spacing.- Returns:
- the length unit
- Since:
- 1.7
-
getPackDirection
Gets the direction children are packed in each line.- Returns:
- the line direction
- Since:
- 1.7
-
getWrapPolicy
Gets the policy for line wrapping.- Returns:
- the wrap policy
- Since:
- 1.7
-
getWrapReverse
public boolean getWrapReverse()Gets whether wrap direction is reversed.- Returns:
- whether wrap direction is reversed
- Since:
- 1.7
-
setAlign
public void setAlign(float align) Sets the alignment of the children within each line.0 means the children are placed at the start of the line, 1 means they are placed at the end of the line. 0.5 means they are placed in the middle of the line.
Alignment is only used when
WrapLayout:justify
is set toADW_JUSTIFY_NONE
, or on the last line when theWrapLayout:justify-last-line
isFALSE
.- Parameters:
align
- the child alignment- Since:
- 1.7
-
setChildSpacing
public void setChildSpacing(int childSpacing) Sets the spacing between widgets on the same line.See
WrapLayout:child-spacing-unit
.- Parameters:
childSpacing
- the child spacing- Since:
- 1.7
-
setChildSpacingUnit
Sets the length unit for child spacing.Allows the spacing to vary depending on the text scale factor.
See
WrapLayout:child-spacing
.- Parameters:
unit
- the length unit- Since:
- 1.7
-
setJustify
Sets whether and how each complete line should be stretched to fill the entire widget.If set to
ADW_JUSTIFY_FILL
, each widget in the line will be stretched, keeping consistent spacing, so that the line fills the entire widget.If set to
ADW_JUSTIFY_SPREAD
, the spacing between widgets will be increased, keeping widget sizes intact. The first and last widget will be aligned with the beginning and end of the line. If the line only contains a single widget, it will be stretched regardless.If set to
ADW_JUSTIFY_NONE
, the line will not be stretched and the children will be placed together within the line, according toWrapLayout:align
.By default this doesn't affect the last line, as it will be incomplete. Use
WrapLayout:justify-last-line
to justify it as well.- Parameters:
justify
- the justify mode- Since:
- 1.7
-
setJustifyLastLine
public void setJustifyLastLine(boolean justifyLastLine) Sets whether the last line should be stretched to fill the entire widget.See
WrapLayout:justify
.- Parameters:
justifyLastLine
- whether to justify the last line- Since:
- 1.7
-
setLineHomogeneous
public void setLineHomogeneous(boolean homogeneous) Sets whether all lines should take the same amount of space.- Parameters:
homogeneous
- whether lines should be homogeneous- Since:
- 1.7
-
setLineSpacing
public void setLineSpacing(int lineSpacing) Sets the spacing between lines.See
WrapLayout:line-spacing-unit
.- Parameters:
lineSpacing
- the line spacing- Since:
- 1.7
-
setLineSpacingUnit
Sets the length unit for line spacing.Allows the spacing to vary depending on the text scale factor.
See
WrapLayout:line-spacing
.- Parameters:
unit
- the length unit- Since:
- 1.7
-
setNaturalLineLength
public void setNaturalLineLength(int naturalLineLength) Sets the natural size for each line.It should be used to limit the line lengths, for example when used in popovers.
See
WrapLayout:natural-line-length-unit
.- Parameters:
naturalLineLength
- the natural length- Since:
- 1.7
-
setNaturalLineLengthUnit
Sets the length unit for natural line length.Allows the length to vary depending on the text scale factor.
See
WrapLayout:natural-line-length
.- Parameters:
unit
- the length unit- Since:
- 1.7
-
setPackDirection
Sets the direction children are packed in each line.- Parameters:
packDirection
- the new line direction- Since:
- 1.7
-
setWrapPolicy
Sets the policy for line wrapping.If set to
ADW_WRAP_NATURAL
, the box will wrap to the next line as soon as the previous line cannot fit any more children without shrinking them past their natural size.If set to
ADW_WRAP_MINIMUM
, the box will try to fit as many children into each line as possible, shrinking them down to their minimum size before wrapping to the next line.- Parameters:
wrapPolicy
- the new wrap policy- Since:
- 1.7
-
setWrapReverse
public void setWrapReverse(boolean wrapReverse) Sets whether wrap direction should be reversed.By default, lines wrap downwards in a horizontal box, and towards the end in a vertical box. If set to
TRUE
, they wrap upwards or towards the start respectively.- Parameters:
wrapReverse
- whether to reverse wrap direction- Since:
- 1.7
-
builder
AWrapLayout.Builder
object constructs aWrapLayout
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withWrapLayout.Builder.build()
.
-