pub struct PaintStyle {
pub bg: Option<Color32>,
pub border: Option<Stroke>,
pub radius: Option<f32>,
pub shadow: bool,
pub custom_shadow: Option<Shadow>,
pub opacity: Option<f32>,
}Expand description
How a box looks: background, border, corner radius, shadow and opacity.
Every field is optional and Default paints nothing, so an element that
nobody styled costs no shapes at all.
The three shapes all sit on the node’s border box — its whole box, not
the content rect — and share one radius. A border of width n is also
reserved by the layout (ItemStyle::to_taffy sets taffy’s border), so the
stroke is drawn StrokeKind::Inside and lands exactly in the band the
children were kept out of.
Fields§
§bg: Option<Color32>Background colour, filled behind the children or the widget.
border: Option<Stroke>Border stroke, drawn on top of them and reserved by the layout.
radius: Option<f32>Corner radius, shared by the shadow, the background and the border.
shadow: boolCast the theme’s Visuals::window_shadow.
custom_shadow: Option<Shadow>Cast this shadow instead, whatever shadow says.
opacity: Option<f32>Multiply the opacity of the node and everything under it.
Implementations§
Source§impl PaintStyle
impl PaintStyle
Sourcepub fn border(self, v: impl Into<Stroke>) -> Self
pub fn border(self, v: impl Into<Stroke>) -> Self
Set the border stroke. The layout reserves its width.
Sourcepub fn custom_shadow(self, v: Shadow) -> Self
pub fn custom_shadow(self, v: Shadow) -> Self
Cast this shadow instead of the theme’s.
Sourcepub fn opacity(self, v: f32) -> Self
pub fn opacity(self, v: f32) -> Self
Multiply the opacity of this node and everything under it.
Sourcepub fn is_none(&self) -> bool
pub fn is_none(&self) -> bool
Whether this style does nothing, so the engine can skip the node.
radius alone does not count: it only rounds shapes that another field
asks for. opacity does, even though it draws nothing itself, because
the engine still has to set it around the children.
Sourcepub fn shadow_shape(&self, rect: Rect, visuals: &Visuals) -> Option<Shape>
pub fn shadow_shape(&self, rect: Rect, visuals: &Visuals) -> Option<Shape>
The shadow shape under rect, if this style casts one.
custom_shadow wins over shadow; shadow alone is the theme’s
window shadow, which is why this needs the Visuals. Shadow::as_shape
offsets and expands the rect itself, so rect is the plain border box.
Sourcepub fn bg_shape(&self, rect: Rect) -> Option<Shape>
pub fn bg_shape(&self, rect: Rect) -> Option<Shape>
The background shape filling rect, if there is a bg.
Sourcepub fn border_shape(&self, rect: Rect) -> Option<Shape>
pub fn border_shape(&self, rect: Rect) -> Option<Shape>
The border shape around rect, if there is a border.
StrokeKind::Inside: the layout already reserved the stroke’s width
inside the border box, so drawing it there costs no extra room and two
neighbours with borders do not overlap.
Trait Implementations§
Source§impl Clone for PaintStyle
impl Clone for PaintStyle
Source§fn clone(&self) -> PaintStyle
fn clone(&self) -> PaintStyle
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PaintStyle
impl Debug for PaintStyle
Source§impl Default for PaintStyle
impl Default for PaintStyle
Source§fn default() -> PaintStyle
fn default() -> PaintStyle
Source§impl PartialEq for PaintStyle
impl PartialEq for PaintStyle
impl Copy for PaintStyle
impl StructuralPartialEq for PaintStyle
Auto Trait Implementations§
impl Freeze for PaintStyle
impl RefUnwindSafe for PaintStyle
impl Send for PaintStyle
impl Sync for PaintStyle
impl Unpin for PaintStyle
impl UnsafeUnpin for PaintStyle
impl UnwindSafe for PaintStyle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more