mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +00:00
Various fixes
This commit is contained in:
@@ -23,7 +23,7 @@ protocol DrawingElement: AnyObject {
|
||||
|
||||
func setupRenderView(screenSize: CGSize) -> DrawingRenderView?
|
||||
func setupRenderLayer() -> DrawingRenderLayer?
|
||||
func updatePath(_ point: DrawingPoint, state: DrawingGesturePipeline.DrawingGestureState)
|
||||
func updatePath(_ point: DrawingPoint, state: DrawingGesturePipeline.DrawingGestureState, zoomScale: CGFloat)
|
||||
|
||||
func draw(in: CGContext, size: CGSize)
|
||||
}
|
||||
@@ -267,7 +267,7 @@ public final class DrawingView: UIView, UIGestureRecognizerDelegate, TGPhotoDraw
|
||||
}
|
||||
strongSelf.currentDrawingLayer = renderLayer
|
||||
}
|
||||
newElement.updatePath(point, state: state)
|
||||
newElement.updatePath(point, state: state, zoomScale: strongSelf.zoomScale)
|
||||
strongSelf.uncommitedElement = newElement
|
||||
strongSelf.updateInternalState()
|
||||
case .changed:
|
||||
@@ -275,7 +275,7 @@ public final class DrawingView: UIView, UIGestureRecognizerDelegate, TGPhotoDraw
|
||||
return
|
||||
}
|
||||
strongSelf.previousPointTimestamp = currentTimestamp
|
||||
strongSelf.uncommitedElement?.updatePath(point, state: state)
|
||||
strongSelf.uncommitedElement?.updatePath(point, state: state, zoomScale: strongSelf.zoomScale)
|
||||
|
||||
// if case let .direct(point) = path, let lastPoint = line.points.last {
|
||||
// if let previousStrokePoint = strongSelf.previousStrokePoint, line.points.count > 10 {
|
||||
@@ -343,25 +343,23 @@ public final class DrawingView: UIView, UIGestureRecognizerDelegate, TGPhotoDraw
|
||||
// strongSelf.previousStrokePoint = lastPoint.location
|
||||
// }
|
||||
// }
|
||||
case .ended:
|
||||
case .ended, .cancelled:
|
||||
strongSelf.isDrawing = false
|
||||
strongSelf.strokeRecognitionTimer?.invalidate()
|
||||
strongSelf.strokeRecognitionTimer = nil
|
||||
strongSelf.uncommitedElement?.updatePath(point, state: state)
|
||||
strongSelf.uncommitedElement?.updatePath(point, state: state, zoomScale: strongSelf.zoomScale)
|
||||
|
||||
let bounds = strongSelf.uncommitedElement?.bounds
|
||||
Queue.mainQueue().after(0.05) {
|
||||
if let bounds = bounds {
|
||||
strongSelf.finishDrawing(rect: bounds, synchronous: true)
|
||||
if strongSelf.uncommitedElement?.isValid == true {
|
||||
let bounds = strongSelf.uncommitedElement?.bounds
|
||||
Queue.mainQueue().after(0.05) {
|
||||
if let bounds = bounds {
|
||||
strongSelf.finishDrawing(rect: bounds, synchronous: true)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
strongSelf.cancelDrawing()
|
||||
}
|
||||
strongSelf.updateInternalState()
|
||||
case .cancelled:
|
||||
strongSelf.isDrawing = false
|
||||
strongSelf.strokeRecognitionTimer?.invalidate()
|
||||
strongSelf.strokeRecognitionTimer = nil
|
||||
strongSelf.cancelDrawing()
|
||||
strongSelf.updateInternalState()
|
||||
}
|
||||
}
|
||||
self.drawingGesturePipeline = drawingGesturePipeline
|
||||
@@ -599,6 +597,9 @@ public final class DrawingView: UIView, UIGestureRecognizerDelegate, TGPhotoDraw
|
||||
}
|
||||
self.currentDrawingLayer = nil
|
||||
}
|
||||
if case .marker = self.tool {
|
||||
self.metalView?.isHidden = true
|
||||
}
|
||||
}
|
||||
|
||||
private func slice(for rect: CGRect) -> DrawingSlice? {
|
||||
|
||||
Reference in New Issue
Block a user