Video editor fixes

This commit is contained in:
Ilya Laktyushin 2020-05-26 17:33:45 +03:00
parent 0d17a8989c
commit a2e713e3ff
12 changed files with 90 additions and 63 deletions

View File

@ -5513,3 +5513,5 @@ Any member of this group will be able to see messages in the channel.";
"Chat.Gifs.SavedSectionHeader" = "MY GIFS";
"Paint.Framed" = "Framed";
"Media.SendingOptionsTooltip" = "Hold this button to send your message with a self-destruct timer.";

View File

@ -44,6 +44,7 @@ typedef enum
@property (nonatomic, copy) void(^tabPressed)(TGPhotoEditorTab tab);
@property (nonatomic, readonly) CGRect cancelButtonFrame;
@property (nonatomic, readonly) CGRect doneButtonFrame;
- (instancetype)initWithBackButton:(TGPhotoEditorBackButton)backButton doneButton:(TGPhotoEditorDoneButton)doneButton solidBackground:(bool)solidBackground;

View File

@ -295,8 +295,6 @@ static BOOL mark = false;
[fixer invalidate];
fixer = nil;
NSLog(@"Lock, %@, count = %d", self, framebufferReferenceCount);
}
- (void)unlock
@ -308,8 +306,6 @@ static BOOL mark = false;
NSAssert(framebufferReferenceCount > 0, @"Tried to overrelease a framebuffer, did you forget to call -useNextFrameForImageCapture before using -imageFromCurrentFramebuffer?");
framebufferReferenceCount--;
NSLog(@"Unlock, %@, count = %d", self, framebufferReferenceCount);
if (framebufferReferenceCount < 1)
{

View File

@ -11,7 +11,7 @@
- (void)setCIImage:(CIImage *)ciImage;
- (void)processTextureWithFrameTime:(CMTime)frameTime synchronous:(bool)synchronous;
- (void)processTextureWithFrameTime:(CMTime)frameTime synchronous:(bool)synchronous completion:(void (^)(void))completion;
- (CGSize)textureSize;

View File

@ -112,7 +112,7 @@
});
}
- (void)processTextureWithFrameTime:(CMTime)frameTime synchronous:(bool)synchronous
- (void)processTextureWithFrameTime:(CMTime)frameTime synchronous:(bool)synchronous completion:(void (^)(void))completion
{
void (^block)(void) = ^
{
@ -125,6 +125,9 @@
[currentTarget setInputFramebuffer:outputFramebuffer atIndex:targetTextureIndex];
[currentTarget newFrameReadyAtTime:frameTime atIndex:targetTextureIndex];
}
if (completion != nil)
completion();
};
if (synchronous)

View File

@ -242,9 +242,10 @@
if (capture)
[_finalFilter useNextFrameForImageCapture];
[(GPUImageTextureInput *)currentInput processTextureWithFrameTime:kCMTimeZero synchronous:synchronous];
if (completion != nil)
completion();
[(GPUImageTextureInput *)currentInput processTextureWithFrameTime:kCMTimeZero synchronous:synchronous completion:^{
if (completion != nil)
completion();
}];
[_finalFilter commitImageCapture];
}
} synchronous:synchronous];

View File

