pub struct CropOverlay { /* private fields */ }Expand description
A crop over a picture: what is out of the frame goes dark, with thirds inside the frame and
a fine grid while it turns. It is built on TransformHandles and draws the same lines as
RuleOfThirdsGrid.
Handles resize it, a drag inside moves it, a drag outside turns it, and it never leaves the content: turning makes it smaller if it must. It hands back the rectangle and the angle and does not turn the picture, since the renderer has no transforms.
Keyboard: the arrows move it, with Alt they resize it, [ and ] turn it, and Shift makes
each of these go further. A Protractor can share the angle through
Binding::map.
use ravenrs_core::{Rect, Size};
use ravenrs_reactive::State;
use ravenrs_widgets::{ContentSpace, CropArea, CropOverlay, Protractor};
let crop = State::new(CropArea::new(Rect::new(300.0, 200.0, 1800.0, 1200.0)));
let overlay = CropOverlay::new(crop.binding())
.aspect(Some(3.0 / 2.0))
.space(ContentSpace::Fit(Size::new(2400.0, 1600.0)))
.size(600.0, 400.0);
let straighten = Protractor::new(crop.binding().map(|c| c.angle, |c, angle| c.angle = angle));Implementations§
Source§impl CropOverlay
impl CropOverlay
Sourcepub fn new(area: Binding<CropArea>) -> CropOverlay
pub fn new(area: Binding<CropArea>) -> CropOverlay
A crop bound to area, in the units of its space.
Sourcepub fn aspect(self, aspect: Option<f32>) -> CropOverlay
pub fn aspect(self, aspect: Option<f32>) -> CropOverlay
Holds this width over height, or lets it go free with None. A crop of other proportions
is cut down to these as soon as this changes.
Sourcepub fn angle_limit(self, degrees: f32) -> CropOverlay
pub fn angle_limit(self, degrees: f32) -> CropOverlay
How far it can turn either way, in degrees (45 by default). With 0 it does not turn.
Sourcepub fn guide(self, guide: Option<CompositionGuide>) -> CropOverlay
pub fn guide(self, guide: Option<CompositionGuide>) -> CropOverlay
The lines inside the frame, or none (thirds by default).
Sourcepub fn turning_guide(self, guide: Option<CompositionGuide>) -> CropOverlay
pub fn turning_guide(self, guide: Option<CompositionGuide>) -> CropOverlay
The lines inside the frame while it turns (eight parts by default).
Sourcepub fn min_size(self, pixels: f32) -> CropOverlay
pub fn min_size(self, pixels: f32) -> CropOverlay
The smallest side, in logical pixels on screen at the current zoom (24 by default).
Sourcepub fn on_commit(self, handler: impl Fn(CropArea) + 'static) -> CropOverlay
pub fn on_commit(self, handler: impl Fn(CropArea) + 'static) -> CropOverlay
Runs handler with the result when a drag ends or a key changes it: one step to undo.
Sourcepub fn disabled(self, disabled: bool) -> CropOverlay
pub fn disabled(self, disabled: bool) -> CropOverlay
Takes no input while disabled.
Source§impl CropOverlay
impl CropOverlay
Sourcepub fn size(self, width: f32, height: f32) -> CropOverlay
pub fn size(self, width: f32, height: f32) -> CropOverlay
Fixed size in logical pixels, instead of taking the free space.
Sourcepub fn grow(self, grow: f32) -> CropOverlay
pub fn grow(self, grow: f32) -> CropOverlay
How much of the free space along the parent stack it takes: 1 by default, or 0 over a stage, which then decides the size.
Sourcepub fn stage(self, stage: impl View + 'static) -> CropOverlay
pub fn stage(self, stage: impl View + 'static) -> CropOverlay
The view it goes over, such as an Image or a
ZoomPanView, which gives it its size. Without one, put it in
a ZStack with a fixed size.
Sourcepub fn space(self, space: ContentSpace) -> CropOverlay
pub fn space(self, space: ContentSpace) -> CropOverlay
Where the content is, and so the units of its coordinates: by default, its own box.
Trait Implementations§
Source§impl Debug for CropOverlay
impl Debug for CropOverlay
Auto Trait Implementations§
impl !RefUnwindSafe for CropOverlay
impl !Send for CropOverlay
impl !Sync for CropOverlay
impl !UnwindSafe for CropOverlay
impl Freeze for CropOverlay
impl Unpin for CropOverlay
impl UnsafeUnpin for CropOverlay
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.