Skip to content

Commit

Permalink
#2434 now use NSTitlebarAccessoryViewController if available
Browse files Browse the repository at this point in the history
  • Loading branch information
abhibeckert committed Jun 5, 2016
1 parent 7bdd7a0 commit 50a0f18
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 21 deletions.
20 changes: 10 additions & 10 deletions Interfaces/English.lproj/DBView.xib
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9532" systemVersion="15E39d" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<dependencies>
<deployment identifier="macosx"/>
<development version="5100" identifier="xcode"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9532"/>
<plugIn identifier="com.apple.WebKitIBPlugin" version="9532"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10117"/>
<plugIn identifier="com.apple.WebKitIBPlugin" version="10117"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="SPDatabaseDocument">
Expand Down Expand Up @@ -885,7 +885,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView identifier="TableStructureIndexesTableView" focusRingType="none" verticalHuggingPriority="750" allowsExpansionToolTips="YES" alternatingRowBackgroundColors="YES" multipleSelection="NO" autosaveColumns="NO" rowHeight="16" headerView="3923" id="289" customClass="SPTableView">
<rect key="frame" x="0.0" y="0.0" width="694" height="135"/>
<rect key="frame" x="0.0" y="0.0" width="690" height="18"/>
<autoresizingMask key="autoresizingMask"/>
<size key="intercellSpacing" width="3" height="2"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
Expand Down Expand Up @@ -3440,7 +3440,7 @@ Gw
<box autoresizesSubviews="NO" title="Table:" borderType="line" id="5660">
<rect key="frame" x="17" y="231" width="345" height="56"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<view key="contentView" id="5Bl-Ho-IU0">
<view key="contentView">
<rect key="frame" x="1" y="1" width="343" height="40"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
Expand Down Expand Up @@ -3479,7 +3479,7 @@ Gw
<box autoresizesSubviews="NO" title="Name" borderType="line" id="7798">
<rect key="frame" x="17" y="291" width="345" height="58"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<view key="contentView" id="3ZP-dJ-QhM">
<view key="contentView">
<rect key="frame" x="1" y="1" width="343" height="42"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
Expand Down Expand Up @@ -3512,7 +3512,7 @@ Gw
<box autoresizesSubviews="NO" title="Action" borderType="line" id="5659">
<rect key="frame" x="17" y="49" width="345" height="87"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<view key="contentView" id="mnI-Zx-qey">
<view key="contentView">
<rect key="frame" x="1" y="1" width="343" height="71"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
Expand Down Expand Up @@ -3584,7 +3584,7 @@ Gw
<box autoresizesSubviews="NO" title="References" borderType="line" id="5652">
<rect key="frame" x="17" y="140" width="345" height="87"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<view key="contentView" id="oBh-ZJ-t7F">
<view key="contentView">
<rect key="frame" x="1" y="1" width="343" height="71"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
Expand Down Expand Up @@ -3705,7 +3705,7 @@ Gw
<box autoresizesSubviews="NO" title="Trigger:" borderType="line" id="6770">
<rect key="frame" x="17" y="219" width="326" height="109"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<view key="contentView" id="TWl-AK-BwB">
<view key="contentView">
<rect key="frame" x="1" y="1" width="324" height="93"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
Expand Down Expand Up @@ -4843,7 +4843,7 @@ Gw
<subviews>
<textField verticalHuggingPriority="750" id="6170">
<rect key="frame" x="2" y="2" width="105" height="14"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" id="6171">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="disabledControlTextColor" catalog="System" colorSpace="catalog"/>
Expand Down
2 changes: 1 addition & 1 deletion Source/SPDatabaseDocument.h
Expand Up @@ -106,7 +106,7 @@

IBOutlet NSView *parentView;

IBOutlet id titleAccessoryView;
IBOutlet NSView *titleAccessoryView;
IBOutlet id titleImageView;
IBOutlet id titleStringView;

Expand Down
37 changes: 27 additions & 10 deletions Source/SPDatabaseDocument.m
Expand Up @@ -3943,17 +3943,34 @@ - (void)updateTitlebarStatusVisibilityForcingHide:(BOOL)forceHide
if (newIsVisible == windowTitleStatusViewIsVisible) return;

if (newIsVisible) {
NSView *windowFrame = [[parentWindow contentView] superview];
NSRect av = [titleAccessoryView frame];
NSRect initialAccessoryViewFrame = NSMakeRect(
[windowFrame frame].size.width - av.size.width - 30,
[windowFrame frame].size.height - av.size.height,
av.size.width,
av.size.height);
[titleAccessoryView setFrame:initialAccessoryViewFrame];
[windowFrame addSubview:titleAccessoryView];
if (NSClassFromString(@"NSTitlebarAccessoryViewController")) { // OS X 10.11 and later
[titleAccessoryView setFrame:NSMakeRect(0, 0, titleAccessoryView.frame.size.width, 120)]; // make it really tall, so that it's on the top right of the title/toolbar area, instead of the bottom right (AppKit will not prevent it from going behind the toolbar)

NSTitlebarAccessoryViewController *accessoryViewController = [[[NSTitlebarAccessoryViewController alloc] init] autorelease];
accessoryViewController.view = titleAccessoryView;
accessoryViewController.layoutAttribute = NSLayoutAttributeRight;
[parentWindow addTitlebarAccessoryViewController:accessoryViewController];
} else {
NSView *windowFrame = [[parentWindow contentView] superview];
NSRect av = [titleAccessoryView frame];
NSRect initialAccessoryViewFrame = NSMakeRect(
[windowFrame frame].size.width - av.size.width - 30,
[windowFrame frame].size.height - av.size.height,
av.size.width,
av.size.height);
[titleAccessoryView setFrame:initialAccessoryViewFrame];
[windowFrame addSubview:titleAccessoryView];
}
} else {
[titleAccessoryView removeFromSuperview];
if (NSClassFromString(@"NSTitlebarAccessoryViewController")) { // OS X 10.11 and later
[parentWindow.titlebarAccessoryViewControllers enumerateObjectsUsingBlock:^(__kindof NSTitlebarAccessoryViewController * _Nonnull accessoryViewController, NSUInteger idx, BOOL * _Nonnull stop) {
if (accessoryViewController.view == titleAccessoryView) {
[parentWindow removeTitlebarAccessoryViewControllerAtIndex:idx];
}
}];
} else {
[titleAccessoryView removeFromSuperview];
}
}

windowTitleStatusViewIsVisible = newIsVisible;
Expand Down

0 comments on commit 50a0f18

Please sign in to comment.