Skip to main content

Magnifier

Struct Magnifier 

Source
pub struct Magnifier {
    pub key: Option<KeyRef>,
    pub additional_focal_point_offset: Offset,
    pub border_radius: BorderRadius,
    pub film_color: Color,
    pub shadows: Vec<BoxShadow>,
    pub clip_behavior: Clip,
    pub size: Size,
}
Expand description

A Material-styled magnifying glass.

This widget focuses on mimicking the style of the magnifier on material. For a widget that is focused on mimicking the behavior of a material magnifier, see TextMagnifier, which uses Magnifier.

The styles implemented in this widget were based on the Android 12 source code, where possible, and on eyeballing a Pixel 6 running Android 12 otherwise.

Fields§

§key: Option<KeyRef>§additional_focal_point_offset: Offset

Any additional offset the focal point requires to “point” to the correct place.

This value is added to K_STANDARD_VERTICAL_FOCAL_POINT_SHIFT to obtain the actual offset.

This is useful for instances where the magnifier is not pointing to something directly below it.

§border_radius: BorderRadius

The border radius for this magnifier.

The magnifier’s shape is a RoundedRectangleBorder with this radius.

§film_color: Color

The color to tint the image in this Magnifier.

On native Android, there is a almost transparent gray tint to the magnifier, in order to better distinguish the contents of the lens from the background.

§shadows: Vec<BoxShadow>

A list of shadows cast by the Magnifier.

If the shadows use a BlurStyle that paints inside the shape, or if they are offset, then a clip_behavior that enables clipping (such as the default Clip::HardEdge) is recommended, otherwise the shadow will occlude the magnifier (the shadow is drawn above the magnifier so as to not be included in the magnified image).

By default, the shadows are offset vertically by two logical pixels, so clipping is recommended.

A shadow that uses BlurStyle::Outer and is not offset does not need clipping; in that case, consider setting clip_behavior to Clip::None.

§clip_behavior: Clip

Whether and how to clip the shadows that render inside the loupe.

Defaults to Clip::HardEdge.

A value of Clip::None can be used if the shadow will not paint where the magnified image appears, or if doing so is intentional (e.g. to blur the edges of the magnified image).

See the discussion at shadows.

§size: Size

The Size of this Magnifier.

The shadows are drawn outside of the size.

Implementations§

Source§

impl Magnifier

Source

pub const K_DEFAULT_MAGNIFIER_SIZE: Size

The default size of this Magnifier.

The size of the magnifier may be modified through the constructor; K_DEFAULT_MAGNIFIER_SIZE is extracted from the default parameter of Magnifier’s constructor so that positioners may depend on it.

Source

pub const K_STANDARD_VERTICAL_FOCAL_POINT_SHIFT: f64 = 22.0

The vertical distance that the magnifier should be above the focal point.

The K_STANDARD_VERTICAL_FOCAL_POINT_SHIFT value is a constant so that positioning of this Magnifier can be done with a guaranteed size, as opposed to an estimate.

Source

pub fn new() -> Magnifier

Creates a RawMagnifier in the Material style.

Source

pub fn key(self, key: KeyRef) -> Magnifier

Dart Magnifier(key:).

Source

pub fn additional_focal_point_offset( self, additional_focal_point_offset: Offset, ) -> Magnifier

Dart Magnifier(additionalFocalPointOffset:).

Source

pub fn border_radius(self, border_radius: BorderRadius) -> Magnifier

Dart Magnifier(borderRadius:).

Source

pub fn film_color(self, film_color: Color) -> Magnifier

Dart Magnifier(filmColor:).

Source

pub fn shadows(self, shadows: Vec<BoxShadow>) -> Magnifier

Dart Magnifier(shadows:).

Source

pub fn clip_behavior(self, clip_behavior: Clip) -> Magnifier

Dart Magnifier(clipBehavior:).

Source

pub fn size(self, size: Size) -> Magnifier

Dart Magnifier(size:).

Trait Implementations§

Source§

impl Debug for Magnifier

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Magnifier

Source§

fn default() -> Magnifier

Returns the “default value” for a type. Read more
Source§

impl StatelessWidget for Magnifier

Source§

fn key(&self) -> Option<&KeyRef>

Source§

fn build(&self, _app: &mut App, _context: BuildContext) -> WidgetRef

Describes the part of the user interface represented by this widget. Read more
Source§

fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )

Dart’s 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 debug_check_constructor(&self)

Dart’s constructor asserts that relate two or more arguments. Read more
Source§

fn as_preferred_size_widget( &self, ) -> Option<&(dyn PreferredSizeWidget + 'static)>

Dart’s this is PreferredSizeWidget: a widget that implements PreferredSizeWidget answers with itself, which is what a parent asking an erased child for its preferred size reads.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Magnifier

§

impl !Send for Magnifier

§

impl !Sync for Magnifier

§

impl !UnwindSafe for Magnifier

§

impl Forget for Magnifier

§

impl Freeze for Magnifier
where *const RcInner<dyn Key> is !null: Freeze, PhantomData<RcInner<dyn Key>>: Freeze, *const u8 is !null: Freeze, PhantomData<BoxShadow>: Freeze,

§

impl Move for Magnifier

§

impl Unpin for Magnifier
where Rc<dyn Key>: Unpin, *const u8 is !null: Unpin,

§

impl UnsafeUnpin for Magnifier
where *const RcInner<dyn Key> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Key>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<BoxShadow>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<W> IntoWidget<StatelessKind> for W
where W: StatelessWidget,

Source§

fn into_widget(self) -> Rc<dyn Widget>

The widget as a tree node, made where this is called: its creation_location.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>