cranpose_ui/modifier/
background.rs1use super::{inspector_metadata, Color, Modifier, RoundedCornerShape};
2use crate::modifier_nodes::{BackgroundElement, CornerShapeElement};
3
4impl Modifier {
5 pub fn background(self, color: Color) -> Self {
9 let modifier = Self::with_element(BackgroundElement::new(color))
10 .with_inspector_metadata(background_metadata(color));
11 self.then(modifier)
12 }
13
14 pub fn rounded_corners(self, radius: f32) -> Self {
18 let shape = RoundedCornerShape::uniform(radius);
19 let modifier = Self::with_element(CornerShapeElement::new(shape));
20 self.then(modifier)
21 }
22
23 pub fn rounded_corner_shape(self, shape: RoundedCornerShape) -> Self {
27 let modifier = Self::with_element(CornerShapeElement::new(shape));
28 self.then(modifier)
29 }
30}
31
32fn background_metadata(color: Color) -> super::InspectorMetadata {
33 inspector_metadata("background", |info| {
34 info.add_property("backgroundColor", format!("{color:?}"));
35 })
36}