On Sat, Feb 7, 2009 at 10:57 AM, Red15 <[email protected]> wrote:
>
>
>
> On Feb 6, 11:21 pm, Alex Holkner <[email protected]> wrote:
>> On Sat, Feb 7, 2009 at 8:04 AM, Red15 <[email protected]> wrote:
>>
>> > Well not really, suppose this :
>>
>> > I have subclassed pyglet.window.Window and am acting on my on_draw
>> > event.
>>
>> > Inside the window.on_draw I put a window.clear(), since this is the
>> > first handler it will be called last so in effect clearing everything
>> > I have just drawn...
>> > Right now i solve it by making the window.on_draw dispatch another
>> > event right after clearing the window and I called it "draw" instead
>> > of "on_draw".
>>
>> > I guess there are other better ways to solve, if so I would like to
>> > hear them, but to me a (relatively) simple solution would be to allow
>> > inserting push_handlers at a certain index position maybe ?
>>
>> It's a fair point that on_draw isn't useful with stacking -- it should
>> have been a special case that calls in reverse order.  It may be
>> changed, in some future unplanned backward-incompatible version.  In
>> the meantime, you can't really use the event stack for your drawing --
>> I typically maintain a separate stack of draw handlers in the
>> application and call them myself.
>>
>> Alex.
>
> Can you give a short style example of what you mean by a separate
> stack of draw handlers and how you maintain them ?

window.draw_handlers = []

Then, each time you window.push_handlers, also:

window.push_handlers(responder)
window.draw_handlers.append(responder.draw)

(Similarly for pop_handlers).  In Window.on_draw:

for func in self.draw_handlers:
    func()

>
> And what would be the downside of my custom draw event (besides a dose
> of possible confusion) ?

Because events are called top-down, and draw calls need to be made
bottom up -- this can only be solved by changing the event mechanism.

> Are events a lot more intensive then calling functions one by one from
> a list ?

I doubt it, that's pretty much what events do anyway.

Alex.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/pyglet-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to