OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/spinner_view.h" | 5 #import "chrome/browser/ui/cocoa/spinner_view.h" |
6 | 6 |
7 #import <QuartzCore/QuartzCore.h> | 7 #import <QuartzCore/QuartzCore.h> |
8 | 8 |
9 #include "base/mac/mac_util.h" | 9 #include "base/mac/mac_util.h" |
10 #include "base/mac/sdk_forward_declarations.h" | 10 #include "base/mac/sdk_forward_declarations.h" |
11 #include "base/mac/scoped_cftyperef.h" | 11 #include "base/mac/scoped_cftyperef.h" |
12 #include "skia/ext/skia_utils_mac.h" | 12 #include "skia/ext/skia_utils_mac.h" |
13 #include "ui/base/theme_provider.h" | 13 #include "ui/base/theme_provider.h" |
14 #include "ui/native_theme/native_theme.h" | 14 #include "ui/native_theme/native_theme.h" |
| 15 #include "ui/native_theme/native_theme_mac.h" |
15 | 16 |
16 namespace { | 17 namespace { |
17 const CGFloat kDegrees90 = (M_PI / 2); | 18 const CGFloat kDegrees90 = (M_PI / 2); |
18 const CGFloat kDegrees180 = (M_PI); | 19 const CGFloat kDegrees180 = (M_PI); |
19 const CGFloat kDegrees270 = (3 * M_PI / 2); | 20 const CGFloat kDegrees270 = (3 * M_PI / 2); |
20 const CGFloat kDegrees360 = (2 * M_PI); | 21 const CGFloat kDegrees360 = (2 * M_PI); |
21 const CGFloat kDesignWidth = 28.0; | 22 const CGFloat kDesignWidth = 28.0; |
22 const CGFloat kArcRadius = 12.5; | 23 const CGFloat kArcRadius = 12.5; |
23 const CGFloat kArcDiameter = kArcRadius * 2.0; | 24 const CGFloat kArcDiameter = kArcRadius * 2.0; |
24 const CGFloat kArcLength = 58.9; | 25 const CGFloat kArcLength = 58.9; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 CGFloat lineWidth; | 111 CGFloat lineWidth; |
111 if (scaledDiameter < kArcDiameter) { | 112 if (scaledDiameter < kArcDiameter) { |
112 lineWidth = kArcStrokeWidth - (kArcDiameter - scaledDiameter) / 16.0; | 113 lineWidth = kArcStrokeWidth - (kArcDiameter - scaledDiameter) / 16.0; |
113 } else { | 114 } else { |
114 lineWidth = kArcStrokeWidth + (scaledDiameter - kArcDiameter) / 11.0; | 115 lineWidth = kArcStrokeWidth + (scaledDiameter - kArcDiameter) / 11.0; |
115 } | 116 } |
116 [shapeLayer_ setLineWidth:lineWidth]; | 117 [shapeLayer_ setLineWidth:lineWidth]; |
117 [shapeLayer_ setLineCap:kCALineCapRound]; | 118 [shapeLayer_ setLineCap:kCALineCapRound]; |
118 [shapeLayer_ setLineDashPattern:@[ @(kArcLength * scaleFactor) ]]; | 119 [shapeLayer_ setLineDashPattern:@[ @(kArcLength * scaleFactor) ]]; |
119 [shapeLayer_ setFillColor:NULL]; | 120 [shapeLayer_ setFillColor:NULL]; |
120 ui::NativeTheme* nativeTheme = ui::NativeTheme::instance(); | 121 ui::NativeTheme* nativeTheme = ui::NativeThemeMac::instance(); |
121 SkColor throbberBlueColor = nativeTheme->GetSystemColor( | 122 SkColor throbberBlueColor = nativeTheme->GetSystemColor( |
122 ui::NativeTheme::kColorId_ThrobberSpinningColor); | 123 ui::NativeTheme::kColorId_ThrobberSpinningColor); |
123 CGColorRef blueColor = gfx::CGColorCreateFromSkColor(throbberBlueColor); | 124 CGColorRef blueColor = gfx::CGColorCreateFromSkColor(throbberBlueColor); |
124 [shapeLayer_ setStrokeColor:blueColor]; | 125 [shapeLayer_ setStrokeColor:blueColor]; |
125 CGColorRelease(blueColor); | 126 CGColorRelease(blueColor); |
126 | 127 |
127 // Create the arc that, when stroked, creates the spinner. | 128 // Create the arc that, when stroked, creates the spinner. |
128 base::ScopedCFTypeRef<CGMutablePathRef> shapePath(CGPathCreateMutable()); | 129 base::ScopedCFTypeRef<CGMutablePathRef> shapePath(CGPathCreateMutable()); |
129 CGPathAddArc(shapePath, NULL, bounds.size.width / 2.0, | 130 CGPathAddArc(shapePath, NULL, bounds.size.width / 2.0, |
130 bounds.size.height / 2.0, kArcRadius * scaleFactor, | 131 bounds.size.height / 2.0, kArcRadius * scaleFactor, |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 [rotationLayer_ addAnimation:rotationAnimation_.get() | 296 [rotationLayer_ addAnimation:rotationAnimation_.get() |
296 forKey:kRotationAnimationName]; | 297 forKey:kRotationAnimationName]; |
297 } | 298 } |
298 } else { | 299 } else { |
299 [shapeLayer_ removeAllAnimations]; | 300 [shapeLayer_ removeAllAnimations]; |
300 [rotationLayer_ removeAllAnimations]; | 301 [rotationLayer_ removeAllAnimations]; |
301 } | 302 } |
302 } | 303 } |
303 | 304 |
304 @end | 305 @end |
OLD | NEW |