pub struct PaintCtx { /* private fields */ }Implementations§
Source§impl PaintCtx
impl PaintCtx
Sourcepub fn motion_policy(&self) -> MotionPolicy
pub fn motion_policy(&self) -> MotionPolicy
The motion policy in effect, for paint that depends on it (such as an entrance offset that reduced motion turns off).
Sourcepub fn output_color_range(&self) -> Option<OutputColorRange>
pub fn output_color_range(&self) -> Option<OutputColorRange>
What the window’s output can show, or None before the platform has
said. Painting reads it as an observation, so the widget is painted
again when it changes.
Sourcepub const fn frame_time(&self) -> f64
pub const fn frame_time(&self) -> f64
The time this frame is expected on screen. Read Motion values at
this time (motion.get(ctx)).
pub const fn window_id(&self) -> WindowId
pub const fn widget_id(&self) -> WidgetId
pub const fn presentation_transform(&self) -> Transform
Sourcepub fn observe<T, O>(&self, observable: &O) -> Twhere
O: Observable<T> + ?Sized,
pub fn observe<T, O>(&self, observable: &O) -> Twhere
O: Observable<T> + ?Sized,
Read an observable whose changes affect painting.
Sourcepub fn observe_with<T, O>(&self, observable: &O, kind: InvalidationKind) -> Twhere
O: Observable<T> + ?Sized,
pub fn observe_with<T, O>(&self, observable: &O, kind: InvalidationKind) -> Twhere
O: Observable<T> + ?Sized,
Read an observable and explicitly declare the resulting invalidation.
pub const fn focused_widget_id(&self) -> Option<WidgetId>
pub fn is_focused(&self) -> bool
pub const fn bounds(&self) -> Rect
pub const fn dpi(&self) -> DpiInfo
pub fn measure_text( &self, text: impl Into<String>, style: TextStyle, ) -> Result<TextMeasurement>
pub fn shape_text( &self, text: impl Into<String>, box_size: Size, style: TextStyle, ) -> Result<TextLayout>
pub fn layout_text_document( &self, request: TextLayoutRequest, ) -> Result<TextLayout>
pub fn clear(&mut self, color: Color)
pub fn fill(&mut self, path: impl Into<Path>, brush: impl Into<Brush>)
pub fn fill_rect(&mut self, rect: Rect, brush: impl Into<Brush>)
pub fn fill_bounds(&mut self, brush: impl Into<Brush>)
pub fn stroke( &mut self, path: impl Into<Path>, brush: impl Into<Brush>, stroke: StrokeStyle, )
pub fn stroke_rect( &mut self, rect: Rect, brush: impl Into<Brush>, stroke: StrokeStyle, )
pub fn stroke_bounds(&mut self, brush: impl Into<Brush>, stroke: StrokeStyle)
pub fn draw_text( &mut self, rect: Rect, text: impl Into<String>, style: TextStyle, )
pub fn draw_text_layout(&mut self, origin: Point, layout: &TextLayout)
pub fn draw_text_layout_with_color( &mut self, origin: Point, layout: &TextLayout, color: Color, )
pub fn draw_persistent_text_layout( &mut self, origin: Point, layout: &PersistentTextLayout, )
pub fn draw_persistent_text_layout_with_color( &mut self, origin: Point, layout: &PersistentTextLayout, color: Color, )
pub fn draw_persistent_text_layout_window( &mut self, origin: Point, layout: &PersistentTextLayout, line_range: Range<usize>, )
pub fn draw_persistent_text_layout_window_with_color( &mut self, origin: Point, layout: &PersistentTextLayout, line_range: Range<usize>, color: Color, )
pub fn label(&mut self, rect: Rect, text: impl Into<String>, color: Color)
pub fn push_text_render_policy(&mut self, policy: TextRenderPolicy)
pub fn pop_text_render_policy(&mut self)
pub fn draw_image(&mut self, rect: Rect, image: ImageHandle)
pub fn image_registered(&self, image: ImageHandle) -> bool
pub fn draw_image_source(&mut self, rect: Rect, source: ImageSource)
pub fn draw_image_quad(&mut self, points: [Point; 4], image: ImageHandle)
pub fn draw_image_quad_source( &mut self, points: [Point; 4], source: ImageSource, )
pub fn widget_image_handle(&self, slot: u64) -> ImageHandle
pub fn register_image(&mut self, handle: ImageHandle, image: RegisteredImage)
Sourcepub fn register_external_image(
&mut self,
handle: ImageHandle,
image: RegisteredExternalImage,
)
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.
pub fn draw_shader_rect(&mut self, rect: Rect, shader: WidgetShader)
Sourcepub fn fill_rrect(
&mut self,
rect: Rect,
radii: [f32; 4],
brush: impl Into<Brush>,
)
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.
Sourcepub fn fill_rrect_bordered(
&mut self,
rect: Rect,
radii: [f32; 4],
brush: impl Into<Brush>,
border: Border,
)
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.
Sourcepub fn draw_shadow(&mut self, rect: Rect, radii: [f32; 4], shadow: ShadowParams)
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).
Sourcepub fn fill_rrect_with_shadow(
&mut self,
rect: Rect,
radii: [f32; 4],
brush: impl Into<Brush>,
shadow: ShadowParams,
)
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.
pub fn push_clip(&mut self, path: impl Into<Path>)
pub fn push_clip_rect(&mut self, rect: Rect)
pub fn pop_clip(&mut self)
pub fn push_transform(&mut self, transform: Transform)
Sourcepub fn with_transform<R>(
&mut self,
transform: Transform,
paint: impl FnOnce(&mut PaintCtx) -> R,
) -> R
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.
pub fn translate(&mut self, delta: Vector)
pub fn pop_transform(&mut self)
pub fn push(&mut self, command: SceneCommand)
Sourcepub fn push_retained_scene_layer(
&mut self,
owner: WidgetId,
bounds: Rect,
scene: Arc<Scene>,
)
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.
Sourcepub fn with_retained_scene_layer<R>(
&mut self,
owner: WidgetId,
bounds: Rect,
paint: impl FnOnce(&mut PaintCtx) -> R,
) -> R
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.