2

This comes from Dictionary APP in 10.7 Lion. Is this a NSShadow in a NSSplitView? I'd appreciate any advice, thanks.

enter image description here

Li Fumin
  • 1,383
  • 2
  • 15
  • 31

2 Answers2

2

Thanks, Li Fumin, for reminding me this was one of those visual effects I wanted to solve. :-) here's some sample code I posted just a bit ago. Enjoy!

Joshua Nozzi
  • 60,946
  • 14
  • 140
  • 135
  • Hi, Joshua, I have read your code. It seems like the effect in your code and the effect in Dictionary APP are not exactly the same thing. In the Dictionary App, texts can go under the splitter shadow, and at the bottom or top of the table view, it applys too. Thanks for your advice,though. – Li Fumin Jul 23 '11 at 02:38
  • And I get some inspirations from this post. But I want to implement this in high level framework rather than low level CoreGraphics. http://stackoverflow.com/questions/6366362/how-to-draw-a-tapered-line-oval-shadow-in-cocoa – Li Fumin Jul 23 '11 at 02:48
  • Actually, the text *doesn't* go under the shadow. If you zoom in and watch as the shadow moves, the text does not change color. The shadow is in fact *under* the text. Could you be referencing the fact the text doesn't truncate in my example? That's a simple toggle for table column data cell behavior... – Joshua Nozzi Jul 23 '11 at 07:48
  • But in your sample code what I saw was that texts can't overlap the shadow which Dictionary APP actually can.It is subtle but important difference. – Li Fumin Jul 23 '11 at 09:19
  • Some extra configuration is necessary. You can set the table's intercell spacing to {0.0, somevalue}. That'll get you most of the way there. The text cell itself is doing some extra stuff to keep the text truncated away from the edge (it'll adjust kerning, etc.). That's left up to you. For proof it works, however, set the gradient width to 8 (vs 4) in lines 63 and 64 of JLNRecessedTableView.m. The gradient is *definitely* under the text. – Joshua Nozzi Jul 23 '11 at 15:23
  • Justification for not adding this behavior to the view subclasses: it may be unwanted and should be app-specific. I just posted an updated version including the intercell spacing demo (it's in the app controller's startup logic). – Joshua Nozzi Jul 23 '11 at 15:38
0

Inspecting it with F-Script shows that it’s a custom split view (DSIndexSplitView) with a custom table view (DSIndexTableView) in the right column – nothing very surprising. The shadow is part of the table view rather than the splitter (which on further consideration can also be seen by the fact that text in the table view can draw over it).

I’d guess it’s either a gradient or an NSShadow drawn into the table view, before passing off to the superclass to render the cells.

Jens Ayton
  • 14,532
  • 3
  • 33
  • 47
  • If it is a shadow over the splitter, it is still possible to draw texts under the shadow.In this case, the splitter can be very thin.Is that right?But I don't know how to code this. – Li Fumin Jul 22 '11 at 12:33