Trait Layout

Source
pub trait Layout {
    // Required methods
    fn insert_widget(
        &mut self,
        _widget_id: i32,
        _widget_position: LayoutPosition,
    );
    fn append_widget(&mut self, _widget_id: i32);
    fn set_padding(&mut self, padding: PaddingConstraint);
    fn get_padding(&self) -> PaddingConstraint;
    fn do_layout(&mut self, _widgets: &[WidgetContainer]);
    fn needs_layout(&self) -> bool;
}
Expand description

This is a Layout trait that is used by the Engine service, which stores a list of Widgets, their positions (based on matrix coordinates), and an entry point to trigger the layout compute action.

Required Methods§

Source

fn insert_widget(&mut self, _widget_id: i32, _widget_position: LayoutPosition)

Adds a Widget by ID to the Layout manager, given its LayoutPosition, as a position marker in the manager.

Source

fn append_widget(&mut self, _widget_id: i32)

Adds a Widget by ID to the Layout manager, automatically adding it to the next available LayoutPosition. Use this as a way to add a widget if you don’t need to specify a LayoutPosition.

Source

fn set_padding(&mut self, padding: PaddingConstraint)

Changes the PaddingConstraint for this Layout.

Source

fn get_padding(&self) -> PaddingConstraint

Retrieves the current PaddingConstraint.

Source

fn do_layout(&mut self, _widgets: &[WidgetContainer])

Performs a layout, applying the WidgetContainer list at the time, so that referenced Widgets can be adjusted as necessary.

Source

fn needs_layout(&self) -> bool

Indicates whether or not the Layout needs to have do_layout re-run. This is generally needed when the LayoutPosition changes, or when PaddingConstraints change.

Implementors§

Source§

impl Layout for GridLayout

This is the Layout implementation for the GridLayout manager. This Layout manager will not reposition any objects within the bounds of the Layout until at least 2 objects have been added to the bounds of the Layout.

Source§

impl Layout for HorizontalLayout

This is the Layout implementation for the HorizontalLayout manager. This Layout manager will not reposition any objects within the bounds of the Layout until at least 2 objects have been added to the bounds of the Layout.

Source§

impl Layout for VerticalLayout

This is the Layout implementation for the VerticalLayout manager. This Layout manager will not reposition any objects within the bounds of the Layout until at least 2 objects have been added to the bounds of the Layout.