Klasse WrapLayout

Alle implementierten Schnittstellen:
PointerInterface

public class WrapLayout extends LayoutManager
A box-like layout that can wrap into multiple lines.

<picture>
<source srcset="wrap-box-dark.png" media="(prefers-color-scheme: dark)">
<img src="wrap-box.png" alt="wrap-box">
</picture>

`AdwWrapLayout` is similar to [class@Gtk.BoxLayout], but can wrap lines when
the widgets cannot fit otherwise. Unlike [class@Gtk.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:

- [property@WrapLayout:child-spacing] between children in the same line;
- [property@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].

https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.WrapLayout.html

  • Konstruktordetails

    • WrapLayout

      public WrapLayout(PointerContainer pointer)
    • WrapLayout

      public WrapLayout()
      Creates a new `AdwWrapLayout`.
  • Methodendetails

    • getClassHandler

      public static ClassHandler getClassHandler()
    • getAlign

      public float getAlign()
      Gets the alignment of the children within each line.
      Gibt zurück:
      the child alignment
    • getChildSpacing

      public int getChildSpacing()
      Gets spacing between widgets on the same line.
      Gibt zurück:
      spacing between widgets on the same line
    • getChildSpacingUnit

      public int getChildSpacingUnit()
      Gets the length unit for child spacing.
      Gibt zurück:
      the length unit
    • getJustify

      public int getJustify()
      Gets whether and how each complete line is stretched to fill the entire widget.
      Gibt zurück:
      the justify mode
    • getJustifyLastLine

      public boolean getJustifyLastLine()
      Gets whether the last line should be stretched to fill the entire widget.
      Gibt zurück:
      whether the last line is justified
    • getLineHomogeneous

      public boolean getLineHomogeneous()
      Gets whether all lines should take the same amount of space.
      Gibt zurück:
      whether lines should be homogeneous
    • getLineSpacing

      public int getLineSpacing()
      Gets the spacing between lines.
      Gibt zurück:
      the line spacing
    • getLineSpacingUnit

      public int getLineSpacingUnit()
      Gets the length unit for line spacing.
      Gibt zurück:
      the length unit
    • getNaturalLineLength

      public int getNaturalLineLength()
      Gets the natural size for each line.
      Gibt zurück:
      the natural length
    • getNaturalLineLengthUnit

      public int getNaturalLineLengthUnit()
      Gets the length unit for line spacing.
      Gibt zurück:
      the length unit
    • getPackDirection

      public int getPackDirection()
      Gets the direction children are packed in each line.
      Gibt zurück:
      the line direction
    • getWrapPolicy

      public int getWrapPolicy()
      Gets the policy for line wrapping.
      Gibt zurück:
      the wrap policy
    • getWrapReverse

      public boolean getWrapReverse()
      Gets whether wrap direction is reversed.
      Gibt zurück:
      whether wrap direction is reversed
    • 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 [property@WrapLayout:justify] is set to
      `ADW_JUSTIFY_NONE`, or on the last line when the
      [property@WrapLayout:justify-last-line] is `FALSE`.
      Parameter:
      align - the child alignment
    • setChildSpacing

      public void setChildSpacing(int child_spacing)
      Sets the spacing between widgets on the same line.

      See [property@WrapLayout:child-spacing-unit].
      Parameter:
      child_spacing - the child spacing
    • setChildSpacingUnit

      public void setChildSpacingUnit(int unit)
      Sets the length unit for child spacing.

      Allows the spacing to vary depending on the text scale factor.

      See [property@WrapLayout:child-spacing].
      Parameter:
      unit - the length unit
    • setJustify

      public void setJustify(int justify)
      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 to
      [property@WrapLayout:align].

      By default this doesn't affect the last line, as it will be incomplete. Use
      [property@WrapLayout:justify-last-line] to justify it as well.
      Parameter:
      justify - the justify mode
    • setJustifyLastLine

      public void setJustifyLastLine(boolean justify_last_line)
      Sets whether the last line should be stretched to fill the entire widget.

      See [property@WrapLayout:justify].
      Parameter:
      justify_last_line - whether to justify the last line
    • setLineHomogeneous

      public void setLineHomogeneous(boolean homogeneous)
      Sets whether all lines should take the same amount of space.
      Parameter:
      homogeneous - whether lines should be homogeneous
    • setLineSpacing

      public void setLineSpacing(int line_spacing)
      Sets the spacing between lines.

      See [property@WrapLayout:line-spacing-unit].
      Parameter:
      line_spacing - the line spacing
    • setLineSpacingUnit

      public void setLineSpacingUnit(int unit)
      Sets the length unit for line spacing.

      Allows the spacing to vary depending on the text scale factor.

      See [property@WrapLayout:line-spacing].
      Parameter:
      unit - the length unit
    • setNaturalLineLength

      public void setNaturalLineLength(int natural_line_length)
      Sets the natural size for each line.

      It should be used to limit the line lengths, for example when used in
      popovers.

      See [property@WrapLayout:natural-line-length-unit].
      Parameter:
      natural_line_length - the natural length
    • setNaturalLineLengthUnit

      public void setNaturalLineLengthUnit(int unit)
      Sets the length unit for natural line length.

      Allows the length to vary depending on the text scale factor.

      See [property@WrapLayout:natural-line-length].
      Parameter:
      unit - the length unit
    • setPackDirection

      public void setPackDirection(int pack_direction)
      Sets the direction children are packed in each line.
      Parameter:
      pack_direction - the new line direction
    • setWrapPolicy

      public void setWrapPolicy(int wrap_policy)
      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.
      Parameter:
      wrap_policy - the new wrap policy
    • setWrapReverse

      public void setWrapReverse(boolean wrap_reverse)
      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.
      Parameter:
      wrap_reverse - whether to reverse wrap direction
    • asOrientable

      public Orientable asOrientable()
      Implements interface Orientable. Call this to get access to interface functions.
      Gibt zurück:
      Orientable
    • getTypeID

      public static long getTypeID()
    • getParentTypeID

      public static long getParentTypeID()
    • getTypeSize

      public static TypeSystem.TypeSize getTypeSize()
    • getParentTypeSize

      public static TypeSystem.TypeSize getParentTypeSize()
    • getInstanceSize

      public static int getInstanceSize()