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/gfx/native_theme_base.h" | 5 #include "ui/gfx/native_theme_base.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "grit/gfx_resources.h" | 10 #include "grit/gfx_resources.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 break; | 138 break; |
139 case kMenuList: | 139 case kMenuList: |
140 PaintMenuList(canvas, state, rect, extra.menu_list); | 140 PaintMenuList(canvas, state, rect, extra.menu_list); |
141 break; | 141 break; |
142 case kMenuCheck: | 142 case kMenuCheck: |
143 case kMenuCheckBackground: | 143 case kMenuCheckBackground: |
144 case kMenuPopupArrow: | 144 case kMenuPopupArrow: |
145 NOTIMPLEMENTED(); | 145 NOTIMPLEMENTED(); |
146 break; | 146 break; |
147 case kMenuPopupBackground: | 147 case kMenuPopupBackground: |
148 PaintMenuPopupBackground(canvas, state, rect, extra.menu_list); | 148 PaintMenuPopupBackground(canvas, rect.size()); |
149 break; | 149 break; |
150 case kMenuPopupGutter: | 150 case kMenuPopupGutter: |
151 case kMenuPopupSeparator: | 151 case kMenuPopupSeparator: |
152 NOTIMPLEMENTED(); | 152 NOTIMPLEMENTED(); |
153 break; | 153 break; |
154 case kMenuItemBackground: | 154 case kMenuItemBackground: |
155 PaintMenuItemBackground(canvas, state, rect, extra.menu_list); | 155 PaintMenuItemBackground(canvas, state, rect, extra.menu_list); |
156 break; | 156 break; |
157 case kProgressBar: | 157 case kProgressBar: |
158 PaintProgressBar(canvas, state, rect, extra.progress_bar); | 158 PaintProgressBar(canvas, state, rect, extra.progress_bar); |
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 paint.setStyle(SkPaint::kFill_Style); | 659 paint.setStyle(SkPaint::kFill_Style); |
660 | 660 |
661 SkPath path; | 661 SkPath path; |
662 path.moveTo(menu_list.arrow_x, menu_list.arrow_y - 3); | 662 path.moveTo(menu_list.arrow_x, menu_list.arrow_y - 3); |
663 path.rLineTo(6, 0); | 663 path.rLineTo(6, 0); |
664 path.rLineTo(-3, 6); | 664 path.rLineTo(-3, 6); |
665 path.close(); | 665 path.close(); |
666 canvas->drawPath(path, paint); | 666 canvas->drawPath(path, paint); |
667 } | 667 } |
668 | 668 |
669 void NativeThemeBase::PaintMenuPopupBackground( | 669 void NativeThemeBase::PaintMenuPopupBackground(SkCanvas* canvas, |
670 SkCanvas* canvas, | 670 const gfx::Size& size) const { |
671 State state, | |
672 const gfx::Rect& rect, | |
673 const MenuListExtraParams& menu_list) const { | |
674 canvas->drawColor(kMenuPopupBackgroundColor, SkXfermode::kSrc_Mode); | 671 canvas->drawColor(kMenuPopupBackgroundColor, SkXfermode::kSrc_Mode); |
675 } | 672 } |
676 | 673 |
677 void NativeThemeBase::PaintMenuItemBackground( | 674 void NativeThemeBase::PaintMenuItemBackground( |
678 SkCanvas* canvas, | 675 SkCanvas* canvas, |
679 State state, | 676 State state, |
680 const gfx::Rect& rect, | 677 const gfx::Rect& rect, |
681 const MenuListExtraParams& menu_list) const { | 678 const MenuListExtraParams& menu_list) const { |
682 // By default don't draw anything over the normal background. | 679 // By default don't draw anything over the normal background. |
683 } | 680 } |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
978 SkScalar min_diff = Clamp((hsv1[1] + hsv2[1]) * 1.2f, 0.28f, 0.5f); | 975 SkScalar min_diff = Clamp((hsv1[1] + hsv2[1]) * 1.2f, 0.28f, 0.5f); |
979 SkScalar diff = Clamp(fabs(hsv1[2] - hsv2[2]) / 2, min_diff, 0.5f); | 976 SkScalar diff = Clamp(fabs(hsv1[2] - hsv2[2]) / 2, min_diff, 0.5f); |
980 | 977 |
981 if (hsv1[2] + hsv2[2] > 1.0) | 978 if (hsv1[2] + hsv2[2] > 1.0) |
982 diff = -diff; | 979 diff = -diff; |
983 | 980 |
984 return SaturateAndBrighten(hsv2, -0.2f, diff); | 981 return SaturateAndBrighten(hsv2, -0.2f, diff); |
985 } | 982 } |
986 | 983 |
987 } // namespace gfx | 984 } // namespace gfx |
OLD | NEW |