~zsombi/ubuntu-ui-toolkit/listitemSelectModeBugs

« back to all changes in this revision

Viewing changes to src/Ubuntu/Components/Themes/Ambiance/1.3/BottomEdgeStyle.qml

  • Committer: Zsombor Egri
  • Date: 2015-12-07 17:02:28 UTC
  • mfrom: (1662.2.80 staging)
  • Revision ID: zsombor.egri@canonical.com-20151207170228-coqv9fvqublui315
staging sync

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2015 Canonical, Ltd.
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License as published by
 
6
 * the Free Software Foundation; version 3.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 */
 
16
import QtQuick 2.4
 
17
import Ubuntu.Components 1.3
 
18
import Ubuntu.Components.Styles 1.3
 
19
 
 
20
BottomEdgeStyle {
 
21
    id: bottomEdgeStyle
 
22
    //setup properties
 
23
    property BottomEdge bottomEdge: styledItem
 
24
    panel: panelItem
 
25
    contentItem: loader.item
 
26
    panelAnimation: panelBehavior
 
27
    revealThreshold: bottomEdge.hint.height + units.gu(2)
 
28
 
 
29
    // own styling properties
 
30
    property color backgroundColor: Qt.rgba(0, 0, 0, Math.min(0.25, (height - revealThreshold - panelItem.y) / (height - revealThreshold)))
 
31
    property color panelColor: theme.palette.normal.overlay
 
32
    property color shadowColor: "#000000"
 
33
 
 
34
    anchors.fill: parent
 
35
 
 
36
    Rectangle {
 
37
        id: background
 
38
        anchors.fill: parent
 
39
        color: backgroundColor
 
40
        z: -1
 
41
    }
 
42
 
 
43
    Rectangle {
 
44
        id: panelItem
 
45
        objectName: "bottomedge_panel"
 
46
        anchors {
 
47
            left: parent.left
 
48
            right: parent.right
 
49
            top: parent.bottom
 
50
            topMargin: bottomEdge.status >= BottomEdge.Revealed
 
51
                       ? -(bottomEdge.height * bottomEdge.dragProgress)
 
52
                       : 0
 
53
        }
 
54
        height: loader.item ? loader.item.height : 0
 
55
        color: panelColor
 
56
        opacity: bottomEdge.status >= BottomEdge.Revealed ? 1.0 : 0.0
 
57
 
 
58
        Behavior on anchors.topMargin { UbuntuNumberAnimation { id: panelBehavior } }
 
59
 
 
60
        state: bottomEdge.status > BottomEdge.Hidden ? "drop-hint" : ""
 
61
        states: [
 
62
            State {
 
63
                name: "drop-hint"
 
64
                PropertyChanges {
 
65
                    target: bottomEdge.hint
 
66
                    restoreEntryValues: false
 
67
                    status: BottomEdgeHint.Inactive
 
68
                }
 
69
            }
 
70
        ]
 
71
 
 
72
        // shadows
 
73
        Rectangle {
 
74
            id: topShadow
 
75
            anchors {
 
76
                bottom: parent.top
 
77
                left: parent.left
 
78
                right: parent.right
 
79
            }
 
80
            height: units.gu(1.5)
 
81
            gradient: Gradient {
 
82
                GradientStop { position: 0.0; color: Qt.rgba(shadowColor.r, shadowColor.g, shadowColor.b, 0.0) }
 
83
                GradientStop { position: 0.75; color: Qt.rgba(shadowColor.r, shadowColor.g, shadowColor.b, 0.05) }
 
84
                GradientStop { position: 1.0; color: Qt.rgba(shadowColor.r, shadowColor.g, shadowColor.b, 0.1) }
 
85
            }
 
86
        }
 
87
        Rectangle {
 
88
            id: bottomShadow
 
89
            anchors {
 
90
                top: parent.bottom
 
91
                left: parent.left
 
92
                right: parent.right
 
93
            }
 
94
            height: units.gu(1.5)
 
95
            rotation: 180
 
96
            gradient: Gradient {
 
97
                GradientStop { position: 0.0; color: Qt.rgba(shadowColor.r, shadowColor.g, shadowColor.b, 0.0) }
 
98
                GradientStop { position: 0.75; color: Qt.rgba(shadowColor.r, shadowColor.g, shadowColor.b, 0.05) }
 
99
                GradientStop { position: 1.0; color: Qt.rgba(shadowColor.r, shadowColor.g, shadowColor.b, 0.1) }
 
100
            }
 
101
        }
 
102
 
 
103
        // content
 
104
        Loader {
 
105
            id: loader
 
106
            anchors.horizontalCenter: parent.horizontalCenter
 
107
            asynchronous: true
 
108
            source: bottomEdge.status > BottomEdge.Hidden ? bottomEdge.contentUrl : ""
 
109
            sourceComponent: bottomEdge.status > BottomEdge.Hidden ? bottomEdge.contentComponent : null
 
110
            onItemChanged: {
 
111
                if (item) {
 
112
                    item.parent = panelItem;
 
113
                    item.anchors.horizontalCenter = panelItem.horizontalCenter;
 
114
                }
 
115
            }
 
116
        }
 
117
    }
 
118
}