mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-17 11:50:56 +00:00
Video avatar fixes
This commit is contained in:
parent
9b89206ec3
commit
bb8595a0ee
@ -20,7 +20,7 @@
|
|||||||
@property (nonatomic, readonly) bool isTracking;
|
@property (nonatomic, readonly) bool isTracking;
|
||||||
@property (nonatomic, readonly) bool isAnimating;
|
@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)setSnapshotImage:(UIImage *)image;
|
||||||
- (void)setSnapshotView:(UIView *)snapshotView;
|
- (void)setSnapshotView:(UIView *)snapshotView;
|
||||||
|
|||||||
@ -88,7 +88,7 @@ const CGFloat TGPhotoAvatarCropButtonsWrapperSize = 61.0f;
|
|||||||
[self.view addSubview:_wrapperView];
|
[self.view addSubview:_wrapperView];
|
||||||
|
|
||||||
PGPhotoEditor *photoEditor = self.photoEditor;
|
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 setCropRect:photoEditor.cropRect];
|
||||||
[_cropView setCropOrientation:photoEditor.cropOrientation];
|
[_cropView setCropOrientation:photoEditor.cropOrientation];
|
||||||
[_cropView setCropMirrored:photoEditor.cropMirrored];
|
[_cropView setCropMirrored:photoEditor.cropMirrored];
|
||||||
|
|||||||
@ -42,12 +42,13 @@ const CGFloat TGPhotoAvatarCropViewCurtainMargin = 200;
|
|||||||
CGFloat _currentDiameter;
|
CGFloat _currentDiameter;
|
||||||
|
|
||||||
__weak PGPhotoEditorView *_fullPreviewView;
|
__weak PGPhotoEditorView *_fullPreviewView;
|
||||||
|
__weak UIImageView *_fullPaintingView;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation TGPhotoAvatarCropView
|
@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];
|
self = [super initWithFrame:CGRectZero];
|
||||||
if (self != nil)
|
if (self != nil)
|
||||||
@ -82,7 +83,12 @@ const CGFloat TGPhotoAvatarCropViewCurtainMargin = 200;
|
|||||||
CGFloat scale = _imageView.bounds.size.width / fittedSize.width;
|
CGFloat scale = _imageView.bounds.size.width / fittedSize.width;
|
||||||
_fullPreviewView.transform = CGAffineTransformMakeScale(self.cropMirrored ? -scale : scale, scale);
|
_fullPreviewView.transform = CGAffineTransformMakeScale(self.cropMirrored ? -scale : scale, scale);
|
||||||
_fullPreviewView.userInteractionEnabled = false;
|
_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:_fullPreviewView];
|
||||||
|
[_wrapperView addSubview:_fullPaintingView];
|
||||||
|
|
||||||
_flashView = [[UIView alloc] init];
|
_flashView = [[UIView alloc] init];
|
||||||
_flashView.alpha = 0.0;
|
_flashView.alpha = 0.0;
|
||||||
@ -452,6 +458,7 @@ const CGFloat TGPhotoAvatarCropViewCurtainMargin = 200;
|
|||||||
CGSize fittedSize = TGScaleToSize(_originalSize, CGSizeMake(1024, 1024));
|
CGSize fittedSize = TGScaleToSize(_originalSize, CGSizeMake(1024, 1024));
|
||||||
CGFloat scale = _imageView.bounds.size.width / fittedSize.width;
|
CGFloat scale = _imageView.bounds.size.width / fittedSize.width;
|
||||||
_fullPreviewView.transform = CGAffineTransformMakeScale(self.cropMirrored ? -scale : scale, scale);
|
_fullPreviewView.transform = CGAffineTransformMakeScale(self.cropMirrored ? -scale : scale, scale);
|
||||||
|
_fullPaintingView.transform = CGAffineTransformMakeScale(self.cropMirrored ? -1.0 : 1.0, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)invalidateCropRect
|
- (void)invalidateCropRect
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
@property (nonatomic, weak) UIView *dotImageView;
|
@property (nonatomic, weak) UIView *dotImageView;
|
||||||
@property (nonatomic, weak) UIView *dotMarkerView;
|
@property (nonatomic, weak) UIView *dotMarkerView;
|
||||||
@property (nonatomic, weak) PGPhotoEditorView *fullPreviewView;
|
@property (nonatomic, weak) PGPhotoEditorView *fullPreviewView;
|
||||||
|
@property (nonatomic, weak) UIImageView *fullPaintingView;
|
||||||
@property (nonatomic, weak) TGMediaPickerGalleryVideoScrubber *scrubberView;
|
@property (nonatomic, weak) TGMediaPickerGalleryVideoScrubber *scrubberView;
|
||||||
|
|
||||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context photoEditor:(PGPhotoEditor *)photoEditor previewView:(TGPhotoEditorPreviewView *)previewView;
|
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context photoEditor:(PGPhotoEditor *)photoEditor previewView:(TGPhotoEditorPreviewView *)previewView;
|
||||||
|
|||||||
@ -63,10 +63,6 @@ const CGFloat TGPhotoAvatarPreviewLandscapePanelSize = TGPhotoAvatarPreviewPanel
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc {
|
|
||||||
NSLog(@"");
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)loadView
|
- (void)loadView
|
||||||
{
|
{
|
||||||
[super loadView];
|
[super loadView];
|
||||||
@ -99,7 +95,7 @@ const CGFloat TGPhotoAvatarPreviewLandscapePanelSize = TGPhotoAvatarPreviewPanel
|
|||||||
};
|
};
|
||||||
|
|
||||||
PGPhotoEditor *photoEditor = self.photoEditor;
|
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 = cropView;
|
||||||
[_cropView setCropRect:photoEditor.cropRect];
|
[_cropView setCropRect:photoEditor.cropRect];
|
||||||
[_cropView setCropOrientation:photoEditor.cropOrientation];
|
[_cropView setCropOrientation:photoEditor.cropOrientation];
|
||||||
|
|||||||
@ -69,6 +69,7 @@
|
|||||||
TGPhotoToolbarView *_landscapeToolbarView;
|
TGPhotoToolbarView *_landscapeToolbarView;
|
||||||
TGPhotoEditorPreviewView *_previewView;
|
TGPhotoEditorPreviewView *_previewView;
|
||||||
PGPhotoEditorView *_fullPreviewView;
|
PGPhotoEditorView *_fullPreviewView;
|
||||||
|
UIImageView *_fullPaintingView;
|
||||||
|
|
||||||
PGPhotoEditor *_photoEditor;
|
PGPhotoEditor *_photoEditor;
|
||||||
|
|
||||||
@ -335,6 +336,9 @@
|
|||||||
_fullPreviewView = [[PGPhotoEditorView alloc] initWithFrame:CGRectMake(0, 0, fittedSize.width, fittedSize.height)];
|
_fullPreviewView = [[PGPhotoEditorView alloc] initWithFrame:CGRectMake(0, 0, fittedSize.width, fittedSize.height)];
|
||||||
_photoEditor.additionalOutputs = @[_fullPreviewView];
|
_photoEditor.additionalOutputs = @[_fullPreviewView];
|
||||||
[self.view addSubview:_fullPreviewView];
|
[self.view addSubview:_fullPreviewView];
|
||||||
|
|
||||||
|
_fullPaintingView = [[UIImageView alloc] init];
|
||||||
|
_fullPaintingView.frame = _fullPreviewView.frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
_dotMarkerView = [[UIImageView alloc] initWithImage:TGCircleImage(7.0, [TGPhotoEditorInterfaceAssets accentColor])];
|
_dotMarkerView = [[UIImageView alloc] initWithImage:TGCircleImage(7.0, [TGPhotoEditorInterfaceAssets accentColor])];
|
||||||
@ -1219,6 +1223,7 @@
|
|||||||
{
|
{
|
||||||
case TGPhotoEditorCropTab:
|
case TGPhotoEditorCropTab:
|
||||||
{
|
{
|
||||||
|
[self updatePreviewView:true];
|
||||||
__block UIView *initialBackgroundView = nil;
|
__block UIView *initialBackgroundView = nil;
|
||||||
|
|
||||||
if ([self presentedForAvatarCreation])
|
if ([self presentedForAvatarCreation])
|
||||||
@ -1230,6 +1235,7 @@
|
|||||||
cropController.dotImageView = _dotImageView;
|
cropController.dotImageView = _dotImageView;
|
||||||
cropController.dotMarkerView = _dotMarkerView;
|
cropController.dotMarkerView = _dotMarkerView;
|
||||||
cropController.fullPreviewView = _fullPreviewView;
|
cropController.fullPreviewView = _fullPreviewView;
|
||||||
|
cropController.fullPaintingView = _fullPaintingView;
|
||||||
cropController.fromCamera = [self presentedFromCamera];
|
cropController.fromCamera = [self presentedFromCamera];
|
||||||
cropController.skipTransitionIn = skipInitialTransition;
|
cropController.skipTransitionIn = skipInitialTransition;
|
||||||
if (snapshotImage != nil)
|
if (snapshotImage != nil)
|
||||||
@ -1614,9 +1620,10 @@
|
|||||||
|
|
||||||
- (void)updatePreviewView:(bool)full
|
- (void)updatePreviewView:(bool)full
|
||||||
{
|
{
|
||||||
if (full)
|
if (full) {
|
||||||
[_previewView setPaintingImageWithData:_photoEditor.paintingData];
|
[_previewView setPaintingImageWithData:_photoEditor.paintingData];
|
||||||
|
_fullPaintingView.image = _photoEditor.paintingData.image;
|
||||||
|
}
|
||||||
UIImageOrientation cropOrientation = _photoEditor.cropOrientation;
|
UIImageOrientation cropOrientation = _photoEditor.cropOrientation;
|
||||||
if ([self presentedForAvatarCreation]) {
|
if ([self presentedForAvatarCreation]) {
|
||||||
cropOrientation = UIImageOrientationUp;
|
cropOrientation = UIImageOrientationUp;
|
||||||
|
|||||||
@ -289,7 +289,7 @@
|
|||||||
_paintingContainerView.transform = CGAffineTransformMakeRotation(rotation);
|
_paintingContainerView.transform = CGAffineTransformMakeRotation(rotation);
|
||||||
_paintingContainerView.frame = self.bounds;
|
_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;
|
CGFloat ratio = 1.0;
|
||||||
if (_cropRect.size.width > 0.0) {
|
if (_cropRect.size.width > 0.0) {
|
||||||
ratio = width / _cropRect.size.width;
|
ratio = width / _cropRect.size.width;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user