summaryrefslogtreecommitdiffstats
path: root/animals
diff options
context:
space:
mode:
authorThomas Zander <t.zander@nokia.com>2010-08-06 14:14:30 +0200
committerThomas Zander <t.zander@nokia.com>2010-08-06 14:14:30 +0200
commit88aa2f41bf9770b49a7d07c821e89b7a33843592 (patch)
tree4ae486d985709b6c13dd65e83a4c96b240bff4a5 /animals
parent0465c312e670f26116d476b3511c50c67cf5798f (diff)
parentb33da2aa1128517b4eaade8e377dea45519a20bd (diff)
Merge branch 'master' of git://gitorious.org/stuff/qml-dashboard
Conflicts: animals/Animal.qml
Diffstat (limited to 'animals')
-rwxr-xr-xanimals/Animal.qml47
-rw-r--r--animals/animals.qml57
-rwxr-xr-xanimals/main.cpp15
-rw-r--r--animals/pangesturerecognizer.cpp8
-rw-r--r--animals/tapgesturerecognizer.cpp14
5 files changed, 115 insertions, 26 deletions
diff --git a/animals/Animal.qml b/animals/Animal.qml
index 28e66e1..9e773f2 100755
--- a/animals/Animal.qml
+++ b/animals/Animal.qml
@@ -73,6 +73,19 @@ Rectangle {
}
}
+/*
+ z:20
+ MouseArea {
+ anchors.fill: parent;
+
+ onClicked: {
+ console.log("mouse clickety click");
+ animalRectangle.toggleSide();
+ }
+ z:20
+ }
+*/
+
GestureArea {
anchors.fill: parent
@@ -103,24 +116,22 @@ Rectangle {
Pan {
onStarted: { console.log("pan started");
}
- onUpdated: { //console.log("pan update");
+ onUpdated: {
+ //console.log("pan update dx:" + gesture.delta.x + " dy: " + gesture.delta.y
+ // + " ox: " + gesture.offset.x);
animalRectangle.scale = 0.8;
//animalRectangle.x += gesture.offset.x;
animalRectangle.opacity = 0.7;
animalRectangle.x += gesture.delta.x;
animalRectangle.y += gesture.delta.y;
}
- onFinished: { console.log("pan finished" + gesture.delta.x + "," + gesture.delta.y
- + " offset " + gesture.offset.x );
-
+ onFinished: { console.log("pan finished");
animalRectangle.scale = 1.0;
animalRectangle.opacity = 1.0;
- //animalRectangle.x += gesture.offset.x;
- //animalRectangle.y += gesture.offset.y;
}
}
-/*
+ /*
Swipe {
when: gesture.state == Qt.GestureStarted
onStarted: { console.log("swipe started");
@@ -128,18 +139,30 @@ Rectangle {
}
Swipe {
when: gesture.state == Qt.GestureFinished
- && gesture.horizontalDirection == QSwipeGesture.Left
- onFinished: { console.log("swipe left");
+ //&& gesture.horizontalDirection == QSwipeGesture.Left
+ onFinished: { console.log("swipe finished");
//animalRectangle.x -= (animalRectangle.width+5);
}
}
+ */
+ /*
+
+ PanSwipe {
+ when: gesture.state == Qt.GestureStarted
+ script: { console.log("I can haz custom gesture!"); }
+ }
+ PanSwipe {
+ when: gesture.state == Qt.GestureFinished
+ script: { console.log("I can haz custom gesture!"); }
+ }
+ */
+ /*
Swipe {
when: gesture.state == Qt.GestureFinished
- && gesture.horizontalDirection == QSwipeGesture.Right
+ //&& gesture.horizontalDirection == QSwipeGesture.Right
onFinished: { console.log("swipe right");
//animalRectangle.x += (animalRectangle.width+5);
}
- }
-*/
+ }*/
}
}
diff --git a/animals/animals.qml b/animals/animals.qml
index 58c68b6..0477cf8 100644
--- a/animals/animals.qml
+++ b/animals/animals.qml
@@ -5,12 +5,63 @@ Rectangle {
width: 520
height: 500
- Flickable {
- //Rectangle {
+/*
+ GestureArea {
+ anchors.fill: parent
+
+ Tap {
+ when: gesture.state == Qt.GestureStarted
+ script: { console.log("tap wallpaper started");
+
+ }
+ }
+
+ Pan {
+ when: gesture.state == Qt.GestureStarted
+ script: { console.log("pan wallpaper started");
+ }
+ }
+ Pan {
+ when: gesture.state == Qt.GestureUpdated
+ script: {
+ //console.log("pan update dx:" + gesture.delta.x + " dy: " + gesture.delta.y
+ // + " ox: " + gesture.offset.x);
+ }
+ }
+ Pan {
+ when: gesture.state == Qt.GestureFinished
+ script: { console.log("pan finished");
+ }
+ }
+ }
+*/
+
+Flickable { contentWidth: parent.width*3; contentHeight: parent.height*3;
id: flickable
width: parent.width
height: parent.height
- contentHeight: parent.height*3
+
+ Text {
+ id: bottomleft;
+ text: "(0," + parent.height + ")";
+ anchors.bottom: parent.bottom;
+ anchors.left: parent.left;
+ z: 2;
+ }
+ Text {
+ id: bottomright;
+ text: "(" + parent.width + "," + parent.height + ")";
+ anchors.bottom: parent.bottom;
+ anchors.right: parent.right;
+ z: 2;
+ }
+ Text {
+ id: topright;
+ text: "(" + parent.width + ",0)";
+ anchors.top: parent.top;
+ anchors.right: parent.right;
+ z: 2;
+ }
Rectangle {
id: contentRect
diff --git a/animals/main.cpp b/animals/main.cpp
index 6469fdb..888cfd3 100755
--- a/animals/main.cpp
+++ b/animals/main.cpp
@@ -14,6 +14,7 @@
#include "tapgesturerecognizer.h"
#include "tapandholdgesturerecognizer.h"
#include "swipegesturerecognizer.h"
+
#endif
int main(int argc, char *argv[])
@@ -24,28 +25,28 @@ int main(int argc, char *argv[])
#if defined(Q_OS_LINUX)
- QGestureRecognizer::unregisterRecognizer(Qt::PanGesture);
- PanGestureRecognizer::registerRecognizer();
+ // Qt Gestures
QGestureRecognizer::unregisterRecognizer(Qt::TapGesture);
TapGestureRecognizer::registerRecognizer();
- QGestureRecognizer::unregisterRecognizer(Qt::TapAndHoldGesture);
- TapAndHoldGestureRecognizer::registerRecognizer();
QGestureRecognizer::unregisterRecognizer(Qt::PinchGesture);
PinchGestureRecognizer::registerRecognizer();
SwipeGestureRecognizer::registerRecognizer();
+
+ QGestureRecognizer::unregisterRecognizer(Qt::TapAndHoldGesture);
+ TapAndHoldGestureRecognizer::registerRecognizer();
+ QGestureRecognizer::unregisterRecognizer(Qt::PanGesture);
+ PanGestureRecognizer::registerRecognizer();
+
#endif
app.setApplicationName("Animals");
app.setOrganizationName("Nokia");
app.setOrganizationDomain("nokia.com");
- //QDeclarativeViewer::registerTypes();
- //QDeclarativeTester::registerTypes();
#ifndef QT_NO_GESTURES
qmlRegisterType<QGesture>("Qt.labs.gestures",1,0, "Gesture");
#endif
-
return app.exec();
}
diff --git a/animals/pangesturerecognizer.cpp b/animals/pangesturerecognizer.cpp
index b2be0a3..2c936bf 100644
--- a/animals/pangesturerecognizer.cpp
+++ b/animals/pangesturerecognizer.cpp
@@ -47,6 +47,7 @@ void PanGestureRecognizer::registerRecognizer()
PanGestureRecognizer::PanGestureRecognizer()
{
+ qDebug() << "creating PanGestureRecognizer (Qt)";
}
QGesture *PanGestureRecognizer::create(QObject *)
@@ -76,6 +77,13 @@ QGestureRecognizer::Result PanGestureRecognizer::recognize(QGesture *state, QObj
QPoint delta = ev->screenPos() - state->property("startPos").toPoint();
q->setLastOffset(q->offset());
q->setOffset(delta);
+
+ if (delta.manhattanLength() < 50) {
+ return QGestureRecognizer::MayBeGesture;
+ }
+
+ //qDebug() << "PanGestureRecognizer::recognize trigger";
+
return QGestureRecognizer::TriggerGesture;
}
return QGestureRecognizer::Ignore;
diff --git a/animals/tapgesturerecognizer.cpp b/animals/tapgesturerecognizer.cpp
index 9b22ee6..f31115b 100644
--- a/animals/tapgesturerecognizer.cpp
+++ b/animals/tapgesturerecognizer.cpp
@@ -47,6 +47,7 @@ void TapGestureRecognizer::registerRecognizer()
TapGestureRecognizer::TapGestureRecognizer()
{
+ qDebug() << "creating TapGestureRecognizer (Qt)";
}
QGesture *TapGestureRecognizer::create(QObject *)
@@ -64,7 +65,10 @@ QGestureRecognizer::Result TapGestureRecognizer::recognize(QGesture *state, QObj
state->setProperty("position", ev->screenPos());
state->setHotSpot(ev->screenPos());
state->setHandled(false);
- event->accept();
+ //event->accept();
+ qDebug() << "TapGestureRecognizer::recognize: trigger gesture" << watched;
+
+
return QGestureRecognizer::TriggerGesture | QGestureRecognizer::ConsumeEventHint;
} else
return QGestureRecognizer::Ignore;
@@ -80,14 +84,16 @@ QGestureRecognizer::Result TapGestureRecognizer::recognize(QGesture *state, QObj
return QGestureRecognizer::FinishGesture;
}
return QGestureRecognizer::Ignore;
+
case QEvent::Gesture: {
QGestureEvent *ge = static_cast<QGestureEvent *>(event);
QGesture *tap = ge->gesture(Qt::TapGesture);
QGesture *pan = ge->gesture(Qt::PanGesture);
- qDebug() << "got a gesture" << tap << (tap ? tap->state() : 0)
- << ", " << pan << (pan ? pan->state() : 0);
+ //qDebug() << "TapGestureRecognizer::recognize got a gesture" << tap << (tap ? tap->state() : 0)
+ // << ", " << pan << (pan ? pan->state() : 0);
if (ge->gesture(Qt::PanGesture)) {
- return QGestureRecognizer::CancelGesture;
+ //return QGestureRecognizer::CancelGesture;
+ return QGestureRecognizer::Ignore;
}
if (ge->gesture(Qt::TapAndHoldGesture))
return QGestureRecognizer::CancelGesture;