Messing around to try to get our animation to start and stop properly.
authorsl
Wed, 04 Jun 2014 08:12:37 +0200
changeset 321c2a7f563019
parent 31 e68f1542d9d3
child 33 cf5eba52cb1d
Messing around to try to get our animation to start and stop properly.
That's still not working though.
MarqueeText.qml
MiniDisplay/minidisplay.cpp
TestsTab.qml
     1.1 --- a/MarqueeText.qml	Tue Jun 03 18:35:43 2014 +0200
     1.2 +++ b/MarqueeText.qml	Wed Jun 04 08:12:37 2014 +0200
     1.3 @@ -35,28 +35,31 @@
     1.4          //Reset to zero and restart onStopped so that we keep looping
     1.5          //onStopped: {scrollingText.x=0;running=true;}
     1.6  
     1.7 +        property int lengthInPixels:scrollingText.width-separatorText.width-scrollingText.x;
     1.8 +        property int durationInMs:(animation.lengthInPixels)*1000/pixelsPerSeconds;
     1.9 +
    1.10          NumberAnimation {
    1.11              target: scrollingText;
    1.12              properties: "x"
    1.13              from: scrollingText.x;
    1.14 -            to: scrollingText.x-scrollingText.width-separatorText.width;
    1.15 -            duration: (scrollingText.width+separatorText.width)*1000/pixelsPerSeconds
    1.16 +            to: scrollingText.x-animation.lengthInPixels;
    1.17 +            duration:animation.durationInMs
    1.18          }
    1.19  
    1.20          NumberAnimation {
    1.21              target: separatorText;
    1.22              properties: "x"
    1.23              from: separatorText.x;
    1.24 -            to: separatorText.x-scrollingText.width-separatorText.width;
    1.25 -            duration: (scrollingText.width+separatorText.width)*1000/pixelsPerSeconds
    1.26 +            to: separatorText.x-animation.lengthInPixels;
    1.27 +            duration: animation.durationInMs
    1.28          }
    1.29  
    1.30          NumberAnimation {
    1.31              target: followingText;
    1.32              properties: "x"
    1.33              from: followingText.x;
    1.34 -            to: followingText.x-scrollingText.width-separatorText.width;
    1.35 -            duration: (scrollingText.width+separatorText.width)*1000/pixelsPerSeconds
    1.36 +            to: followingText.x-animation.lengthInPixels;
    1.37 +            duration: animation.durationInMs
    1.38          }
    1.39  
    1.40      }
    1.41 @@ -65,8 +68,22 @@
    1.42      MouseArea {
    1.43          id:mouseArea
    1.44          anchors.fill: parent
    1.45 -        onClicked: {
    1.46 -            animation.running=!animation.running;
    1.47 +        onClicked: {animation.running=!animation.running;
    1.48 +            /*
    1.49 +            if (!animation.running) {
    1.50 +                animation.start();
    1.51 +                return;
    1.52 +            }
    1.53 +            if (animation.paused)
    1.54 +            {
    1.55 +                console.log("resume")
    1.56 +                animation.resume;
    1.57 +            }
    1.58 +            else
    1.59 +            {
    1.60 +                console.log("pause")
    1.61 +                animation.pause;
    1.62 +            }*/
    1.63          }
    1.64      }
    1.65  }
     2.1 --- a/MiniDisplay/minidisplay.cpp	Tue Jun 03 18:35:43 2014 +0200
     2.2 +++ b/MiniDisplay/minidisplay.cpp	Wed Jun 04 08:12:37 2014 +0200
     2.3 @@ -219,7 +219,7 @@
     2.4  void MiniDisplay::onAfterAnimating()
     2.5  {
     2.6      static int frame=0;
     2.7 -    qDebug() << frame << "MiniDisplay::onAfterAnimating";
     2.8 +    //qDebug() << frame << "MiniDisplay::onAfterAnimating";
     2.9      /*
    2.10      if (iAfterAnimatingCallback.isCallable())
    2.11      {
     3.1 --- a/TestsTab.qml	Tue Jun 03 18:35:43 2014 +0200
     3.2 +++ b/TestsTab.qml	Wed Jun 04 08:12:37 2014 +0200
     3.3 @@ -133,7 +133,7 @@
     3.4              }
     3.5  
     3.6  
     3.7 -            var frameCounter=frameCount-firstFrame;
     3.8 +            var frameCounter=(frameCount-firstFrame)/2;
     3.9              labelFrameCount.text=frameCounter;
    3.10              labelTime.text=milliseconds/1000;
    3.11              labelTimePerFrame.text=(milliseconds/frameCounter).toFixed(3);