diff options
author | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-09 21:16:22 +0000 |
---|---|---|
committer | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-09 21:16:22 +0000 |
commit | 9343914ea1812ea24afd00724f6a38bf60b2f67c (patch) | |
tree | ac3dea451124cee01569b713ccda7c5662649af2 | |
parent | 98324891649cf5fa7430c2e231ad5493fdb76c8e (diff) | |
download | chromium_src-9343914ea1812ea24afd00724f6a38bf60b2f67c.zip chromium_src-9343914ea1812ea24afd00724f6a38bf60b2f67c.tar.gz chromium_src-9343914ea1812ea24afd00724f6a38bf60b2f67c.tar.bz2 |
Start a drag if the tab is dragged off the sides of the window.
BUG=14926
TEST=drag tabs and make sure nothing breaks.
Review URL: http://codereview.chromium.org/195043
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25787 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/cocoa/browser_window_controller.mm | 4 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_strip_controller.h | 6 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_strip_controller.mm | 11 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_view.mm | 7 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_window_controller.h | 6 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_window_controller.mm | 5 |
6 files changed, 36 insertions, 3 deletions
diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm index 8971cea..3c7b6e8 100644 --- a/chrome/browser/cocoa/browser_window_controller.mm +++ b/chrome/browser/cocoa/browser_window_controller.mm @@ -817,6 +817,10 @@ willPositionSheet:(NSWindow*)sheet yStretchiness:0]; } +- (BOOL)isTabFullyVisible:(TabView*)tab { + return [tabStripController_ isTabFullyVisible:tab]; +} + - (void)showNewTabButton:(BOOL)show { [tabStripController_ showNewTabButton:show]; } diff --git a/chrome/browser/cocoa/tab_strip_controller.h b/chrome/browser/cocoa/tab_strip_controller.h index e1778b5..e9f0625 100644 --- a/chrome/browser/cocoa/tab_strip_controller.h +++ b/chrome/browser/cocoa/tab_strip_controller.h @@ -120,6 +120,12 @@ class ToolbarModel; frame:(NSRect)frame yStretchiness:(CGFloat)yStretchiness; +// Returns whether or not |tab| can still be fully seen in the tab strip or if +// its current position would cause it be obscured by things such as the edge +// of the window or the window decorations. Returns YES only if the entire tab +// is visible. +- (BOOL)isTabFullyVisible:(TabView*)tab; + // Show or hide the new tab button. The button is hidden immediately, but // waits until the next call to |-layoutTabs| to show it again. - (void)showNewTabButton:(BOOL)show; diff --git a/chrome/browser/cocoa/tab_strip_controller.mm b/chrome/browser/cocoa/tab_strip_controller.mm index 2035cdc..0a2c79b 100644 --- a/chrome/browser/cocoa/tab_strip_controller.mm +++ b/chrome/browser/cocoa/tab_strip_controller.mm @@ -37,6 +37,10 @@ NSString* const kTabStripNumberOfTabsChanged = @"kTabStripNumberOfTabsChanged"; // view. static const float kUseFullAvailableWidth = -1.0; +// Left-side indent for tab layout so tabs don't overlap with the window +// controls. +static const float kIndentLeavingSpaceForControls = 64.0; + // A simple view class that prevents the Window Server from dragging the area // behind tabs. Sometimes core animation confuses it. Unfortunately, it can also // falsely pick up clicks during rapid tab closure, so we have to account for @@ -321,6 +325,12 @@ static const float kUseFullAvailableWidth = -1.0; [self layoutTabs]; } +- (BOOL)isTabFullyVisible:(TabView*)tab { + NSRect frame = [tab frame]; + return NSMinX(frame) >= kIndentLeavingSpaceForControls && + NSMaxX(frame) <= NSMaxX([tabView_ frame]); +} + - (void)showNewTabButton:(BOOL)show { forceNewTabButtonHidden_ = show ? NO : YES; if (forceNewTabButtonHidden_) @@ -338,7 +348,6 @@ static const float kUseFullAvailableWidth = -1.0; // tabs would cause an overflow. - (void)layoutTabsWithAnimation:(BOOL)animate regenerateSubviews:(BOOL)doUpdate { - const float kIndentLeavingSpaceForControls = 64.0; const float kTabOverlap = 20.0; const float kNewTabButtonOffset = 8.0; const float kMaxTabWidth = [TabController maxTabWidth]; diff --git a/chrome/browser/cocoa/tab_view.mm b/chrome/browser/cocoa/tab_view.mm index 351882c..a277627 100644 --- a/chrome/browser/cocoa/tab_view.mm +++ b/chrome/browser/cocoa/tab_view.mm @@ -267,9 +267,12 @@ static const CGFloat kRapidCloseDist = 2.5; frame:NSOffsetRect(sourceTabFrame_, offset, 0) yStretchiness:stretchiness]; - + // Check that we haven't pulled the tab too far to start a drag. This + // can include either pulling it too far down, or off the side of the tab + // strip that would cause it to no longer be fully visible. + BOOL stillVisible = [sourceController_ isTabFullyVisible:self]; CGFloat tearForce = fabs(thisPoint.y - dragOrigin_.y); - if (tearForce > kTearDistance) { + if (tearForce > kTearDistance || !stillVisible) { draggingWithinTabStrip_ = NO; // When you finally leave the strip, we treat that as the origin. dragOrigin_.x = thisPoint.x; diff --git a/chrome/browser/cocoa/tab_window_controller.h b/chrome/browser/cocoa/tab_window_controller.h index 4c0f07a..76dfdc4 100644 --- a/chrome/browser/cocoa/tab_window_controller.h +++ b/chrome/browser/cocoa/tab_window_controller.h @@ -73,6 +73,12 @@ // waits until the next call to |-layoutTabs| to show it again. - (void)showNewTabButton:(BOOL)show; +// Returns whether or not |tab| can still be fully seen in the tab strip or if +// its current position would cause it be obscured by things such as the edge +// of the window or the window decorations. Returns YES only if the entire tab +// is visible. The default implementation always returns YES. +- (BOOL)isTabFullyVisible:(TabView*)tab; + // Called to check if the receiver can receive dragged tabs from // source. Return YES if so. The default implementation returns NO. - (BOOL)canReceiveFrom:(TabWindowController*)source; diff --git a/chrome/browser/cocoa/tab_window_controller.mm b/chrome/browser/cocoa/tab_window_controller.mm index 7684f13..5e9ce23 100644 --- a/chrome/browser/cocoa/tab_window_controller.mm +++ b/chrome/browser/cocoa/tab_window_controller.mm @@ -155,6 +155,11 @@ [self showNewTabButton:YES]; } +- (BOOL)isTabFullyVisible:(TabView*)tab { + // Subclasses should implement this, but it's not necessary. + return YES; +} + - (void)showNewTabButton:(BOOL)show { // subclass must implement NOTIMPLEMENTED(); |