Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: ui/native_theme/native_theme_base.cc

Issue 2426793002: Aura overlay scrollbars adjust color for dark backgrounds (Closed)
Patch Set: fix test Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/native_theme/native_theme_base.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include <memory> 8 #include <memory>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 case kWindowResizeGripper: 149 case kWindowResizeGripper:
150 NOTIMPLEMENTED(); 150 NOTIMPLEMENTED();
151 break; 151 break;
152 default: 152 default:
153 NOTREACHED() << "Unknown theme part: " << part; 153 NOTREACHED() << "Unknown theme part: " << part;
154 break; 154 break;
155 } 155 }
156 return gfx::Size(); 156 return gfx::Size();
157 } 157 }
158 158
159 void NativeThemeBase::PaintStateTransition(SkCanvas* canvas,
160 Part part,
161 State startState,
162 State endState,
163 double progress,
164 const gfx::Rect& rect) const {
165 if (rect.IsEmpty())
166 return;
167
168 // Currently state transition is animation only working for overlay scrollbars
169 // on Aura platforms.
170 switch (part) {
171 case kScrollbarHorizontalThumb:
172 case kScrollbarVerticalThumb:
173 PaintScrollbarThumbStateTransition(canvas, part, startState, endState,
174 progress, rect);
175 break;
176 default:
177 NOTREACHED() << "Does not support state transition for this part:"
178 << part;
179 break;
180 }
181 return;
182 }
183
184 void NativeThemeBase::Paint(SkCanvas* canvas, 159 void NativeThemeBase::Paint(SkCanvas* canvas,
185 Part part, 160 Part part,
186 State state, 161 State state,
187 const gfx::Rect& rect, 162 const gfx::Rect& rect,
188 const ExtraParams& extra) const { 163 const ExtraParams& extra) const {
189 if (rect.IsEmpty()) 164 if (rect.IsEmpty())
190 return; 165 return;
191 166
192 canvas->save(); 167 canvas->save();
193 canvas->clipRect(gfx::RectToSkRect(rect)); 168 canvas->clipRect(gfx::RectToSkRect(rect));
(...skipping 26 matching lines...) Expand all
220 break; 195 break;
221 case kScrollbarDownArrow: 196 case kScrollbarDownArrow:
222 case kScrollbarUpArrow: 197 case kScrollbarUpArrow:
223 case kScrollbarLeftArrow: 198 case kScrollbarLeftArrow:
224 case kScrollbarRightArrow: 199 case kScrollbarRightArrow:
225 if (scrollbar_button_length_ > 0) 200 if (scrollbar_button_length_ > 0)
226 PaintArrowButton(canvas, rect, part, state); 201 PaintArrowButton(canvas, rect, part, state);
227 break; 202 break;
228 case kScrollbarHorizontalThumb: 203 case kScrollbarHorizontalThumb:
229 case kScrollbarVerticalThumb: 204 case kScrollbarVerticalThumb:
230 PaintScrollbarThumb(canvas, part, state, rect); 205 PaintScrollbarThumb(canvas, part, state, rect,
206 extra.scrollbar_thumb.scrollbar_theme);
231 break; 207 break;
232 case kScrollbarHorizontalTrack: 208 case kScrollbarHorizontalTrack:
233 case kScrollbarVerticalTrack: 209 case kScrollbarVerticalTrack:
234 PaintScrollbarTrack(canvas, part, state, extra.scrollbar_track, rect); 210 PaintScrollbarTrack(canvas, part, state, extra.scrollbar_track, rect);
235 break; 211 break;
236 case kScrollbarHorizontalGripper: 212 case kScrollbarHorizontalGripper:
237 case kScrollbarVerticalGripper: 213 case kScrollbarVerticalGripper:
238 // Invoked by views scrollbar code, don't care about for non-win 214 // Invoked by views scrollbar code, don't care about for non-win
239 // implementations, so no NOTIMPLEMENTED. 215 // implementations, so no NOTIMPLEMENTED.
240 break; 216 break;
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 canvas->drawIRect(skrect, paint); 403 canvas->drawIRect(skrect, paint);
428 404
429 SkScalar thumb_hsv[3]; 405 SkScalar thumb_hsv[3];
430 SkColorToHSV(thumb_inactive_color_, thumb_hsv); 406 SkColorToHSV(thumb_inactive_color_, thumb_hsv);
431 407
432 paint.setColor(OutlineColor(track_hsv, thumb_hsv)); 408 paint.setColor(OutlineColor(track_hsv, thumb_hsv));
433 DrawBox(canvas, rect, paint); 409 DrawBox(canvas, rect, paint);
434 } 410 }
435 411
436 void NativeThemeBase::PaintScrollbarThumb(SkCanvas* canvas, 412 void NativeThemeBase::PaintScrollbarThumb(SkCanvas* canvas,
437 Part part, 413 Part part,
438 State state, 414 State state,
439 const gfx::Rect& rect) const { 415 const gfx::Rect& rect,
416 ScrollbarOverlayColorTheme) const {
440 const bool hovered = state == kHovered; 417 const bool hovered = state == kHovered;
441 const int midx = rect.x() + rect.width() / 2; 418 const int midx = rect.x() + rect.width() / 2;
442 const int midy = rect.y() + rect.height() / 2; 419 const int midy = rect.y() + rect.height() / 2;
443 const bool vertical = part == kScrollbarVerticalThumb; 420 const bool vertical = part == kScrollbarVerticalThumb;
444 421
445 SkScalar thumb[3]; 422 SkScalar thumb[3];
446 SkColorToHSV(hovered ? thumb_active_color_ : thumb_inactive_color_, thumb); 423 SkColorToHSV(hovered ? thumb_active_color_ : thumb_inactive_color_, thumb);
447 424
448 SkPaint paint; 425 SkPaint paint;
449 paint.setColor(SaturateAndBrighten(thumb, 0, 0.02f)); 426 paint.setColor(SaturateAndBrighten(thumb, 0, 0.02f));
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 SkScalar min_diff = Clamp((hsv1[1] + hsv2[1]) * 1.2f, 0.28f, 0.5f); 992 SkScalar min_diff = Clamp((hsv1[1] + hsv2[1]) * 1.2f, 0.28f, 0.5f);
1016 SkScalar diff = Clamp(fabs(hsv1[2] - hsv2[2]) / 2, min_diff, 0.5f); 993 SkScalar diff = Clamp(fabs(hsv1[2] - hsv2[2]) / 2, min_diff, 0.5f);
1017 994
1018 if (hsv1[2] + hsv2[2] > 1.0) 995 if (hsv1[2] + hsv2[2] > 1.0)
1019 diff = -diff; 996 diff = -diff;
1020 997
1021 return SaturateAndBrighten(hsv2, -0.2f, diff); 998 return SaturateAndBrighten(hsv2, -0.2f, diff);
1022 } 999 }
1023 1000
1024 } // namespace ui 1001 } // namespace ui
OLDNEW
« no previous file with comments | « ui/native_theme/native_theme_base.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698