on bbbdccd help sign in
unity8/plugins/Ubuntu/Gestures/FloatingFlickable.h
86 lines 2.8 kB history 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 */
17#ifndef FLOATING_FLICKABLE_H
18#define FLOATING_FLICKABLE_H
20#include <QQuickItem>
21#include "UbuntuGesturesQmlGlobal.h"
22#include "Direction.h"
24class DirectionalDragArea;
25class QQuickFlickable;
27/*
28 A Flickable that can be put in front of the item to be flicked and
29 still have the item-to-be-flicked receive input events that are not flicks.
31 Ie, it's a Flickable that, input-wise, is transparent to non-flick gestures.
33 With a regular Flickable you would have to make the item-to-be-flicked a child
34 of Flicakble to achieve the same result. FloatingFlickable has no such requirement
35 or limitation.
36 */
37class UBUNTUGESTURESQML_EXPORT FloatingFlickable : public QQuickItem {
38 Q_OBJECT
40 Q_PROPERTY(qreal contentWidth READ contentWidth WRITE setContentWidth NOTIFY contentWidthChanged)
41 Q_PROPERTY(qreal contentHeight READ contentHeight WRITE setContentHeight NOTIFY contentHeightChanged)
42 Q_PROPERTY(qreal contentX READ contentX WRITE setContentX NOTIFY contentXChanged)
43 Q_PROPERTY(qreal contentY READ contentY WRITE setContentY NOTIFY contentYChanged)
45 Q_PROPERTY(Direction::Type direction READ direction WRITE setDirection NOTIFY directionChanged)
47Q_SIGNALS:
48 void contentWidthChanged();
49 void contentHeightChanged();
50 void contentXChanged();
51 void contentYChanged();
52 void directionChanged();
54public:
55 FloatingFlickable(QQuickItem *parent = nullptr);
57 qreal contentWidth() const;
58 void setContentWidth(qreal contentWidth);
60 qreal contentHeight() const;
61 void setContentHeight(qreal contentHeight);
63 qreal contentX() const;
64 void setContentX(qreal contentX);
66 qreal contentY() const;
67 void setContentY(qreal contentY);
69 Direction::Type direction() const;
70 void setDirection(Direction::Type);
72private Q_SLOTS:
73 void updateChildrenWidth();
74 void updateChildrenHeight();
75 void onDragAreaTouchPosChanged(qreal);
76 void onDragAreaDraggingChanged(bool value);
78private:
79 DirectionalDragArea *m_dragArea;
80 QQuickFlickable *m_flickable;
81 bool m_mousePressed;
83 friend class tst_FloatingFlickable;
84};
86#endif // FLOATING_FLICKABLE_H