pub struct DrawingContext<'a> { /* private fields */ }Expand description
The surface a visual draws itself onto during rendering.
Implementations§
Source§impl<'a> DrawingContext<'a>
impl<'a> DrawingContext<'a>
Sourcepub fn new(core: &'a mut dyn IDrawingContextCore) -> Self
pub fn new(core: &'a mut dyn IDrawingContextCore) -> Self
Creates a context over a borrowed core. Dropping (or disposing) the context pops the states still pushed but leaves the core alive.
Sourcepub fn owned(core: Box<dyn IDrawingContextCore + 'a>) -> Self
pub fn owned(core: Box<dyn IDrawingContextCore + 'a>) -> Self
Creates a context that owns its core: disposing (or dropping) the context pops the states still pushed and disposes the core.
Sourcepub fn dispose(self)
pub fn dispose(self)
Pops every state still pushed and releases the context (and the core, if the context owns it).
Sourcepub fn draw_image(&mut self, source: &dyn IImage, rect: Rect)
pub fn draw_image(&mut self, source: &dyn IImage, rect: Rect)
Draws an image into rect.
Sourcepub fn draw_image_with_rects(
&mut self,
source: &dyn IImage,
source_rect: Rect,
dest_rect: Rect,
)
pub fn draw_image_with_rects( &mut self, source: &dyn IImage, source_rect: Rect, dest_rect: Rect, )
Draws the part of an image inside source_rect into dest_rect.
Sourcepub fn draw_bitmap(
&mut self,
source: &RefCounted<SharedBitmapImpl>,
opacity: f64,
source_rect: Rect,
dest_rect: Rect,
)
pub fn draw_bitmap( &mut self, source: &RefCounted<SharedBitmapImpl>, opacity: f64, source_rect: Rect, dest_rect: Rect, )
Draws a platform bitmap.
Sourcepub fn draw_geometry(
&mut self,
brush: Option<&Rc<dyn IBrush>>,
pen: Option<&Rc<dyn IPen>>,
geometry: &Ref<Geometry>,
)
pub fn draw_geometry( &mut self, brush: Option<&Rc<dyn IBrush>>, pen: Option<&Rc<dyn IPen>>, geometry: &Ref<Geometry>, )
Draws a geometry.
Sourcepub fn draw_geometry_impl(
&mut self,
brush: Option<&Rc<dyn IBrush>>,
pen: Option<&Rc<dyn IPen>>,
geometry: &Arc<dyn IGeometryImpl>,
)
pub fn draw_geometry_impl( &mut self, brush: Option<&Rc<dyn IBrush>>, pen: Option<&Rc<dyn IPen>>, geometry: &Arc<dyn IGeometryImpl>, )
Draws a platform geometry.
Sourcepub fn draw_rectangle(
&mut self,
brush: Option<&Rc<dyn IBrush>>,
pen: Option<&Rc<dyn IPen>>,
rect: Rect,
radius_x: f64,
radius_y: f64,
box_shadows: &BoxShadows,
)
pub fn draw_rectangle( &mut self, brush: Option<&Rc<dyn IBrush>>, pen: Option<&Rc<dyn IPen>>, rect: Rect, radius_x: f64, radius_y: f64, box_shadows: &BoxShadows, )
Draws a rectangle with the specified brush and pen.
The brush and the pen can both be None. If the brush is None, no
fill is performed. If the pen is None, no stroke is performed. If
both are None and there are no box shadows, the call is a no-op.
Sourcepub fn draw_rounded_rectangle(
&mut self,
brush: Option<&Rc<dyn IBrush>>,
pen: Option<&Rc<dyn IPen>>,
rrect: RoundedRect,
box_shadows: &BoxShadows,
)
pub fn draw_rounded_rectangle( &mut self, brush: Option<&Rc<dyn IBrush>>, pen: Option<&Rc<dyn IPen>>, rrect: RoundedRect, box_shadows: &BoxShadows, )
Draws a rounded rectangle with the specified brush and pen.
Sourcepub fn draw_rectangle_outline(
&mut self,
pen: &Rc<dyn IPen>,
rect: Rect,
corner_radius: f32,
)
pub fn draw_rectangle_outline( &mut self, pen: &Rc<dyn IPen>, rect: Rect, corner_radius: f32, )
Draws the outline of a rectangle.
Sourcepub fn fill_rectangle(
&mut self,
brush: &Rc<dyn IBrush>,
rect: Rect,
corner_radius: f32,
)
pub fn fill_rectangle( &mut self, brush: &Rc<dyn IBrush>, rect: Rect, corner_radius: f32, )
Draws a filled rectangle.
Sourcepub fn draw_ellipse_at(
&mut self,
brush: Option<&Rc<dyn IBrush>>,
pen: Option<&Rc<dyn IPen>>,
center: Point,
radius_x: f64,
radius_y: f64,
)
pub fn draw_ellipse_at( &mut self, brush: Option<&Rc<dyn IBrush>>, pen: Option<&Rc<dyn IPen>>, center: Point, radius_x: f64, radius_y: f64, )
Draws an ellipse given its center and radii.
Sourcepub fn draw_ellipse(
&mut self,
brush: Option<&Rc<dyn IBrush>>,
pen: Option<&Rc<dyn IPen>>,
rect: Rect,
)
pub fn draw_ellipse( &mut self, brush: Option<&Rc<dyn IBrush>>, pen: Option<&Rc<dyn IPen>>, rect: Rect, )
Draws an ellipse inscribed in a rectangle.
Sourcepub fn custom(&mut self, custom: &Arc<dyn ICustomDrawOperation>)
pub fn custom(&mut self, custom: &Arc<dyn ICustomDrawOperation>)
Draws a custom drawing operation.
Sourcepub fn draw_text(&mut self, text: &FormattedText, origin: Point)
pub fn draw_text(&mut self, text: &FormattedText, origin: Point)
Draws text. origin is the upper-left corner of the text.
Sourcepub fn draw_glyph_run(
&mut self,
foreground: Option<&Rc<dyn IBrush>>,
glyph_run: &Rc<GlyphRun>,
)
pub fn draw_glyph_run( &mut self, foreground: Option<&Rc<dyn IBrush>>, glyph_run: &Rc<GlyphRun>, )
Draws a glyph run.
Sourcepub fn draw_rectangle_acrylic(
&mut self,
material: &dyn IExperimentalAcrylicMaterial,
rect: RoundedRect,
)
pub fn draw_rectangle_acrylic( &mut self, material: &dyn IExperimentalAcrylicMaterial, rect: RoundedRect, )
Draws a rectangle filled with an acrylic-like material. A core
without acrylic support fills the rectangle with the fallback color
of the material; see
IDrawingContextCore::draw_rectangle_acrylic_core.
Sourcepub fn pop(&mut self, state: PushedState)
pub fn pop(&mut self, state: PushedState)
Pops a pushed state (C# PushedState.Dispose).
Panics if the state is not the most recently pushed one. Popping
PushedState::NONE, or any state after the context has been
disposed, does nothing.
Sourcepub fn scope(&mut self, state: PushedState) -> PushedScope<'_, 'a>
pub fn scope(&mut self, state: PushedState) -> PushedScope<'_, 'a>
Turns a pushed state into a guard that derefs to the context and pops the state when dropped.
Sourcepub fn push_rounded_clip(&mut self, clip: RoundedRect) -> PushedState
pub fn push_rounded_clip(&mut self, clip: RoundedRect) -> PushedState
Pushes a rounded clip rectangle.
Sourcepub fn push_clip(&mut self, clip: Rect) -> PushedState
pub fn push_clip(&mut self, clip: Rect) -> PushedState
Pushes a clip rectangle.
Sourcepub fn push_geometry_clip(&mut self, clip: &Ref<Geometry>) -> PushedState
pub fn push_geometry_clip(&mut self, clip: &Ref<Geometry>) -> PushedState
Pushes a clip geometry.
Sourcepub fn push_opacity(&mut self, opacity: f64) -> PushedState
pub fn push_opacity(&mut self, opacity: f64) -> PushedState
Pushes an opacity value.
Sourcepub fn push_opacity_mask(
&mut self,
mask: &Rc<dyn IBrush>,
bounds: Rect,
) -> PushedState
pub fn push_opacity_mask( &mut self, mask: &Rc<dyn IBrush>, bounds: Rect, ) -> PushedState
Pushes an opacity mask.
bounds are the bounds of the control, used to place brushes
correctly.
Sourcepub fn push_transform(&mut self, matrix: Matrix) -> PushedState
pub fn push_transform(&mut self, matrix: Matrix) -> PushedState
Pushes a matrix transformation.
Sourcepub fn push_render_options(
&mut self,
render_options: RenderOptions,
) -> PushedState
pub fn push_render_options( &mut self, render_options: RenderOptions, ) -> PushedState
Pushes render options.
Sourcepub fn push_text_options(&mut self, text_options: TextOptions) -> PushedState
pub fn push_text_options(&mut self, text_options: TextOptions) -> PushedState
Pushes text options.
Sourcepub fn push_effect(
&mut self,
effect: &Rc<dyn IEffect>,
bounds: Rect,
) -> PushedState
pub fn push_effect( &mut self, effect: &Rc<dyn IEffect>, bounds: Rect, ) -> PushedState
Pushes an effect applied to everything drawn until the state is
popped. bounds are the bounds of the affected content.
Trait Implementations§
Source§impl Drop for DrawingContext<'_>
impl Drop for DrawingContext<'_>
Source§impl ITextDrawingSink for DrawingContext<'_>
Text draws itself through the sink members, which are the corresponding
drawing context members. A sink push has no state token: its pop restores
the state pushed last, which is the transform the matching push pushed
because text balances its pushes.
impl ITextDrawingSink for DrawingContext<'_>
Text draws itself through the sink members, which are the corresponding drawing context members. A sink push has no state token: its pop restores the state pushed last, which is the transform the matching push pushed because text balances its pushes.
Source§fn draw_glyph_run(
&mut self,
foreground: Option<&Rc<dyn IBrush>>,
glyph_run: &Rc<GlyphRun>,
)
fn draw_glyph_run( &mut self, foreground: Option<&Rc<dyn IBrush>>, glyph_run: &Rc<GlyphRun>, )
DrawingContext.DrawGlyphRun(IBrush? foreground, GlyphRun glyphRun)).Source§fn draw_rectangle(
&mut self,
brush: Option<&Rc<dyn IBrush>>,
pen: Option<&Rc<dyn IPen>>,
rect: Rect,
)
fn draw_rectangle( &mut self, brush: Option<&Rc<dyn IBrush>>, pen: Option<&Rc<dyn IPen>>, rect: Rect, )
DrawingContext.DrawRectangle(IBrush? brush, IPen? pen, Rect rect)).Source§fn draw_line(&mut self, pen: &Rc<dyn IPen>, p1: Point, p2: Point)
fn draw_line(&mut self, pen: &Rc<dyn IPen>, p1: Point, p2: Point)
DrawingContext.DrawLine(IPen pen, Point p1, Point p2)).Source§fn push_transform(&mut self, matrix: Matrix)
fn push_transform(&mut self, matrix: Matrix)
DrawingContext.PushTransform(Matrix matrix)).
Every push is balanced by one ITextDrawingSink::pop_transform.Source§fn pop_transform(&mut self)
fn pop_transform(&mut self)
PushedState).Auto Trait Implementations§
impl<'a> !RefUnwindSafe for DrawingContext<'a>
impl<'a> !Send for DrawingContext<'a>
impl<'a> !Sync for DrawingContext<'a>
impl<'a> !UnwindSafe for DrawingContext<'a>
impl<'a> Freeze for DrawingContext<'a>
impl<'a> Unpin for DrawingContext<'a>
impl<'a> UnsafeUnpin for DrawingContext<'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
Source§impl<T> ClassDefaults for Twhere
T: ?Sized,
impl<T> ClassDefaults for Twhere
T: ?Sized,
Source§fn static_constructor()
fn static_constructor()
affects_render, metadata
overrides). Read more