OLD | NEW |
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 "chrome/browser/ui/views/download/download_item_view.h" | 5 #include "chrome/browser/ui/views/download/download_item_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 width += download_util::kSmallProgressIconSize; | 395 width += download_util::kSmallProgressIconSize; |
396 width += kTextWidth; | 396 width += kTextWidth; |
397 width += normal_body_image_set_.top_right->width(); | 397 width += normal_body_image_set_.top_right->width(); |
398 width += normal_drop_down_image_set_.top->width(); | 398 width += normal_drop_down_image_set_.top->width(); |
399 } | 399 } |
400 return gfx::Size(width, height); | 400 return gfx::Size(width, height); |
401 } | 401 } |
402 | 402 |
403 // Handle a mouse click and open the context menu if the mouse is | 403 // Handle a mouse click and open the context menu if the mouse is |
404 // over the drop-down region. | 404 // over the drop-down region. |
405 bool DownloadItemView::OnMousePressed(const views::MouseEvent& event) { | 405 bool DownloadItemView::OnMousePressed(const ui::MouseEvent& event) { |
406 HandlePressEvent(event, event.IsOnlyLeftMouseButton()); | 406 HandlePressEvent(event, event.IsOnlyLeftMouseButton()); |
407 return true; | 407 return true; |
408 } | 408 } |
409 | 409 |
410 // Handle drag (file copy) operations. | 410 // Handle drag (file copy) operations. |
411 bool DownloadItemView::OnMouseDragged(const views::MouseEvent& event) { | 411 bool DownloadItemView::OnMouseDragged(const ui::MouseEvent& event) { |
412 // Mouse should not activate us in dangerous mode. | 412 // Mouse should not activate us in dangerous mode. |
413 if (IsShowingWarningDialog()) | 413 if (IsShowingWarningDialog()) |
414 return true; | 414 return true; |
415 | 415 |
416 if (!starting_drag_) { | 416 if (!starting_drag_) { |
417 starting_drag_ = true; | 417 starting_drag_ = true; |
418 drag_start_point_ = event.location(); | 418 drag_start_point_ = event.location(); |
419 } | 419 } |
420 if (dragging_) { | 420 if (dragging_) { |
421 if (download_->IsComplete()) { | 421 if (download_->IsComplete()) { |
422 IconManager* im = g_browser_process->icon_manager(); | 422 IconManager* im = g_browser_process->icon_manager(); |
423 gfx::Image* icon = im->LookupIcon(download_->GetUserVerifiedFilePath(), | 423 gfx::Image* icon = im->LookupIcon(download_->GetUserVerifiedFilePath(), |
424 IconLoader::SMALL); | 424 IconLoader::SMALL); |
425 if (icon) { | 425 if (icon) { |
426 views::Widget* widget = GetWidget(); | 426 views::Widget* widget = GetWidget(); |
427 download_util::DragDownload(download_, icon, | 427 download_util::DragDownload(download_, icon, |
428 widget ? widget->GetNativeView() : NULL); | 428 widget ? widget->GetNativeView() : NULL); |
429 } | 429 } |
430 } | 430 } |
431 } else if (ExceededDragThreshold( | 431 } else if (ExceededDragThreshold( |
432 event.location().x() - drag_start_point_.x(), | 432 event.location().x() - drag_start_point_.x(), |
433 event.location().y() - drag_start_point_.y())) { | 433 event.location().y() - drag_start_point_.y())) { |
434 dragging_ = true; | 434 dragging_ = true; |
435 } | 435 } |
436 return true; | 436 return true; |
437 } | 437 } |
438 | 438 |
439 void DownloadItemView::OnMouseReleased(const views::MouseEvent& event) { | 439 void DownloadItemView::OnMouseReleased(const ui::MouseEvent& event) { |
440 HandleClickEvent(event, event.IsOnlyLeftMouseButton()); | 440 HandleClickEvent(event, event.IsOnlyLeftMouseButton()); |
441 } | 441 } |
442 | 442 |
443 void DownloadItemView::OnMouseCaptureLost() { | 443 void DownloadItemView::OnMouseCaptureLost() { |
444 // Mouse should not activate us in dangerous mode. | 444 // Mouse should not activate us in dangerous mode. |
445 if (mode_ == DANGEROUS_MODE) | 445 if (mode_ == DANGEROUS_MODE) |
446 return; | 446 return; |
447 | 447 |
448 if (dragging_) { | 448 if (dragging_) { |
449 // Starting a drag results in a MouseCaptureLost. | 449 // Starting a drag results in a MouseCaptureLost. |
450 dragging_ = false; | 450 dragging_ = false; |
451 starting_drag_ = false; | 451 starting_drag_ = false; |
452 } else { | 452 } else { |
453 SetState(NORMAL, NORMAL); | 453 SetState(NORMAL, NORMAL); |
454 } | 454 } |
455 } | 455 } |
456 | 456 |
457 void DownloadItemView::OnMouseMoved(const views::MouseEvent& event) { | 457 void DownloadItemView::OnMouseMoved(const ui::MouseEvent& event) { |
458 // Mouse should not activate us in dangerous mode. | 458 // Mouse should not activate us in dangerous mode. |
459 if (mode_ == DANGEROUS_MODE) | 459 if (mode_ == DANGEROUS_MODE) |
460 return; | 460 return; |
461 | 461 |
462 bool on_body = !InDropDownButtonXCoordinateRange(event.x()); | 462 bool on_body = !InDropDownButtonXCoordinateRange(event.x()); |
463 SetState(on_body ? HOT : NORMAL, on_body ? NORMAL : HOT); | 463 SetState(on_body ? HOT : NORMAL, on_body ? NORMAL : HOT); |
464 if (on_body) { | 464 if (on_body) { |
465 if (!IsShowingWarningDialog()) | 465 if (!IsShowingWarningDialog()) |
466 body_hover_animation_->Show(); | 466 body_hover_animation_->Show(); |
467 drop_hover_animation_->Hide(); | 467 drop_hover_animation_->Hide(); |
468 } else { | 468 } else { |
469 if (!IsShowingWarningDialog()) | 469 if (!IsShowingWarningDialog()) |
470 body_hover_animation_->Hide(); | 470 body_hover_animation_->Hide(); |
471 drop_hover_animation_->Show(); | 471 drop_hover_animation_->Show(); |
472 } | 472 } |
473 } | 473 } |
474 | 474 |
475 void DownloadItemView::OnMouseExited(const views::MouseEvent& event) { | 475 void DownloadItemView::OnMouseExited(const ui::MouseEvent& event) { |
476 // Mouse should not activate us in dangerous mode. | 476 // Mouse should not activate us in dangerous mode. |
477 if (mode_ == DANGEROUS_MODE) | 477 if (mode_ == DANGEROUS_MODE) |
478 return; | 478 return; |
479 | 479 |
480 SetState(NORMAL, drop_down_pressed_ ? PUSHED : NORMAL); | 480 SetState(NORMAL, drop_down_pressed_ ? PUSHED : NORMAL); |
481 if (!IsShowingWarningDialog()) | 481 if (!IsShowingWarningDialog()) |
482 body_hover_animation_->Hide(); | 482 body_hover_animation_->Hide(); |
483 drop_hover_animation_->Hide(); | 483 drop_hover_animation_->Hide(); |
484 } | 484 } |
485 | 485 |
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1217 // Drop down button is glued to the left of the download shelf. | 1217 // Drop down button is glued to the left of the download shelf. |
1218 drop_down_x_left_ = 0; | 1218 drop_down_x_left_ = 0; |
1219 drop_down_x_right_ = normal_drop_down_image_set_.top->width(); | 1219 drop_down_x_right_ = normal_drop_down_image_set_.top->width(); |
1220 } else { | 1220 } else { |
1221 // Drop down button is glued to the right of the download shelf. | 1221 // Drop down button is glued to the right of the download shelf. |
1222 drop_down_x_left_ = | 1222 drop_down_x_left_ = |
1223 size.width() - normal_drop_down_image_set_.top->width(); | 1223 size.width() - normal_drop_down_image_set_.top->width(); |
1224 drop_down_x_right_ = size.width(); | 1224 drop_down_x_right_ = size.width(); |
1225 } | 1225 } |
1226 } | 1226 } |
OLD | NEW |