OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include "ui/native_theme/native_theme_mac.h" | 5 #include "ui/native_theme/native_theme_mac.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 case kColorId_TableGroupingIndicatorColor: | 246 case kColorId_TableGroupingIndicatorColor: |
247 return SkColorSetRGB(140, 140, 140); | 247 return SkColorSetRGB(140, 140, 140); |
248 | 248 |
249 default: | 249 default: |
250 // TODO(tapted): Handle all values and remove the default case. | 250 // TODO(tapted): Handle all values and remove the default case. |
251 return GetAuraColor(color_id, this); | 251 return GetAuraColor(color_id, this); |
252 } | 252 } |
253 } | 253 } |
254 | 254 |
255 void NativeThemeMac::PaintMenuPopupBackground( | 255 void NativeThemeMac::PaintMenuPopupBackground( |
256 SkCanvas* canvas, | 256 cc::PaintCanvas* canvas, |
257 const gfx::Size& size, | 257 const gfx::Size& size, |
258 const MenuBackgroundExtraParams& menu_background) const { | 258 const MenuBackgroundExtraParams& menu_background) const { |
259 SkPaint paint; | 259 cc::PaintFlags paint; |
260 paint.setAntiAlias(true); | 260 paint.setAntiAlias(true); |
261 if (base::mac::IsOS10_9()) | 261 if (base::mac::IsOS10_9()) |
262 paint.setColor(kMenuPopupBackgroundColorMavericks); | 262 paint.setColor(kMenuPopupBackgroundColorMavericks); |
263 else | 263 else |
264 paint.setColor(kMenuPopupBackgroundColor); | 264 paint.setColor(kMenuPopupBackgroundColor); |
265 const SkScalar radius = SkIntToScalar(menu_background.corner_radius); | 265 const SkScalar radius = SkIntToScalar(menu_background.corner_radius); |
266 SkRect rect = gfx::RectToSkRect(gfx::Rect(size)); | 266 SkRect rect = gfx::RectToSkRect(gfx::Rect(size)); |
267 canvas->drawRoundRect(rect, radius, radius, paint); | 267 canvas->drawRoundRect(rect, radius, radius, paint); |
268 } | 268 } |
269 | 269 |
270 void NativeThemeMac::PaintMenuItemBackground( | 270 void NativeThemeMac::PaintMenuItemBackground( |
271 SkCanvas* canvas, | 271 cc::PaintCanvas* canvas, |
272 State state, | 272 State state, |
273 const gfx::Rect& rect, | 273 const gfx::Rect& rect, |
274 const MenuItemExtraParams& menu_item) const { | 274 const MenuItemExtraParams& menu_item) const { |
275 SkPaint paint; | 275 cc::PaintFlags paint; |
276 switch (state) { | 276 switch (state) { |
277 case NativeTheme::kNormal: | 277 case NativeTheme::kNormal: |
278 case NativeTheme::kDisabled: | 278 case NativeTheme::kDisabled: |
279 // Draw nothing over the regular background. | 279 // Draw nothing over the regular background. |
280 break; | 280 break; |
281 case NativeTheme::kHovered: | 281 case NativeTheme::kHovered: |
282 // TODO(tapted): Draw a gradient, and use [NSColor currentControlTint] to | 282 // TODO(tapted): Draw a gradient, and use [NSColor currentControlTint] to |
283 // pick colors. The System color "selectedMenuItemColor" is actually still | 283 // pick colors. The System color "selectedMenuItemColor" is actually still |
284 // blue for Graphite. And while "keyboardFocusIndicatorColor" does change, | 284 // blue for Graphite. And while "keyboardFocusIndicatorColor" does change, |
285 // and is a good shade of gray, it's not blue enough for the Blue theme. | 285 // and is a good shade of gray, it's not blue enough for the Blue theme. |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 | 363 |
364 for (size_t i = 0; i < arraysize(gradient_colors); ++i) | 364 for (size_t i = 0; i < arraysize(gradient_colors); ++i) |
365 gradient_colors[i] = ApplySystemControlTint(gradient_colors[i]); | 365 gradient_colors[i] = ApplySystemControlTint(gradient_colors[i]); |
366 | 366 |
367 return SkGradientShader::MakeLinear( | 367 return SkGradientShader::MakeLinear( |
368 gradient_points, gradient_colors, gradient_positions, | 368 gradient_points, gradient_colors, gradient_positions, |
369 arraysize(gradient_positions), SkShader::kClamp_TileMode); | 369 arraysize(gradient_positions), SkShader::kClamp_TileMode); |
370 } | 370 } |
371 | 371 |
372 // static | 372 // static |
373 void NativeThemeMac::PaintStyledGradientButton(SkCanvas* canvas, | 373 void NativeThemeMac::PaintStyledGradientButton(cc::PaintCanvas* canvas, |
374 const gfx::Rect& integer_bounds, | 374 const gfx::Rect& integer_bounds, |
375 ButtonBackgroundType type, | 375 ButtonBackgroundType type, |
376 bool round_left, | 376 bool round_left, |
377 bool round_right, | 377 bool round_right, |
378 bool focus) { | 378 bool focus) { |
379 const SkScalar kBorderThickness = 1; | 379 const SkScalar kBorderThickness = 1; |
380 const SkScalar kFocusRingThickness = 4; | 380 const SkScalar kFocusRingThickness = 4; |
381 const SkColor kFocusRingColor = ApplySystemControlTint( | 381 const SkColor kFocusRingColor = ApplySystemControlTint( |
382 SkColorSetARGB(0x94, 0x79, 0xa7, 0xe9)); | 382 SkColorSetARGB(0x94, 0x79, 0xa7, 0xe9)); |
383 | 383 |
(...skipping 18 matching lines...) Expand all Loading... |
402 SkRRect shape; | 402 SkRRect shape; |
403 if (round_left && round_right) | 403 if (round_left && round_right) |
404 shape.setRectXY(bounds, kButtonCornerRadius, kButtonCornerRadius); | 404 shape.setRectXY(bounds, kButtonCornerRadius, kButtonCornerRadius); |
405 else if (round_left) | 405 else if (round_left) |
406 shape.setRectRadii(bounds, kLeftCurves); | 406 shape.setRectRadii(bounds, kLeftCurves); |
407 else if (round_right) | 407 else if (round_right) |
408 shape.setRectRadii(bounds, kRightCurves); | 408 shape.setRectRadii(bounds, kRightCurves); |
409 else | 409 else |
410 shape.setRect(bounds); | 410 shape.setRect(bounds); |
411 | 411 |
412 SkPaint paint; | 412 cc::PaintFlags paint; |
413 paint.setStyle(SkPaint::kFill_Style); | 413 paint.setStyle(cc::PaintFlags::kFill_Style); |
414 paint.setAntiAlias(true); | 414 paint.setAntiAlias(true); |
415 | 415 |
416 // First draw the darker "outer" border, with its gradient and shadow. Inside | 416 // First draw the darker "outer" border, with its gradient and shadow. Inside |
417 // a tab strip, this will draw over the outer border and inner separator. | 417 // a tab strip, this will draw over the outer border and inner separator. |
418 paint.setLooper(gfx::CreateShadowDrawLooper(shadows)); | 418 paint.setLooper(gfx::CreateShadowDrawLooper(shadows)); |
419 paint.setShader(GetButtonBorderShader(type, shape.height())); | 419 paint.setShader( |
| 420 cc::WrapSkShader(GetButtonBorderShader(type, shape.height()))); |
420 canvas->drawRRect(shape, paint); | 421 canvas->drawRRect(shape, paint); |
421 | 422 |
422 // Then, inset the rounded rect and draw over that with the inner gradient. | 423 // Then, inset the rounded rect and draw over that with the inner gradient. |
423 shape.inset(kBorderThickness, kBorderThickness); | 424 shape.inset(kBorderThickness, kBorderThickness); |
424 paint.setLooper(nullptr); | 425 paint.setLooper(nullptr); |
425 paint.setShader(GetButtonBackgroundShader(type, shape.height())); | 426 paint.setShader( |
| 427 cc::WrapSkShader(GetButtonBackgroundShader(type, shape.height()))); |
426 canvas->drawRRect(shape, paint); | 428 canvas->drawRRect(shape, paint); |
427 | 429 |
428 if (!focus) | 430 if (!focus) |
429 return; | 431 return; |
430 | 432 |
431 SkRRect outer_shape; | 433 SkRRect outer_shape; |
432 shape.outset(kFocusRingThickness, kFocusRingThickness, &outer_shape); | 434 shape.outset(kFocusRingThickness, kFocusRingThickness, &outer_shape); |
433 paint.setShader(nullptr); | 435 paint.setShader(nullptr); |
434 paint.setColor(kFocusRingColor); | 436 paint.setColor(kFocusRingColor); |
435 canvas->drawDRRect(outer_shape, shape, paint); | 437 canvas->drawDRRect(outer_shape, shape, paint); |
436 } | 438 } |
437 | 439 |
438 NativeThemeMac::NativeThemeMac() { | 440 NativeThemeMac::NativeThemeMac() { |
439 } | 441 } |
440 | 442 |
441 NativeThemeMac::~NativeThemeMac() { | 443 NativeThemeMac::~NativeThemeMac() { |
442 } | 444 } |
443 | 445 |
444 } // namespace ui | 446 } // namespace ui |
OLD | NEW |