OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/cocoa/tabs/tab_controller.h" | 5 #import "chrome/browser/ui/cocoa/tabs/tab_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 TabController* owner_; // weak, owns me | 64 TabController* owner_; // weak, owns me |
65 }; | 65 }; |
66 | 66 |
67 } // TabControllerInternal namespace | 67 } // TabControllerInternal namespace |
68 | 68 |
69 // The min widths is the smallest number at which the right edge of the right | 69 // The min widths is the smallest number at which the right edge of the right |
70 // tab border image is not visibly clipped. It is a bit smaller than the sum | 70 // tab border image is not visibly clipped. It is a bit smaller than the sum |
71 // of the two tab edge bitmaps because these bitmaps have a few transparent | 71 // of the two tab edge bitmaps because these bitmaps have a few transparent |
72 // pixels on the side. The selected tab width includes the close button width. | 72 // pixels on the side. The selected tab width includes the close button width. |
73 + (CGFloat)minTabWidth { return 36; } | 73 + (CGFloat)minTabWidth { return 36; } |
74 + (CGFloat)minSelectedTabWidth { return 52; } | 74 + (CGFloat)minActiveTabWidth { return 52; } |
75 + (CGFloat)maxTabWidth { return 214; } | 75 + (CGFloat)maxTabWidth { return 214; } |
76 + (CGFloat)miniTabWidth { return 58; } | 76 + (CGFloat)miniTabWidth { return 58; } |
77 + (CGFloat)appTabWidth { return 66; } | 77 + (CGFloat)appTabWidth { return 66; } |
78 | 78 |
79 - (TabView*)tabView { | 79 - (TabView*)tabView { |
80 DCHECK([[self view] isKindOfClass:[TabView class]]); | 80 DCHECK([[self view] isKindOfClass:[TabView class]]); |
81 return static_cast<TabView*>([self view]); | 81 return static_cast<TabView*>([self view]); |
82 } | 82 } |
83 | 83 |
84 - (id)init { | 84 - (id)init { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 } | 180 } |
181 } | 181 } |
182 | 182 |
183 - (void)setTitle:(NSString*)title { | 183 - (void)setTitle:(NSString*)title { |
184 if ([[self title] isEqualToString:title]) | 184 if ([[self title] isEqualToString:title]) |
185 return; | 185 return; |
186 | 186 |
187 TabView* tabView = [self tabView]; | 187 TabView* tabView = [self tabView]; |
188 [tabView setTitle:title]; | 188 [tabView setTitle:title]; |
189 | 189 |
190 if ([self mini] && ![self selected]) { | 190 if ([self mini] && ![self active]) { |
191 [tabView startAlert]; | 191 [tabView startAlert]; |
192 } | 192 } |
193 [super setTitle:title]; | 193 [super setTitle:title]; |
194 } | 194 } |
195 | 195 |
196 - (void)setToolTip:(NSString*)toolTip { | 196 - (void)setToolTip:(NSString*)toolTip { |
197 [[self view] setToolTip:toolTip]; | 197 [[self view] setToolTip:toolTip]; |
198 } | 198 } |
199 | 199 |
200 - (void)setActive:(BOOL)active { | 200 - (void)setActive:(BOOL)active { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 const int kPaddingBetweenIcons = 2; | 266 const int kPaddingBetweenIcons = 2; |
267 if (availableWidth >= widthPerIcon && | 267 if (availableWidth >= widthPerIcon && |
268 availableWidth < (widthPerIcon + kPaddingBetweenIcons)) { | 268 availableWidth < (widthPerIcon + kPaddingBetweenIcons)) { |
269 return 1; | 269 return 1; |
270 } | 270 } |
271 return availableWidth / (widthPerIcon + kPaddingBetweenIcons); | 271 return availableWidth / (widthPerIcon + kPaddingBetweenIcons); |
272 } | 272 } |
273 | 273 |
274 - (BOOL)shouldShowIcon { | 274 - (BOOL)shouldShowIcon { |
275 return chrome::ShouldTabShowFavicon( | 275 return chrome::ShouldTabShowFavicon( |
276 [self iconCapacity], [self mini], [self selected], iconView_ != nil, | 276 [self iconCapacity], [self mini], [self active], iconView_ != nil, |
277 !mediaIndicatorView_ ? TAB_MEDIA_STATE_NONE : | 277 !mediaIndicatorView_ ? TAB_MEDIA_STATE_NONE : |
278 [mediaIndicatorView_ animatingMediaState]); | 278 [mediaIndicatorView_ animatingMediaState]); |
279 } | 279 } |
280 | 280 |
281 - (BOOL)shouldShowMediaIndicator { | 281 - (BOOL)shouldShowMediaIndicator { |
282 if (!mediaIndicatorView_) | 282 if (!mediaIndicatorView_) |
283 return NO; | 283 return NO; |
284 return chrome::ShouldTabShowMediaIndicator( | 284 return chrome::ShouldTabShowMediaIndicator( |
285 [self iconCapacity], [self mini], [self selected], iconView_ != nil, | 285 [self iconCapacity], [self mini], [self active], iconView_ != nil, |
286 [mediaIndicatorView_ animatingMediaState]); | 286 [mediaIndicatorView_ animatingMediaState]); |
287 } | 287 } |
288 | 288 |
289 - (BOOL)shouldShowCloseButton { | 289 - (BOOL)shouldShowCloseButton { |
290 return chrome::ShouldTabShowCloseButton( | 290 return chrome::ShouldTabShowCloseButton( |
291 [self iconCapacity], [self mini], [self selected]); | 291 [self iconCapacity], [self mini], [self active]); |
292 } | 292 } |
293 | 293 |
294 - (void)setIconImage:(NSImage*)image { | 294 - (void)setIconImage:(NSImage*)image { |
295 [self setIconImage:image withToastAnimation:NO]; | 295 [self setIconImage:image withToastAnimation:NO]; |
296 } | 296 } |
297 | 297 |
298 - (void)setIconImage:(NSImage*)image withToastAnimation:(BOOL)animate { | 298 - (void)setIconImage:(NSImage*)image withToastAnimation:(BOOL)animate { |
299 if (image == nil) { | 299 if (image == nil) { |
300 [self setIconView:nil]; | 300 [self setIconView:nil]; |
301 } else { | 301 } else { |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 // TabStripDragController. | 427 // TabStripDragController. |
428 - (BOOL)tabCanBeDragged:(TabController*)controller { | 428 - (BOOL)tabCanBeDragged:(TabController*)controller { |
429 return [[target_ dragController] tabCanBeDragged:controller]; | 429 return [[target_ dragController] tabCanBeDragged:controller]; |
430 } | 430 } |
431 | 431 |
432 - (void)maybeStartDrag:(NSEvent*)event forTab:(TabController*)tab { | 432 - (void)maybeStartDrag:(NSEvent*)event forTab:(TabController*)tab { |
433 [[target_ dragController] maybeStartDrag:event forTab:tab]; | 433 [[target_ dragController] maybeStartDrag:event forTab:tab]; |
434 } | 434 } |
435 | 435 |
436 @end | 436 @end |
OLD | NEW |