[][src]Trait pushrod::core::layout_manager::LayoutManager

pub trait LayoutManager {
    fn do_layout(
        &mut self,
        origin: Point,
        size: Size,
        coordinates: LayoutManagerCoordinates
    ) -> LayoutManagerCoordinates;
fn adjust_layout(&mut self, coordinates: LayoutManagerPadding);
fn get_widget_id(&self) -> i32; }

Describes the behavior of a LayoutManager. Layout Managers do not actually manage any Widget objects by themselves, they only apply the rules of the LayoutManagerPadding coordinates, and the size of the LayoutManager that is available.

Required methods

fn do_layout(
    &mut self,
    origin: Point,
    size: Size,
    coordinates: LayoutManagerCoordinates
) -> LayoutManagerCoordinates

This method is called when a new Widget is added to the list, or the layout needs to be re-computed (due to a resize). The origin passed is the origin of the layout manager's top-level Widget, as each LayoutManager requires a Widget against which objects can be added. size indicates the Size of the Widget container, which is the total allowed bounds of the objects within its layout area. coordinates are the coordinates of the Widgets to be resized. Once the compute of all of the coordinates of all of the objects is completed, a new LayoutManagerCoordinates object must be returned, containing the new coordinates of all of the objects within its bounds. See also HorizontalLayoutManager and VerticalLayoutManager for more info.

fn adjust_layout(&mut self, coordinates: LayoutManagerPadding)

This method is used to reset the LayoutManagerCoordinates. Once the layout coordinates are adjusted, the system will automatically call do_layout so that the layout is re-calculated, and the objects are redrawn inside the bounds of the layout box.

fn get_widget_id(&self) -> i32

This function must be overridden to return the ID of the Widget that is stored within the LayoutManager, since the system doesn't have direct access to it.

Loading content...

Implementors

impl LayoutManager for HorizontalLayoutManager[src]

impl LayoutManager for VerticalLayoutManager[src]

Loading content...