Trait layout_engine::Layout

source ·
pub trait Layout {
    // Required methods
    fn width_for_height(&self, height: usize) -> usize;
    fn height_for_width(&self, width: usize) -> usize;
    fn prefered_size(&self) -> Vec2;

    // Provided method
    fn prefered_size_of_container(&self, container: Vec2) -> Vec2 { ... }
}
Expand description

A layout trait

It uses height to width management like Gtk

Required Methods§

source

fn width_for_height(&self, height: usize) -> usize

Given a height, how much width would this like to have at minimum.

source

fn height_for_width(&self, width: usize) -> usize

Given a width, how much height would this like to have at minimum.

source

fn prefered_size(&self) -> Vec2

What would this widget like to have in an ideal world.

This should be the minimum which isn’t too small

Provided Methods§

source

fn prefered_size_of_container(&self, container: Vec2) -> Vec2

How would this widget choose to allocate itself given the parent’s size

Implementations on Foreign Types§

source§

impl<T: Layout> Layout for &T

Implementors§