[Drawkit] Changing margins does not shift drawing objects
Graham Cox
graham.cox at bigpond.com
Tue Jul 8 17:41:21 PDT 2008
Hi Brad,
I agree with you that the position should be relative to the origin of
the grid, which is generally the top, left point inside the margin
(this is where the ruler shows 0,0).
I'll need to look into the most efficient way to do this, which I
think is probably to manipulate the container transform supplied by
the layer to include this origin. This would avoid the need to iterate
over the objects and change their position property.
I'm less sure about scaling the objects - not that you mentioned it
but Dick did in his message. It could be handled in the same way, but
it's less clear if it's desirable. The original thinking was that you
set up your scale/grid initially and then draw at that scale. Changing
the grid doesn't keep objects at that original scale - effectively
they are "rescaled" to the new grid by remaining exactly the same
size. I can see that some apps might want to do something different
though, so it may be a case of providing a method that will do the
job, and leave it up to the app to use it.
I want to try and get a new beta out asap - I was hoping today but I
noticed a last-minute bug that I'd prefer to fix, so maybe, maybe not.
I'll also try and get this in too. However do be prepared for some
renaming work (for the last time I hope!).
cheers, Graham
On 9 Jul 2008, at 2:14 am, Brad Larson wrote:
> I just added the ability to resize the document workspace to our
> drawing client, and in our application I wanted the margins to scale
> as a percentage of the drawing working area. I noticed that when
> the margins changed, the objects within the drawing did not shift to
> match, causing items that were drawn at the left edge of the working
> area to fall off the drawing and into the margins.
>
> It seems like you'd want the objects to stay at their same relative
> positions in the drawing, and be shifted appropriately by the
> changing margins, but I'm not quite sure where in DrawKit you would
> handle this. DKDrawableObjects are drawn by specifying their
> absolute Quartz position (using DKGrid's pointForGridLocation:),
> which includes the margin origin in the initial placement
> calculation. You'd need to recalculate the Quartz positions of all
> objects using the difference between the old and new margins to move
> them properly. DKObjectOwnerLayers might handle this, by responding
> to the kDKDrawingWillChangeMargins and kDKDrawingDidChangeMargins
> notifications and adjusting all their internal objects to match.
>
> For now, I can do this manually, but it would be nice for this to be
> handled internally.
>
> ______________________
> Brad Larson
> SonoPlot, Inc.
> 3030 Laura Lane, Suite 120
> Middleton, WI 53562
>
>
>
> _______________________________________________
> Drawkit mailing list
> Drawkit at lists.apptree.net
> http://lists.apptree.net/listinfo.cgi/drawkit-apptree.net
More information about the Drawkit
mailing list