Debian Codegraph @

src/imports/Components/Themes/Ambiance/1.3/BottomEdgeStyle.qml

raw
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 Lomiri.Components 1.3
18 import Lomiri.Components.Styles 1.3
19
20 BottomEdgeStyle {
21 id: bottomEdgeStyle
22 //setup properties
23 property BottomEdge bottomEdge: styledItem
24 panel: panelItem
25 panelAnimation: panelBehavior
26 revealThreshold: bottomEdge.hint.height + units.gu(2)
27
28 //deprecated for now
29 contentItem: bottomEdge.contentItem
30
31 // own styling properties
32 property color backgroundColor: !panelItem.collapsing
33 ? Qt.rgba(0, 0, 0, Math.min(0.25, (height - revealThreshold - panelItem.y) / (height - revealThreshold)))
34 : "transparent"
35 property color panelColor: theme.palette.normal.overlay
36 property color shadowColor: "#000000"
37
38 anchors.fill: parent
39
40 Rectangle {
41 id: background
42 anchors.fill: parent
43 color: backgroundColor
44 z: -1
45 }
46
47 Rectangle {
48 id: panelItem
49 objectName: "bottomedge_panel"
50 property bool collapsing: false
51 anchors {
52 left: parent.left
53 right: parent.right
54 top: parent.bottom
55 topMargin: bottomEdge.status >= BottomEdge.Revealed
56 ? -(bottomEdge.height * bottomEdge.dragProgress)
57 : 0
58 }
59 height: bottomEdge.contentItem ? bottomEdge.contentItem.height : 0
60 color: panelColor
61 opacity: bottomEdge.status >= BottomEdge.Revealed ? 1.0 : 0.0
62
63 Behavior on anchors.topMargin { LomiriNumberAnimation { id: panelBehavior } }
64
65 Connections {
66 target: bottomEdge
67 function onCollapseStarted() { panelItem.collapsing = true }
68 function onCollapseCompleted() { panelItem.collapsing = false }
69 }
70
71 state: bottomEdge.status > BottomEdge.Hidden ? "drop-hint" : ""
72 states: [
73 State {
74 name: "drop-hint"
75 PropertyChanges {
76 target: bottomEdge.hint
77 restoreEntryValues: false
78 status: BottomEdgeHint.Inactive
79 }
80 }
81 ]
82
83 // shadows
84 Rectangle {
85 id: topShadow
86 anchors {
87 bottom: parent.top
88 left: parent.left
89 right: parent.right
90 }
91 height: units.gu(1.5)
92 gradient: Gradient {
93 GradientStop { position: 0.0; color: Qt.rgba(shadowColor.r, shadowColor.g, shadowColor.b, 0.0) }
94 GradientStop { position: 0.75; color: Qt.rgba(shadowColor.r, shadowColor.g, shadowColor.b, 0.05) }
95 GradientStop { position: 1.0; color: Qt.rgba(shadowColor.r, shadowColor.g, shadowColor.b, 0.1) }
96 }
97 }
98 Rectangle {
99 id: bottomShadow
100 anchors {
101 top: parent.bottom
102 left: parent.left
103 right: parent.right
104 }
105 height: units.gu(1.5)
106 rotation: 180
107 gradient: Gradient {
108 GradientStop { position: 0.0; color: Qt.rgba(shadowColor.r, shadowColor.g, shadowColor.b, 0.0) }
109 GradientStop { position: 0.75; color: Qt.rgba(shadowColor.r, shadowColor.g, shadowColor.b, 0.05) }
110 GradientStop { position: 1.0; color: Qt.rgba(shadowColor.r, shadowColor.g, shadowColor.b, 0.1) }
111 }
112 }
113 }
114 }