ui::RenderRecording¶
Header: winui/render/RenderRecording.hpp.
Derives from ui::Renderer.
A Renderer that keeps every call, with its full arguments, so it can be replayed into any other Renderer later, any number of times: a resolution-independent snapshot of an element.
Unlike TestRenderer, which records commands as data for tests (without a bitmap's pixels or an SVG's markup), this copies whatever each call needs to be drawn again. It is what a ConnectedAnimation shows of its source after the source itself is gone.
Example:
ui::Control<ui::Border> card; // filled through the card's `.control`
const float fade = 0.6f;
// Take a snapshot of a card before it leaves the tree.
ui::RenderRecording snapshot;
card->render(snapshot);
// Later, in a custom control's render_override(), once per frame while the snapshot flies to
// its destination. The same recording replays as often as needed.
if (!snapshot.empty())
{
renderer.push_opacity_layer(fade);
renderer.push_transform(0.8f, ui::Point{40, 20});
snapshot.replay(renderer);
renderer.pop_transform();
renderer.pop_opacity_layer();
}
fill_rounded_rect¶
Fills a rect with rounded corners (radius in DIPs, 0 for square) in a solid color.
stroke_rounded_rect¶
void stroke_rounded_rect(const Rect& bounds, float radius, const Color& color, float stroke_width) override
Strokes a rounded rect's outline, the pen centered on bounds' edge.
draw_text¶
void draw_text(std::string_view text, const Rect& bounds, const Color& color, const TextStyle& style) override
Draws UTF-8 text laid out in bounds per style (font, alignment, wrapping). Text overflowing bounds is not trimmed, and not clipped unless a clip is pushed.
fill_rounded_rect_gradient¶
void fill_rounded_rect_gradient(const Rect& bounds, float radius, const LinearGradientBrush& brush) override
Fills a rounded rect with a gradient along the brush's axis. The XP and Vista themes draw their chrome with it.
stroke_rounded_rect_gradient¶
void stroke_rounded_rect_gradient(const Rect& bounds, float radius, const LinearGradientBrush& brush, float extent_px, float stroke_width) override
Strokes a rounded rect with a gradient spanning extent_px device pixels, for Fluent's elevation border. StrokeRoundedRectGradient explains the sign of extent_px.
stroke_line¶
A straight line; also one edge of a classic raised/sunken bevel (see draw_bevel_border(), which draws a whole border out of these).
stroke_wavy_line¶
void stroke_wavy_line(Point from, Point to, const Color& color, float stroke_width, float amplitude, float wavelength) override
Draws the misspelling squiggle (see StrokeWavyLine).
fill_polygon¶
Fills a closed polygon with one color (see FillPolygon).
stroke_polyline¶
Strokes straight lines through a list of points (see StrokePolyline).
draw_geometry¶
Fills and strokes a PathGeometry (see DrawGeometry). A backend that cannot draw an AcrylicBrush draws its fallback color.
push_clip¶
Clips everything drawn until the matching pop_clip() to bounds, intersected with any enclosing clip.
pop_clip¶
Ends the innermost push_clip(), push_clip_ellipse() or push_clip_rounded_rect().
push_clip_ellipse¶
An elliptical clip, ended by the same pop_clip() as a rect clip (see PushClipEllipse).
push_clip_rounded_rect¶
A clip to bounds with corners rounded by radius, ended by the same pop_clip() (see PushClipRoundedRect). A radius of 0 is the same clip as push_clip().
fill_ellipse¶
Fills an ellipse centered on center, radii in DIPs.
stroke_ellipse¶
void stroke_ellipse(Point center, float radius_x, float radius_y, const Color& color, float stroke_width) override
Strokes an ellipse outline centered on center, radii in DIPs.
fill_rect_pattern¶
void fill_rect_pattern(const Rect& bounds, Pattern pattern, const Color& fg, const Color& bg) override
Fills bounds with a two-color stipple (see Pattern).
draw_image_nine_slice¶
void draw_image_nine_slice(const std::string& image_name, const Rect& bounds, const Thickness& slice_margins) override
Optional image-theme chrome (see ImageThemePack). A no-op wherever image_name isn't found in whatever pack the backend was configured with; ImageThemePack::empty() is the common case, and every backend must tolerate it. The default draws nothing, which is what a backend with no pack does.
draw_image¶
A caller-supplied bitmap, stretched into bounds per stretch (see DrawImage). image need only be valid for the duration of the call.
draw_image_rect¶
Draws the source part of image into bounds (see DrawImageRect). source is in the image's pixels and is clipped to them.
draw_svg¶
Draws svg into bounds (see DrawSvg). A backend that cannot draw SVG draws nothing.
push_opacity_layer¶
Draws everything until the matching pop_opacity_layer() as one layer at opacity (0..1); see PushOpacityLayer.
pop_opacity_layer¶
Ends the innermost push_opacity_layer().
push_matrix¶
Transforms everything drawn until the matching pop_transform(); nested pushes compose, the inner one applying first (see PushTransform). What every push_transform() overload lands in: a backend implements this one, and callers use push_transform().
pop_transform¶
Ends the innermost push_transform().
set_rasterization¶
Sets the theme's rasterization policy (see SetRasterization). Window::render() calls it once per frame, first, from the active Theme. A backend that ignores it draws everything antialiased, which matches the Modern look.
replay¶
Draws everything recorded into target, in order.
size¶
How many calls were recorded.
empty¶
True when nothing has been recorded (or since clear()).
clear¶
Drops every recorded call, for example to take a new snapshot of the same element.