# HG changeset patch # User sl # Date 1401723632 -7200 # Node ID bb3f9b3c64163a220067ae95af60b47a363adf9b # Parent aec049087578b71c01ddb9a56acde75ee739ac3e Adding scrolling text animation demo. diff -r aec049087578 -r bb3f9b3c6416 MarqueeText.qml --- a/MarqueeText.qml Mon Jun 02 14:07:25 2014 +0200 +++ b/MarqueeText.qml Mon Jun 02 17:40:32 2014 +0200 @@ -4,22 +4,76 @@ id:marqueeText height: scrollingText.height clip: true - property int tempX: 0 + property int pixelsPerSeconds:25 property alias text: scrollingText.text + property alias separator: separatorText.text + Text { - x: tempX id:scrollingText } + Text { + id:separatorText + text:" || " + x:scrollingText.x+scrollingText.width + } + + Text { + id:followingText + text:scrollingText.text + x:scrollingText.x+scrollingText.width+separatorText.width + } + + ParallelAnimation { + id: animation + loops: Animation.Infinite; + //Reset to zero and restart onStopped so that we keep looping + //onStopped: {scrollingText.x=0;running=true;} + + XAnimator { + target: scrollingText; + //from: 0; + to: -scrollingText.width-separatorText.width; + duration: (scrollingText.width+separatorText.width)*1000/pixelsPerSeconds + } + + XAnimator { + target: separatorText; + from: separatorText.x; + to: separatorText.x-scrollingText.width-separatorText.width; + duration: (scrollingText.width+separatorText.width)*1000/pixelsPerSeconds + } + + XAnimator { + target: followingText; + from: followingText.x; + to: followingText.x-scrollingText.width-separatorText.width; + duration: (scrollingText.width+separatorText.width)*1000/pixelsPerSeconds + } + + } + + + + + MouseArea { id:mouseArea anchors.fill: parent onClicked: { - tempX = 0; - timer.running = true; + animation.running=true; + //animator.running=true; + //otherAnimator.running=true; + //scrollingText.x=-500; + + //tempX = 0; + //timer.running = true; } + } + + /* Timer { id:timer interval: 33; running: false; repeat: true @@ -41,4 +95,5 @@ scrollingText.x = 0 } } + */ } diff -r aec049087578 -r bb3f9b3c6416 TestsTab.qml --- a/TestsTab.qml Mon Jun 02 14:07:25 2014 +0200 +++ b/TestsTab.qml Mon Jun 02 17:40:32 2014 +0200 @@ -248,21 +248,24 @@ // Rectangle { - border.width: 2 - border.color: "black" - color: "lightsteelblue" + border.width: 2 + border.color: "black" + color: "lightsteelblue" + anchors.horizontalCenter: parent.horizontalCenter + width: 250 + height: text.height + 10 + y:100 + MarqueeText { + id:text + width: 200 + pixelsPerSeconds:50 + anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenter: parent.horizontalCenter - width: 250 - height: text.height + 10 - y:100 - MarqueeText { - id:text - width: 200 - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.horizontalCenter - text: "start ------ abcdefghijklmnopqrtaksdjfkdfjklsdjflksdjfklsjadfkljsad;flasjdlfjasdfjldsdfljf---- end" - } + text: "start ------ abcdefghijklmnopqrtaksdjfkdfjklsdjflksdjfklsjadfkljsad;flasjdlfjasdfjldsdfljf---- end" + //text: "start ------ end" + separator: " | " } + } } }