| 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 #include "ui/native_theme/native_theme_base.h" | 5 #include "ui/native_theme/native_theme_base.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 startEndColors = kCheckboxGradientPressedColors; | 598 startEndColors = kCheckboxGradientPressedColors; |
| 599 else if (state == kHovered) | 599 else if (state == kHovered) |
| 600 startEndColors = kCheckboxGradientHoveredColors; | 600 startEndColors = kCheckboxGradientHoveredColors; |
| 601 else if (state == kDisabled) | 601 else if (state == kDisabled) |
| 602 startEndColors = kCheckboxGradientDisabledColors; | 602 startEndColors = kCheckboxGradientDisabledColors; |
| 603 else /* kNormal */ | 603 else /* kNormal */ |
| 604 startEndColors = kCheckboxGradientColors; | 604 startEndColors = kCheckboxGradientColors; |
| 605 SkColor colors[3] = {startEndColors[0], startEndColors[0], startEndColors[1]}; | 605 SkColor colors[3] = {startEndColors[0], startEndColors[0], startEndColors[1]}; |
| 606 skia::RefPtr<SkShader> shader = skia::AdoptRef( | 606 skia::RefPtr<SkShader> shader = skia::AdoptRef( |
| 607 SkGradientShader::CreateLinear( | 607 SkGradientShader::CreateLinear( |
| 608 gradient_bounds, colors, NULL, 3, SkShader::kClamp_TileMode, NULL)); | 608 gradient_bounds, colors, NULL, 3, SkShader::kClamp_TileMode)); |
| 609 SkPaint paint; | 609 SkPaint paint; |
| 610 paint.setAntiAlias(true); | 610 paint.setAntiAlias(true); |
| 611 paint.setShader(shader.get()); | 611 paint.setShader(shader.get()); |
| 612 paint.setStyle(SkPaint::kFill_Style); | 612 paint.setStyle(SkPaint::kFill_Style); |
| 613 canvas->drawRoundRect(skrect, borderRadius, borderRadius, paint); | 613 canvas->drawRoundRect(skrect, borderRadius, borderRadius, paint); |
| 614 paint.setShader(NULL); | 614 paint.setShader(NULL); |
| 615 | 615 |
| 616 // Draw the border. | 616 // Draw the border. |
| 617 if (state == kHovered) | 617 if (state == kHovered) |
| 618 paint.setColor(kCheckboxBorderHoveredColor); | 618 paint.setColor(kCheckboxBorderHoveredColor); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 const int kDarkEnd = !kLightEnd; | 685 const int kDarkEnd = !kLightEnd; |
| 686 SkPoint gradient_bounds[2]; | 686 SkPoint gradient_bounds[2]; |
| 687 gradient_bounds[kLightEnd].iset(rect.x(), rect.y()); | 687 gradient_bounds[kLightEnd].iset(rect.x(), rect.y()); |
| 688 gradient_bounds[kDarkEnd].iset(rect.x(), kBottom - 1); | 688 gradient_bounds[kDarkEnd].iset(rect.x(), kBottom - 1); |
| 689 SkColor colors[2]; | 689 SkColor colors[2]; |
| 690 colors[0] = light_color; | 690 colors[0] = light_color; |
| 691 colors[1] = base_color; | 691 colors[1] = base_color; |
| 692 | 692 |
| 693 skia::RefPtr<SkShader> shader = skia::AdoptRef( | 693 skia::RefPtr<SkShader> shader = skia::AdoptRef( |
| 694 SkGradientShader::CreateLinear( | 694 SkGradientShader::CreateLinear( |
| 695 gradient_bounds, colors, NULL, 2, SkShader::kClamp_TileMode, NULL)); | 695 gradient_bounds, colors, NULL, 2, SkShader::kClamp_TileMode)); |
| 696 paint.setStyle(SkPaint::kFill_Style); | 696 paint.setStyle(SkPaint::kFill_Style); |
| 697 paint.setAntiAlias(true); | 697 paint.setAntiAlias(true); |
| 698 paint.setShader(shader.get()); | 698 paint.setShader(shader.get()); |
| 699 | 699 |
| 700 canvas->drawRoundRect(skrect, SkIntToScalar(1), SkIntToScalar(1), paint); | 700 canvas->drawRoundRect(skrect, SkIntToScalar(1), SkIntToScalar(1), paint); |
| 701 paint.setShader(NULL); | 701 paint.setShader(NULL); |
| 702 | 702 |
| 703 if (button.has_border) { | 703 if (button.has_border) { |
| 704 int border_alpha = state == kHovered ? 0x80 : 0x55; | 704 int border_alpha = state == kHovered ? 0x80 : 0x55; |
| 705 if (button.is_focused) { | 705 if (button.is_focused) { |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1062 SkScalar min_diff = Clamp((hsv1[1] + hsv2[1]) * 1.2f, 0.28f, 0.5f); | 1062 SkScalar min_diff = Clamp((hsv1[1] + hsv2[1]) * 1.2f, 0.28f, 0.5f); |
| 1063 SkScalar diff = Clamp(fabs(hsv1[2] - hsv2[2]) / 2, min_diff, 0.5f); | 1063 SkScalar diff = Clamp(fabs(hsv1[2] - hsv2[2]) / 2, min_diff, 0.5f); |
| 1064 | 1064 |
| 1065 if (hsv1[2] + hsv2[2] > 1.0) | 1065 if (hsv1[2] + hsv2[2] > 1.0) |
| 1066 diff = -diff; | 1066 diff = -diff; |
| 1067 | 1067 |
| 1068 return SaturateAndBrighten(hsv2, -0.2f, diff); | 1068 return SaturateAndBrighten(hsv2, -0.2f, diff); |
| 1069 } | 1069 } |
| 1070 | 1070 |
| 1071 } // namespace ui | 1071 } // namespace ui |
| OLD | NEW |