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

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: Add comment. 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
« no previous file with comments | « ui/base/native_theme/native_theme.h ('k') | ui/views/controls/button/text_button.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/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,
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);
501 501
502 // Our standard gradient is from 0xdd to 0xf8. This is the amount of 502 // Our standard gradient is from 0xdd to 0xf8. This is the amount of
(...skipping 21 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 int border_alpha = state == kHovered ? 0x80 : 0x55;
535 if (button.is_focused) {
536 border_alpha = 0xff;
537 paint.setColor(GetSystemColor(kColorId_FocusedBorderColor));
538 }
535 paint.setStyle(SkPaint::kStroke_Style); 539 paint.setStyle(SkPaint::kStroke_Style);
536 paint.setStrokeWidth(SkIntToScalar(1)); 540 paint.setStrokeWidth(SkIntToScalar(1));
537 paint.setARGB(kBorderAlpha, 0, 0, 0); 541 paint.setAlpha(border_alpha);
538 skrect.inset(SkFloatToScalar(.5f), SkFloatToScalar(.5f)); 542 skrect.inset(SkFloatToScalar(.5f), SkFloatToScalar(.5f));
539 canvas->drawRoundRect(skrect, SkIntToScalar(1), SkIntToScalar(1), paint); 543 canvas->drawRoundRect(skrect, SkIntToScalar(1), SkIntToScalar(1), paint);
540 } 544 }
541 } 545 }
542 546
543 void NativeThemeBase::PaintTextField(SkCanvas* canvas, 547 void NativeThemeBase::PaintTextField(SkCanvas* canvas,
544 State state, 548 State state,
545 const gfx::Rect& rect, 549 const gfx::Rect& rect,
546 const TextFieldExtraParams& text) const { 550 const TextFieldExtraParams& text) const {
547 // The following drawing code simulates the user-agent css border for 551 // 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); 910 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); 911 SkScalar diff = Clamp(fabs(hsv1[2] - hsv2[2]) / 2, min_diff, 0.5f);
908 912
909 if (hsv1[2] + hsv2[2] > 1.0) 913 if (hsv1[2] + hsv2[2] > 1.0)
910 diff = -diff; 914 diff = -diff;
911 915
912 return SaturateAndBrighten(hsv2, -0.2f, diff); 916 return SaturateAndBrighten(hsv2, -0.2f, diff);
913 } 917 }
914 918
915 } // namespace ui 919 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/native_theme/native_theme.h ('k') | ui/views/controls/button/text_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698