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

Side by Side Diff: views/controls/button/text_button.cc

Issue 7138003: Revert 88683 - Change profile menu button to avatar button (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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 | « views/controls/button/text_button.h ('k') | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "views/controls/button/text_button.h" 5 #include "views/controls/button/text_button.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 646
647 if (max_width_ > 0) 647 if (max_width_ > 0)
648 prefsize.set_width(std::min(max_width_, prefsize.width())); 648 prefsize.set_width(std::min(max_width_, prefsize.width()));
649 649
650 return prefsize; 650 return prefsize;
651 } 651 }
652 652
653 void TextButton::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) { 653 void TextButton::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) {
654 TextButtonBase::PaintButton(canvas, mode); 654 TextButtonBase::PaintButton(canvas, mode);
655 655
656 const SkBitmap& icon = GetImageToPaint(); 656 SkBitmap icon = icon_;
657 if (show_multiple_icon_states_) {
658 if (has_hover_icon_ && (state() == BS_HOT))
659 icon = icon_hover_;
660 else if (has_pushed_icon_ && (state() == BS_PUSHED))
661 icon = icon_pushed_;
662 }
657 663
658 if (icon.width() > 0) { 664 if (icon.width() > 0) {
659 gfx::Rect text_bounds = GetTextBounds(); 665 gfx::Rect text_bounds = GetTextBounds();
660 int icon_x; 666 int icon_x;
661 int spacing = text_.empty() ? 0 : icon_text_spacing_; 667 int spacing = text_.empty() ? 0 : icon_text_spacing_;
662 if (icon_placement_ == ICON_ON_LEFT) { 668 if (icon_placement_ == ICON_ON_LEFT) {
663 icon_x = text_bounds.x() - icon.width() - spacing; 669 icon_x = text_bounds.x() - icon.width() - spacing;
664 } else { 670 } else {
665 icon_x = text_bounds.right() + spacing; 671 icon_x = text_bounds.right() + spacing;
666 } 672 }
(...skipping 22 matching lines...) Expand all
689 params->button.indeterminate = false; 695 params->button.indeterminate = false;
690 params->button.is_default = is_default_; 696 params->button.is_default = is_default_;
691 params->button.has_border = false; 697 params->button.has_border = false;
692 params->button.classic_state = 0; 698 params->button.classic_state = 0;
693 params->button.background_color = kEnabledColor; 699 params->button.background_color = kEnabledColor;
694 } 700 }
695 701
696 gfx::Rect TextButton::GetTextBounds() const { 702 gfx::Rect TextButton::GetTextBounds() const {
697 int extra_width = 0; 703 int extra_width = 0;
698 704
699 const SkBitmap& icon = GetImageToPaint(); 705 SkBitmap icon = icon_;
706 if (show_multiple_icon_states_) {
707 if (has_hover_icon_ && (state() == BS_HOT))
708 icon = icon_hover_;
709 else if (has_pushed_icon_ && (state() == BS_PUSHED))
710 icon = icon_pushed_;
711 }
712
700 if (icon.width() > 0) 713 if (icon.width() > 0)
701 extra_width = icon.width() + (text_.empty() ? 0 : icon_text_spacing_); 714 extra_width = icon.width() + (text_.empty() ? 0 : icon_text_spacing_);
702 715
703 gfx::Rect bounds(GetContentBounds(extra_width)); 716 gfx::Rect bounds(GetContentBounds(extra_width));
704 717
705 if (extra_width > 0) { 718 if (extra_width > 0) {
706 // Make sure the icon is always fully visible. 719 // Make sure the icon is always fully visible.
707 if (icon_placement_ == ICON_ON_LEFT) { 720 if (icon_placement_ == ICON_ON_LEFT) {
708 bounds.Inset(extra_width, 0, 0, 0); 721 bounds.Inset(extra_width, 0, 0, 0);
709 } else { 722 } else {
710 bounds.Inset(0, 0, extra_width, 0); 723 bounds.Inset(0, 0, extra_width, 0);
711 } 724 }
712 } 725 }
713 726
714 return bounds; 727 return bounds;
715 } 728 }
716 729
717 const SkBitmap& TextButton::GetImageToPaint() const {
718 if (show_multiple_icon_states_) {
719 if (has_hover_icon_ && (state() == BS_HOT))
720 return icon_hover_;
721 if (has_pushed_icon_ && (state() == BS_PUSHED))
722 return icon_pushed_;
723 }
724 return icon_;
725 }
726
727 } // namespace views 730 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/button/text_button.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698