Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
multitouch
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
multitouch
Commits
010cb2bc
Commit
010cb2bc
authored
Jun 20, 2012
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hand tracker events are now handled by a fullscreen overlay so that touch points are never 'lost'.
parent
29dd92a4
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
14 deletions
+27
-14
src/areas.py
src/areas.py
+3
-0
src/trackers/transform.py
src/trackers/transform.py
+13
-3
tests/testapp.py
tests/testapp.py
+11
-11
No files found.
src/areas.py
View file @
010cb2bc
...
...
@@ -69,5 +69,8 @@ class FullscreenArea(RectangularArea):
def
__str__
(
self
):
return
'<FullscreenArea size=(%d, %d)>'
%
self
.
get_size
()
def
contains
(
self
,
x
,
y
):
return
True
def
contains_event
(
self
,
event
):
return
True
src/trackers/transform.py
View file @
010cb2bc
...
...
@@ -94,6 +94,8 @@ class TransformationTracker(GestureTracker):
supported_gestures
=
[
RotationGesture
,
PinchGesture
,
DragGesture
,
FlickGesture
]
configurable
=
[
'propagate_events'
]
def
__init__
(
self
,
area
):
super
(
TransformationTracker
,
self
).
__init__
(
area
)
...
...
@@ -105,6 +107,8 @@ class TransformationTracker(GestureTracker):
self
.
deleted
=
[]
self
.
propagate_events
=
False
def
update_centroid
(
self
):
if
not
self
.
points
:
self
.
centroid
=
None
...
...
@@ -126,6 +130,8 @@ class TransformationTracker(GestureTracker):
def
on_point_down
(
self
,
event
):
self
.
points
.
append
(
event
.
point
)
self
.
update_centroid
()
if
not
self
.
propagate_events
:
event
.
stop_propagation
()
def
on_point_move
(
self
,
event
):
...
...
@@ -142,7 +148,9 @@ class TransformationTracker(GestureTracker):
self
.
points
.
append
(
point
)
self
.
update_centroid
()
if
not
self
.
propagate_events
:
event
.
stop_propagation
()
self
.
invalidate_points
()
l
=
len
(
self
.
points
)
...
...
@@ -175,6 +183,8 @@ class TransformationTracker(GestureTracker):
self
.
trigger
(
FlickGesture
(
event
,
self
.
centroid
,
self
.
centroid
.
translation
()))
self
.
update_centroid
()
if
not
self
.
propagate_events
:
event
.
stop_propagation
()
...
...
tests/testapp.py
View file @
010cb2bc
...
...
@@ -122,12 +122,6 @@ def create_context_window(w, h, callback):
cr
=
area
.
window
.
cairo_create
()
draw
()
def
update_window
():
"""Synchronize overlay with GTK window."""
overlay
.
set_size
(
*
window
.
get_size
())
refresh
()
return
True
def
handle_key
(
win
,
event
):
"""Handle key event. 'f' toggles fullscreen, 'b' toggles bounding
boxes, 'i' toggles input points, 'q' exits the program."""
...
...
@@ -151,9 +145,9 @@ def create_context_window(w, h, callback):
elif
key
==
'q'
:
quit
()
# Root area (will be synchronized with GTK window)
global
overlay
overlay
=
mt
.
RectangularArea
(
0
,
0
,
w
,
h
)
def
update_window
():
refresh
()
return
True
# GTK window
global
window
,
root
...
...
@@ -284,10 +278,16 @@ def on_show(window):
if
draw_touch_objects
:
refresh
()
global
screen
,
overlay
screen
=
mt
.
FullscreenArea
()
overlay
=
mt
.
FullscreenArea
()
screen
.
add_area
(
root
)
screen
.
add_area
(
overlay
)
overlay
.
on_finger_down
(
handle_down
)
overlay
.
on_finger_move
(
lambda
g
:
draw_touch_objects
and
refresh
())
overlay
.
on_finger_up
(
handle_up
)
root
.
add_area
(
overlay
)
# Root area rotation leads to rotation of all polygons around the centroid
def
move_to_polygons
(
g
):
...
...
@@ -331,7 +331,7 @@ if __name__ == '__main__':
create_context_window
(
800
,
600
,
on_show
)
# Run multi-touch gesture server in separate thread
driver
=
mt
.
create_driver
(
root
)
driver
=
mt
.
create_driver
(
screen
)
mt_thread
=
Thread
(
target
=
driver
.
start
)
mt_thread
.
daemon
=
True
mt_thread
.
start
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment