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 "ash/launcher/launcher_view.h" | 5 #include "ash/launcher/launcher_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/launcher/app_list_button.h" | 9 #include "ash/launcher/app_list_button.h" |
10 #include "ash/launcher/launcher_button.h" | 10 #include "ash/launcher/launcher_button.h" |
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 | 564 |
565 void LauncherView::FadeIn(views::View* view) { | 565 void LauncherView::FadeIn(views::View* view) { |
566 view->SetVisible(true); | 566 view->SetVisible(true); |
567 view->layer()->SetOpacity(0); | 567 view->layer()->SetOpacity(0); |
568 AnimateToIdealBounds(); | 568 AnimateToIdealBounds(); |
569 bounds_animator_->SetAnimationDelegate( | 569 bounds_animator_->SetAnimationDelegate( |
570 view, new FadeInAnimationDelegate(view), true); | 570 view, new FadeInAnimationDelegate(view), true); |
571 } | 571 } |
572 | 572 |
573 void LauncherView::PrepareForDrag(Pointer pointer, | 573 void LauncherView::PrepareForDrag(Pointer pointer, |
574 const views::LocatedEvent& event) { | 574 const ui::LocatedEvent& event) { |
575 DCHECK(!dragging()); | 575 DCHECK(!dragging()); |
576 DCHECK(drag_view_); | 576 DCHECK(drag_view_); |
577 drag_pointer_ = pointer; | 577 drag_pointer_ = pointer; |
578 start_drag_index_ = view_model_->GetIndexOfView(drag_view_); | 578 start_drag_index_ = view_model_->GetIndexOfView(drag_view_); |
579 | 579 |
580 // If the item is no longer draggable, bail out. | 580 // If the item is no longer draggable, bail out. |
581 if (start_drag_index_ == -1 || | 581 if (start_drag_index_ == -1 || |
582 !delegate_->IsDraggable(model_->items()[start_drag_index_])) { | 582 !delegate_->IsDraggable(model_->items()[start_drag_index_])) { |
583 CancelDrag(-1); | 583 CancelDrag(-1); |
584 return; | 584 return; |
585 } | 585 } |
586 | 586 |
587 // Move the view to the front so that it appears on top of other views. | 587 // Move the view to the front so that it appears on top of other views. |
588 ReorderChildView(drag_view_, -1); | 588 ReorderChildView(drag_view_, -1); |
589 bounds_animator_->StopAnimatingView(drag_view_); | 589 bounds_animator_->StopAnimatingView(drag_view_); |
590 } | 590 } |
591 | 591 |
592 void LauncherView::ContinueDrag(const views::LocatedEvent& event) { | 592 void LauncherView::ContinueDrag(const ui::LocatedEvent& event) { |
593 // TODO: I don't think this works correctly with RTL. | 593 // TODO: I don't think this works correctly with RTL. |
594 gfx::Point drag_point(event.location()); | 594 gfx::Point drag_point(event.location()); |
595 views::View::ConvertPointToView(drag_view_, this, &drag_point); | 595 views::View::ConvertPointToTarget(drag_view_, this, &drag_point); |
596 int current_index = view_model_->GetIndexOfView(drag_view_); | 596 int current_index = view_model_->GetIndexOfView(drag_view_); |
597 DCHECK_NE(-1, current_index); | 597 DCHECK_NE(-1, current_index); |
598 | 598 |
599 // If the item is no longer draggable, bail out. | 599 // If the item is no longer draggable, bail out. |
600 if (current_index == -1 || | 600 if (current_index == -1 || |
601 !delegate_->IsDraggable(model_->items()[current_index])) { | 601 !delegate_->IsDraggable(model_->items()[current_index])) { |
602 CancelDrag(-1); | 602 CancelDrag(-1); |
603 return; | 603 return; |
604 } | 604 } |
605 | 605 |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
882 } | 882 } |
883 } | 883 } |
884 | 884 |
885 void LauncherView::LauncherItemMoved(int start_index, int target_index) { | 885 void LauncherView::LauncherItemMoved(int start_index, int target_index) { |
886 view_model_->Move(start_index, target_index); | 886 view_model_->Move(start_index, target_index); |
887 AnimateToIdealBounds(); | 887 AnimateToIdealBounds(); |
888 } | 888 } |
889 | 889 |
890 void LauncherView::PointerPressedOnButton(views::View* view, | 890 void LauncherView::PointerPressedOnButton(views::View* view, |
891 Pointer pointer, | 891 Pointer pointer, |
892 const views::LocatedEvent& event) { | 892 const ui::LocatedEvent& event) { |
893 if (drag_view_) | 893 if (drag_view_) |
894 return; | 894 return; |
895 | 895 |
896 tooltip_->Close(); | 896 tooltip_->Close(); |
897 int index = view_model_->GetIndexOfView(view); | 897 int index = view_model_->GetIndexOfView(view); |
898 if (index == -1 || | 898 if (index == -1 || |
899 view_model_->view_size() <= 1 || | 899 view_model_->view_size() <= 1 || |
900 !delegate_->IsDraggable(model_->items()[index])) | 900 !delegate_->IsDraggable(model_->items()[index])) |
901 return; // View is being deleted or not draggable, ignore request. | 901 return; // View is being deleted or not draggable, ignore request. |
902 | 902 |
903 drag_view_ = view; | 903 drag_view_ = view; |
904 drag_offset_ = primary_axis_coordinate(event.x(), event.y()); | 904 drag_offset_ = primary_axis_coordinate(event.x(), event.y()); |
905 } | 905 } |
906 | 906 |
907 void LauncherView::PointerDraggedOnButton(views::View* view, | 907 void LauncherView::PointerDraggedOnButton(views::View* view, |
908 Pointer pointer, | 908 Pointer pointer, |
909 const views::LocatedEvent& event) { | 909 const ui::LocatedEvent& event) { |
910 if (!dragging() && drag_view_ && | 910 if (!dragging() && drag_view_ && |
911 primary_axis_coordinate(abs(event.x() - drag_offset_), | 911 primary_axis_coordinate(abs(event.x() - drag_offset_), |
912 abs(event.y() - drag_offset_)) >= | 912 abs(event.y() - drag_offset_)) >= |
913 kMinimumDragDistance) { | 913 kMinimumDragDistance) { |
914 PrepareForDrag(pointer, event); | 914 PrepareForDrag(pointer, event); |
915 } | 915 } |
916 if (drag_pointer_ == pointer) | 916 if (drag_pointer_ == pointer) |
917 ContinueDrag(event); | 917 ContinueDrag(event); |
918 } | 918 } |
919 | 919 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1076 FOR_EACH_OBSERVER(LauncherIconObserver, observers_, | 1076 FOR_EACH_OBSERVER(LauncherIconObserver, observers_, |
1077 OnLauncherIconPositionsChanged()); | 1077 OnLauncherIconPositionsChanged()); |
1078 PreferredSizeChanged(); | 1078 PreferredSizeChanged(); |
1079 } | 1079 } |
1080 | 1080 |
1081 void LauncherView::OnBoundsAnimatorDone(views::BoundsAnimator* animator) { | 1081 void LauncherView::OnBoundsAnimatorDone(views::BoundsAnimator* animator) { |
1082 } | 1082 } |
1083 | 1083 |
1084 } // namespace internal | 1084 } // namespace internal |
1085 } // namespace ash | 1085 } // namespace ash |
OLD | NEW |