azul_core::callbacks

Struct LayoutInfo

Source
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,
}
Expand description

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 OpenGL context - 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§

Source§

impl<'a> LayoutInfo<'a>

Source

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

Returns a reference-counted pointer to the OpenGL context

Source§

impl<'a> LayoutInfo<'a>

Source

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

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:

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.

Source

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

Source

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

Source

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

Auto Trait Implementations§

§

impl<'a> Freeze for LayoutInfo<'a>

§

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§

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