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

Unified Diff: ui/views/controls/combobox/combobox.cc

Issue 2383243002: Refactor MdFocusRing to make it easier to reuse on other controls. (Closed)
Patch Set: explicit onfocus 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 side-by-side diff with in-line comments
Download patch
Index: ui/views/controls/combobox/combobox.cc
diff --git a/ui/views/controls/combobox/combobox.cc b/ui/views/controls/combobox/combobox.cc
index dfd1585cc2b7c2508c7565b7a3e08a22206d56fb..1d1fff2d0ac828b107ca399f9cef6020701bd86e 100644
--- a/ui/views/controls/combobox/combobox.cc
+++ b/ui/views/controls/combobox/combobox.cc
@@ -34,6 +34,7 @@
#include "ui/views/controls/button/custom_button.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/combobox/combobox_listener.h"
+#include "ui/views/controls/focus_ring.h"
#include "ui/views/controls/focusable_border.h"
#include "ui/views/controls/menu/menu_config.h"
#include "ui/views/controls/menu/menu_model_adapter.h"
@@ -392,12 +393,13 @@ class Combobox::ComboboxMenuModel : public ui::MenuModel,
Combobox::Combobox(ui::ComboboxModel* model, Style style)
: model_(model),
style_(style),
- listener_(NULL),
+ listener_(nullptr),
selected_index_(style == STYLE_ACTION ? 0 : model_->GetDefaultIndex()),
invalid_(false),
menu_model_(new ComboboxMenuModel(this, model)),
text_button_(new TransparentButton(this, style_ == STYLE_ACTION)),
arrow_button_(new TransparentButton(this, style_ == STYLE_ACTION)),
+ focus_ring_(nullptr),
size_to_largest_label_(style_ == STYLE_NORMAL),
weak_ptr_factory_(this) {
ModelChanged();
@@ -413,6 +415,8 @@ Combobox::Combobox(ui::ComboboxModel* model, Style style)
std::unique_ptr<Background> b =
PlatformStyle::CreateComboboxBackground(GetArrowContainerWidth());
set_background(b.release());
+ focus_ring_ = new FocusRing();
+ AddChildView(focus_ring_);
}
// Initialize the button images.
@@ -715,6 +719,8 @@ void Combobox::OnFocus() {
View::OnFocus();
// Border renders differently when focused.
SchedulePaint();
+ if (UseMd())
+ focus_ring_->SetVisible(true);
}
void Combobox::OnBlur() {
@@ -725,6 +731,8 @@ void Combobox::OnBlur() {
selector_->OnViewBlur();
// Border renders differently when focused.
SchedulePaint();
+ if (UseMd())
sky 2016/10/03 23:53:15 Is there a reason not to delegate focus_ring_ here
Evan Stade 2016/10/04 01:04:55 No reason. Made a couple of statics to create and
+ focus_ring_->SetVisible(false);
}
void Combobox::GetAccessibleState(ui::AXViewState* state) {

Powered by Google App Engine
This is Rietveld 408576698