Skip to content

ui::ClipScope

Header: winui/render/Renderer.hpp.

Pushes a clip when it is made and pops it when it goes out of scope, so an early return cannot leave the clip pushed.

Example:

class Caption : public ui::Element
{
    std::string label_ = "A caption longer than its box";

    void render_override(ui::Renderer& r, const ui::RenderContext& context) const override
    {
        const ui::Theme&    theme = context.theme;
        const ui::ClipScope clip{r, bounds()};
        r.draw_text(label_, bounds(), theme.colors().text, theme.type.body); // clipped to bounds()
    }
};

ClipScope

ClipScope(Renderer& renderer, const Rect& bounds)

Clips to bounds (Renderer::push_clip()).

ClipScope

ClipScope(Renderer& renderer, Point center, float radius_x, float radius_y)

Clips to an ellipse (Renderer::push_clip_ellipse()).

ClipScope

ClipScope(Renderer& renderer, const Rect& bounds, float radius)

Clips to a rect with rounded corners (Renderer::push_clip_rounded_rect()).

~ClipScope

~ClipScope()

Pops the clip.

ClipScope

ClipScope(const ClipScope&) = delete

operator=

ClipScope& operator=(const ClipScope&) = delete