pub struct ClipRect {
pub key: Option<KeyRef>,
pub clipper: Option<Rc<dyn CustomClipper<Rect>>>,
pub clip_behavior: Clip,
pub child: Option<WidgetRef>,
}Expand description
A widget that clips its child using a rectangle.
By default, ClipRect prevents its child from painting outside its
bounds, but the size and location of the clip rect can be customized using a
custom clipper.
ClipRect is commonly used with these widgets, which commonly paint outside
their bounds:
CustomPaintCustomSingleChildLayoutCustomMultiChildLayoutAlignandCenter(e.g., ifAlign::width_factororAlign::height_factoris less than 1.0).OverflowBoxSizedOverflowBox
For example, by combining a ClipRect with an Align, one can show just
the top half of an image:
ClipRect::new().child(
Align::new()
.alignment(AlignmentGeometry::TOP_CENTER)
.height_factor(0.5)
.child(avatar),
)See also:
CustomClipper, for information about creating custom clips.ClipRRect, for a clip with rounded corners.ClipOval, for an elliptical clip.ClipPath, for an arbitrarily shaped clip.
Fields§
§key: Option<KeyRef>§clipper: Option<Rc<dyn CustomClipper<Rect>>>If non-None, determines which clip to use.
clip_behavior: ClipWhether and how to clip the child.
Defaults to Clip::HardEdge.
child: Option<WidgetRef>Implementations§
Source§impl ClipRect
impl ClipRect
Sourcepub fn new() -> ClipRect
pub fn new() -> ClipRect
Creates a rectangular clip; Dart’s named arguments are the setters.
If clipper is None, the clip will match the layout size and
position of the child.
If clip_behavior is Clip::None, no clipping will be
applied.
Sourcepub fn clipper(self, clipper: impl CustomClipper<Rect>) -> ClipRect
pub fn clipper(self, clipper: impl CustomClipper<Rect>) -> ClipRect
Dart ClipRect(clipper:).
Sourcepub fn clip_behavior(self, clip_behavior: Clip) -> ClipRect
pub fn clip_behavior(self, clip_behavior: Clip) -> ClipRect
Dart ClipRect(clipBehavior:).
Sourcepub fn child<K>(self, child: impl IntoWidget<K>) -> ClipRect
pub fn child<K>(self, child: impl IntoWidget<K>) -> ClipRect
Dart ClipRect(child:).
Trait Implementations§
Source§impl RenderObjectWidget for ClipRect
impl RenderObjectWidget for ClipRect
Source§type RenderObject = RenderClipRect
type RenderObject = RenderClipRect
covariant RenderObject parameter type.Source§fn debug_fill_properties(
&self,
_app: &App,
properties: &mut DiagnosticPropertiesBuilder,
)
fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )
debugFillProperties: the properties a dump shows for this widget, in Dart’s
order. Dart’s Widget base only sets the dense tree style, which the framework does.Source§fn create_render_object(
&self,
app: &mut App,
_context: BuildContext,
) -> AnyRenderObject
fn create_render_object( &self, app: &mut App, _context: BuildContext, ) -> AnyRenderObject
RenderObject class that this widget represents, using the
configuration described by this widget. Read moreSource§fn update_render_object(
&self,
app: &mut App,
_context: BuildContext,
render_object: RenderHandle<RenderClipRect>,
)
fn update_render_object( &self, app: &mut App, _context: BuildContext, render_object: RenderHandle<RenderClipRect>, )
create_render_object. Read moreSource§fn did_unmount_render_object(
&self,
app: &mut App,
render_object: RenderHandle<RenderClipRect>,
)
fn did_unmount_render_object( &self, app: &mut App, render_object: RenderHandle<RenderClipRect>, )
RenderObject will be of the same type as returned by this object’s
create_render_object.Source§fn to_string_short(&self) -> String
fn to_string_short(&self) -> String
toStringShort, for a widget that names itself apart from its type, as
SizedBox.expand does; see Widget::to_string_short.Source§fn debug_visit_onstage_children(
&self,
app: &App,
children: &[AnyElement],
visitor: &mut dyn FnMut(AnyElement),
)
fn debug_visit_onstage_children( &self, app: &App, children: &[AnyElement], visitor: &mut dyn FnMut(AnyElement), )
debugVisitOnstageChildren of the element this widget makes, for a widget whose
Dart element subclass overrides it only to hide children (_OffstageElement,
_IndexedStackElement): calls visitor for each of children, in order, that is
onstage. Waft’s generic single- and multi-child elements stand in for those subclasses
and ask their widget here; an element of a widget’s own overrides
Element::debug_visit_onstage_children instead.Auto Trait Implementations§
impl !RefUnwindSafe for ClipRect
impl !Send for ClipRect
impl !Sync for ClipRect
impl !UnwindSafe for ClipRect
impl Forget for ClipRect
impl Freeze for ClipRectwhere
*const RcInner<dyn Key> is !null: Freeze,
PhantomData<RcInner<dyn Key>>: Freeze,
*const RcInner<dyn CustomClipper<Rect>> is !null: Freeze,
PhantomData<RcInner<dyn CustomClipper<Rect>>>: Freeze,
*const RcInner<dyn Widget> is !null: Freeze,
PhantomData<RcInner<dyn Widget>>: Freeze,
impl Move for ClipRect
impl Unpin for ClipRect
impl UnsafeUnpin for ClipRectwhere
*const RcInner<dyn Key> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Key>>: UnsafeUnpin,
*const RcInner<dyn CustomClipper<Rect>> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn CustomClipper<Rect>>>: UnsafeUnpin,
*const RcInner<dyn Widget> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Widget>>: UnsafeUnpin,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<W> IntoWidget<SingleChildRenderObjectKind> for Wwhere
W: SingleChildRenderObjectWidget,
<W as RenderObjectWidget>::RenderObject: RenderObjectWithChildMixin,
impl<W> IntoWidget<SingleChildRenderObjectKind> for Wwhere
W: SingleChildRenderObjectWidget,
<W as RenderObjectWidget>::RenderObject: RenderObjectWithChildMixin,
Source§fn into_widget(self) -> Rc<dyn Widget>
fn into_widget(self) -> Rc<dyn Widget>
creation_location.