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>
impl<'a> LayoutInfo<'a>
Sourcepub fn get_gl_context(&self) -> Rc<dyn Gl>
pub fn get_gl_context(&self) -> Rc<dyn Gl>
Returns a reference-counted pointer to the OpenGL context
Source§impl<'a> LayoutInfo<'a>
impl<'a> LayoutInfo<'a>
Sourcepub fn window_width_larger_than(&mut self, width: f32) -> bool
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.