Debian Codegraph @

src/activities/digital_electricity/components/TerminalPoint.qml

raw
1 /* GCompris - TerminalPoint.qml
2 *
3 * SPDX-FileCopyrightText: 2016 Pulkit Gupta <[email protected]>
4 *
5 * Authors:
6 * Bruno Coudoin <[email protected]> (GTK+ version)
7 * Pulkit Gupta <[email protected]> (Qt Quick port)
8 *
9 * SPDX-License-Identifier: GPL-3.0-or-later
10 */
11 import QtQuick
12 import core 1.0
13
14 import "../digital_electricity.js" as Activity
15
16 Image {
17 id: terminalPoint
18
19 property double posX
20 property double posY
21 property double size: parent ? parent.terminalSize : 1
22 property bool selected: false
23 property string type
24 property int value: 0
25 property var wires: []
26
27 width: parent ? size * parent.paintedHeight : 1
28 height: width
29 source: Activity.url + "tPoint.svg"
30 sourceSize.width: width
31 sourceSize.height: width
32 antialiasing: true
33
34 x: parent ? (parent.width - parent.paintedWidth) * 0.5 + posX * parent.paintedWidth - width * 0.5 : 1
35 y: parent ? (parent.height - parent.paintedHeight) * 0.5 + posY * parent.paintedHeight - height * 0.5 : 1
36
37 property double xCenter: parent ? terminalPoint.parent.x + terminalPoint.x + width * 0.5 : 1
38 property double yCenter: parent ? terminalPoint.parent.y + terminalPoint.y + height * 0.5 : 1
39 property double xCenterFromComponent: parent ? terminalPoint.x + width * 0.5 - terminalPoint.parent.width * 0.5 : 1
40 property double yCenterFromComponent: parent ? terminalPoint.y + height * 0.5 - terminalPoint.parent.height * 0.5 : 1
41
42 Rectangle {
43 id: boundary
44 anchors.centerIn: terminalPoint
45 width: terminalPoint.width * 2
46 height: width
47 visible: selected
48 radius: width / 2
49 color: "#08D050"
50 z: -1
51 }
52
53 MouseArea {
54 id: mouseArea
55 anchors.fill: parent
56 onPressed: {
57 selected = true
58 Activity.terminalPointSelected(terminalPoint)
59 }
60 }
61 }