pub struct Shadow {
pub x: f32,
pub y: f32,
pub blur: f32,
pub spread: f32,
pub color: Color,
pub cut_out: bool,
pub follow_content: bool,
}Expand description
A shadow cast by a widget’s box, as CSS’s box-shadow: the box’s
shape moved by x and y, grown by spread and blurred over blur
logical pixels. Unlike CSS’s, it is drawn under the box too, so a
translucent background shows it through, unless it is
cut_out.
use crabshell_ui::{Color, Shadow, Style};
const CARD: Style = Style::new()
.background(Color::hex("#1e1e2e"))
.radius(8.0)
.shadow(Shadow::new(0.0, 4.0, 12.0, Color::rgba(0, 0, 0, 96)));Fields§
§x: f32How far right it is moved.
y: f32How far down it is moved.
blur: f32How far its edge is blurred. 0 is a sharp edge.
spread: f32How much larger than the box it is on each side, or smaller when negative.
color: ColorIts color.
cut_out: boolWhether it is left out under the box, as under translucent glass.
follow_content: boolWhether it is cast by what the widget and its children draw, through their alpha, instead of by its box.
Implementations§
Source§impl Shadow
impl Shadow
Sourcepub const fn new(x: f32, y: f32, blur: f32, color: Color) -> Shadow
pub const fn new(x: f32, y: f32, blur: f32, color: Color) -> Shadow
A shadow moved by x and y and blurred over blur, the box’s
size.
Sourcepub const fn cut_out(self) -> Shadow
pub const fn cut_out(self) -> Shadow
The same shadow left out under the box’s own shape, so a translucent
background, such as glass the compositor blurs, shows what is
behind it instead of the shadow. CSS’s box-shadow is always drawn
this way.
Sourcepub const fn follow_content(self) -> Shadow
pub const fn follow_content(self) -> Shadow
The same shadow cast by what the widget and everything inside it
draw, through their alpha, instead of by its box, so text and icons
get a drop shadow, as Qt’s MultiEffect shadow gives. It is drawn
under them, offset, spread and blurred as a box shadow is, and
after a mask, so it follows the masked shape. Cut
out, it is left out under the content’s own alpha.
use crabshell_ui::{Color, Shadow, Style};
const LABEL: Style = Style::new()
.color(Color::hex("#cdd6f4"))
.shadow(Shadow::new(0.0, 1.0, 3.0, Color::rgba(0, 0, 0, 160)).follow_content());Sourcepub fn casts_from_content(&self) -> bool
pub fn casts_from_content(&self) -> bool
Whether this shadow is cast by the content and can be: its numbers are finite and it reaches at most 64 logical pixels past what casts it, the size of its spread plus one and a half blurs. One reaching farther is left out whole and the content drawn without it, so the work of casting it stays bounded.