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

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: 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 ApplicationDnDHost;
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 SetAppListDnDHost(ApplicationDnDHost* dnd_host);
80
77 // Prerenders the icons on and around |page_index|. 81 // Prerenders the icons on and around |page_index|.
78 void Prerender(int page_index); 82 void Prerender(int page_index);
79 83
80 bool has_dragged_view() const { return drag_view_ != NULL; } 84 bool has_dragged_view() const { return drag_view_ != NULL; }
81 bool dragging() const { return drag_pointer_ != NONE; } 85 bool dragging() const { return drag_pointer_ != NONE; }
82 86
83 // Overridden from views::View: 87 // Overridden from views::View:
84 virtual gfx::Size GetPreferredSize() OVERRIDE; 88 virtual gfx::Size GetPreferredSize() OVERRIDE;
85 virtual void Layout() OVERRIDE; 89 virtual void Layout() OVERRIDE;
86 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; 90 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, 154 void ExtractDragLocation(const ui::LocatedEvent& event,
151 gfx::Point* drag_point); 155 gfx::Point* drag_point);
152 156
153 // Calculates |drop_target_| based on |drag_point|. |drag_point| is in the 157 // 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 158 // 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 159 // |drag_point| is hovering on a page button, use the last slot on that page
156 // as drop target. 160 // as drop target.
157 void CalculateDropTarget(const gfx::Point& drag_point, 161 void CalculateDropTarget(const gfx::Point& drag_point,
158 bool use_page_button_hovering); 162 bool use_page_button_hovering);
159 163
164 // Dispatch the drag and drop update event to the dnd host (if needed).
165 void DispatchDragEventToDnDHost(const ui::LocatedEvent& event);
166
160 // Starts the page flip timer if |drag_point| is in left/right side page flip 167 // Starts the page flip timer if |drag_point| is in left/right side page flip
161 // zone or is over page switcher. 168 // zone or is over page switcher.
162 void MaybeStartPageFlipTimer(const gfx::Point& drag_point); 169 void MaybeStartPageFlipTimer(const gfx::Point& drag_point);
163 170
164 // Invoked when |page_flip_timer_| fires. 171 // Invoked when |page_flip_timer_| fires.
165 void OnPageFlipTimer(); 172 void OnPageFlipTimer();
166 173
167 // Updates |model_| to move item represented by |item_view| to |target| slot. 174 // Updates |model_| to move item represented by |item_view| to |target| slot.
168 void MoveItemInModel(views::View* item_view, const Index& target); 175 void MoveItemInModel(views::View* item_view, const Index& target);
169 176
(...skipping 25 matching lines...) Expand all
195 int rows_per_page_; 202 int rows_per_page_;
196 203
197 // Tracks app item views. There is a view per item in |model_|. 204 // Tracks app item views. There is a view per item in |model_|.
198 views::ViewModel view_model_; 205 views::ViewModel view_model_;
199 206
200 // Tracks pulsing block views. 207 // Tracks pulsing block views.
201 views::ViewModel pulsing_blocks_model_; 208 views::ViewModel pulsing_blocks_model_;
202 209
203 views::View* selected_view_; 210 views::View* selected_view_;
204 211
205 views::View* drag_view_; 212 AppListItemView* drag_view_;
206 gfx::Point drag_start_; 213 gfx::Point drag_start_;
207 Pointer drag_pointer_; 214 Pointer drag_pointer_;
208 Index drop_target_; 215 Index drop_target_;
209 216
217 // An application target drag and drop host which accepts dnd operations.
218 ApplicationDnDHost* dnd_host_;
219
220 // The drag operation is currently inside the dnd host and events get
221 // dispatched.
222 bool dnd_host_dispatched_drag_;
223
210 // Last mouse drag location in this view's coordinates. 224 // Last mouse drag location in this view's coordinates.
211 gfx::Point last_drag_point_; 225 gfx::Point last_drag_point_;
212 226
213 // Timer to auto flip page when dragging an item near the left/right edges. 227 // Timer to auto flip page when dragging an item near the left/right edges.
214 base::OneShotTimer<AppsGridView> page_flip_timer_; 228 base::OneShotTimer<AppsGridView> page_flip_timer_;
215 229
216 // Target page to switch to when |page_flip_timer_| fires. 230 // Target page to switch to when |page_flip_timer_| fires.
217 int page_flip_target_; 231 int page_flip_target_;
218 232
219 // Delay in milliseconds of when |page_flip_timer_| should fire after user 233 // Delay in milliseconds of when |page_flip_timer_| should fire after user
220 // drags an item near the edges. 234 // drags an item near the edges.
221 int page_flip_delay_in_ms_; 235 int page_flip_delay_in_ms_;
222 236
223 views::BoundsAnimator bounds_animator_; 237 views::BoundsAnimator bounds_animator_;
224 238
225 DISALLOW_COPY_AND_ASSIGN(AppsGridView); 239 DISALLOW_COPY_AND_ASSIGN(AppsGridView);
226 }; 240 };
227 241
228 } // namespace app_list 242 } // namespace app_list
229 243
230 #endif // UI_APP_LIST_VIEWS_APPS_GRID_VIEW_H_ 244 #endif // UI_APP_LIST_VIEWS_APPS_GRID_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698