Holy smokes! Okay, just used the wrong Rect. Needed to use documentVisibleRect instead of the contentView's bounds. Ugh... Working fine now.
J. On 2011-10-12, at 12:24 PM, 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/jbmaxwell%40rubato-music.com > > This email sent to jbmaxw...@rubato-music.com ------------------------------------------------------ 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/archive%40mail-archive.com This email sent to arch...@mail-archive.com