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

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

Issue 17370003: [Win] App launcher drag/drop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix compile 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
« no previous file with comments | « ui/app_list/views/app_list_item_view.h ('k') | ui/app_list/views/app_list_main_view.h » ('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/app_list_item_view.h" 5 #include "ui/app_list/views/app_list_item_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "grit/ui_resources.h" 10 #include "grit/ui_resources.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_item_model.h" 12 #include "ui/app_list/app_list_item_model.h"
13 #include "ui/app_list/views/apps_grid_view.h" 13 #include "ui/app_list/views/apps_grid_view.h"
14 #include "ui/app_list/views/cached_label.h" 14 #include "ui/app_list/views/cached_label.h"
15 #include "ui/base/accessibility/accessible_view_state.h" 15 #include "ui/base/accessibility/accessible_view_state.h"
16 #include "ui/base/animation/throb_animation.h" 16 #include "ui/base/animation/throb_animation.h"
17 #include "ui/base/dragdrop/drag_utils.h"
17 #include "ui/base/resource/resource_bundle.h" 18 #include "ui/base/resource/resource_bundle.h"
18 #include "ui/compositor/layer.h" 19 #include "ui/compositor/layer.h"
19 #include "ui/compositor/scoped_layer_animation_settings.h" 20 #include "ui/compositor/scoped_layer_animation_settings.h"
20 #include "ui/gfx/canvas.h" 21 #include "ui/gfx/canvas.h"
21 #include "ui/gfx/font.h" 22 #include "ui/gfx/font.h"
22 #include "ui/gfx/image/image_skia_operations.h" 23 #include "ui/gfx/image/image_skia_operations.h"
23 #include "ui/gfx/transform_util.h" 24 #include "ui/gfx/transform_util.h"
24 #include "ui/views/controls/image_view.h" 25 #include "ui/views/controls/image_view.h"
25 #include "ui/views/controls/label.h" 26 #include "ui/views/controls/label.h"
26 #include "ui/views/controls/menu/menu_item_view.h" 27 #include "ui/views/controls/menu/menu_item_view.h"
27 #include "ui/views/controls/menu/menu_runner.h" 28 #include "ui/views/controls/menu/menu_runner.h"
29 #include "ui/views/drag_controller.h"
28 30
29 namespace app_list { 31 namespace app_list {
30 32
31 namespace { 33 namespace {
32 34
33 const int kTopBottomPadding = 10; 35 const int kTopBottomPadding = 10;
34 const int kTopPadding = 20; 36 const int kTopPadding = 20;
35 const int kIconTitleSpacing = 7; 37 const int kIconTitleSpacing = 7;
36 const int kProgressBarHorizontalPadding = 12; 38 const int kProgressBarHorizontalPadding = 12;
37 const int kProgressBarVerticalPadding = 4; 39 const int kProgressBarVerticalPadding = 4;
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 167
166 void AppListItemView::OnMouseDragTimer() { 168 void AppListItemView::OnMouseDragTimer() {
167 DCHECK(apps_grid_view_->IsDraggedView(this)); 169 DCHECK(apps_grid_view_->IsDraggedView(this));
168 SetUIState(UI_STATE_DRAGGING); 170 SetUIState(UI_STATE_DRAGGING);
169 } 171 }
170 172
171 void AppListItemView::Prerender() { 173 void AppListItemView::Prerender() {
172 title_->PaintToBackingImage(); 174 title_->PaintToBackingImage();
173 } 175 }
174 176
177 gfx::ImageSkia AppListItemView::GetDragImage() {
178 gfx::Canvas canvas(size(), ui::SCALE_FACTOR_100P, false /* is_opaque */);
179 gfx::Rect bounds(size());
180 canvas.DrawColor(SK_ColorTRANSPARENT);
181 PaintChildren(&canvas);
182 return gfx::ImageSkia(canvas.ExtractImageRep());
183 }
184
175 void AppListItemView::ItemIconChanged() { 185 void AppListItemView::ItemIconChanged() {
176 UpdateIcon(); 186 UpdateIcon();
177 } 187 }
178 188
179 void AppListItemView::ItemTitleChanged() { 189 void AppListItemView::ItemTitleChanged() {
180 title_->SetText(UTF8ToUTF16(model_->title())); 190 title_->SetText(UTF8ToUTF16(model_->title()));
181 title_->Invalidate(); 191 title_->Invalidate();
182 Layout(); 192 Layout();
183 } 193 }
184 194
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 } 345 }
336 346
337 void AppListItemView::OnMouseReleased(const ui::MouseEvent& event) { 347 void AppListItemView::OnMouseReleased(const ui::MouseEvent& event) {
338 CustomButton::OnMouseReleased(event); 348 CustomButton::OnMouseReleased(event);
339 apps_grid_view_->EndDrag(false); 349 apps_grid_view_->EndDrag(false);
340 mouse_drag_timer_.Stop(); 350 mouse_drag_timer_.Stop();
341 SetUIState(UI_STATE_NORMAL); 351 SetUIState(UI_STATE_NORMAL);
342 } 352 }
343 353
344 void AppListItemView::OnMouseCaptureLost() { 354 void AppListItemView::OnMouseCaptureLost() {
355 // We don't cancel the dag on mouse capture lost for windows as entering a
356 // synchronous drag causes mouse capture to be lost and pressing escape
357 // dismisses the app list anyway.
358 #if !defined(OS_WIN)
345 CustomButton::OnMouseCaptureLost(); 359 CustomButton::OnMouseCaptureLost();
346 apps_grid_view_->EndDrag(true); 360 apps_grid_view_->EndDrag(true);
347 mouse_drag_timer_.Stop(); 361 mouse_drag_timer_.Stop();
348 SetUIState(UI_STATE_NORMAL); 362 SetUIState(UI_STATE_NORMAL);
363 #endif
349 } 364 }
350 365
351 bool AppListItemView::OnMouseDragged(const ui::MouseEvent& event) { 366 bool AppListItemView::OnMouseDragged(const ui::MouseEvent& event) {
352 CustomButton::OnMouseDragged(event); 367 CustomButton::OnMouseDragged(event);
353 apps_grid_view_->UpdateDrag(this, AppsGridView::MOUSE, event); 368 apps_grid_view_->UpdateDragFromItem(AppsGridView::MOUSE, event);
354 369
355 // Shows dragging UI when it's confirmed without waiting for the timer. 370 // Shows dragging UI when it's confirmed without waiting for the timer.
356 if (ui_state_ != UI_STATE_DRAGGING && 371 if (ui_state_ != UI_STATE_DRAGGING &&
357 apps_grid_view_->dragging() && 372 apps_grid_view_->dragging() &&
358 apps_grid_view_->IsDraggedView(this)) { 373 apps_grid_view_->IsDraggedView(this)) {
359 mouse_drag_timer_.Stop(); 374 mouse_drag_timer_.Stop();
360 SetUIState(UI_STATE_DRAGGING); 375 SetUIState(UI_STATE_DRAGGING);
361 } 376 }
362 return true; 377 return true;
363 } 378 }
364 379
365 void AppListItemView::OnGestureEvent(ui::GestureEvent* event) { 380 void AppListItemView::OnGestureEvent(ui::GestureEvent* event) {
366 switch (event->type()) { 381 switch (event->type()) {
367 case ui::ET_GESTURE_SCROLL_BEGIN: 382 case ui::ET_GESTURE_SCROLL_BEGIN:
368 if (touch_dragging_) { 383 if (touch_dragging_) {
369 apps_grid_view_->InitiateDrag(this, AppsGridView::TOUCH, *event); 384 apps_grid_view_->InitiateDrag(this, AppsGridView::TOUCH, *event);
370 event->SetHandled(); 385 event->SetHandled();
371 } 386 }
372 break; 387 break;
373 case ui::ET_GESTURE_SCROLL_UPDATE: 388 case ui::ET_GESTURE_SCROLL_UPDATE:
374 if (touch_dragging_) { 389 if (touch_dragging_) {
375 apps_grid_view_->UpdateDrag(this, AppsGridView::TOUCH, *event); 390 apps_grid_view_->UpdateDragFromItem(AppsGridView::TOUCH, *event);
376 event->SetHandled(); 391 event->SetHandled();
377 } 392 }
378 break; 393 break;
379 case ui::ET_GESTURE_SCROLL_END: 394 case ui::ET_GESTURE_SCROLL_END:
380 case ui::ET_SCROLL_FLING_START: 395 case ui::ET_SCROLL_FLING_START:
381 if (touch_dragging_) { 396 if (touch_dragging_) {
382 SetTouchDragging(false); 397 SetTouchDragging(false);
383 apps_grid_view_->EndDrag(false); 398 apps_grid_view_->EndDrag(false);
384 event->SetHandled(); 399 event->SetHandled();
385 } 400 }
386 break; 401 break;
387 case ui::ET_GESTURE_LONG_PRESS: 402 case ui::ET_GESTURE_LONG_PRESS:
388 if (!apps_grid_view_->has_dragged_view()) 403 if (!apps_grid_view_->has_dragged_view())
389 SetTouchDragging(true); 404 SetTouchDragging(true);
390 event->SetHandled(); 405 event->SetHandled();
391 break; 406 break;
392 case ui::ET_GESTURE_LONG_TAP: 407 case ui::ET_GESTURE_LONG_TAP:
393 case ui::ET_GESTURE_END: 408 case ui::ET_GESTURE_END:
394 if (touch_dragging_) 409 if (touch_dragging_)
395 SetTouchDragging(false); 410 SetTouchDragging(false);
396 break; 411 break;
397 default: 412 default:
398 break; 413 break;
399 } 414 }
400 if (!event->handled()) 415 if (!event->handled())
401 CustomButton::OnGestureEvent(event); 416 CustomButton::OnGestureEvent(event);
402 } 417 }
403 418
404 } // namespace app_list 419 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/views/app_list_item_view.h ('k') | ui/app_list/views/app_list_main_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698