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

Side by Side Diff: ui/views/controls/combobox/combobox.cc

Issue 2383243002: Refactor MdFocusRing to make it easier to reuse on other controls. (Closed)
Patch Set: install Created 4 years, 2 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
« no previous file with comments | « ui/views/controls/button/md_text_button.cc ('k') | ui/views/controls/focus_ring.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/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 16 matching lines...) Expand all
27 #include "ui/native_theme/common_theme.h" 27 #include "ui/native_theme/common_theme.h"
28 #include "ui/native_theme/native_theme.h" 28 #include "ui/native_theme/native_theme.h"
29 #include "ui/native_theme/native_theme_aura.h" 29 #include "ui/native_theme/native_theme_aura.h"
30 #include "ui/resources/grit/ui_resources.h" 30 #include "ui/resources/grit/ui_resources.h"
31 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" 31 #include "ui/views/animation/flood_fill_ink_drop_ripple.h"
32 #include "ui/views/animation/ink_drop_highlight.h" 32 #include "ui/views/animation/ink_drop_highlight.h"
33 #include "ui/views/background.h" 33 #include "ui/views/background.h"
34 #include "ui/views/controls/button/custom_button.h" 34 #include "ui/views/controls/button/custom_button.h"
35 #include "ui/views/controls/button/label_button.h" 35 #include "ui/views/controls/button/label_button.h"
36 #include "ui/views/controls/combobox/combobox_listener.h" 36 #include "ui/views/controls/combobox/combobox_listener.h"
37 #include "ui/views/controls/focus_ring.h"
37 #include "ui/views/controls/focusable_border.h" 38 #include "ui/views/controls/focusable_border.h"
38 #include "ui/views/controls/menu/menu_config.h" 39 #include "ui/views/controls/menu/menu_config.h"
39 #include "ui/views/controls/menu/menu_model_adapter.h" 40 #include "ui/views/controls/menu/menu_model_adapter.h"
40 #include "ui/views/controls/menu/menu_runner.h" 41 #include "ui/views/controls/menu/menu_runner.h"
41 #include "ui/views/controls/prefix_selector.h" 42 #include "ui/views/controls/prefix_selector.h"
42 #include "ui/views/controls/textfield/textfield.h" 43 #include "ui/views/controls/textfield/textfield.h"
43 #include "ui/views/mouse_constants.h" 44 #include "ui/views/mouse_constants.h"
44 #include "ui/views/painter.h" 45 #include "ui/views/painter.h"
45 #include "ui/views/resources/grit/views_resources.h" 46 #include "ui/views/resources/grit/views_resources.h"
46 #include "ui/views/style/platform_style.h" 47 #include "ui/views/style/platform_style.h"
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 386
386 DISALLOW_COPY_AND_ASSIGN(ComboboxMenuModel); 387 DISALLOW_COPY_AND_ASSIGN(ComboboxMenuModel);
387 }; 388 };
388 389
389 //////////////////////////////////////////////////////////////////////////////// 390 ////////////////////////////////////////////////////////////////////////////////
390 // Combobox, public: 391 // Combobox, public:
391 392
392 Combobox::Combobox(ui::ComboboxModel* model, Style style) 393 Combobox::Combobox(ui::ComboboxModel* model, Style style)
393 : model_(model), 394 : model_(model),
394 style_(style), 395 style_(style),
395 listener_(NULL), 396 listener_(nullptr),
396 selected_index_(style == STYLE_ACTION ? 0 : model_->GetDefaultIndex()), 397 selected_index_(style == STYLE_ACTION ? 0 : model_->GetDefaultIndex()),
397 invalid_(false), 398 invalid_(false),
398 menu_model_(new ComboboxMenuModel(this, model)), 399 menu_model_(new ComboboxMenuModel(this, model)),
399 text_button_(new TransparentButton(this, style_ == STYLE_ACTION)), 400 text_button_(new TransparentButton(this, style_ == STYLE_ACTION)),
400 arrow_button_(new TransparentButton(this, style_ == STYLE_ACTION)), 401 arrow_button_(new TransparentButton(this, style_ == STYLE_ACTION)),
401 size_to_largest_label_(style_ == STYLE_NORMAL), 402 size_to_largest_label_(style_ == STYLE_NORMAL),
402 weak_ptr_factory_(this) { 403 weak_ptr_factory_(this) {
403 ModelChanged(); 404 ModelChanged();
404 #if defined(OS_MACOSX) 405 #if defined(OS_MACOSX)
405 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); 406 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY);
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 } 709 }
709 } 710 }
710 711
711 void Combobox::OnFocus() { 712 void Combobox::OnFocus() {
712 if (GetInputMethod()) 713 if (GetInputMethod())
713 GetInputMethod()->SetFocusedTextInputClient(GetPrefixSelector()); 714 GetInputMethod()->SetFocusedTextInputClient(GetPrefixSelector());
714 715
715 View::OnFocus(); 716 View::OnFocus();
716 // Border renders differently when focused. 717 // Border renders differently when focused.
717 SchedulePaint(); 718 SchedulePaint();
719 if (UseMd())
720 FocusRing::Install(this);
718 } 721 }
719 722
720 void Combobox::OnBlur() { 723 void Combobox::OnBlur() {
721 if (GetInputMethod()) 724 if (GetInputMethod())
722 GetInputMethod()->DetachTextInputClient(GetPrefixSelector()); 725 GetInputMethod()->DetachTextInputClient(GetPrefixSelector());
723 726
724 if (selector_) 727 if (selector_)
725 selector_->OnViewBlur(); 728 selector_->OnViewBlur();
726 // Border renders differently when focused. 729 // Border renders differently when focused.
727 SchedulePaint(); 730 SchedulePaint();
731 if (UseMd())
732 FocusRing::Uninstall(this);
728 } 733 }
729 734
730 void Combobox::GetAccessibleState(ui::AXViewState* state) { 735 void Combobox::GetAccessibleState(ui::AXViewState* state) {
731 state->role = ui::AX_ROLE_COMBO_BOX; 736 state->role = ui::AX_ROLE_COMBO_BOX;
732 state->name = accessible_name_; 737 state->name = accessible_name_;
733 state->value = model_->GetItemAt(selected_index_); 738 state->value = model_->GetItemAt(selected_index_);
734 state->index = selected_index_; 739 state->index = selected_index_;
735 state->count = model_->GetItemCount(); 740 state->count = model_->GetItemCount();
736 } 741 }
737 742
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 const int kMdPaddingWidth = 8; 997 const int kMdPaddingWidth = 8;
993 int arrow_pad = UseMd() ? kMdPaddingWidth 998 int arrow_pad = UseMd() ? kMdPaddingWidth
994 : PlatformStyle::kComboboxNormalArrowPadding; 999 : PlatformStyle::kComboboxNormalArrowPadding;
995 int padding = style_ == STYLE_NORMAL 1000 int padding = style_ == STYLE_NORMAL
996 ? arrow_pad * 2 1001 ? arrow_pad * 2
997 : kActionLeftPadding + kActionRightPadding; 1002 : kActionLeftPadding + kActionRightPadding;
998 return ArrowSize().width() + padding; 1003 return ArrowSize().width() + padding;
999 } 1004 }
1000 1005
1001 } // namespace views 1006 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/button/md_text_button.cc ('k') | ui/views/controls/focus_ring.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698