Drawing improvements

This commit is contained in:
Ilya Laktyushin
2022-12-23 21:08:37 +04:00
parent 9937826307
commit 439b130f56
94 changed files with 701 additions and 10617 deletions

View File

@@ -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 {