Skip to main content

SceneItemPaintContext

Struct SceneItemPaintContext 

Source
pub struct SceneItemPaintContext<'a> {
    pub view_transform: Transform2D,
    pub dirty_scene_rect: Option<Rect>,
    pub text_scale: f32,
    pub theme: &'a Theme,
    pub window_active: bool,
    pub enabled: bool,
}
Expand description

Context handed to SceneItem::paint.

view_transform is the composed pan/zoom/rotation of the SceneView that’s painting this item; the canvas already has the item’s scene_transform pushed, so paint methods work in local coords without further matrix math.

theme, window_active, and enabled mirror the widget-tier PaintContext so lightweight items can resolve theme-aware colours exactly like widgets do — call some_color_prop.resolve(ctx.theme, ctx.enabled) in paint. theme is already the fully-projected theme for this pass (the render walker swaps in the inactive-window / high-contrast variant before handing it here), so items never call Theme::for_inactive_window themselves; reading ctx.theme grants automatic window-blur desaturation of accent roles.

Fields§

§view_transform: Transform2D

View pan/zoom/rotation as a single affine. Items rarely need this directly — the canvas’s transform stack already accounts for it — but custom items wanting to draw at a fixed pixel size regardless of zoom can read the zoom factor from here.

§dirty_scene_rect: Option<Rect>

Optional scene-coord region the renderer is currently repainting. Items that internally subdivide their geometry can use this to skip work outside the dirty region. None means “full repaint”.

§text_scale: f32

Global accessibility text-scale factor (1.0 = 100 %), forwarded from the widget PaintContext. Lightweight text items that opt in (see TextItem::follow_text_scale) multiply their font size by this so they grow with the app-wide “grow all text” setting. Off-by-default because the scene already has its own pan/zoom.

§theme: &'a Theme

Fully-projected theme for this paint pass. Already swapped to the inactive-window / high-contrast variant by the render walker — read it directly and never call [Theme::for_inactive_window] yourself. Pass to [ColorProp::resolve] to turn a role/reactive colour into a concrete Color.

§window_active: bool

true iff the host window is focused AND not occluded (true in headless tests). Read for behavioural blur cues the accent-desaturation theme swap can’t cover (e.g. hiding a caret / muting a selection).

§enabled: bool

Effective enabled state of the item being painted (derived from ItemFlags::IS_ENABLED). Forwarded to [ColorProp::resolve] so a role-based colour picks its disabled variant on a disabled item.

Implementations§

Source§

impl<'a> SceneItemPaintContext<'a>

Source

pub fn new( view_transform: Transform2D, dirty_scene_rect: Option<Rect>, theme: &'a Theme, ) -> Self

Construct a paint context with the given view transform, optional dirty region, and the active theme. text_scale defaults to 1.0, window_active and enabled to true; use the with_* builders to carry the accessibility scale, window-active state, and per-item enabled state from the widget paint pass.

Source

pub fn with_text_scale(self, text_scale: f32) -> Self

Set the global accessibility text-scale factor carried to opted-in items.

Source

pub fn with_window_active(self, window_active: bool) -> Self

Set whether the host window is currently active (focused and unoccluded).

Source

pub fn with_enabled(self, enabled: bool) -> Self

Set the effective enabled state of the item being painted.

Trait Implementations§

Source§

impl<'a> Clone for SceneItemPaintContext<'a>

Source§

fn clone(&self) -> SceneItemPaintContext<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for SceneItemPaintContext<'a>

Auto Trait Implementations§

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
§

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

§

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

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

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

§

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

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

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

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

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

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.

§

impl<T> Instrument for T

§

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

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

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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