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

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

Issue 163953008: Remove the animation delay for showing the top level apps when user opens app list launcher. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move show/hide and animation logic for the views from Layout to SetShowState. Created 6 years, 10 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_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 8
9 #include "ui/app_list/app_list_constants.h" 9 #include "ui/app_list/app_list_constants.h"
10 #include "ui/app_list/app_list_folder_item.h" 10 #include "ui/app_list/app_list_folder_item.h"
(...skipping 26 matching lines...) Expand all
37 37
38 app_list_folder_view_ = new AppListFolderView( 38 app_list_folder_view_ = new AppListFolderView(
39 this, 39 this,
40 model, 40 model,
41 app_list_main_view, 41 app_list_main_view,
42 start_page_contents); 42 start_page_contents);
43 AddChildView(app_list_folder_view_); 43 AddChildView(app_list_folder_view_);
44 44
45 apps_grid_view_->SetModel(model_); 45 apps_grid_view_->SetModel(model_);
46 apps_grid_view_->SetItemList(model_->item_list()); 46 apps_grid_view_->SetItemList(model_->item_list());
47 SetShowState(SHOW_APPS,
48 false); /* show apps without animation */
47 } 49 }
48 50
49 AppsContainerView::~AppsContainerView() { 51 AppsContainerView::~AppsContainerView() {
50 } 52 }
51 53
52 void AppsContainerView::ShowActiveFolder(AppListFolderItem* folder_item) { 54 void AppsContainerView::ShowActiveFolder(AppListFolderItem* folder_item) {
53 app_list_folder_view_->SetAppListFolderItem(folder_item); 55 app_list_folder_view_->SetAppListFolderItem(folder_item);
54 SetShowState(SHOW_ACTIVE_FOLDER); 56 SetShowState(SHOW_ACTIVE_FOLDER, false);
55 57
56 CreateViewsForFolderTopItemsAnimation(folder_item, true); 58 CreateViewsForFolderTopItemsAnimation(folder_item, true);
57 } 59 }
58 60
59 void AppsContainerView::ShowApps(AppListFolderItem* folder_item) { 61 void AppsContainerView::ShowApps(AppListFolderItem* folder_item) {
60 PrepareToShowApps(folder_item); 62 PrepareToShowApps(folder_item);
61 SetShowState(SHOW_APPS); 63 SetShowState(SHOW_APPS,
64 true); /* show apps with animation */
62 } 65 }
63 66
64 void AppsContainerView::SetDragAndDropHostOfCurrentAppList( 67 void AppsContainerView::SetDragAndDropHostOfCurrentAppList(
65 ApplicationDragAndDropHost* drag_and_drop_host) { 68 ApplicationDragAndDropHost* drag_and_drop_host) {
66 apps_grid_view()->SetDragAndDropHostOfCurrentAppList(drag_and_drop_host); 69 apps_grid_view()->SetDragAndDropHostOfCurrentAppList(drag_and_drop_host);
67 app_list_folder_view()->items_grid_view()-> 70 app_list_folder_view()->items_grid_view()->
68 SetDragAndDropHostOfCurrentAppList(drag_and_drop_host); 71 SetDragAndDropHostOfCurrentAppList(drag_and_drop_host);
69 } 72 }
70 73
71 void AppsContainerView::ReparentFolderItemTransit( 74 void AppsContainerView::ReparentFolderItemTransit(
72 AppListFolderItem* folder_item) { 75 AppListFolderItem* folder_item) {
73 PrepareToShowApps(folder_item); 76 PrepareToShowApps(folder_item);
74 SetShowState(SHOW_ITEM_REPARENT); 77 SetShowState(SHOW_ITEM_REPARENT, false);
75 } 78 }
76 79
77 gfx::Size AppsContainerView::GetPreferredSize() { 80 gfx::Size AppsContainerView::GetPreferredSize() {
78 const gfx::Size grid_size = apps_grid_view_->GetPreferredSize(); 81 const gfx::Size grid_size = apps_grid_view_->GetPreferredSize();
79 const gfx::Size folder_view_size = app_list_folder_view_->GetPreferredSize(); 82 const gfx::Size folder_view_size = app_list_folder_view_->GetPreferredSize();
80 83
81 int width = std::max(grid_size.width(), folder_view_size.width()); 84 int width = std::max(grid_size.width(), folder_view_size.width());
82 int height = std::max(grid_size.height(), folder_view_size.height()); 85 int height = std::max(grid_size.height(), folder_view_size.height());
83 return gfx::Size(width, height); 86 return gfx::Size(width, height);
84 } 87 }
85 88
86 void AppsContainerView::Layout() { 89 void AppsContainerView::Layout() {
87 gfx::Rect rect(GetContentsBounds()); 90 gfx::Rect rect(GetContentsBounds());
88 if (rect.IsEmpty()) 91 if (rect.IsEmpty())
89 return; 92 return;
90 93
91 switch (show_state_) { 94 switch (show_state_) {
92 case SHOW_APPS: 95 case SHOW_APPS:
93 folder_background_view_->SetVisible(false);
94 app_list_folder_view_->ScheduleShowHideAnimation(false, false);
95 apps_grid_view_->SetBoundsRect(rect); 96 apps_grid_view_->SetBoundsRect(rect);
96 apps_grid_view_->ScheduleShowHideAnimation(true);
97 break; 97 break;
98 case SHOW_ACTIVE_FOLDER: 98 case SHOW_ACTIVE_FOLDER:
99 folder_background_view_->SetBoundsRect(rect); 99 folder_background_view_->SetBoundsRect(rect);
100 folder_background_view_->SetVisible(true);
101 apps_grid_view_->ScheduleShowHideAnimation(false);
102 app_list_folder_view_->SetBoundsRect(rect); 100 app_list_folder_view_->SetBoundsRect(rect);
103 app_list_folder_view_->ScheduleShowHideAnimation(true, false);
104 break; 101 break;
105 case SHOW_ITEM_REPARENT: 102 case SHOW_ITEM_REPARENT:
106 folder_background_view_->SetVisible(false);
107 folder_background_view_->UpdateFolderContainerBubble(
108 FolderBackgroundView::NO_BUBBLE);
109 app_list_folder_view_->ScheduleShowHideAnimation(false, true);
110 apps_grid_view_->ScheduleShowHideAnimation(true);
111 break; 103 break;
112 default: 104 default:
113 NOTREACHED(); 105 NOTREACHED();
114 } 106 }
115 } 107 }
116 108
117 bool AppsContainerView::OnKeyPressed(const ui::KeyEvent& event) { 109 bool AppsContainerView::OnKeyPressed(const ui::KeyEvent& event) {
118 if (show_state_ == SHOW_APPS) 110 if (show_state_ == SHOW_APPS)
119 return apps_grid_view_->OnKeyPressed(event); 111 return apps_grid_view_->OnKeyPressed(event);
120 else 112 else
121 return app_list_folder_view_->OnKeyPressed(event); 113 return app_list_folder_view_->OnKeyPressed(event);
122 } 114 }
123 115
124 void AppsContainerView::OnTopIconAnimationsComplete() { 116 void AppsContainerView::OnTopIconAnimationsComplete() {
125 --top_icon_animation_pending_count_; 117 --top_icon_animation_pending_count_;
126 118
127 if (!top_icon_animation_pending_count_) { 119 if (!top_icon_animation_pending_count_) {
128 // Clean up the transitional views used for top item icon animation. 120 // Clean up the transitional views used for top item icon animation.
129 top_icon_views_.clear(); 121 top_icon_views_.clear();
130 122
131 // Show the folder icon when closing the folder. 123 // Show the folder icon when closing the folder.
132 if ((show_state_ == SHOW_APPS || show_state_ == SHOW_ITEM_REPARENT) && 124 if ((show_state_ == SHOW_APPS || show_state_ == SHOW_ITEM_REPARENT) &&
133 apps_grid_view_->activated_item_view()) { 125 apps_grid_view_->activated_item_view()) {
134 apps_grid_view_->activated_item_view()->SetVisible(true); 126 apps_grid_view_->activated_item_view()->SetVisible(true);
135 } 127 }
136 } 128 }
137 } 129 }
138 130
139 void AppsContainerView::SetShowState(ShowState show_state) { 131 void AppsContainerView::SetShowState(ShowState show_state,
132 bool show_apps_with_animation) {
140 if (show_state_ == show_state) 133 if (show_state_ == show_state)
141 return; 134 return;
142 135
143 show_state_ = show_state; 136 show_state_ = show_state;
137
138 switch (show_state_) {
139 case SHOW_APPS:
140 folder_background_view_->SetVisible(false);
141 if (show_apps_with_animation) {
142 app_list_folder_view_->ScheduleShowHideAnimation(false, false);
143 apps_grid_view_->ScheduleShowHideAnimation(true);
144 } else {
145 app_list_folder_view_->HideViewImmediately();
146 apps_grid_view_->SetVisible(true);
147 }
148 break;
149 case SHOW_ACTIVE_FOLDER:
150 folder_background_view_->SetVisible(true);
151 apps_grid_view_->ScheduleShowHideAnimation(false);
152 app_list_folder_view_->ScheduleShowHideAnimation(true, false);
153 break;
154 case SHOW_ITEM_REPARENT:
155 folder_background_view_->SetVisible(false);
156 folder_background_view_->UpdateFolderContainerBubble(
157 FolderBackgroundView::NO_BUBBLE);
158 app_list_folder_view_->ScheduleShowHideAnimation(false, true);
159 apps_grid_view_->ScheduleShowHideAnimation(true);
160 break;
161 default:
162 NOTREACHED();
163 }
164
144 Layout(); 165 Layout();
145 } 166 }
146 167
147 Rects AppsContainerView::GetTopItemIconBoundsInActiveFolder() { 168 Rects AppsContainerView::GetTopItemIconBoundsInActiveFolder() {
148 // Get the active folder's icon bounds relative to AppsContainerView. 169 // Get the active folder's icon bounds relative to AppsContainerView.
149 AppListItemView* folder_item_view = apps_grid_view_->activated_item_view(); 170 AppListItemView* folder_item_view = apps_grid_view_->activated_item_view();
150 gfx::Rect to_grid_view = folder_item_view->ConvertRectToParent( 171 gfx::Rect to_grid_view = folder_item_view->ConvertRectToParent(
151 folder_item_view->GetIconBounds()); 172 folder_item_view->GetIconBounds());
152 gfx::Rect to_container = apps_grid_view_->ConvertRectToParent(to_grid_view); 173 gfx::Rect to_container = apps_grid_view_->ConvertRectToParent(to_grid_view);
153 174
(...skipping 27 matching lines...) Expand all
181 void AppsContainerView::PrepareToShowApps(AppListFolderItem* folder_item) { 202 void AppsContainerView::PrepareToShowApps(AppListFolderItem* folder_item) {
182 if (folder_item) 203 if (folder_item)
183 CreateViewsForFolderTopItemsAnimation(folder_item, false); 204 CreateViewsForFolderTopItemsAnimation(folder_item, false);
184 205
185 // Hide the active folder item until the animation completes. 206 // Hide the active folder item until the animation completes.
186 if (apps_grid_view_->activated_item_view()) 207 if (apps_grid_view_->activated_item_view())
187 apps_grid_view_->activated_item_view()->SetVisible(false); 208 apps_grid_view_->activated_item_view()->SetVisible(false);
188 } 209 }
189 210
190 } // namespace app_list 211 } // 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