CSS-style box shadows, painted by the PARENT under its children, because a shadow lies outside the component and would be clipped by it.
More...
|
| static std::optional< ShadowList > | parse (const juce::var &shadow) |
| | Parses a box shadow: a string of comma separated layers or an array of layer strings.
|
| static void | setRenderer (Renderer renderer) |
| | The renderer for every container that has none of its own; nullptr = no shadows.
|
| static void | setRenderer (juce::Component &container, Renderer renderer) |
| | A renderer for the shadows of this container's children; nullptr = the global one.
|
| static void | set (juce::Component &c, const juce::var &shadow) |
| | The component's shadow, as the layout's "boxShadow" entry sets it; void clears.
|
| static void | setRadius (juce::Component &c, float radius) |
| | The corner radius of the outline the shadow follows, as "borderRadius" sets it.
|
| static void | paintChildShadows (juce::Graphics &g, juce::Component &container) |
| | Paints the shadows of the container's children in its coordinates, as its layer does.
|
CSS-style box shadows, painted by the PARENT under its children, because a shadow lies outside the component and would be clipped by it.
JSON Format
{ "id": "card", "boxShadow": "0 4 8 0.45, 0 12 30 0.6", "borderRadius": 14,
"states": { "hover": { "boxShadow": "0 6 10 0.5, 0 16 36 0.65" } },
"transition": { "boxShadow": "60 inOutQuad" } }
- "boxShadow": one or more layers separated by commas (or a json array of strings), each "<x> <y> <blur> <opacity> [<spread>] [<colour>]": offset and blur in pixels, opacity 0..1 multiplying the colour's alpha, the colour black by default ("#ff3366", "ff00ff00" or a JUCE colour name like "red"). "none" or "" for no shadow.
- "borderRadius": the corner radius of the outline the shadow follows, number or expression (e.g. "pillH / 2").
- Animated with the "boxShadow" transition, usable in "states" like "alpha" and "scale".
- The outline is the component's bounds with that radius, following its scale transform, its bounds transitions and its alpha.
Painting
The first shadow in a container adds an invisible layer as its first child (at the back, taking no clicks, ignored by the layout's maxX/maxY), which paints the shadows of all its siblings; so "zorder" indices count it. A container that clips (most do) needs room around shadowed children for the blur.
Renderer
Gin draws no blur itself: install a renderer once, e.g. at app start, otherwise no shadows are drawn at all:
gin::BoxShadow::setRenderer ([] (juce::Graphics& g, const juce::Path& outline, const gin::ShadowSpec& s)
{
});
Code
gin::BoxShadow::set (tile, "0 3 6 0.45, 0 8 24 0.6");
gin::BoxShadow::setRadius (tile, 14.0f);