[Drawkit] permanent objects
Graham Cox
graham.cox at bigpond.com
Wed Jun 4 19:24:22 PDT 2008
On 5 Jun 2008, at 12:01 pm, James Maxwell wrote:
> Hey Graham,
>
> Yes, it's just a DKDrawableShape, so I could most certainly lock it!
> Can't believe I didn't think of that! :-\
> Mind you, will this prevent its initial instantiation from being
> undone? It all gets a bit weird, because I will want to be able to
> undo creation of later instances of these objects... I may have to
> think this through a bit more, I suppose.
Undo will still work fine. Locking an object is really a contract
between it and various tools/layers - if they see that flag they
basically agree not to touch it. But if they went ahead and did
anyway, the object itself would be unable to entirely enforce the lock
status. Thus, adding and deleting locked objects programatically is
still possible and thus undoable (but user interaction such as hitting
'delete' will honour the lock flag).
In the next update I added an overrideable method -
objectMayBecomeSelected that will also help you in this situation -
normally all objects return YES, but if you return NO your object
can't ever be selected and will never display a selection highlight.
It is intended to permit non-editable content to be intermixed with
editable content.
There are other approaches too - you could add these objects to a
separate layer and lock the layer as a whole for example.
> Basically, I'm creating something similar to a timeline with
> barlines for this app (music app), but they're only barlines in the
> most basic formal sense - they demarcate a border between two metric
> formalisms - which in this app means they split the timeline.
> They're not barlines in a traditional sense. So, each time I create
> one of these quasi-barlines, I will be "splitting" the existing
> timeline object; shortening the existing one to end at the barline,
> and creating a new one, which starts at the barline. I'm not sure
> how I'll make this undoable yet, but I'm just experimenting with
> ideas, at this point...
>
OK, well I don't see any special case necessarily being needed here -
adding new objects will be undoable anyway. If you perform a split by
resizing the object that also will be undoable by default.
cheers, Graham
More information about the Drawkit
mailing list