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_view.h" | 5 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" |
6 | 6 |
7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/mac/sdk_forward_declarations.h" | 9 #include "base/mac/sdk_forward_declarations.h" |
10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 const NSTimeInterval kHoverHoldDuration = 0.02; | 40 const NSTimeInterval kHoverHoldDuration = 0.02; |
41 const NSTimeInterval kHoverHideDuration = 0.4; | 41 const NSTimeInterval kHoverHideDuration = 0.4; |
42 const NSTimeInterval kAlertShowDuration = 0.4; | 42 const NSTimeInterval kAlertShowDuration = 0.4; |
43 const NSTimeInterval kAlertHoldDuration = 0.4; | 43 const NSTimeInterval kAlertHoldDuration = 0.4; |
44 const NSTimeInterval kAlertHideDuration = 0.4; | 44 const NSTimeInterval kAlertHideDuration = 0.4; |
45 | 45 |
46 // The default time interval in seconds between glow updates (when | 46 // The default time interval in seconds between glow updates (when |
47 // increasing/decreasing). | 47 // increasing/decreasing). |
48 const NSTimeInterval kGlowUpdateInterval = 0.025; | 48 const NSTimeInterval kGlowUpdateInterval = 0.025; |
49 | 49 |
| 50 // The intensity of the white overlay when hovering the mouse over a tab. |
| 51 const CGFloat kMouseHoverWhiteValue = 1.0; |
| 52 const CGFloat kMouseHoverWhiteValueIncongito = 0.3; |
| 53 |
50 // This is used to judge whether the mouse has moved during rapid closure; if it | 54 // This is used to judge whether the mouse has moved during rapid closure; if it |
51 // has moved less than the threshold, we want to close the tab. | 55 // has moved less than the threshold, we want to close the tab. |
52 const CGFloat kRapidCloseDist = 2.5; | 56 const CGFloat kRapidCloseDist = 2.5; |
53 | 57 |
54 @interface NSView (PrivateAPI) | 58 @interface NSView (PrivateAPI) |
55 // Called by AppKit to check if dragging this view should move the window. | 59 // Called by AppKit to check if dragging this view should move the window. |
56 // NSButton overrides this method in the same way so dragging window buttons | 60 // NSButton overrides this method in the same way so dragging window buttons |
57 // has no effect. NSView implementation returns NSZeroRect so the whole view | 61 // has no effect. NSView implementation returns NSZeroRect so the whole view |
58 // area can be dragged. | 62 // area can be dragged. |
59 - (NSRect)_opaqueRectForWindowMoveWhenInTitlebar; | 63 - (NSRect)_opaqueRectForWindowMoveWhenInTitlebar; |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 // image. However, even if the theme doesn't provide a tab background, the | 476 // image. However, even if the theme doesn't provide a tab background, the |
473 // theme machinery will make one if given a frame image. See | 477 // theme machinery will make one if given a frame image. See |
474 // BrowserThemePack::GenerateTabBackgroundImages for details. | 478 // BrowserThemePack::GenerateTabBackgroundImages for details. |
475 const ui::ThemeProvider* themeProvider = [[self window] themeProvider]; | 479 const ui::ThemeProvider* themeProvider = [[self window] themeProvider]; |
476 BOOL hasCustomTheme = themeProvider && | 480 BOOL hasCustomTheme = themeProvider && |
477 (themeProvider->HasCustomImage(IDR_THEME_TAB_BACKGROUND) || | 481 (themeProvider->HasCustomImage(IDR_THEME_TAB_BACKGROUND) || |
478 themeProvider->HasCustomImage(IDR_THEME_FRAME)); | 482 themeProvider->HasCustomImage(IDR_THEME_FRAME)); |
479 // Draw a mouse hover gradient for the default themes. | 483 // Draw a mouse hover gradient for the default themes. |
480 if (hoverAlpha > 0) { | 484 if (hoverAlpha > 0) { |
481 if (themeProvider && !hasCustomTheme) { | 485 if (themeProvider && !hasCustomTheme) { |
482 CGFloat whiteValue = 1; | 486 CGFloat whiteValue = kMouseHoverWhiteValue; |
483 // In Incognito mode, give the glow a darker value. | |
484 if (themeProvider && themeProvider->InIncognitoMode()) { | 487 if (themeProvider && themeProvider->InIncognitoMode()) { |
485 whiteValue = 0.5; | 488 whiteValue = kMouseHoverWhiteValueIncongito; |
486 } | 489 } |
487 base::scoped_nsobject<NSGradient> glow([NSGradient alloc]); | 490 base::scoped_nsobject<NSGradient> glow([NSGradient alloc]); |
488 [glow initWithStartingColor:[NSColor colorWithCalibratedWhite:whiteValue | 491 [glow initWithStartingColor:[NSColor colorWithCalibratedWhite:whiteValue |
489 alpha:1.0 * hoverAlpha] | 492 alpha:1.0 * hoverAlpha] |
490 endingColor:[NSColor colorWithCalibratedWhite:whiteValue | 493 endingColor:[NSColor colorWithCalibratedWhite:whiteValue |
491 alpha:0.0]]; | 494 alpha:0.0]]; |
492 NSRect rect = [self bounds]; | 495 NSRect rect = [self bounds]; |
493 NSPoint point = hoverPoint_; | 496 NSPoint point = hoverPoint_; |
494 point.y = NSHeight(rect); | 497 point.y = NSHeight(rect); |
495 [glow drawFromCenter:point | 498 [glow drawFromCenter:point |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1017 | 1020 |
1018 // For "Increase Contrast" mode, use flat black instead of semitransparent black | 1021 // For "Increase Contrast" mode, use flat black instead of semitransparent black |
1019 // for the tab edge stroke. | 1022 // for the tab edge stroke. |
1020 + (void)setTabEdgeStrokeColor { | 1023 + (void)setTabEdgeStrokeColor { |
1021 static NSColor* heavyStrokeColor = | 1024 static NSColor* heavyStrokeColor = |
1022 [skia::SkColorToSRGBNSColor(SK_ColorBLACK) retain]; | 1025 [skia::SkColorToSRGBNSColor(SK_ColorBLACK) retain]; |
1023 [heavyStrokeColor set]; | 1026 [heavyStrokeColor set]; |
1024 } | 1027 } |
1025 | 1028 |
1026 @end | 1029 @end |
OLD | NEW |