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§
Sourcefn insert_widget(&mut self, _widget_id: i32, _widget_position: LayoutPosition)
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.
Sourcefn append_widget(&mut self, _widget_id: i32)
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.
Sourcefn set_padding(&mut self, padding: PaddingConstraint)
fn set_padding(&mut self, padding: PaddingConstraint)
Changes the PaddingConstraint for this Layout.
Sourcefn get_padding(&self) -> PaddingConstraint
fn get_padding(&self) -> PaddingConstraint
Retrieves the current PaddingConstraint.
Sourcefn do_layout(&mut self, _widgets: &[WidgetContainer])
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.
Sourcefn needs_layout(&self) -> bool
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§
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.
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.
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.