-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ConnectionsCanvas as a separate QML file
The existing logic for managing and painting connections has been abstracted into a new QML file, ConnectionsCanvas.qml. The Main.qml file has been updated to use this new component. Additionally, unnecessary whitespaces and
- Loading branch information
Showing
3 changed files
with
50 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import QtQuick | ||
import com.cssodessa.AppController | ||
import com.cssodessa.NodeController | ||
import com.cssodessa.ConnectionController | ||
|
||
|
||
Canvas { | ||
id: canvas | ||
|
||
property AppController appController | ||
|
||
function repaintConnections() { | ||
canvas.requestPaint() | ||
} | ||
|
||
anchors.fill: parent | ||
anchors.margins: 10 | ||
contextType: "2d" | ||
|
||
onPaint: { | ||
context.save() | ||
context.clearRect(0, 0, width, height) | ||
|
||
context.strokeStyle = "orange" | ||
context.lineWidth = 3 | ||
|
||
for (let i = 0; i < appController.connections.length; i++) { | ||
const connection = appController.connections[i]; | ||
const output = connection.source.outputs[connection.outputIdx]; | ||
const input = connection.target.inputs[connection.inputIdx]; | ||
|
||
context.beginPath() | ||
context.moveTo(output.viewPos.x, output.viewPos.y) | ||
context.bezierCurveTo( | ||
output.viewPos.x + 40, output.viewPos.y, | ||
input.viewPos.x - 40, input.viewPos.y, | ||
input.viewPos.x, input.viewPos.y | ||
) | ||
context.stroke() | ||
} | ||
|
||
context.restore() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters