Skip to content

Commit

Permalink
Translate selected frame
Browse files Browse the repository at this point in the history
  • Loading branch information
akaDuality committed Mar 8, 2024
1 parent 282f2d6 commit cae6e29
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion Shared/Sources/Canvas/Drawing/DrawingController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ public class DrawingController {
if let corner = view.hud.corner(for: location) {
startResizing(control: selectedControl, startLocation: location, corner: corner)
return
} else if let frame = selectedControl as? ImageLayer {
startDragging(control: frame, startLocation: location)
return
}
}

Expand All @@ -198,7 +201,9 @@ public class DrawingController {
return
}

if view.control(at: location) != nil {
let hasElementUnderCursor = view.control(at: location) != nil
let isFrameSelected = selectedControl is ImageLayer
if hasElementUnderCursor || isFrameSelected {
pointerSubject.send(view.copyListener.isModifierActive ? .copy : .hover)
} else {
pointerSubject.send(nil)
Expand Down
2 changes: 0 additions & 2 deletions Shared/Sources/Canvas/Drawing/DrawingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ public extension DrawingView {
// TODO: Refactor
let viewsUnderCoordinate = drawnControls.filter({ control in
control.model!.frame.contains(coordinate)
}) + frames.filter({ control in
control.model!.frame.contains(coordinate)
})

switch viewsUnderCoordinate.count {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class NewDrawingTests: CanvasAfterDidLoadTests {
// MARK: - Artboard
func test_frameOnScreen_whenAddElementInsideFrame_shouldAddElementToFrame() throws {
addFrame()
sut.deselect()
XCTAssertNotNil(document.artboard.frames.first)

sut.mouseDown(on: start10)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import XCTest
@testable import Canvas

@MainActor
class RoutingTests: CanvasAfterDidLoadTests {

func test_openSettings() async throws {
Expand Down

0 comments on commit cae6e29

Please sign in to comment.