Skip to main content

MenuLayout

Struct MenuLayout 

Source
pub struct MenuLayout { /* private fields */ }
Expand description

Re-exported for the same reason: menu_skin returns a MenuSkin, and a caller that can name this crate’s menu art should not have to add a second dependency to lay out and draw the menu it skins. It is also what lets an end-to-end suite that depends on this crate take a golden image of the real menu rather than of a replica. One frame’s placement of a menu: the panel, the title and every button, in screen pixels.

Produced by Menu::layout and consumed by Menu::render, for the art and the text alike. Carrying the MenuStyle it was built with is what stops the two being measured with different metrics — the failure that puts a label a scale out of step with the frame around it.

Implementations§

Source§

impl MenuLayout

Source

pub const fn style(&self) -> &MenuStyle

The style this layout was measured with.

Source

pub const fn screen(&self) -> Vec2

The framebuffer this was laid out in, in pixels.

Source

pub const fn panel(&self) -> (Vec2, Vec2)

The window frame’s rectangle: (min, max) in screen pixels.

Source

pub fn panel_size(&self) -> Vec2

The panel’s size in pixels.

Source

pub fn panel_centre(&self) -> Vec2

The middle of the panel, in screen pixels.

Source

pub const fn title_pos(&self) -> Vec2

Where the title’s em box starts.

Source

pub fn items(&self) -> &[MenuItemLayout]

Every button, in the order they are drawn.

In a scrolled list every row is here, where the scroll put it: a row scrolled out of view lies outside the viewport, and outside the panel too, and is neither drawn nor hit — see shows.

Source

pub fn viewport(&self) -> Option<(Vec2, Vec2)>

Where a scrolled item list shows its rows: (min, max) in screen pixels, inside the panel. None when the list is not scrolled and every row is in view.

A row is drawn cut at this rectangle’s edges and hit only inside it.

Source

pub fn scroll(&self) -> f32

How far the item list is scrolled, in pixels: zero unless it scrolls.

Source

pub fn shows(&self, index: usize) -> bool

Whether row index is at least partly in view, and so drawn and hit. Every row is, unless the list scrolls; no row past the last is.

Source

pub fn scrim(&self) -> (Vec2, Vec2)

The whole framebuffer, as the rectangle the scrim covers.

Trait Implementations§

Source§

impl Clone for MenuLayout

Source§

fn clone(&self) -> MenuLayout

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for MenuLayout

Source§

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

Formats the value using the given formatter. Read more
Source§

impl PartialEq for MenuLayout

Source§

fn eq(&self, other: &MenuLayout) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for MenuLayout

Auto Trait Implementations§

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> HalThreadSafe for T
where T: Send + Sync,

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.