| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef UI_APP_LIST_VIEWS_SEARCH_RESULT_ACTIONS_VIEW_H_ | 5 #ifndef UI_APP_LIST_VIEWS_SEARCH_RESULT_ACTIONS_VIEW_H_ |
| 6 #define UI_APP_LIST_VIEWS_SEARCH_RESULT_ACTIONS_VIEW_H_ | 6 #define UI_APP_LIST_VIEWS_SEARCH_RESULT_ACTIONS_VIEW_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "ui/app_list/search_result.h" | 9 #include "ui/app_list/search_result.h" |
| 10 #include "ui/views/controls/button/button.h" | 10 #include "ui/views/controls/button/image_button.h" |
| 11 #include "ui/views/view.h" | 11 #include "ui/views/view.h" |
| 12 | 12 |
| 13 namespace app_list { | 13 namespace app_list { |
| 14 | 14 |
| 15 class SearchResultActionsViewDelegate; | 15 class SearchResultActionsViewDelegate; |
| 16 | 16 |
| 17 // SearchResultActionsView displays a SearchResult::Actions in a button | 17 // SearchResultActionsView displays a SearchResult::Actions in a button |
| 18 // strip. Each action is presented as a button and horizontally laid out. | 18 // strip. Each action is presented as a button and horizontally laid out. |
| 19 class SearchResultActionsView : public views::View, | 19 class SearchResultActionsView : public views::View, |
| 20 public views::ButtonListener { | 20 public views::ImageButtonDelegate { |
| 21 public: | 21 public: |
| 22 explicit SearchResultActionsView(SearchResultActionsViewDelegate* delegate); | 22 explicit SearchResultActionsView(SearchResultActionsViewDelegate* delegate); |
| 23 ~SearchResultActionsView() override; | 23 ~SearchResultActionsView() override; |
| 24 | 24 |
| 25 void SetActions(const SearchResult::Actions& actions); | 25 void SetActions(const SearchResult::Actions& actions); |
| 26 | 26 |
| 27 void SetSelectedAction(int action_index); | 27 void SetSelectedAction(int action_index); |
| 28 int selected_action() const { return selected_action_; } | 28 int selected_action() const { return selected_action_; } |
| 29 | 29 |
| 30 bool IsValidActionIndex(int action_index) const; | 30 bool IsValidActionIndex(int action_index) const; |
| 31 | 31 |
| 32 private: | 32 private: |
| 33 void CreateImageButton(const SearchResult::Action& action); | 33 void CreateImageButton(const SearchResult::Action& action); |
| 34 void CreateBlueButton(const SearchResult::Action& action); | 34 void CreateBlueButton(const SearchResult::Action& action); |
| 35 | 35 |
| 36 // views::View overrides: | 36 // views::View: |
| 37 void OnPaint(gfx::Canvas* canvas) override; | 37 void OnPaint(gfx::Canvas* canvas) override; |
| 38 | 38 |
| 39 // views::ButtonListener overrides: | 39 // views::ImageButtonDelegate: |
| 40 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | 40 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| 41 | 41 |
| 42 SearchResultActionsViewDelegate* delegate_; // Not owned. | 42 SearchResultActionsViewDelegate* delegate_; // Not owned. |
| 43 int selected_action_; | 43 int selected_action_; |
| 44 | 44 |
| 45 DISALLOW_COPY_AND_ASSIGN(SearchResultActionsView); | 45 DISALLOW_COPY_AND_ASSIGN(SearchResultActionsView); |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 } // namespace app_list | 48 } // namespace app_list |
| 49 | 49 |
| 50 #endif // UI_APP_LIST_VIEWS_SEARCH_RESULT_ACTIONS_VIEW_H_ | 50 #endif // UI_APP_LIST_VIEWS_SEARCH_RESULT_ACTIONS_VIEW_H_ |
| OLD | NEW |