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 #include "ui/app_list/views/apps_grid_view.h" | 5 #include "ui/app_list/views/apps_grid_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/guid.h" | 11 #include "base/guid.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
14 #include "ui/app_list/app_list_constants.h" | 14 #include "ui/app_list/app_list_constants.h" |
15 #include "ui/app_list/app_list_folder_item.h" | 15 #include "ui/app_list/app_list_folder_item.h" |
16 #include "ui/app_list/app_list_item.h" | 16 #include "ui/app_list/app_list_item.h" |
17 #include "ui/app_list/app_list_switches.h" | 17 #include "ui/app_list/app_list_switches.h" |
18 #include "ui/app_list/pagination_controller.h" | 18 #include "ui/app_list/pagination_controller.h" |
19 #include "ui/app_list/views/app_list_drag_and_drop_host.h" | 19 #include "ui/app_list/views/app_list_drag_and_drop_host.h" |
20 #include "ui/app_list/views/app_list_folder_view.h" | 20 #include "ui/app_list/views/app_list_folder_view.h" |
21 #include "ui/app_list/views/app_list_item_view.h" | 21 #include "ui/app_list/views/app_list_item_view.h" |
22 #include "ui/app_list/views/apps_grid_view_delegate.h" | 22 #include "ui/app_list/views/apps_grid_view_delegate.h" |
23 #include "ui/app_list/views/page_switcher.h" | 23 #include "ui/app_list/views/page_switcher.h" |
24 #include "ui/app_list/views/pulsing_block_view.h" | 24 #include "ui/app_list/views/pulsing_block_view.h" |
25 #include "ui/app_list/views/top_icon_animation_view.h" | 25 #include "ui/app_list/views/top_icon_animation_view.h" |
| 26 #include "ui/compositor/layer_type.h" |
26 #include "ui/compositor/scoped_layer_animation_settings.h" | 27 #include "ui/compositor/scoped_layer_animation_settings.h" |
27 #include "ui/events/event.h" | 28 #include "ui/events/event.h" |
28 #include "ui/gfx/animation/animation.h" | 29 #include "ui/gfx/animation/animation.h" |
29 #include "ui/gfx/geometry/vector2d.h" | 30 #include "ui/gfx/geometry/vector2d.h" |
30 #include "ui/gfx/geometry/vector2d_conversions.h" | 31 #include "ui/gfx/geometry/vector2d_conversions.h" |
31 #include "ui/views/border.h" | 32 #include "ui/views/border.h" |
32 #include "ui/views/controls/label.h" | 33 #include "ui/views/controls/label.h" |
33 #include "ui/views/view_model_utils.h" | 34 #include "ui/views/view_model_utils.h" |
34 #include "ui/views/widget/widget.h" | 35 #include "ui/views/widget/widget.h" |
35 | 36 |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 drag_start_page_(-1), | 216 drag_start_page_(-1), |
216 drag_pointer_(NONE), | 217 drag_pointer_(NONE), |
217 drop_attempt_(DROP_FOR_NONE), | 218 drop_attempt_(DROP_FOR_NONE), |
218 drag_and_drop_host_(NULL), | 219 drag_and_drop_host_(NULL), |
219 forward_events_to_drag_and_drop_host_(false), | 220 forward_events_to_drag_and_drop_host_(false), |
220 page_flip_target_(-1), | 221 page_flip_target_(-1), |
221 page_flip_delay_in_ms_(kPageFlipDelayInMs), | 222 page_flip_delay_in_ms_(kPageFlipDelayInMs), |
222 bounds_animator_(this), | 223 bounds_animator_(this), |
223 activated_folder_item_view_(NULL), | 224 activated_folder_item_view_(NULL), |
224 dragging_for_reparent_item_(false) { | 225 dragging_for_reparent_item_(false) { |
225 SetPaintToLayer(true); | 226 SetPaintToLayer(ui::LAYER_TEXTURED); |
226 // Clip any icons that are outside the grid view's bounds. These icons would | 227 // Clip any icons that are outside the grid view's bounds. These icons would |
227 // otherwise be visible to the user when the grid view is off screen. | 228 // otherwise be visible to the user when the grid view is off screen. |
228 layer()->SetMasksToBounds(true); | 229 layer()->SetMasksToBounds(true); |
229 layer()->SetFillsBoundsOpaquely(false); | 230 layer()->SetFillsBoundsOpaquely(false); |
230 | 231 |
231 pagination_model_.SetTransitionDurations(kPageTransitionDurationInMs, | 232 pagination_model_.SetTransitionDurations(kPageTransitionDurationInMs, |
232 kOverscrollPageTransitionDurationMs); | 233 kOverscrollPageTransitionDurationMs); |
233 | 234 |
234 pagination_model_.AddObserver(this); | 235 pagination_model_.AddObserver(this); |
235 pagination_controller_.reset(new PaginationController( | 236 pagination_controller_.reset(new PaginationController( |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 | 552 |
552 // Since the item is new, its placeholder is conceptually at the back of the | 553 // Since the item is new, its placeholder is conceptually at the back of the |
553 // entire apps grid. | 554 // entire apps grid. |
554 reorder_placeholder_ = GetLastViewIndex(); | 555 reorder_placeholder_ = GetLastViewIndex(); |
555 | 556 |
556 // Create a new AppListItemView to duplicate the original_drag_view in the | 557 // Create a new AppListItemView to duplicate the original_drag_view in the |
557 // folder's grid view. | 558 // folder's grid view. |
558 AppListItemView* view = new AppListItemView(this, original_drag_view->item()); | 559 AppListItemView* view = new AppListItemView(this, original_drag_view->item()); |
559 AddChildView(view); | 560 AddChildView(view); |
560 drag_view_ = view; | 561 drag_view_ = view; |
561 drag_view_->SetPaintToLayer(true); | 562 drag_view_->SetPaintToLayer(ui::LAYER_TEXTURED); |
562 drag_view_->layer()->SetFillsBoundsOpaquely(false); | 563 drag_view_->layer()->SetFillsBoundsOpaquely(false); |
563 drag_view_->SetBoundsRect(drag_view_rect); | 564 drag_view_->SetBoundsRect(drag_view_rect); |
564 drag_view_->SetDragUIState(); // Hide the title of the drag_view_. | 565 drag_view_->SetDragUIState(); // Hide the title of the drag_view_. |
565 | 566 |
566 // Hide the drag_view_ for drag icon proxy when a native drag is responsible | 567 // Hide the drag_view_ for drag icon proxy when a native drag is responsible |
567 // for showing the icon. | 568 // for showing the icon. |
568 if (has_native_drag) | 569 if (has_native_drag) |
569 SetViewHidden(drag_view_, true /* hide */, true /* no animate */); | 570 SetViewHidden(drag_view_, true /* hide */, true /* no animate */); |
570 | 571 |
571 // Add drag_view_ to the end of the view_model_. | 572 // Add drag_view_ to the end of the view_model_. |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
818 AddChildView(view); | 819 AddChildView(view); |
819 } | 820 } |
820 } | 821 } |
821 | 822 |
822 AppListItemView* AppsGridView::CreateViewForItemAtIndex(size_t index) { | 823 AppListItemView* AppsGridView::CreateViewForItemAtIndex(size_t index) { |
823 // The drag_view_ might be pending for deletion, therefore view_model_ | 824 // The drag_view_ might be pending for deletion, therefore view_model_ |
824 // may have one more item than item_list_. | 825 // may have one more item than item_list_. |
825 DCHECK_LE(index, item_list_->item_count()); | 826 DCHECK_LE(index, item_list_->item_count()); |
826 AppListItemView* view = new AppListItemView(this, | 827 AppListItemView* view = new AppListItemView(this, |
827 item_list_->item_at(index)); | 828 item_list_->item_at(index)); |
828 view->SetPaintToLayer(true); | 829 view->SetPaintToLayer(ui::LAYER_TEXTURED); |
829 view->layer()->SetFillsBoundsOpaquely(false); | 830 view->layer()->SetFillsBoundsOpaquely(false); |
830 return view; | 831 return view; |
831 } | 832 } |
832 | 833 |
833 AppsGridView::Index AppsGridView::GetIndexFromModelIndex( | 834 AppsGridView::Index AppsGridView::GetIndexFromModelIndex( |
834 int model_index) const { | 835 int model_index) const { |
835 return Index(model_index / tiles_per_page(), model_index % tiles_per_page()); | 836 return Index(model_index / tiles_per_page(), model_index % tiles_per_page()); |
836 } | 837 } |
837 | 838 |
838 int AppsGridView::GetModelIndexFromIndex(const Index& index) const { | 839 int AppsGridView::GetModelIndexFromIndex(const Index& index) const { |
(...skipping 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1915 | 1916 |
1916 void AppsGridView::SetAsFolderDroppingTarget(const Index& target_index, | 1917 void AppsGridView::SetAsFolderDroppingTarget(const Index& target_index, |
1917 bool is_target_folder) { | 1918 bool is_target_folder) { |
1918 AppListItemView* target_view = | 1919 AppListItemView* target_view = |
1919 GetViewDisplayedAtSlotOnCurrentPage(target_index.slot); | 1920 GetViewDisplayedAtSlotOnCurrentPage(target_index.slot); |
1920 if (target_view) | 1921 if (target_view) |
1921 target_view->SetAsAttemptedFolderTarget(is_target_folder); | 1922 target_view->SetAsAttemptedFolderTarget(is_target_folder); |
1922 } | 1923 } |
1923 | 1924 |
1924 } // namespace app_list | 1925 } // namespace app_list |
OLD | NEW |