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

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

Issue 187483005: Extending the Views-on-Mac experiment: whole app list grid. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: still compiles r263560 + crrev/195793005 Created 6 years, 8 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
« no previous file with comments | « ui/app_list/views/apps_grid_view.h ('k') | ui/app_list/views/contents_switcher_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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 "content/public/browser/web_contents.h" 12 #include "content/public/browser/web_contents.h"
13 #include "ui/app_list/app_list_constants.h" 13 #include "ui/app_list/app_list_constants.h"
14 #include "ui/app_list/app_list_folder_item.h" 14 #include "ui/app_list/app_list_folder_item.h"
15 #include "ui/app_list/app_list_item.h" 15 #include "ui/app_list/app_list_item.h"
16 #include "ui/app_list/app_list_switches.h" 16 #include "ui/app_list/app_list_switches.h"
17 #include "ui/app_list/pagination_model.h" 17 #include "ui/app_list/pagination_model.h"
18 #include "ui/app_list/views/app_list_drag_and_drop_host.h" 18 #include "ui/app_list/views/app_list_drag_and_drop_host.h"
19 #include "ui/app_list/views/app_list_folder_view.h" 19 //#include "ui/app_list/views/app_list_folder_view.h"
20 #include "ui/app_list/views/app_list_item_view.h" 20 #include "ui/app_list/views/app_list_item_view.h"
21 #include "ui/app_list/views/apps_grid_view_delegate.h" 21 #include "ui/app_list/views/apps_grid_view_delegate.h"
22 #include "ui/app_list/views/apps_grid_view_folder_delegate.h"
22 #include "ui/app_list/views/page_switcher.h" 23 #include "ui/app_list/views/page_switcher.h"
23 #include "ui/app_list/views/pulsing_block_view.h" 24 //#include "ui/app_list/views/pulsing_block_view.h"
24 #include "ui/app_list/views/top_icon_animation_view.h" 25 #include "ui/app_list/views/top_icon_animation_view.h"
25 #include "ui/compositor/scoped_layer_animation_settings.h" 26 #include "ui/compositor/scoped_layer_animation_settings.h"
26 #include "ui/events/event.h" 27 #include "ui/events/event.h"
27 #include "ui/gfx/animation/animation.h" 28 #include "ui/gfx/animation/animation.h"
28 #include "ui/views/border.h" 29 #include "ui/views/border.h"
29 #include "ui/views/controls/webview/webview.h" 30 #include "ui/views/controls/webview/webview.h"
30 #include "ui/views/view_model_utils.h" 31 #include "ui/views/view_model_utils.h"
31 #include "ui/views/widget/widget.h" 32 #include "ui/views/widget/widget.h"
32 33
33 #if defined(USE_AURA) 34 #if defined(USE_AURA)
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 gfx::Point drag_view_offset_; 305 gfx::Point drag_view_offset_;
305 bool has_shortcut_path_; 306 bool has_shortcut_path_;
306 base::FilePath shortcut_path_; 307 base::FilePath shortcut_path_;
307 bool running_; 308 bool running_;
308 bool canceled_; 309 bool canceled_;
309 310
310 DISALLOW_COPY_AND_ASSIGN(SynchronousDrag); 311 DISALLOW_COPY_AND_ASSIGN(SynchronousDrag);
311 }; 312 };
312 #endif // defined(OS_WIN) 313 #endif // defined(OS_WIN)
313 314
315 const char AppsGridView::kViewClassName[] = "AppsGridView";
316
314 AppsGridView::AppsGridView(AppsGridViewDelegate* delegate, 317 AppsGridView::AppsGridView(AppsGridViewDelegate* delegate,
315 PaginationModel* pagination_model) 318 PaginationModel* pagination_model)
316 : model_(NULL), 319 : model_(NULL),
317 item_list_(NULL), 320 item_list_(NULL),
318 delegate_(delegate), 321 delegate_(delegate),
319 folder_delegate_(NULL), 322 folder_delegate_(NULL),
320 pagination_model_(pagination_model), 323 pagination_model_(pagination_model),
321 page_switcher_view_(new PageSwitcher(pagination_model)), 324 page_switcher_view_(new PageSwitcher(pagination_model)),
322 cols_(0), 325 cols_(0),
323 rows_per_page_(0), 326 rows_per_page_(0),
324 selected_view_(NULL), 327 selected_view_(NULL),
325 drag_view_(NULL), 328 drag_view_(NULL),
326 drag_start_page_(-1), 329 drag_start_page_(-1),
327 drag_pointer_(NONE), 330 drag_pointer_(NONE),
328 drop_attempt_(DROP_FOR_NONE), 331 drop_attempt_(DROP_FOR_NONE),
329 drag_and_drop_host_(NULL), 332 drag_and_drop_host_(NULL),
330 forward_events_to_drag_and_drop_host_(false), 333 forward_events_to_drag_and_drop_host_(false),
331 page_flip_target_(-1), 334 page_flip_target_(-1),
332 page_flip_delay_in_ms_(kPageFlipDelayInMs), 335 page_flip_delay_in_ms_(kPageFlipDelayInMs),
333 bounds_animator_(this), 336 bounds_animator_(this),
334 activated_item_view_(NULL), 337 activated_item_view_(NULL),
335 dragging_for_reparent_item_(false) { 338 dragging_for_reparent_item_(false) {
339 #if defined(USE_AURA)
336 SetPaintToLayer(true); 340 SetPaintToLayer(true);
341 #endif
337 SetFillsBoundsOpaquely(false); 342 SetFillsBoundsOpaquely(false);
338 343
339 pagination_model_->AddObserver(this); 344 pagination_model_->AddObserver(this);
340 AddChildView(page_switcher_view_); 345 AddChildView(page_switcher_view_);
341 } 346 }
342 347
343 AppsGridView::~AppsGridView() { 348 AppsGridView::~AppsGridView() {
344 // Coming here |drag_view_| should already be canceled since otherwise the 349 // Coming here |drag_view_| should already be canceled since otherwise the
345 // drag would disappear after the app list got animated away and closed, 350 // drag would disappear after the app list got animated away and closed,
346 // which would look odd. 351 // which would look odd.
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 Layout(); 769 Layout();
765 int start = std::max(0, (page_index - kPrerenderPages) * tiles_per_page()); 770 int start = std::max(0, (page_index - kPrerenderPages) * tiles_per_page());
766 int end = std::min(view_model_.view_size(), 771 int end = std::min(view_model_.view_size(),
767 (page_index + 1 + kPrerenderPages) * tiles_per_page()); 772 (page_index + 1 + kPrerenderPages) * tiles_per_page());
768 for (int i = start; i < end; i++) { 773 for (int i = start; i < end; i++) {
769 AppListItemView* v = static_cast<AppListItemView*>(view_model_.view_at(i)); 774 AppListItemView* v = static_cast<AppListItemView*>(view_model_.view_at(i));
770 v->Prerender(); 775 v->Prerender();
771 } 776 }
772 } 777 }
773 778
779 const char* AppsGridView::GetClassName() const {
780 return kViewClassName;
781 }
782
774 gfx::Size AppsGridView::GetPreferredSize() { 783 gfx::Size AppsGridView::GetPreferredSize() {
775 const gfx::Insets insets(GetInsets()); 784 const gfx::Insets insets(GetInsets());
776 const gfx::Size tile_size = gfx::Size(kPreferredTileWidth, 785 const gfx::Size tile_size = gfx::Size(kPreferredTileWidth,
777 kPreferredTileHeight); 786 kPreferredTileHeight);
778 const int page_switcher_height = 787 const int page_switcher_height =
779 page_switcher_view_->GetPreferredSize().height(); 788 page_switcher_view_->GetPreferredSize().height();
780 return gfx::Size( 789 return gfx::Size(
781 tile_size.width() * cols_ + insets.width(), 790 tile_size.width() * cols_ + insets.width(),
782 tile_size.height() * rows_per_page_ + 791 tile_size.height() * rows_per_page_ +
783 page_switcher_height + insets.height()); 792 page_switcher_height + insets.height());
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 883
875 bounds_animator_.StopAnimatingView(details.child); 884 bounds_animator_.StopAnimatingView(details.child);
876 } 885 }
877 } 886 }
878 887
879 void AppsGridView::Update() { 888 void AppsGridView::Update() {
880 DCHECK(!selected_view_ && !drag_view_); 889 DCHECK(!selected_view_ && !drag_view_);
881 view_model_.Clear(); 890 view_model_.Clear();
882 if (!item_list_ || !item_list_->item_count()) 891 if (!item_list_ || !item_list_->item_count())
883 return; 892 return;
893 DLOG(INFO) << "AppsGridView::Update(n=" << item_list_->item_count() << ")";
884 for (size_t i = 0; i < item_list_->item_count(); ++i) { 894 for (size_t i = 0; i < item_list_->item_count(); ++i) {
885 views::View* view = CreateViewForItemAtIndex(i); 895 views::View* view = CreateViewForItemAtIndex(i);
886 view_model_.Add(view, i); 896 view_model_.Add(view, i);
887 AddChildView(view); 897 AddChildView(view);
888 } 898 }
889 UpdatePaging(); 899 UpdatePaging();
890 UpdatePulsingBlockViews(); 900 UpdatePulsingBlockViews();
891 Layout(); 901 Layout();
892 SchedulePaint(); 902 SchedulePaint();
893 } 903 }
(...skipping 16 matching lines...) Expand all
910 if (pulsing_blocks_model_.view_size() == desired) 920 if (pulsing_blocks_model_.view_size() == desired)
911 return; 921 return;
912 922
913 while (pulsing_blocks_model_.view_size() > desired) { 923 while (pulsing_blocks_model_.view_size() > desired) {
914 views::View* view = pulsing_blocks_model_.view_at(0); 924 views::View* view = pulsing_blocks_model_.view_at(0);
915 pulsing_blocks_model_.Remove(0); 925 pulsing_blocks_model_.Remove(0);
916 delete view; 926 delete view;
917 } 927 }
918 928
919 while (pulsing_blocks_model_.view_size() < desired) { 929 while (pulsing_blocks_model_.view_size() < desired) {
930 NOTREACHED();
931 #ifdef FIXME
920 views::View* view = new PulsingBlockView( 932 views::View* view = new PulsingBlockView(
921 gfx::Size(kPreferredTileWidth, kPreferredTileHeight), true); 933 gfx::Size(kPreferredTileWidth, kPreferredTileHeight), true);
922 pulsing_blocks_model_.Add(view, 0); 934 pulsing_blocks_model_.Add(view, 0);
923 AddChildView(view); 935 AddChildView(view);
936 #endif
924 } 937 }
925 } 938 }
926 939
927 views::View* AppsGridView::CreateViewForItemAtIndex(size_t index) { 940 views::View* AppsGridView::CreateViewForItemAtIndex(size_t index) {
928 // The drag_view_ might be pending for deletion, therefore view_model_ 941 // The drag_view_ might be pending for deletion, therefore view_model_
929 // may have one more item than item_list_. 942 // may have one more item than item_list_.
930 DCHECK_LE(index, item_list_->item_count()); 943 DCHECK_LE(index, item_list_->item_count());
931 AppListItemView* view = new AppListItemView(this, 944 AppListItemView* view = new AppListItemView(this,
932 item_list_->item_at(index)); 945 item_list_->item_at(index));
933 view->SetIconSize(icon_size_); 946 view->SetIconSize(icon_size_);
(...skipping 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after
2086 void AppsGridView::SetAsFolderDroppingTarget(const Index& target_index, 2099 void AppsGridView::SetAsFolderDroppingTarget(const Index& target_index,
2087 bool is_target_folder) { 2100 bool is_target_folder) {
2088 AppListItemView* target_view = 2101 AppListItemView* target_view =
2089 static_cast<AppListItemView*>( 2102 static_cast<AppListItemView*>(
2090 GetViewAtSlotOnCurrentPage(target_index.slot)); 2103 GetViewAtSlotOnCurrentPage(target_index.slot));
2091 if (target_view) 2104 if (target_view)
2092 target_view->SetAsAttemptedFolderTarget(is_target_folder); 2105 target_view->SetAsAttemptedFolderTarget(is_target_folder);
2093 } 2106 }
2094 2107
2095 } // namespace app_list 2108 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/views/apps_grid_view.h ('k') | ui/app_list/views/contents_switcher_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698