Commit b1d79c3b authored by fqj's avatar fqj Committed by Commit bot

Fix two issues with HoverHighlightView

1) Set the enable status of icon and label before it's being added as a
child of HoverHighlightView

2) Refuse SetHoverHightlight to true when disabled, and SetHoverHightlight
to false when OnEnabledChanged triggered and enabled() changed to false.

BUG=560013, 560027

Review URL: https://codereview.chromium.org/1470783002

Cr-Commit-Position: refs/heads/master@{#361146}
parent 65b7ffe6
...@@ -73,6 +73,7 @@ void HoverHighlightView::DoAddIconAndLabel(const gfx::ImageSkia& image, ...@@ -73,6 +73,7 @@ void HoverHighlightView::DoAddIconAndLabel(const gfx::ImageSkia& image,
views::ImageView* image_view = views::ImageView* image_view =
new FixedSizedImageView(kTrayPopupDetailsIconWidth, 0); new FixedSizedImageView(kTrayPopupDetailsIconWidth, 0);
image_view->SetImage(image); image_view->SetImage(image);
image_view->SetEnabled(enabled());
AddChildView(image_view); AddChildView(image_view);
text_label_ = new views::Label(text); text_label_ = new views::Label(text);
...@@ -80,6 +81,7 @@ void HoverHighlightView::DoAddIconAndLabel(const gfx::ImageSkia& image, ...@@ -80,6 +81,7 @@ void HoverHighlightView::DoAddIconAndLabel(const gfx::ImageSkia& image,
text_label_->SetFontList(GetFontList(highlight)); text_label_->SetFontList(GetFontList(highlight));
if (text_default_color_) if (text_default_color_)
text_label_->SetEnabledColor(text_default_color_); text_label_->SetEnabledColor(text_default_color_);
text_label_->SetEnabled(enabled());
AddChildView(text_label_); AddChildView(text_label_);
SetAccessibleName(text); SetAccessibleName(text);
...@@ -107,6 +109,7 @@ views::Label* HoverHighlightView::AddLabel(const base::string16& text, ...@@ -107,6 +109,7 @@ views::Label* HoverHighlightView::AddLabel(const base::string16& text,
text_label_->SetDisabledColor(SkColorSetARGB(255, 127, 127, 127)); text_label_->SetDisabledColor(SkColorSetARGB(255, 127, 127, 127));
if (text_default_color_) if (text_default_color_)
text_label_->SetEnabledColor(text_default_color_); text_label_->SetEnabledColor(text_default_color_);
text_label_->SetEnabled(enabled());
AddChildView(text_label_); AddChildView(text_label_);
SetAccessibleName(text); SetAccessibleName(text);
...@@ -129,6 +132,7 @@ views::Label* HoverHighlightView::AddCheckableLabel(const base::string16& text, ...@@ -129,6 +132,7 @@ views::Label* HoverHighlightView::AddCheckableLabel(const base::string16& text,
views::ImageView* image_view = new FixedSizedImageView(margin, 0); views::ImageView* image_view = new FixedSizedImageView(margin, 0);
image_view->SetImage(check); image_view->SetImage(check);
image_view->SetHorizontalAlignment(views::ImageView::TRAILING); image_view->SetHorizontalAlignment(views::ImageView::TRAILING);
image_view->SetEnabled(enabled());
AddChildView(image_view); AddChildView(image_view);
text_label_ = new views::Label(text); text_label_ = new views::Label(text);
...@@ -137,6 +141,7 @@ views::Label* HoverHighlightView::AddCheckableLabel(const base::string16& text, ...@@ -137,6 +141,7 @@ views::Label* HoverHighlightView::AddCheckableLabel(const base::string16& text,
text_label_->SetDisabledColor(SkColorSetARGB(127, 0, 0, 0)); text_label_->SetDisabledColor(SkColorSetARGB(127, 0, 0, 0));
if (text_default_color_) if (text_default_color_)
text_label_->SetEnabledColor(text_default_color_); text_label_->SetEnabledColor(text_default_color_);
text_label_->SetEnabled(enabled());
AddChildView(text_label_); AddChildView(text_label_);
SetAccessibleName(text); SetAccessibleName(text);
...@@ -153,6 +158,8 @@ void HoverHighlightView::SetExpandable(bool expandable) { ...@@ -153,6 +158,8 @@ void HoverHighlightView::SetExpandable(bool expandable) {
} }
void HoverHighlightView::SetHoverHighlight(bool hover) { void HoverHighlightView::SetHoverHighlight(bool hover) {
if (!enabled() && hover)
return;
if (hover_ == hover) if (hover_ == hover)
return; return;
hover_ = hover; hover_ = hover;
...@@ -218,6 +225,8 @@ void HoverHighlightView::OnBoundsChanged(const gfx::Rect& previous_bounds) { ...@@ -218,6 +225,8 @@ void HoverHighlightView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
} }
void HoverHighlightView::OnEnabledChanged() { void HoverHighlightView::OnEnabledChanged() {
if (!enabled())
SetHoverHighlight(false);
for (int i = 0; i < child_count(); ++i) for (int i = 0; i < child_count(); ++i)
child_at(i)->SetEnabled(enabled()); child_at(i)->SetEnabled(enabled());
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment