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
7433abd3
Commit
7433abd3
authored
Jun 08, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved propagation from gesture to event.
parent
fa4f154f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
23 deletions
+52
-23
src/event.py
src/event.py
+12
-5
src/event_server.py
src/event_server.py
+1
-1
src/tracker.py
src/tracker.py
+0
-7
src/widget.py
src/widget.py
+39
-10
No files found.
src/event.py
View file @
7433abd3
...
...
@@ -13,7 +13,7 @@ class Event(object):
def
__init__
(
self
,
touch_object
):
self
.
touch_object
=
touch_object
self
.
stop
=
False
self
.
stop
ped
=
self
.
stopped_immidiate
=
False
def
__getattr__
(
self
,
name
):
if
name
in
OBJECT_NAMES
\
...
...
@@ -32,8 +32,15 @@ class Event(object):
def
get_position
(
self
):
return
self
.
touch_object
.
get_position
()
def
stop_
dele
gation
(
self
):
self
.
stop
=
True
def
stop_
propa
gation
(
self
):
self
.
stop
ped
=
True
def
is_delegation_stopped
(
self
):
return
self
.
stop
def
is_propagation_stopped
(
self
):
return
self
.
stopped
def
stop_immidiate_propagation
(
self
):
self
.
stop_propagation
()
self
.
stopped_immidiate
=
True
def
is_immediate_propagation_stopped
(
self
):
return
self
.
stopped_immidiate
src/event_server.py
View file @
7433abd3
...
...
@@ -25,7 +25,7 @@ class EventServer(Logger):
Delegate an event that has been triggered by the event driver to the
widget tree.
"""
self
.
root_widget
.
handl
e_event
(
event
)
self
.
root_widget
.
delegat
e_event
(
event
)
def
start
(
self
):
"""
...
...
src/tracker.py
View file @
7433abd3
...
...
@@ -50,7 +50,6 @@ class Gesture(object):
_type
=
NotImplemented
def
__init__
(
self
,
originating_event
=
None
):
self
.
stop
=
False
self
.
tracker
=
None
self
.
originating_event
=
originating_event
...
...
@@ -68,9 +67,3 @@ class Gesture(object):
def
set_tracker
(
self
,
tracker
):
self
.
tracker
=
tracker
def
stop_propagation
(
self
):
self
.
stop
=
True
def
is_propagation_stopped
(
self
):
return
self
.
stop
src/widget.py
View file @
7433abd3
...
...
@@ -22,6 +22,24 @@ class Widget(Positionable, Logger):
self
.
parent
=
None
self
.
children
=
[]
def
get_offset
(
self
,
offset_parent
=
None
):
"""
Get the offset position relative to an offset parent. If no offset
parent is specified, the parent widget is used. If no parent widget is
assigned, return absolute coordinates.
"""
x
,
y
=
self
.
get_position
()
if
not
offset_parent
:
if
not
self
.
parent
:
return
x
,
y
offset_parent
=
self
.
parent
ox
,
oy
=
offset_parent
.
get_position
()
return
x
-
ox
,
y
-
oy
def
add_widget
(
self
,
widget
):
"""
Add a new child widget.
...
...
@@ -114,19 +132,30 @@ class Widget(Positionable, Logger):
"""
raise
NotImplementedError
def
handl
e_event
(
self
,
event
):
def
delegat
e_event
(
self
,
event
):
"""
Delegate a triggered event to gesture trackers and child widgets. A
handler can stop the delegation of the event, preventing it from being
delegated to child widgets.
Delegate a triggered event to child widgets. If a child stops
propagation
"""
if
not
self
.
children
:
self
.
propagate_event
(
event
)
else
:
for
child
in
self
.
children
:
if
child
.
contains_event
(
event
):
child
.
delegate_event
(
event
)
if
event
.
is_propagation_stopped
():
break
def
propagate_event
(
self
,
event
):
for
tracker
in
set
(
self
.
trackers
.
itervalues
()):
tracker
.
handle_event
(
event
)
if
not
event
.
is_delegation_stopped
():
for
child
in
self
.
children
:
if
child
.
contains_event
(
event
):
child
.
handle_event
(
event
)
if
event
.
is_immediate_propagation_stopped
():
break
if
self
.
parent
and
not
event
.
is_propagation_stopped
():
self
.
parent
.
propagate_event
(
event
)
def
handle_gesture
(
self
,
gesture
):
"""
...
...
@@ -138,5 +167,5 @@ class Widget(Positionable, Logger):
for
handler
in
self
.
handlers
.
get
(
gesture
.
get_type
(),
()):
handler
(
gesture
)
if
self
.
parent
and
not
gesture
.
is_propagation_stopped
():
self
.
parent
.
handle_gesture
(
gesture
)
#
if self.parent and not gesture.is_propagation_stopped():
#
self.parent.handle_gesture(gesture)
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