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

Side by Side Diff: ui/app_list/views/apps_grid_view.h

Issue 14533006: Drag and drop between app list and launcher - First patch (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed Created 7 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_APPS_GRID_VIEW_H_ 5 #ifndef UI_APP_LIST_VIEWS_APPS_GRID_VIEW_H_
6 #define UI_APP_LIST_VIEWS_APPS_GRID_VIEW_H_ 6 #define UI_APP_LIST_VIEWS_APPS_GRID_VIEW_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/timer.h" 10 #include "base/timer.h"
(...skipping 10 matching lines...) Expand all
21 namespace views { 21 namespace views {
22 class ButtonListener; 22 class ButtonListener;
23 } 23 }
24 24
25 namespace app_list { 25 namespace app_list {
26 26
27 namespace test { 27 namespace test {
28 class AppsGridViewTestApi; 28 class AppsGridViewTestApi;
29 } 29 }
30 30
31 class ApplicationDragAndDropHost;
31 class AppListItemView; 32 class AppListItemView;
32 class AppsGridViewDelegate; 33 class AppsGridViewDelegate;
33 class PageSwitcher; 34 class PageSwitcher;
34 class PaginationModel; 35 class PaginationModel;
35 36
36 // AppsGridView displays a grid for AppListModel::Apps sub model. 37 // AppsGridView displays a grid for AppListModel::Apps sub model.
37 class APP_LIST_EXPORT AppsGridView : public views::View, 38 class APP_LIST_EXPORT AppsGridView : public views::View,
38 public views::ButtonListener, 39 public views::ButtonListener,
39 public ui::ListModelObserver, 40 public ui::ListModelObserver,
40 public PaginationModelObserver, 41 public PaginationModelObserver,
(...skipping 17 matching lines...) Expand all
58 void SetModel(AppListModel* model); 59 void SetModel(AppListModel* model);
59 60
60 void SetSelectedView(views::View* view); 61 void SetSelectedView(views::View* view);
61 void ClearSelectedView(views::View* view); 62 void ClearSelectedView(views::View* view);
62 bool IsSelectedView(const views::View* view) const; 63 bool IsSelectedView(const views::View* view) const;
63 64
64 // Ensures the view is visible. Note that if there is a running page 65 // Ensures the view is visible. Note that if there is a running page
65 // transition, this does nothing. 66 // transition, this does nothing.
66 void EnsureViewVisible(const views::View* view); 67 void EnsureViewVisible(const views::View* view);
67 68
68 void InitiateDrag(views::View* view, 69 void InitiateDrag(AppListItemView* view,
69 Pointer pointer, 70 Pointer pointer,
70 const ui::LocatedEvent& event); 71 const ui::LocatedEvent& event);
71 void UpdateDrag(views::View* view, 72 void UpdateDrag(AppListItemView* view,
72 Pointer pointer, 73 Pointer pointer,
73 const ui::LocatedEvent& event); 74 const ui::LocatedEvent& event);
74 void EndDrag(bool cancel); 75 void EndDrag(bool cancel);
75 bool IsDraggedView(const views::View* view) const; 76 bool IsDraggedView(const views::View* view) const;
76 77
78 // Set the drag and drop host for application links.
79 void SetDragAndDropHostOfCurrentAppList(
80 ApplicationDragAndDropHost* drag_and_drop_host);
81
77 // Prerenders the icons on and around |page_index|. 82 // Prerenders the icons on and around |page_index|.
78 void Prerender(int page_index); 83 void Prerender(int page_index);
79 84
80 bool has_dragged_view() const { return drag_view_ != NULL; } 85 bool has_dragged_view() const { return drag_view_ != NULL; }
81 bool dragging() const { return drag_pointer_ != NONE; } 86 bool dragging() const { return drag_pointer_ != NONE; }
82 87
83 // Overridden from views::View: 88 // Overridden from views::View:
84 virtual gfx::Size GetPreferredSize() OVERRIDE; 89 virtual gfx::Size GetPreferredSize() OVERRIDE;
85 virtual void Layout() OVERRIDE; 90 virtual void Layout() OVERRIDE;
86 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; 91 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 void ExtractDragLocation(const ui::LocatedEvent& event, 155 void ExtractDragLocation(const ui::LocatedEvent& event,
151 gfx::Point* drag_point); 156 gfx::Point* drag_point);
152 157
153 // Calculates |drop_target_| based on |drag_point|. |drag_point| is in the 158 // Calculates |drop_target_| based on |drag_point|. |drag_point| is in the
154 // grid view's coordinates. When |use_page_button_hovering| is true and 159 // grid view's coordinates. When |use_page_button_hovering| is true and
155 // |drag_point| is hovering on a page button, use the last slot on that page 160 // |drag_point| is hovering on a page button, use the last slot on that page
156 // as drop target. 161 // as drop target.
157 void CalculateDropTarget(const gfx::Point& drag_point, 162 void CalculateDropTarget(const gfx::Point& drag_point,
158 bool use_page_button_hovering); 163 bool use_page_button_hovering);
159 164
165 // Dispatch the drag and drop update event to the dnd host (if needed).
166 void DispatchDragEventToDragAndDropHost(const ui::LocatedEvent& event);
167
160 // Starts the page flip timer if |drag_point| is in left/right side page flip 168 // Starts the page flip timer if |drag_point| is in left/right side page flip
161 // zone or is over page switcher. 169 // zone or is over page switcher.
162 void MaybeStartPageFlipTimer(const gfx::Point& drag_point); 170 void MaybeStartPageFlipTimer(const gfx::Point& drag_point);
163 171
164 // Invoked when |page_flip_timer_| fires. 172 // Invoked when |page_flip_timer_| fires.
165 void OnPageFlipTimer(); 173 void OnPageFlipTimer();
166 174
167 // Updates |model_| to move item represented by |item_view| to |target| slot. 175 // Updates |model_| to move item represented by |item_view| to |target| slot.
168 void MoveItemInModel(views::View* item_view, const Index& target); 176 void MoveItemInModel(views::View* item_view, const Index& target);
169 177
(...skipping 25 matching lines...) Expand all
195 int rows_per_page_; 203 int rows_per_page_;
196 204
197 // Tracks app item views. There is a view per item in |model_|. 205 // Tracks app item views. There is a view per item in |model_|.
198 views::ViewModel view_model_; 206 views::ViewModel view_model_;
199 207
200 // Tracks pulsing block views. 208 // Tracks pulsing block views.
201 views::ViewModel pulsing_blocks_model_; 209 views::ViewModel pulsing_blocks_model_;
202 210
203 views::View* selected_view_; 211 views::View* selected_view_;
204 212
205 views::View* drag_view_; 213 AppListItemView* drag_view_;
206 gfx::Point drag_start_; 214 gfx::Point drag_start_;
207 Pointer drag_pointer_; 215 Pointer drag_pointer_;
208 Index drop_target_; 216 Index drop_target_;
209 217
218 // An application target drag and drop host which accepts dnd operations.
219 ApplicationDragAndDropHost* drag_and_drop_host_;
220
221 // The drag operation is currently inside the dnd host and events get
222 // forwarded.
223 bool forward_events_to_drag_and_drop_host_;
224
210 // Last mouse drag location in this view's coordinates. 225 // Last mouse drag location in this view's coordinates.
211 gfx::Point last_drag_point_; 226 gfx::Point last_drag_point_;
212 227
213 // Timer to auto flip page when dragging an item near the left/right edges. 228 // Timer to auto flip page when dragging an item near the left/right edges.
214 base::OneShotTimer<AppsGridView> page_flip_timer_; 229 base::OneShotTimer<AppsGridView> page_flip_timer_;
215 230
216 // Target page to switch to when |page_flip_timer_| fires. 231 // Target page to switch to when |page_flip_timer_| fires.
217 int page_flip_target_; 232 int page_flip_target_;
218 233
219 // Delay in milliseconds of when |page_flip_timer_| should fire after user 234 // Delay in milliseconds of when |page_flip_timer_| should fire after user
220 // drags an item near the edges. 235 // drags an item near the edges.
221 int page_flip_delay_in_ms_; 236 int page_flip_delay_in_ms_;
222 237
223 views::BoundsAnimator bounds_animator_; 238 views::BoundsAnimator bounds_animator_;
224 239
225 DISALLOW_COPY_AND_ASSIGN(AppsGridView); 240 DISALLOW_COPY_AND_ASSIGN(AppsGridView);
226 }; 241 };
227 242
228 } // namespace app_list 243 } // namespace app_list
229 244
230 #endif // UI_APP_LIST_VIEWS_APPS_GRID_VIEW_H_ 245 #endif // UI_APP_LIST_VIEWS_APPS_GRID_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698