mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
Drawing improvements
This commit is contained in:
@@ -295,6 +295,12 @@ final class DrawingBubbleEntititySelectionView: DrawingEntitySelectionView, UIGe
|
||||
entityView.onSnapToYAxis(snapped)
|
||||
}
|
||||
}
|
||||
|
||||
self.snapTool.onSnapRotationUpdated = { [weak self] snappedAngle in
|
||||
if let strongSelf = self, let entityView = strongSelf.entityView {
|
||||
entityView.onSnapToAngle(snappedAngle)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
@@ -401,6 +407,8 @@ final class DrawingBubbleEntititySelectionView: DrawingEntitySelectionView, UIGe
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
entityView.onPositionUpdated(entity.position)
|
||||
}
|
||||
|
||||
override func handlePinch(_ gestureRecognizer: UIPinchGestureRecognizer) {
|
||||
@@ -425,16 +433,29 @@ final class DrawingBubbleEntititySelectionView: DrawingEntitySelectionView, UIGe
|
||||
return
|
||||
}
|
||||
|
||||
let velocity = gestureRecognizer.velocity
|
||||
var updatedRotation = entity.rotation
|
||||
var rotation: CGFloat = 0.0
|
||||
|
||||
switch gestureRecognizer.state {
|
||||
case .began, .changed:
|
||||
let rotation = gestureRecognizer.rotation
|
||||
entity.rotation += rotation
|
||||
entityView.update()
|
||||
case .began:
|
||||
self.snapTool.maybeSkipFromStart(entityView: entityView, rotation: entity.rotation)
|
||||
case .changed:
|
||||
rotation = gestureRecognizer.rotation
|
||||
updatedRotation += rotation
|
||||
|
||||
gestureRecognizer.rotation = 0.0
|
||||
case .ended, .cancelled:
|
||||
self.snapTool.rotationReset()
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
updatedRotation = self.snapTool.update(entityView: entityView, velocity: velocity, delta: rotation, updatedRotation: updatedRotation)
|
||||
entity.rotation = updatedRotation
|
||||
entityView.update()
|
||||
|
||||
entityView.onPositionUpdated(entity.position)
|
||||
}
|
||||
|
||||
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
|
||||
|
||||
Reference in New Issue
Block a user