pub struct VirtualViewCallbackInfo {
pub reason: VirtualViewCallbackReason,
pub system_fonts: *const FcFontCache,
pub image_cache: *const ImageCache,
pub window_theme: WindowTheme,
pub window_frame: WindowFrame,
pub bounds: HidpiAdjustedBounds,
pub materialized: LogicalRect,
pub virtual_rect: LogicalRect,
pub scroll_offset: LogicalPosition,
/* private fields */
}Fields§
§reason: VirtualViewCallbackReason§system_fonts: *const FcFontCache§image_cache: *const ImageCache§window_theme: WindowTheme§window_frame: WindowFrameThe window’s CURRENT frame: normal, minimized, maximized, fullscreen.
Here for the same reason window_theme is: a view whose content
depends on a window-level fact should read that fact, not be handed a
copy of it at build time and then kept in sync. The window control that
has to draw “maximize” or “restore” is the case - a seeded copy is
wrong the moment the window manager maximizes the window itself
(super+up, edge snap, a tiling rule), which never goes through the
button’s own callback.
bounds: HidpiAdjustedBoundsRECT 1 - THE CONTAINER: the VirtualView’s on-screen box, computed by
the framework from the outer DOM. You do not set this; you render into
it.
materialized: LogicalRectRECT 2 - WHAT IS CURRENTLY MATERIALIZED, in VIRTUAL space: the window
you returned last time (origin = where it starts in the document,
size = its extent). Zero-sized on the first invoke.
virtual_rect: LogicalRectRECT 3 - THE DOCUMENT, in VIRTUAL space: the extent you last declared, which is what the scrollbar currently represents.
scroll_offset: LogicalPositionWHERE THE USER IS LOOKING: the live scroll offset in virtual space.
This is the input your “which slice do I render?” math keys off. It was
previously spelled virtual_scroll_offset and the engine hardcoded
that to zero, so apps computing a page index from it always rendered
the first page — one of the two reasons a VirtualView could not
scroll.
Implementations§
Source§impl VirtualViewCallbackInfo
impl VirtualViewCallbackInfo
pub const fn new<'a>( reason: VirtualViewCallbackReason, system_fonts: &'a FcFontCache, image_cache: &'a ImageCache, window_theme: WindowTheme, window_frame: WindowFrame, bounds: HidpiAdjustedBounds, materialized: LogicalRect, virtual_rect: LogicalRect, scroll_offset: LogicalPosition, ) -> Self
Sourcepub const fn set_callable_ptr(&mut self, callable: &OptionRefAny)
pub const fn set_callable_ptr(&mut self, callable: &OptionRefAny)
Set the callable pointer for FFI language bindings
Sourcepub fn set_measure_dom_fn(&mut self, f: MeasureDomFn, ctx: *mut c_void)
pub fn set_measure_dom_fn(&mut self, f: MeasureDomFn, ctx: *mut c_void)
Inject the headless-measure trampoline (called by the layout crate right before the user callback is invoked).
Sourcepub fn measure_dom(&self, dom: Dom, available: LogicalSize) -> LogicalSize
pub fn measure_dom(&self, dom: Dom, available: LogicalSize) -> LogicalSize
Measure a DOM headlessly: style + lay it out against available
constraints using the host window’s fonts and system style, without
touching the live layout. Returns the union of all node bounds.
Use a very tall available.height (e.g. 1_000_000.0) to obtain a
DOM’s natural height at a fixed width - the building block for
virtual-scroll sizing: measure one (or a few) item template(s), then
virtual_scroll_size.height = item_height * item_count and render
only the visible window of items. Each call is a full cold layout
pass, so cache measured sizes per item template.
Returns LogicalSize::zero() when no measure hook was injected.
Sourcepub fn measure_dom_shrink_to_fit(
&self,
dom: Dom,
bound: LogicalSize,
) -> LogicalSize
pub fn measure_dom_shrink_to_fit( &self, dom: Dom, bound: LogicalSize, ) -> LogicalSize
Measure a DOM headlessly at the size its CONTENT asks for: as wide as
its max-content width (no wider than bound), and as tall as that
makes it. The natural-size counterpart of Self::measure_dom,
whose block root stretches to whatever width it is given - so a
label measured that way reports the box, not the text.
This is what a content-sized view returns as its materialized
rect: a text label, a badge, a popup panel. Pass a generous bound
(a few thousand pixels) for “unconstrained”; the view is then laid
out at the size it reports (a VirtualView with width: auto is
sized by what it returns).
Returns LogicalSize::zero() when no measure hook was injected.
Sourcepub fn get_ctx(&self) -> OptionRefAny
pub fn get_ctx(&self) -> OptionRefAny
Get the callable for FFI language bindings (Python, etc.)