pub struct CompareView { /* private fields */ }Expand description
Two pictures to tell apart: side by side, or one over the other with a divider between what shows of each. The divider follows a drag from anywhere, the arrows (with Shift, further), Home and End, and a double click puts it in the middle. A picture that does not have the proportions of the box is fitted in it, centered.
With chosen, side by side, a click or the arrows pick one of the two, which
is marked with a check as well as a colored outline.
A drag of the divider paints without a build, so it costs no rebuilds if nothing else reads its position.
use ravenrs_core::{Color, ImageData};
use ravenrs_widgets::{CompareMode, CompareView};
let before = ImageData::from_fn(64, 48, |_, _| Color::rgb(0.3, 0.3, 0.3));
let after = ImageData::from_fn(64, 48, |_, _| Color::rgb(0.6, 0.5, 0.3));
if let (Some(before), Some(after)) = (before, after) {
let compare = CompareView::new(before, after).mode(CompareMode::Divider).size(480.0, 320.0);
}Implementations§
Source§impl CompareView
impl CompareView
Sourcepub fn new(first: ImageData, second: ImageData) -> CompareView
pub fn new(first: ImageData, second: ImageData) -> CompareView
Compares two pictures, side by side.
Sourcepub fn mode(self, mode: CompareMode) -> CompareView
pub fn mode(self, mode: CompareMode) -> CompareView
How it shows them.
Sourcepub fn divider(self, divider: Binding<f32>) -> CompareView
pub fn divider(self, divider: Binding<f32>) -> CompareView
Where the divider is, from 0 (all of the second) to 1 (all of the first). Without this it keeps its own, starting in the middle.
Sourcepub fn chosen(self, chosen: Binding<CompareSide>) -> CompareView
pub fn chosen(self, chosen: Binding<CompareSide>) -> CompareView
Which of the two is picked, side by side.
Sourcepub fn captions(
self,
first: impl Into<String>,
second: impl Into<String>,
) -> CompareView
pub fn captions( self, first: impl Into<String>, second: impl Into<String>, ) -> CompareView
What the small captions over the pictures say, instead of those in
Labels.
Sourcepub fn no_captions(self) -> CompareView
pub fn no_captions(self) -> CompareView
Shows no captions.
Sourcepub fn size(self, width: f32, height: f32) -> CompareView
pub fn size(self, width: f32, height: f32) -> CompareView
Fixed size in logical pixels, instead of taking the free space.
Sourcepub fn grow(self, grow: f32) -> CompareView
pub fn grow(self, grow: f32) -> CompareView
How much of the free space along the parent stack it takes (1 by default).
Trait Implementations§
Source§impl Debug for CompareView
impl Debug for CompareView
Auto Trait Implementations§
impl !RefUnwindSafe for CompareView
impl !Send for CompareView
impl !Sync for CompareView
impl !UnwindSafe for CompareView
impl Freeze for CompareView
impl Unpin for CompareView
impl UnsafeUnpin for CompareView
Blanket Implementations§
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
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
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
fn to_sample_(self) -> U
Source§impl<V> ViewExt for Vwhere
V: View,
impl<V> ViewExt for Vwhere
V: View,
Source§fn padding(self, padding: impl Into<Insets>) -> Styled<Self>
fn padding(self, padding: impl Into<Insets>) -> Styled<Self>
Source§fn background(self, fill: impl Into<Fill>) -> Styled<Self>
fn background(self, fill: impl Into<Fill>) -> Styled<Self>
Source§fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
None keeps the content size.