mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-13 21:42:32 +00:00
Splitter handling now works better with Inspector. Still some work to be done!
This commit is contained in:
@@ -16,6 +16,10 @@
|
||||
|
||||
@property (retain) MPSettingsController *settingsController;
|
||||
@property (retain) MPMainWindowController *mainWindowController;
|
||||
@property (assign) IBOutlet NSMenuItem *toggleOutlineViewMenuItem;
|
||||
@property (assign) IBOutlet NSMenuItem *toggleInspectorViewMenuItem;
|
||||
|
||||
- (void)_setupMenues;
|
||||
|
||||
- (IBAction)showPreferences:(id)sender;
|
||||
@end
|
||||
@@ -25,6 +29,8 @@
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
|
||||
self.mainWindowController = [[[MPMainWindowController alloc] init] autorelease];
|
||||
[self.mainWindowController showWindow:[self.mainWindowController window]];
|
||||
[self _setupMenues];
|
||||
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
@@ -37,6 +43,13 @@
|
||||
return [[NSBundle mainBundle] infoDictionary][@"CFBundleName"];
|
||||
}
|
||||
|
||||
#pragma mark Setup
|
||||
|
||||
- (void)_setupMenues {
|
||||
[self.toggleInspectorViewMenuItem setAction:@selector(toggleInspector:)];
|
||||
[self.toggleOutlineViewMenuItem setAction:@selector(toggleOutlineView:)];
|
||||
}
|
||||
|
||||
#pragma mark Menu Actions
|
||||
|
||||
- (void)showMainWindow:(id)sender {
|
||||
|
||||
@@ -31,5 +31,6 @@
|
||||
*/
|
||||
- (void)clearFilter:(id)sender;
|
||||
- (void)toggleInspector:(id)sender;
|
||||
- (void)toggleOutlineView:(id)sender;
|
||||
|
||||
@end
|
||||
|
||||
@@ -17,8 +17,9 @@
|
||||
#import "MPInspectorTabViewController.h"
|
||||
#import "MPAppDelegate.h"
|
||||
|
||||
#define MIN_WINDOW_WIDTH MPMainWindowSplitViewDelegateMinimumContentWidth + MPMainWindowSplitViewDelegateMinimumOutlineWidth + [self.splitView dividerThickness]
|
||||
|
||||
static CGFloat _outlineSplitterPosition;
|
||||
static CGFloat _inspectorSplitterPosition;
|
||||
|
||||
@interface MPMainWindowController ()
|
||||
|
||||
@@ -46,6 +47,10 @@ static CGFloat _inspectorSplitterPosition;
|
||||
- (void)_setContentViewController:(MPViewController *)viewController;
|
||||
- (void)_updateWindowTitle;
|
||||
|
||||
/* window reszing and content checks */
|
||||
- (BOOL)_windowsIsLargeEnoughForInspectorView;
|
||||
- (void)_resizeWindowForInspectorView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MPMainWindowController
|
||||
@@ -94,8 +99,7 @@ static CGFloat _inspectorSplitterPosition;
|
||||
|
||||
[[self.welcomeText cell] setBackgroundStyle:NSBackgroundStyleRaised];
|
||||
|
||||
const CGFloat minimumWindowWidth = MPMainWindowSplitViewDelegateMinimumContentWidth + MPMainWindowSplitViewDelegateMinimumOutlineWidth + [self.splitView dividerThickness];
|
||||
[self.window setMinSize:NSMakeSize( minimumWindowWidth, 400)];
|
||||
[self.window setMinSize:NSMakeSize( MIN_WINDOW_WIDTH, 400)];
|
||||
|
||||
_toolbar = [[NSToolbar alloc] initWithIdentifier:@"MainWindowToolbar"];
|
||||
[self.toolbar setAllowsUserCustomization:YES];
|
||||
@@ -191,18 +195,47 @@ static CGFloat _inspectorSplitterPosition;
|
||||
NSView *inspectorView = [self.splitView subviews][MPSplitViewInspectorViewIndex];
|
||||
const BOOL collapsed = [self.splitView isSubviewCollapsed:inspectorView];
|
||||
if(collapsed) {
|
||||
CGFloat splitterPosition = MAX(MPMainWindowSplitViewDelegateMinimumInspectorWidth, _inspectorSplitterPosition);
|
||||
if( NO == [self _windowsIsLargeEnoughForInspectorView]) {
|
||||
[self _resizeWindowForInspectorView];
|
||||
}
|
||||
CGFloat splitterPosition = [self.splitView frame].size.width - MPMainWindowSplitViewDelegateMinimumInspectorWidth;
|
||||
[self.splitView setPosition:splitterPosition ofDividerAtIndex:MPSplitViewInspectorDividerIndex];
|
||||
}
|
||||
else {
|
||||
_inspectorSplitterPosition = [inspectorView frame].origin.x;
|
||||
CGFloat splitterPosition = [inspectorView frame].origin.x * [inspectorView frame].size.width;
|
||||
[[NSAnimationContext currentContext] setDuration:2];
|
||||
[[self.splitView animator] setPosition:splitterPosition ofDividerAtIndex:MPSplitViewInspectorDividerIndex];
|
||||
CGFloat splitterPosition = [self.splitView frame].size.width;
|
||||
[self.splitView setPosition:splitterPosition ofDividerAtIndex:MPSplitViewInspectorDividerIndex];
|
||||
}
|
||||
[inspectorView setHidden:!collapsed];
|
||||
}
|
||||
|
||||
- (void)toggleOutlineView:(id)sender {
|
||||
|
||||
}
|
||||
|
||||
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem {
|
||||
SEL menuAction = [menuItem action];
|
||||
if(menuAction == @selector(toggleOutlineView:)) {
|
||||
NSView *outlineView = [self.splitView subviews][MPSplitViewOutlineViewIndex];
|
||||
BOOL outlineIsHidden = [self.splitView isSubviewCollapsed:outlineView];
|
||||
if(outlineIsHidden) {
|
||||
[menuItem setTitle:@"Show Outline View"];
|
||||
}
|
||||
[menuItem setTitle:@"Hide Outline View"];
|
||||
return YES;
|
||||
}
|
||||
|
||||
if( menuAction == @selector(toggleInspector:) ) {
|
||||
NSView *inspectorView = [self.splitView subviews][MPSplitViewInspectorViewIndex];
|
||||
BOOL inspectorIsHidden = [self.splitView isSubviewCollapsed:inspectorView];
|
||||
if(inspectorIsHidden) {
|
||||
[menuItem setTitle:@"Show Inspecotr"];
|
||||
}
|
||||
[menuItem setTitle:@"Hide Inspector"];
|
||||
return YES;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)performFindPanelAction:(id)sender {
|
||||
[self.window makeFirstResponder:[self.toolbarDelegate.searchItem view]];
|
||||
}
|
||||
@@ -268,6 +301,24 @@ static CGFloat _inspectorSplitterPosition;
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (BOOL)_windowsIsLargeEnoughForInspectorView {
|
||||
return ( MPMainWindowSplitViewDelegateMinimumInspectorWidth
|
||||
< ([self.splitView frame].size.width
|
||||
- MPMainWindowSplitViewDelegateMinimumContentWidth
|
||||
- MPMainWindowSplitViewDelegateMinimumOutlineWidth
|
||||
- 2 * [self.splitView dividerThickness]) );
|
||||
}
|
||||
|
||||
- (void)_resizeWindowForInspectorView {
|
||||
NSRect frame = [self.window frame];
|
||||
NSView *outlinView = [self.splitView subviews][MPSplitViewOutlineViewIndex];
|
||||
NSView *contentView = [self.splitView subviews][MPSplitViewContentViewIndex];
|
||||
|
||||
CGFloat outlineWidth = [self.splitView isSubviewCollapsed:outlinView] ? 0 : [outlinView frame].size.width;
|
||||
frame.size.width = outlineWidth + [contentView frame].size.width + MPMainWindowSplitViewDelegateMinimumInspectorWidth;
|
||||
[self.window setFrame:frame display:YES animate:YES];
|
||||
}
|
||||
|
||||
#pragma mark Notifications
|
||||
|
||||
- (void)didOpenDocument:(NSNotification *)notification {
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
#import "MPMainWindowSplitViewDelegate.h"
|
||||
|
||||
const CGFloat MPMainWindowSplitViewDelegateMinimumOutlineWidth = 150.0;
|
||||
const CGFloat MPMainWindowSplitViewDelegateMinimumContentWidth = 400.0;
|
||||
const CGFloat MPMainWindowSplitViewDelegateMinimumInspectorWidth = 200.0;
|
||||
const CGFloat MPMainWindowSplitViewDelegateMinimumContentWidth = 250.0;
|
||||
const CGFloat MPMainWindowSplitViewDelegateMinimumInspectorWidth = 250.0;
|
||||
|
||||
|
||||
@interface MPMainWindowSplitViewDelegate ()
|
||||
@@ -26,22 +26,51 @@ const CGFloat MPMainWindowSplitViewDelegateMinimumInspectorWidth = 200.0;
|
||||
}
|
||||
|
||||
- (BOOL)splitView:(NSSplitView *)splitView canCollapseSubview:(NSView *)subview {
|
||||
return (subview != [self _subViewOfType:MPSplitViewContentViewIndex splitView:splitView]);
|
||||
return (subview == [self _subViewOfType:MPSplitViewInspectorViewIndex splitView:splitView]);
|
||||
}
|
||||
|
||||
- (CGFloat)splitView:(NSSplitView *)splitView constrainMinCoordinate:(CGFloat)proposedMinimumPosition ofSubviewAt:(NSInteger)dividerIndex {
|
||||
return proposedMinimumPosition;
|
||||
|
||||
// Update to take inspector into account
|
||||
return (proposedMinimumPosition < MPMainWindowSplitViewDelegateMinimumOutlineWidth) ? MPMainWindowSplitViewDelegateMinimumOutlineWidth : proposedMinimumPosition;
|
||||
switch (dividerIndex) {
|
||||
case MPSplitViewOutlineDividerIndex:
|
||||
return (proposedMinimumPosition < MPMainWindowSplitViewDelegateMinimumOutlineWidth) ? MPMainWindowSplitViewDelegateMinimumOutlineWidth : proposedMinimumPosition;
|
||||
break;
|
||||
|
||||
case MPSplitViewInspectorDividerIndex: {
|
||||
return [self splitView:splitView constrainSplitPosition:proposedMinimumPosition ofSubviewAt:dividerIndex];
|
||||
}
|
||||
|
||||
default:
|
||||
return proposedMinimumPosition;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (CGFloat)splitView:(NSSplitView *)splitView constrainSplitPosition:(CGFloat)proposedPosition ofSubviewAt:(NSInteger)dividerIndex {
|
||||
if(dividerIndex == MPSplitViewInspectorDividerIndex) {
|
||||
return [splitView frame].size.width - MPMainWindowSplitViewDelegateMinimumInspectorWidth;
|
||||
}
|
||||
return proposedPosition;
|
||||
}
|
||||
|
||||
- (CGFloat)splitView:(NSSplitView *)splitView constrainMaxCoordinate:(CGFloat)proposedMaximumPosition ofSubviewAt:(NSInteger)dividerIndex {
|
||||
return proposedMaximumPosition;
|
||||
|
||||
// Update to take inpspector into account
|
||||
CGFloat availableWidth = [splitView frame].size.width - [splitView dividerThickness];
|
||||
return (availableWidth - MPMainWindowSplitViewDelegateMinimumOutlineWidth);
|
||||
NSView *outlineView = [self _subViewOfType:MPSplitViewOutlineViewIndex splitView:splitView];
|
||||
NSView *inspectorView = [self _subViewOfType:MPSplitViewInspectorViewIndex splitView:splitView];
|
||||
NSUInteger outlineMultiplicator = [splitView isSubviewCollapsed:outlineView] ? 0 : 1;
|
||||
NSUInteger inpsectorMulitplicator = [splitView isSubviewCollapsed:inspectorView] ? 0 : 1;
|
||||
NSUInteger dividerMultiplicator = inpsectorMulitplicator + outlineMultiplicator;
|
||||
CGFloat availableWidth = [splitView frame].size.width - (dividerMultiplicator * [splitView dividerThickness]);
|
||||
switch (dividerIndex) {
|
||||
case MPSplitViewOutlineDividerIndex:
|
||||
return availableWidth - (outlineMultiplicator * [outlineView frame].size.width ) - MPMainWindowSplitViewDelegateMinimumContentWidth;
|
||||
|
||||
case MPSplitViewInspectorDividerIndex:
|
||||
return availableWidth - MPMainWindowSplitViewDelegateMinimumInspectorWidth;
|
||||
|
||||
default:
|
||||
return proposedMaximumPosition;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)splitView:(NSSplitView *)splitView resizeSubviewsWithOldSize:(NSSize)oldSize {
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>475</string>
|
||||
<string>48A</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
|
||||
<data>
|
||||
<int key="IBDocument.SystemTarget">1070</int>
|
||||
<string key="IBDocument.SystemVersion">12C60</string>
|
||||
<string key="IBDocument.SystemVersion">12C3103</string>
|
||||
<string key="IBDocument.InterfaceBuilderVersion">3084</string>
|
||||
<string key="IBDocument.AppKitVersion">1187.34</string>
|
||||
<string key="IBDocument.HIToolboxVersion">625.00</string>
|
||||
@@ -708,6 +708,33 @@
|
||||
<object class="NSMenu" key="NSSubmenu" id="466310130">
|
||||
<string key="NSTitle">View</string>
|
||||
<array class="NSMutableArray" key="NSMenuItems">
|
||||
<object class="NSMenuItem" id="650817293">
|
||||
<reference key="NSMenu" ref="466310130"/>
|
||||
<string key="NSTitle">Toggle Outline View</string>
|
||||
<string key="NSKeyEquiv"/>
|
||||
<int key="NSMnemonicLoc">2147483647</int>
|
||||
<reference key="NSOnImage" ref="35465992"/>
|
||||
<reference key="NSMixedImage" ref="502551668"/>
|
||||
</object>
|
||||
<object class="NSMenuItem" id="366402813">
|
||||
<reference key="NSMenu" ref="466310130"/>
|
||||
<string key="NSTitle">Toggle Inspector</string>
|
||||
<string key="NSKeyEquiv">i</string>
|
||||
<int key="NSKeyEquivModMask">1048576</int>
|
||||
<int key="NSMnemonicLoc">2147483647</int>
|
||||
<reference key="NSOnImage" ref="35465992"/>
|
||||
<reference key="NSMixedImage" ref="502551668"/>
|
||||
</object>
|
||||
<object class="NSMenuItem" id="43915532">
|
||||
<reference key="NSMenu" ref="466310130"/>
|
||||
<bool key="NSIsDisabled">YES</bool>
|
||||
<bool key="NSIsSeparator">YES</bool>
|
||||
<string key="NSTitle"/>
|
||||
<string key="NSKeyEquiv"/>
|
||||
<int key="NSMnemonicLoc">2147483647</int>
|
||||
<reference key="NSOnImage" ref="35465992"/>
|
||||
<reference key="NSMixedImage" ref="502551668"/>
|
||||
</object>
|
||||
<object class="NSMenuItem" id="102151532">
|
||||
<reference key="NSMenu" ref="466310130"/>
|
||||
<string key="NSTitle">Show Toolbar</string>
|
||||
@@ -1254,6 +1281,22 @@
|
||||
</object>
|
||||
<int key="connectionID">1178</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBOutletConnection" key="connection">
|
||||
<string key="label">toggleOutlineViewMenuItem</string>
|
||||
<reference key="source" ref="976324537"/>
|
||||
<reference key="destination" ref="650817293"/>
|
||||
</object>
|
||||
<int key="connectionID">1182</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBOutletConnection" key="connection">
|
||||
<string key="label">toggleInspectorViewMenuItem</string>
|
||||
<reference key="source" ref="976324537"/>
|
||||
<reference key="destination" ref="366402813"/>
|
||||
</object>
|
||||
<int key="connectionID">1183</int>
|
||||
</object>
|
||||
</array>
|
||||
<object class="IBMutableOrderedSet" key="objectRecords">
|
||||
<array key="orderedObjects">
|
||||
@@ -1686,6 +1729,9 @@
|
||||
<array class="NSMutableArray" key="children">
|
||||
<reference ref="102151532"/>
|
||||
<reference ref="237841660"/>
|
||||
<reference ref="43915532"/>
|
||||
<reference ref="650817293"/>
|
||||
<reference ref="366402813"/>
|
||||
</array>
|
||||
<reference key="parent" ref="586577488"/>
|
||||
</object>
|
||||
@@ -1882,6 +1928,21 @@
|
||||
<reference key="object" ref="174162306"/>
|
||||
<reference key="parent" ref="835318025"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">1179</int>
|
||||
<reference key="object" ref="43915532"/>
|
||||
<reference key="parent" ref="466310130"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">1180</int>
|
||||
<reference key="object" ref="650817293"/>
|
||||
<reference key="parent" ref="466310130"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">1181</int>
|
||||
<reference key="object" ref="366402813"/>
|
||||
<reference key="parent" ref="466310130"/>
|
||||
</object>
|
||||
</array>
|
||||
</object>
|
||||
<dictionary class="NSMutableDictionary" key="flattenedProperties">
|
||||
@@ -1891,6 +1952,9 @@
|
||||
<string key="112.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="1176.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="1177.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="1179.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="1180.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="1181.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="124.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="125.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="126.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
@@ -1985,7 +2049,7 @@
|
||||
<nil key="activeLocalization"/>
|
||||
<dictionary class="NSMutableDictionary" key="localizations"/>
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">1178</int>
|
||||
<int key="maxID">1183</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||
@@ -2006,6 +2070,20 @@
|
||||
<string key="candidateClassName">id</string>
|
||||
</object>
|
||||
</dictionary>
|
||||
<dictionary class="NSMutableDictionary" key="outlets">
|
||||
<string key="toggleInspectorViewMenuItem">NSMenuItem</string>
|
||||
<string key="toggleOutlineViewMenuItem">NSMenuItem</string>
|
||||
</dictionary>
|
||||
<dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
|
||||
<object class="IBToOneOutletInfo" key="toggleInspectorViewMenuItem">
|
||||
<string key="name">toggleInspectorViewMenuItem</string>
|
||||
<string key="candidateClassName">NSMenuItem</string>
|
||||
</object>
|
||||
<object class="IBToOneOutletInfo" key="toggleOutlineViewMenuItem">
|
||||
<string key="name">toggleOutlineViewMenuItem</string>
|
||||
<string key="candidateClassName">NSMenuItem</string>
|
||||
</object>
|
||||
</dictionary>
|
||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||
<string key="majorKey">IBProjectSource</string>
|
||||
<string key="minorKey">./Classes/MPAppDelegate.h</string>
|
||||
|
||||
Reference in New Issue
Block a user