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