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