ui::ShadowRecipe¶
Header: winui/render/OverlayShadow.hpp.
The two superimposed black shadows that make up a drop shadow: an omnidirectional ambient and a downward-offset directional. Both are pure black, and only their alpha varies. Blur and offsets are in DIPs, alphas 0..1. Anything below Z 4 casts nothing, which is why a Fluent button has no shadow.
Example:
// A card-like Border at Z = 8, drawn under its own background.
const ui::Rect bounds{16, 16, 240, 120};
const ui::Color card_background = ui::colors::White;
const ui::ShadowRecipe recipe = ui::ShadowRecipe::for_elevation(ui::elevation_z::Card, theme.dark);
if (recipe.casts())
{
ui::draw_drop_shadow(renderer, bounds, 8.0f, recipe);
}
renderer.fill_rounded_rect(bounds, 8.0f, card_background);
ambient_blur¶
Blur radius of the ambient shadow.
ambient_y¶
Downward offset of the ambient shadow.
ambient_alpha¶
Opacity of the ambient shadow; 0 draws none.
directional_blur¶
Blur radius of the directional (key-light) shadow.
directional_y¶
Downward offset of the directional shadow.
directional_alpha¶
Opacity of the directional shadow; 0 draws none.
casts¶
Whether either shadow is visible at all.
for_elevation¶
The drop-shadow recipe for elevation elevation, with the alphas for a light or dark theme. A dark theme's alphas are roughly double. Up to Z 32 there is no ambient shadow. In a light theme the directional alpha stops growing at Z 16, so a ToolTip and a Flyout have the same opacity and differ only in blur and offset. A dark theme uses a flat 0.26 up to Z 32.