feat(crop-rotate): keep aspect ratio orientation on rotate#829
Merged
Conversation
Add an opt-in `CropRotateEditorConfigs.enableKeepAspectRatioOnRotate` flag that keeps the crop frame's orientation when the image is rotated, so a `9:16` crop stays `9:16` instead of inverting to `16:9`. The image is zoomed in to fully cover the crop area, and the crop overlay is faded out/in during the rotation so the frame never appears to change its aspect ratio mid-rotation. Works for fixed, `original` and `free` aspect ratios. Defaults to `false` to keep the existing behavior (backward compatible). Closes #655
056caa0 to
ffce5fb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #655.
Adds an opt-in flag
CropRotateEditorConfigs.enableKeepAspectRatioOnRotatethat keeps the crop frame's orientation when the image is rotated. With it enabled, a9:16crop stays9:16after a 90° rotation instead of inverting to16:9, and the image is zoomed in so it still fully covers the crop area.original(0) andfree(-1) aspect ratios — the current crop frame orientation is preserved by inverting its ratio.false, so existing behavior is unchanged (backward compatible, as requested in the issue).How it works
9:16frame visibly widen towards1:1at the 45° mark. To avoid this, during a locked rotation the crop overlay is faded out, the image rotates + zooms while the frame is hidden, and the frame is then faded back in at the preserved aspect ratio.calcCropRect(newRatio: …)), which keeps the on-screen orientation regardless of the ratio mode.angle,flipX/flipY, exportcropRect) are unchanged, so cropping/export stay correct — no flip-swap changes were needed.Changes
CropRotateEditorConfigs: newenableKeepAspectRatioOnRotateflag (+copyWith).CropRotateEditor: locked-rotation flow (fade out → rotate/zoom → fade in); only active when the flag is enabled, otherwise the normal rotate path is used.CropCornerPainter: newframeOpacitymultiplier to cleanly fade the crop overlay to transparent (the existingfadeInOpacityblends towards the background/hero state, which would hide the image outside the crop while rotating).Tests
Added widget tests covering the enabled (fixed + free ratio) and disabled cases.
flutter analyzeis clean and all crop-rotate tests pass.