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

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

Issue 15774015: Fixed problem with clicking on app launcher item (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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
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 8
9 #include "ui/app_list/app_list_item_model.h" 9 #include "ui/app_list/app_list_item_model.h"
10 #include "ui/app_list/apps_grid_view_delegate.h" 10 #include "ui/app_list/apps_grid_view_delegate.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 if (drag_view_ || pulsing_blocks_model_.view_size()) 194 if (drag_view_ || pulsing_blocks_model_.view_size())
195 return; 195 return;
196 196
197 drag_view_ = view; 197 drag_view_ = view;
198 198
199 // When a drag and drop host is given, the item can be dragged out of the app 199 // When a drag and drop host is given, the item can be dragged out of the app
200 // list window. In that case a proxy widget needs to be used. 200 // list window. In that case a proxy widget needs to be used.
201 // Note: This code has very likely to be changed for Windows (non metro mode) 201 // Note: This code has very likely to be changed for Windows (non metro mode)
202 // when a |drag_and_drop_host_| gets implemented. 202 // when a |drag_and_drop_host_| gets implemented.
203 if (drag_and_drop_host_) { 203 if (drag_and_drop_host_) {
204 // Determine the mouse offset to the center of the icon so that the drag and
205 // drop host follows this layer.
206 gfx::Vector2d delta = event.root_location() -
207 drag_view_->GetBoundsInScreen().CenterPoint();
208 delta.set_y(delta.y() + drag_view_->title()->size().height() / 2);
204 // We have to hide the original item since the drag and drop host will do 209 // We have to hide the original item since the drag and drop host will do
205 // the OS dependent code to "lift off the dragged item". 210 // the OS dependent code to "lift off the dragged item".
206 // Note that we cannot use SetVisible since it would remove the mouse input.
207 drag_view_->SetSize(gfx::Size());
208 drag_and_drop_host_->CreateDragIconProxy(event.root_location(), 211 drag_and_drop_host_->CreateDragIconProxy(event.root_location(),
209 view->model()->icon(), 212 view->model()->icon(),
210 drag_view_, 213 drag_view_,
214 delta,
211 kDragAndDropProxyScale); 215 kDragAndDropProxyScale);
216 HideView(drag_view_, true);
212 } 217 }
213 drag_start_ = event.location(); 218 drag_start_ = event.location();
214 } 219 }
215 220
216 void AppsGridView::UpdateDrag(AppListItemView* view, 221 void AppsGridView::UpdateDrag(AppListItemView* view,
217 Pointer pointer, 222 Pointer pointer,
218 const ui::LocatedEvent& event) { 223 const ui::LocatedEvent& event) {
219 if (!dragging() && drag_view_ && 224 if (!dragging() && drag_view_ &&
220 ExceededDragThreshold(event.location() - drag_start_)) { 225 ExceededDragThreshold(event.location() - drag_start_)) {
221 drag_pointer_ = pointer; 226 drag_pointer_ = pointer;
(...skipping 15 matching lines...) Expand all
237 MaybeStartPageFlipTimer(last_drag_point_); 242 MaybeStartPageFlipTimer(last_drag_point_);
238 243
239 gfx::Point page_switcher_point(last_drag_point_); 244 gfx::Point page_switcher_point(last_drag_point_);
240 views::View::ConvertPointToTarget(this, page_switcher_view_, 245 views::View::ConvertPointToTarget(this, page_switcher_view_,
241 &page_switcher_point); 246 &page_switcher_point);
242 page_switcher_view_->UpdateUIForDragPoint(page_switcher_point); 247 page_switcher_view_->UpdateUIForDragPoint(page_switcher_point);
243 248
244 if (last_drop_target != drop_target_) 249 if (last_drop_target != drop_target_)
245 AnimateToIdealBounds(); 250 AnimateToIdealBounds();
246 251
247 if (drag_and_drop_host_) { 252 if (drag_and_drop_host_)
248 drag_and_drop_host_->UpdateDragIconProxy(event.root_location()); 253 drag_and_drop_host_->UpdateDragIconProxy(event.root_location());
249 return;
250 }
251 254
252 drag_view_->SetPosition( 255 drag_view_->SetPosition(
253 gfx::PointAtOffsetFromOrigin(last_drag_point_ - drag_start_)); 256 gfx::PointAtOffsetFromOrigin(last_drag_point_ - drag_start_));
254 } 257 }
255 258
256 void AppsGridView::EndDrag(bool cancel) { 259 void AppsGridView::EndDrag(bool cancel) {
257 if (forward_events_to_drag_and_drop_host_) { 260 if (forward_events_to_drag_and_drop_host_) {
258 forward_events_to_drag_and_drop_host_ = false; 261 forward_events_to_drag_and_drop_host_ = false;
259 drag_and_drop_host_->EndDrag(cancel); 262 drag_and_drop_host_->EndDrag(cancel);
260 } else if (!cancel && dragging() && drag_view_) { 263 } else if (!cancel && dragging() && drag_view_) {
261 CalculateDropTarget(last_drag_point_, true); 264 CalculateDropTarget(last_drag_point_, true);
262 if (IsValidIndex(drop_target_)) 265 if (IsValidIndex(drop_target_))
263 MoveItemInModel(drag_view_, drop_target_); 266 MoveItemInModel(drag_view_, drop_target_);
264 } 267 }
265 268
266 // In case we had a drag and drop proxy icon, we delete it and make the real
267 // item visible again.
268 if (drag_and_drop_host_) { 269 if (drag_and_drop_host_) {
270 // If we had a drag and drop proxy icon, we delete it and make the real
271 // item visible again.
269 drag_and_drop_host_->DestroyDragIconProxy(); 272 drag_and_drop_host_->DestroyDragIconProxy();
270 // To avoid an incorrect animation on re-group, |drag_view_| gets positioned 273 HideView(drag_view_, false);
271 // at its last known drag location.
272 drag_view_->SetPosition(
273 gfx::PointAtOffsetFromOrigin(last_drag_point_ - drag_start_));
274 } 274 }
275 275
276 drag_pointer_ = NONE; 276 drag_pointer_ = NONE;
277 drop_target_ = Index(); 277 drop_target_ = Index();
278 if (drag_view_) { 278 if (drag_view_) {
279 drag_view_ = NULL; 279 drag_view_ = NULL;
280 AnimateToIdealBounds(); 280 AnimateToIdealBounds();
281 } 281 }
282 282
283 page_flip_timer_.Stop(); 283 page_flip_timer_.Stop();
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 if (pagination_model_->is_valid_page(transition.target_page)) 912 if (pagination_model_->is_valid_page(transition.target_page))
913 Layout(); 913 Layout();
914 } 914 }
915 915
916 void AppsGridView::OnAppListModelStatusChanged() { 916 void AppsGridView::OnAppListModelStatusChanged() {
917 UpdatePulsingBlockViews(); 917 UpdatePulsingBlockViews();
918 Layout(); 918 Layout();
919 SchedulePaint(); 919 SchedulePaint();
920 } 920 }
921 921
922 void AppsGridView::HideView(views::View* view, bool hide) {
923 ui::LayerAnimator* animator = view->layer()->GetAnimator();
924 ui::LayerAnimator::PreemptionStrategy strategy =
James Cook 2013/05/31 22:33:11 Use ui::ScopedLayerAnimationSettings here
Mr4D (OOO till 08-26) 2013/05/31 22:51:24 Done.
925 animator->preemption_strategy();
926 animator->set_preemption_strategy(
927 ui::LayerAnimator::IMMEDIATELY_SET_NEW_TARGET);
928 view->layer()->SetOpacity(hide ? 0 : 1);
929 animator->set_preemption_strategy(strategy);
930 }
931
922 } // namespace app_list 932 } // namespace app_list
OLDNEW
« ui/app_list/views/apps_grid_view.h ('K') | « ui/app_list/views/apps_grid_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698