OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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_CONTAINER_VIEW_H_ | 5 #ifndef UI_APP_LIST_VIEWS_SEARCH_RESULT_CONTAINER_VIEW_H_ |
6 #define UI_APP_LIST_VIEWS_SEARCH_RESULT_CONTAINER_VIEW_H_ | 6 #define UI_APP_LIST_VIEWS_SEARCH_RESULT_CONTAINER_VIEW_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 // Updates the distance_from_origin() properties of the results in this | 55 // Updates the distance_from_origin() properties of the results in this |
56 // container. |y_index| is the absolute y-index of the first result of this | 56 // container. |y_index| is the absolute y-index of the first result of this |
57 // container (counting from the top of the app list). | 57 // container (counting from the top of the app list). |
58 virtual void NotifyFirstResultYIndex(int y_index) = 0; | 58 virtual void NotifyFirstResultYIndex(int y_index) = 0; |
59 | 59 |
60 // Gets the number of down keystrokes from the beginning to the end of this | 60 // Gets the number of down keystrokes from the beginning to the end of this |
61 // container. | 61 // container. |
62 virtual int GetYSize() = 0; | 62 virtual int GetYSize() = 0; |
63 | 63 |
64 // Schedules an Update call using |update_factory_|. Do nothing if there is a | 64 // Batching method that actually performs the update and updates layout. |
65 // pending call. | 65 void Update(); |
66 void ScheduleUpdate(); | |
67 | 66 |
68 // Returns whether an update is currently scheduled for this container. | 67 // Returns whether an update is currently scheduled for this container. |
69 bool UpdateScheduled(); | 68 bool UpdateScheduled(); |
70 | 69 |
71 // Overridden from ui::ListModelObserver: | 70 // Overridden from ui::ListModelObserver: |
72 void ListItemsAdded(size_t start, size_t count) override; | 71 void ListItemsAdded(size_t start, size_t count) override; |
73 void ListItemsRemoved(size_t start, size_t count) override; | 72 void ListItemsRemoved(size_t start, size_t count) override; |
74 void ListItemMoved(size_t index, size_t target_index) override; | 73 void ListItemMoved(size_t index, size_t target_index) override; |
75 void ListItemsChanged(size_t start, size_t count) override; | 74 void ListItemsChanged(size_t start, size_t count) override; |
76 | 75 |
77 // Updates the container for being selected. |from_bottom| is true if the view | 76 // Updates the container for being selected. |from_bottom| is true if the view |
78 // was entered into from a selected view below it; false if entered into from | 77 // was entered into from a selected view below it; false if entered into from |
79 // above. |directional_movement| is true if the navigation was caused by | 78 // above. |directional_movement| is true if the navigation was caused by |
80 // directional controls (eg, arrow keys), as opposed to linear controls (eg, | 79 // directional controls (eg, arrow keys), as opposed to linear controls (eg, |
81 // Tab). | 80 // Tab). |
82 virtual void OnContainerSelected(bool from_bottom, | 81 virtual void OnContainerSelected(bool from_bottom, |
83 bool directional_movement) = 0; | 82 bool directional_movement) = 0; |
84 | 83 |
85 private: | 84 private: |
| 85 // Schedules an Update call using |update_factory_|. Do nothing if there is a |
| 86 // pending call. |
| 87 void ScheduleUpdate(); |
| 88 |
86 // Updates UI with model. Returns the number of visible results. | 89 // Updates UI with model. Returns the number of visible results. |
87 virtual int Update() = 0; | 90 virtual int DoUpdate() = 0; |
88 | 91 |
89 // Updates UI for a change in the selected index. | 92 // Updates UI for a change in the selected index. |
90 virtual void UpdateSelectedIndex(int old_selected, int new_selected) = 0; | 93 virtual void UpdateSelectedIndex(int old_selected, int new_selected) = 0; |
91 | 94 |
92 // Batching method that actually performs the update and updates layout. | |
93 void DoUpdate(); | |
94 | |
95 Delegate* delegate_; | 95 Delegate* delegate_; |
96 | 96 |
97 int selected_index_; | 97 int selected_index_; |
98 int num_results_; | 98 int num_results_; |
99 | 99 |
100 double container_score_; | 100 double container_score_; |
101 | 101 |
102 AppListModel::SearchResults* results_; // Owned by AppListModel. | 102 AppListModel::SearchResults* results_; // Owned by AppListModel. |
103 | 103 |
104 // The factory that consolidates multiple Update calls into one. | 104 // The factory that consolidates multiple Update calls into one. |
105 base::WeakPtrFactory<SearchResultContainerView> update_factory_; | 105 base::WeakPtrFactory<SearchResultContainerView> update_factory_; |
106 | 106 |
107 DISALLOW_COPY_AND_ASSIGN(SearchResultContainerView); | 107 DISALLOW_COPY_AND_ASSIGN(SearchResultContainerView); |
108 }; | 108 }; |
109 | 109 |
110 } // namespace app_list | 110 } // namespace app_list |
111 | 111 |
112 #endif // UI_APP_LIST_VIEWS_SEARCH_RESULT_CONTAINER_VIEW_H_ | 112 #endif // UI_APP_LIST_VIEWS_SEARCH_RESULT_CONTAINER_VIEW_H_ |
OLD | NEW |