aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/PSMTabBar/PSMTabBarControl.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2010-06-30 23:44:55 +0000
committerrowanbeentje <rowan@beent.je>2010-06-30 23:44:55 +0000
commit219afc56c02b508fbb6d706dfed4e1a1ccc949d4 (patch)
treede4e473de2a5fd1063c671733a5f7552e6080ba0 /Frameworks/PSMTabBar/PSMTabBarControl.m
parentba332e64c29622e0b69412cb2fea639182ac1d1c (diff)
downloadsequelpro-219afc56c02b508fbb6d706dfed4e1a1ccc949d4.tar.gz
sequelpro-219afc56c02b508fbb6d706dfed4e1a1ccc949d4.tar.bz2
sequelpro-219afc56c02b508fbb6d706dfed4e1a1ccc949d4.zip
Improve tab functionality, behaviour and interaction.
PSMTabBar general improvements: - Fix a phantom tab appearing in windows a tab was just dragged out of - Add support for a new control usersSafariStyleDragging property; this causes tabs being dragged inside a tab bar to snap to the tab bar, be drawn at full transparency (also no longer darkening the placeholder position), and alters tab ordering within the tab bar to be based on the tab position rather than the mouse position, for a more Mac-like reordering feel. - Add support for dragging items onto the menubar to cancel the drag - Alter the image of the dragged tab to use a tab drawn onto a transparent background instead of snapshotting a rectangle around the tab, improving drag appearance - Allow tabs to be dragged partially off screen and keep their position instead of snapping back fully onto the screen - Improve behaviour when dragging tabs out of and back into tab bars, or into new windows, resizing the tabs in the target tab bar to improve display and no longer intermittently showing close buttons while dragging - Pull windows to the front as tabs are dragged onto their tab bars - Abstract Custom Query Editor text snippet code, adding a delegate method so code could be moved to the SP window manager. Sequel Pro tab styling improvements: - Improve and clean up tab drawing code - Draw background tabs with shadows as appropriate - Improve logic for how background tab edges are drawn, handling edges cases better (active tab in overflow menu etc) and vastly improving drawing when a tab is being dragged (respect placeholder position when stacking tabs, draw edges on either side) Sequel Pro tab behaviour improvements: - Improve show/hide tab bar interaction - Improve window positioning after creating new windows via a drag - Alter tab dragging out of the tab bar to use an image based on the full window appearance - looks better, and fixes issues like the tab bar background not being drawn while dragging
Diffstat (limited to 'Frameworks/PSMTabBar/PSMTabBarControl.m')
-rw-r--r--Frameworks/PSMTabBar/PSMTabBarControl.m35
1 files changed, 28 insertions, 7 deletions
diff --git a/Frameworks/PSMTabBar/PSMTabBarControl.m b/Frameworks/PSMTabBar/PSMTabBarControl.m
index d361364e..6753bc08 100644
--- a/Frameworks/PSMTabBar/PSMTabBarControl.m
+++ b/Frameworks/PSMTabBar/PSMTabBarControl.m
@@ -137,6 +137,7 @@
_selectsTabsOnMouseDown = NO;
_alwaysShowActiveTab = NO;
_allowsScrubbing = NO;
+ _useSafariStyleDragging = NO;
_cellMinWidth = 100;
_cellMaxWidth = 280;
_cellOptimumWidth = 130;
@@ -594,6 +595,16 @@
_allowsScrubbing = value;
}
+- (BOOL)usesSafariStyleDragging
+{
+ return _useSafariStyleDragging;
+}
+
+- (void)setUsesSafariStyleDragging:(BOOL)value
+{
+ _useSafariStyleDragging = value;
+}
+
- (PSMTabBarTearOffStyle)tearOffStyle
{
return _tearOffStyle;
@@ -1002,8 +1013,9 @@
- (void)update:(BOOL)animate
{
- // make sure all of our tabs are accounted for before updating
- if ([[self tabView] numberOfTabViewItems] != [_cells count]) {
+ // make sure all of our tabs are accounted for before updating,
+ // or only proceed if a drag is in progress (where counts may mismatch)
+ if ([[self tabView] numberOfTabViewItems] != [_cells count] && ![[PSMTabDragAssistant sharedDragAssistant] isDragging]) {
return;
}
@@ -1163,11 +1175,18 @@
- (void)_setupTrackingRectsForCell:(PSMTabBarCell *)cell
{
+
+ // Skip tracking rects for placeholders - not required.
+ if ([cell isPlaceholder]) return;
+
NSInteger tag, index = [_cells indexOfObject:cell];
NSRect cellTrackingRect = [_controller cellTrackingRectAtIndex:index];
NSPoint mousePoint = [self convertPoint:[[self window] mouseLocationOutsideOfEventStream] fromView:nil];
BOOL mouseInCell = NSMouseInRect(mousePoint, cellTrackingRect, [self isFlipped]);
-
+
+ // If dragging, suppress mouse interaction
+ if ([[PSMTabDragAssistant sharedDragAssistant] isDragging]) mouseInCell = NO;
+
//set the cell tracking rect
[self removeTrackingRect:[cell cellTrackingTag]];
tag = [self addTrackingRect:cellTrackingRect owner:cell userData:nil assumeInside:mouseInCell];
@@ -1496,10 +1515,12 @@
userInfo:sender
repeats:NO] retain];
}
- //If user drags a text string to a tab switch to Custom Query Editor
- if (![[[cell representedObject] identifier] isCustomQuerySelected]
- && [[[sender draggingPasteboard] types] indexOfObject:NSStringPboardType] != NSNotFound) {
- [[[cell representedObject] identifier] performSelector:@selector(viewQuery:) withObject:nil];
+
+ // Notify the delegate to respond to drag events if supported. This allows custom
+ // behaviour when dragging certain drag types onto the tab - for example changing the
+ // view appropriately.
+ if ([self delegate] && [[self delegate] respondsToSelector:@selector(draggingEvent:enteredTabBar:tabView:)]) {
+ [[self delegate] draggingEvent:sender enteredTabBar:self tabView:[cell representedObject]];
}
}
return NSDragOperationCopy;