Skip to main content

PaintCtx

Struct PaintCtx 

Source
pub struct PaintCtx { /* private fields */ }

Implementations§

Source§

impl PaintCtx

Source

pub const fn window_id(&self) -> WindowId

Source

pub const fn widget_id(&self) -> WidgetId

Source

pub const fn presentation_transform(&self) -> Transform

Source

pub fn observe<T, O>(&self, observable: &O) -> T
where O: Observable<T> + ?Sized,

Read an observable whose changes affect painting.

Source

pub fn observe_with<T, O>(&self, observable: &O, kind: InvalidationKind) -> T
where O: Observable<T> + ?Sized,

Read an observable and explicitly declare the resulting invalidation.

Source

pub const fn focused_widget_id(&self) -> Option<WidgetId>

Source

pub fn is_focused(&self) -> bool

Source

pub const fn bounds(&self) -> Rect

Source

pub const fn dpi(&self) -> DpiInfo

Source

pub fn measure_text( &self, text: impl Into<String>, style: TextStyle, ) -> Result<TextMeasurement, Error>

Source

pub fn shape_text( &self, text: impl Into<String>, box_size: Size, style: TextStyle, ) -> Result<TextLayout, Error>

Source

pub fn layout_text_document( &self, request: TextLayoutRequest, ) -> Result<TextLayout, Error>

Source

pub fn clear(&mut self, color: Color)

Source

pub fn fill(&mut self, path: impl Into<Path>, brush: impl Into<Brush>)

Source

pub fn fill_rect(&mut self, rect: Rect, brush: impl Into<Brush>)

Source

pub fn fill_bounds(&mut self, brush: impl Into<Brush>)

Source

pub fn stroke( &mut self, path: impl Into<Path>, brush: impl Into<Brush>, stroke: StrokeStyle, )

Source

pub fn stroke_rect( &mut self, rect: Rect, brush: impl Into<Brush>, stroke: StrokeStyle, )

Source

pub fn stroke_bounds(&mut self, brush: impl Into<Brush>, stroke: StrokeStyle)

Source

pub fn draw_text( &mut self, rect: Rect, text: impl Into<String>, style: TextStyle, )

Source

pub fn draw_text_layout(&mut self, origin: Point, layout: &TextLayout)

Source

pub fn draw_text_layout_with_color( &mut self, origin: Point, layout: &TextLayout, color: Color, )

Source

pub fn draw_persistent_text_layout( &mut self, origin: Point, layout: &PersistentTextLayout, )

Source

pub fn draw_persistent_text_layout_with_color( &mut self, origin: Point, layout: &PersistentTextLayout, color: Color, )

Source

pub fn draw_persistent_text_layout_window( &mut self, origin: Point, layout: &PersistentTextLayout, line_range: Range<usize>, )

Source

pub fn draw_persistent_text_layout_window_with_color( &mut self, origin: Point, layout: &PersistentTextLayout, line_range: Range<usize>, color: Color, )

Source

pub fn label(&mut self, rect: Rect, text: impl Into<String>, color: Color)

Source

pub fn push_text_render_policy(&mut self, policy: TextRenderPolicy)

Source

pub fn pop_text_render_policy(&mut self)

Source

pub fn draw_image(&mut self, rect: Rect, image: ImageHandle)

Source

pub fn image_registered(&self, image: ImageHandle) -> bool

Source

pub fn draw_image_source(&mut self, rect: Rect, source: ImageSource)

Source

pub fn draw_image_quad(&mut self, points: [Point; 4], image: ImageHandle)

Source

pub fn draw_image_quad_source( &mut self, points: [Point; 4], source: ImageSource, )

Source

pub fn widget_image_handle(&self, slot: u64) -> ImageHandle

Source

pub fn register_image(&mut self, handle: ImageHandle, image: RegisteredImage)

Source

pub fn register_external_image( &mut self, handle: ImageHandle, image: RegisteredExternalImage, )

Register renderer-neutral metadata for an externally owned image.

The active renderer must have a matching backend resource registered for handle. The external resource remains app-owned; this only makes its dimensions available to layout and scene construction for the current frame.

Source

pub fn draw_shader_rect(&mut self, rect: Rect, shader: WidgetShader)

Source

pub fn fill_rrect( &mut self, rect: Rect, radii: [f32; 4], brush: impl Into<Brush>, )

Fill a rounded rectangle (per-corner radii [tl, tr, br, bl]) with a brush.

Source

pub fn fill_rrect_bordered( &mut self, rect: Rect, radii: [f32; 4], brush: impl Into<Brush>, border: Border, )

Fill a rounded rectangle with a brush and stroke an inset border.

Source

pub fn draw_shadow(&mut self, rect: Rect, radii: [f32; 4], shadow: ShadowParams)

Paint just a soft drop shadow for a rounded rectangle (no fill).

Source

pub fn fill_rrect_with_shadow( &mut self, rect: Rect, radii: [f32; 4], brush: impl Into<Brush>, shadow: ShadowParams, )

Fill a rounded rectangle with a brush behind a soft drop shadow.

Source

pub fn push_clip(&mut self, path: impl Into<Path>)

Source

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

Source

pub fn pop_clip(&mut self)

Source

pub fn push_transform(&mut self, transform: Transform)

Source

pub fn with_transform<R>( &mut self, transform: Transform, paint: impl FnOnce(&mut PaintCtx) -> R, ) -> R

Paint several retained children or drawing operations under one shared affine transform.

Unlike a raw Self::push_transform call, the nested context also advertises the transformed presentation space to retained child pods. Children arranged with the same presentation transform can therefore append their scenes directly instead of emitting an identical PushTransform/PopTransform pair for every child. Paint bounds and IME geometry produced inside the callback are mapped back into this context’s coordinate space when the group is appended.

Source

pub fn translate(&mut self, delta: Vector)

Source

pub fn pop_transform(&mut self)

Source

pub fn push(&mut self, command: SceneCommand)

Source

pub fn push_retained_scene_layer( &mut self, owner: WidgetId, bounds: Rect, scene: Arc<Scene>, )

Insert a stable retained scene layer owned by another logical widget.

Canvas-style containers use this to keep world-space drawing cached beneath a changing outer transform. Reusing owner preserves renderer packet identity; changing scene still invalidates the packet by its content signature. The owner must be exposed through normal widget visitation so runtime ordering and diagnostics can resolve it.

Source

pub fn with_retained_scene_layer<R>( &mut self, owner: WidgetId, bounds: Rect, paint: impl FnOnce(&mut PaintCtx) -> R, ) -> R

Paint a logical widget subtree into one retained scene layer.

The callback uses the current presentation space, so this composes with Self::with_transform without repeating the transform in every child. A stable owner lets the renderer reuse the layer packet when the callback produces identical scene content on a later frame. Child paint bounds, resource registrations, invalidations, and IME geometry are merged back into this context.

Source

pub fn scene(&self) -> &Scene

Source

pub fn scene_mut(&mut self) -> &mut Scene

Source

pub fn request(&mut self, request: InvalidationRequest)

Source

pub fn request_paint(&mut self)

Source

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

Source

pub fn invalidations(&self) -> &[InvalidationRequest]

Source

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

Source

pub fn clear_ime_composition_rect(&mut self)

Source

pub const fn ime_composition_rect(&self) -> Option<Rect>

Trait Implementations§

Source§

impl Clone for PaintCtx

Source§

fn clone(&self) -> PaintCtx

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 Debug for PaintCtx

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

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

Source§

fn downcast(&self) -> &T

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> 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 = !

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

Source§

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

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