| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "chrome/browser/cocoa/tab_strip_controller.h" | 5 #import "chrome/browser/cocoa/tab_strip_controller.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/mac_util.h" | 8 #include "base/mac_util.h" |
| 9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
| 10 #include "chrome/app/chrome_dll_resource.h" | 10 #include "chrome/app/chrome_dll_resource.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 #include "chrome/browser/tabs/tab_strip_model.h" | 30 #include "chrome/browser/tabs/tab_strip_model.h" |
| 31 #include "grit/generated_resources.h" | 31 #include "grit/generated_resources.h" |
| 32 #include "skia/ext/skia_utils_mac.h" | 32 #include "skia/ext/skia_utils_mac.h" |
| 33 | 33 |
| 34 NSString* const kTabStripNumberOfTabsChanged = @"kTabStripNumberOfTabsChanged"; | 34 NSString* const kTabStripNumberOfTabsChanged = @"kTabStripNumberOfTabsChanged"; |
| 35 | 35 |
| 36 // A value to indicate tab layout should use the full available width of the | 36 // A value to indicate tab layout should use the full available width of the |
| 37 // view. | 37 // view. |
| 38 static const float kUseFullAvailableWidth = -1.0; | 38 static const float kUseFullAvailableWidth = -1.0; |
| 39 | 39 |
| 40 // Left-side indent for tab layout so tabs don't overlap with the window |
| 41 // controls. |
| 42 static const float kIndentLeavingSpaceForControls = 64.0; |
| 43 |
| 40 // A simple view class that prevents the Window Server from dragging the area | 44 // A simple view class that prevents the Window Server from dragging the area |
| 41 // behind tabs. Sometimes core animation confuses it. Unfortunately, it can also | 45 // behind tabs. Sometimes core animation confuses it. Unfortunately, it can also |
| 42 // falsely pick up clicks during rapid tab closure, so we have to account for | 46 // falsely pick up clicks during rapid tab closure, so we have to account for |
| 43 // that. | 47 // that. |
| 44 @interface TabStripControllerDragBlockingView : NSView { | 48 @interface TabStripControllerDragBlockingView : NSView { |
| 45 TabStripController* controller_; // weak; owns us | 49 TabStripController* controller_; // weak; owns us |
| 46 } | 50 } |
| 47 | 51 |
| 48 - (id)initWithFrame:(NSRect)frameRect | 52 - (id)initWithFrame:(NSRect)frameRect |
| 49 controller:(TabStripController*)controller; | 53 controller:(TabStripController*)controller; |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 | 318 |
| 315 - (void)insertPlaceholderForTab:(TabView*)tab | 319 - (void)insertPlaceholderForTab:(TabView*)tab |
| 316 frame:(NSRect)frame | 320 frame:(NSRect)frame |
| 317 yStretchiness:(CGFloat)yStretchiness { | 321 yStretchiness:(CGFloat)yStretchiness { |
| 318 placeholderTab_ = tab; | 322 placeholderTab_ = tab; |
| 319 placeholderFrame_ = frame; | 323 placeholderFrame_ = frame; |
| 320 placeholderStretchiness_ = yStretchiness; | 324 placeholderStretchiness_ = yStretchiness; |
| 321 [self layoutTabs]; | 325 [self layoutTabs]; |
| 322 } | 326 } |
| 323 | 327 |
| 328 - (BOOL)isTabFullyVisible:(TabView*)tab { |
| 329 NSRect frame = [tab frame]; |
| 330 return NSMinX(frame) >= kIndentLeavingSpaceForControls && |
| 331 NSMaxX(frame) <= NSMaxX([tabView_ frame]); |
| 332 } |
| 333 |
| 324 - (void)showNewTabButton:(BOOL)show { | 334 - (void)showNewTabButton:(BOOL)show { |
| 325 forceNewTabButtonHidden_ = show ? NO : YES; | 335 forceNewTabButtonHidden_ = show ? NO : YES; |
| 326 if (forceNewTabButtonHidden_) | 336 if (forceNewTabButtonHidden_) |
| 327 [newTabButton_ setHidden:YES]; | 337 [newTabButton_ setHidden:YES]; |
| 328 } | 338 } |
| 329 | 339 |
| 330 // Lay out all tabs in the order of their TabContentsControllers, which matches | 340 // Lay out all tabs in the order of their TabContentsControllers, which matches |
| 331 // the ordering in the TabStripModel. This call isn't that expensive, though | 341 // the ordering in the TabStripModel. This call isn't that expensive, though |
| 332 // it is O(n) in the number of tabs. Tabs will animate to their new position | 342 // it is O(n) in the number of tabs. Tabs will animate to their new position |
| 333 // if the window is visible and |animate| is YES. | 343 // if the window is visible and |animate| is YES. |
| 334 // TODO(pinkerton): Handle drag placeholders via proxy objects, perhaps a | 344 // TODO(pinkerton): Handle drag placeholders via proxy objects, perhaps a |
| 335 // subclass of TabContentsController with everything stubbed out or by | 345 // subclass of TabContentsController with everything stubbed out or by |
| 336 // abstracting a base class interface. | 346 // abstracting a base class interface. |
| 337 // TODO(pinkerton): Note this doesn't do too well when the number of min-sized | 347 // TODO(pinkerton): Note this doesn't do too well when the number of min-sized |
| 338 // tabs would cause an overflow. | 348 // tabs would cause an overflow. |
| 339 - (void)layoutTabsWithAnimation:(BOOL)animate | 349 - (void)layoutTabsWithAnimation:(BOOL)animate |
| 340 regenerateSubviews:(BOOL)doUpdate { | 350 regenerateSubviews:(BOOL)doUpdate { |
| 341 const float kIndentLeavingSpaceForControls = 64.0; | |
| 342 const float kTabOverlap = 20.0; | 351 const float kTabOverlap = 20.0; |
| 343 const float kNewTabButtonOffset = 8.0; | 352 const float kNewTabButtonOffset = 8.0; |
| 344 const float kMaxTabWidth = [TabController maxTabWidth]; | 353 const float kMaxTabWidth = [TabController maxTabWidth]; |
| 345 const float kMinTabWidth = [TabController minTabWidth]; | 354 const float kMinTabWidth = [TabController minTabWidth]; |
| 346 const float kMinSelectedTabWidth = [TabController minSelectedTabWidth]; | 355 const float kMinSelectedTabWidth = [TabController minSelectedTabWidth]; |
| 347 | 356 |
| 348 NSRect enclosingRect = NSZeroRect; | 357 NSRect enclosingRect = NSZeroRect; |
| 349 [NSAnimationContext beginGrouping]; | 358 [NSAnimationContext beginGrouping]; |
| 350 [[NSAnimationContext currentContext] setDuration:0.2]; | 359 [[NSAnimationContext currentContext] setDuration:0.2]; |
| 351 | 360 |
| (...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 955 BrowserWindowController* controller = | 964 BrowserWindowController* controller = |
| 956 (BrowserWindowController*)[[switchView_ window] windowController]; | 965 (BrowserWindowController*)[[switchView_ window] windowController]; |
| 957 DCHECK(index >= 0); | 966 DCHECK(index >= 0); |
| 958 if (index >= 0) { | 967 if (index >= 0) { |
| 959 [controller setTab:[self viewAtIndex:index] isDraggable:YES]; | 968 [controller setTab:[self viewAtIndex:index] isDraggable:YES]; |
| 960 } | 969 } |
| 961 } | 970 } |
| 962 | 971 |
| 963 | 972 |
| 964 @end | 973 @end |
| OLD | NEW |