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

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

Issue 17370003: [Win] App launcher drag/drop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix ash Created 7 years, 6 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"
11 #include "ui/app_list/app_list_export.h" 11 #include "ui/app_list/app_list_export.h"
12 #include "ui/app_list/app_list_model.h" 12 #include "ui/app_list/app_list_model.h"
13 #include "ui/app_list/app_list_model_observer.h" 13 #include "ui/app_list/app_list_model_observer.h"
14 #include "ui/app_list/pagination_model_observer.h" 14 #include "ui/app_list/pagination_model_observer.h"
15 #include "ui/base/dragdrop/drag_source_win.h"
xiyuan 2013/06/19 05:41:38 Shouldn't this be wrapped in a #if defined(OS_WIN)
koz (OOO until 15th September) 2013/06/19 07:55:08 Done.
15 #include "ui/base/models/list_model_observer.h" 16 #include "ui/base/models/list_model_observer.h"
16 #include "ui/views/animation/bounds_animator.h" 17 #include "ui/views/animation/bounds_animator.h"
17 #include "ui/views/controls/button/button.h" 18 #include "ui/views/controls/button/button.h"
18 #include "ui/views/view.h" 19 #include "ui/views/view.h"
19 #include "ui/views/view_model.h" 20 #include "ui/views/view_model.h"
20 21
21 namespace views { 22 namespace views {
22 class ButtonListener; 23 class ButtonListener;
23 class DragImageView; 24 class DragImageView;
24 } 25 }
25 26
26 namespace app_list { 27 namespace app_list {
27 28
29 #if defined(OS_WIN)
30 class SynchronousDrag;
31 #endif
32
28 namespace test { 33 namespace test {
29 class AppsGridViewTestApi; 34 class AppsGridViewTestApi;
30 } 35 }
31 36
32 class ApplicationDragAndDropHost; 37 class ApplicationDragAndDropHost;
33 class AppListItemView; 38 class AppListItemView;
34 class AppsGridViewDelegate; 39 class AppsGridViewDelegate;
35 class PageSwitcher; 40 class PageSwitcher;
36 class PaginationModel; 41 class PaginationModel;
37 42
(...skipping 25 matching lines...) Expand all
63 void ClearSelectedView(views::View* view); 68 void ClearSelectedView(views::View* view);
64 bool IsSelectedView(const views::View* view) const; 69 bool IsSelectedView(const views::View* view) const;
65 70
66 // Ensures the view is visible. Note that if there is a running page 71 // Ensures the view is visible. Note that if there is a running page
67 // transition, this does nothing. 72 // transition, this does nothing.
68 void EnsureViewVisible(const views::View* view); 73 void EnsureViewVisible(const views::View* view);
69 74
70 void InitiateDrag(AppListItemView* view, 75 void InitiateDrag(AppListItemView* view,
71 Pointer pointer, 76 Pointer pointer,
72 const ui::LocatedEvent& event); 77 const ui::LocatedEvent& event);
73 void UpdateDrag(AppListItemView* view, 78
74 Pointer pointer, 79 // Called from AppListItemView when it receives a drag event.
75 const ui::LocatedEvent& event); 80 void UpdateDragFromItem(Pointer pointer,
81 const ui::LocatedEvent& event);
82
83 // Called when the user is dragging an app. |point| is in grid view
84 // coordinates.
85 void UpdateDrag(Pointer pointer, const gfx::Point& point);
76 void EndDrag(bool cancel); 86 void EndDrag(bool cancel);
77 bool IsDraggedView(const views::View* view) const; 87 bool IsDraggedView(const views::View* view) const;
78 88
89 void StartSettingUpSynchronousDrag();
90 bool RunSynchronousDrag();
91 void CleanUpSynchronousDrag();
92 void OnGotShortcutPath(const base::FilePath& path);
93
79 // Set the drag and drop host for application links. 94 // Set the drag and drop host for application links.
80 void SetDragAndDropHostOfCurrentAppList( 95 void SetDragAndDropHostOfCurrentAppList(
81 ApplicationDragAndDropHost* drag_and_drop_host); 96 ApplicationDragAndDropHost* drag_and_drop_host);
82 97
83 // Prerenders the icons on and around |page_index|. 98 // Prerenders the icons on and around |page_index|.
84 void Prerender(int page_index); 99 void Prerender(int page_index);
85 100
86 bool has_dragged_view() const { return drag_view_ != NULL; } 101 bool has_dragged_view() const { return drag_view_ != NULL; }
87 bool dragging() const { return drag_pointer_ != NONE; } 102 bool dragging() const { return drag_pointer_ != NONE; }
88 103
89 // Overridden from views::View: 104 // Overridden from views::View:
90 virtual gfx::Size GetPreferredSize() OVERRIDE; 105 virtual gfx::Size GetPreferredSize() OVERRIDE;
91 virtual void Layout() OVERRIDE; 106 virtual void Layout() OVERRIDE;
92 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; 107 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE;
93 virtual bool OnKeyReleased(const ui::KeyEvent& event) OVERRIDE; 108 virtual bool OnKeyReleased(const ui::KeyEvent& event) OVERRIDE;
94 virtual void ViewHierarchyChanged( 109 virtual void ViewHierarchyChanged(
95 const ViewHierarchyChangedDetails& details) OVERRIDE; 110 const ViewHierarchyChangedDetails& details) OVERRIDE;
111 virtual bool GetDropFormats(
112 int* formats,
113 std::set<OSExchangeData::CustomFormat>* custom_formats) OVERRIDE;
114 virtual bool CanDrop(const OSExchangeData& data) OVERRIDE;
115 virtual int OnDragUpdated(const ui::DropTargetEvent& event) OVERRIDE;
116
117 // Stops the timer that triggers a page flip during a drag.
118 void StopPageFlipTimer();
96 119
97 // Get the last grid view which was created. 120 // Get the last grid view which was created.
98 static AppsGridView* GetLastGridViewForTest(); 121 static AppsGridView* GetLastGridViewForTest();
99 122
100 // Return the view model for test purposes. 123 // Return the view model for test purposes.
101 const views::ViewModel* view_model_for_test() const { return &view_model_; } 124 const views::ViewModel* view_model_for_test() const { return &view_model_; }
102 125
103 // For test: Return if the drag and drop handler was set. 126 // For test: Return if the drag and drop handler was set.
104 bool has_drag_and_drop_host_for_test() { return NULL != drag_and_drop_host_; } 127 bool has_drag_and_drop_host_for_test() { return NULL != drag_and_drop_host_; }
105 128
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 gfx::Point* drag_point); 193 gfx::Point* drag_point);
171 194
172 // Calculates |drop_target_| based on |drag_point|. |drag_point| is in the 195 // Calculates |drop_target_| based on |drag_point|. |drag_point| is in the
173 // grid view's coordinates. When |use_page_button_hovering| is true and 196 // grid view's coordinates. When |use_page_button_hovering| is true and
174 // |drag_point| is hovering on a page button, use the last slot on that page 197 // |drag_point| is hovering on a page button, use the last slot on that page
175 // as drop target. 198 // as drop target.
176 void CalculateDropTarget(const gfx::Point& drag_point, 199 void CalculateDropTarget(const gfx::Point& drag_point,
177 bool use_page_button_hovering); 200 bool use_page_button_hovering);
178 201
179 // Dispatch the drag and drop update event to the dnd host (if needed). 202 // Dispatch the drag and drop update event to the dnd host (if needed).
180 void DispatchDragEventToDragAndDropHost(const ui::LocatedEvent& event); 203 void DispatchDragEventToDragAndDropHost(const gfx::Point& point);
181 204
182 // Starts the page flip timer if |drag_point| is in left/right side page flip 205 // Starts the page flip timer if |drag_point| is in left/right side page flip
183 // zone or is over page switcher. 206 // zone or is over page switcher.
184 void MaybeStartPageFlipTimer(const gfx::Point& drag_point); 207 void MaybeStartPageFlipTimer(const gfx::Point& drag_point);
185 208
186 // Invoked when |page_flip_timer_| fires. 209 // Invoked when |page_flip_timer_| fires.
187 void OnPageFlipTimer(); 210 void OnPageFlipTimer();
188 211
189 // Updates |model_| to move item represented by |item_view| to |target| slot. 212 // Updates |model_| to move item represented by |item_view| to |target| slot.
190 void MoveItemInModel(views::View* item_view, const Index& target); 213 void MoveItemInModel(views::View* item_view, const Index& target);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 245
223 // Tracks app item views. There is a view per item in |model_|. 246 // Tracks app item views. There is a view per item in |model_|.
224 views::ViewModel view_model_; 247 views::ViewModel view_model_;
225 248
226 // Tracks pulsing block views. 249 // Tracks pulsing block views.
227 views::ViewModel pulsing_blocks_model_; 250 views::ViewModel pulsing_blocks_model_;
228 251
229 views::View* selected_view_; 252 views::View* selected_view_;
230 253
231 AppListItemView* drag_view_; 254 AppListItemView* drag_view_;
232 gfx::Point drag_start_; 255
256 // The point where the drag started in AppListItemView coordinates.
257 gfx::Point drag_view_offset_;
258
259 // The point where the drag started in GridView coordinates.
260 gfx::Point drag_start_grid_view_;
261
262 // The location of |drag_view_| when the drag started.
263 gfx::Point drag_view_start_;
264
265 #if defined(OS_WIN)
266 // Created when a drag is started (ie: drag exceeds the drag threshold), but
267 // not Run() until supplied with a shortcut path.
268 scoped_refptr<SynchronousDrag> synchronous_drag_;
269 #endif
270
233 Pointer drag_pointer_; 271 Pointer drag_pointer_;
234 Index drop_target_; 272 Index drop_target_;
235 273
236 // An application target drag and drop host which accepts dnd operations. 274 // An application target drag and drop host which accepts dnd operations.
237 ApplicationDragAndDropHost* drag_and_drop_host_; 275 ApplicationDragAndDropHost* drag_and_drop_host_;
238 276
239 // The drag operation is currently inside the dnd host and events get 277 // The drag operation is currently inside the dnd host and events get
240 // forwarded. 278 // forwarded.
241 bool forward_events_to_drag_and_drop_host_; 279 bool forward_events_to_drag_and_drop_host_;
242 280
(...skipping 11 matching lines...) Expand all
254 int page_flip_delay_in_ms_; 292 int page_flip_delay_in_ms_;
255 293
256 views::BoundsAnimator bounds_animator_; 294 views::BoundsAnimator bounds_animator_;
257 295
258 DISALLOW_COPY_AND_ASSIGN(AppsGridView); 296 DISALLOW_COPY_AND_ASSIGN(AppsGridView);
259 }; 297 };
260 298
261 } // namespace app_list 299 } // namespace app_list
262 300
263 #endif // UI_APP_LIST_VIEWS_APPS_GRID_VIEW_H_ 301 #endif // UI_APP_LIST_VIEWS_APPS_GRID_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698