OLD | NEW |
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 #ifndef UI_APP_LIST_VIEWS_SEARCH_RESULT_LIST_VIEW_H_ | 5 #ifndef UI_APP_LIST_VIEWS_SEARCH_RESULT_LIST_VIEW_H_ |
6 #define UI_APP_LIST_VIEWS_SEARCH_RESULT_LIST_VIEW_H_ | 6 #define UI_APP_LIST_VIEWS_SEARCH_RESULT_LIST_VIEW_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "ui/app_list/app_list_model.h" | 10 #include "ui/app_list/app_list_model.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 class SearchResultView; | 26 class SearchResultView; |
27 | 27 |
28 // SearchResultListView displays SearchResultList with a list of | 28 // SearchResultListView displays SearchResultList with a list of |
29 // SearchResultView. | 29 // SearchResultView. |
30 class APP_LIST_EXPORT SearchResultListView : public views::View, | 30 class APP_LIST_EXPORT SearchResultListView : public views::View, |
31 public gfx::AnimationDelegate, | 31 public gfx::AnimationDelegate, |
32 public ui::ListModelObserver { | 32 public ui::ListModelObserver { |
33 public: | 33 public: |
34 SearchResultListView(SearchResultListViewDelegate* delegate, | 34 SearchResultListView(SearchResultListViewDelegate* delegate, |
35 AppListViewDelegate* view_delegate); | 35 AppListViewDelegate* view_delegate); |
36 virtual ~SearchResultListView(); | 36 ~SearchResultListView() override; |
37 | 37 |
38 void SetResults(AppListModel::SearchResults* results); | 38 void SetResults(AppListModel::SearchResults* results); |
39 | 39 |
40 void SetSelectedIndex(int selected_index); | 40 void SetSelectedIndex(int selected_index); |
41 | 41 |
42 void UpdateAutoLaunchState(); | 42 void UpdateAutoLaunchState(); |
43 | 43 |
44 bool IsResultViewSelected(const SearchResultView* result_view) const; | 44 bool IsResultViewSelected(const SearchResultView* result_view) const; |
45 | 45 |
46 void SearchResultActivated(SearchResultView* view, int event_flags); | 46 void SearchResultActivated(SearchResultView* view, int event_flags); |
47 | 47 |
48 void SearchResultActionActivated(SearchResultView* view, | 48 void SearchResultActionActivated(SearchResultView* view, |
49 size_t action_index, | 49 size_t action_index, |
50 int event_flags); | 50 int event_flags); |
51 | 51 |
52 void OnSearchResultInstalled(SearchResultView* view); | 52 void OnSearchResultInstalled(SearchResultView* view); |
53 | 53 |
54 void OnSearchResultUninstalled(SearchResultView* view); | 54 void OnSearchResultUninstalled(SearchResultView* view); |
55 | 55 |
56 // Overridden from views::View: | 56 // Overridden from views::View: |
57 virtual bool OnKeyPressed(const ui::KeyEvent& event) override; | 57 bool OnKeyPressed(const ui::KeyEvent& event) override; |
58 virtual gfx::Size GetPreferredSize() const override; | 58 gfx::Size GetPreferredSize() const override; |
59 | 59 |
60 private: | 60 private: |
61 friend class test::SearchResultListViewTest; | 61 friend class test::SearchResultListViewTest; |
62 | 62 |
63 // Updates the auto launch states. | 63 // Updates the auto launch states. |
64 void SetAutoLaunchTimeout(const base::TimeDelta& timeout); | 64 void SetAutoLaunchTimeout(const base::TimeDelta& timeout); |
65 void CancelAutoLaunchTimeout(); | 65 void CancelAutoLaunchTimeout(); |
66 | 66 |
67 // Helper function to get SearchResultView at given |index|. | 67 // Helper function to get SearchResultView at given |index|. |
68 SearchResultView* GetResultViewAt(int index); | 68 SearchResultView* GetResultViewAt(int index); |
69 | 69 |
70 // Updates UI with model. | 70 // Updates UI with model. |
71 void Update(); | 71 void Update(); |
72 | 72 |
73 // Schedules an Update call using |update_factory_|. Do nothing if there is a | 73 // Schedules an Update call using |update_factory_|. Do nothing if there is a |
74 // pending call. | 74 // pending call. |
75 void ScheduleUpdate(); | 75 void ScheduleUpdate(); |
76 | 76 |
77 // Forcibly auto-launch for test if it is in auto-launching state. | 77 // Forcibly auto-launch for test if it is in auto-launching state. |
78 void ForceAutoLaunchForTest(); | 78 void ForceAutoLaunchForTest(); |
79 | 79 |
80 // Overridden from views::View: | 80 // Overridden from views::View: |
81 virtual void Layout() override; | 81 void Layout() override; |
82 virtual int GetHeightForWidth(int w) const override; | 82 int GetHeightForWidth(int w) const override; |
83 virtual void VisibilityChanged( | 83 void VisibilityChanged(views::View* starting_from, bool is_visible) override; |
84 views::View* starting_from, bool is_visible) override; | |
85 | 84 |
86 // Overridden from gfx::AnimationDelegate: | 85 // Overridden from gfx::AnimationDelegate: |
87 virtual void AnimationEnded(const gfx::Animation* animation) override; | 86 void AnimationEnded(const gfx::Animation* animation) override; |
88 virtual void AnimationProgressed(const gfx::Animation* animation) override; | 87 void AnimationProgressed(const gfx::Animation* animation) override; |
89 | 88 |
90 // Overridden from ui::ListModelObserver: | 89 // Overridden from ui::ListModelObserver: |
91 virtual void ListItemsAdded(size_t start, size_t count) override; | 90 void ListItemsAdded(size_t start, size_t count) override; |
92 virtual void ListItemsRemoved(size_t start, size_t count) override; | 91 void ListItemsRemoved(size_t start, size_t count) override; |
93 virtual void ListItemMoved(size_t index, size_t target_index) override; | 92 void ListItemMoved(size_t index, size_t target_index) override; |
94 virtual void ListItemsChanged(size_t start, size_t count) override; | 93 void ListItemsChanged(size_t start, size_t count) override; |
95 | 94 |
96 SearchResultListViewDelegate* delegate_; // Not owned. | 95 SearchResultListViewDelegate* delegate_; // Not owned. |
97 AppListViewDelegate* view_delegate_; // Not owned. | 96 AppListViewDelegate* view_delegate_; // Not owned. |
98 AppListModel::SearchResults* results_; // Owned by AppListModel. | 97 AppListModel::SearchResults* results_; // Owned by AppListModel. |
99 | 98 |
100 views::View* results_container_; | 99 views::View* results_container_; |
101 views::View* auto_launch_indicator_; | 100 views::View* auto_launch_indicator_; |
102 scoped_ptr<gfx::LinearAnimation> auto_launch_animation_; | 101 scoped_ptr<gfx::LinearAnimation> auto_launch_animation_; |
103 | 102 |
104 int last_visible_index_; | 103 int last_visible_index_; |
105 int selected_index_; | 104 int selected_index_; |
106 | 105 |
107 // The factory that consolidates multiple Update calls into one. | 106 // The factory that consolidates multiple Update calls into one. |
108 base::WeakPtrFactory<SearchResultListView> update_factory_; | 107 base::WeakPtrFactory<SearchResultListView> update_factory_; |
109 | 108 |
110 DISALLOW_COPY_AND_ASSIGN(SearchResultListView); | 109 DISALLOW_COPY_AND_ASSIGN(SearchResultListView); |
111 }; | 110 }; |
112 | 111 |
113 } // namespace app_list | 112 } // namespace app_list |
114 | 113 |
115 #endif // UI_APP_LIST_VIEWS_SEARCH_RESULT_LIST_VIEW_H_ | 114 #endif // UI_APP_LIST_VIEWS_SEARCH_RESULT_LIST_VIEW_H_ |
OLD | NEW |