| OLD | NEW |
| 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/views/controls/combobox/combobox.h" | 5 #include "ui/views/controls/combobox/combobox.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 void Combobox::SetAccessibleName(const base::string16& name) { | 500 void Combobox::SetAccessibleName(const base::string16& name) { |
| 501 accessible_name_ = name; | 501 accessible_name_ = name; |
| 502 } | 502 } |
| 503 | 503 |
| 504 void Combobox::SetInvalid(bool invalid) { | 504 void Combobox::SetInvalid(bool invalid) { |
| 505 if (invalid == invalid_) | 505 if (invalid == invalid_) |
| 506 return; | 506 return; |
| 507 | 507 |
| 508 invalid_ = invalid; | 508 invalid_ = invalid; |
| 509 | 509 |
| 510 if (HasFocus() && UseMd()) { |
| 511 FocusRing::Install(this, invalid_ |
| 512 ? ui::NativeTheme::kColorId_AlertSeverityHigh |
| 513 : ui::NativeTheme::kColorId_NumColors); |
| 514 } |
| 510 UpdateBorder(); | 515 UpdateBorder(); |
| 511 SchedulePaint(); | 516 SchedulePaint(); |
| 512 } | 517 } |
| 513 | 518 |
| 514 void Combobox::Layout() { | 519 void Combobox::Layout() { |
| 515 View::Layout(); | 520 View::Layout(); |
| 516 | 521 |
| 517 int text_button_width = 0; | 522 int text_button_width = 0; |
| 518 int arrow_button_width = 0; | 523 int arrow_button_width = 0; |
| 519 | 524 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 } | 708 } |
| 704 } | 709 } |
| 705 | 710 |
| 706 void Combobox::OnFocus() { | 711 void Combobox::OnFocus() { |
| 707 if (GetInputMethod()) | 712 if (GetInputMethod()) |
| 708 GetInputMethod()->SetFocusedTextInputClient(GetPrefixSelector()); | 713 GetInputMethod()->SetFocusedTextInputClient(GetPrefixSelector()); |
| 709 | 714 |
| 710 View::OnFocus(); | 715 View::OnFocus(); |
| 711 // Border renders differently when focused. | 716 // Border renders differently when focused. |
| 712 SchedulePaint(); | 717 SchedulePaint(); |
| 713 if (UseMd()) | 718 if (UseMd()) { |
| 714 FocusRing::Install(this); | 719 FocusRing::Install(this, invalid_ |
| 720 ? ui::NativeTheme::kColorId_AlertSeverityHigh |
| 721 : ui::NativeTheme::kColorId_NumColors); |
| 722 } |
| 715 } | 723 } |
| 716 | 724 |
| 717 void Combobox::OnBlur() { | 725 void Combobox::OnBlur() { |
| 718 if (GetInputMethod()) | 726 if (GetInputMethod()) |
| 719 GetInputMethod()->DetachTextInputClient(GetPrefixSelector()); | 727 GetInputMethod()->DetachTextInputClient(GetPrefixSelector()); |
| 720 | 728 |
| 721 if (selector_) | 729 if (selector_) |
| 722 selector_->OnViewBlur(); | 730 selector_->OnViewBlur(); |
| 723 // Border renders differently when focused. | 731 // Border renders differently when focused. |
| 724 SchedulePaint(); | 732 SchedulePaint(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 source_type = ui::MENU_SOURCE_TOUCH; | 766 source_type = ui::MENU_SOURCE_TOUCH; |
| 759 ShowDropDownMenu(source_type); | 767 ShowDropDownMenu(source_type); |
| 760 } | 768 } |
| 761 } | 769 } |
| 762 | 770 |
| 763 void Combobox::UpdateBorder() { | 771 void Combobox::UpdateBorder() { |
| 764 std::unique_ptr<FocusableBorder> border(new FocusableBorder()); | 772 std::unique_ptr<FocusableBorder> border(new FocusableBorder()); |
| 765 if (style_ == STYLE_ACTION) | 773 if (style_ == STYLE_ACTION) |
| 766 border->SetInsets(5, 10, 5, 10); | 774 border->SetInsets(5, 10, 5, 10); |
| 767 if (invalid_) | 775 if (invalid_) |
| 768 border->SetColor(gfx::kGoogleRed700); | 776 border->SetColorId(ui::NativeTheme::kColorId_AlertSeverityHigh); |
| 769 SetBorder(std::move(border)); | 777 SetBorder(std::move(border)); |
| 770 } | 778 } |
| 771 | 779 |
| 772 void Combobox::AdjustBoundsForRTLUI(gfx::Rect* rect) const { | 780 void Combobox::AdjustBoundsForRTLUI(gfx::Rect* rect) const { |
| 773 rect->set_x(GetMirroredXForRect(*rect)); | 781 rect->set_x(GetMirroredXForRect(*rect)); |
| 774 } | 782 } |
| 775 | 783 |
| 776 void Combobox::PaintText(gfx::Canvas* canvas) { | 784 void Combobox::PaintText(gfx::Canvas* canvas) { |
| 777 gfx::Insets insets = GetInsets(); | 785 gfx::Insets insets = GetInsets(); |
| 778 insets += gfx::Insets(0, Textfield::kTextPadding, 0, Textfield::kTextPadding); | 786 insets += gfx::Insets(0, Textfield::kTextPadding, 0, Textfield::kTextPadding); |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 990 const int kMdPaddingWidth = 8; | 998 const int kMdPaddingWidth = 8; |
| 991 int arrow_pad = UseMd() ? kMdPaddingWidth | 999 int arrow_pad = UseMd() ? kMdPaddingWidth |
| 992 : PlatformStyle::kComboboxNormalArrowPadding; | 1000 : PlatformStyle::kComboboxNormalArrowPadding; |
| 993 int padding = style_ == STYLE_NORMAL | 1001 int padding = style_ == STYLE_NORMAL |
| 994 ? arrow_pad * 2 | 1002 ? arrow_pad * 2 |
| 995 : kActionLeftPadding + kActionRightPadding; | 1003 : kActionLeftPadding + kActionRightPadding; |
| 996 return ArrowSize().width() + padding; | 1004 return ArrowSize().width() + padding; |
| 997 } | 1005 } |
| 998 | 1006 |
| 999 } // namespace views | 1007 } // namespace views |
| OLD | NEW |