mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Image editor fixes.
This commit is contained in:
parent
17c3ba0580
commit
5dcde44486
3 changed files with 8 additions and 6 deletions
|
@ -10,7 +10,7 @@ class ImageEditorGestureRecognizer: UIGestureRecognizer {
|
|||
public var shouldAllowOutsideView = true
|
||||
|
||||
@objc
|
||||
public weak var referenceView: UIView?
|
||||
public weak var canvasView: UIView?
|
||||
|
||||
@objc
|
||||
override func canPrevent(_ preventedGestureRecognizer: UIGestureRecognizer) -> Bool {
|
||||
|
@ -105,8 +105,8 @@ class ImageEditorGestureRecognizer: UIGestureRecognizer {
|
|||
owsFailDebug("Missing gestureView")
|
||||
return .invalid
|
||||
}
|
||||
guard let referenceView = referenceView else {
|
||||
owsFailDebug("Missing referenceView")
|
||||
guard let canvasView = canvasView else {
|
||||
owsFailDebug("Missing canvasView")
|
||||
return .invalid
|
||||
}
|
||||
guard let allTouches = event.allTouches else {
|
||||
|
@ -132,8 +132,8 @@ class ImageEditorGestureRecognizer: UIGestureRecognizer {
|
|||
}
|
||||
|
||||
// Reject new touches outside this GR's view's bounds.
|
||||
let location = firstTouch.location(in: referenceView)
|
||||
if !referenceView.bounds.contains(location) {
|
||||
let location = firstTouch.location(in: canvasView)
|
||||
if !canvasView.bounds.contains(location) {
|
||||
if shouldAllowOutsideView {
|
||||
// Do nothing
|
||||
} else if isNewTouch {
|
||||
|
|
|
@ -500,6 +500,8 @@ public class ImageEditorModel: NSObject {
|
|||
public func crop(unitCropRect: CGRect) {
|
||||
guard let croppedImage = ImageEditorModel.crop(imagePath: contents.imagePath,
|
||||
unitCropRect: unitCropRect) else {
|
||||
// Not an error; user might have tapped or
|
||||
// otherwise drawn an invalid crop region.
|
||||
Logger.warn("Could not crop image.")
|
||||
return
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ public class ImageEditorView: UIView, ImageEditorModelDelegate {
|
|||
self.isUserInteractionEnabled = true
|
||||
layersView.isUserInteractionEnabled = true
|
||||
let editorGestureRecognizer = ImageEditorGestureRecognizer(target: self, action: #selector(handleTouchGesture(_:)))
|
||||
editorGestureRecognizer.referenceView = layersView
|
||||
editorGestureRecognizer.canvasView = layersView
|
||||
self.addGestureRecognizer(editorGestureRecognizer)
|
||||
self.editorGestureRecognizer = editorGestureRecognizer
|
||||
|
||||
|
|
Loading…
Reference in a new issue