• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Basic: How to go about implementing such a view?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Basic: How to go about implementing such a view?


  • Subject: Re: Basic: How to go about implementing such a view?
  • From: Ken Tozier <email@hidden>
  • Date: Thu, 1 Jan 2009 18:11:56 -0500

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 (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

_______________________________________________

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


  • Prev by Date: Re: Display sleep vs. enterFullScreenMode
  • Next by Date: Re: Which language to get started with cocoa development?
  • Previous by thread: Re: Basic: How to go about implementing such a view?
  • Next by thread: Re: Basic: How to go about implementing such a view?
  • Index(es):
    • Date
    • Thread