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

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

Issue 214423002: Reset the app list when it is shown on Windows and Linux. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix_app_list_folder_drag_for_real
Patch Set: Created 6 years, 9 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
« no previous file with comments | « ui/app_list/views/apps_container_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_container_view.h" 5 #include "ui/app_list/views/apps_container_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "ui/app_list/app_list_constants.h" 11 #include "ui/app_list/app_list_constants.h"
12 #include "ui/app_list/app_list_folder_item.h" 12 #include "ui/app_list/app_list_folder_item.h"
13 #include "ui/app_list/app_list_switches.h" 13 #include "ui/app_list/app_list_switches.h"
14 #include "ui/app_list/pagination_model.h" 14 #include "ui/app_list/pagination_model.h"
15 #include "ui/app_list/views/app_list_folder_view.h" 15 #include "ui/app_list/views/app_list_folder_view.h"
16 #include "ui/app_list/views/app_list_item_view.h" 16 #include "ui/app_list/views/app_list_item_view.h"
17 #include "ui/app_list/views/app_list_main_view.h" 17 #include "ui/app_list/views/app_list_main_view.h"
18 #include "ui/app_list/views/apps_grid_view.h" 18 #include "ui/app_list/views/apps_grid_view.h"
19 #include "ui/app_list/views/folder_background_view.h" 19 #include "ui/app_list/views/folder_background_view.h"
20 #include "ui/events/event.h" 20 #include "ui/events/event.h"
21 21
22 namespace app_list { 22 namespace app_list {
23 23
24 AppsContainerView::AppsContainerView(AppListMainView* app_list_main_view, 24 AppsContainerView::AppsContainerView(AppListMainView* app_list_main_view,
25 PaginationModel* pagination_model, 25 PaginationModel* pagination_model,
26 AppListModel* model, 26 AppListModel* model,
27 content::WebContents* start_page_contents) 27 content::WebContents* start_page_contents)
28 : model_(model), 28 : model_(model),
29 show_state_(SHOW_APPS), 29 show_state_(SHOW_APPS),
30 activated_folder_view_(NULL),
30 top_icon_animation_pending_count_(0) { 31 top_icon_animation_pending_count_(0) {
31 apps_grid_view_ = new AppsGridView( 32 apps_grid_view_ = new AppsGridView(
32 app_list_main_view, pagination_model, start_page_contents); 33 app_list_main_view, pagination_model, start_page_contents);
33 int cols = kPreferredCols; 34 int cols = kPreferredCols;
34 int rows = kPreferredRows; 35 int rows = kPreferredRows;
35 if (CommandLine::ForCurrentProcess()->HasSwitch( 36 if (CommandLine::ForCurrentProcess()->HasSwitch(
36 app_list::switches::kEnableExperimentalAppList)) { 37 app_list::switches::kEnableExperimentalAppList)) {
37 cols = kExperimentalPreferredCols; 38 cols = kExperimentalPreferredCols;
38 rows = kExperimentalPreferredRows; 39 rows = kExperimentalPreferredRows;
39 } 40 }
40 apps_grid_view_->SetLayout(kPreferredIconDimension, cols, rows); 41 apps_grid_view_->SetLayout(kPreferredIconDimension, cols, rows);
41 AddChildView(apps_grid_view_); 42 AddChildView(apps_grid_view_);
42 43
43 folder_background_view_ = new FolderBackgroundView(); 44 folder_background_view_ = new FolderBackgroundView();
44 AddChildView(folder_background_view_); 45 AddChildView(folder_background_view_);
45 46
46 app_list_folder_view_ = new AppListFolderView( 47 app_list_folder_view_ = new AppListFolderView(
47 this, 48 this,
48 model, 49 model,
49 app_list_main_view, 50 app_list_main_view,
50 start_page_contents); 51 start_page_contents);
51 AddChildView(app_list_folder_view_); 52 AddChildView(app_list_folder_view_);
52 53
53 apps_grid_view_->SetModel(model_); 54 apps_grid_view_->SetModel(model_);
54 apps_grid_view_->SetItemList(model_->item_list()); 55 apps_grid_view_->SetItemList(model_->item_list());
55 SetShowState(SHOW_APPS, 56 ResetForShow();
jennyz 2014/03/27 18:35:54 We don't need to ResetForShow in the constructor.
calamity 2014/03/28 03:43:27 Done. Note that this removes the SetState() call t
56 false); /* show apps without animation */
57 } 57 }
58 58
59 AppsContainerView::~AppsContainerView() { 59 AppsContainerView::~AppsContainerView() {
60 } 60 }
61 61
62 void AppsContainerView::ShowActiveFolder(AppListFolderItem* folder_item) { 62 void AppsContainerView::ShowActiveFolder(AppListFolderItem* folder_item) {
63 if (activated_folder_view_)
64 return;
65
63 app_list_folder_view_->SetAppListFolderItem(folder_item); 66 app_list_folder_view_->SetAppListFolderItem(folder_item);
64 SetShowState(SHOW_ACTIVE_FOLDER, false); 67 SetShowState(SHOW_ACTIVE_FOLDER, false);
65 68
66 CreateViewsForFolderTopItemsAnimation(folder_item, true); 69 CreateViewsForFolderTopItemsAnimation(folder_item, true);
67 } 70 }
68 71
69 void AppsContainerView::ShowApps(AppListFolderItem* folder_item) { 72 void AppsContainerView::ShowApps(AppListFolderItem* folder_item) {
70 PrepareToShowApps(folder_item); 73 PrepareToShowApps(folder_item);
71 SetShowState(SHOW_APPS, 74 SetShowState(SHOW_APPS,
72 true); /* show apps with animation */ 75 true); /* show apps with animation */
73 } 76 }
74 77
78 void AppsContainerView::ResetForShow() {
79 SetShowState(SHOW_APPS, false /* show apps without animation */);
80 folder_background_view_->UpdateFolderContainerBubble(
81 FolderBackgroundView::NO_BUBBLE);
82 }
83
75 void AppsContainerView::SetDragAndDropHostOfCurrentAppList( 84 void AppsContainerView::SetDragAndDropHostOfCurrentAppList(
76 ApplicationDragAndDropHost* drag_and_drop_host) { 85 ApplicationDragAndDropHost* drag_and_drop_host) {
77 apps_grid_view()->SetDragAndDropHostOfCurrentAppList(drag_and_drop_host); 86 apps_grid_view()->SetDragAndDropHostOfCurrentAppList(drag_and_drop_host);
78 app_list_folder_view()->items_grid_view()-> 87 app_list_folder_view()->items_grid_view()->
79 SetDragAndDropHostOfCurrentAppList(drag_and_drop_host); 88 SetDragAndDropHostOfCurrentAppList(drag_and_drop_host);
80 } 89 }
81 90
82 void AppsContainerView::ReparentFolderItemTransit( 91 void AppsContainerView::ReparentFolderItemTransit(
83 AppListFolderItem* folder_item) { 92 AppListFolderItem* folder_item) {
84 PrepareToShowApps(folder_item); 93 PrepareToShowApps(folder_item);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 132
124 void AppsContainerView::OnTopIconAnimationsComplete() { 133 void AppsContainerView::OnTopIconAnimationsComplete() {
125 --top_icon_animation_pending_count_; 134 --top_icon_animation_pending_count_;
126 135
127 if (!top_icon_animation_pending_count_) { 136 if (!top_icon_animation_pending_count_) {
128 // Clean up the transitional views used for top item icon animation. 137 // Clean up the transitional views used for top item icon animation.
129 top_icon_views_.clear(); 138 top_icon_views_.clear();
130 139
131 // Show the folder icon when closing the folder. 140 // Show the folder icon when closing the folder.
132 if ((show_state_ == SHOW_APPS || show_state_ == SHOW_ITEM_REPARENT) && 141 if ((show_state_ == SHOW_APPS || show_state_ == SHOW_ITEM_REPARENT) &&
133 apps_grid_view_->activated_item_view()) { 142 activated_folder_view_) {
134 apps_grid_view_->activated_item_view()->SetVisible(true); 143 activated_folder_view_->SetVisible(true);
144 activated_folder_view_ = NULL;
135 } 145 }
136 } 146 }
137 } 147 }
138 148
139 void AppsContainerView::SetShowState(ShowState show_state, 149 void AppsContainerView::SetShowState(ShowState show_state,
140 bool show_apps_with_animation) { 150 bool show_apps_with_animation) {
141 if (show_state_ == show_state) 151 if (show_state_ == show_state)
142 return; 152 return;
143 153
144 show_state_ = show_state; 154 show_state_ = show_state;
145 155
146 switch (show_state_) { 156 switch (show_state_) {
147 case SHOW_APPS: 157 case SHOW_APPS:
148 folder_background_view_->SetVisible(false); 158 folder_background_view_->SetVisible(false);
149 if (show_apps_with_animation) { 159 if (show_apps_with_animation) {
150 app_list_folder_view_->ScheduleShowHideAnimation(false, false); 160 app_list_folder_view_->ScheduleShowHideAnimation(false, false);
151 apps_grid_view_->ScheduleShowHideAnimation(true); 161 apps_grid_view_->ScheduleShowHideAnimation(true);
152 } else { 162 } else {
163 if (activated_folder_view_) {
164 activated_folder_view_->SetVisible(true);
165 activated_folder_view_ = NULL;
166 }
153 app_list_folder_view_->HideViewImmediately(); 167 app_list_folder_view_->HideViewImmediately();
168 apps_grid_view_->layer()->SetOpacity(1.0f);
154 apps_grid_view_->SetVisible(true); 169 apps_grid_view_->SetVisible(true);
155 } 170 }
156 break; 171 break;
157 case SHOW_ACTIVE_FOLDER: 172 case SHOW_ACTIVE_FOLDER:
158 folder_background_view_->SetVisible(true); 173 folder_background_view_->SetVisible(true);
159 apps_grid_view_->ScheduleShowHideAnimation(false); 174 apps_grid_view_->ScheduleShowHideAnimation(false);
160 app_list_folder_view_->ScheduleShowHideAnimation(true, false); 175 app_list_folder_view_->ScheduleShowHideAnimation(true, false);
161 break; 176 break;
162 case SHOW_ITEM_REPARENT: 177 case SHOW_ITEM_REPARENT:
163 folder_background_view_->SetVisible(false); 178 folder_background_view_->SetVisible(false);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 app_list_folder_view_->GetItemIconBoundsAt(i))); 220 app_list_folder_view_->GetItemIconBoundsAt(i)));
206 static_cast<TopIconAnimationView*>(top_icon_views_[i])->TransformView(); 221 static_cast<TopIconAnimationView*>(top_icon_views_[i])->TransformView();
207 } 222 }
208 } 223 }
209 224
210 void AppsContainerView::PrepareToShowApps(AppListFolderItem* folder_item) { 225 void AppsContainerView::PrepareToShowApps(AppListFolderItem* folder_item) {
211 if (folder_item) 226 if (folder_item)
212 CreateViewsForFolderTopItemsAnimation(folder_item, false); 227 CreateViewsForFolderTopItemsAnimation(folder_item, false);
213 228
214 // Hide the active folder item until the animation completes. 229 // Hide the active folder item until the animation completes.
215 if (apps_grid_view_->activated_item_view()) 230 if (apps_grid_view_->activated_item_view()) {
216 apps_grid_view_->activated_item_view()->SetVisible(false); 231 activated_folder_view_ = apps_grid_view_->activated_item_view();
jennyz 2014/03/27 18:35:54 Cache activated_folder_view_ seems dangerous,the i
calamity 2014/03/28 03:43:27 This does happen on ChromeOS (checked on latest ca
232 activated_folder_view_->SetVisible(false);
233 }
217 } 234 }
218 235
219 } // namespace app_list 236 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/views/apps_container_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698