pub struct PaintCtx<'a> { /* private fields */ }Expand description
Context passed to Widget::paint: resolved geometry, frame-request
signals that bubble into a PaintOutcome, and root-threaded globals.
Implementations§
Source§impl<'a> PaintCtx<'a>
impl<'a> PaintCtx<'a>
Sourcepub const MAX_PACED_INTERVAL: Duration
pub const MAX_PACED_INTERVAL: Duration
Ceiling on paced intervals: above every real cadence, far below where
the shells’ pacing arithmetic (interval * 2, nanos as u64) overflows.
Sourcepub fn new(origin: Point, size: Size) -> Self
pub fn new(origin: Point, size: Size) -> Self
Create a paint context at origin/size with a zero clock and no theme.
Sourcepub fn with_theme(self, theme: &'a dyn Any) -> Self
pub fn with_theme(self, theme: &'a dyn Any) -> Self
Attach the app’s active theme, type-erased (widget tests).
Sourcepub fn with_translucent(self, translucent: bool) -> Self
pub fn with_translucent(self, translucent: bool) -> Self
Mark the pass as painting a translucent surface (widget tests).
Sourcepub fn with_retained_ledger(self, ledger: &'a RetainedLedger) -> Self
pub fn with_retained_ledger(self, ledger: &'a RetainedLedger) -> Self
Thread a resident-key ledger into the pass (widget tests).
Sourcepub fn theme_as<T: Any>(&self) -> Option<&T>
pub fn theme_as<T: Any>(&self) -> Option<&T>
Recover the theme as &T, or None if absent or of another type.
Sourcepub fn window_insets(&self) -> WindowInsets
pub fn window_insets(&self) -> WindowInsets
The window insets for this paint pass.
Sourcepub fn with_window_insets<R>(
&mut self,
insets: WindowInsets,
f: impl FnOnce(&mut Self) -> R,
) -> R
pub fn with_window_insets<R>( &mut self, insets: WindowInsets, f: impl FnOnce(&mut Self) -> R, ) -> R
Run f with insets as the window insets, then restore them; wrapping
paint_child hands the override to the whole subtree.
Sourcepub fn presented_frames(&self) -> Option<u64>
pub fn presented_frames(&self) -> Option<u64>
The shell’s count of frames actually presented, or None. An FPS meter
differences this (wrapping_sub), not its own paint count.
Sourcepub fn origin(&self) -> Point
pub fn origin(&self) -> Point
The widget’s absolute window-space origin — the one to anchor overlays
and reported rects from (ChildPod::origin is parent-relative).
Sourcepub fn has_focus(&self) -> bool
pub fn has_focus(&self) -> bool
Whether the widget holds the focus path — authoritative at paint, since
a container-routed blur never reaches the widget’s event().
Sourcepub fn shortcut_hints(&self) -> Rc<[ShortcutHint]>
pub fn shortcut_hints(&self) -> Rc<[ShortcutHint]>
The previous paint’s shortcut declarations, as BuildCtx::shortcut_hints returns them;
empty on a context its root did not seed.
Sourcepub fn is_focused_for_ring(&self) -> bool
pub fn is_focused_for_ring(&self) -> bool
Whether to draw a focus ring: PaintCtx::has_focus and the root’s
FocusRingPolicy allowing one right now.
Sourcepub fn is_hovered(&self) -> bool
pub fn is_hovered(&self) -> bool
Whether this widget or a descendant is on the hover path (CSS :hover).
Authoritative: the widget the pointer left gets no event, so a hover
consumer self-corrects from this each paint.
Sourcepub fn frame_time(&self) -> FrameTime
pub fn frame_time(&self) -> FrameTime
The shell clock for this frame; only ever difference it against a stored earlier value.
Sourcepub fn request_frame(&mut self)
pub fn request_frame(&mut self)
Request another frame because paint advanced animation state
(TickClass::Transition).
Sourcepub fn request_frame_paced(&mut self)
pub fn request_frame_paced(&mut self)
Request a pacable (TickClass::CosmeticLoop) frame at the theme’s
cosmetic_loop_rate.
Sourcepub fn request_frame_paced_at(&mut self, interval: Duration)
pub fn request_frame_paced_at(&mut self, interval: Duration)
Request a pacable repaint at most once per interval (a caret blink).
Intervals fold to the minimum, so a slow request never starves a fast
one; capped at Self::MAX_PACED_INTERVAL.
Sourcepub fn request_frame_class(&mut self, class: TickClass)
pub fn request_frame_class(&mut self, class: TickClass)
Request a frame of an explicit TickClass.
Sourcepub fn needs_frame(&self) -> bool
pub fn needs_frame(&self) -> bool
Whether a continuation frame was requested during this (sub)paint.
Sourcepub fn frame_class(&self) -> Option<TickClass>
pub fn frame_class(&self) -> Option<TickClass>
The aggregate TickClass requested, or None if no frame was.
Sourcepub fn needs_frame_paced_only(&self) -> bool
pub fn needs_frame_paced_only(&self) -> bool
Whether every frame request was TickClass::CosmeticLoop (paceable).
Sourcepub fn paced_interval(&self) -> Option<Duration>
pub fn paced_interval(&self) -> Option<Duration>
The tightest paced interval named, or None; both mean the theme rate.
Sourcepub fn request_layout(&mut self)
pub fn request_layout(&mut self)
Request layout next frame because this paint’s animation changes layout;
implies an unpaced Self::request_frame.
Sourcepub fn needs_layout(&self) -> bool
pub fn needs_layout(&self) -> bool
Whether a layout re-run was requested during this (sub)paint.
Sourcepub fn publish_ime_state(&mut self, state: ImeState)
pub fn publish_ime_state(&mut self, state: ImeState)
Publish the focused editable’s IME surface, so an app-driven change that never crosses the event pass still reaches the shell.
Sourcepub fn take_ime_state(&mut self) -> Option<ImeState>
pub fn take_ime_state(&mut self) -> Option<ImeState>
Take the IME surface published during this (sub)paint, if any.
Sourcepub fn publish_platform_view(&mut self, frame: PlatformViewFrame)
pub fn publish_platform_view(&mut self, frame: PlatformViewFrame)
Publish a platform-view slot’s frame (pushed; many slots per pass).
Sourcepub fn take_platform_views(&mut self) -> Vec<PlatformViewFrame>
pub fn take_platform_views(&mut self) -> Vec<PlatformViewFrame>
Take (and clear) every platform-view frame published this (sub)paint.
Sourcepub fn report_input_shield(&mut self, rect: Rect)
pub fn report_input_shield(&mut self, rect: Rect)
Report an absolute rect where frust content over a platform-view slot keeps winning input (a “z-shield”); the shell differ assigns it to slots.
Sourcepub fn take_input_shields(&mut self) -> Vec<Rect>
pub fn take_input_shields(&mut self) -> Vec<Rect>
Take (and clear) every z-shield rect reported this (sub)paint.
Sourcepub fn register_overlay(&mut self, entry: OverlayEntry)
pub fn register_overlay(&mut self, entry: OverlayEntry)
Float entry’s pod above the app this frame and register it for input
routing. The root paints it after the main tree, so the owner must not;
the registry clears each pass, so the owner re-registers every paint.
Sourcepub fn register_shortcut(&mut self, decl: ShortcutDecl)
pub fn register_shortcut(&mut self, decl: ShortcutDecl)
Declare a keyboard shortcut for this frame (see crate::shortcuts). The table clears
each paint, so the declarer re-declares every paint; it answers its own
InputEvent::Shortcut with Handled.
Sourcepub fn publish_selection_toolbar(&mut self, request: SelectionToolbarRequest)
pub fn publish_selection_toolbar(&mut self, request: SelectionToolbarRequest)
Publish this frame’s focused-field verbs and menu anchor for the platform edit menu. A focused field publishes every paint, so hardware shortcuts stay answerable; no publish means nothing is focused.
Sourcepub fn report_hero(&mut self, tag: &str, bounds: Rect) -> HeroDirective
pub fn report_hero(&mut self, tag: &str, bounds: Rect) -> HeroDirective
Report a hero’s absolute bounds and read back its directive; a no-op
returning HeroDirective::Normal with no reporter installed.
Sourcepub fn hero_active(&self) -> bool
pub fn hero_active(&self) -> bool
Whether a hero reporter is installed (culling containers stop culling).
Sourcepub fn with_hero_registry(
&mut self,
registry: &RefCell<HeroFrames>,
f: impl FnOnce(&mut PaintCtx<'_>),
)
pub fn with_hero_registry( &mut self, registry: &RefCell<HeroFrames>, f: impl FnOnce(&mut PaintCtx<'_>), )
Run f with registry as the hero reporter; requests and publications
inside bubble back onto self.
Sourcepub fn visible_rect(&self) -> Option<Rect>
pub fn visible_rect(&self) -> Option<Rect>
The absolute visible rect for culling, or None (paint everything).
Sourcepub fn constrain_visible_rect(&mut self, rect: Rect)
pub fn constrain_visible_rect(&mut self, rect: Rect)
Constrain the visible rect to rect (absolute); nested rects intersect.
Sourcepub fn is_translucent(&self) -> bool
pub fn is_translucent(&self) -> bool
Whether the shell surface is translucent (“Mode B”); the hole-punch clears only then.
Sourcepub fn paint_serial(&self) -> u64
pub fn paint_serial(&self) -> u64
The serial the root minted for this pass (0 with no root), echoed by
the ledger’s frame.
Sourcepub fn retained_available(
&self,
key: RetainedKey,
rect_px: Size,
scale: f32,
recorded_serial: u64,
) -> bool
pub fn retained_available( &self, key: RetainedKey, rect_px: Size, scale: f32, recorded_serial: u64, ) -> bool
Whether the renderer holds a page for key at rect_px and scale, per
a ledger covering recorded_serial (guarding against a stale ledger).
Sourcepub fn subtree_clean(&self, pod: &ChildPod) -> bool
pub fn subtree_clean(&self, pod: &ChildPod) -> bool
Whether nothing under pod changed since its last paint (ask about the
child pod); hover and focus moves bump the paint epoch.
Sourcepub fn retained_enabled(&self) -> bool
pub fn retained_enabled(&self) -> bool
Whether a boundary may bracket its body (retained layers on, ledger set).
Sourcepub fn paint_publications(&self) -> u32
pub fn paint_publications(&self) -> u32
Side-channel publications (IME, platform view, shield, overlay, toolbar, hero) this (sub)paint made; a body that published must not be replayed.