summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/tab_strip_view.mm
diff options
context:
space:
mode:
authorpinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-23 16:37:13 +0000
committerpinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-23 16:37:13 +0000
commit52a63f4d1c139345fb3fe0bc294ab27abfcd6db8 (patch)
tree033fe46019059f06d7b14990f45350543d713a84 /chrome/browser/cocoa/tab_strip_view.mm
parentf15a3b036835167385507265692b626969b305f1 (diff)
downloadchromium_src-52a63f4d1c139345fb3fe0bc294ab27abfcd6db8.zip
chromium_src-52a63f4d1c139345fb3fe0bc294ab27abfcd6db8.tar.gz
chromium_src-52a63f4d1c139345fb3fe0bc294ab27abfcd6db8.tar.bz2
Implement side tab view and controller and hook up their creation. Parameterize tab strip layout so it can be vertical in addition to horizontal without breaking up the code too much. Abstracted some of the side tab knowledge into TabWindowController with overrides in BrowserWindowController.
Nib change: added a SideTabStripView custom view to BrowserWindow and hooked it to an outlet. Renamed the outlets to better reflect both views. BUG=44773 TEST=Tab layout, full screen, dragging tabs within and to other windows to make sure they reflow and draw correctly. Side tabs themselves are still behind a flag, but this cl touches many normal codepaths. Review URL: http://codereview.chromium.org/2846028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50606 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/tab_strip_view.mm')
-rw-r--r--chrome/browser/cocoa/tab_strip_view.mm35
1 files changed, 26 insertions, 9 deletions
diff --git a/chrome/browser/cocoa/tab_strip_view.mm b/chrome/browser/cocoa/tab_strip_view.mm
index 25ed090..5149dbf 100644
--- a/chrome/browser/cocoa/tab_strip_view.mm
+++ b/chrome/browser/cocoa/tab_strip_view.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -28,21 +28,26 @@
return self;
}
-- (void)drawRect:(NSRect)rect {
- NSRect boundsRect = [self bounds];
+// Draw bottom border (a dark border and light highlight). Each tab is
+// responsible for mimicing this bottom border, unless it's the selected
+// tab.
+- (void)drawBorder:(NSRect)bounds {
NSRect borderRect, contentRect;
- // Draw bottom border (a dark border and light highlight). Each tab is
- // responsible for mimicing this bottom border, unless it's the selected
- // tab.
- borderRect = boundsRect;
+ borderRect = bounds;
borderRect.origin.y = 1;
borderRect.size.height = 1;
[[NSColor colorWithCalibratedWhite:0.0 alpha:0.2] set];
NSRectFillUsingOperation(borderRect, NSCompositeSourceOver);
- NSDivideRect(boundsRect, &borderRect, &contentRect, 1, NSMinYEdge);
+ NSDivideRect(bounds, &borderRect, &contentRect, 1, NSMinYEdge);
[[NSColor colorWithCalibratedWhite:0.96 alpha:1.0] set];
NSRectFillUsingOperation(borderRect, NSCompositeSourceOver);
+}
+
+- (void)drawRect:(NSRect)rect {
+ NSRect boundsRect = [self bounds];
+
+ [self drawBorder:boundsRect];
// Draw drop-indicator arrow (if appropriate).
// TODO(viettrungluu): this is all a stop-gap measure.
@@ -70,7 +75,7 @@
// Height we have to work with (insetting on the top).
CGFloat availableHeight =
- NSMaxY([self bounds]) - arrowTipPos.y - kArrowTopInset;
+ NSMaxY(boundsRect) - arrowTipPos.y - kArrowTopInset;
DCHECK(availableHeight >= 5);
// Based on the knobs above, calculate actual dimensions which we'll need
@@ -104,6 +109,12 @@
}
}
+// YES if a double-click in the background of the tab strip minimizes the
+// window.
+- (BOOL)doubleClickMinimizesWindow {
+ return YES;
+}
+
// We accept first mouse so clicks onto close/zoom/miniaturize buttons and
// title bar double-clicks are properly detected even when the window is in the
// background.
@@ -113,6 +124,12 @@
// Trap double-clicks and make them miniaturize the browser window.
- (void)mouseUp:(NSEvent*)event {
+ // Bail early if double-clicks are disabled.
+ if (![self doubleClickMinimizesWindow]) {
+ [super mouseUp:event];
+ return;
+ }
+
NSInteger clickCount = [event clickCount];
NSTimeInterval timestamp = [event timestamp];