pub enum Shape {
RoundedRectangle {
top_left: Dp,
top_right: Dp,
bottom_right: Dp,
bottom_left: Dp,
g2_k_value: f32,
},
Ellipse,
HorizontalCapsule,
VerticalCapsule,
}
Expand description
Shape definitions for UI components
Shape
is used by multiple components (surface
, fluid_glass
, sliders, progress, buttons)
to define:
- Visual outline (fill / border / highlight pipelines)
- Interaction & ripple hit-testing region
- Automatic corner radius derivation for capsule variants
§Variants
Shape::RoundedRectangle
– Independent corner radii +g2_k_value
curvature controlShape::Ellipse
– Ellipse filling the component boundsShape::HorizontalCapsule
– Pill where corner radius = height / 2 (resolved at render)Shape::VerticalCapsule
– Pill where corner radius = width / 2 (resolved at render)
Capsule variants are convenience markers; they are internally converted into a rounded rectangle whose four radii equal half of the minor axis (height for horizontal, width for vertical).
§Example
use tessera_ui::dp::Dp;
use tessera_ui_basic_components::shape_def::Shape;
// Explicit rounded rectangle
let rr = Shape::RoundedRectangle {
top_left: Dp(8.0),
top_right: Dp(8.0),
bottom_right: Dp(8.0),
bottom_left: Dp(8.0),
g2_k_value: 3.0,
};
// Ellipse
let ellipse = Shape::Ellipse;
// Capsules (auto radius from minor axis)
let h_capsule = Shape::HorizontalCapsule;
let v_capsule = Shape::VerticalCapsule;
Variants§
RoundedRectangle
Rounded rectangle with independent corner radii and a curvature factor:
g2_k_value
controls the transition curve (G2 continuity parameter).
Ellipse
Ellipse fitting the component bounds.
HorizontalCapsule
Horizontal capsule (pill) – rendered as a rounded rectangle whose corner radius
is computed as height / 2.0
at draw time.
VerticalCapsule
Vertical capsule (pill) – rendered as a rounded rectangle whose corner radius
is computed as width / 2.0
at draw time.
Implementations§
Source§impl Shape
impl Shape
Sourcepub const fn rounded_rectangle(radius: Dp) -> Self
pub const fn rounded_rectangle(radius: Dp) -> Self
A Quick helper to create a uniform rounded rectangle shape.
§Example
use tessera_ui::dp::Dp;
use tessera_ui_basic_components::shape_def::Shape;
let shape = Shape::rounded_rectangle(Dp(8.0));
assert_eq!(shape, Shape::RoundedRectangle { top_left: Dp(8.0), top_right: Dp(8.0), bottom_right: Dp(8.0), bottom_left: Dp(8.0), g2_k_value: 3.0 });
Trait Implementations§
Source§impl Default for Shape
impl Default for Shape
Source§fn default() -> Self
fn default() -> Self
Returns the default shape, which is a rectangle with zero corner radius.
§Example
use tessera_ui::dp::Dp;
use tessera_ui_basic_components::shape_def::Shape;
let default_shape = Shape::default();
assert_eq!(default_shape, Shape::RoundedRectangle { top_left: Dp(0.0), top_right: Dp(0.0), bottom_right: Dp(0.0), bottom_left: Dp(0.0), g2_k_value: 3.0 });
impl Copy for Shape
impl StructuralPartialEq for Shape
Auto Trait Implementations§
impl Freeze for Shape
impl RefUnwindSafe for Shape
impl Send for Shape
impl Sync for Shape
impl Unpin for Shape
impl UnwindSafe for Shape
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,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.