Changeset View
Changeset View
Standalone View
Standalone View
src/activities/analog_electricity/TerminalPoint.qml
- This file was copied from src/activities/digital_electricity/components/TerminalPoint.qml.
1 | /* GCompris - TerminalPoint.qml | 1 | /* GCompris - TerminalPoint.qml | ||
---|---|---|---|---|---|
2 | * | 2 | * | ||
3 | * Copyright (C) 2016 Pulkit Gupta <pulkitnsit@gmail.com> | 3 | * Copyright (C) 2019 Deepak Kumar <deepakdk2431@gmail.com> | ||
4 | * | | |||
5 | * Authors: | | |||
6 | * Bruno Coudoin <bruno.coudoin@gcompris.net> (GTK+ version) | | |||
7 | * Pulkit Gupta <pulkitnsit@gmail.com> (Qt Quick port) | | |||
8 | * | 4 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 3 of the License, or | 7 | * the Free Software Foundation; either version 3 of the License, or | ||
12 | * (at your option) any later version. | 8 | * (at your option) any later version. | ||
13 | * | 9 | * | ||
14 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. | ||
18 | * | 14 | * | ||
19 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, see <https://www.gnu.org/licenses/>. | 16 | * along with this program; if not, see <https://www.gnu.org/licenses/>. | ||
21 | */ | 17 | */ | ||
22 | import QtQuick 2.6 | 18 | import QtQuick 2.6 | ||
23 | import GCompris 1.0 | 19 | import GCompris 1.0 | ||
24 | 20 | | |||
25 | import "../digital_electricity.js" as Activity | 21 | import "../../core" | ||
22 | import "analog_electricity.js" as Activity | ||||
26 | 23 | | |||
27 | Image { | 24 | Image { | ||
28 | id: terminalPoint | 25 | id: terminalPoint | ||
29 | 26 | | |||
30 | property double posX | 27 | property double posX | ||
31 | property double posY | 28 | property double posY | ||
32 | property double size: parent.terminalSize | 29 | property double size: parent.terminalSize | ||
33 | property bool selected: false | 30 | property bool selected: false | ||
34 | property string type | 31 | property string type | ||
35 | property int value: 0 | 32 | property int value: 0 | ||
36 | property var wires: [] | 33 | property var wires: [] | ||
37 | 34 | | |||
38 | width: size * parent.paintedHeight | 35 | width: size * parent.paintedHeight | ||
39 | height: width | 36 | height: width | ||
40 | source: Activity.url + "tPoint.svg" | 37 | source: Activity.url + "tPoint.svg" | ||
41 | sourceSize.width: width | 38 | sourceSize.width: width | ||
42 | sourceSize.height: width | 39 | sourceSize.height: width | ||
43 | antialiasing: true | 40 | antialiasing: true | ||
44 | 41 | | |||
45 | x: (parent.width - parent.paintedWidth) / 2 + posX * parent.paintedWidth - width / 2 | 42 | | ||
46 | y: (parent.height - parent.paintedHeight) / 2 + posY * parent.paintedHeight - height / 2 | 43 | x: (parent.width - parent.paintedWidth) / 2 + posX * parent.paintedWidth - width | ||
44 | y: (parent.height - parent.paintedHeight) / 2 + posY * parent.paintedHeight - height | ||||
47 | 45 | | |||
48 | property double xCenter: terminalPoint.parent.x + terminalPoint.x + width/2 | 46 | property double xCenter: terminalPoint.parent.x + terminalPoint.x + width/2 | ||
49 | property double yCenter: terminalPoint.parent.y + terminalPoint.y + height/2 | 47 | property double yCenter: terminalPoint.parent.y + terminalPoint.y + height/2 | ||
50 | property double xCenterFromComponent: terminalPoint.x + width/2 - terminalPoint.parent.width / 2 | 48 | property double xCenterFromComponent: terminalPoint.x + width/2 - terminalPoint.parent.width / 2 | ||
51 | property double yCenterFromComponent: terminalPoint.y + height/2 - terminalPoint.parent.height / 2 | 49 | property double yCenterFromComponent: terminalPoint.y + height/2 - terminalPoint.parent.height / 2 | ||
52 | 50 | | |||
53 | Rectangle { | 51 | Rectangle { | ||
54 | id: boundary | 52 | id: boundary | ||
55 | anchors.centerIn: terminalPoint | 53 | anchors.centerIn: terminalPoint | ||
56 | width: terminalPoint.width * 2 | 54 | width: terminalPoint.width * 2 | ||
57 | height: width | 55 | height: width | ||
58 | visible: selected | 56 | visible: true | ||
59 | radius: width / 2 | 57 | radius: width / 2 | ||
60 | color: "#08D050" | 58 | color: "#08D050" | ||
61 | z: -1 | 59 | z: -1 | ||
62 | } | 60 | } | ||
63 | 61 | | |||
64 | MouseArea { | 62 | MouseArea { | ||
65 | id: mouseArea | 63 | id: mouseArea | ||
66 | anchors.fill: parent | 64 | anchors.fill: parent | ||
67 | onPressed: { | 65 | onPressed: { | ||
68 | selected = true | 66 | selected = true | ||
69 | Activity.terminalPointSelected(terminalPoint) | 67 | Activity.terminalPointSelected(terminalPoint) | ||
70 | } | 68 | } | ||
71 | } | 69 | } | ||
72 | } | 70 | } |