@ -879,19 +879,7 @@
[timerButton setIconImage:defaultIcon activeIconImage:icon];
TGPhotoEditorButton *landscapeTimerButton = [_landscapeToolbarView buttonForTab:TGPhotoEditorTimerTab];
if ([self shouldDisplayTooltip])
{
willShowTimerTooltip = true;
TGDispatchAfter(0.5, dispatch_get_main_queue(), ^
{
if (!TGIsPad() && self.frame.size.width > self.frame.size.height)
[self setupTooltip:[_landscapeToolbarView convertRect:landscapeTimerButton.frame toView:self]];
else
[self setupTooltip:[_portraitToolbarView convertRect:timerButton.frame toView:self]];
});
}
timerButton = landscapeTimerButton;
[timerButton setIconImage:defaultIcon activeIconImage:icon];
@ -899,6 +887,18 @@
highlightedButtons |= TGPhotoEditorTimerTab;
}
if ([self shouldDisplayTooltip])
{
willShowTimerTooltip = true;
TGDispatchAfter(0.5, dispatch_get_main_queue(), ^
{
if (!TGIsPad() && self.frame.size.width > self.frame.size.height)
[self setupTooltip:[_landscapeToolbarView convertRect:[_landscapeToolbarView doneButtonFrame] toView:self]];
else
[self setupTooltip:[_portraitToolbarView convertRect:[_portraitToolbarView doneButtonFrame] toView:self]];
});
}
if (adjustments.sendAsGif)
disabledButtons |= TGPhotoEditorQualityTab;
@ -913,7 +913,8 @@
- (bool)shouldDisplayTooltip
{
return ![[[NSUserDefaults standardUserDefaults] objectForKey:@"TG_displayedMediaTimerTooltip_v0"] boolValue];
// return true;
return ![[[NSUserDefaults standardUserDefaults] objectForKey:@"TG_displayedMediaTimerTooltip_v1"] boolValue];
}
- (void)setupTooltip:(CGRect)rect
@ -927,15 +928,16 @@
[self addSubview:_tooltipContainerView];
NSMutableArray *actions = [[NSMutableArray alloc] init];
[actions addObject:[[NSDictionary alloc] initWithObjectsAndKeys:TGLocalized(@"MediaPicker.TimerTooltip"), @"title", nil]];
[actions addObject:[[NSDictionary alloc] initWithObjectsAndKeys:TGLocalized(@"Media.SendingOptionsTooltip"), @"title", nil]];
_tooltipContainerView.menuView.multiline = true;
[_tooltipContainerView.menuView setButtonsAndActions:actions watcherHandle:_actionHandle];
[_tooltipContainerView.menuView sizeToFit];
_tooltipContainerView.menuView.buttonHighlightDisabled = true;
[_tooltipContainerView showMenuFromRect:rect animated:false];
[[NSUserDefaults standardUserDefaults] setObject:@true forKey:@"TG_displayedMediaTimerTooltip_v0"];
[[NSUserDefaults standardUserDefaults] setObject:@true forKey:@"TG_displayedMediaTimerTooltip_v1"];
}
- (void)tooltipTimerTick

View File

@ -26,7 +26,7 @@
- (TGPhotoEditorTab)toolbarTabs
{
return TGPhotoEditorCropTab | TGPhotoEditorToolsTab | TGPhotoEditorPaintTab | TGPhotoEditorTimerTab;
return TGPhotoEditorCropTab | TGPhotoEditorToolsTab | TGPhotoEditorPaintTab;
}
- (Class)viewClass

View File

