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

Unified Diff: ui/app_list/views/search_result_answer_card_view.cc

Issue 2920393002: Implementing answer card hover highlight. (Closed)
Patch Set: CR comments Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/app_list/search_result_observer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/app_list/views/search_result_answer_card_view.cc
diff --git a/ui/app_list/views/search_result_answer_card_view.cc b/ui/app_list/views/search_result_answer_card_view.cc
index 3e36ba067c360adc394658d5e7ddff41c1584de9..e5b683c7f9b7940f8d6ddbcc0c0bbe3a8e1b147d 100644
--- a/ui/app_list/views/search_result_answer_card_view.cc
+++ b/ui/app_list/views/search_result_answer_card_view.cc
@@ -7,6 +7,7 @@
#include "ui/app_list/app_list_constants.h"
#include "ui/app_list/app_list_features.h"
#include "ui/app_list/app_list_view_delegate.h"
+#include "ui/app_list/search_result_observer.h"
#include "ui/views/background.h"
#include "ui/views/controls/button/custom_button.h"
#include "ui/views/layout/box_layout.h"
@@ -17,7 +18,8 @@ namespace app_list {
// Container of the search answer view.
class SearchResultAnswerCardView::SearchAnswerContainerView
: public views::CustomButton,
- public views::ButtonListener {
+ public views::ButtonListener,
+ public SearchResultObserver {
public:
explicit SearchAnswerContainerView(AppListViewDelegate* view_delegate)
: CustomButton(this), view_delegate_(view_delegate) {
@@ -49,7 +51,11 @@ class SearchResultAnswerCardView::SearchAnswerContainerView
AddChildView(new_result_view);
}
+ if (search_result_)
+ search_result_->RemoveObserver(this);
search_result_ = search_result ? search_result->Duplicate() : nullptr;
+ if (search_result_)
+ search_result_->AddObserver(this);
SetVisible(new_result_view != nullptr);
}
@@ -69,12 +75,19 @@ class SearchResultAnswerCardView::SearchAnswerContainerView
event.flags());
}
+ // SearchResultObserver overrides:
+ void OnViewHoverStateChanged() override { UpdateBackgroundColor(); }
+
private:
void UpdateBackgroundColor() {
- if (selected_)
+ if (selected_) {
SetBackground(views::CreateSolidBackground(kSelectedColor));
- else if (state() == STATE_HOVERED || state() == STATE_PRESSED)
+ } else if (state() == STATE_HOVERED || state() == STATE_PRESSED ||
+ (search_result_ && search_result_->is_mouse_in_view())) {
SetBackground(views::CreateSolidBackground(kHighlightedColor));
+ } else {
+ SetBackground(nullptr);
+ }
SchedulePaint();
}
« no previous file with comments | « ui/app_list/search_result_observer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698