Skip to content

ui::RenderContext

Header: winui/ui/LayoutContext.hpp.

What a render pass hands each element's render_override() beside the renderer, and what a container hands on to its children's render(). It holds what drawing reads besides the renderer; more fields (a DPI scale, the dirty rect) may be added later without breaking an override.

Example:

class CardControl : public ui::Element
{
protected:
    void render_override(ui::Renderer& renderer, const ui::RenderContext& context) const override
    {
        renderer.fill_rounded_rect(bounds(), context.theme.corner_radius, fill_);
        child_->render(renderer, context);
    }

private:
    ui::Color                    fill_;
    std::unique_ptr<ui::Element> child_;
};

theme

const Theme& theme

The theme in effect here (an ElementTheme scope already applied).

with_theme

RenderContext with_theme(const Theme& other) const

The same context under another theme, for a container that draws its children with one of its own.