Skip to content

ui::MeasureContext

Header: winui/ui/LayoutContext.hpp.

What a measure pass hands each element's measure_override(), and what a container hands on to its children's measure(). Both must outlive the next measure() (see Element::measure()).

Example:

class PaddedControl : public ui::Element
{
protected:
    ui::Size measure_override(ui::Size available, const ui::MeasureContext& context) const override
    {
        const ui::Size inner = child_->measure(available, context);
        return {inner.width + 16.0f, inner.height + 16.0f};
    }

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

measurer

const TextMeasurer& measurer

Sizes text the way the renderer will draw it.

theme

const Theme& theme

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

with_theme

MeasureContext with_theme(const Theme& other) const

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