~ubuntu-branches/ubuntu/quantal/qtmobility/quantal

« back to all changes in this revision

Viewing changes to examples/qmlorganizer/contents/ScrollBar.qml

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-11-16 16:18:07 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20101116161807-k2dzt2nyse975r3l
Tags: 1.1.0-0ubuntu1
* New upstream release
* Syncronise with Debian, no remaining changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import Qt 4.6
 
2
 
 
3
Item {
 
4
    id: scrollBar
 
5
    // The properties that define the scrollbar's state.
 
6
    // position and pageSize are in the range 0.0 - 1.0.  They are relative to the
 
7
    // height of the page, i.e. a pageSize of 0.5 means that you can see 50%
 
8
    // of the height of the view.
 
9
    // orientation can be either 'Vertical' or 'Horizontal'
 
10
    property real position
 
11
    property real pageSize
 
12
    property var orientation : "Vertical"
 
13
    property alias bgColor: background.color
 
14
    property alias fgColor: thumb.color
 
15
 
 
16
    // A light, semi-transparent background
 
17
    Rectangle {
 
18
        id: background
 
19
        radius: orientation == 'Vertical' ? (width/2 - 1) : (height/2 - 1)
 
20
        color: "white"; opacity: 0.3
 
21
        anchors.fill: parent
 
22
    }
 
23
    // Size the bar to the required size, depending upon the orientation.
 
24
    Rectangle {
 
25
        id: thumb
 
26
        opacity: 0.7
 
27
        color: "black"
 
28
        radius: orientation == 'Vertical' ? (width/2 - 1) : (height/2 - 1)
 
29
        x: orientation == 'Vertical' ? 1 : (scrollBar.position * (scrollBar.width-2) + 1)
 
30
        y: orientation == 'Vertical' ? (scrollBar.position * (scrollBar.height-2) + 1) : 1
 
31
        width: orientation == 'Vertical' ? (parent.width-2) : (scrollBar.pageSize * (scrollBar.width-2))
 
32
        height: orientation == 'Vertical' ? (scrollBar.pageSize * (scrollBar.height-2)) : (parent.height-2)
 
33
    }
 
34
}