fix(crop-rotate): honor initAspectRatio for the initial oval cropper (#828)#839
Merged
Conversation
…828) Opening the editor directly in CropMode.oval with a fixed initAspectRatio (e.g. 1.0) rendered and exported an ellipse stretched to the full image bounds for non-square images. The main editor initializes its history with an empty transform that only carries the crop mode, so the initial state never consulted initAspectRatio and every consumer fell back to the full image aspect ratio. Add CropRotateEditorConfigs.initialOvalCropAspectRatio, which exposes the fixed ratio for the initial oval state (null for free/original/non-oval), and use it in the three places that derive the initial mask: the main editor capture overlay, the shared layer-stack overlay and the export clip (CutOutsideArea). A 1:1 ratio now produces a circle; free (-1) and original (0.0) ratios keep the previous full-image behavior.
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.
Fixes #828
Problem
Opening
ProImageEditordirectly in the oval cropper with a fixedinitAspectRatio(e.g.1.0) renders and exports an ellipse stretched to the full image bounds for any non-square image, instead of a circle.Root cause
The main editor initializes its history with an empty transform that only carries the crop mode:
initAspectRatiois never consulted for the initial state, so every consumer that derives the oval mask falls back to the full image aspect ratio:main_editor_interactive_content.dart)layer_stack.dart)CutOutsideAreaintransformed_content_generator.dart)If the user exports without first entering the crop sub-editor, the result is an ellipse.
Fix
Add
CropRotateEditorConfigs.initialOvalCropAspectRatio, which returns the fixed ratio for the initial oval state andnullwhen the full image should be used (free-1, original0.0, or a non-oval initial crop mode). All three consumers now use it as the fallback before the full-image aspect ratio, andCutOutsideAreabuilds a centered crop rect of that ratio for the initial oval mask.Result: a
1.0ratio renders/exports a circle; free (-1) and original (0.0) ratios keep the previous full-image behavior. The fix is scoped to the oval cropper so rectangular crops are unaffected (they still only crop once the user confirms in the crop sub-editor).Tests
Added
cut_outside_area_test.dartcovering the new getter (oval+fixed ratio → ratio; free/original/rectangular → null) andCutOutsideArea.getClip(non-square image → centered square for 1:1, full bounds without a fixed ratio, width-fit for a wide ratio).