Re: best way to implement a clickable grid?

2015-09-15 Thread Jonathan Mitchell

> On 15 Sep 2015, at 01:17, Patrick J. Collins  
> 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…
> 
You might find this useful.

https://github.com/ThesaurusSoftware/TSUniformGrid

Jonathan














___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

best way to implement a clickable grid?

2015-09-14 Thread Patrick J. Collins
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!


Patrick J. Collins
http://collinatorstudios.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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: best way to implement a clickable grid?

2015-09-14 Thread Jens Alfke
I would probably just implement it as a custom NSView. Then it doesn’t even 
have to be represented in memory as a grid; you just remember the level for 
each x coord and fill in the appropriate squares when drawing.

> Or is there a better way to handle click events on a simple NSView?

Just override mouseDown:, mouseDragged:, mouseUp:. You’ll have to convert the 
event coords from window to view coords.

—Jens
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: best way to implement a clickable grid?

2015-09-14 Thread Uli Kusterer
On 15 Sep 2015, at 02:35, Jens Alfke  wrote:
> I would probably just implement it as a custom NSView. Then it doesn’t even 
> have to be represented in memory as a grid; you just remember the level for 
> each x coord and fill in the appropriate squares when drawing.
> 
>> Or is there a better way to handle click events on a simple NSView?
> 
> Just override mouseDown:, mouseDragged:, mouseUp:. You’ll have to convert the 
> event coords from window to view coords.

 Oh, if you go the route of a custom view like Jens and I suggest, don't forget 
to implement Accessibility for it. You can probably just give a number 
indicating the level, but otherwise you might have to do whatever NSSlider does 
to expose itself to Accessibility. Or maybe you could just subclass NSSlider, 
replace all the tracking and drawing code, and that way get Accessibility for 
free.

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://stacksmith.org





___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: best way to implement a clickable grid?

2015-09-14 Thread Doug Hill
Hey Patrick,

An interesting problem.

Depending on how far you want to take this, how much this view will be reused, 
how customizable it needs to be, etc. will inform your design decisions.

Just off the top of my head…If the number of blocks in each cell is fixed, it 
might be easy to make a custom NSView with n number of buttons. This could be 
created dynamically at runtime or in a XIB. Clicking a button would send a 
message to your custom view object that allows you to style all the other 
buttons. You could then group a number of these views to create your grid. If 
your view needs to be dynamic (n buttons in y groups), you might consider using 
a tableview or collection view to construct this. This is more work but will be 
the most customizable and reusable.

Good luck!

Doug Hill
http://chartcube .com/


> On Sep 14, 2015, at 5:17 PM, Patrick J. Collins 
>  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!
> 
> 
> Patrick J. Collins
> http://collinatorstudios.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:
> https://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40breaqz.com
> 
> This email sent to cocoa...@breaqz.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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: best way to implement a clickable grid?

2015-09-14 Thread Uli Kusterer
On 15 Sep 2015, at 02:17, Patrick J. Collins  
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 (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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com