Skip to main content

PaintCtx

Struct PaintCtx 

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

Source

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.

Source

pub fn new(origin: Point, size: Size) -> PaintCtx<'a>

Create a paint context at origin/size with a zero clock and no theme.

Source

pub fn with_theme(self, theme: &'a (dyn Any + 'static)) -> PaintCtx<'a>

Attach the app’s active theme, type-erased (widget tests).

Source

pub fn with_translucent(self, translucent: bool) -> PaintCtx<'a>

Mark the pass as painting a translucent surface (widget tests).

Source

pub fn with_retained_ledger(self, ledger: &'a RetainedLedger) -> PaintCtx<'a>

Thread a resident-key ledger into the pass (widget tests).

Source

pub fn theme_as<T>(&self) -> Option<&T>
where T: Any,

Recover the theme as &T, or None if absent or of another type.

Source

pub fn window_insets(&self) -> WindowInsets

The window insets for this paint pass.

Source

pub fn with_window_insets<R>( &mut self, insets: WindowInsets, f: impl FnOnce(&mut PaintCtx<'a>) -> R, ) -> R

Run f with insets as the window insets, then restore them; wrapping paint_child hands the override to the whole subtree.

Source

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.

Source

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

Source

pub fn size(&self) -> Size

The widget’s resolved size.

Source

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

Source

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.

Source

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.

Source

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.

Source

pub fn frame_time(&self) -> FrameTime

The shell clock for this frame; only ever difference it against a stored earlier value.

Source

pub fn request_frame(&mut self)

Request another frame because paint advanced animation state (TickClass::Transition).

Source

pub fn request_frame_paced(&mut self)

Request a pacable (TickClass::CosmeticLoop) frame at the theme’s cosmetic_loop_rate.

Source

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.

Source

pub fn request_frame_class(&mut self, class: TickClass)

Request a frame of an explicit TickClass.

Source

pub fn needs_frame(&self) -> bool

Whether a continuation frame was requested during this (sub)paint.

Source

pub fn frame_class(&self) -> Option<TickClass>

The aggregate TickClass requested, or None if no frame was.

Source

pub fn needs_frame_paced_only(&self) -> bool

Whether every frame request was TickClass::CosmeticLoop (paceable).

Source

pub fn paced_interval(&self) -> Option<Duration>

The tightest paced interval named, or None; both mean the theme rate.

Source

pub fn request_layout(&mut self)

Request layout next frame because this paint’s animation changes layout; implies an unpaced Self::request_frame.

Source

pub fn needs_layout(&self) -> bool

Whether a layout re-run was requested during this (sub)paint.

Source

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.

Source

pub fn take_ime_state(&mut self) -> Option<ImeState>

Take the IME surface published during this (sub)paint, if any.

Source

pub fn publish_platform_view(&mut self, frame: PlatformViewFrame)

Publish a platform-view slot’s frame (pushed; many slots per pass).

Source

pub fn take_platform_views(&mut self) -> Vec<PlatformViewFrame>

Take (and clear) every platform-view frame published this (sub)paint.

Source

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.

Source

pub fn take_input_shields(&mut self) -> Vec<Rect>

Take (and clear) every z-shield rect reported this (sub)paint.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn hero_active(&self) -> bool

Whether a hero reporter is installed (culling containers stop culling).

Source

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.

Source

pub fn visible_rect(&self) -> Option<Rect>

The absolute visible rect for culling, or None (paint everything).

Source

pub fn constrain_visible_rect(&mut self, rect: Rect)

Constrain the visible rect to rect (absolute); nested rects intersect.

Source

pub fn is_translucent(&self) -> bool

Whether the shell surface is translucent (“Mode B”); the hole-punch clears only then.

Source

pub fn paint_serial(&self) -> u64

The serial the root minted for this pass (0 with no root), echoed by the ledger’s frame.

Source

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

Source

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.

Source

pub fn retained_enabled(&self) -> bool

Whether a boundary may bracket its body (retained layers on, ledger set).

Source

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.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for PaintCtx<'a>

§

impl<'a> !Send for PaintCtx<'a>

§

impl<'a> !Sync for PaintCtx<'a>

§

impl<'a> !UnwindSafe for PaintCtx<'a>

§

impl<'a> Freeze for PaintCtx<'a>

§

impl<'a> Unpin for PaintCtx<'a>

§

impl<'a> UnsafeUnpin for PaintCtx<'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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T> StorageAccess<T> for T

Source§

fn as_borrowed(&self) -> &T

Borrows the value.
Source§

fn into_taken(self) -> T

Takes the value.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more