Re: Looking for Cocoa Drawing Strategy Advice
Re: Looking for Cocoa Drawing Strategy Advice
- Subject: Re: Looking for Cocoa Drawing Strategy Advice
- From: Quincey Morris <email@hidden>
- Date: Fri, 14 May 2010 14:14:39 -0700
On May 14, 2010, at 10:41, Philip Regan wrote:
> The feature that I'm stuck on sorting on how best to implement is custom rulers—multiple types of horizontal rulers that can be shown and hidden by the user together or alone (or none at all), each with their own editable objects and types of hash marks (if any at all), and a vertical ruler that requires actual art and interaction as opposed to just hash marks. From what I can surmise from the documentation and reading other questions on various forums, there are two ways to handle this...
>
> The first strategy I'm looking at is to use the already supplied NSRulerViews to create my own view hierarchy to manage and draw as I see fit. I'm leaning towards this method because it seems to be more of what Cocoa would expect, but it also seems as though the NSRulerView has a very pre-determined use that really can't be modified too much without a whole lot of trouble.
My advice: forget it. NSRulerViews are tightly integrated with scroll views, and they're kind of quirky.
> The second strategy is to draw the rulers in the main NSView nested in the NSScrollView and use NSClipView to maintain their position on the left and top of the NSScrollView. But that seems kludgey to me somehow.
If you're literally drawing them inside the "main" view, then the clip view won't help you keep them in place.
If you draw them in separate views, then they're outside the scrolling that the clip view does, so they'll stay in place. Of course, you'll have to synchronize them with the clip view in the one direction they each do scroll (not very hard). In this case, you'd want to subclass NSScrollView to override its 'tile' method, to keep your rulers correctly sized and positioned when the size of the scroll view itself changes.
> Also, I'm looking to incorporate certain simple 2D drawing techniques like rounded corners, transparency, and possibly drop shadows. In a GUI interface is there a graphics library I should stick with or ones that I should stay away from (I know OpenGL is overkill here, but would CoreAnimation be a bad thing in a drag-and-drop editing scenario).
These effects are not hard to do yourself -- you can create a display representation of each drawing object that's as simple as a NSBezierPath, or as complex as a PDF document, I guess.
In terms of placing these drawing objects within a larger canvas (with layering, z-ordering, all the other stuff drawing has), you might want to look into Graham Cox's DrawKit, which designed for this sort of thing. DrawKit may even have a good solution to the custom rulers thing.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden