author | sl |
Tue, 03 Jun 2014 16:11:47 +0200 | |
changeset 29 | a42cc76a2d5a |
parent 27 | 3d3f781bf543 |
child 30 | c0f274a21d33 |
permissions | -rw-r--r-- |
sl@25 | 1 |
import QtQuick 2.2 |
sl@28 | 2 |
import QtQuick.Controls 1.2 |
sl@25 | 3 |
|
sl@25 | 4 |
Item { |
sl@28 | 5 |
id:item |
sl@25 | 6 |
height: scrollingText.height |
sl@25 | 7 |
clip: true |
sl@28 | 8 |
antialiasing: false |
sl@26 | 9 |
property int pixelsPerSeconds:25 |
sl@25 | 10 |
property alias text: scrollingText.text |
sl@26 | 11 |
property alias separator: separatorText.text |
sl@26 | 12 |
|
sl@28 | 13 |
Label { |
sl@25 | 14 |
id:scrollingText |
sl@28 | 15 |
antialiasing: item.antialiasing |
sl@25 | 16 |
} |
sl@25 | 17 |
|
sl@28 | 18 |
Label { |
sl@26 | 19 |
id:separatorText |
sl@26 | 20 |
text:" || " |
sl@26 | 21 |
x:scrollingText.x+scrollingText.width |
sl@28 | 22 |
antialiasing: item.antialiasing |
sl@26 | 23 |
} |
sl@26 | 24 |
|
sl@28 | 25 |
Label { |
sl@26 | 26 |
id:followingText |
sl@26 | 27 |
text:scrollingText.text |
sl@26 | 28 |
x:scrollingText.x+scrollingText.width+separatorText.width |
sl@28 | 29 |
antialiasing: item.antialiasing |
sl@26 | 30 |
} |
sl@26 | 31 |
|
sl@26 | 32 |
ParallelAnimation { |
sl@26 | 33 |
id: animation |
sl@26 | 34 |
loops: Animation.Infinite; |
sl@26 | 35 |
//Reset to zero and restart onStopped so that we keep looping |
sl@26 | 36 |
//onStopped: {scrollingText.x=0;running=true;} |
sl@26 | 37 |
|
sl@27 | 38 |
NumberAnimation { |
sl@26 | 39 |
target: scrollingText; |
sl@27 | 40 |
properties: "x" |
sl@26 | 41 |
//from: 0; |
sl@26 | 42 |
to: -scrollingText.width-separatorText.width; |
sl@26 | 43 |
duration: (scrollingText.width+separatorText.width)*1000/pixelsPerSeconds |
sl@26 | 44 |
} |
sl@26 | 45 |
|
sl@27 | 46 |
NumberAnimation { |
sl@26 | 47 |
target: separatorText; |
sl@27 | 48 |
properties: "x" |
sl@26 | 49 |
from: separatorText.x; |
sl@26 | 50 |
to: separatorText.x-scrollingText.width-separatorText.width; |
sl@26 | 51 |
duration: (scrollingText.width+separatorText.width)*1000/pixelsPerSeconds |
sl@26 | 52 |
} |
sl@26 | 53 |
|
sl@27 | 54 |
NumberAnimation { |
sl@26 | 55 |
target: followingText; |
sl@27 | 56 |
properties: "x" |
sl@26 | 57 |
from: followingText.x; |
sl@26 | 58 |
to: followingText.x-scrollingText.width-separatorText.width; |
sl@26 | 59 |
duration: (scrollingText.width+separatorText.width)*1000/pixelsPerSeconds |
sl@26 | 60 |
} |
sl@26 | 61 |
|
sl@26 | 62 |
} |
sl@26 | 63 |
|
sl@27 | 64 |
//Click to start |
sl@25 | 65 |
MouseArea { |
sl@25 | 66 |
id:mouseArea |
sl@25 | 67 |
anchors.fill: parent |
sl@25 | 68 |
onClicked: { |
sl@26 | 69 |
animation.running=true; |
sl@25 | 70 |
} |
sl@26 | 71 |
|
sl@25 | 72 |
} |
sl@25 | 73 |
} |