blob: 596c785203bf1294cd200e2bde5e3df073bed7f5 (
plain)
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
|
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
Item {
id: rootItem
property real showFpsAnimated: fpsHelper.enabled
property bool scrubbing: false
property real scrubTime: 0
property int scrubFrame: 0
property int scrubStartFrame: 0
property int scrubStartX: 0
function reset() {
scrubTime = 0;
scrubFrame = 0;
}
anchors.verticalCenter: parent.verticalCenter
height: parent.height
width: Math.max(fpsTextItem.width + 20, timeTextItem.width + 20)
Behavior on showFpsAnimated {
NumberAnimation {
duration: 400
easing.type: Easing.InOutQuad
}
}
Column {
id: fpsTextItem
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenterOffset: -60 * rootItem.showFpsAnimated
height: parent.height
spacing: 0
Text {
anchors.horizontalCenter: parent.horizontalCenter
color: mainView.foregroundColor2
font.pixelSize: 14
text: fpsHelper.fps.toFixed(1)
opacity: rootItem.showFpsAnimated
}
Text {
anchors.horizontalCenter: parent.horizontalCenter
color: mainView.foregroundColor1
font.pixelSize: 14
font.bold: true
text: "FPS"
opacity: rootItem.showFpsAnimated
}
}
Text {
id: timeTextItem
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
anchors.verticalCenterOffset: -10
color: mainView.foregroundColor2
font.pixelSize: 14
text: effectPreview.animatedTime >= 100 ? effectPreview.animatedTime.toFixed(1) + " s" : effectPreview.animatedTime.toFixed(3) + " s"
}
Text {
id: frameTextItem
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
anchors.verticalCenterOffset: 10
color: mainView.foregroundColor1
font.pixelSize: 14
font.bold: true
text: (effectPreview.animatedFrame).toString().padStart(6, '0');
}
Rectangle {
z: -1
anchors.fill: parent
anchors.margins: -2
color: "#000000"
border.width: 2
border.color: mainView.highlightColor
antialiasing: true
radius: 5
opacity: rootItem.scrubbing * 0.5
visible: opacity > 0
Behavior on opacity {
NumberAnimation {
duration: 200
easing.type: Easing.InOutQuad
}
}
}
MouseArea {
anchors.fill: parent
onPressed: {
scrubStartX = mouseX;
scrubStartFrame = scrubFrame;
rootItem.scrubbing = true;
previewAnimationRunning = false;
}
onReleased: {
rootItem.scrubbing = false;
}
onPositionChanged: {
let pannedFrame = scrubStartFrame + (mouseX - scrubStartX);
let pannedTime = (1 / 60) * pannedFrame;
// Don't scrub below time < 0 or frame < 0
pannedFrame = Math.max(pannedFrame, -previewFrameTimer.currentFrame);
pannedTime = Math.max(pannedTime, -previewFrameTimer.elapsedTime);
rootItem.scrubFrame = pannedFrame;
rootItem.scrubTime = pannedTime;
}
}
}
|