class Adw::WrapLayout

Overview

A box-like layout that can wrap into multiple lines.

wrap-box

Adw::WrapLayout is similar to Gtk::BoxLayout, but can wrap lines when the widgets cannot fit otherwise. Unlike Gtk::FlowBox, the children aren't arranged into a grid and behave more like words in a wrapping label.

Like Gtk::BoxLayout, Adw::WrapLayout is orientable and has spacing:

::: note Unlike Gtk::BoxLayout, Adw::WrapLayout 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 Gtk::Popover.

Normally, a horizontal Adw::WrapLayout 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 WrapLayout::align property.

Lines can be justified using the 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, Adw::WrapLayout 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 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 #WrapBox.

Included Modules

Defined in:

lib/gi-crystal/src/auto/adw-1/wrap_layout.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from module Gtk::Orientable

orientation : Gtk::Orientation orientation, orientation=(orientation : Gtk::Orientation) : Nil orientation=, to_unsafe to_unsafe

Constructor methods inherited from module Gtk::Orientable

cast(obj : GObject::Object) : self cast

Class methods inherited from module Gtk::Orientable

cast?(obj : GObject::Object) : self | Nil cast?, g_type : UInt64 g_type

Instance methods inherited from class Gtk::LayoutManager

==(other : self) ==, allocate(widget : Gtk::Widget, width : Int32, height : Int32, baseline : Int32) : Nil allocate, hash(hasher) hash, layout_changed : Nil layout_changed, layout_child(child : Gtk::Widget) : Gtk::LayoutChild layout_child, measure(widget : Gtk::Widget, orientation : Gtk::Orientation, for_size : Int32) : Nil measure, request_mode : Gtk::SizeRequestMode request_mode, widget : Gtk::Widget | Nil widget

Constructor methods inherited from class Gtk::LayoutManager

new new

Class methods inherited from class Gtk::LayoutManager

g_type : UInt64 g_type

Instance methods inherited from class GObject::Object

==(other : self) ==, bind_property(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags) : GObject::Binding bind_property, bind_property_full(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags, transform_to : GObject::Closure, transform_from : GObject::Closure) : GObject::Binding bind_property_full, data(key : String) : Pointer(Void) | Nil data, finalize finalize, freeze_notify : Nil freeze_notify, getv(names : Enumerable(String), values : Enumerable(_)) : Nil getv, hash(hasher) hash, notify(property_name : String) : Nil notify, notify_by_pspec(pspec : GObject::ParamSpec) : Nil notify_by_pspec, notify_signal notify_signal, property(property_name : String, value : _) : Nil property, qdata(quark : UInt32) : Pointer(Void) | Nil qdata, ref_count : UInt32 ref_count, run_dispose : Nil run_dispose, set_data(key : String, data : Pointer(Void) | Nil) : Nil set_data, set_property(property_name : String, value : _) : Nil set_property, steal_data(key : String) : Pointer(Void) | Nil steal_data, steal_qdata(quark : UInt32) : Pointer(Void) | Nil steal_qdata, thaw_notify : Nil thaw_notify, to_unsafe : Pointer(Void) to_unsafe, watch_closure(closure : GObject::Closure) : Nil watch_closure

Constructor methods inherited from class GObject::Object

cast(obj : GObject::Object) : self cast, new(pointer : Pointer(Void), transfer : GICrystal::Transfer)
new
new
, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self newv

Class methods inherited from class GObject::Object

cast?(obj : GObject::Object) : self | Nil cast?, compat_control(what : UInt64, data : Pointer(Void) | Nil) : UInt64 compat_control, g_type : UInt64 g_type, interface_find_property(g_iface : GObject::TypeInterface, property_name : String) : GObject::ParamSpec interface_find_property, interface_list_properties(g_iface : GObject::TypeInterface) : Enumerable(GObject::ParamSpec) interface_list_properties

Macros inherited from class GObject::Object

previous_vfunc(*args) previous_vfunc, previous_vfunc!(*args) previous_vfunc!, signal(signature) signal

