[ardour-dev] Ahhhh-dour....mmmmm

Paul Davis paul at linuxaudiosystems.com
Wed Oct 27 13:00:48 PDT 2004

>When the user clicks anywhere in the canvas, I assume it delivers an
>event (or callback or whatever) that contains the x,y coordinates
>of the click (probably relative to the canvas origin). You need that

it does. but the event is associated with a given object - the object
is determined by the canvas itself. the event coordinates are relative
to the object, though they can be transformed to the global canvas or
the root window or whatever you want.

you would have to intercept every event on the canvas and check if you
wanted to consider it to be associated with a different object. thats
a really ugly hack, if you ask me. you're really saying "i know i set
"close" to be N pixels, but if its within N+M pixels of objects of
type foo or bar, then the event is really for that object, not the one
chosen using the "close" setting". ugh.

ardour has what i call a vertical breakdown for handling canvas
events: all events go to the Editor object, but they first pass
through a layer that adds ardour's own item type to the information
about the event. the editor then does a huge, ugly, complex switch
statement that factors the item type, the event type and the current
state of the editor, and comes with a decision about what to do.

there have been discussions about the pros and cons of using a
horizontal breakdown, where each kind of item handles its own events,
using the state of the editor. there are pros and there are cons -
this change has not been made, and might never be. it would make the
kind of event analysis you are describing rather difficult.

>This sort of thing is trivial when you use X directly. If it gets
>more difficult with a toolset, then I wonder what the toolset's use is.

well, for the canvas alone:

* z-order stacking
* alpha blending/transparency
* object picking
* a simple abstraction that makes writing new canvas items fairly trivial
* multiple coordinate system management
* existing very useful canvas items


More information about the Ardour-Dev mailing list