[−][src]Struct azul_core::callbacks::LayoutInfo
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:
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,