On Jun 14, 2014, at 3:18 PM, Bill Cheeseman <wjcheese...@gmail.com> wrote:

> The -[NSScrollView addFloatingSubview:] method was added in OS X 10.9 
> Mavericks. I can't find any usage examples, and the Mavericks release notes 
> and the reference document are not helpful to me. Playing around with it for 
> a few minutes has gotten me nowhere.
> 
> Has anybody figured out how to use this?
> 
> The reason I'm asking is that it seems like it might be one way to put a 
> button bar at the bottom of a source list outline and have the source list's 
> special color show through the button bar. Lots of Apple applications and 
> others show the source list background color through and around the buttons 
> at the bottom, but I can't find any examples of how they do it. Maybe they 
> just use regular colors that happen to match the system source list 
> background color. (I want to use the special "_sourceListBackgroundColor" 
> that automatically changes color when the window moves between active and 
> inactive states. It's easy to assign normal colors to the button bar, but 
> -[NSBox fillColor] won't accept special system colors like this.)


I figured this one out just a few minutes later.

In Interface Builder, I have a SourceListView nib file containing my source 
list view, which as usual is an NSScrollView containing an NSClipView 
containing an NSOutlineView. In my SourceListViewController, -awakeFromNib adds 
this source list view into the left pane of a vertical split view in my 
application's main window. 

To add a floating (non-scrolling) NSBox view containing gradient buttons to the 
bottom of the source list, I start by creating a freestanding NSBox view 
containing some gradient buttons in SourceListView.xib. This is a separate view 
object sitting alongside the source list view in the nib file. I select the 
NSBox view's Transparent checkbox. I connect the NSBox view to the 
sourceListButtonBox IBOutlet in my SourceListViewController class (file's 
owner).  

In SourceListViewController's -awakeFromNib method, I insert this code after 
setting up and configuring the source list:

     NSOutlineView *outlineView = [self sourceListOutlineView];
     NSScrollView *scrollView = (NSScrollView *)[[outlineView superview] 
superview];
     NSBox *buttonBox = [self sourcListButtonBox];

     [scrollView addFloatingSubview:buttonBox 
forAxis:NSEventGestureAxisVertical];
     [buttonBox setFrameOrigin:NSMakePoint(0.0, [scrollView bounds].size.height 
- [buttonBox bounds].size.height)];

And that's it. When I run it, the gradient buttons in the NSBox sit near the 
bottom of the source list, no matter how I resize the window or the left pane 
of the split view, and no matter how I scroll the source list. The special 
"_sourceListBackgroundColor" of the source list shows through the transparent 
NSBox view and around the opaque gradient buttons, and it turns from light blue 
to white when the window becomes inactive and back to light blue when it 
becomes active.

The really funky part of this is that the rows of images and text fields in the 
source list are visible through the transparent NSBox view and around the 
gradient buttons as the source list scrolls. Once I figure out how to dim the 
source list rows while they scroll behind the gradient buttons (see my other 
message of today), I will have source list rows visible (but dimmed) behind the 
group rows at the top of the source list and behind the gradient buttons at the 
bottom of the source list, for a consistent visual appearance.

Whether one likes this visual appearance is a matter of taste, I suppose. I am 
certainly uncomfortable with it, as I am with any new UI theme. But it does 
seem to be the wave of the future as seen in Yosemite.

-- 

Bill Cheeseman - b...@cheeseman.name

_______________________________________________

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

Reply via email to