Skip to content

ui::TransformScope

Header: winui/render/Renderer.hpp.

Pushes a transform when it is made and pops it when it goes out of scope.

Example:

class ZoomedSwatch : public ui::Element
{
    ui::Color color_ = ui::colors::Black;

    void render_override(ui::Renderer& r, const ui::RenderContext&) const override
    {
        const ui::TransformScope zoom{r, 2.0f, ui::Point{bounds().x, bounds().y}};
        r.fill_rounded_rect(ui::Rect{0.0f, 0.0f, 8.0f, 8.0f}, 0.0f, color_); // 16 DIPs at the top left
    }
};

TransformScope

TransformScope(Renderer& renderer, const Matrix& transform)

Transforms by transform (Renderer::push_transform()).

TransformScope

TransformScope(Renderer& renderer, float scale_x, float scale_y, Point offset)

Scales by scale_x/scale_y about the origin, then translates by offset.

TransformScope

TransformScope(Renderer& renderer, float scale, Point offset)

Scales uniformly by scale, then translates by offset.

~TransformScope

~TransformScope()

Pops the transform.

TransformScope

TransformScope(const TransformScope&) = delete

operator=

TransformScope& operator=(const TransformScope&) = delete