pub trait CustomClipper<T>: 'static {
// Required methods
fn get_clip(&self, size: Size) -> T;
fn should_reclip(&self, old_clipper: &dyn CustomClipper<T>) -> bool;
fn as_any(&self) -> &dyn Any;
// Provided method
fn reclip(&self) -> Option<&Rc<dyn Listenable>> { ... }
}Expand description
An interface for providing custom clips.
This trait is used by a number of clip widgets (e.g., ClipRect and ClipPath).
The get_clip method is called whenever the custom clip needs to be
updated.
The should_reclip method is called when a new instance of the class
is provided, to check if the new instance actually represents different information.
The most efficient way to update the clip provided by this class is to
supply a reclip listenable, which notifies its listeners when it is time to
reclip, avoiding both the build and layout phases of the pipeline.
Required Methods§
Sourcefn get_clip(&self, size: Size) -> T
fn get_clip(&self, size: Size) -> T
Returns a description of the clip given that the render object being clipped is of the given size.
Sourcefn should_reclip(&self, old_clipper: &dyn CustomClipper<T>) -> bool
fn should_reclip(&self, old_clipper: &dyn CustomClipper<T>) -> bool
Called whenever a new instance of the custom clipper delegate class is provided to the clip object, or any time that a new clip object is created with a new instance of the custom clipper delegate class (which amounts to the same thing, because the latter is implemented in terms of the former).
If the new instance represents different information than the old instance, then the method should return true, otherwise it should return false.
If the method returns false, then the get_clip call might be
optimized away.
It’s possible that the get_clip method will get called even if
should_reclip returns false or if the
should_reclip method is never called at all (e.g. if the box
changes size). It is only called with a clipper of this clipper’s own type, as Dart’s
covariant parameter is.
Provided Methods§
Sourcefn reclip(&self) -> Option<&Rc<dyn Listenable>>
fn reclip(&self) -> Option<&Rc<dyn Listenable>>
The Listenable that notifies when it is time to reclip.
Dart’s CustomClipper takes it as a constructor argument and forwards addListener /
removeListener to it; here the clipper answers with it and the same forwarding is the
Listenable implementation of dyn CustomClipper<T>.
Trait Implementations§
Source§impl<T: 'static> Listenable for dyn CustomClipper<T>
impl<T: 'static> Listenable for dyn CustomClipper<T>
Source§fn add_listener(&self, app: &mut App, listener: Listener)
fn add_listener(&self, app: &mut App, listener: Listener)
Register a closure to be notified when it is time to reclip.
Forwards to the reclip listenable, if it is not None.
Source§fn remove_listener(&self, app: &mut App, listener: &Listener)
fn remove_listener(&self, app: &mut App, listener: &Listener)
Remove a previously registered closure from the list of closures that the object notifies when it is time to reclip.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".