[ui] sequence player: play-pause sequence using a timer

This commit is contained in:
Loïc Vital 2023-03-24 15:31:46 +01:00
parent 45a95b5114
commit 47d3089e5b

View file

@ -7,6 +7,8 @@ import Controls 1.0
FloatingPane { FloatingPane {
id: root id: root
property real fps: 4
function sequence(vps) { function sequence(vps) {
let objs = [] let objs = []
for (let i = 0; i < vps.count; i++) { for (let i = 0; i < vps.count; i++) {
@ -27,16 +29,48 @@ FloatingPane {
QtObject { QtObject {
id: m id: m
property var currentCameraInit: _reconstruction && _reconstruction.cameraInit ? _reconstruction.cameraInit : undefined property var currentCameraInit: _reconstruction && _reconstruction.cameraInit ? _reconstruction.cameraInit : undefined
property var viewpoints: currentCameraInit ? currentCameraInit.attribute('viewpoints').value : undefined property var viewpoints: currentCameraInit ? currentCameraInit.attribute('viewpoints').value : undefined
property var sortedViewIds: viewpoints ? sequence(viewpoints) : [] property var sortedViewIds: viewpoints ? sequence(viewpoints) : []
} }
Timer {
id: timer
repeat: true
running: false
interval: 1000 / fps
onTriggered: {
viewSlider.value = viewSlider.value + 1;
}
}
RowLayout { RowLayout {
anchors.fill: parent anchors.fill: parent
Button {
id: playButton
checkable: true
checked: false
text: checked ? "pause" : "play"
onCheckedChanged: {
if (checked) {
timer.running = true;
}
else {
timer.running = false;
}
}
}
Slider { Slider {
id: viewSlider
Layout.fillWidth: true Layout.fillWidth: true
@ -45,7 +79,7 @@ FloatingPane {
live: true live: true
from: 0 from: 0
to: Math.max(m.sortedViewIds.length, 1) to: m.sortedViewIds.length + 1
onValueChanged: { onValueChanged: {
let idx = Math.floor(value); let idx = Math.floor(value);