pub struct Frame<T> {
pub fitting: Fitting,
/* private fields */
}Expand description
A layout frame that manages rectangular areas with margins and scaling. A frame consists of an outer rectangle, an inner cursor rectangle (available space), and properties that control how child frames are created and positioned.
Fields§
§fitting: FittingControls how children rects are culled when they exceed available space
Implementations§
Source§impl<T> Frame<T>where
T: Num,
impl<T> Frame<T>where
T: Num,
Sourcepub fn new(rect: Rect<T>) -> Self
pub fn new(rect: Rect<T>) -> Self
Creates a new frame with the specified outer rectangle. Initializes with default values for scale (1.0) and margin (5 pixels).
Sourcepub fn rect(&self) -> Rect<T>
pub fn rect(&self) -> Rect<T>
The rect that represents this Frame’s position and size. Does not change when adding child frames.
Sourcepub fn cursor(&self) -> Rect<T>
pub fn cursor(&self) -> Rect<T>
The available space to push_edge more child frames. Shrinks every time a child frame is added.
Sourcepub fn get_margin(&self) -> T
pub fn get_margin(&self) -> T
Returns the current margin value.
Sourcepub fn set_margin(&mut self, margin: T)
pub fn set_margin(&mut self, margin: T)
Sets a new margin value and recalculates the cursor rectangle.
Sourcepub fn divide_width(&self, columns: u32) -> T
pub fn divide_width(&self, columns: u32) -> T
Calculates the size if you divide the available space’s width by “columns”, taking into account the size of the gaps between each column
Sourcepub fn divide_height(&self, rows: u32) -> T
pub fn divide_height(&self, rows: u32) -> T
Calculates the size if you divide the available space’s height by “rows”, taking into account the size of the gaps between each row
Sourcepub fn push_size(
&mut self,
align: Align,
w: T,
h: T,
func: impl FnMut(&mut Frame<T>),
)
pub fn push_size( &mut self, align: Align, w: T, h: T, func: impl FnMut(&mut Frame<T>), )
Attempts to push_edge a rect with size (w,h), if there isn’t enough available space, the rect is scaled down preserving the aspect ratio.
§Parameters
align- Alignment that determines positioning and cursor updatingw- Width of the new frameh- Height of the new framefunc- Closure to execute with the new child frame
Sourcepub fn push_edge(&mut self, edge: Edge, len: T, func: impl FnMut(&mut Frame<T>))
pub fn push_edge(&mut self, edge: Edge, len: T, func: impl FnMut(&mut Frame<T>))
Adds a new frame on the specified edge with specified length.
§Parameters
edge- Which edge to add the child frame tolen- Length of the new framefunc- Closure to execute with the new child frame
Sourcepub fn fill(&mut self, func: impl FnMut(&mut Frame<T>))
pub fn fill(&mut self, func: impl FnMut(&mut Frame<T>))
Fills the entire available cursor with a new Frame.
§Parameters
func- Closure to execute with the new child frame
Sourcepub fn place(
&mut self,
align: Align,
x: T,
y: T,
w: T,
h: T,
func: impl FnMut(&mut Frame<T>),
)
pub fn place( &mut self, align: Align, x: T, y: T, w: T, h: T, func: impl FnMut(&mut Frame<T>), )
Allows arbitrary placement of the new frame in relation to the current frame. Does not modify the available space by default, unless Align is not Center. Scales the frame if necessary to fit.
§Parameters
align- Alignment that determines cursor updatingx- X position of the new frame in relation to this frame.y- Y position of the new frame in relation to this frame.w- Width of the new frameh- Height of the new framefunc- Closure to execute with the new child frame