mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Video avatar fixes
This commit is contained in:
parent
f7061fde4f
commit
ee64d32ccf
@ -800,7 +800,7 @@
|
|||||||
CGRect fittedCropRect = [TGPhotoPaintController fittedCropRect:cropRect originalSize:originalSize keepOriginalSize:false];
|
CGRect fittedCropRect = [TGPhotoPaintController fittedCropRect:cropRect originalSize:originalSize keepOriginalSize:false];
|
||||||
_contentWrapperView.frame = CGRectMake(0.0f, 0.0f, fittedContentSize.width, fittedContentSize.height);
|
_contentWrapperView.frame = CGRectMake(0.0f, 0.0f, fittedContentSize.width, fittedContentSize.height);
|
||||||
|
|
||||||
CGFloat contentScale = ratio;//_contentView.bounds.size.width / fittedCropRect.size.width;
|
CGFloat contentScale = ratio;
|
||||||
_contentWrapperView.transform = CGAffineTransformMakeScale(contentScale, contentScale);
|
_contentWrapperView.transform = CGAffineTransformMakeScale(contentScale, contentScale);
|
||||||
_contentWrapperView.frame = CGRectMake(0.0f, 0.0f, _contentView.bounds.size.width, _contentView.bounds.size.height);
|
_contentWrapperView.frame = CGRectMake(0.0f, 0.0f, _contentView.bounds.size.width, _contentView.bounds.size.height);
|
||||||
|
|
||||||
|
@ -42,6 +42,8 @@ const CGFloat TGPhotoAvatarCropViewCurtainMargin = 200;
|
|||||||
|
|
||||||
CGFloat _currentDiameter;
|
CGFloat _currentDiameter;
|
||||||
|
|
||||||
|
UIView *_entitiesWrapperView;
|
||||||
|
|
||||||
__weak PGPhotoEditorView *_fullPreviewView;
|
__weak PGPhotoEditorView *_fullPreviewView;
|
||||||
__weak UIImageView *_fullPaintingView;
|
__weak UIImageView *_fullPaintingView;
|
||||||
__weak TGPhotoEntitiesContainerView *_fullEntitiesView;
|
__weak TGPhotoEntitiesContainerView *_fullEntitiesView;
|
||||||
@ -91,9 +93,16 @@ const CGFloat TGPhotoAvatarCropViewCurtainMargin = 200;
|
|||||||
_fullPaintingView.frame = _fullPreviewView.frame;
|
_fullPaintingView.frame = _fullPreviewView.frame;
|
||||||
[_wrapperView addSubview:_fullPaintingView];
|
[_wrapperView addSubview:_fullPaintingView];
|
||||||
|
|
||||||
|
_entitiesWrapperView = [[UIView alloc] init];
|
||||||
_fullEntitiesView = fullEntitiesView;
|
_fullEntitiesView = fullEntitiesView;
|
||||||
_fullEntitiesView.frame = _fullPreviewView.frame;
|
_fullEntitiesView.frame = CGRectMake(0.0, 0.0, _fullEntitiesView.frame.size.width, _fullEntitiesView.frame.size.height);
|
||||||
[_wrapperView addSubview:_fullEntitiesView];
|
_entitiesWrapperView.frame = _fullEntitiesView.frame;
|
||||||
|
|
||||||
|
CGFloat entitiesScale = _fullPreviewView.frame.size.width / _entitiesWrapperView.frame.size.width;
|
||||||
|
_entitiesWrapperView.transform = CGAffineTransformMakeScale(entitiesScale, entitiesScale);
|
||||||
|
_entitiesWrapperView.frame = _fullPreviewView.frame;
|
||||||
|
[_entitiesWrapperView addSubview:_fullEntitiesView];
|
||||||
|
[_wrapperView addSubview:_entitiesWrapperView];
|
||||||
|
|
||||||
_flashView = [[UIView alloc] init];
|
_flashView = [[UIView alloc] init];
|
||||||
_flashView.alpha = 0.0;
|
_flashView.alpha = 0.0;
|
||||||
|
@ -346,7 +346,8 @@
|
|||||||
|
|
||||||
_fullEntitiesView = [[TGPhotoEntitiesContainerView alloc] init];
|
_fullEntitiesView = [[TGPhotoEntitiesContainerView alloc] init];
|
||||||
_fullEntitiesView.userInteractionEnabled = false;
|
_fullEntitiesView.userInteractionEnabled = false;
|
||||||
_fullEntitiesView.frame = _fullPreviewView.frame;
|
CGRect rect = [TGPhotoPaintController fittedCropRect:_photoEditor.cropRect originalSize:_photoEditor.originalSize keepOriginalSize:true];
|
||||||
|
_fullEntitiesView.frame = CGRectMake(0, 0, rect.size.width, rect.size.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
_dotMarkerView = [[UIImageView alloc] initWithImage:TGCircleImage(7.0, [TGPhotoEditorInterfaceAssets accentColor])];
|
_dotMarkerView = [[UIImageView alloc] initWithImage:TGCircleImage(7.0, [TGPhotoEditorInterfaceAssets accentColor])];
|
||||||
|
@ -98,6 +98,7 @@ const CGFloat TGPhotoPaintStickerKeyboardSize = 260.0f;
|
|||||||
id<TGPhotoPaintStickersScreen> _stickersScreen;
|
id<TGPhotoPaintStickersScreen> _stickersScreen;
|
||||||
|
|
||||||
bool _appeared;
|
bool _appeared;
|
||||||
|
bool _skipEntitiesSetup;
|
||||||
|
|
||||||
TGPhotoPaintFont *_selectedTextFont;
|
TGPhotoPaintFont *_selectedTextFont;
|
||||||
TGPhotoPaintTextEntityStyle _selectedTextStyle;
|
TGPhotoPaintTextEntityStyle _selectedTextStyle;
|
||||||
@ -152,6 +153,9 @@ const CGFloat TGPhotoPaintStickerKeyboardSize = 260.0f;
|
|||||||
self.photoEditor = photoEditor;
|
self.photoEditor = photoEditor;
|
||||||
self.previewView = previewView;
|
self.previewView = previewView;
|
||||||
_entitiesContainerView = entitiesView;
|
_entitiesContainerView = entitiesView;
|
||||||
|
if (entitiesView != nil) {
|
||||||
|
_skipEntitiesSetup = true;
|
||||||
|
}
|
||||||
entitiesView.userInteractionEnabled = true;
|
entitiesView.userInteractionEnabled = true;
|
||||||
|
|
||||||
_brushes = @
|
_brushes = @
|
||||||
@ -509,7 +513,9 @@ const CGFloat TGPhotoPaintStickerKeyboardSize = 260.0f;
|
|||||||
[super viewDidLoad];
|
[super viewDidLoad];
|
||||||
|
|
||||||
PGPhotoEditor *photoEditor = _photoEditor;
|
PGPhotoEditor *photoEditor = _photoEditor;
|
||||||
[_entitiesContainerView setupWithPaintingData:photoEditor.paintingData];
|
if (!_skipEntitiesSetup) {
|
||||||
|
[_entitiesContainerView setupWithPaintingData:photoEditor.paintingData];
|
||||||
|
}
|
||||||
for (TGPhotoPaintEntityView *view in _entitiesContainerView.subviews)
|
for (TGPhotoPaintEntityView *view in _entitiesContainerView.subviews)
|
||||||
{
|
{
|
||||||
if (![view isKindOfClass:[TGPhotoPaintEntityView class]])
|
if (![view isKindOfClass:[TGPhotoPaintEntityView class]])
|
||||||
|
@ -22,6 +22,9 @@
|
|||||||
#import "TGPhotoEditorPreviewView.h"
|
#import "TGPhotoEditorPreviewView.h"
|
||||||
#import "TGPhotoEditorHUDView.h"
|
#import "TGPhotoEditorHUDView.h"
|
||||||
#import "TGPhotoEditorSparseView.h"
|
#import "TGPhotoEditorSparseView.h"
|
||||||
|
#import "TGPhotoEntitiesContainerView.h"
|
||||||
|
|
||||||
|
#import "TGPhotoPaintController.h"
|
||||||
|
|
||||||
const CGFloat TGPhotoEditorToolsPanelSize = 180.0f;
|
const CGFloat TGPhotoEditorToolsPanelSize = 180.0f;
|
||||||
const CGFloat TGPhotoEditorToolsLandscapePanelSize = TGPhotoEditorToolsPanelSize + 40.0f;
|
const CGFloat TGPhotoEditorToolsLandscapePanelSize = TGPhotoEditorToolsPanelSize + 40.0f;
|
||||||
@ -53,6 +56,8 @@ const CGFloat TGPhotoEditorToolsLandscapePanelSize = TGPhotoEditorToolsPanelSize
|
|||||||
bool _preview;
|
bool _preview;
|
||||||
TGPhotoEditorTab _currentTab;
|
TGPhotoEditorTab _currentTab;
|
||||||
|
|
||||||
|
UIView *_entitiesWrapperView;
|
||||||
|
|
||||||
UIView <TGPhotoEditorToolView> *_toolAreaView;
|
UIView <TGPhotoEditorToolView> *_toolAreaView;
|
||||||
UIView <TGPhotoEditorToolView> *_portraitToolControlView;
|
UIView <TGPhotoEditorToolView> *_portraitToolControlView;
|
||||||
UIView <TGPhotoEditorToolView> *_landscapeToolControlView;
|
UIView <TGPhotoEditorToolView> *_landscapeToolControlView;
|
||||||
@ -101,6 +106,29 @@ const CGFloat TGPhotoEditorToolsLandscapePanelSize = TGPhotoEditorToolsPanelSize
|
|||||||
_landscapeCollectionView.toolsDataSource = nil;
|
_landscapeCollectionView.toolsDataSource = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)layoutEntitiesView {
|
||||||
|
CGSize fittedContentSize = [TGPhotoPaintController fittedContentSize:_photoEditor.cropRect orientation:_photoEditor.cropOrientation originalSize:_photoEditor.originalSize];
|
||||||
|
CGRect fittedCropRect = [TGPhotoPaintController fittedCropRect:_photoEditor.cropRect originalSize:_photoEditor.originalSize keepOriginalSize:false];
|
||||||
|
_entitiesWrapperView.frame = CGRectMake(0.0f, 0.0f, fittedContentSize.width, fittedContentSize.height);
|
||||||
|
|
||||||
|
CGRect rect = [TGPhotoPaintController fittedCropRect:self.photoEditor.cropRect originalSize:self.photoEditor.originalSize keepOriginalSize:true];
|
||||||
|
_entitiesView.frame = CGRectMake(0, 0, rect.size.width, rect.size.height);
|
||||||
|
_entitiesView.transform = CGAffineTransformMakeRotation(_photoEditor.cropRotation);
|
||||||
|
|
||||||
|
CGSize fittedOriginalSize = TGScaleToSize(_photoEditor.originalSize, [TGPhotoPaintController maximumPaintingSize]);
|
||||||
|
CGSize rotatedSize = TGRotatedContentSize(fittedOriginalSize, _photoEditor.cropRotation);
|
||||||
|
CGPoint centerPoint = CGPointMake(rotatedSize.width / 2.0f, rotatedSize.height / 2.0f);
|
||||||
|
|
||||||
|
CGFloat scale = fittedOriginalSize.width / _photoEditor.originalSize.width;
|
||||||
|
CGPoint offset = TGPaintSubtractPoints(centerPoint, [TGPhotoPaintController fittedCropRect:_photoEditor.cropRect centerScale:scale]);
|
||||||
|
|
||||||
|
CGPoint boundsCenter = TGPaintCenterOfRect(_entitiesWrapperView.bounds);
|
||||||
|
_entitiesView.center = TGPaintAddPoints(boundsCenter, offset);
|
||||||
|
if (_entitiesView.superview != _entitiesWrapperView) {
|
||||||
|
[_entitiesWrapperView addSubview:_entitiesView];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (void)loadView
|
- (void)loadView
|
||||||
{
|
{
|
||||||
[super loadView];
|
[super loadView];
|
||||||
@ -191,6 +219,10 @@ const CGFloat TGPhotoEditorToolsLandscapePanelSize = TGPhotoEditorToolsPanelSize
|
|||||||
_wrapperView = [[TGPhotoEditorSparseView alloc] initWithFrame:CGRectZero];
|
_wrapperView = [[TGPhotoEditorSparseView alloc] initWithFrame:CGRectZero];
|
||||||
[self.view addSubview:_wrapperView];
|
[self.view addSubview:_wrapperView];
|
||||||
|
|
||||||
|
_entitiesWrapperView = [[UIView alloc] init];
|
||||||
|
_entitiesWrapperView.userInteractionEnabled = false;
|
||||||
|
[_wrapperView addSubview:_entitiesWrapperView];
|
||||||
|
|
||||||
_portraitToolsWrapperView = [[UIView alloc] initWithFrame:CGRectZero];
|
_portraitToolsWrapperView = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
_portraitToolsWrapperView.alpha = 0.0f;
|
_portraitToolsWrapperView.alpha = 0.0f;
|
||||||
[_wrapperView addSubview:_portraitToolsWrapperView];
|
[_wrapperView addSubview:_portraitToolsWrapperView];
|
||||||
@ -977,6 +1009,7 @@ const CGFloat TGPhotoEditorToolsLandscapePanelSize = TGPhotoEditorToolsPanelSize
|
|||||||
[_landscapeCollectionView.collectionViewLayout invalidateLayout];
|
[_landscapeCollectionView.collectionViewLayout invalidateLayout];
|
||||||
|
|
||||||
[self updatePreviewView];
|
[self updatePreviewView];
|
||||||
|
[self layoutEntitiesView];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (TGPhotoEditorTab)availableTabs
|
- (TGPhotoEditorTab)availableTabs
|
||||||
|
@ -1307,7 +1307,6 @@ private final class DrawingStickersScreenNode: ViewControllerTracingNode {
|
|||||||
strongSelf.hiddenPane?.removeFromSupernode()
|
strongSelf.hiddenPane?.removeFromSupernode()
|
||||||
strongSelf.hiddenListView?.removeFromSupernode()
|
strongSelf.hiddenListView?.removeFromSupernode()
|
||||||
strongSelf.isHidden = true
|
strongSelf.isHidden = true
|
||||||
strongSelf.dismiss?()
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user