/* * Copyright (c) 2013-2019 Meltytech, LLC * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ import QtQuick 2.0 import QtQuick.Controls 1.0 Rectangle { property int index: 0 property real timeScale: 1.0 property int adjustment: 0 property real stepSize: (5 * profile.fps * Math.max(1, Math.floor(1/timeScale)) * timeScale) + adjustment SystemPalette { id: activePalette } id: rulerTop enabled: false height: 28 color: activePalette.base function timecode(seconds) { var hours = Math.floor(seconds / 3600) seconds -= hours * 3600 var minutes = Math.floor(seconds / 60) seconds -= minutes * 60 hours = ('0' + hours).substr(-2) minutes = ('0' + minutes).substr(-2) seconds = ('0' + Math.round(seconds)).substr(-2) return hours + ':' + minutes + ':' + seconds } Repeater { model: parent.width / stepSize Rectangle { anchors.bottom: rulerTop.bottom height: 18 width: 1 color: activePalette.windowText x: index * stepSize Label { anchors.left: parent.right anchors.leftMargin: 2 anchors.bottom: parent.bottom anchors.bottomMargin: 2 color: activePalette.windowText x: index * stepSize + 2 text: timecode((index * stepSize / timeScale) / profile.fps) } } } Connections { target: profile onProfileChanged: { // Force a repeater model change to update the labels. ++adjustment --adjustment } } }