Skip to content

Commit

Permalink
Merge pull request #935 from Sequel-Ace/titleAccessory
Browse files Browse the repository at this point in the history
Remove titleAccessoryView #removed
  • Loading branch information
Kaspik committed Mar 4, 2021
2 parents 1ad55c9 + e308881 commit 479f8a8
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 85 deletions.
24 changes: 0 additions & 24 deletions Interfaces/DBView.xib
Expand Up @@ -62,9 +62,6 @@
<outlet property="tableTabView" destination="25" id="1244"/>
<outlet property="tableTriggersInstance" destination="6691" id="6796"/>
<outlet property="tablesListInstance" destination="68" id="104"/>
<outlet property="titleAccessoryView" destination="5999" id="6002"/>
<outlet property="titleImageView" destination="6000" id="6003"/>
<outlet property="titleStringView" destination="6170" id="6172"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
Expand Down Expand Up @@ -4160,27 +4157,6 @@ Gw
</subviews>
<point key="canvasLocation" x="-1822" y="484"/>
</customView>
<customView id="5999" userLabel="Title Icon View">
<rect key="frame" x="0.0" y="0.0" width="110" height="20"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
<subviews>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="6170">
<rect key="frame" x="2" y="2" width="105" height="14"/>
<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="message" size="11"/>
<color key="textColor" name="disabledControlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<imageView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="6000">
<rect key="frame" x="5" y="-2" width="101" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" animates="YES" imageAlignment="right" imageScaling="proportionallyDown" id="6001"/>
</imageView>
</subviews>
<point key="canvasLocation" x="-1323" y="644"/>
</customView>
<customView id="6885" userLabel="statusTable Accessory View">
<rect key="frame" x="0.0" y="0.0" width="360" height="157"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
Expand Down
2 changes: 0 additions & 2 deletions Source/Controllers/MainViewControllers/SPDatabaseDocument.h
Expand Up @@ -95,7 +95,6 @@

IBOutlet NSView *parentView;

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

Expand Down Expand Up @@ -409,7 +408,6 @@
- (void)setStatusIconToImageWithName:(NSString *)imagePath;
- (void)setTitlebarStatus:(NSString *)status;
- (void)clearStatusIcon;
- (void)updateTitlebarStatusVisibilityForcingHide:(BOOL)forceHide;

// Toolbar methods
- (void)updateWindowTitle:(id)sender;
Expand Down
58 changes: 1 addition & 57 deletions Source/Controllers/MainViewControllers/SPDatabaseDocument.m
Expand Up @@ -223,8 +223,6 @@ - (instancetype)initWithWindowController:(SPWindowController *)windowController
spfDocData = [[NSMutableDictionary alloc] init];
runningActivitiesArray = [[NSMutableArray alloc] init];

titleAccessoryView = nil;

taskProgressWindow = nil;
taskDisplayIsIndeterminate = YES;
taskDisplayLastValue = 0;
Expand Down Expand Up @@ -330,8 +328,6 @@ - (void)awakeFromNib
[taskProgressWindow setAlphaValue:0.0f];
[taskProgressWindow setContentView:taskProgressLayer];

[self updateTitlebarStatusVisibilityForcingHide:NO];

alterDatabaseCharsetHelper = [[SPCharsetCollationHelper alloc] initWithCharsetButton:databaseAlterEncodingButton CollationButton:databaseAlterCollationButton];
addDatabaseCharsetHelper = [[SPCharsetCollationHelper alloc] initWithCharsetButton:databaseEncodingButton CollationButton:databaseCollationButton];
}
Expand Down Expand Up @@ -3624,53 +3620,6 @@ - (void)clearStatusIcon
[titleImageView setImage:nil];
}

/**
* Update the title bar status area visibility. The status area is visible if the tab is
* frontmost in the window, and if the window is not fullscreen.
*/
- (void)updateTitlebarStatusVisibilityForcingHide:(BOOL)forceHide
{
BOOL newIsVisible = !forceHide;
if (newIsVisible && [[self.parentWindowController window] styleMask] & NSWindowStyleMaskFullScreen) newIsVisible = NO;
if (newIsVisible && [self.parentWindowController selectedTableDocument] != self) newIsVisible = NO;
if (newIsVisible == windowTitleStatusViewIsVisible) return;

if (newIsVisible) {
Class controllerClass;
if ((controllerClass = 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 = [[controllerClass alloc] init];
accessoryViewController.view = titleAccessoryView;
accessoryViewController.layoutAttribute = NSLayoutAttributeRight;
[[self.parentWindowController window] addTitlebarAccessoryViewController:accessoryViewController];
} else {
NSView *windowFrame = [[[self.parentWindowController window] 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 {
if (NSClassFromString(@"NSTitlebarAccessoryViewController")) { // OS X 10.11 and later
[[self.parentWindowController window].titlebarAccessoryViewControllers enumerateObjectsUsingBlock:^(__kindof NSTitlebarAccessoryViewController * _Nonnull accessoryViewController, NSUInteger idx, BOOL * _Nonnull stop) {
if (accessoryViewController.view == titleAccessoryView) {
[[self.parentWindowController window] removeTitlebarAccessoryViewControllerAtIndex:idx];
}
}];
} else {
[titleAccessoryView removeFromSuperview];
}
}

windowTitleStatusViewIsVisible = newIsVisible;
}

#pragma mark -
#pragma mark Toolbar Methods

Expand Down Expand Up @@ -4081,10 +4030,7 @@ - (void)parentTabDidClose
* window, but is being switched away from, to allow cleaning up
* details in the window.
*/
- (void)willResignActiveTabInWindow
{
[self updateTitlebarStatusVisibilityForcingHide:YES];

- (void)willResignActiveTabInWindow {
// Remove the task progress window
[[self.parentWindowController window] removeChildWindow:taskProgressWindow];
[taskProgressWindow orderOut:self];
Expand All @@ -4105,8 +4051,6 @@ - (void)didBecomeActiveTabInWindow
[self updateWindowTitle:self];
[[self.parentWindowController window] setRepresentedURL:(spfFileURL && [spfFileURL isFileURL] ? spfFileURL : nil)];

[self updateTitlebarStatusVisibilityForcingHide:NO];

// Add the progress window to this window
[self centerTaskWindow];
[[self.parentWindowController window] addChildWindow:taskProgressWindow ordered:NSWindowAbove];
Expand Down
2 changes: 0 additions & 2 deletions Source/Controllers/Window/SPWindowController.m
Expand Up @@ -579,15 +579,13 @@ - (void)windowDidResize:(NSNotification *)notification
*/
- (void)windowWillEnterFullScreen:(NSNotification *)notification
{
[self.selectedTableDocument updateTitlebarStatusVisibilityForcingHide:YES];
}

/**
* If the window exits fullscreen, update the front tab's titlebar status view visibility.
*/
- (void)windowDidExitFullScreen:(NSNotification *)notification
{
[self.selectedTableDocument updateTitlebarStatusVisibilityForcingHide:NO];
}

#pragma mark -
Expand Down

0 comments on commit 479f8a8

Please sign in to comment.