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

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

Issue 2426793002: Aura overlay scrollbars adjust color for dark backgrounds (Closed)
Patch Set: update Created 4 years, 2 months 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
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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 break; 154 break;
155 } 155 }
156 return gfx::Size(); 156 return gfx::Size();
157 } 157 }
158 158
159 void NativeThemeBase::PaintStateTransition(SkCanvas* canvas, 159 void NativeThemeBase::PaintStateTransition(SkCanvas* canvas,
160 Part part, 160 Part part,
161 State startState, 161 State startState,
162 State endState, 162 State endState,
163 double progress, 163 double progress,
164 const gfx::Rect& rect) const { 164 const gfx::Rect& rect,
165 ScrollbarOverlayStyle style) const {
165 if (rect.IsEmpty()) 166 if (rect.IsEmpty())
166 return; 167 return;
167 168
168 // Currently state transition is animation only working for overlay scrollbars 169 // Currently state transition is animation only working for overlay scrollbars
169 // on Aura platforms. 170 // on Aura platforms.
170 switch (part) { 171 switch (part) {
171 case kScrollbarHorizontalThumb: 172 case kScrollbarHorizontalThumb:
172 case kScrollbarVerticalThumb: 173 case kScrollbarVerticalThumb:
173 PaintScrollbarThumbStateTransition(canvas, part, startState, endState, 174 PaintScrollbarThumbStateTransition(canvas, part, startState, endState,
174 progress, rect); 175 progress, rect, style);
175 break; 176 break;
176 default: 177 default:
177 NOTREACHED() << "Does not support state transition for this part:" 178 NOTREACHED() << "Does not support state transition for this part:"
178 << part; 179 << part;
179 break; 180 break;
180 } 181 }
181 return; 182 return;
182 } 183 }
183 184
184 void NativeThemeBase::Paint(SkCanvas* canvas, 185 void NativeThemeBase::Paint(SkCanvas* canvas,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 break; 221 break;
221 case kScrollbarDownArrow: 222 case kScrollbarDownArrow:
222 case kScrollbarUpArrow: 223 case kScrollbarUpArrow:
223 case kScrollbarLeftArrow: 224 case kScrollbarLeftArrow:
224 case kScrollbarRightArrow: 225 case kScrollbarRightArrow:
225 if (scrollbar_button_length_ > 0) 226 if (scrollbar_button_length_ > 0)
226 PaintArrowButton(canvas, rect, part, state); 227 PaintArrowButton(canvas, rect, part, state);
227 break; 228 break;
228 case kScrollbarHorizontalThumb: 229 case kScrollbarHorizontalThumb:
229 case kScrollbarVerticalThumb: 230 case kScrollbarVerticalThumb:
230 PaintScrollbarThumb(canvas, part, state, rect); 231 PaintScrollbarThumb(canvas, part, state, rect, extra.scrollbar_style);
231 break; 232 break;
232 case kScrollbarHorizontalTrack: 233 case kScrollbarHorizontalTrack:
233 case kScrollbarVerticalTrack: 234 case kScrollbarVerticalTrack:
234 PaintScrollbarTrack(canvas, part, state, extra.scrollbar_track, rect); 235 PaintScrollbarTrack(canvas, part, state, extra.scrollbar_track, rect);
235 break; 236 break;
236 case kScrollbarHorizontalGripper: 237 case kScrollbarHorizontalGripper:
237 case kScrollbarVerticalGripper: 238 case kScrollbarVerticalGripper:
238 // Invoked by views scrollbar code, don't care about for non-win 239 // Invoked by views scrollbar code, don't care about for non-win
239 // implementations, so no NOTIMPLEMENTED. 240 // implementations, so no NOTIMPLEMENTED.
240 break; 241 break;
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 SkScalar thumb_hsv[3]; 430 SkScalar thumb_hsv[3];
430 SkColorToHSV(thumb_inactive_color_, thumb_hsv); 431 SkColorToHSV(thumb_inactive_color_, thumb_hsv);
431 432
432 paint.setColor(OutlineColor(track_hsv, thumb_hsv)); 433 paint.setColor(OutlineColor(track_hsv, thumb_hsv));
433 DrawBox(canvas, rect, paint); 434 DrawBox(canvas, rect, paint);
434 } 435 }
435 436
436 void NativeThemeBase::PaintScrollbarThumb(SkCanvas* canvas, 437 void NativeThemeBase::PaintScrollbarThumb(SkCanvas* canvas,
437 Part part, 438 Part part,
438 State state, 439 State state,
439 const gfx::Rect& rect) const { 440 const gfx::Rect& rect,
441 ScrollbarOverlayStyle style) const {
440 const bool hovered = state == kHovered; 442 const bool hovered = state == kHovered;
441 const int midx = rect.x() + rect.width() / 2; 443 const int midx = rect.x() + rect.width() / 2;
442 const int midy = rect.y() + rect.height() / 2; 444 const int midy = rect.y() + rect.height() / 2;
443 const bool vertical = part == kScrollbarVerticalThumb; 445 const bool vertical = part == kScrollbarVerticalThumb;
444 446
445 SkScalar thumb[3]; 447 SkScalar thumb[3];
446 SkColorToHSV(hovered ? thumb_active_color_ : thumb_inactive_color_, thumb); 448 SkColorToHSV(hovered ? thumb_active_color_ : thumb_inactive_color_, thumb);
447 449
448 SkPaint paint; 450 SkPaint paint;
449 paint.setColor(SaturateAndBrighten(thumb, 0, 0.02f)); 451 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); 1017 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); 1018 SkScalar diff = Clamp(fabs(hsv1[2] - hsv2[2]) / 2, min_diff, 0.5f);
1017 1019
1018 if (hsv1[2] + hsv2[2] > 1.0) 1020 if (hsv1[2] + hsv2[2] > 1.0)
1019 diff = -diff; 1021 diff = -diff;
1020 1022
1021 return SaturateAndBrighten(hsv2, -0.2f, diff); 1023 return SaturateAndBrighten(hsv2, -0.2f, diff);
1022 } 1024 }
1023 1025
1024 } // namespace ui 1026 } // namespace ui
OLDNEW
« third_party/WebKit/public/platform/WebThemeEngine.h ('K') | « 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