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

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

Issue 10796071: Enable new checkbox style by default (Linux/CrOS only) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with trunk Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « ui/base/native_theme/native_theme_base.h ('k') | ui/base/ui_base_switches.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) 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/base/native_theme/native_theme_base.h" 5 #include "ui/base/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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 SkColorSetRGB(0xed, 0xed, 0xed), 49 SkColorSetRGB(0xed, 0xed, 0xed),
50 SkColorSetRGB(0xde, 0xde, 0xde) }; 50 SkColorSetRGB(0xde, 0xde, 0xde) };
51 const SkColor kCheckboxGradientPressedColors[] = { 51 const SkColor kCheckboxGradientPressedColors[] = {
52 SkColorSetRGB(0xe7, 0xe7, 0xe7), 52 SkColorSetRGB(0xe7, 0xe7, 0xe7),
53 SkColorSetRGB(0xd7, 0xd7, 0xd7) }; 53 SkColorSetRGB(0xd7, 0xd7, 0xd7) };
54 const SkColor kCheckboxGradientHoveredColors[] = { 54 const SkColor kCheckboxGradientHoveredColors[] = {
55 SkColorSetRGB(0xf0, 0xf0, 0xf0), 55 SkColorSetRGB(0xf0, 0xf0, 0xf0),
56 SkColorSetRGB(0xe0, 0xe0, 0xe0) }; 56 SkColorSetRGB(0xe0, 0xe0, 0xe0) };
57 const SkColor kCheckboxGradientDisabledColors[] = { 57 const SkColor kCheckboxGradientDisabledColors[] = {
58 SkColorSetARGB(0xB3, 0xed, 0xed, 0xed), 58 SkColorSetARGB(0xB3, 0xed, 0xed, 0xed),
59 SkColorSetARGB(0xB3, 0xde, 0xde, 0xde) }; 59 SkColorSetARGB(0xB3, 0xed, 0xed, 0xed) };
60 const SkColor kCheckboxBorderColor = SkColorSetARGB(0x40, 0, 0, 0); 60 const SkColor kCheckboxBorderColor = SkColorSetARGB(0x40, 0, 0, 0);
61 const SkColor kCheckboxBorderHoveredColor = SkColorSetARGB(0x4D, 0, 0, 0); 61 const SkColor kCheckboxBorderHoveredColor = SkColorSetARGB(0x4D, 0, 0, 0);
62 const SkColor kCheckboxBorderDisabledColor = SkColorSetARGB(0x30, 0, 0, 0); 62 const SkColor kCheckboxBorderDisabledColor = SkColorSetARGB(0x30, 0, 0, 0);
63 const SkColor kCheckboxStrokeColor = SkColorSetARGB(0xB3, 0, 0, 0); 63 const SkColor kCheckboxStrokeColor = SkColorSetARGB(0xB3, 0, 0, 0);
64 const SkColor kCheckboxStrokeDisabledColor = SkColorSetARGB(0x86, 0, 0, 0); 64 const SkColor kCheckboxStrokeDisabledColor = SkColorSetARGB(0x86, 0, 0, 0);
65 const SkColor kRadioDotColor = SkColorSetRGB(0x66, 0x66, 0x66); 65 const SkColor kRadioDotColor = SkColorSetRGB(0x66, 0x66, 0x66);
66 const SkColor kRadioDotDisabledColor = SkColorSetARGB(0xC0, 0x66, 0x66, 0x66); 66 const SkColor kRadioDotDisabledColor = SkColorSetARGB(0xC0, 0x66, 0x66, 0x66);
67 67
68 // Get lightness adjusted color. 68 // Get lightness adjusted color.
69 SkColor BrightenColor(const color_utils::HSL& hsl, SkAlpha alpha, 69 SkColor BrightenColor(const color_utils::HSL& hsl, SkAlpha alpha,
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 DrawVertLine(canvas, 461 DrawVertLine(canvas,
462 midx + inter_grippy_offset, 462 midx + inter_grippy_offset,
463 midy - grippy_half_width, 463 midy - grippy_half_width,
464 midy + grippy_half_width, 464 midy + grippy_half_width,
465 paint); 465 paint);
466 } 466 }
467 } 467 }
468 } 468 }
469 469
470 bool NativeThemeBase::IsNewCheckboxStyleEnabled(SkCanvas* canvas) const { 470 bool NativeThemeBase::IsNewCheckboxStyleEnabled(SkCanvas* canvas) const {
471 // Mostly this new style is experimental behind a flag. 471 // The new style is now the default.
472 // TODO(rbyers): Enable new style by default. http://crbug.com/125773 472 // TODO(rbyers): Remove this flag once we're sure the new behavior is fine.
473 if (CommandLine::ForCurrentProcess()->HasSwitch( 473 // http://crbug.com/133991
474 switches::kNewCheckboxStyle)) 474 if (!CommandLine::ForCurrentProcess()->HasSwitch(
475 return true; 475 switches::kOldCheckboxStyle))
476
477 // Also enable explicitly when high-DPI is being used (since this is the only
478 // way we have to get nice looking widgets in high-DPI.
479 if (canvas->getTotalMatrix().getScaleX() > 1)
480 return true; 476 return true;
481 477
482 return false; 478 return false;
483 } 479 }
484 480
485 void NativeThemeBase::PaintCheckbox(SkCanvas* canvas, 481 void NativeThemeBase::PaintCheckbox(SkCanvas* canvas,
486 State state, 482 State state,
487 const gfx::Rect& rect, 483 const gfx::Rect& rect,
488 const ButtonExtraParams& button) const { 484 const ButtonExtraParams& button) const {
489 if (IsNewCheckboxStyleEnabled(canvas)) { 485 if (IsNewCheckboxStyleEnabled(canvas)) {
(...skipping 26 matching lines...) Expand all
516 // Returns the rectangle within which any additional decorations should be 512 // Returns the rectangle within which any additional decorations should be
517 // drawn, or empty if none. 513 // drawn, or empty if none.
518 SkRect NativeThemeBase::PaintCheckboxRadioNewCommon( 514 SkRect NativeThemeBase::PaintCheckboxRadioNewCommon(
519 SkCanvas* canvas, 515 SkCanvas* canvas,
520 State state, 516 State state,
521 const gfx::Rect& rect, 517 const gfx::Rect& rect,
522 const SkScalar borderRadius) const { 518 const SkScalar borderRadius) const {
523 519
524 SkRect skrect = gfx::RectToSkRect(rect); 520 SkRect skrect = gfx::RectToSkRect(rect);
525 521
522 // Use the largest square rectangle that fits inside the provided rectangle.
Avi (use Gerrit) 2012/07/23 19:29:07 drive-by: s/square rectangle/square/
523 // No other browser seems to support non-square widget, so accidentally
524 // having non-square sizes is common (eg. amazon and webkit dev tools).
525 if (skrect.width() != skrect.height()) {
526 SkScalar size = SkMinScalar(skrect.width(), skrect.height());
527 skrect.inset((skrect.width() - size) / 2, (skrect.height() - size) / 2);
528 }
529
526 // If the rectangle is too small then paint only a rectangle. We don't want 530 // If the rectangle is too small then paint only a rectangle. We don't want
527 // to have to worry about '- 1' and '+ 1' calculations below having overflow 531 // to have to worry about '- 1' and '+ 1' calculations below having overflow
528 // or underflow. 532 // or underflow.
529 if (rect.width() <= 2 || rect.height() <= 2) { 533 if (skrect.width() <= 2) {
530 SkPaint paint; 534 SkPaint paint;
531 paint.setColor(kCheckboxTinyColor); 535 paint.setColor(kCheckboxTinyColor);
532 paint.setStyle(SkPaint::kFill_Style); 536 paint.setStyle(SkPaint::kFill_Style);
533 canvas->drawRect(skrect, paint); 537 canvas->drawRect(skrect, paint);
534 // Too small to draw anything more. 538 // Too small to draw anything more.
535 return SkRect::MakeEmpty(); 539 return SkRect::MakeEmpty();
536 } 540 }
537 541
538 // Make room for the drop shadow. 542 // Make room for the drop shadow.
539 skrect.iset(skrect.x(), skrect.y(), skrect.right() - 1, skrect.bottom() - 1); 543 skrect.iset(skrect.x(), skrect.y(), skrect.right() - 1, skrect.bottom() - 1);
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 SkScalar min_diff = Clamp((hsv1[1] + hsv2[1]) * 1.2f, 0.28f, 0.5f); 1121 SkScalar min_diff = Clamp((hsv1[1] + hsv2[1]) * 1.2f, 0.28f, 0.5f);
1118 SkScalar diff = Clamp(fabs(hsv1[2] - hsv2[2]) / 2, min_diff, 0.5f); 1122 SkScalar diff = Clamp(fabs(hsv1[2] - hsv2[2]) / 2, min_diff, 0.5f);
1119 1123
1120 if (hsv1[2] + hsv2[2] > 1.0) 1124 if (hsv1[2] + hsv2[2] > 1.0)
1121 diff = -diff; 1125 diff = -diff;
1122 1126
1123 return SaturateAndBrighten(hsv2, -0.2f, diff); 1127 return SaturateAndBrighten(hsv2, -0.2f, diff);
1124 } 1128 }
1125 1129
1126 } // namespace ui 1130 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/native_theme/native_theme_base.h ('k') | ui/base/ui_base_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698