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

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

Issue 11110004: Make gfx::Rect class operations consistently mutate the class they are called on. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 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/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 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 } else if (button.checked) { 497 } else if (button.checked) {
498 image = state == kDisabled ? 498 image = state == kDisabled ?
499 rb.GetImageSkiaNamed(IDR_CHECKBOX_DISABLED_ON) : 499 rb.GetImageSkiaNamed(IDR_CHECKBOX_DISABLED_ON) :
500 rb.GetImageSkiaNamed(IDR_CHECKBOX_ON); 500 rb.GetImageSkiaNamed(IDR_CHECKBOX_ON);
501 } else { 501 } else {
502 image = state == kDisabled ? 502 image = state == kDisabled ?
503 rb.GetImageSkiaNamed(IDR_CHECKBOX_DISABLED_OFF) : 503 rb.GetImageSkiaNamed(IDR_CHECKBOX_DISABLED_OFF) :
504 rb.GetImageSkiaNamed(IDR_CHECKBOX_OFF); 504 rb.GetImageSkiaNamed(IDR_CHECKBOX_OFF);
505 } 505 }
506 506
507 gfx::Rect bounds = rect.Center(gfx::Size(image->width(), image->height())); 507 gfx::Rect bounds = rect;
508 bounds.ClampToCenteredSize(gfx::Size(image->width(), image->height()));
508 DrawImageInt(canvas, *image, 0, 0, image->width(), image->height(), 509 DrawImageInt(canvas, *image, 0, 0, image->width(), image->height(),
509 bounds.x(), bounds.y(), bounds.width(), bounds.height()); 510 bounds.x(), bounds.y(), bounds.width(), bounds.height());
510 } 511 }
511 512
512 // Draws the common elements of checkboxes and radio buttons. 513 // Draws the common elements of checkboxes and radio buttons.
513 // Returns the rectangle within which any additional decorations should be 514 // Returns the rectangle within which any additional decorations should be
514 // drawn, or empty if none. 515 // drawn, or empty if none.
515 SkRect NativeThemeBase::PaintCheckboxRadioNewCommon( 516 SkRect NativeThemeBase::PaintCheckboxRadioNewCommon(
516 SkCanvas* canvas, 517 SkCanvas* canvas,
517 State state, 518 State state,
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 if (state == kDisabled) { 649 if (state == kDisabled) {
649 image = button.checked ? 650 image = button.checked ?
650 rb.GetImageSkiaNamed(IDR_RADIO_DISABLED_ON) : 651 rb.GetImageSkiaNamed(IDR_RADIO_DISABLED_ON) :
651 rb.GetImageSkiaNamed(IDR_RADIO_DISABLED_OFF); 652 rb.GetImageSkiaNamed(IDR_RADIO_DISABLED_OFF);
652 } else { 653 } else {
653 image = button.checked ? 654 image = button.checked ?
654 rb.GetImageSkiaNamed(IDR_RADIO_ON) : 655 rb.GetImageSkiaNamed(IDR_RADIO_ON) :
655 rb.GetImageSkiaNamed(IDR_RADIO_OFF); 656 rb.GetImageSkiaNamed(IDR_RADIO_OFF);
656 } 657 }
657 658
658 gfx::Rect bounds = rect.Center(gfx::Size(image->width(), image->height())); 659 gfx::Rect bounds = rect;
660 bounds.ClampToCenteredSize(gfx::Size(image->width(), image->height()));
659 DrawImageInt(canvas, *image, 0, 0, image->width(), image->height(), 661 DrawImageInt(canvas, *image, 0, 0, image->width(), image->height(),
660 bounds.x(), bounds.y(), bounds.width(), bounds.height()); 662 bounds.x(), bounds.y(), bounds.width(), bounds.height());
661 } 663 }
662 664
663 void NativeThemeBase::PaintRadioNew(SkCanvas* canvas, 665 void NativeThemeBase::PaintRadioNew(SkCanvas* canvas,
664 State state, 666 State state,
665 const gfx::Rect& rect, 667 const gfx::Rect& rect,
666 const ButtonExtraParams& button) const { 668 const ButtonExtraParams& button) const {
667 669
668 // Most of a radio button is the same as a checkbox, except the the rounded 670 // Most of a radio button is the same as a checkbox, except the the rounded
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
1124 SkScalar min_diff = Clamp((hsv1[1] + hsv2[1]) * 1.2f, 0.28f, 0.5f); 1126 SkScalar min_diff = Clamp((hsv1[1] + hsv2[1]) * 1.2f, 0.28f, 0.5f);
1125 SkScalar diff = Clamp(fabs(hsv1[2] - hsv2[2]) / 2, min_diff, 0.5f); 1127 SkScalar diff = Clamp(fabs(hsv1[2] - hsv2[2]) / 2, min_diff, 0.5f);
1126 1128
1127 if (hsv1[2] + hsv2[2] > 1.0) 1129 if (hsv1[2] + hsv2[2] > 1.0)
1128 diff = -diff; 1130 diff = -diff;
1129 1131
1130 return SaturateAndBrighten(hsv2, -0.2f, diff); 1132 return SaturateAndBrighten(hsv2, -0.2f, diff);
1131 } 1133 }
1132 1134
1133 } // namespace ui 1135 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/gestures/gesture_point.cc ('k') | ui/base/win/hwnd_util.cc » ('j') | ui/gfx/rect_base.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698