summaryrefslogtreecommitdiff
path: root/prototype_2016/third_party/qml-material/src/window/Sidebar.qml
diff options
context:
space:
mode:
Diffstat (limited to 'prototype_2016/third_party/qml-material/src/window/Sidebar.qml')
-rw-r--r--prototype_2016/third_party/qml-material/src/window/Sidebar.qml151
1 files changed, 0 insertions, 151 deletions
diff --git a/prototype_2016/third_party/qml-material/src/window/Sidebar.qml b/prototype_2016/third_party/qml-material/src/window/Sidebar.qml
deleted file mode 100644
index 7954294..0000000
--- a/prototype_2016/third_party/qml-material/src/window/Sidebar.qml
+++ /dev/null
@@ -1,151 +0,0 @@
1/*
2 * QML Material - An application framework implementing Material Design.
3 *
4 * Copyright (C) 2014-2016 Michael Spencer <sonrisesoftware@gmail.com>
5 *
6 * This Source Code Form is subject to the terms of the Mozilla Public
7 * License, v. 2.0. If a copy of the MPL was not distributed with this
8 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 */
10
11import QtQuick 2.4
12import Material 0.3
13import "ListItems" as ListItem
14
15/*!
16 \qmltype Sidebar
17 \inqmlmodule Material
18
19 \brief A sidebar component for use in adaptive layouts
20
21 To use, simply add an instance to your code, and anchor other components to it.
22
23 To show or hide, set the expanded property.
24
25 By default, the sidebar has a flickable built in, and whatever contents are added
26 will be placed in the flickable. When you want this disabled, or want to fill the
27 entire sidebar, set the autoFill property to false.
28
29 Examples:
30 \qml
31 Item{
32 property bool wideAspect: width > gu(80)
33
34 Sidebar {
35 expanded: wideAspect
36
37 // Anchoring is automatic
38 }
39 }
40 \endqml
41 */
42View {
43 id: root
44
45 backgroundColor: style === "default" ? "white" : "#333"
46
47 anchors {
48 left: mode === "left" ? parent.left : undefined
49 right: mode === "right" ? parent.right : undefined
50 top: parent.top
51 bottom: parent.bottom
52 leftMargin: expanded ? 0 : -width
53 rightMargin: expanded ? 0 : -width
54 }
55
56 width: 250 * Units.dp
57
58 property bool expanded: true
59
60 property string mode: "left" // or "right"
61 property alias header: headerItem.text
62
63 property color borderColor: style === "dark" ? Qt.rgba(0.5,0.5,0.5,0.5) : Theme.light.dividerColor
64
65 property bool autoFlick: true
66
67 default property alias contents: contents.data
68
69 Behavior on anchors.leftMargin {
70 NumberAnimation { duration: 200 }
71 }
72
73 Behavior on anchors.rightMargin {
74 NumberAnimation { duration: 200 }
75 }
76
77 Rectangle {
78 color: borderColor
79 width: 1
80
81 anchors {
82 top: parent.top
83 bottom: parent.bottom
84 right: mode === "left" ? parent.right : undefined
85 left: mode === "right" ? parent.left : undefined
86 //rightMargin: -1
87 }
88 }
89
90 Item {
91 clip: true
92
93 anchors {
94 fill: parent
95 rightMargin: mode === "left" ? 1 : 0
96 leftMargin: mode === "right" ? 1 : 0
97 }
98
99 ListItem.Subheader {
100 id: headerItem
101
102 visible: text !== ""
103 backgroundColor: root.backgroundColor
104 elevation: flickable.atYBeginning ? 0 : 1
105 fullWidth: true
106 z: 2
107 }
108
109 Flickable {
110 id: flickable
111
112 clip: true
113
114 anchors {
115 top: headerItem.visible ? headerItem.bottom : parent.top
116 left: parent.left
117 right: parent.right
118 bottom: parent.bottom
119 }
120
121 contentWidth: width
122 contentHeight: autoFlick ? contents.height : height
123 interactive: contentHeight > height
124
125 Item {
126 id: contents
127
128 width: flickable.width
129 height: autoFlick ? childrenRect.height : flickable.height
130 }
131
132 function getFlickableChild(item) {
133 if (item && item.hasOwnProperty("children")) {
134 for (var i=0; i < item.children.length; i++) {
135 var child = item.children[i];
136 if (internal.isVerticalFlickable(child)) {
137 if (child.anchors.top === page.top || child.anchors.fill === page) {
138 return item.children[i];
139 }
140 }
141 }
142 }
143 return null;
144 }
145 }
146
147 Scrollbar {
148 flickableItem: flickable
149 }
150 }
151}