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: Transform2DView 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: f32Global 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 ThemeFully-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: booltrue 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: boolEffective 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>
impl<'a> SceneItemPaintContext<'a>
Sourcepub fn new(
view_transform: Transform2D,
dirty_scene_rect: Option<Rect>,
theme: &'a Theme,
) -> Self
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.
Sourcepub fn with_text_scale(self, text_scale: f32) -> Self
pub fn with_text_scale(self, text_scale: f32) -> Self
Set the global accessibility text-scale factor carried to opted-in items.
Sourcepub fn with_window_active(self, window_active: bool) -> Self
pub fn with_window_active(self, window_active: bool) -> Self
Set whether the host window is currently active (focused and unoccluded).
Sourcepub fn with_enabled(self, enabled: bool) -> Self
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>
impl<'a> Clone for SceneItemPaintContext<'a>
Source§fn clone(&self) -> SceneItemPaintContext<'a>
fn clone(&self) -> SceneItemPaintContext<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl<'a> Copy for SceneItemPaintContext<'a>
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for SceneItemPaintContext<'a>
impl<'a> !Send for SceneItemPaintContext<'a>
impl<'a> !Sync for SceneItemPaintContext<'a>
impl<'a> !UnwindSafe for SceneItemPaintContext<'a>
impl<'a> Freeze for SceneItemPaintContext<'a>
impl<'a> Unpin for SceneItemPaintContext<'a>
impl<'a> UnsafeUnpin for SceneItemPaintContext<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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