Constructor Detail

def self.new : self #

Creates a new Adw::WrapLayout.


def self.new(*, align : Float32 | Nil = nil, child_spacing : Int32 | Nil = nil, child_spacing_unit : Adw::LengthUnit | Nil = nil, justify : Adw::JustifyMode | Nil = nil, justify_last_line : Bool | Nil = nil, line_homogeneous : Bool | Nil = nil, line_spacing : Int32 | Nil = nil, line_spacing_unit : Adw::LengthUnit | Nil = nil, natural_line_length : Int32 | Nil = nil, natural_line_length_unit : Adw::LengthUnit | Nil = nil, orientation : Gtk::Orientation | Nil = nil, pack_direction : Adw::PackDirection | Nil = nil, wrap_policy : Adw::WrapPolicy | Nil = nil, wrap_reverse : Bool | Nil = nil) #

Class Method Detail

def self.g_type : UInt64 #

Returns the type id (GType) registered in GLib type system.


Instance Method Detail

def ==(other : self) #
Description copied from class Reference

Returns true if this reference is the same as other. Invokes same?.


def align : Float32 #

Gets the alignment of the children within each line.


def align=(align : Float32) : Nil #

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 to ADW_JUSTIFY_NONE, or on the last line when the [property@WrapLayout:justify-last-line] is FALSE.


def child_spacing : Int32 #

Gets spacing between widgets on the same line.


def child_spacing=(child_spacing : Int32) : Nil #

Sets the spacing between widgets on the same line.

See [property@WrapLayout:child-spacing-unit].


def child_spacing_unit : Adw::LengthUnit #

Gets the length unit for child spacing.


def child_spacing_unit=(unit : Adw::LengthUnit) : Nil #

Sets the length unit for child spacing.

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

See [property@WrapLayout:child-spacing].


def hash(hasher) #
Description copied from class Reference

See Object#hash(hasher)


def justify : Adw::JustifyMode #

Gets whether and how each complete line is stretched to fill the entire widget.


def justify=(justify : Adw::JustifyMode) : Nil #

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 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.


def justify_last_line : Bool #

Gets whether the last line should be stretched to fill the entire widget.


def justify_last_line=(justify_last_line : Bool) : Nil #

Sets whether the last line should be stretched to fill the entire widget.

See WrapLayout::justify.


def justify_last_line? : Bool #

def line_homogeneous : Bool #

Gets whether all lines should take the same amount of space.


def line_homogeneous=(homogeneous : Bool) : Nil #

Sets whether all lines should take the same amount of space.


def line_homogeneous? : Bool #

def line_spacing : Int32 #

Gets the spacing between lines.


def line_spacing=(line_spacing : Int32) : Nil #

Sets the spacing between lines.

See [property@WrapLayout:line-spacing-unit].


def line_spacing_unit : Adw::LengthUnit #

Gets the length unit for line spacing.


def line_spacing_unit=(unit : Adw::LengthUnit) : Nil #

Sets the length unit for line spacing.

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

See [property@WrapLayout:line-spacing].


def natural_line_length : Int32 #

Gets the natural size for each line.


def natural_line_length=(natural_line_length : Int32) : Nil #

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].


def natural_line_length_unit : Adw::LengthUnit #

Gets the length unit for line spacing.


def natural_line_length_unit=(unit : Adw::LengthUnit) : Nil #

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].


def pack_direction : Adw::PackDirection #

Gets the direction children are packed in each line.


def pack_direction=(pack_direction : Adw::PackDirection) : Nil #

Sets the direction children are packed in each line.


def wrap_policy : Adw::WrapPolicy #

Gets the policy for line wrapping.


def wrap_policy=(wrap_policy : Adw::WrapPolicy) : Nil #

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.


def wrap_reverse : Bool #

Gets whether wrap direction is reversed.


def wrap_reverse=(wrap_reverse : Bool) : Nil #

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.


def wrap_reverse? : Bool #