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

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

Issue 8597015: Add a new GetSystemColor method to native theme. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more code motion Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « ui/gfx/native_theme_base.h ('k') | ui/gfx/native_theme_gtk.h » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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"
11 #include "third_party/skia/include/effects/SkGradientShader.h" 11 #include "third_party/skia/include/effects/SkGradientShader.h"
12 #include "ui/base/resource/resource_bundle.h" 12 #include "ui/base/resource/resource_bundle.h"
13 #include "ui/gfx/color_utils.h" 13 #include "ui/gfx/color_utils.h"
14 #include "ui/gfx/rect.h" 14 #include "ui/gfx/rect.h"
15 #include "ui/gfx/size.h" 15 #include "ui/gfx/size.h"
16 16
17 namespace {
18
19 // Hardcoded colors for use when there is no system theme (Aura, ChromeOS).
20 const SkColor kDefaultDialogBackgroundColor = SkColorSetRGB(200, 200, 200);
21 const SkColor kInvalidColorIdColor = SkColorSetRGB(255, 0, 128);
22
23 } // namespace
24
17 namespace gfx { 25 namespace gfx {
18 26
19 unsigned int NativeThemeBase::button_length_ = 14; 27 unsigned int NativeThemeBase::button_length_ = 14;
20 #if defined(TOUCH_UI) 28 #if defined(TOUCH_UI)
21 unsigned int NativeThemeBase::scrollbar_width_ = 0; 29 unsigned int NativeThemeBase::scrollbar_width_ = 0;
22 #else 30 #else
23 unsigned int NativeThemeBase::scrollbar_width_ = 15; 31 unsigned int NativeThemeBase::scrollbar_width_ = 15;
24 #endif 32 #endif
25 33
26 // These are the default dimensions of radio buttons and checkboxes. 34 // These are the default dimensions of radio buttons and checkboxes.
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 case kTrackbarTrack: 335 case kTrackbarTrack:
328 case kWindowResizeGripper: 336 case kWindowResizeGripper:
329 NOTIMPLEMENTED(); 337 NOTIMPLEMENTED();
330 break; 338 break;
331 default: 339 default:
332 NOTREACHED() << "Unknown theme part: " << part; 340 NOTREACHED() << "Unknown theme part: " << part;
333 break; 341 break;
334 } 342 }
335 } 343 }
336 344
345 SkColor NativeThemeBase::GetSystemColor(ColorId color_id) const {
346 // This implementation returns hardcoded colors. It's used by NativeThemeAura
347 // and NativeThemeChromeos and overridden by NativeThemeGtk.
348 switch (color_id) {
349 case kColorId_DialogBackground:
350 return kDefaultDialogBackgroundColor;
351 default:
352 NOTREACHED() << "Invalid color_id: " << color_id;
353 break;
354 }
355 return kInvalidColorIdColor;
356 }
357
337 void NativeThemeBase::PaintScrollbarTrack(SkCanvas* canvas, 358 void NativeThemeBase::PaintScrollbarTrack(SkCanvas* canvas,
338 Part part, 359 Part part,
339 State state, 360 State state,
340 const ScrollbarTrackExtraParams& extra_params, 361 const ScrollbarTrackExtraParams& extra_params,
341 const gfx::Rect& rect) const { 362 const gfx::Rect& rect) const {
342 SkPaint paint; 363 SkPaint paint;
343 SkIRect skrect; 364 SkIRect skrect;
344 365
345 skrect.set(rect.x(), rect.y(), rect.right(), rect.bottom()); 366 skrect.set(rect.x(), rect.y(), rect.right(), rect.bottom());
346 SkScalar track_hsv[3]; 367 SkScalar track_hsv[3];
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 SkScalar min_diff = Clamp((hsv1[1] + hsv2[1]) * 1.2f, 0.28f, 0.5f); 1006 SkScalar min_diff = Clamp((hsv1[1] + hsv2[1]) * 1.2f, 0.28f, 0.5f);
986 SkScalar diff = Clamp(fabs(hsv1[2] - hsv2[2]) / 2, min_diff, 0.5f); 1007 SkScalar diff = Clamp(fabs(hsv1[2] - hsv2[2]) / 2, min_diff, 0.5f);
987 1008
988 if (hsv1[2] + hsv2[2] > 1.0) 1009 if (hsv1[2] + hsv2[2] > 1.0)
989 diff = -diff; 1010 diff = -diff;
990 1011
991 return SaturateAndBrighten(hsv2, -0.2f, diff); 1012 return SaturateAndBrighten(hsv2, -0.2f, diff);
992 } 1013 }
993 1014
994 } // namespace gfx 1015 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/native_theme_base.h ('k') | ui/gfx/native_theme_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698