ui::OpacityLayerScope¶
Header: winui/render/Renderer.hpp.
Pushes an opacity layer when it is made and pops it when it goes out of scope.
Example:
class FadedSwatch : public ui::Element
{
ui::Color color_ = ui::colors::Black;
void render_override(ui::Renderer& r, const ui::RenderContext&) const override
{
const ui::OpacityLayerScope faded{r, 0.4f};
r.fill_rounded_rect(bounds(), 4.0f, color_); // drawn at 40 %
}
};
OpacityLayerScope¶
Draws everything in the scope as one layer at opacity (Renderer::push_opacity_layer()).
~OpacityLayerScope¶
Pops the layer.