Skip to content

Commit

Permalink
Use offset.
Browse files Browse the repository at this point in the history
  • Loading branch information
schwa committed Oct 6, 2022
1 parent 94aef6d commit f6bcf05
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions Sources/SwiftNodeEditor/NodeGraphEditorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,19 @@ internal struct WireView<Presentation>: View where Presentation: PresentationPro

var body: some View {
model.presentation.content(for: _wire, configuration: configuration)
.overlay(PinView<Presentation>(wire: _wire, socket: wire.sourceSocket, location: configuration.start))
.overlay(PinView<Presentation>(wire: _wire, socket: wire.destinationSocket, location: configuration.end))
.overlay(PinView<Presentation>(wire: _wire, socket: wire.sourceSocket).offset(configuration.start))
.overlay(PinView<Presentation>(wire: _wire, socket: wire.destinationSocket).offset(configuration.start))
.opacity(configuration.active ? 0.33 : 1)
}
}
}

extension View {
func offset(_ point: CGPoint) -> some View {
self.offset(x: point.x, y: point.y)
}
}

internal struct ActiveWireView<Presentation>: View where Presentation: PresentationProtocol {
typealias Node = Presentation.Node
typealias Wire = Presentation.Wire
Expand Down Expand Up @@ -307,13 +313,9 @@ internal struct PinView<Presentation>: View where Presentation: PresentationProt

let socket: Socket

// TODO: instead of location rely on parent setting .offset correctly.
let location: CGPoint

var body: some View {
WireDragSource(presentationType: Presentation.self, socket: socket, existingWire: wire) {
model.presentation.content(forPin: socket)
.offset(x: location.x, y: location.y)
}
}
}
Expand Down

0 comments on commit f6bcf05

Please sign in to comment.