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 mode(self, mode: CompareMode) -> Self
pub fn mode(self, mode: CompareMode) -> Self
How it shows them.
Sourcepub fn divider(self, divider: Binding<f32>) -> Self
pub fn divider(self, divider: Binding<f32>) -> Self
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>) -> Self
pub fn chosen(self, chosen: Binding<CompareSide>) -> Self
Which of the two is picked, side by side.
Sourcepub fn captions(
self,
first: impl Into<String>,
second: impl Into<String>,
) -> Self
pub fn captions( self, first: impl Into<String>, second: impl Into<String>, ) -> Self
What the small captions over the pictures say, instead of those in
Labels.
Sourcepub fn no_captions(self) -> Self
pub fn no_captions(self) -> Self
Shows no captions.
Sourcepub fn size(self, width: f32, height: f32) -> Self
pub fn size(self, width: f32, height: f32) -> Self
Fixed size in logical pixels, instead of taking the free space.
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§
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<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
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.