diff --git a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGPhotoAvatarCropView.h b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGPhotoAvatarCropView.h index 98f4b11d96..fd0ee10637 100644 --- a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGPhotoAvatarCropView.h +++ b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGPhotoAvatarCropView.h @@ -20,7 +20,7 @@ @property (nonatomic, readonly) bool isTracking; @property (nonatomic, readonly) bool isAnimating; -- (instancetype)initWithOriginalSize:(CGSize)originalSize screenSize:(CGSize)screenSize fullPreviewView:(PGPhotoEditorView *)fullPreviewView; +- (instancetype)initWithOriginalSize:(CGSize)originalSize screenSize:(CGSize)screenSize fullPreviewView:(PGPhotoEditorView *)fullPreviewView fullPaintingView:(UIImageView *)fullPaintingView; - (void)setSnapshotImage:(UIImage *)image; - (void)setSnapshotView:(UIView *)snapshotView; diff --git a/submodules/LegacyComponents/Sources/TGPhotoAvatarCropController.m b/submodules/LegacyComponents/Sources/TGPhotoAvatarCropController.m index e4c6d0f5f2..65945b77d9 100644 --- a/submodules/LegacyComponents/Sources/TGPhotoAvatarCropController.m +++ b/submodules/LegacyComponents/Sources/TGPhotoAvatarCropController.m @@ -88,7 +88,7 @@ const CGFloat TGPhotoAvatarCropButtonsWrapperSize = 61.0f; [self.view addSubview:_wrapperView]; PGPhotoEditor *photoEditor = self.photoEditor; - _cropView = [[TGPhotoAvatarCropView alloc] initWithOriginalSize:photoEditor.originalSize screenSize:[self referenceViewSize] fullPreviewView:nil]; + _cropView = [[TGPhotoAvatarCropView alloc] initWithOriginalSize:photoEditor.originalSize screenSize:[self referenceViewSize] fullPreviewView:nil fullPaintingView:nil]; [_cropView setCropRect:photoEditor.cropRect]; [_cropView setCropOrientation:photoEditor.cropOrientation]; [_cropView setCropMirrored:photoEditor.cropMirrored]; diff --git a/submodules/LegacyComponents/Sources/TGPhotoAvatarCropView.m b/submodules/LegacyComponents/Sources/TGPhotoAvatarCropView.m index 7666ec7bb6..f2de64a4ba 100644 --- a/submodules/LegacyComponents/Sources/TGPhotoAvatarCropView.m +++ b/submodules/LegacyComponents/Sources/TGPhotoAvatarCropView.m @@ -42,12 +42,13 @@ const CGFloat TGPhotoAvatarCropViewCurtainMargin = 200; CGFloat _currentDiameter; __weak PGPhotoEditorView *_fullPreviewView; + __weak UIImageView *_fullPaintingView; } @end @implementation TGPhotoAvatarCropView -- (instancetype)initWithOriginalSize:(CGSize)originalSize screenSize:(CGSize)screenSize fullPreviewView:(PGPhotoEditorView *)fullPreviewView +- (instancetype)initWithOriginalSize:(CGSize)originalSize screenSize:(CGSize)screenSize fullPreviewView:(PGPhotoEditorView *)fullPreviewView fullPaintingView:(UIImageView *)fullPaintingView { self = [super initWithFrame:CGRectZero]; if (self != nil) @@ -82,7 +83,12 @@ const CGFloat TGPhotoAvatarCropViewCurtainMargin = 200; CGFloat scale = _imageView.bounds.size.width / fittedSize.width; _fullPreviewView.transform = CGAffineTransformMakeScale(self.cropMirrored ? -scale : scale, scale); _fullPreviewView.userInteractionEnabled = false; + + _fullPaintingView = fullPaintingView; + _fullPaintingView.frame = _fullPreviewView.frame; + _fullPaintingView.transform = CGAffineTransformMakeScale(self.cropMirrored ? -1.0 : 1.0, 1.0); [_wrapperView addSubview:_fullPreviewView]; + [_wrapperView addSubview:_fullPaintingView]; _flashView = [[UIView alloc] init]; _flashView.alpha = 0.0; @@ -452,6 +458,7 @@ const CGFloat TGPhotoAvatarCropViewCurtainMargin = 200; CGSize fittedSize = TGScaleToSize(_originalSize, CGSizeMake(1024, 1024)); CGFloat scale = _imageView.bounds.size.width / fittedSize.width; _fullPreviewView.transform = CGAffineTransformMakeScale(self.cropMirrored ? -scale : scale, scale); + _fullPaintingView.transform = CGAffineTransformMakeScale(self.cropMirrored ? -1.0 : 1.0, 1.0); } - (void)invalidateCropRect diff --git a/submodules/LegacyComponents/Sources/TGPhotoAvatarPreviewController.h b/submodules/LegacyComponents/Sources/TGPhotoAvatarPreviewController.h index ca98f9a308..a4587f0318 100644 --- a/submodules/LegacyComponents/Sources/TGPhotoAvatarPreviewController.h +++ b/submodules/LegacyComponents/Sources/TGPhotoAvatarPreviewController.h @@ -18,6 +18,7 @@ @property (nonatomic, weak) UIView *dotImageView; @property (nonatomic, weak) UIView *dotMarkerView; @property (nonatomic, weak) PGPhotoEditorView *fullPreviewView; +@property (nonatomic, weak) UIImageView *fullPaintingView; @property (nonatomic, weak) TGMediaPickerGalleryVideoScrubber *scrubberView; - (instancetype)initWithContext:(id)context photoEditor:(PGPhotoEditor *)photoEditor previewView:(TGPhotoEditorPreviewView *)previewView; diff --git a/submodules/LegacyComponents/Sources/TGPhotoAvatarPreviewController.m b/submodules/LegacyComponents/Sources/TGPhotoAvatarPreviewController.m index 789b772b09..138c163556 100644 --- a/submodules/LegacyComponents/Sources/TGPhotoAvatarPreviewController.m +++ b/submodules/LegacyComponents/Sources/TGPhotoAvatarPreviewController.m @@ -63,10 +63,6 @@ const CGFloat TGPhotoAvatarPreviewLandscapePanelSize = TGPhotoAvatarPreviewPanel return self; } -- (void)dealloc { - NSLog(@""); -} - - (void)loadView { [super loadView]; @@ -99,7 +95,7 @@ const CGFloat TGPhotoAvatarPreviewLandscapePanelSize = TGPhotoAvatarPreviewPanel }; PGPhotoEditor *photoEditor = self.photoEditor; - TGPhotoAvatarCropView *cropView = [[TGPhotoAvatarCropView alloc] initWithOriginalSize:photoEditor.originalSize screenSize:[self referenceViewSize] fullPreviewView:_fullPreviewView]; + TGPhotoAvatarCropView *cropView = [[TGPhotoAvatarCropView alloc] initWithOriginalSize:photoEditor.originalSize screenSize:[self referenceViewSize] fullPreviewView:_fullPreviewView fullPaintingView:_fullPaintingView]; _cropView = cropView; [_cropView setCropRect:photoEditor.cropRect]; [_cropView setCropOrientation:photoEditor.cropOrientation]; diff --git a/submodules/LegacyComponents/Sources/TGPhotoEditorController.m b/submodules/LegacyComponents/Sources/TGPhotoEditorController.m index 3e719ef8a3..ec973426ea 100644 --- a/submodules/LegacyComponents/Sources/TGPhotoEditorController.m +++ b/submodules/LegacyComponents/Sources/TGPhotoEditorController.m @@ -69,6 +69,7 @@ TGPhotoToolbarView *_landscapeToolbarView; TGPhotoEditorPreviewView *_previewView; PGPhotoEditorView *_fullPreviewView; + UIImageView *_fullPaintingView; PGPhotoEditor *_photoEditor; @@ -335,6 +336,9 @@ _fullPreviewView = [[PGPhotoEditorView alloc] initWithFrame:CGRectMake(0, 0, fittedSize.width, fittedSize.height)]; _photoEditor.additionalOutputs = @[_fullPreviewView]; [self.view addSubview:_fullPreviewView]; + + _fullPaintingView = [[UIImageView alloc] init]; + _fullPaintingView.frame = _fullPreviewView.frame; } _dotMarkerView = [[UIImageView alloc] initWithImage:TGCircleImage(7.0, [TGPhotoEditorInterfaceAssets accentColor])]; @@ -1219,6 +1223,7 @@ { case TGPhotoEditorCropTab: { + [self updatePreviewView:true]; __block UIView *initialBackgroundView = nil; if ([self presentedForAvatarCreation]) @@ -1230,6 +1235,7 @@ cropController.dotImageView = _dotImageView; cropController.dotMarkerView = _dotMarkerView; cropController.fullPreviewView = _fullPreviewView; + cropController.fullPaintingView = _fullPaintingView; cropController.fromCamera = [self presentedFromCamera]; cropController.skipTransitionIn = skipInitialTransition; if (snapshotImage != nil) @@ -1614,9 +1620,10 @@ - (void)updatePreviewView:(bool)full { - if (full) + if (full) { [_previewView setPaintingImageWithData:_photoEditor.paintingData]; - + _fullPaintingView.image = _photoEditor.paintingData.image; + } UIImageOrientation cropOrientation = _photoEditor.cropOrientation; if ([self presentedForAvatarCreation]) { cropOrientation = UIImageOrientationUp; diff --git a/submodules/LegacyComponents/Sources/TGPhotoEditorPreviewView.m b/submodules/LegacyComponents/Sources/TGPhotoEditorPreviewView.m index b88dd69ab6..ed90cd3dfa 100644 --- a/submodules/LegacyComponents/Sources/TGPhotoEditorPreviewView.m +++ b/submodules/LegacyComponents/Sources/TGPhotoEditorPreviewView.m @@ -289,7 +289,7 @@ _paintingContainerView.transform = CGAffineTransformMakeRotation(rotation); _paintingContainerView.frame = self.bounds; - CGFloat width = TGOrientationIsSideward(_cropOrientation, NULL) ? self.frame.size.height : self.frame.size.width; + CGFloat width = TGOrientationIsSideward(_cropOrientation, NULL) ? self.bounds.size.height : self.bounds.size.width; CGFloat ratio = 1.0; if (_cropRect.size.width > 0.0) { ratio = width / _cropRect.size.width;