-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBottom_Bar.qml
372 lines (333 loc) · 14.4 KB
/
Bottom_Bar.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
import QtQuick
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.5
import Qt.labs.animation
//icon source: https://fontawesome.com
Item {
property int tick: 15;
property int screenEdge: parent.width
property int container_stopPositionX: 0
property int container_startPositionX: 0
property int positionmarker_stopPositionX: 0
property int currentTime: 0
property string status: slurm_status
property bool live:true
property int endTime: parent.endTime
property bool bar_enable_timeline : enable_timeline
property string options: parent.option
property var timestampA: null
property var timestampB: null
onOptionsChanged: {
if(bar_enable_timeline && playbutton.icon.name==="play"){
nodesList.showConditionAt(timestampA, timestampB)
}
}
id: bottom_timeline_bar
width: parent.width
height: 70
onWidthChanged: {
timeline.width = width
currentTime=0
screenEdge+=parent.width
}
RowLayout{
id: timeline_layout
anchors.fill: parent
width: parent.width
spacing: 0
Rectangle{
id: timeline_buttons
implicitWidth: 150
z: 1
implicitHeight: parent.height
color: "#383936"
Layout.fillWidth: true
Layout.maximumWidth: 150
Layout.minimumWidth: 150
Component.onCompleted: {
//screenEdge=150
}
Row{
padding: 10
topPadding: 20
spacing: 10
//width: parent.width
//height: parent.height
RoundButton{
id: playbutton
scale: 1.2
icon.name: "pause"
icon.source: "/icons/pause.png"
icon.color: "grey"
enabled: bar_enable_timeline
onEnabledChanged: {
if (enabled == true){
currentTime = startTime
timeline_timer.start()
icon.color = "red"
timeline.width+=1
if(!live){
//console.log("enable playbutton clicked")
playbutton.clicked()
}
} else if (enabled == false) {
currentTime = 0
icon.color = "grey"
icon.source = "/icons/pause.png"
icon.name = "pause"
screenEdge = parent.width
container_stopPositionX = 0
positionmarker_stopPositionX = 0
timeline_positionmarker.x = 0
timeline.width = bottom_timeline_bar.width
timeline_container.interactive = false
}
}
onClicked: {
if(icon.name==="pause"){
icon.color = "red"
icon.source= "/icons/play.png"
icon.name= "play"
timeline_timer.stop()
container_stopPositionX = timeline_container.contentX
/*if(timeline_positionmarker.x >= timeline_endmarker.x){
positionmarker_stopPositionX = 0
nodesList.reset_bottom_bar()
} else {*/
positionmarker_stopPositionX = timeline_positionmarker.x
// }
timeline_container.interactive=true
//nodesList.startAndStop(true);
}
else {
icon.color = "red"
icon.source= "/icons/pause.png"
icon.name= "pause"
timeline_timer.start()
timeline_container.contentX=container_stopPositionX
timeline_positionmarker.x = positionmarker_stopPositionX
timeline_container.interactive=false
//nodesList.startAndStop(false);
}
}
}
RoundButton{
//icon.name: "backward"
scale: 1.2
icon.source: "/icons/backward_step.png"
icon.color: "white"
onClicked: {
if(playbutton.icon.name==="play"){
timeline_positionmarker.x -=tick
var timestamp = timeline_positionmarker.x/tick;
nodesList.showConditionAt(timestamp, timestamp)
}
}
}
RoundButton{
//icon.name: "forward-step"
scale: 1.2
icon.source: "/icons/forward_step.png"
icon.color: "white"
onClicked: {
if(playbutton.icon.name==="play"){
timeline_positionmarker.x +=tick
var timestamp = timeline_positionmarker.x/tick;
nodesList.showConditionAt(timestamp, timestamp)
}
}
}
}
}
Rectangle{
id: rect_over_timeline_container
implicitWidth: parent.width-timeline_buttons.width
implicitHeight: parent.height
Layout.fillWidth: true
Flickable{
id: timeline_container
width: parent.width
height: parent.height
contentWidth: timeline.width
contentHeight: parent.height
flickableDirection: Flickable.HorizontalFlick
clip: true
boundsBehavior: Flickable.StopAtBounds
interactive: false
ScrollBar.horizontal: ScrollBar {
id: scrollable_area
orientation: Qt.Horizontal
visible: timeline_container.interactive
}
Component.onCompleted: {
container_startPositionX = timeline_container.contentX
}
WheelHandler{
onWheel: event=>{
if(timeline_container.interactive){
timeline_container.flick(event.angleDelta.y*event.y, 0)
}
}
}
Rectangle{
id: timeline
width: bottom_timeline_bar.width//-timeline_buttons.width
height: parent.height
color: "#383936"
//x: timeline_container.visibleArea.xPosition
Repeater{
id: timeline_repeater
model:parent.width/tick
anchors.fill: parent
delegate: Item {
anchors.fill: parent
Rectangle{
id: second
x: index*tick
anchors.top: parent.top
width: 1
height: timeline.height/3
color: "grey"
}
Text{
id: timestamp
anchors.top: second.bottom
x: index*tick
font.pointSize: 8
color: "grey"
}
Component.onCompleted: {
if(index===0 || index%5==0){
second.height=timeline.height/1.5
//console.log("CurrentTime : "+currentTime)
var hours = Math.floor(currentTime / 3600);
var minutes = Math.floor((currentTime % 3600) / 60);
var seconds = currentTime % 60;
timestamp.text=("0" + hours).slice(-2) + ":" + ("0" + minutes).slice(-2) + ":" + ("0" + seconds).slice(-2);
//console.log(timestamp.text)
currentTime+=5;
}
}
}
}
Rectangle{
id: timeline_endmarker
width: 5
height: parent.height
visible: false
color: "blue"
opacity: 0.7
border.color: "blue"
x : (endTime - startTime)*tick
onXChanged:{
if(endTime == 0){
visible = false;
}
else {
visible = true
//console.log("timeline_endmarker set: "+ timeline_endmarker.x)
}
if(startTime!=0 && !live){
if(timeline.width < (endTime - startTime)*tick){
//console.log("resize timeline width")
timeline.width = 100 + (endTime - startTime)*tick
}
}
}
}
Rectangle{
id:timeline_positionmarker
width: 2
height: parent.height
color: "red"
opacity: 0.3
border.color: "red"
//anchors.bottom: parent
}
MouseArea{
id: timeline_mousearea
anchors.fill: parent
property int markerareaStart : 0
property int markerareaEnd: 0
property int markerareaWidth : 0
/*onClicked: {
if(playbutton.icon.name==="play"
){
timeline_positionmarker.width=2
timeline_positionmarker.x = Math.floor(timeline_mousearea.mouseX/15)*15
}
}*/
onPressed: {
// Startpunkt des markierten Bereichs
if(playbutton.icon.name==="play"){
timeline_container.interactive=false
timeline_positionmarker.width = 2
timeline_positionmarker.x = Math.floor(timeline_mousearea.mouseX/tick)*tick
markerareaStart = Math.floor(timeline_mousearea.mouseX/tick)*tick
}
}
onReleased: {
// Endpunkt des markierten Bereichs
if(playbutton.icon.name==="play"){
timeline_container.interactive=true
markerareaEnd = Math.floor(timeline_mousearea.mouseX/tick)*tick
markerareaWidth = markerareaEnd - markerareaStart
if(markerareaWidth>tick-1){
timeline_positionmarker.width = markerareaWidth + 2
}
timestampA = timeline_positionmarker.x/tick;
timestampB = markerareaEnd/tick;
nodesList.showConditionAt(timestampA, timestampB)
}
}
onPositionChanged: {
//console.log(timeline_mousearea.mouseX)
if(playbutton.icon.name==="play"){
markerareaEnd = timeline_mousearea.mouseX
markerareaWidth = markerareaEnd - markerareaStart
timeline_positionmarker.width = markerareaWidth
if(timeline_mousearea.mouseX >= timeline_container.width-50 && timeline_mousearea.mouseX<timeline.width){
timeline_container.contentX += tick
}
}
}
}
}
}
}
}
Timer{
id: timeline_timer
interval: 1000
running: false
repeat: true
//triggeredOnStart: true
property int ticker_counter: 0
onTriggered: {
if(bottom_timeline_bar.endTime != 0 && timeline_positionmarker.x >= timeline_endmarker.x){
timeline_positionmarker.x = 0
ticker_counter = 0;
timeline_container.contentX = container_startPositionX
} else {
timeline_positionmarker.x +=tick
}
ticker_counter++
var mappedPosition = timeline_positionmarker.mapToItem(rootItem, 0.0, 0.0);
nodesList.signalToUpdateData(nodesList.time_display)
if(endTime != 0){
if(timeline_positionmarker.x >= timeline_endmarker.x){
playbutton.clicked()
nodesList.reset_bottom_bar()
enable_start = true
}
}
if(mappedPosition.x>=parent.width-50){
//currentTime=0
timeline.width += parent.width + 50
timeline_container.contentX+=ticker_counter*tick
ticker_counter=0
//timestamp.text=Date()
}
}
}
}