Re: Re: NSMatrix, NSImageCell and selection indicator
Re: Re: NSMatrix, NSImageCell and selection indicator
- Subject: Re: Re: NSMatrix, NSImageCell and selection indicator
- From: "David Holmes" <email@hidden>
- Date: Mon, 18 Dec 2006 23:16:50 -0600
Thanks Brian, I'll try something similar.
Matt, sorry if it came across that way, but if I was snarling it was
only meant for myself.
On 12/18/06, Brian Ganninger <email@hidden> wrote:
I recently did exactly this for a project. May not be perfect/optimal/
etc. but it works. A simple breakdown in pseudo-codese:
1. onClick (your action for the matrix) grab the image of the
selected cell (row + column intersection)
if you've cached an image already [2] you'll need to restore the
last clicked column to its clean state
2. Use a couple global variables to track the column index just
clicked (to restore) and to cache the 'clean' image
3. Create a new image for the selection indicator [or optimize: draw
once, cache], lock focus and draw, I went with a style similar to
Installer.app (semi-transparent circle stroked with a circular
colored border) [note: you can get the user's selected color easily
enough from the frameworks]
4. Composite the drawn selection indicator over the cell's image
5. Set the image for the cell to what you've created in [4]
Hopefully that makes sense.
- brian
PS: if you're overwhelmed at the idea of drawing in the Cocoa APIs
then take a look at Apple's guide (http://developer.apple.com/
documentation/Cocoa/Conceptual/CocoaDrawingGuide) and you'll be ready
to go.
On Dec 18, 2006, at 5:46 PM, David Holmes wrote:
> There is a disconnect. But it is due to not knowing how to draw the
> selection indicator, not from not wanting to write any code. Cocoa is
> still new so I'm a little lost and haven't found a good reference for
> doing what I want with NSMatrix. I can sort of do it by changing the
> frame style on the image, but it doesn't look that great and causes
> the image to shrink a little to allow for the new frame border. I
> think it is just frustration with myself and finding lots of close
> examples that do the matrix with imagecell but not the selection
> indicator. Sorry for the despair, just need some direction.
>
> Thanks,
> David
>
> On 12/18/06, Matt Neuburg <email@hidden> wrote:
>> On Mon, 18 Dec 2006 13:54:01 -0600, "David Holmes"
>> <email@hidden>
>> said:
>> >I'm not drawing the image
>>
>> Right, but I was suggesting you might like to.
>>
>> > I'm using NSImageCell initImageCell and
>> >putting the Cell into the matrix. NSButtonCell does not achieve the
>> >desired look either. I want something akin to an iPhoto/Aperture
>> >thumbnail browser, but I do not need resizing. I just need the
>> >selected image to have a selected/focus/border indicator around it
>> >without adjusting the size of the image. I'm afraid NSMatrix isn't
>> >capable and I'll end up writing a custom view. Bleh.
>>
>> I don't see what you're bleh-ing. You say you have an NSMatrix
>> subclass, so
>> you can draw what you like. If you want to put an indicator around
>> the
>> selected cell, put it - you're already getting highlightCell and
>> drawCell
>> calls, after all.
>>
>> There's a logical disconnect here. At first you seem to be
>> complaining at
>> the notion that you might have to write *any* code, then you
>> suddenly jump
>> to the idea of writing a custom view, which would mean writing a
>> *lot* of
>> code. m.
>>
>> >
>> >On 12/18/06, Matt Neuburg <email@hidden> wrote:
>> >> On Sun, 17 Dec 2006 17:35:04 -0600, "David Holmes"
>> <email@hidden>
>> >> said:
>> >> >I have an NSMatrix subclass that I am adding NSImageCells to at
>> >> >runtime. I am unable to find a way to indicate an image is
>> selected
>> >> >when clicked on. I can get the selected cell through target and
>> >> >action, but have tried highlight, border, focus without
>> success. I
>> >> >would just like the selected image to have some indication
>> that it is
>> >> >selected. Any help would be appreciated.
>> >>
>> >> Simply redraw the image in a manner that suggests selectedness.
>> Or, use a
>> >> button cell instead of an image cell, if you want to take
>> advantage of the
>> >> built-in redrawing. m.
>> >>
>> >> --
>> >> matt neuburg, phd = email@hidden, <http://www.tidbits.com/
>> matt/>
>> >> A fool + a tool + an autorelease pool = cool!
>> >> AppleScript: the Definitive Guide - Second Edition!
>> >> <http://www.amazon.com/gp/product/0596102119>
>> >>
>> >>
>> >>
>> >>
>> >
>> >
>> >
>>
>> --
>> matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
>> A fool + a tool + an autorelease pool = cool!
>> AppleScript: the Definitive Guide - Second Edition!
>> <http://www.amazon.com/gp/product/0596102119>
>>
>>
>>
>>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> 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:
> 40mac.com
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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