| 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/shelf/shelf_view.h" | 5 #include "ash/shelf/shelf_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "ash/ash_constants.h" | 10 #include "ash/ash_constants.h" |
| (...skipping 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1126 } | 1126 } |
| 1127 | 1127 |
| 1128 bounds_animator_->StopAnimatingView(drag_view_); | 1128 bounds_animator_->StopAnimatingView(drag_view_); |
| 1129 int drag_view_index = view_model_->GetIndexOfView(drag_view_); | 1129 int drag_view_index = view_model_->GetIndexOfView(drag_view_); |
| 1130 drag_view_->SetBoundsRect(view_model_->ideal_bounds(drag_view_index)); | 1130 drag_view_->SetBoundsRect(view_model_->ideal_bounds(drag_view_index)); |
| 1131 } | 1131 } |
| 1132 // Move our proxy view item. | 1132 // Move our proxy view item. |
| 1133 UpdateDragIconProxy(screen_location); | 1133 UpdateDragIconProxy(screen_location); |
| 1134 return true; | 1134 return true; |
| 1135 } | 1135 } |
| 1136 // Check if we are too far away from the shelf to enter the ripped off state. | 1136 |
| 1137 // Determine the distance to the shelf. | 1137 // Mark the item as dragged off the shelf if the drag distance exceeds |
| 1138 // |kRipOffDistance|, or if it's dragged between the main and overflow shelf. |
| 1138 int delta = CalculateShelfDistance(screen_location); | 1139 int delta = CalculateShelfDistance(screen_location); |
| 1139 if (delta > kRipOffDistance) { | 1140 bool dragged_off_shelf = delta > kRipOffDistance; |
| 1141 dragged_off_shelf |= |
| 1142 (is_overflow_mode() && |
| 1143 main_shelf_->GetBoundsForDragInsertInScreen().Contains(screen_location)); |
| 1144 dragged_off_shelf |= (!is_overflow_mode() && overflow_bubble_ && |
| 1145 overflow_bubble_->IsShowing() && |
| 1146 overflow_bubble_->shelf_view() |
| 1147 ->GetBoundsForDragInsertInScreen() |
| 1148 .Contains(screen_location)); |
| 1149 |
| 1150 if (dragged_off_shelf) { |
| 1140 // Create a proxy view item which can be moved anywhere. | 1151 // Create a proxy view item which can be moved anywhere. |
| 1141 CreateDragIconProxy(event.root_location(), drag_view_->GetImage(), | 1152 CreateDragIconProxy(event.root_location(), drag_view_->GetImage(), |
| 1142 drag_view_, gfx::Vector2d(0, 0), | 1153 drag_view_, gfx::Vector2d(0, 0), |
| 1143 kDragAndDropProxyScale); | 1154 kDragAndDropProxyScale); |
| 1144 drag_view_->layer()->SetOpacity(0.0f); | 1155 drag_view_->layer()->SetOpacity(0.0f); |
| 1145 dragged_off_shelf_ = true; | 1156 dragged_off_shelf_ = true; |
| 1146 if (RemovableByRipOff(current_index) == REMOVABLE) { | 1157 if (RemovableByRipOff(current_index) == REMOVABLE) { |
| 1147 // Move the item to the front of the first panel item and hide it. | 1158 // Move the item to the front of the first panel item and hide it. |
| 1148 // ShelfItemMoved() callback will handle the |view_model_| update and | 1159 // ShelfItemMoved() callback will handle the |view_model_| update and |
| 1149 // call AnimateToIdealBounds(). | 1160 // call AnimateToIdealBounds(). |
| (...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1836 if (pointer == TOUCH && | 1847 if (pointer == TOUCH && |
| 1837 (base::TimeTicks::Now() - touch_press_time_) < | 1848 (base::TimeTicks::Now() - touch_press_time_) < |
| 1838 base::TimeDelta::FromMilliseconds(kTouchDragTimeThresholdMs)) { | 1849 base::TimeDelta::FromMilliseconds(kTouchDragTimeThresholdMs)) { |
| 1839 return false; | 1850 return false; |
| 1840 } | 1851 } |
| 1841 | 1852 |
| 1842 return true; | 1853 return true; |
| 1843 } | 1854 } |
| 1844 | 1855 |
| 1845 } // namespace ash | 1856 } // namespace ash |
| OLD | NEW |