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

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

Issue 10513009: Indicate focused state on text buttons with blue outline. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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
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/logging.h" 9 #include "base/logging.h"
10 #include "grit/ui_resources_standard.h" 10 #include "grit/ui_resources_standard.h"
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 rb.GetImageSkiaNamed(IDR_RADIO_ON) : 480 rb.GetImageSkiaNamed(IDR_RADIO_ON) :
481 rb.GetImageSkiaNamed(IDR_RADIO_OFF); 481 rb.GetImageSkiaNamed(IDR_RADIO_OFF);
482 } 482 }
483 483
484 gfx::Rect bounds = rect.Center(gfx::Size(image->width(), image->height())); 484 gfx::Rect bounds = rect.Center(gfx::Size(image->width(), image->height()));
485 DrawBitmapInt(canvas, *image, 0, 0, image->width(), image->height(), 485 DrawBitmapInt(canvas, *image, 0, 0, image->width(), image->height(),
486 bounds.x(), bounds.y(), bounds.width(), bounds.height()); 486 bounds.x(), bounds.y(), bounds.width(), bounds.height());
487 } 487 }
488 488
489 void NativeThemeBase::PaintButton(SkCanvas* canvas, 489 void NativeThemeBase::PaintButton(SkCanvas* canvas,
490 State state, 490 State state,
tony 2012/06/04 19:20:45 Can you fix the indenting while you're here?
flackr 2012/06/05 14:13:18 Done.
491 const gfx::Rect& rect, 491 const gfx::Rect& rect,
492 const ButtonExtraParams& button) const { 492 const ButtonExtraParams& button) const {
493 SkPaint paint; 493 SkPaint paint;
494 const int kRight = rect.right(); 494 const int kRight = rect.right();
495 const int kBottom = rect.bottom(); 495 const int kBottom = rect.bottom();
496 SkRect skrect = SkRect::MakeLTRB(rect.x(), rect.y(), kRight, kBottom); 496 SkRect skrect = SkRect::MakeLTRB(rect.x(), rect.y(), kRight, kBottom);
497 SkColor base_color = button.background_color; 497 SkColor base_color = button.background_color;
498 498
499 color_utils::HSL base_hsl; 499 color_utils::HSL base_hsl;
500 color_utils::SkColorToHSL(base_color, &base_hsl); 500 color_utils::SkColorToHSL(base_color, &base_hsl);
(...skipping 23 matching lines...) Expand all
524 gradient_bounds, colors, NULL, 2, SkShader::kClamp_TileMode, NULL); 524 gradient_bounds, colors, NULL, 2, SkShader::kClamp_TileMode, NULL);
525 paint.setStyle(SkPaint::kFill_Style); 525 paint.setStyle(SkPaint::kFill_Style);
526 paint.setAntiAlias(true); 526 paint.setAntiAlias(true);
527 paint.setShader(shader); 527 paint.setShader(shader);
528 shader->unref(); 528 shader->unref();
529 529
530 canvas->drawRoundRect(skrect, SkIntToScalar(1), SkIntToScalar(1), paint); 530 canvas->drawRoundRect(skrect, SkIntToScalar(1), SkIntToScalar(1), paint);
531 paint.setShader(NULL); 531 paint.setShader(NULL);
532 532
533 if (button.has_border) { 533 if (button.has_border) {
534 const int kBorderAlpha = state == kHovered ? 0x80 : 0x55; 534 const int kBorderAlpha = button.is_focused ? 0xff :
535 state == kHovered ? 0x80 : 0x55;
tony 2012/06/04 19:20:45 Nit: Nested ternary operators are hard to read. C
flackr 2012/06/05 14:13:18 Done.
536 if (button.is_focused)
537 paint.setColor(GetSystemColor(kColorId_FocusedBorderColor));
535 paint.setStyle(SkPaint::kStroke_Style); 538 paint.setStyle(SkPaint::kStroke_Style);
536 paint.setStrokeWidth(SkIntToScalar(1)); 539 paint.setStrokeWidth(SkIntToScalar(1));
537 paint.setARGB(kBorderAlpha, 0, 0, 0); 540 paint.setAlpha(kBorderAlpha);
538 skrect.inset(SkFloatToScalar(.5f), SkFloatToScalar(.5f)); 541 skrect.inset(SkFloatToScalar(.5f), SkFloatToScalar(.5f));
539 canvas->drawRoundRect(skrect, SkIntToScalar(1), SkIntToScalar(1), paint); 542 canvas->drawRoundRect(skrect, SkIntToScalar(1), SkIntToScalar(1), paint);
540 } 543 }
541 } 544 }
542 545
543 void NativeThemeBase::PaintTextField(SkCanvas* canvas, 546 void NativeThemeBase::PaintTextField(SkCanvas* canvas,
544 State state, 547 State state,
545 const gfx::Rect& rect, 548 const gfx::Rect& rect,
546 const TextFieldExtraParams& text) const { 549 const TextFieldExtraParams& text) const {
547 // The following drawing code simulates the user-agent css border for 550 // The following drawing code simulates the user-agent css border for
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 SkScalar min_diff = Clamp((hsv1[1] + hsv2[1]) * 1.2f, 0.28f, 0.5f); 909 SkScalar min_diff = Clamp((hsv1[1] + hsv2[1]) * 1.2f, 0.28f, 0.5f);
907 SkScalar diff = Clamp(fabs(hsv1[2] - hsv2[2]) / 2, min_diff, 0.5f); 910 SkScalar diff = Clamp(fabs(hsv1[2] - hsv2[2]) / 2, min_diff, 0.5f);
908 911
909 if (hsv1[2] + hsv2[2] > 1.0) 912 if (hsv1[2] + hsv2[2] > 1.0)
910 diff = -diff; 913 diff = -diff;
911 914
912 return SaturateAndBrighten(hsv2, -0.2f, diff); 915 return SaturateAndBrighten(hsv2, -0.2f, diff);
913 } 916 }
914 917
915 } // namespace ui 918 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698