Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
multitouch
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Taddeüs Kroes
multitouch
Commits
010cb2bc
Commit
010cb2bc
authored
12 years ago
by
Taddeüs Kroes
Browse files
Options
Downloads
Patches
Plain Diff
Hand tracker events are now handled by a fullscreen overlay so that touch points are never 'lost'.
parent
29dd92a4
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/areas.py
+3
-0
3 additions, 0 deletions
src/areas.py
src/trackers/transform.py
+13
-3
13 additions, 3 deletions
src/trackers/transform.py
tests/testapp.py
+11
-11
11 additions, 11 deletions
tests/testapp.py
with
27 additions
and
14 deletions
src/areas.py
+
3
−
0
View file @
010cb2bc
...
@@ -69,5 +69,8 @@ class FullscreenArea(RectangularArea):
...
@@ -69,5 +69,8 @@ class FullscreenArea(RectangularArea):
def
__str__
(
self
):
def
__str__
(
self
):
return
'
<FullscreenArea size=(%d, %d)>
'
%
self
.
get_size
()
return
'
<FullscreenArea size=(%d, %d)>
'
%
self
.
get_size
()
def
contains
(
self
,
x
,
y
):
return
True
def
contains_event
(
self
,
event
):
def
contains_event
(
self
,
event
):
return
True
return
True
This diff is collapsed.
Click to expand it.
src/trackers/transform.py
+
13
−
3
View file @
010cb2bc
...
@@ -94,6 +94,8 @@ class TransformationTracker(GestureTracker):
...
@@ -94,6 +94,8 @@ class TransformationTracker(GestureTracker):
supported_gestures
=
[
RotationGesture
,
PinchGesture
,
DragGesture
,
supported_gestures
=
[
RotationGesture
,
PinchGesture
,
DragGesture
,
FlickGesture
]
FlickGesture
]
configurable
=
[
'
propagate_events
'
]
def
__init__
(
self
,
area
):
def
__init__
(
self
,
area
):
super
(
TransformationTracker
,
self
).
__init__
(
area
)
super
(
TransformationTracker
,
self
).
__init__
(
area
)
...
@@ -105,6 +107,8 @@ class TransformationTracker(GestureTracker):
...
@@ -105,6 +107,8 @@ class TransformationTracker(GestureTracker):
self
.
deleted
=
[]
self
.
deleted
=
[]
self
.
propagate_events
=
False
def
update_centroid
(
self
):
def
update_centroid
(
self
):
if
not
self
.
points
:
if
not
self
.
points
:
self
.
centroid
=
None
self
.
centroid
=
None
...
@@ -126,7 +130,9 @@ class TransformationTracker(GestureTracker):
...
@@ -126,7 +130,9 @@ class TransformationTracker(GestureTracker):
def
on_point_down
(
self
,
event
):
def
on_point_down
(
self
,
event
):
self
.
points
.
append
(
event
.
point
)
self
.
points
.
append
(
event
.
point
)
self
.
update_centroid
()
self
.
update_centroid
()
event
.
stop_propagation
()
if
not
self
.
propagate_events
:
event
.
stop_propagation
()
def
on_point_move
(
self
,
event
):
def
on_point_move
(
self
,
event
):
point
=
event
.
point
point
=
event
.
point
...
@@ -142,7 +148,9 @@ class TransformationTracker(GestureTracker):
...
@@ -142,7 +148,9 @@ class TransformationTracker(GestureTracker):
self
.
points
.
append
(
point
)
self
.
points
.
append
(
point
)
self
.
update_centroid
()
self
.
update_centroid
()
event
.
stop_propagation
()
if
not
self
.
propagate_events
:
event
.
stop_propagation
()
self
.
invalidate_points
()
self
.
invalidate_points
()
l
=
len
(
self
.
points
)
l
=
len
(
self
.
points
)
...
@@ -175,7 +183,9 @@ class TransformationTracker(GestureTracker):
...
@@ -175,7 +183,9 @@ class TransformationTracker(GestureTracker):
self
.
trigger
(
FlickGesture
(
event
,
self
.
centroid
,
self
.
trigger
(
FlickGesture
(
event
,
self
.
centroid
,
self
.
centroid
.
translation
()))
self
.
centroid
.
translation
()))
self
.
update_centroid
()
self
.
update_centroid
()
event
.
stop_propagation
()
if
not
self
.
propagate_events
:
event
.
stop_propagation
()
def
invalidate_points
(
self
):
def
invalidate_points
(
self
):
...
...
This diff is collapsed.
Click to expand it.
tests/testapp.py
+
11
−
11
View file @
010cb2bc
...
@@ -122,12 +122,6 @@ def create_context_window(w, h, callback):
...
@@ -122,12 +122,6 @@ def create_context_window(w, h, callback):
cr
=
area
.
window
.
cairo_create
()
cr
=
area
.
window
.
cairo_create
()
draw
()
draw
()
def
update_window
():
"""
Synchronize overlay with GTK window.
"""
overlay
.
set_size
(
*
window
.
get_size
())
refresh
()
return
True
def
handle_key
(
win
,
event
):
def
handle_key
(
win
,
event
):
"""
Handle key event.
'
f
'
toggles fullscreen,
'
b
'
toggles bounding
"""
Handle key event.
'
f
'
toggles fullscreen,
'
b
'
toggles bounding
boxes,
'
i
'
toggles input points,
'
q
'
exits the program.
"""
boxes,
'
i
'
toggles input points,
'
q
'
exits the program.
"""
...
@@ -151,9 +145,9 @@ def create_context_window(w, h, callback):
...
@@ -151,9 +145,9 @@ def create_context_window(w, h, callback):
elif
key
==
'
q
'
:
elif
key
==
'
q
'
:
quit
()
quit
()
# Root area (will be synchronized with GTK
window
)
def
update_
window
():
global
overlay
refresh
()
overlay
=
mt
.
RectangularArea
(
0
,
0
,
w
,
h
)
return
True
# GTK window
# GTK window
global
window
,
root
global
window
,
root
...
@@ -284,10 +278,16 @@ def on_show(window):
...
@@ -284,10 +278,16 @@ def on_show(window):
if
draw_touch_objects
:
if
draw_touch_objects
:
refresh
()
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_down
(
handle_down
)
overlay
.
on_finger_move
(
lambda
g
:
draw_touch_objects
and
refresh
())
overlay
.
on_finger_move
(
lambda
g
:
draw_touch_objects
and
refresh
())
overlay
.
on_finger_up
(
handle_up
)
overlay
.
on_finger_up
(
handle_up
)
root
.
add_area
(
overlay
)
# Root area rotation leads to rotation of all polygons around the centroid
# Root area rotation leads to rotation of all polygons around the centroid
def
move_to_polygons
(
g
):
def
move_to_polygons
(
g
):
...
@@ -331,7 +331,7 @@ if __name__ == '__main__':
...
@@ -331,7 +331,7 @@ if __name__ == '__main__':
create_context_window
(
800
,
600
,
on_show
)
create_context_window
(
800
,
600
,
on_show
)
# Run multi-touch gesture server in separate thread
# 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
=
Thread
(
target
=
driver
.
start
)
mt_thread
.
daemon
=
True
mt_thread
.
daemon
=
True
mt_thread
.
start
()
mt_thread
.
start
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment