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
918eb1b3
Commit
918eb1b3
authored
Jun 16, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Positions are now expressed in numbers instead of objects.
parent
a7a2067c
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
15 deletions
+21
-15
src/area.py
src/area.py
+11
-8
src/areas.py
src/areas.py
+3
-3
src/driver.py
src/driver.py
+1
-3
src/event.py
src/event.py
+6
-1
No files found.
src/area.py
View file @
918eb1b3
...
@@ -43,25 +43,28 @@ class Area(Positionable, Logger):
...
@@ -43,25 +43,28 @@ class Area(Positionable, Logger):
if
not
self
.
parent
:
if
not
self
.
parent
:
return
self
.
get_position
()
return
self
.
get_position
()
return
self
.
get_position
()
+
self
.
parent
.
get_screen_position
()
ox
,
oy
=
self
.
parent
.
get_screen_position
()
return
ox
+
self
.
x
,
oy
+
self
.
y
def
get_root_position
(
self
):
def
get_root_position
(
self
):
"""
"""
Get the position relative to the root area.
Get the position relative to the root area.
"""
"""
if
not
self
.
parent
:
if
not
self
.
parent
:
return
Positionable
(
0
,
0
)
return
0
,
0
return
self
.
get_position
()
+
self
.
parent
.
get_root_position
()
ox
,
oy
=
self
.
parent
.
get_root_position
()
return
ox
+
self
.
x
,
oy
+
self
.
y
def
get_offset
(
self
,
offset_area
):
def
get_offset
(
self
,
offset_area
):
"""
"""
Get the position relative to an ancestor area.
Get the position relative to an ancestor area.
"""
"""
if
self
.
parent
==
offset_area
:
if
self
==
offset_area
:
return
self
.
get_position
()
return
0
,
0
return
self
.
get_position
()
+
self
.
parent
.
get_offset
(
offset_area
)
ox
,
oy
=
self
.
parent
.
get_offset
(
offset_area
)
return
ox
+
self
.
x
,
oy
+
self
.
y
def
add_area
(
self
,
area
):
def
add_area
(
self
,
area
):
"""
"""
...
@@ -178,11 +181,11 @@ class Area(Positionable, Logger):
...
@@ -178,11 +181,11 @@ class Area(Positionable, Logger):
child_found
=
False
child_found
=
False
if
self
.
children
:
if
self
.
children
:
event
.
set_area
(
self
)
# Delegate to children in reverse order because areas that are
# Delegate to children in reverse order because areas that are
# added later, should be placed over previously added siblings
# added later, should be placed over previously added siblings
for
child
in
reversed
(
self
.
children
):
for
child
in
reversed
(
self
.
children
):
event
.
set_area
(
self
)
if
child
.
contains_event
(
event
):
if
child
.
contains_event
(
event
):
child_found
=
True
child_found
=
True
child
.
delegate_event
(
event
)
child
.
delegate_event
(
event
)
...
...
src/areas.py
View file @
918eb1b3
...
@@ -26,9 +26,9 @@ class RectangularArea(Area):
...
@@ -26,9 +26,9 @@ class RectangularArea(Area):
return
self
.
width
,
self
.
height
return
self
.
width
,
self
.
height
def
contains_event
(
self
,
event
):
def
contains_event
(
self
,
event
):
x
,
y
=
event
.
get_offset
()
ex
,
ey
=
event
.
get_position
()
return
self
.
x
<=
x
<=
self
.
x
+
self
.
width
\
return
self
.
x
<=
e
x
<=
self
.
x
+
self
.
width
\
and
self
.
y
<=
y
<=
self
.
y
+
self
.
height
and
self
.
y
<=
e
y
<=
self
.
y
+
self
.
height
class
CircularArea
(
Area
):
class
CircularArea
(
Area
):
...
...
src/driver.py
View file @
918eb1b3
...
@@ -21,8 +21,6 @@ class EventDriver(Logger):
...
@@ -21,8 +21,6 @@ class EventDriver(Logger):
Delegate an event that has been triggered by the event driver to the
Delegate an event that has been triggered by the event driver to the
area tree.
area tree.
"""
"""
if
self
.
root_area
.
contains_event
(
event
):
event
.
set_area
(
self
.
root_area
)
self
.
root_area
.
delegate_event
(
event
)
self
.
root_area
.
delegate_event
(
event
)
def
start
(
self
):
def
start
(
self
):
...
...
src/event.py
View file @
918eb1b3
from
copy
import
copy
from
geometry
import
Positionable
from
geometry
import
Positionable
from
touch_objects
import
OBJECT_NAMES
from
touch_objects
import
OBJECT_NAMES
...
@@ -40,7 +42,7 @@ class Event(Positionable):
...
@@ -40,7 +42,7 @@ class Event(Positionable):
def
get_offset
(
self
,
area
):
def
get_offset
(
self
,
area
):
ox
,
oy
=
area
.
get_screen_position
()
ox
,
oy
=
area
.
get_screen_position
()
return
Positionable
(
self
.
x
-
ox
,
self
.
y
-
oy
)
return
self
.
x
-
ox
,
self
.
y
-
oy
def
get_type
(
self
):
def
get_type
(
self
):
return
self
.
_type
return
self
.
_type
...
@@ -60,3 +62,6 @@ class Event(Positionable):
...
@@ -60,3 +62,6 @@ class Event(Positionable):
def
is_immediate_propagation_stopped
(
self
):
def
is_immediate_propagation_stopped
(
self
):
return
self
.
stopped_immidiate
return
self
.
stopped_immidiate
def
clone
(
self
):
return
copy
(
self
)
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