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 aspect(self, aspect: Option<f32>) -> Self
pub fn aspect(self, aspect: Option<f32>) -> Self
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) -> Self
pub fn angle_limit(self, degrees: f32) -> Self
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>) -> Self
pub fn guide(self, guide: Option<CompositionGuide>) -> Self
The lines inside the frame, or none (thirds by default).
Sourcepub fn turning_guide(self, guide: Option<CompositionGuide>) -> Self
pub fn turning_guide(self, guide: Option<CompositionGuide>) -> Self
The lines inside the frame while it turns (eight parts by default).
Sourcepub fn min_size(self, pixels: f32) -> Self
pub fn min_size(self, pixels: f32) -> Self
The smallest side, in logical pixels on screen at the current zoom (24 by default).
Source§impl CropOverlay
impl CropOverlay
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.
Sourcepub fn grow(self, grow: f32) -> Self
pub fn grow(self, grow: f32) -> Self
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) -> Self
pub fn stage(self, stage: impl View + 'static) -> Self
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) -> Self
pub fn space(self, space: ContentSpace) -> Self
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§
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.