[][src]Struct azul_core::callbacks::LayoutInfo

pub struct LayoutInfo<'a> {
    pub window_size: &'a WindowSize,
    pub window_size_width_stops: &'a mut Vec<f32>,
    pub window_size_height_stops: &'a mut Vec<f32>,
    pub gl_context: Rc<dyn Gl>,
    pub resources: &'a AppResources,
}

Gives the layout() function access to the AppResources and the Window (for querying images and fonts, as well as width / height)

Fields

window_size: &'a WindowSize

Window size (so that apps can return a different UI depending on the window size - mobile / desktop view). Should be later removed in favor of "resize" handlers and @media queries.

window_size_width_stops: &'a mut Vec<f32>

Optimization for resizing: If a DOM has no Iframes and the window size does not change the state of the UI, then resizing the window will not result in calls to the .layout() function (since the resulting UI would stay the same).

Stores "stops" in logical pixels where the UI needs to be re-generated should the width of the window change.

window_size_height_stops: &'a mut Vec<f32>

Same as window_size_width_stops but for the height of the window.

gl_context: Rc<dyn Gl>

An Rc to the original WindowContext - this is only so that the user can create textures and other OpenGL content in the window

resources: &'a AppResources

Allows the layout() function to reference app resources such as FontIDs or ImageIDs

Implementations

impl<'a> LayoutInfo<'a>[src]

pub fn get_gl_context(&self) -> Rc<dyn Gl>[src]

Returns a reference-counted pointer to the OpenGL context

impl<'a> LayoutInfo<'a>[src]

pub fn window_width_larger_than(&mut self, width: f32) -> bool[src]

Returns whether the window width is larger than width, but sets an internal "dirty" flag - so that the UI is re-generated when the window is resized above or below width.

For example:

This example is not tested
fn layout(info: LayoutInfo<T>) -> Dom {
    if info.window_width_larger_than(720.0) {
        render_desktop_ui()
    } else {
        render_mobile_ui()
    }
}

Here, the UI is dependent on the width of the window, so if the window resizes above or below 720px, the layout() function needs to be called again. Internally Azul stores the 720.0 and only calls the .layout() function again if the window resizes above or below the value.

NOTE: This should be later depreceated into On::Resize handlers and @media queries.

pub fn window_width_smaller_than(&mut self, width: f32) -> bool[src]

pub fn window_height_larger_than(&mut self, height: f32) -> bool[src]

pub fn window_height_smaller_than(&mut self, height: f32) -> bool[src]

Auto Trait Implementations

impl<'a> !RefUnwindSafe for LayoutInfo<'a>

impl<'a> !Send for LayoutInfo<'a>

impl<'a> !Sync for LayoutInfo<'a>

impl<'a> Unpin for LayoutInfo<'a>

impl<'a> !UnwindSafe for LayoutInfo<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.