aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPFavoritesOutlineView.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2012-10-06 11:48:15 +0000
committerrowanbeentje <rowan@beent.je>2012-10-06 11:48:15 +0000
commitecb5c70566d1303288e4faf170bda40672a799e1 (patch)
tree2882fa5fd6f25eed9c754e810785f5834225b95f /Source/SPFavoritesOutlineView.m
parentada181f6fe5b010a5ab56030d16b35e92e58af10 (diff)
downloadsequelpro-ecb5c70566d1303288e4faf170bda40672a799e1.tar.gz
sequelpro-ecb5c70566d1303288e4faf170bda40672a799e1.tar.bz2
sequelpro-ecb5c70566d1303288e4faf170bda40672a799e1.zip
Change the connection screen interface, particularly relating to favourite editing on the connection screen (Issue #1339, Issue #1440):
- No longer save changes made to connection favourites as soon as the interface is updated - Alter the interfaace if favourites are editing, offering to save the changes either to the old connection favourite or to a new favourite - Add a "Test connection" button to verify changes before saving - Add a "Quick Connect" entry to the top of the connection view's favourites list so a blank form is always available - Use a custom highlight when editing favourites to show the favourite has changed but is still linked - Reduce the margin on the left-hand side of the connection favourites list to increase the available space - Alter favourite name generation, making it less aggressive when generating names from partial details (eg creating names of just "@") and removing the user - Alter key icon usage to correctly update the button appearance if an SSL or SSH key is selected
Diffstat (limited to 'Source/SPFavoritesOutlineView.m')
-rw-r--r--Source/SPFavoritesOutlineView.m63
1 files changed, 63 insertions, 0 deletions
diff --git a/Source/SPFavoritesOutlineView.m b/Source/SPFavoritesOutlineView.m
index 883896ef..08880ec8 100644
--- a/Source/SPFavoritesOutlineView.m
+++ b/Source/SPFavoritesOutlineView.m
@@ -31,6 +31,9 @@
// More info at <http://code.google.com/p/sequel-pro/>
#import "SPFavoritesOutlineView.h"
+#import "SPConnectionControllerDelegate.h"
+
+static NSUInteger SPFavoritesOutlineViewUnindent = 14;
@implementation SPFavoritesOutlineView
@@ -88,4 +91,64 @@
}
}
+/**
+ * Don't reserve a gap for the disclosure triangles for top-level items. This involves reducing the
+ * padding - and increasing the width - of all rows to compensate.
+ */
+- (NSRect)frameOfCellAtColumn:(NSInteger)columnIndex row:(NSInteger)rowIndex
+{
+ NSRect superFrame = [super frameOfCellAtColumn:columnIndex row:rowIndex];
+
+ return NSMakeRect(superFrame.origin.x - SPFavoritesOutlineViewUnindent, superFrame.origin.y, superFrame.size.width + SPFavoritesOutlineViewUnindent, superFrame.size.height);
+}
+
+/**
+ * As no gap is reserved for the disclosure triangles at the top level, the frames for other
+ * disclosure items need to be similarly moved.
+ */
+- (NSRect)frameOfOutlineCellAtRow:(NSInteger)rowIndex
+{
+ NSRect superFrame = [super frameOfOutlineCellAtRow:rowIndex];
+
+ if (superFrame.origin.x > SPFavoritesOutlineViewUnindent) {
+ return NSMakeRect(superFrame.origin.x - SPFavoritesOutlineViewUnindent, superFrame.origin.y, superFrame.size.width, superFrame.size.height);
+ }
+
+ return superFrame;
+}
+
+
+/**
+ * If the delegate is a SPConnectionControllerDelegate, and editing is currently in
+ * progress, draw a custom highlight.
+ */
+- (void)highlightSelectionInClipRect:(NSRect)clipRect
+{
+
+ // Only proceed if a the delegate is a SPConnectionControllerDelegate and a favoruite being edited
+ if ([[self delegate] isKindOfClass:[SPConnectionController class]]
+ && [(SPConnectionController *)[self delegate] isEditingConnection]
+ && [(SPConnectionController *)[self delegate] selectedFavorite])
+ {
+
+ // Draw an editing dot instead of highlighting the whole row
+ NSRect rowRect = [self rectOfRow:[self selectedRow]];
+ float dotSize = rowRect.size.height / 1.9;
+ NSRect dotRect = NSMakeRect(9.f, rowRect.origin.y + ((rowRect.size.height - dotSize) / 2), dotSize, dotSize);
+ [NSGraphicsContext saveGraphicsState];
+
+ NSBezierPath *clipPath = [NSBezierPath bezierPath];
+ [clipPath appendBezierPathWithOvalInRect:dotRect];
+ [clipPath addClip];
+
+ NSGradient *dotGradient = [[[NSGradient alloc] initWithStartingColor:[NSColor colorWithDeviceRed:0.44f green:0.72f blue:0.92f alpha:1.f] endingColor:[NSColor colorWithDeviceRed:0.21f green:0.53f blue:0.82f alpha:1.f]] autorelease];
+ [dotGradient drawInRect:dotRect angle:90.f];
+
+ [NSGraphicsContext restoreGraphicsState];
+ return;
+ }
+
+ [super highlightSelectionInClipRect:clipRect];
+}
+
@end