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
0c55af10
Commit
0c55af10
authored
Jun 20, 2012
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Separated GTK+ event window into a separate layer.
parent
3f6257fe
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
13 deletions
+60
-13
src/area.py
src/area.py
+22
-0
src/areas.py
src/areas.py
+2
-0
tests/testapp.py
tests/testapp.py
+9
-11
tests/utils.py
tests/utils.py
+27
-2
No files found.
src/area.py
View file @
0c55af10
...
@@ -29,6 +29,8 @@ class Area(Positionable, Logger):
...
@@ -29,6 +29,8 @@ class Area(Positionable, Logger):
self
.
delegate_queue
=
{}
self
.
delegate_queue
=
{}
self
.
update_handlers
=
[]
def
get_root_area
(
self
):
def
get_root_area
(
self
):
"""
"""
Traverse up in the area tree to find the root area.
Traverse up in the area tree to find the root area.
...
@@ -230,3 +232,23 @@ class Area(Positionable, Logger):
...
@@ -230,3 +232,23 @@ class Area(Positionable, Logger):
"""
"""
for
handler
in
self
.
handlers
.
get
(
gesture
.
get_type
(),
()):
for
handler
in
self
.
handlers
.
get
(
gesture
.
get_type
(),
()):
handler
(
gesture
)
handler
(
gesture
)
def
on_update
(
self
,
handler
):
self
.
update_handlers
.
append
(
handler
)
def
update
(
self
):
"""
Call update handlers of this area and all children, so that the
underlying subtree knows about changes in geometry and can redraw.
"""
for
handler
in
self
.
update_handlers
:
if
handler
():
return
True
for
child
in
self
.
children
:
if
child
.
update
():
return
True
def
set_position
(
self
,
x
,
y
):
Positionable
.
set_position
(
self
,
x
,
y
)
self
.
update
()
src/areas.py
View file @
0c55af10
...
@@ -21,6 +21,7 @@ class RectangularArea(Area):
...
@@ -21,6 +21,7 @@ class RectangularArea(Area):
def
set_size
(
self
,
width
,
height
):
def
set_size
(
self
,
width
,
height
):
self
.
width
=
width
self
.
width
=
width
self
.
height
=
height
self
.
height
=
height
self
.
update
()
def
get_size
(
self
):
def
get_size
(
self
):
return
self
.
width
,
self
.
height
return
self
.
width
,
self
.
height
...
@@ -48,6 +49,7 @@ class CircularArea(Area):
...
@@ -48,6 +49,7 @@ class CircularArea(Area):
def
set_radius
(
self
,
radius
):
def
set_radius
(
self
,
radius
):
self
.
radius
=
radius
self
.
radius
=
radius
self
.
update
()
def
get_radius
(
self
):
def
get_radius
(
self
):
return
self
.
radius
return
self
.
radius
...
...
tests/testapp.py
View file @
0c55af10
...
@@ -5,7 +5,7 @@ from threading import Thread
...
@@ -5,7 +5,7 @@ from threading import Thread
from
math
import
pi
,
tan
from
math
import
pi
,
tan
import
src
as
mt
import
src
as
mt
from
utils
import
BoundingBoxArea
,
Flick
,
FlickThread
from
utils
import
BoundingBoxArea
,
Flick
,
FlickThread
,
GtkEventWindow
RED
=
1
,
0
,
0
RED
=
1
,
0
,
0
...
@@ -120,11 +120,9 @@ def create_context_window(w, h, callback):
...
@@ -120,11 +120,9 @@ def create_context_window(w, h, callback):
cr
=
area
.
window
.
cairo_create
()
cr
=
area
.
window
.
cairo_create
()
draw
()
draw
()
def
move_window
(
win
,
event
):
def
update_window
():
"""Synchronize root multi-touch area with GTK window."""
"""Synchronize overlay with GTK window."""
root
.
set_position
(
*
event
.
get_coords
())
overlay
.
set_size
(
*
window
.
get_size
())
root
.
set_size
(
event
.
width
,
event
.
height
)
overlay
.
set_size
(
event
.
width
,
event
.
height
)
refresh
()
refresh
()
def
handle_key
(
win
,
event
):
def
handle_key
(
win
,
event
):
...
@@ -151,18 +149,18 @@ def create_context_window(w, h, callback):
...
@@ -151,18 +149,18 @@ def create_context_window(w, h, callback):
quit
()
quit
()
# Root area (will be synchronized with GTK window)
# Root area (will be synchronized with GTK window)
global
root
,
overlay
global
overlay
root
=
mt
.
RectangularArea
(
0
,
0
,
w
,
h
)
overlay
=
mt
.
RectangularArea
(
0
,
0
,
w
,
h
)
overlay
=
mt
.
RectangularArea
(
0
,
0
,
w
,
h
)
# GTK window
# GTK window
global
window
global
window
,
root
window
=
gtk
.
Window
()
window
=
GtkEvent
Window
()
window
.
set_title
(
'Cairo test'
)
window
.
set_title
(
'Cairo test'
)
window
.
connect
(
'destroy'
,
quit
)
window
.
connect
(
'destroy'
,
quit
)
window
.
connect
(
'key-press-event'
,
handle_key
)
window
.
connect
(
'key-press-event'
,
handle_key
)
window
.
connect
(
'configure-event'
,
move_window
)
window
.
connect
(
'show'
,
callback
)
window
.
connect
(
'show'
,
callback
)
window
.
on_update
(
update_window
)
root
=
window
.
get_area
()
if
fullscreen
:
if
fullscreen
:
window
.
fullscreen
()
window
.
fullscreen
()
...
...
tests/utils.py
View file @
0c55af10
...
@@ -2,6 +2,7 @@ from __future__ import division
...
@@ -2,6 +2,7 @@ from __future__ import division
from
time
import
sleep
from
time
import
sleep
from
threading
import
Thread
from
threading
import
Thread
from
numpy
import
array
,
diag
,
dot
,
cos
,
sin
,
asarray
,
column_stack
,
c_
from
numpy
import
array
,
diag
,
dot
,
cos
,
sin
,
asarray
,
column_stack
,
c_
from
gtk
import
Window
from
src
import
RectangularArea
from
src
import
RectangularArea
...
@@ -36,11 +37,16 @@ class BoundingBoxArea(RectangularArea):
...
@@ -36,11 +37,16 @@ class BoundingBoxArea(RectangularArea):
def
update_bounds
(
self
):
def
update_bounds
(
self
):
min_x
,
min_y
=
self
.
points
.
min
(
1
)
min_x
,
min_y
=
self
.
points
.
min
(
1
)
max_x
,
max_y
=
self
.
points
.
max
(
1
)
max_x
,
max_y
=
self
.
points
.
max
(
1
)
self
.
set_size
(
max_x
-
min_x
,
max_y
-
min_y
)
width
=
max_x
-
min_x
height
=
max_y
-
min_y
if
min_x
or
min_y
:
if
min_x
or
min_y
:
self
.
translate
(
min_x
,
min_y
)
self
.
width
=
width
self
.
height
=
height
self
.
translate_points
(
-
min_x
,
-
min_y
)
self
.
translate_points
(
-
min_x
,
-
min_y
)
self
.
translate
(
min_x
,
min_y
)
elif
width
!=
self
.
width
or
height
!=
self
.
height
:
self
.
set_size
(
width
,
height
)
FLICK_UPDATE_RATE
=
30
FLICK_UPDATE_RATE
=
30
...
@@ -114,3 +120,22 @@ def inside_shape(p, verts):
...
@@ -114,3 +120,22 @@ def inside_shape(p, verts):
inside
=
not
inside
inside
=
not
inside
return
inside
return
inside
class
GtkEventWindow
(
Window
):
def
__init__
(
self
,
width
=
0
,
height
=
0
):
Window
.
__init__
(
self
)
self
.
area
=
RectangularArea
(
0
,
0
,
width
,
height
)
self
.
connect
(
'configure-event'
,
self
.
sync_area
)
def
get_area
(
self
):
return
self
.
area
def
on_update
(
self
,
handler
):
self
.
area
.
on_update
(
handler
)
def
sync_area
(
self
,
win
,
event
):
"""Synchronize root multi-touch area with GTK window."""
self
.
area
.
width
=
event
.
width
self
.
area
.
height
=
event
.
height
self
.
area
.
set_position
(
*
event
.
get_coords
())
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