From 16fc04e9bae49425540d623933946ec4dc933d6f Mon Sep 17 00:00:00 2001 From: Bibiko Date: Sat, 12 Jun 2010 12:34:18 +0000 Subject: =?UTF-8?q?=E2=80=A2=20added=20tooltip=20for=20tab=20view=20titles?= =?UTF-8?q?=20-=20for=20selected=20tab=20view=20item=20show=20tooltip=20on?= =?UTF-8?q?ly=20if=20title=20is=20truncated=20-=20for=20unselected=20tab?= =?UTF-8?q?=20view=20items=20show=20the=20full=20display=20title=20as=20to?= =?UTF-8?q?oltip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPWindowController.m | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'Source/SPWindowController.m') diff --git a/Source/SPWindowController.m b/Source/SPWindowController.m index a19bcd08..23b1bc9b 100644 --- a/Source/SPWindowController.m +++ b/Source/SPWindowController.m @@ -281,7 +281,49 @@ */ - (NSString *)tabView:(NSTabView *)aTabView toolTipForTabViewItem:(NSTabViewItem *)tabViewItem { - // Not yet implemented + PSMTabBarCell *theCell = [[tabBar cells] objectAtIndex:[tabView indexOfTabViewItem:tabViewItem]]; + + // If cell is selected show tooltip if truncated only + if([theCell tabState] & PSMTab_SelectedMask) { + + CGFloat cellWidth = [theCell width]; + CGFloat titleWidth = [theCell stringSize].width; + CGFloat closeButtonWidth = 0; + + if([theCell hasCloseButton]) + closeButtonWidth = [theCell closeButtonRectForFrame:[theCell frame]].size.width; + + if(titleWidth > cellWidth - closeButtonWidth) + return [theCell title]; + + return @""; + + // if cell is not selected show full title as tooltip + } else { + SPDatabaseDocument *doc = [tabViewItem identifier]; + NSMutableString *tabTitle; + + // Determine name details + NSString *pathName = @""; + if ([[[doc fileURL] path] length] && ![doc isUntitled]) + pathName = [NSString stringWithFormat:@"%@ — ", [[[doc fileURL] path] lastPathComponent]]; + + if ([doc getConnection] == nil) + return [NSString stringWithFormat:@"%@%@", pathName, @"Sequel Pro"]; + + tabTitle = [NSMutableString string]; + [tabTitle appendString:[doc name]]; + if ([doc database]) { + if ([tabTitle length]) [tabTitle appendString:@"/"]; + [tabTitle appendString:[doc database]]; + } + if ([[doc table] length]) { + if ([tabTitle length]) [tabTitle appendString:@"/"]; + [tabTitle appendString:[doc table]]; + } + return tabTitle; + } + return @""; } -- cgit v1.2.3