On Thu, Apr 21, 2011 at 5:52 PM, Graham Cox <graham....@bigpond.com> wrote:

>
> On 21/04/2011, at 4:17 PM, Bryan Hansen wrote:
>
> > Am I on the right track with this? Is there a better way to get a bunch
> of movable colorwells within a custom control?
>
>
> I'd say no, you're not on the right track and yes, there's a better way.
>
> What you're attempting is probably doable, but the purpose of cells is to
> allow their re-use in a number of different situations - buttons, tables,
> matrices and so on. Since you're just making a custom control for a single
> purpose, using cells is just a lot of extra effort without a benefit (not to
> mention the extensive and ad-hoc nature of the NSCell API which invariable
> needs much customisation for every new situation).
>
> I've written a gradient control similar to what you're doing, with movable
> colour wells inside a bar. The original implementation used cells and it was
> a complex, overwrought mess. I later rewrote it as a single custom NSView
> which reduced the amount of code by 60% or so, and it worked a lot better (a
> good sign that you are doing it right!). The movable wells were simply
> elements drawn as needed in the right places.


That works, but if the stock NSColorWell drawing and behavior is already
what you want, you can use normal NSColorWell objects as subviews.  Your
uber view might be in charge of positioning them.

But definitely, if you don't need to put this in a table, no reason to deal
with cells here.

-Ken


> I did need to perform some tricks to get them to interact with the usual
> instances of NSColorWell in terms of getting the focus of the color panel -
> originally I did this using swizzling but when that was deprecated I did it
> some other way (the details momentarily escape me, but it "played nice").
>
> If you are interested in my implementation, I'm happy to share the code -
> contact me offlist. There are numerous problems you'd need to solve if you
> rolled your own - for example, since the movable well has some rectangular
> size, it's possible for two or more of these to overlap within the overall
> control. You need to handle that, as well as the already mentioned issue of
> getting Color Panel focus in conjunction with any other NSColorWell
> instances that exist in your app.
>
> You can preview the design here: http://gradientpanel.com/ though that
> project is pretty much dead, and uses the old complex design. The revised
> one looks the same however.
>
> --Graham
>
>
> _______________________________________________
>
> 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/kenferry%40gmail.com
>
> This email sent to kenfe...@gmail.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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Reply via email to