Struct Frame

Source
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: Fitting

Controls how children rects are culled when they exceed available space

Implementations§

Source§

impl<T> Frame<T>
where T: Num,

Source

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).

Source

pub fn rect(&self) -> Rect<T>

The rect that represents this Frame’s position and size. Does not change when adding child frames.

Source

pub fn cursor(&self) -> Rect<T>

The available space to push_edge more child frames. Shrinks every time a child frame is added.

Source

pub fn get_margin(&self) -> T

Returns the current margin value.

Source

pub fn set_margin(&mut self, margin: T)

Sets a new margin value and recalculates the cursor rectangle.

Source

pub fn get_gap(&self) -> T

Returns the current gap value.

Source

pub fn set_gap(&mut self, gap: T)

Sets a new gap value.

Source

pub fn get_scale(&self) -> f32

Returns the current scale factor.

Source

pub fn set_scale(&mut self, scale: f32)

Sets a new scale factor for the frame.

Source

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

Source

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

Source

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 updating
  • w - Width of the new frame
  • h - Height of the new frame
  • func - Closure to execute with the new child frame
Source

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 to
  • len - Length of the new frame
  • func - Closure to execute with the new child frame
Source

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
Source

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 updating
  • x - 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 frame
  • h - Height of the new frame
  • func - Closure to execute with the new child frame

Trait Implementations§

Source§

impl<T: Clone> Clone for Frame<T>

Source§

fn clone(&self) -> Frame<T>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for Frame<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Frame<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Frame<T>
where T: RefUnwindSafe,

§

impl<T> Send for Frame<T>
where T: Send,

§

impl<T> Sync for Frame<T>
where T: Sync,

§

impl<T> Unpin for Frame<T>
where T: Unpin,

§

impl<T> UnwindSafe for Frame<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.