Skip to content

Commit

Permalink
Fix on_attach event handling
Browse files Browse the repository at this point in the history
  • Loading branch information
rougier committed Jan 4, 2015
1 parent 66506f9 commit de7d52d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
8 changes: 4 additions & 4 deletions examples/transform-linear-scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ def on_draw(dt):
window.clear()
points.draw()

@window.event
def on_mouse_scroll(x,y,dx,dy):
if dy < 0: transform["ydomain"] = 1.1*transform["ydomain"]
else: transform["ydomain"] = transform["ydomain"]/1.1
#@window.event
#def on_mouse_scroll(x,y,dx,dy):
# if dy < 0: transform["ydomain"] = 1.1*transform["ydomain"]
# else: transform["ydomain"] = transform["ydomain"]/1.1

transform = Position3D(LinearScale()) + Viewport()
points = PointCollection("agg", transform = transform)
Expand Down
17 changes: 8 additions & 9 deletions glumpy/transforms/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,16 @@ def __init__(self, code, *args, **kwargs):
def attach(self, program):
""" Attach the transform to a program """

Snippet.attach(self,program)
self.dispatch_event("on_attach", program)
if program not in self._programs:
self._programs.append(program)
program._build_uniforms()
program._build_attributes()

for snippet in self.snippets[1:]:
snippet.attach(program)

self.dispatch_event("on_attach", program)

def on_attach(self, program):
for snippet in list(self._args):
if isinstance(snippet, Snippet):
snippet.dispatch_event("on_attach", program)
if self._next:
operator, snippet = self._next
snippet.dispatch_event("on_attach", program)

def on_resize(self, width, height):
for snippet in list(self._args):
Expand Down

0 comments on commit de7d52d

Please sign in to comment.