[Drawkit] Object manipulation notification
Linan Wang
tali.wang at gmail.com
Tue Jul 1 02:32:17 PDT 2008
Thank you for your response.
For object adding/removal issue, I think it would be great if it could
be implemented in KVO style, that is, programer can just observe the
"objects" key of any DKObjectOwnerLayer.
For object properties changing notifications: my program binds a
"building" object with each DKDrawableObject (I put it as userInfo), I
want to change the location/size/orientation properties of the objects
when user manipulates the DKDrawableObject, so that extra info will be
supplied to users to help them make design decisions.
I feel it could be only achieved effeciently by hook
postNotificationName:selector:object into methods which change the
DKDrawableObject properties.
Any thoughts?
Thanks
On 6/30/08, Graham Cox <graham.cox at bigpond.com> wrote:
> I agree with you that notifications for object adding/removal would be
> useful - in fact when I read that my first thought was that I already added
> that ages ago but you're right - they are not there. So I will add that.
>
> For general notification when any object changes, you might be able to make
> use of the update mechanism. When any object changes in any way that alters
> its appearance, it calls -notifyVisualChange. Ultimately this passes up to
> the view(s) and invokes the -setNeedsDisplayInRect: method, but you can also
> intercept it at a variety of levels to find out when objects change. If you
> need to know which object changed, the highest point you can get that
> information is in DKObjectOwnerLayer -drawable:needsDisplayInRect: After
> that the information about the object is not propagated as it just becomes a
> generic rect update. From there it goes to:
>
> DKLayer - setNeedsDisplayInRect:
> DKDrawing -setNeedsDisplayInRect:
> DKViewController -setViewNeedsDisplayInRect:
> NSView -setNeedsDisplayInRect:
>
> One thing to bear in mind is that if you hook into this, you will get a
> flood of notifications, because in many situations an object needs to call
> this both before and after making the change to ensure that its old
> appearance gets erased if necessary. You can't tell the difference between
> the 'before' and 'after' messages easily either.
>
> There is also a -notifyStatusChange for non-visual changes but at present
> it's not called by very much.
>
> I could buy an argument for having specific notifications for these, but
> until now I haven't thought that necessary. If you can give me more info
> about why your logic requires this I might be able to think of a better way.
>
> cheers, Graham
>
>
> On 1 Jul 2008, at 1:17 am, Linan Wang wrote:
>
>
> >
> > Hi everyone,
> >
> > I'm working on a program that uses DrawKit to help architects conduct site
> analysis. Basically I'm using DKDrawing as a site map, and DKDrawableObject
> as arbitrary objects like buildings, streets etc. The logic of the program
> need to know when an object is modified (resize, rotate, etc), and the site
> map is modified (add new object(s), remove object(s)).
> >
> > My basic idea is to post notifications when those events happen. I've
> added posting notifications codes to DKObjectOwnerLayer to watch add/remove
> objects. I'm little bit confused where to add resize/rotate/move
> notifications, since methods of DKDrawableObject is not always called by
> subclasses.
> >
> > My question is if it's the best approach? if it is, I feel it's valuable
> to add this kind of notifications into the framework since for application
> developers, those notifications are important. It would make developers
> lives a lot easier. I'd love to contribute to this part of work if it's
> valuable.
> >
> > (btw, congrat, it's a great framework!)
> >
> > --
> > Best regards
> >
> > Linan Wang
> > _______________________________________________
> > Drawkit mailing list
> > Drawkit at lists.apptree.net
> >
> http://lists.apptree.net/listinfo.cgi/drawkit-apptree.net
> >
>
> _______________________________________________
> Drawkit mailing list
> Drawkit at lists.apptree.net
> http://lists.apptree.net/listinfo.cgi/drawkit-apptree.net
>
--
Best regards
Linan Wang
More information about the Drawkit
mailing list