Re: best way to implement a clickable grid?
Re: best way to implement a clickable grid?
- Subject: Re: best way to implement a clickable grid?
- From: Uli Kusterer <email@hidden>
- Date: Tue, 15 Sep 2015 03:17:21 +0200
On 15 Sep 2015, at 02:17, Patrick J. Collins <email@hidden> wrote:
> Hi everyone,
>
> I am looking to implement something that would look somewhat like a
> graphic equalizer. Meaning, a grid of blocks... Clicking on a single
> grid block would change the appearance of all cells directly under it..
> So in other words, clicking on 1,1 would turn on 1,1. but clicking 1,5
> woudl turn on 1,5, 1,4, 1,3, 1,2, 1,1...
>
> I am curious if anyone here has a suggestion of what the best design
> approach would be for something like this? Should I just
> programatically generate a bunch of NSViews? Should I overal an
> invisible button over each view? Or is there a better way to handle
> click events on a simple NSView?
>
> Any push in the right direction would be greatly appreciated. Thanks!
I'd generally use a single view and use the click Y coordinate to determine which segment was clicked, then I'd have two images, one containing unselected, the other selected versions of the grid elements, and would just clip to those.
It's what I did for our equalizer display. Although I in fact used two CALayers to show the image. That way the clipping happens on the GPU and the CPU doesn't constantly need to update the entire image and upload it onto the GPU. IIRC the contentsRect property is what I used to tell the GPU how to clip the drawing in the "selected" layer.
Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://stacksmith.org
_______________________________________________
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