[Drawkit] "sticking" objects to a drawable shape

James Maxwell jbmaxwell at rubato-music.com
Tue Aug 31 07:12:34 PDT 2010


HI Graham,
> 
> I don't have enough time to go into it in sufficient detail, but I think a good study of DKShapeGroup will be helpful, as it is a fully-fledged container that is in many ways similar to what you're trying to do.

Okay, will do.
> 
> The fact that your notes are getting drawn is suspicious, because unless you draw them, they shouldn't be. That suggests that perhaps they are still being added to the layer.

Quite right. I haven't gone so far as to actually rewrite the tool, but I think I'll have to. I forgot that the normal tool creates, and **adds**, a temporary "pending" object, which it then commits to the drawing if it's valid. I think it must be the pending object that's being drawn.

> Your stave will need to draw the notes and also handle the selected notes, if you have such a concept.
> 
> The container protocol is just about ownership, as you thought. It doesn't give you any actual functionality, being a protocol (a class would, and there is such a class - DKDrawableObject. Your stave would inherit from this (or an existing subclass) in order to get messages such as drawing its content and so on.)

Ah, this makes more sense to me now. I didn't see how the container protocol could do all this for me, but DK is such a complex beast I kind of assumed I just wasn't seeing the magic. I'll study DKShapeGroup until I really understand it.
> 
> I think also you're trying to rely too much on the existing creation tool behaviour. You need to subclass that (or DKDrawingTool) so that the note creation works correctly with stave objects and ignores layers. It's much easier than it might sound, tools are typically lightweight objects that call on the drawables they work with do do the heavy lifting, in this case staves.

Yes, I see now that my tool needs to be quite different from the standard one.
Thanks for your time.

J.


More information about the Drawkit mailing list