blob: 331726c689d44b685202bc9af07b1b8e82b4dae0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#ifndef CURSORNAVIGATION_H
#define CURSORNAVIGATION_H
#include "cursornavigationattached.h"
#include "inputtypes.h"
#include "inputadapter.h"
#include "spatialnavigation360.h"
#include "spatialnavigation4dir.h"
#include <QObject>
#include <qqml.h>
#include <QStack>
//TODO remove useless debug prints and change over to categorized logging
class QQuickItem;
class CursorNavigation : public QObject
{
Q_OBJECT
public:
CursorNavigation(QQuickWindow *parent);
//pass input events forward to the current item
//void setMagnitude(qreal angle, qreal magnitude);
//void setMagnitude(const QVector2D& vector);
//move the cursor
bool move(qreal angle, qreal tolerance, bool discrete);
//find the next item without moving the cursor
QQuickItem *find(qreal angle, qreal tolerance, bool discrete);
bool action(Action action);
static CursorNavigationAttached *qmlAttachedProperties(QObject *object);
static CursorNavigation *cursorNavigationForWindow(QQuickWindow *window);
static CursorNavigationAttached *cursorNavigationAttachment(QQuickItem *item);
private:
void setCursorOnItem(CursorNavigationAttached *item);
void onActiveFocusItemChanged();
void registerItem(CursorNavigationAttached* item);
void unregisterItem(CursorNavigationAttached* item);
CursorNavigationAttached *defaultItem();
private:
static const char windowPropertyName[];
QQuickWindow *m_window;
InputAdapter m_inputAdapter;
CursorNavigationAttached *m_currentItem; //item that currently has the cursor
SpatialNavigation360 m_navigation360;
SpatialNavigation4Dir m_navigation4Dir;
//a root item that is not tied to any actual QQuickItem
CursorNavigationAttached *m_rootItem;
friend class CursorNavigationAttached;
friend class InputAdapter;
};
QML_DECLARE_TYPEINFO(CursorNavigation, QML_HAS_ATTACHED_PROPERTIES)
#endif // CURSORNAVIGATION_H
|