@ -384,16 +384,13 @@
if (backgroundCIImage != nil) {
resultImage = backgroundCIImage;
}
CGSize size = resultImage.extent.size;
if (editor != nil) {
NSLog(@"setCIImage");
[editor setCIImage:resultImage];
resultImage = editor.currentResultCIImage;
NSLog(@"resultCIImage");
}
CGSize size = resultImage.extent.size;
if (overlayImage != nil && overlayImage.size.width > 0.0) {
if (overlayCIImage == nil) {
overlayCIImage = [[CIImage alloc] initWithImage:overlayImage];

View File

@ -347,6 +347,11 @@
self.cancelPressed();
}
- (CGRect)doneButtonFrame
{
return _doneButton.frame;
}
- (void)doneButtonPressed
{
if (self.donePressed != nil)

View File

@ -232,10 +232,10 @@ func chatMediaInputPanelGifModeEntries(theme: PresentationTheme) -> [ChatMediaIn
return entries
}
func chatMediaInputGridEntries(view: ItemCollectionsView, savedStickers: OrderedItemListView?, recentStickers: OrderedItemListView?, peerSpecificPack: PeerSpecificPackData?, canInstallPeerSpecificPack: CanInstallPeerSpecificPack, strings: PresentationStrings, theme: PresentationTheme) -> [ChatMediaInputGridEntry] {
func chatMediaInputGridEntries(view: ItemCollectionsView, savedStickers: OrderedItemListView?, recentStickers: OrderedItemListView?, peerSpecificPack: PeerSpecificPackData?, canInstallPeerSpecificPack: CanInstallPeerSpecificPack, hasSearch: Bool = true, strings: PresentationStrings, theme: PresentationTheme) -> [ChatMediaInputGridEntry] {
var entries: [ChatMediaInputGridEntry] = []
if view.lower == nil {
if hasSearch && view.lower == nil {
entries.append(.search(theme: theme, strings: strings))
}

View File

@ -32,8 +32,11 @@ private final class DrawingStickersScreenNode: ViewControllerTracingNode {
private let blurView: UIView
private let topPanel: ASDisplayNode
private let segmentedControlNode: SegmentedControlNode
private let cancelButton: HighlightableButtonNode
private let topSeparatorNode: ASDisplayNode
private let bottomSeparatorNode: ASDisplayNode
private let listView: ListView
@ -111,17 +114,21 @@ private final class DrawingStickersScreenNode: ViewControllerTracingNode {
self.blurView = UIVisualEffectView(effect: UIBlurEffect(style: .dark))
let segmentedTheme = SegmentedControlTheme(backgroundColor: UIColor(rgb: 0x2c2d2d), foregroundColor: UIColor(rgb: 0x656565), shadowColor: UIColor.clear, textColor: .white, dividerColor: .white)
self.topPanel = ASDisplayNode()
self.topPanel.clipsToBounds = true
self.topPanel.backgroundColor = UIColor(rgb: 0x151515)
self.topPanel.alpha = 0.4
self.segmentedControlNode = SegmentedControlNode(theme: segmentedTheme, items: [SegmentedControlItem(title: "Stickers"), SegmentedControlItem(title: "Masks")], selectedIndex: 0)
let segmentedTheme = SegmentedControlTheme(backgroundColor: UIColor(rgb: 0x2c2d2d), foregroundColor: UIColor(rgb: 0x656565), shadowColor: UIColor.clear, textColor: .white, dividerColor: .white)
self.segmentedControlNode = SegmentedControlNode(theme: segmentedTheme, items: [SegmentedControlItem(title: self.presentationData.strings.Paint_Stickers), SegmentedControlItem(title: self.presentationData.strings.Paint_Masks)], selectedIndex: 0)
self.cancelButton = HighlightableButtonNode()
self.cancelButton.setAttributedTitle(NSAttributedString(string: self.presentationData.strings.Common_Cancel, font: Font.regular(17.0), textColor: .white), for: .normal)
self.collectionListPanel = ASDisplayNode()
self.collectionListPanel.clipsToBounds = true
self.collectionListPanel.backgroundColor = UIColor(rgb: 0x151515)
self.collectionListPanel.alpha = 0.4
self.collectionListContainer = CollectionListContainerNode()
self.collectionListContainer.clipsToBounds = true
@ -129,6 +136,12 @@ private final class DrawingStickersScreenNode: ViewControllerTracingNode {
self.listView = ListView()
self.listView.transform = CATransform3DMakeRotation(-CGFloat(Double.pi / 2.0), 0.0, 0.0, 1.0)
self.topSeparatorNode = ASDisplayNode()
self.topSeparatorNode.backgroundColor = UIColor(rgb: 0x2c2d2d)
self.bottomSeparatorNode = ASDisplayNode()
self.bottomSeparatorNode.backgroundColor = UIColor(rgb: 0x2c2d2d)
var paneDidScrollImpl: ((ChatMediaInputPane, ChatMediaInputPaneScrollState, ContainedViewLayoutTransition) -> Void)?
self.stickerPane = ChatMediaInputStickerPane(theme: self.presentationData.theme, strings: self.presentationData.strings, paneDidScroll: { pane, state, transition in
paneDidScrollImpl?(pane, state, transition)
@ -263,12 +276,17 @@ private final class DrawingStickersScreenNode: ViewControllerTracingNode {
self.inputNodeInteraction.stickerSettings = ChatInterfaceStickerSettings(loopAnimatedStickers: true)
self.collectionListPanel.addSubnode(self.listView)
self.addSubnode(self.topPanel)
self.collectionListContainer.addSubnode(self.collectionListPanel)
self.collectionListContainer.addSubnode(self.listView)
self.addSubnode(self.collectionListContainer)
self.addSubnode(self.segmentedControlNode)
self.addSubnode(self.cancelButton)
self.addSubnode(self.topSeparatorNode)
self.addSubnode(self.bottomSeparatorNode)
let trendingInteraction = TrendingPaneInteraction(installPack: { [weak self] info in
}, openPack: { [weak self] info in
@ -365,8 +383,8 @@ private final class DrawingStickersScreenNode: ViewControllerTracingNode {
}
}
let panelEntries = chatMediaInputPanelEntries(view: view, savedStickers: savedStickers, recentStickers: recentStickers, peerSpecificPack: nil, canInstallPeerSpecificPack: .none, hasUnreadTrending: hasUnreadTrending, theme: theme, hasGifs: false)
var gridEntries = chatMediaInputGridEntries(view: view, savedStickers: savedStickers, recentStickers: recentStickers, peerSpecificPack: nil, canInstallPeerSpecificPack: .none, strings: strings, theme: theme)
let panelEntries = chatMediaInputPanelEntries(view: view, savedStickers: savedStickers, recentStickers: recentStickers, peerSpecificPack: nil, canInstallPeerSpecificPack: .none, hasUnreadTrending: nil, theme: theme, hasGifs: false)
var gridEntries = chatMediaInputGridEntries(view: view, savedStickers: savedStickers, recentStickers: recentStickers, peerSpecificPack: nil, canInstallPeerSpecificPack: .none, hasSearch: false, strings: strings, theme: theme)
if view.higher == nil {
var hasTopSeparator = true
@ -377,9 +395,9 @@ private final class DrawingStickersScreenNode: ViewControllerTracingNode {
var index = 0
for item in trendingPacks {
if !installedPacks.contains(item.info.id) {
gridEntries.append(.trending(TrendingPanePackEntry(index: index, info: item.info, theme: theme, strings: strings, topItems: item.topItems, installed: installedPacks.contains(item.info.id), unread: item.unread, topSeparator: hasTopSeparator)))
hasTopSeparator = true
index += 1
// gridEntries.append(.trending(TrendingPanePackEntry(index: index, info: item.info, theme: theme, strings: strings, topItems: item.topItems, installed: installedPacks.contains(item.info.id), unread: item.unread, topSeparator: hasTopSeparator)))
// hasTopSeparator = true
// index += 1
}
}
}
@ -395,10 +413,7 @@ private final class DrawingStickersScreenNode: ViewControllerTracingNode {
strongSelf.enqueuePanelTransition(panelTransition, firstTime: panelFirstTime, thenGridTransition: gridTransition, gridFirstTime: gridFirstTime)
if !strongSelf.initializedArrangement {
strongSelf.initializedArrangement = true
var currentPane = strongSelf.paneArrangement.panes[strongSelf.paneArrangement.currentIndex]
if view.entries.isEmpty {
//currentPane = .trending
}
let currentPane = strongSelf.paneArrangement.panes[strongSelf.paneArrangement.currentIndex]
if currentPane != strongSelf.paneArrangement.panes[strongSelf.paneArrangement.currentIndex] {
strongSelf.setCurrentPane(currentPane, transition: .immediate)
}
@ -420,9 +435,9 @@ private final class DrawingStickersScreenNode: ViewControllerTracingNode {
}
}
if let collectionId = topVisibleCollectionId {
// if strongSelf.inputNodeInteraction.highlightedItemCollectionId != collectionId {
// strongSelf.setHighlightedItemCollectionId(collectionId)
// }
if strongSelf.inputNodeInteraction.highlightedItemCollectionId != collectionId {
strongSelf.setHighlightedItemCollectionId(collectionId)
}
}
if let currentView = strongSelf.currentView, let (topIndex, topItem) = visibleItems.top, let (bottomIndex, bottomItem) = visibleItems.bottom {
@ -614,11 +629,10 @@ private final class DrawingStickersScreenNode: ViewControllerTracingNode {
func updateLayout(width: CGFloat, topInset: CGFloat, leftInset: CGFloat, rightInset: CGFloat, bottomInset: CGFloat, standardInputHeight: CGFloat, inputHeight: CGFloat, maximumHeight: CGFloat, inputPanelHeight: CGFloat, transition: ContainedViewLayoutTransition, deviceMetrics: DeviceMetrics, isVisible: Bool) -> (CGFloat, CGFloat) {
var searchMode: ChatMediaInputSearchMode?
let wasVisible = true
var displaySearch = false
let separatorHeight = UIScreenPixel
let separatorHeight = max(UIScreenPixel, 1.0 - UIScreenPixel)
let topPanelHeight: CGFloat = 56.0
let panelHeight: CGFloat
var isExpanded: Bool = true
@ -632,12 +646,14 @@ private final class DrawingStickersScreenNode: ViewControllerTracingNode {
// }
self.stickerPane.collectionListPanelOffset = 0.0
transition.updateFrame(node: self.topPanel, frame: CGRect(origin: CGPoint(), size: CGSize(width: width, height: topInset + topPanelHeight)))
var cancelSize = self.cancelButton.measure(CGSize(width: width, height: .greatestFiniteMagnitude))
cancelSize.width += 16.0 * 2.0
self.cancelButton.frame = CGRect(origin: CGPoint(x: width - cancelSize.width, y: topInset + 5.0), size: cancelSize)
transition.updateFrame(node: self.cancelButton, frame: CGRect(origin: CGPoint(x: width - cancelSize.width, y: topInset + floorToScreenPixels((topPanelHeight - cancelSize.height) / 2.0)), size: cancelSize))
let controlSize = self.segmentedControlNode.updateLayout(.stretchToFill(width: width - cancelSize.width - 16.0 * 2.0), transition: transition)
transition.updateFrame(node: self.segmentedControlNode, frame: CGRect(origin: CGPoint(x: 16.0, y: topInset), size: controlSize))
transition.updateFrame(node: self.segmentedControlNode, frame: CGRect(origin: CGPoint(x: 16.0, y: topInset + floorToScreenPixels((topPanelHeight - controlSize.height) / 2.0)), size: controlSize))
if displaySearch {
if let searchContainerNode = self.searchContainerNode {
@ -674,20 +690,24 @@ private final class DrawingStickersScreenNode: ViewControllerTracingNode {
}
}
let bottomPanelHeight: CGFloat = 49.0
let contentVerticalOffset: CGFloat = displaySearch ? -(inputPanelHeight + 41.0) : 0.0
let collectionListPanelOffset: CGFloat = 0.0
transition.updateFrame(view: self.blurView, frame: CGRect(origin: CGPoint(), size: CGSize(width: width, height: maximumHeight)))
transition.updateFrame(node: self.collectionListContainer, frame: CGRect(origin: CGPoint(x: 0.0, y: maximumHeight + contentVerticalOffset - 41.0 - bottomInset), size: CGSize(width: width, height: max(0.0, 41.0 + UIScreenPixel + bottomInset))))
transition.updateFrame(node: self.collectionListPanel, frame: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: width, height: 41.0 + bottomInset)))
transition.updateFrame(node: self.collectionListContainer, frame: CGRect(origin: CGPoint(x: 0.0, y: maximumHeight + contentVerticalOffset - bottomPanelHeight - bottomInset), size: CGSize(width: width, height: max(0.0, bottomPanelHeight + UIScreenPixel + bottomInset))))
transition.updateFrame(node: self.collectionListPanel, frame: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: width, height: bottomPanelHeight + bottomInset)))
self.listView.bounds = CGRect(x: 0.0, y: 0.0, width: 41.0, height: width)
transition.updatePosition(node: self.listView, position: CGPoint(x: width / 2.0, y: (41.0 - collectionListPanelOffset) / 2.0 + 2.0))
self.listView.bounds = CGRect(x: 0.0, y: 0.0, width: bottomPanelHeight, height: width)
transition.updatePosition(node: self.listView, position: CGPoint(x: width / 2.0, y: (bottomPanelHeight - collectionListPanelOffset) / 2.0))
transition.updateFrame(node: self.topSeparatorNode, frame: CGRect(origin: CGPoint(x: 0.0, y: topInset + topPanelHeight), size: CGSize(width: width, height: separatorHeight)))
transition.updateFrame(node: self.bottomSeparatorNode, frame: CGRect(origin: CGPoint(x: 0.0, y: maximumHeight + contentVerticalOffset - bottomPanelHeight - bottomInset), size: CGSize(width: width, height: separatorHeight)))
let (duration, curve) = listViewAnimationDurationAndCurve(transition: transition)
let updateSizeAndInsets = ListViewUpdateSizeAndInsets(size: CGSize(width: 41.0, height: width), insets: UIEdgeInsets(top: 4.0 + leftInset, left: 0.0, bottom: 4.0 + rightInset, right: 0.0), duration: duration, curve: curve)
let updateSizeAndInsets = ListViewUpdateSizeAndInsets(size: CGSize(width: bottomPanelHeight, height: width), insets: UIEdgeInsets(top: 4.0 + leftInset, left: 0.0, bottom: 4.0 + rightInset, right: 0.0), duration: duration, curve: curve)
self.listView.transaction(deleteIndices: [], insertIndicesAndItems: [], updateIndicesAndItems: [], options: [.Synchronous, .LowLatency], scrollToItem: nil, updateSizeAndInsets: updateSizeAndInsets, stationaryItemRange: nil, updateOpaqueState: nil, completion: { _ in })
@ -703,12 +723,12 @@ private final class DrawingStickersScreenNode: ViewControllerTracingNode {
}
for (pane, paneOrigin) in visiblePanes {
let paneFrame = CGRect(origin: CGPoint(x: paneOrigin + leftInset, y: topInset + 54.0), size: CGSize(width: width - leftInset - rightInset, height: panelHeight - topInset))
let paneFrame = CGRect(origin: CGPoint(x: paneOrigin + leftInset, y: topInset + topPanelHeight), size: CGSize(width: width - leftInset - rightInset, height: panelHeight - topInset - topPanelHeight - bottomInset - bottomPanelHeight))
switch pane {
case .stickers:
if self.stickerPane.supernode == nil {
self.insertSubnode(self.stickerPane, belowSubnode: self.collectionListContainer)
self.stickerPane.frame = CGRect(origin: CGPoint(x: width, y: topInset + 54.0), size: CGSize(width: width, height: panelHeight - topInset))
self.stickerPane.frame = CGRect(origin: CGPoint(x: width, y: topInset + topPanelHeight), size: CGSize(width: width, height: panelHeight - topInset - topPanelHeight - bottomInset - bottomPanelHeight))
}
if self.stickerPane.frame != paneFrame {
self.stickerPane.layer.removeAnimation(forKey: "position")
@ -719,7 +739,7 @@ private final class DrawingStickersScreenNode: ViewControllerTracingNode {
}
}
self.stickerPane.updateLayout(size: CGSize(width: width - leftInset - rightInset, height: panelHeight), topInset: 0.0, bottomInset: bottomInset, isExpanded: isExpanded, isVisible: true, deviceMetrics: deviceMetrics, transition: transition)
self.stickerPane.updateLayout(size: CGSize(width: width - leftInset - rightInset, height: panelHeight - topInset - topPanelHeight - bottomInset - bottomPanelHeight), topInset: 0.0, bottomInset: bottomInset, isExpanded: isExpanded, isVisible: true, deviceMetrics: deviceMetrics, transition: transition)
if !displaySearch, let searchContainerNode = self.searchContainerNode {
self.searchContainerNode = nil