[vlmc-devel] Timeline: Move zerofill and timecode functions to main.qml
Yikai Lu
git at videolan.org
Mon Jul 18 15:40:00 CEST 2016
vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Mon Jul 18 22:16:15 2016 +0900| [b75a85de9d405515c1b398b61cb660107fddab08] | committer: Yikai Lu
Timeline: Move zerofill and timecode functions to main.qml
> https://code.videolan.org/videolan/vlmc/commit/b75a85de9d405515c1b398b61cb660107fddab08
---
src/Gui/timeline/Ruler.qml | 19 +------------------
src/Gui/timeline/main.qml | 21 +++++++++++++++++++++
2 files changed, 22 insertions(+), 18 deletions(-)
diff --git a/src/Gui/timeline/Ruler.qml b/src/Gui/timeline/Ruler.qml
index 14717bb..4df195b 100644
--- a/src/Gui/timeline/Ruler.qml
+++ b/src/Gui/timeline/Ruler.qml
@@ -60,14 +60,6 @@ Rectangle {
}
}
- function zerofill( number, width ) {
- var str = "" + number;
- while ( str.length < width ) {
- str = "0" + str;
- }
- return str;
- }
-
Component.onCompleted: {
if ( index % 10 == 0 ) {
// Text
@@ -79,16 +71,7 @@ Rectangle {
);
obj.text = Qt.binding( function()
{
- var seconds = Math.floor( index * unit / 1000 );
- var minutes = Math.floor( seconds / 60 );
- var hours = Math.floor( minutes / 60 );
-
- return zerofill( hours, 3 ) + ':' + // hours
- zerofill( minutes % 60, 2 ) + ':' + // minutes
- zerofill( seconds % 60, 2 ) + ':' + // seconds
- // The second Math.round prevents the first value from exceeding fps.
- // e.g. 30 % Math.round( 29.97 ) = 0
- zerofill( Math.round( ptof( index * ppu ) % fps ) % Math.round( fps ), 2 ); // frames in a minute
+ return timecodeFromFrames( ptof( x ) );
} );
scale.color = "#AA7777";
scale.width = 2;
diff --git a/src/Gui/timeline/main.qml b/src/Gui/timeline/main.qml
index 3642251..a00ecf9 100644
--- a/src/Gui/timeline/main.qml
+++ b/src/Gui/timeline/main.qml
@@ -29,6 +29,27 @@ Rectangle {
}
}
+ function zerofill( number, width ) {
+ var str = "" + number;
+ while ( str.length < width ) {
+ str = "0" + str;
+ }
+ return str;
+ }
+
+ function timecodeFromFrames( frames ) {
+ var seconds = Math.floor( frames / Math.round( fps ) );
+ var minutes = Math.floor( seconds / 60 );
+ var hours = Math.floor( minutes / 60 );
+
+ return zerofill( hours, 3 ) + ':' + // hours
+ zerofill( minutes % 60, 2 ) + ':' + // minutes
+ zerofill( seconds % 60, 2 ) + ':' + // seconds
+ // The second Math.round prevents the first value from exceeding fps.
+ // e.g. 30 % Math.round( 29.97 ) = 0
+ zerofill( Math.floor( frames % Math.round( fps ) ), 2 ); // frames in a minute
+ }
+
// Convert length in frames to pixels
function ftop( frames )
{
More information about the Vlmc-devel
mailing list