File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ import QtQuick.Layouts
5
5
import QtQuick.Controls
6
6
import ScratchCPP.Render
7
7
8
+ import "internal"
9
+
8
10
ProjectScene {
9
11
property string fileName
10
12
property int stageWidth: 480
@@ -64,6 +66,21 @@ ProjectScene {
64
66
else
65
67
clones .model .remove (i);
66
68
}
69
+
70
+ onMonitorAdded : (monitorModel )=> monitors .model .append ({" monitorModel" : monitorModel})
71
+
72
+ onMonitorRemoved : (monitorModel )=> {
73
+ // TODO: Removing the monitor from C++ would probably be faster
74
+ let i;
75
+
76
+ for (i = 0 ; i < monitors .model .count ; i++ ) {
77
+ if (monitors .model .get (i).monitorModel === monitorModel)
78
+ break ;
79
+ }
80
+
81
+ if (i !== monitors .model .count )
82
+ monitors .model .remove (i);
83
+ }
67
84
}
68
85
69
86
function start () {
@@ -130,6 +147,35 @@ ProjectScene {
130
147
onMouseReleased: root .handleMouseRelease ()
131
148
}
132
149
150
+ Component {
151
+ id: renderedValueMonitor
152
+
153
+ ValueMonitor {
154
+ model: parent .model
155
+ scale: root .stageScale
156
+ transformOrigin: Item .TopLeft
157
+ x: model .x * scale
158
+ y: model .y * scale
159
+ }
160
+ }
161
+
162
+ Component {
163
+ id: renderedMonitor
164
+
165
+ Loader {
166
+ readonly property MonitorModel model: monitorModel
167
+ sourceComponent: monitorModel ? (monitorModel .type === MonitorModel .Value ? renderedValueMonitor : null ) : null
168
+ active: sourceComponent != null
169
+ z: loader .sprites .length + loader .clones .length + 1 // above all sprites
170
+ }
171
+ }
172
+
173
+ Repeater {
174
+ id: monitors
175
+ model: ListModel {}
176
+ delegate: renderedMonitor
177
+ }
178
+
133
179
Loader {
134
180
anchors .fill : parent
135
181
active: showLoadingProgress && loading
You can’t perform that action at this time.
0 commit comments