HI James,

I would say that even if you have got it working, you're going out on a limb 
there.

If you have elements in your interface that are positioned statically rather 
than part of the general content of the 'canvas' they might be better off being 
put into a separate view that is independent of DrawKit. Without knowing what 
these elements are however, it's hard to advise.

--Graham


On 13/10/2011, at 6:24 AM, James Maxwell wrote:

> I'm using GCDrawKit, which has been an amazing help in getting my app's 
> interface together. However, I've run into a problem that's making me 
> slightly crazy...
> 
> My main view is a zooming scroll view. Thanks to drawKit, I generally have no 
> problems at all; it handles the zooming beautifully, so I don't even think 
> about it. However, what I need to do now is to have certain objects remain in 
> a fixed position, relative to the viewable area -- so if, for example, an 
> object is in the upper-left corner, it will remain there during scrolling and 
> zooming (I DO want it to zoom, but it should stay in the upper-left corner). 
> I managed to get this working (or I thought I did), by telling my 
> enclosingScrollView to post frame changed notifications, then using those to 
> update the position of the object. 
> 
> - (void)                updateWithScroll
> {
>    NSPoint selfOrigin = [self location];
>    DKDrawingView* view = [(DKDrawingDocument*)[[self drawing] owner] 
> mainView];
>    NSRect bounds = [[[view enclosingScrollView] contentView] bounds];
>    NSPoint origin = bounds.origin;
>    if(self.lockXPositionToContentRect)
>    {
>        selfOrigin.x = origin.x + scrollOffset.x;
>    }
>    if(self.lockYPositionToContentRect)
>    {
>        selfOrigin.y = origin.y + scrollOffset.y;
>    }
>    [self setLocation:selfOrigin];
> }
> 
> But unfortunately I forgot about zooming, so my objects only stay in their 
> correct positions if I'm either: A) at a zoom scale of 1.0, or B) the scroll 
> view is at the document's origin (i.e., 0,0 for both document and view). How 
> do I do this for both scrolling and zooming? 
> (I tried multiplying the location coordinates by the scaling amount, but that 
> doesn't quite do it -- it's closer, but not correct.)
> 
> Any help appreciated.
> 
> J.
> 
> ------------------------------------------------------
> James B. Maxwell
> Composer/Researcher/PhD Candidate
> jbmaxw...@rubato-music.com
> 
> 
> 
> 
> 
> _______________________________________________
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/graham.cox%40bigpond.com
> 
> This email sent to graham....@bigpond.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to