pub trait ShapeBorder: Any + Debug {
Show 17 methods
// Required methods
fn dimensions(&self) -> EdgeInsetsGeometry;
fn scale(&self, t: f64) -> ShapeBorderRef;
fn get_outer_path(
&self,
rect: Rect,
text_direction: Option<TextDirection>,
) -> Path;
fn get_inner_path(
&self,
rect: Rect,
text_direction: Option<TextDirection>,
) -> Path;
fn paint(
&self,
canvas: &mut DisplayListBuilder,
rect: Rect,
text_direction: Option<TextDirection>,
);
fn as_any(&self) -> &(dyn Any + 'static);
// Provided methods
fn add(
&self,
other: &ShapeBorderRef,
reversed: bool,
) -> Option<ShapeBorderRef> { ... }
fn lerp_from(
&self,
a: Option<&(dyn ShapeBorder + 'static)>,
t: f64,
) -> Option<ShapeBorderRef> { ... }
fn lerp_to(
&self,
b: Option<&(dyn ShapeBorder + 'static)>,
t: f64,
) -> Option<ShapeBorderRef> { ... }
fn hit_test(
&self,
rect: Rect,
position: Offset,
text_direction: Option<TextDirection>,
) -> bool { ... }
fn paint_interior(
&self,
canvas: &mut DisplayListBuilder,
rect: Rect,
paint: &Paint,
text_direction: Option<TextDirection>,
) { ... }
fn prefer_paint_interior(&self) -> bool { ... }
fn as_outlined_border(&self) -> Option<&(dyn OutlinedBorder + 'static)> { ... }
fn into_outlined_border(self: Rc<Self>) -> Option<Rc<dyn OutlinedBorder>> { ... }
fn as_box_border(&self) -> Option<&(dyn BoxBorder + 'static)> { ... }
fn into_box_border(self: Rc<Self>) -> Option<Rc<dyn BoxBorder>> { ... }
fn eq_shape(&self, other: &(dyn ShapeBorder + 'static)) -> bool { ... }
}Expand description
Base class for shape outlines.
This class handles how to add multiple borders together. Subclasses define
various shapes, like circles (CircleBorder), rounded rectangles
(RoundedRectangleBorder), continuous rectangles
(ContinuousRectangleBorder), or beveled rectangles
(BeveledRectangleBorder).
Required Methods§
Sourcefn dimensions(&self) -> EdgeInsetsGeometry
fn dimensions(&self) -> EdgeInsetsGeometry
The widths of the sides of this border represented as an EdgeInsetsGeometry.
Sourcefn scale(&self, t: f64) -> ShapeBorderRef
fn scale(&self, t: f64) -> ShapeBorderRef
Creates a copy of this border, scaled by the factor t.
Sourcefn get_outer_path(
&self,
rect: Rect,
text_direction: Option<TextDirection>,
) -> Path
fn get_outer_path( &self, rect: Rect, text_direction: Option<TextDirection>, ) -> Path
Create a Path that describes the outer edge of the border.
Sourcefn get_inner_path(
&self,
rect: Rect,
text_direction: Option<TextDirection>,
) -> Path
fn get_inner_path( &self, rect: Rect, text_direction: Option<TextDirection>, ) -> Path
Create a Path that describes the inner edge of the border.
Sourcefn paint(
&self,
canvas: &mut DisplayListBuilder,
rect: Rect,
text_direction: Option<TextDirection>,
)
fn paint( &self, canvas: &mut DisplayListBuilder, rect: Rect, text_direction: Option<TextDirection>, )
Provided Methods§
Sourcefn add(&self, other: &ShapeBorderRef, reversed: bool) -> Option<ShapeBorderRef>
fn add(&self, other: &ShapeBorderRef, reversed: bool) -> Option<ShapeBorderRef>
Attempts to create a new object that represents the amalgamation of
this border and the other border.
If the type of the other border isn’t known, or the given instance cannot be reasonably added to this instance, then this should return None.
The reversed argument is true if this object was the right operand of
plus, and false if it was the left operand.
Sourcefn lerp_from(
&self,
a: Option<&(dyn ShapeBorder + 'static)>,
t: f64,
) -> Option<ShapeBorderRef>
fn lerp_from( &self, a: Option<&(dyn ShapeBorder + 'static)>, t: f64, ) -> Option<ShapeBorderRef>
Linearly interpolates from another ShapeBorder (possibly of another
class) to this.
Return None if this class cannot interpolate from a. If a is None,
this must not return None.
Sourcefn lerp_to(
&self,
b: Option<&(dyn ShapeBorder + 'static)>,
t: f64,
) -> Option<ShapeBorderRef>
fn lerp_to( &self, b: Option<&(dyn ShapeBorder + 'static)>, t: f64, ) -> Option<ShapeBorderRef>
Linearly interpolates from this to another ShapeBorder (possibly of
another class).
Return None if this class cannot interpolate to b. If b is None,
this must not return None.
Sourcefn hit_test(
&self,
rect: Rect,
position: Offset,
text_direction: Option<TextDirection>,
) -> bool
fn hit_test( &self, rect: Rect, position: Offset, text_direction: Option<TextDirection>, ) -> bool
Tests whether the outer boundary of this border contains position.
Sourcefn paint_interior(
&self,
canvas: &mut DisplayListBuilder,
rect: Rect,
paint: &Paint,
text_direction: Option<TextDirection>,
)
fn paint_interior( &self, canvas: &mut DisplayListBuilder, rect: Rect, paint: &Paint, text_direction: Option<TextDirection>, )
Paint a canvas with the appropriate shape.
On subclasses whose prefer_paint_interior
returns true, this should be faster than using Canvas.draw_path with
the path provided by get_outer_path.
Sourcefn prefer_paint_interior(&self) -> bool
fn prefer_paint_interior(&self) -> bool
Reports whether paint_interior is implemented.
Sourcefn as_outlined_border(&self) -> Option<&(dyn OutlinedBorder + 'static)>
fn as_outlined_border(&self) -> Option<&(dyn OutlinedBorder + 'static)>
OutlinedBorder downcast for Dart’s is OutlinedBorder.
Sourcefn into_outlined_border(self: Rc<Self>) -> Option<Rc<dyn OutlinedBorder>>
fn into_outlined_border(self: Rc<Self>) -> Option<Rc<dyn OutlinedBorder>>
OutlinedBorder downcast of the shared border, for Dart’s as OutlinedBorder
(ShapeBorderRef::as_outlined_border_ref). An OutlinedBorder answers Some(self),
as it answers as_outlined_border.
Sourcefn as_box_border(&self) -> Option<&(dyn BoxBorder + 'static)>
fn as_box_border(&self) -> Option<&(dyn BoxBorder + 'static)>
BoxBorder downcast for BoxBorderRef::lerp.
Sourcefn into_box_border(self: Rc<Self>) -> Option<Rc<dyn BoxBorder>>
fn into_box_border(self: Rc<Self>) -> Option<Rc<dyn BoxBorder>>
BoxBorder downcast of the shared border
(ShapeBorderRef::as_box_border_ref). A box border answers Some(self), as it
answers as_box_border.
Sourcefn eq_shape(&self, other: &(dyn ShapeBorder + 'static)) -> bool
fn eq_shape(&self, other: &(dyn ShapeBorder + 'static)) -> bool
Field equality. Dart’s default == is identity; subclasses that override
== implement this.
Trait Implementations§
Source§impl From<Box<dyn ShapeBorder>> for ShapeBorderRef
impl From<Box<dyn ShapeBorder>> for ShapeBorderRef
Source§fn from(border: Box<dyn ShapeBorder>) -> ShapeBorderRef
fn from(border: Box<dyn ShapeBorder>) -> ShapeBorderRef
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl ShapeBorder for BeveledRectangleBorder
impl ShapeBorder for Border
impl ShapeBorder for BorderDirectional
impl ShapeBorder for CircleBorder
impl ShapeBorder for ContinuousRectangleBorder
impl ShapeBorder for LinearBorder
impl ShapeBorder for OvalBorder
impl ShapeBorder for RoundedRectangleBorder
impl ShapeBorder for RoundedSuperellipseBorder
impl ShapeBorder for StadiumBorder
impl ShapeBorder for WidgetStateOutlinedBorder
_WidgetStateOutlinedBorder extends RoundedRectangleBorder: every ShapeBorder member is
the default rounded rectangle’s.