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