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
918eb1b3
Commit
918eb1b3
authored
12 years ago
by
Taddeus Kroes
Browse files
Options
Downloads
Patches
Plain Diff
Positions are now expressed in numbers instead of objects.
parent
a7a2067c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/area.py
+11
-8
11 additions, 8 deletions
src/area.py
src/areas.py
+3
-3
3 additions, 3 deletions
src/areas.py
src/driver.py
+1
-3
1 addition, 3 deletions
src/driver.py
src/event.py
+6
-1
6 additions, 1 deletion
src/event.py
with
21 additions
and
15 deletions
src/area.py
+
11
−
8
View file @
918eb1b3
...
...
@@ -43,25 +43,28 @@ class Area(Positionable, Logger):
if
not
self
.
parent
:
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
):
"""
Get the position relative to the root area.
"""
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
):
"""
Get the position relative to an ancestor area.
"""
if
self
.
parent
==
offset_area
:
return
self
.
get_position
()
if
self
==
offset_area
:
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
):
"""
...
...
@@ -178,11 +181,11 @@ class Area(Positionable, Logger):
child_found
=
False
if
self
.
children
:
event
.
set_area
(
self
)
# Delegate to children in reverse order because areas that are
# added later, should be placed over previously added siblings
for
child
in
reversed
(
self
.
children
):
event
.
set_area
(
self
)
if
child
.
contains_event
(
event
):
child_found
=
True
child
.
delegate_event
(
event
)
...
...
This diff is collapsed.
Click to expand it.
src/areas.py
+
3
−
3
View file @
918eb1b3
...
...
@@ -26,9 +26,9 @@ class RectangularArea(Area):
return
self
.
width
,
self
.
height
def
contains_event
(
self
,
event
):
x
,
y
=
event
.
get_
offset
()
return
self
.
x
<=
x
<=
self
.
x
+
self
.
width
\
and
self
.
y
<=
y
<=
self
.
y
+
self
.
height
e
x
,
e
y
=
event
.
get_
position
()
return
self
.
x
<=
e
x
<=
self
.
x
+
self
.
width
\
and
self
.
y
<=
e
y
<=
self
.
y
+
self
.
height
class
CircularArea
(
Area
):
...
...
This diff is collapsed.
Click to expand it.
src/driver.py
+
1
−
3
View file @
918eb1b3
...
...
@@ -21,9 +21,7 @@ class EventDriver(Logger):
Delegate an event that has been triggered by the event driver to the
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
):
"""
...
...
This diff is collapsed.
Click to expand it.
src/event.py
+
6
−
1
View file @
918eb1b3
from
copy
import
copy
from
geometry
import
Positionable
from
touch_objects
import
OBJECT_NAMES
...
...
@@ -40,7 +42,7 @@ class Event(Positionable):
def
get_offset
(
self
,
area
):
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
):
return
self
.
_type
...
...
@@ -60,3 +62,6 @@ class Event(Positionable):
def
is_immediate_propagation_stopped
(
self
):
return
self
.
stopped_immidiate
def
clone
(
self
):
return
copy
(
self
)
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