diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-06-12 12:34:18 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-06-12 12:34:18 +0000 |
commit | 16fc04e9bae49425540d623933946ec4dc933d6f (patch) | |
tree | b565bd5c6331ce3468f2ffaf1bb73a025f94f86c | |
parent | a7247b9f9098b40f170f6b2bcd28a4e934a02dc5 (diff) | |
download | sequelpro-16fc04e9bae49425540d623933946ec4dc933d6f.tar.gz sequelpro-16fc04e9bae49425540d623933946ec4dc933d6f.tar.bz2 sequelpro-16fc04e9bae49425540d623933946ec4dc933d6f.zip |
• added tooltip for tab view titles
- for selected tab view item show tooltip only if title is truncated
- for unselected tab view items show the full display title as tooltip
-rw-r--r-- | Source/SPWindowController.m | 44 |
1 files changed, 43 insertions, 1 deletions
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 @""; } |