on be7527f help sign in
unity8/qml/Components/FloatingFlickable.qml
62 lines 2.2 kB history raw
1/*
2 * Copyright (C) 2015-2016 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 */
17import QtQuick 2.4
18import Ubuntu.Components 1.3
19import Ubuntu.Gestures 0.1
21/*
22 A Flickable that can be put in front of the item to be flicked and
23 still have the item-to-be-flicked receive input events that are not flicks.
25 Ie, it's a Flickable that, input-wise, is transparent to non-flick gestures.
27 With a regular Flickable you would have to make the item-to-be-flicked a child
28 of Flicakble to achieve the same result. FloatingFlickable has no such requirement
29 or limitation.
30 */
31Item {
32 property alias contentWidth: flickable.contentWidth
33 property alias contentHeight: flickable.contentHeight
34 property alias contentX: flickable.contentX
35 property alias contentY: flickable.contentY
36 property alias direction: swipeArea.direction
37 property alias leftMargin: flickable.leftMargin
38 property alias rightMargin: flickable.rightMargin
39 property alias dragging: flickable.dragging
41 MouseEventGenerator {
42 id: mouseEventGenerator
43 targetItem: flickable
44 }
46 Flickable {
47 id: flickable
48 enabled: false
49 anchors.fill: parent
50 flickableDirection: Direction.isHorizontal(swipeArea.direction) ? Flickable.HorizontalFlick : Flickable.VerticalFlick
51 }
53 SwipeArea {
54 id: swipeArea
55 anchors.fill: parent
56 direction: Direction.Horizontal
58 onTouchPositionChanged: mouseEventGenerator.move(touchPosition);
59 onDraggingChanged: dragging ? mouseEventGenerator.press(touchPosition)
60 : mouseEventGenerator.release(touchPosition)
61 }