pub struct ImageCompare<'a, Message> { /* private fields */ }image-compare only.Expand description
An image compare builder. Convert it into an Element to render.
The divider can only be dragged when the compare has an
on_divider message.
Implementations§
Source§impl<'a, Message> ImageCompare<'a, Message>
impl<'a, Message> ImageCompare<'a, Message>
pub fn mode(self, mode: Mode) -> Self
Sourcepub fn divider(self, divider: f32) -> Self
pub fn divider(self, divider: f32) -> Self
Where the divider sits in Mode::Slider, from 0 (all after) to 1
(all before).
Sourcepub fn opacity(self, opacity: f32) -> Self
pub fn opacity(self, opacity: f32) -> Self
How opaque the before image is in Mode::Overlay, from 0 to 1.
Sourcepub fn outlines(self, outlines: impl IntoIterator<Item = Outline>) -> Self
pub fn outlines(self, outlines: impl IntoIterator<Item = Outline>) -> Self
Adds several outlines over the images.
Sourcepub fn height(self, height: impl Into<Length>) -> Self
pub fn height(self, height: impl Into<Length>) -> Self
Follows the images’ shape by default. A fixed height letterboxes them, centred.
Sourcepub fn pixelated(self, pixelated: bool) -> Self
pub fn pixelated(self, pixelated: bool) -> Self
Draws pixels as hard squares rather than smoothing them, for screenshots compared at a large zoom.
Sourcepub fn label(self, label: impl IntoFragment<'a>) -> Self
pub fn label(self, label: impl IntoFragment<'a>) -> Self
The name tests and assistive tools know it by. “Image compare” by default.
Sourcepub fn on_divider(self, on_divider: impl Fn(f32) -> Message + 'a) -> Self
pub fn on_divider(self, on_divider: impl Fn(f32) -> Message + 'a) -> Self
Sent with the divider’s new position while it is dragged, or where a shortcut moves it.
Sourcepub fn keymap(self, keymap: Keymap<Action>) -> Self
pub fn keymap(self, keymap: Keymap<Action>) -> Self
Replaces the default_keymap the compare resolves keys with while
it has keyboard focus or was the last thing pressed.
Sourcepub fn on_hover(self, on_hover: impl Fn(Option<Point>) -> Message + 'a) -> Self
pub fn on_hover(self, on_hover: impl Fn(Option<Point>) -> Message + 'a) -> Self
Sent with the image pixel under the pointer whenever it changes, and
None when the pointer leaves the images.
Sourcepub fn on_press(self, on_press: impl Fn(Point) -> Message + 'a) -> Self
pub fn on_press(self, on_press: impl Fn(Point) -> Message + 'a) -> Self
Sent with the image pixel under a press away from the divider.
pub fn current_mode(&self) -> Mode
pub fn divider_position(&self) -> f32
pub fn is_single(&self) -> bool
Trait Implementations§
Source§impl<Message> Debug for ImageCompare<'_, Message>
impl<Message> Debug for ImageCompare<'_, Message>
Source§impl<'a, Message: 'a> From<ImageCompare<'a, Message>> for Element<'a, Message>
impl<'a, Message: 'a> From<ImageCompare<'a, Message>> for Element<'a, Message>
Source§fn from(compare: ImageCompare<'a, Message>) -> Self
fn from(compare: ImageCompare<'a, Message>) -> Self
Source§impl<Message> Widget<Message, Theme, ()> for ImageCompare<'_, Message>
impl<Message> Widget<Message, Theme, ()> for ImageCompare<'_, Message>
Source§fn draw(
&self,
tree: &Tree,
renderer: &mut Renderer,
theme: &Theme,
_style: &Style,
layout: Layout<'_>,
cursor: Cursor,
_viewport: &Rectangle,
)
fn draw( &self, tree: &Tree, renderer: &mut Renderer, theme: &Theme, _style: &Style, layout: Layout<'_>, cursor: Cursor, _viewport: &Rectangle, )
Widget using the associated Renderer.Source§fn update(
&mut self,
tree: &mut Tree,
event: &Event,
layout: Layout<'_>,
cursor: Cursor,
renderer: &Renderer,
_clipboard: &mut dyn Clipboard,
shell: &mut Shell<'_, Message>,
_viewport: &Rectangle,
)
fn update( &mut self, tree: &mut Tree, event: &Event, layout: Layout<'_>, cursor: Cursor, renderer: &Renderer, _clipboard: &mut dyn Clipboard, shell: &mut Shell<'_, Message>, _viewport: &Rectangle, )
Source§fn mouse_interaction(
&self,
tree: &Tree,
layout: Layout<'_>,
cursor: Cursor,
_viewport: &Rectangle,
renderer: &Renderer,
) -> Interaction
fn mouse_interaction( &self, tree: &Tree, layout: Layout<'_>, cursor: Cursor, _viewport: &Rectangle, renderer: &Renderer, ) -> Interaction
Auto Trait Implementations§
impl<'a, Message> !Freeze for ImageCompare<'a, Message>
impl<'a, Message> !RefUnwindSafe for ImageCompare<'a, Message>
impl<'a, Message> !Send for ImageCompare<'a, Message>
impl<'a, Message> !Sync for ImageCompare<'a, Message>
impl<'a, Message> !UnwindSafe for ImageCompare<'a, Message>
impl<'a, Message> Forget for ImageCompare<'a, Message>
impl<'a, Message> Move for ImageCompare<'a, Message>
impl<'a, Message> Unpin for ImageCompare<'a, Message>where
*const u8 is !null: Unpin,
*const u8: Unpin,
Align8<*mut ()>: Unpin,
&'static Vtable: Unpin,
&'a str: Unpin,
String: Unpin,
&'static str: Unpin,
Arc<str>: Unpin,
InternalBitFlags: Unpin,
Box<dyn Fn(f32) -> Message + 'a>: Unpin,
Box<dyn Fn(Option<Point>) -> Message + 'a>: Unpin,
Box<dyn Fn(Point) -> Message + 'a>: Unpin,
impl<'a, Message> UnsafeUnpin for ImageCompare<'a, Message>where
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
*const u8: UnsafeUnpin,
Align8<*mut ()>: UnsafeUnpin,
&'static Vtable: UnsafeUnpin,
PhantomData<Outline>: UnsafeUnpin,
&'a str: UnsafeUnpin,
String: UnsafeUnpin,
PhantomData<(Chord, Action)>: UnsafeUnpin,
*const dyn Fn(f32) -> Message + 'a is !null: UnsafeUnpin,
PhantomData<dyn Fn(f32) -> Message + 'a>: UnsafeUnpin,
*const dyn Fn(Option<Point>) -> Message + 'a is !null: UnsafeUnpin,
PhantomData<dyn Fn(Option<Point>) -> Message + 'a>: UnsafeUnpin,
*const dyn Fn(Point) -> Message + 'a is !null: UnsafeUnpin,
PhantomData<dyn Fn(Point) -> Message + 'a>: 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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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.Source§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.Source§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.Source§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.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<State, Message> IntoBoot<State, Message> for State
impl<State, Message> IntoBoot<State, Message> for State
Source§fn into_boot(self) -> (State, Task<Message>)
fn into_boot(self) -> (State, Task<Message>)
Application.