~ubuntu-branches/ubuntu/quantal/kde-runtime/quantal

« back to all changes in this revision

Viewing changes to plasma/declarativeimports/plasmacomponents/qml/ScrollDecoratorDelegate.qml

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2012-06-03 21:50:00 UTC
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: package-import@ubuntu.com-20120603215000-vn7oarsq0ynrydj5
Tags: upstream-4.8.80
Import upstream version 4.8.80

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
*   Copyright (C) 2011 by Daker Fernandes Pinheiro <dakerfp@gmail.com>
3
 
*   Copyright (C) 2011 Marco Martin <mart@kde.org>
4
 
*
5
 
*   This program is free software; you can redistribute it and/or modify
6
 
*   it under the terms of the GNU Library General Public License as
7
 
*   published by the Free Software Foundation; either version 2, or
8
 
*   (at your option) any later version.
9
 
*
10
 
*   This program is distributed in the hope that it will be useful,
11
 
*   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
*   GNU General Public License for more details
14
 
*
15
 
*   You should have received a copy of the GNU Library General Public
16
 
*   License along with this program; if not, write to the
17
 
*   Free Software Foundation, Inc.,
18
 
*   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19
 
*/
20
 
 
21
 
import QtQuick 1.1
22
 
import org.kde.plasma.core 0.1 as PlasmaCore
23
 
 
24
 
 
25
 
PlasmaCore.FrameSvgItem {
26
 
    id: background
27
 
    anchors.fill: parent
28
 
    imagePath:"widgets/scrollbar"
29
 
    prefix: internalLoader.isVertical ? "background-vertical" : "background-horizontal"
30
 
 
31
 
    opacity: 0
32
 
    Behavior on opacity {
33
 
        NumberAnimation {
34
 
            duration: 250
35
 
            easing.type: Easing.OutQuad
36
 
        }
37
 
    }
38
 
 
39
 
    property Item handle: handle
40
 
 
41
 
    property Item contents: contents
42
 
    Item {
43
 
        id: contents
44
 
        anchors.fill: parent
45
 
 
46
 
        PlasmaCore.FrameSvgItem {
47
 
            id: handle
48
 
            imagePath:"widgets/scrollbar"
49
 
            prefix: "slider"
50
 
 
51
 
            function length()
52
 
            {
53
 
                var nh, ny;
54
 
 
55
 
                if (internalLoader.isVertical) {
56
 
                    nh = flickableItem.visibleArea.heightRatio * internalLoader.height
57
 
                } else {
58
 
                    nh = flickableItem.visibleArea.widthRatio * internalLoader.width
59
 
                }
60
 
 
61
 
                if (internalLoader.isVertical) {
62
 
                    ny = flickableItem.visibleArea.yPosition * internalLoader.height
63
 
                } else {
64
 
                    ny = flickableItem.visibleArea.xPosition * internalLoader.width
65
 
                }
66
 
 
67
 
                if (ny > 3) {
68
 
                    var t
69
 
 
70
 
                    if (internalLoader.isVertical) {
71
 
                        t = Math.ceil(internalLoader.height - 3 - ny)
72
 
                    } else {
73
 
                        t = Math.ceil(internalLoader.width - 3 - ny)
74
 
                    }
75
 
 
76
 
                    if (nh > t) {
77
 
                        return t
78
 
                    } else {
79
 
                        return nh
80
 
                    }
81
 
                } else {
82
 
                    return nh + ny
83
 
                }
84
 
            }
85
 
 
86
 
            width: internalLoader.isVertical ? parent.width : length()
87
 
            height: internalLoader.isVertical ? length() : parent.height
88
 
        }
89
 
    }
90
 
 
91
 
    property MouseArea mouseArea: null
92
 
 
93
 
    Connections {
94
 
        target: flickableItem
95
 
        onMovingChanged: {
96
 
            if (flickableItem.moving) {
97
 
                opacityTimer.running = false
98
 
                background.opacity = 1
99
 
            } else {
100
 
                opacityTimer.restart()
101
 
            }
102
 
        }
103
 
    }
104
 
    Timer {
105
 
        id: opacityTimer
106
 
        interval: 500
107
 
        repeat: false
108
 
        running: false
109
 
        onTriggered: {
110
 
            background.opacity = 0
111
 
        }
112
 
    }
113
 
}
114