diff options
author | rbyers@chromium.org <rbyers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-08 07:31:23 +0000 |
---|---|---|
committer | rbyers@chromium.org <rbyers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-08 07:31:23 +0000 |
commit | a244f258f3b9a2492cf455cddab48636d615f70c (patch) | |
tree | 0f610464e15e312003d285ed0dba1e825a880935 /ui/native_theme/native_theme_base.cc | |
parent | 2d765c6319ef03c69348d089918d5d0f4a43935e (diff) | |
download | chromium_src-a244f258f3b9a2492cf455cddab48636d615f70c.zip chromium_src-a244f258f3b9a2492cf455cddab48636d615f70c.tar.gz chromium_src-a244f258f3b9a2492cf455cddab48636d615f70c.tar.bz2 |
Remove old-checkbox-style flag, code and assets
BUG=133991
Review URL: https://chromiumcodereview.appspot.com/12383065
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@186915 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/native_theme/native_theme_base.cc')
-rw-r--r-- | ui/native_theme/native_theme_base.cc | 129 |
1 files changed, 30 insertions, 99 deletions
diff --git a/ui/native_theme/native_theme_base.cc b/ui/native_theme/native_theme_base.cc index 6f2147f..97961a1 100644 --- a/ui/native_theme/native_theme_base.cc +++ b/ui/native_theme/native_theme_base.cc @@ -473,52 +473,45 @@ void NativeThemeBase::PaintScrollbarThumb(SkCanvas* canvas, } } -bool NativeThemeBase::IsNewCheckboxStyleEnabled(SkCanvas* canvas) const { - // The new style is now the default. - // TODO(rbyers): Remove this flag once we're sure the new behavior is fine. - // http://crbug.com/133991 - if (!CommandLine::ForCurrentProcess()->HasSwitch( - switches::kOldCheckboxStyle)) - return true; - - return false; -} - void NativeThemeBase::PaintCheckbox(SkCanvas* canvas, State state, const gfx::Rect& rect, const ButtonExtraParams& button) const { - if (IsNewCheckboxStyleEnabled(canvas)) { - PaintCheckboxNew(canvas, state, rect, button); - return; - } - - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - gfx::ImageSkia* image = NULL; - if (button.indeterminate) { - image = state == kDisabled ? - rb.GetImageSkiaNamed(IDR_CHECKBOX_DISABLED_INDETERMINATE) : - rb.GetImageSkiaNamed(IDR_CHECKBOX_INDETERMINATE); - } else if (button.checked) { - image = state == kDisabled ? - rb.GetImageSkiaNamed(IDR_CHECKBOX_DISABLED_ON) : - rb.GetImageSkiaNamed(IDR_CHECKBOX_ON); - } else { - image = state == kDisabled ? - rb.GetImageSkiaNamed(IDR_CHECKBOX_DISABLED_OFF) : - rb.GetImageSkiaNamed(IDR_CHECKBOX_OFF); + SkRect skrect = PaintCheckboxRadioCommon(canvas, state, rect, + SkIntToScalar(2)); + if (!skrect.isEmpty()) { + // Draw the checkmark / dash. + SkPaint paint; + paint.setAntiAlias(true); + paint.setStyle(SkPaint::kStroke_Style); + if (state == kDisabled) + paint.setColor(kCheckboxStrokeDisabledColor); + else + paint.setColor(kCheckboxStrokeColor); + if (button.indeterminate) { + SkPath dash; + dash.moveTo(skrect.x() + skrect.width() * 0.16, + (skrect.y() + skrect.bottom()) / 2); + dash.rLineTo(skrect.width() * 0.68, 0); + paint.setStrokeWidth(SkFloatToScalar(skrect.height() * 0.2)); + canvas->drawPath(dash, paint); + } else if (button.checked) { + SkPath check; + check.moveTo(skrect.x() + skrect.width() * 0.2, + skrect.y() + skrect.height() * 0.5); + check.rLineTo(skrect.width() * 0.2, skrect.height() * 0.2); + paint.setStrokeWidth(SkFloatToScalar(skrect.height() * 0.23)); + check.lineTo(skrect.right() - skrect.width() * 0.2, + skrect.y() + skrect.height() * 0.2); + canvas->drawPath(check, paint); + } } - - gfx::Rect bounds = rect; - bounds.ClampToCenteredSize(gfx::Size(image->width(), image->height())); - DrawImageInt(canvas, *image, 0, 0, image->width(), image->height(), - bounds.x(), bounds.y(), bounds.width(), bounds.height()); } // Draws the common elements of checkboxes and radio buttons. // Returns the rectangle within which any additional decorations should be // drawn, or empty if none. -SkRect NativeThemeBase::PaintCheckboxRadioNewCommon( +SkRect NativeThemeBase::PaintCheckboxRadioCommon( SkCanvas* canvas, State state, const gfx::Rect& rect, @@ -607,78 +600,16 @@ SkRect NativeThemeBase::PaintCheckboxRadioNewCommon( return skrect; } -void NativeThemeBase::PaintCheckboxNew(SkCanvas* canvas, - State state, - const gfx::Rect& rect, - const ButtonExtraParams& button) const { - SkRect skrect = PaintCheckboxRadioNewCommon(canvas, state, rect, - SkIntToScalar(2)); - if (!skrect.isEmpty()) { - // Draw the checkmark / dash. - SkPaint paint; - paint.setAntiAlias(true); - paint.setStyle(SkPaint::kStroke_Style); - if (state == kDisabled) - paint.setColor(kCheckboxStrokeDisabledColor); - else - paint.setColor(kCheckboxStrokeColor); - if (button.indeterminate) { - SkPath dash; - dash.moveTo(skrect.x() + skrect.width() * 0.16, - (skrect.y() + skrect.bottom()) / 2); - dash.rLineTo(skrect.width() * 0.68, 0); - paint.setStrokeWidth(SkFloatToScalar(skrect.height() * 0.2)); - canvas->drawPath(dash, paint); - } else if (button.checked) { - SkPath check; - check.moveTo(skrect.x() + skrect.width() * 0.2, - skrect.y() + skrect.height() * 0.5); - check.rLineTo(skrect.width() * 0.2, skrect.height() * 0.2); - paint.setStrokeWidth(SkFloatToScalar(skrect.height() * 0.23)); - check.lineTo(skrect.right() - skrect.width() * 0.2, - skrect.y() + skrect.height() * 0.2); - canvas->drawPath(check, paint); - } - } -} - void NativeThemeBase::PaintRadio(SkCanvas* canvas, State state, const gfx::Rect& rect, const ButtonExtraParams& button) const { - if (IsNewCheckboxStyleEnabled(canvas)) { - PaintRadioNew(canvas, state, rect, button); - return; - } - - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - gfx::ImageSkia* image = NULL; - if (state == kDisabled) { - image = button.checked ? - rb.GetImageSkiaNamed(IDR_RADIO_DISABLED_ON) : - rb.GetImageSkiaNamed(IDR_RADIO_DISABLED_OFF); - } else { - image = button.checked ? - rb.GetImageSkiaNamed(IDR_RADIO_ON) : - rb.GetImageSkiaNamed(IDR_RADIO_OFF); - } - - gfx::Rect bounds = rect; - bounds.ClampToCenteredSize(gfx::Size(image->width(), image->height())); - DrawImageInt(canvas, *image, 0, 0, image->width(), image->height(), - bounds.x(), bounds.y(), bounds.width(), bounds.height()); -} - -void NativeThemeBase::PaintRadioNew(SkCanvas* canvas, - State state, - const gfx::Rect& rect, - const ButtonExtraParams& button) const { // Most of a radio button is the same as a checkbox, except the the rounded // square is a circle (i.e. border radius >= 100%). const SkScalar radius = SkFloatToScalar( static_cast<float>(std::max(rect.width(), rect.height())) / 2); - SkRect skrect = PaintCheckboxRadioNewCommon(canvas, state, rect, radius); + SkRect skrect = PaintCheckboxRadioCommon(canvas, state, rect, radius); if (!skrect.isEmpty() && button.checked) { // Draw the dot. SkPaint paint; |