This looks like a good fit for CGLayers.

http://developer.apple.com/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_layers/chapter_13_section_1.html#/ /apple_ref/doc/uid/TP30001066-CH219-TPXREF101

The background and color bars could be a plain old bitmap images drawn into cglayers. Once loaded into a layer, you can reuse an element as many times as you like, manipulating its width and origin with transforms. There is an example at the above link that shows how to create a U.S. flag using CGLayers that is pretty much what you're trying to do with your background.

I don't know about hit testing an item in a layer, but an alternative way to create color bars would be to use NSBezierPath which has a "containsPoint:" method you could use for bar selection.

http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSBezierPath_Class/Reference/Reference.html#/ /apple_ref/occ/instm/NSBezierPath/containsPoint:

As to animating the bar movements, someone else will need to chime in on that one.




On Dec 30, 2008, at 11:35 PM, Matt Rajca wrote:

Hi!

I am trying to figure out how to implement a 'Piano Roll' view in Cocoa. Attached is a screenshot of what I'm trying to accomplish. Disregard the keyboard on the left of the window and let's just focus on the area with the colorful rectangles, symbolizing notes.

1. When drawing the light and dark grey rows which make up a background, should I just use a loop with Quartz 2D/Cocoa Drawing calls? 2. When drawing the vertical lines, should I just use a loop with Quartz 2D/Cocoa Drawing calls? 3. Should I put the notes (colorful rectangles) each in a separate view (or Core Animation layer), or is it effective to just draw them directly in the main view (same view in which the rows are drawn)? I am eventually going to want to resize them and change their position by dragging them around. 4. How would I go about changing the view's width as more notes (rectangles) are added to the view? When enclosed in a NSScrollView, would manipulating the width of the view also hide/show the horizontal scrollbar appropriately?

Thanks!

~Matt


<PianoRollWindow.jpg>
_______________________________________________

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/kentozier%40comcast.net

This email sent to kentoz...@comcast.net

_______________________________________________

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