| 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" |
| 11 #include "ash/drag_drop/drag_image_view.h" | 11 #include "ash/drag_drop/drag_image_view.h" |
| 12 #include "ash/public/cpp/shelf_item_delegate.h" | 12 #include "ash/public/cpp/shelf_item_delegate.h" |
| 13 #include "ash/scoped_root_window_for_new_windows.h" | 13 #include "ash/scoped_root_window_for_new_windows.h" |
| 14 #include "ash/shelf/app_list_button.h" | 14 #include "ash/shelf/app_list_button.h" |
| 15 #include "ash/shelf/overflow_bubble.h" | 15 #include "ash/shelf/overflow_bubble.h" |
| 16 #include "ash/shelf/overflow_bubble_view.h" | 16 #include "ash/shelf/overflow_bubble_view.h" |
| 17 #include "ash/shelf/overflow_button.h" | 17 #include "ash/shelf/overflow_button.h" |
| 18 #include "ash/shelf/shelf_application_menu_model.h" | 18 #include "ash/shelf/shelf_application_menu_model.h" |
| 19 #include "ash/shelf/shelf_button.h" | 19 #include "ash/shelf/shelf_button.h" |
| 20 #include "ash/shelf/shelf_constants.h" | 20 #include "ash/shelf/shelf_constants.h" |
| 21 #include "ash/shelf/shelf_delegate.h" | |
| 22 #include "ash/shelf/shelf_model.h" | 21 #include "ash/shelf/shelf_model.h" |
| 23 #include "ash/shelf/shelf_widget.h" | 22 #include "ash/shelf/shelf_widget.h" |
| 24 #include "ash/shelf/wm_shelf.h" | 23 #include "ash/shelf/wm_shelf.h" |
| 25 #include "ash/shell.h" | 24 #include "ash/shell.h" |
| 26 #include "ash/shell_delegate.h" | 25 #include "ash/shell_delegate.h" |
| 27 #include "ash/shell_port.h" | 26 #include "ash/shell_port.h" |
| 28 #include "ash/strings/grit/ash_strings.h" | 27 #include "ash/strings/grit/ash_strings.h" |
| 29 #include "ash/wm/root_window_finder.h" | 28 #include "ash/wm/root_window_finder.h" |
| 30 #include "ash/wm_window.h" | 29 #include "ash/wm_window.h" |
| 31 #include "base/auto_reset.h" | 30 #include "base/auto_reset.h" |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 ShelfView* shelf_view_; | 231 ShelfView* shelf_view_; |
| 233 views::View* view_; | 232 views::View* view_; |
| 234 | 233 |
| 235 DISALLOW_COPY_AND_ASSIGN(StartFadeAnimationDelegate); | 234 DISALLOW_COPY_AND_ASSIGN(StartFadeAnimationDelegate); |
| 236 }; | 235 }; |
| 237 | 236 |
| 238 // static | 237 // static |
| 239 const int ShelfView::kMinimumDragDistance = 8; | 238 const int ShelfView::kMinimumDragDistance = 8; |
| 240 | 239 |
| 241 ShelfView::ShelfView(ShelfModel* model, | 240 ShelfView::ShelfView(ShelfModel* model, |
| 242 ShelfDelegate* delegate, | |
| 243 WmShelf* wm_shelf, | 241 WmShelf* wm_shelf, |
| 244 ShelfWidget* shelf_widget) | 242 ShelfWidget* shelf_widget) |
| 245 : model_(model), | 243 : model_(model), |
| 246 delegate_(delegate), | |
| 247 wm_shelf_(wm_shelf), | 244 wm_shelf_(wm_shelf), |
| 248 shelf_widget_(shelf_widget), | 245 shelf_widget_(shelf_widget), |
| 249 view_model_(new views::ViewModel), | 246 view_model_(new views::ViewModel), |
| 250 first_visible_index_(0), | 247 first_visible_index_(0), |
| 251 last_visible_index_(-1), | 248 last_visible_index_(-1), |
| 252 overflow_button_(nullptr), | 249 overflow_button_(nullptr), |
| 253 owner_overflow_bubble_(nullptr), | 250 owner_overflow_bubble_(nullptr), |
| 254 tooltip_(this), | 251 tooltip_(this), |
| 255 drag_pointer_(NONE), | 252 drag_pointer_(NONE), |
| 256 drag_view_(nullptr), | 253 drag_view_(nullptr), |
| 257 start_drag_index_(-1), | 254 start_drag_index_(-1), |
| 258 context_menu_id_(0), | 255 context_menu_id_(0), |
| 259 cancelling_drag_model_changed_(false), | 256 cancelling_drag_model_changed_(false), |
| 260 last_hidden_index_(0), | 257 last_hidden_index_(0), |
| 261 closing_event_time_(base::TimeTicks()), | 258 closing_event_time_(base::TimeTicks()), |
| 262 drag_and_drop_item_pinned_(false), | 259 drag_and_drop_item_pinned_(false), |
| 263 drag_and_drop_shelf_id_(0), | 260 drag_and_drop_shelf_id_(0), |
| 264 drag_replaced_view_(nullptr), | 261 drag_replaced_view_(nullptr), |
| 265 dragged_off_shelf_(false), | 262 dragged_off_shelf_(false), |
| 266 snap_back_from_rip_off_view_(nullptr), | 263 snap_back_from_rip_off_view_(nullptr), |
| 267 overflow_mode_(false), | 264 overflow_mode_(false), |
| 268 main_shelf_(nullptr), | 265 main_shelf_(nullptr), |
| 269 dragged_off_from_overflow_to_shelf_(false), | 266 dragged_off_from_overflow_to_shelf_(false), |
| 270 is_repost_event_on_same_item_(false), | 267 is_repost_event_on_same_item_(false), |
| 271 last_pressed_index_(-1), | 268 last_pressed_index_(-1), |
| 272 weak_factory_(this) { | 269 weak_factory_(this) { |
| 273 DCHECK(model_); | 270 DCHECK(model_); |
| 274 DCHECK(delegate_); | |
| 275 DCHECK(wm_shelf_); | 271 DCHECK(wm_shelf_); |
| 276 DCHECK(shelf_widget_); | 272 DCHECK(shelf_widget_); |
| 277 bounds_animator_.reset(new views::BoundsAnimator(this)); | 273 bounds_animator_.reset(new views::BoundsAnimator(this)); |
| 278 bounds_animator_->AddObserver(this); | 274 bounds_animator_->AddObserver(this); |
| 279 set_context_menu_controller(this); | 275 set_context_menu_controller(this); |
| 280 focus_search_.reset(new ShelfFocusSearch(view_model_.get())); | 276 focus_search_.reset(new ShelfFocusSearch(view_model_.get())); |
| 281 } | 277 } |
| 282 | 278 |
| 283 ShelfView::~ShelfView() { | 279 ShelfView::~ShelfView() { |
| 284 bounds_animator_->RemoveObserver(this); | 280 bounds_animator_->RemoveObserver(this); |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 // This could happen if mouse / touch operations overlap. | 549 // This could happen if mouse / touch operations overlap. |
| 554 if (drag_and_drop_shelf_id_ || | 550 if (drag_and_drop_shelf_id_ || |
| 555 !GetBoundsInScreen().Contains(location_in_screen_coordinates)) | 551 !GetBoundsInScreen().Contains(location_in_screen_coordinates)) |
| 556 return false; | 552 return false; |
| 557 | 553 |
| 558 // If the AppsGridView (which was dispatching this event) was opened by our | 554 // If the AppsGridView (which was dispatching this event) was opened by our |
| 559 // button, ShelfView dragging operations are locked and we have to unlock. | 555 // button, ShelfView dragging operations are locked and we have to unlock. |
| 560 CancelDrag(-1); | 556 CancelDrag(-1); |
| 561 drag_and_drop_item_pinned_ = false; | 557 drag_and_drop_item_pinned_ = false; |
| 562 drag_and_drop_app_id_ = app_id; | 558 drag_and_drop_app_id_ = app_id; |
| 563 drag_and_drop_shelf_id_ = | 559 drag_and_drop_shelf_id_ = model_->GetShelfIDForAppID(drag_and_drop_app_id_); |
| 564 delegate_->GetShelfIDForAppID(drag_and_drop_app_id_); | |
| 565 // Check if the application is known and pinned - if not, we have to pin it so | 560 // Check if the application is known and pinned - if not, we have to pin it so |
| 566 // that we can re-arrange the shelf order accordingly. Note that items have | 561 // that we can re-arrange the shelf order accordingly. Note that items have |
| 567 // to be pinned to give them the same (order) possibilities as a shortcut. | 562 // to be pinned to give them the same (order) possibilities as a shortcut. |
| 568 // When an item is dragged from overflow to shelf, IsShowingOverflowBubble() | 563 // When an item is dragged from overflow to shelf, IsShowingOverflowBubble() |
| 569 // returns true. At this time, we don't need to pin the item. | 564 // returns true. At this time, we don't need to pin the item. |
| 570 if (!IsShowingOverflowBubble() && | 565 if (!IsShowingOverflowBubble() && |
| 571 (!drag_and_drop_shelf_id_ || !delegate_->IsAppPinned(app_id))) { | 566 (!drag_and_drop_shelf_id_ || !model_->IsAppPinned(app_id))) { |
| 572 delegate_->PinAppWithID(app_id); | 567 model_->PinAppWithID(app_id); |
| 573 drag_and_drop_shelf_id_ = | 568 drag_and_drop_shelf_id_ = model_->GetShelfIDForAppID(drag_and_drop_app_id_); |
| 574 delegate_->GetShelfIDForAppID(drag_and_drop_app_id_); | |
| 575 if (!drag_and_drop_shelf_id_) | 569 if (!drag_and_drop_shelf_id_) |
| 576 return false; | 570 return false; |
| 577 drag_and_drop_item_pinned_ = true; | 571 drag_and_drop_item_pinned_ = true; |
| 578 } | 572 } |
| 579 views::View* drag_and_drop_view = | 573 views::View* drag_and_drop_view = |
| 580 view_model_->view_at(model_->ItemIndexByID(drag_and_drop_shelf_id_)); | 574 view_model_->view_at(model_->ItemIndexByID(drag_and_drop_shelf_id_)); |
| 581 DCHECK(drag_and_drop_view); | 575 DCHECK(drag_and_drop_view); |
| 582 | 576 |
| 583 // Since there is already an icon presented by the caller, we hide this item | 577 // Since there is already an icon presented by the caller, we hide this item |
| 584 // for now. That has to be done by reducing the size since the visibility will | 578 // for now. That has to be done by reducing the size since the visibility will |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 void ShelfView::EndDrag(bool cancel) { | 616 void ShelfView::EndDrag(bool cancel) { |
| 623 if (!drag_and_drop_shelf_id_) | 617 if (!drag_and_drop_shelf_id_) |
| 624 return; | 618 return; |
| 625 | 619 |
| 626 views::View* drag_and_drop_view = | 620 views::View* drag_and_drop_view = |
| 627 view_model_->view_at(model_->ItemIndexByID(drag_and_drop_shelf_id_)); | 621 view_model_->view_at(model_->ItemIndexByID(drag_and_drop_shelf_id_)); |
| 628 PointerReleasedOnButton(drag_and_drop_view, DRAG_AND_DROP, cancel); | 622 PointerReleasedOnButton(drag_and_drop_view, DRAG_AND_DROP, cancel); |
| 629 | 623 |
| 630 // Either destroy the temporarily created item - or - make the item visible. | 624 // Either destroy the temporarily created item - or - make the item visible. |
| 631 if (drag_and_drop_item_pinned_ && cancel) { | 625 if (drag_and_drop_item_pinned_ && cancel) { |
| 632 delegate_->UnpinAppWithID(drag_and_drop_app_id_); | 626 model_->UnpinAppWithID(drag_and_drop_app_id_); |
| 633 } else if (drag_and_drop_view) { | 627 } else if (drag_and_drop_view) { |
| 634 if (cancel) { | 628 if (cancel) { |
| 635 // When a hosted drag gets canceled, the item can remain in the same slot | 629 // When a hosted drag gets canceled, the item can remain in the same slot |
| 636 // and it might have moved within the bounds. In that case the item need | 630 // and it might have moved within the bounds. In that case the item need |
| 637 // to animate back to its correct location. | 631 // to animate back to its correct location. |
| 638 AnimateToIdealBounds(); | 632 AnimateToIdealBounds(); |
| 639 } else { | 633 } else { |
| 640 drag_and_drop_view->SetSize(pre_drag_and_drop_size_); | 634 drag_and_drop_view->SetSize(pre_drag_and_drop_size_); |
| 641 } | 635 } |
| 642 } | 636 } |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1056 // Change the model, the ShelfItemMoved() callback will handle the | 1050 // Change the model, the ShelfItemMoved() callback will handle the |
| 1057 // |view_model_| update. | 1051 // |view_model_| update. |
| 1058 model_->Move(current_index, target_index); | 1052 model_->Move(current_index, target_index); |
| 1059 bounds_animator_->StopAnimatingView(drag_view_); | 1053 bounds_animator_->StopAnimatingView(drag_view_); |
| 1060 } | 1054 } |
| 1061 | 1055 |
| 1062 bool ShelfView::HandleRipOffDrag(const ui::LocatedEvent& event) { | 1056 bool ShelfView::HandleRipOffDrag(const ui::LocatedEvent& event) { |
| 1063 int current_index = view_model_->GetIndexOfView(drag_view_); | 1057 int current_index = view_model_->GetIndexOfView(drag_view_); |
| 1064 DCHECK_NE(-1, current_index); | 1058 DCHECK_NE(-1, current_index); |
| 1065 std::string dragged_app_id = | 1059 std::string dragged_app_id = |
| 1066 delegate_->GetAppIDForShelfID(model_->items()[current_index].id); | 1060 model_->GetAppIDForShelfID(model_->items()[current_index].id); |
| 1067 | 1061 |
| 1068 gfx::Point screen_location = | 1062 gfx::Point screen_location = |
| 1069 WmWindow::Get(GetWidget()->GetNativeWindow()) | 1063 WmWindow::Get(GetWidget()->GetNativeWindow()) |
| 1070 ->GetRootWindow() | 1064 ->GetRootWindow() |
| 1071 ->ConvertPointToScreen(event.root_location()); | 1065 ->ConvertPointToScreen(event.root_location()); |
| 1072 | 1066 |
| 1073 // To avoid ugly forwards and backwards flipping we use different constants | 1067 // To avoid ugly forwards and backwards flipping we use different constants |
| 1074 // for ripping off / re-inserting the items. | 1068 // for ripping off / re-inserting the items. |
| 1075 if (dragged_off_shelf_) { | 1069 if (dragged_off_shelf_) { |
| 1076 // If the shelf/overflow bubble bounds contains |screen_location| we insert | 1070 // If the shelf/overflow bubble bounds contains |screen_location| we insert |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1179 drag_view_->layer()->SetOpacity(1.0f); | 1173 drag_view_->layer()->SetOpacity(1.0f); |
| 1180 } else if (RemovableByRipOff(current_index) != REMOVABLE) { | 1174 } else if (RemovableByRipOff(current_index) != REMOVABLE) { |
| 1181 // Make sure we do not try to remove un-removable items like items which | 1175 // Make sure we do not try to remove un-removable items like items which |
| 1182 // were not pinned or have to be always there. | 1176 // were not pinned or have to be always there. |
| 1183 cancel = true; | 1177 cancel = true; |
| 1184 snap_back = true; | 1178 snap_back = true; |
| 1185 } else { | 1179 } else { |
| 1186 // Make sure the item stays invisible upon removal. | 1180 // Make sure the item stays invisible upon removal. |
| 1187 drag_view_->SetVisible(false); | 1181 drag_view_->SetVisible(false); |
| 1188 std::string app_id = | 1182 std::string app_id = |
| 1189 delegate_->GetAppIDForShelfID(model_->items()[current_index].id); | 1183 model_->GetAppIDForShelfID(model_->items()[current_index].id); |
| 1190 delegate_->UnpinAppWithID(app_id); | 1184 model_->UnpinAppWithID(app_id); |
| 1191 } | 1185 } |
| 1192 } | 1186 } |
| 1193 if (cancel || snap_back) { | 1187 if (cancel || snap_back) { |
| 1194 if (dragged_off_from_overflow_to_shelf_) { | 1188 if (dragged_off_from_overflow_to_shelf_) { |
| 1195 dragged_off_from_overflow_to_shelf_ = false; | 1189 dragged_off_from_overflow_to_shelf_ = false; |
| 1196 // Main shelf handles revert of dragged item. | 1190 // Main shelf handles revert of dragged item. |
| 1197 main_shelf_->EndDrag(true); | 1191 main_shelf_->EndDrag(true); |
| 1198 drag_view_->layer()->SetOpacity(1.0f); | 1192 drag_view_->layer()->SetOpacity(1.0f); |
| 1199 } else if (!cancelling_drag_model_changed_) { | 1193 } else if (!cancelling_drag_model_changed_) { |
| 1200 // Only do something if the change did not come through a model change. | 1194 // Only do something if the change did not come through a model change. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1222 ShelfView::RemovableState ShelfView::RemovableByRipOff(int index) const { | 1216 ShelfView::RemovableState ShelfView::RemovableByRipOff(int index) const { |
| 1223 DCHECK(index >= 0 && index < model_->item_count()); | 1217 DCHECK(index >= 0 && index < model_->item_count()); |
| 1224 ShelfItemType type = model_->items()[index].type; | 1218 ShelfItemType type = model_->items()[index].type; |
| 1225 if (type == TYPE_APP_LIST || type == TYPE_DIALOG) | 1219 if (type == TYPE_APP_LIST || type == TYPE_DIALOG) |
| 1226 return NOT_REMOVABLE; | 1220 return NOT_REMOVABLE; |
| 1227 | 1221 |
| 1228 if (model_->items()[index].pinned_by_policy) | 1222 if (model_->items()[index].pinned_by_policy) |
| 1229 return NOT_REMOVABLE; | 1223 return NOT_REMOVABLE; |
| 1230 | 1224 |
| 1231 // Note: Only pinned app shortcuts can be removed! | 1225 // Note: Only pinned app shortcuts can be removed! |
| 1232 std::string app_id = delegate_->GetAppIDForShelfID(model_->items()[index].id); | 1226 std::string app_id = model_->GetAppIDForShelfID(model_->items()[index].id); |
| 1233 return (type == TYPE_PINNED_APP && delegate_->IsAppPinned(app_id)) | 1227 return (type == TYPE_PINNED_APP && model_->IsAppPinned(app_id)) ? REMOVABLE |
| 1234 ? REMOVABLE | 1228 : DRAGGABLE; |
| 1235 : DRAGGABLE; | |
| 1236 } | 1229 } |
| 1237 | 1230 |
| 1238 bool ShelfView::SameDragType(ShelfItemType typea, ShelfItemType typeb) const { | 1231 bool ShelfView::SameDragType(ShelfItemType typea, ShelfItemType typeb) const { |
| 1239 switch (typea) { | 1232 switch (typea) { |
| 1240 case TYPE_PINNED_APP: | 1233 case TYPE_PINNED_APP: |
| 1241 case TYPE_BROWSER_SHORTCUT: | 1234 case TYPE_BROWSER_SHORTCUT: |
| 1242 return (typeb == TYPE_PINNED_APP || typeb == TYPE_BROWSER_SHORTCUT); | 1235 return (typeb == TYPE_PINNED_APP || typeb == TYPE_BROWSER_SHORTCUT); |
| 1243 case TYPE_APP_PANEL: | 1236 case TYPE_APP_PANEL: |
| 1244 case TYPE_APP_LIST: | 1237 case TYPE_APP_LIST: |
| 1245 case TYPE_APP: | 1238 case TYPE_APP: |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1274 | 1267 |
| 1275 void ShelfView::ToggleOverflowBubble() { | 1268 void ShelfView::ToggleOverflowBubble() { |
| 1276 if (IsShowingOverflowBubble()) { | 1269 if (IsShowingOverflowBubble()) { |
| 1277 overflow_bubble_->Hide(); | 1270 overflow_bubble_->Hide(); |
| 1278 return; | 1271 return; |
| 1279 } | 1272 } |
| 1280 | 1273 |
| 1281 if (!overflow_bubble_) | 1274 if (!overflow_bubble_) |
| 1282 overflow_bubble_.reset(new OverflowBubble(wm_shelf_)); | 1275 overflow_bubble_.reset(new OverflowBubble(wm_shelf_)); |
| 1283 | 1276 |
| 1284 ShelfView* overflow_view = | 1277 ShelfView* overflow_view = new ShelfView(model_, wm_shelf_, shelf_widget_); |
| 1285 new ShelfView(model_, delegate_, wm_shelf_, shelf_widget_); | |
| 1286 overflow_view->overflow_mode_ = true; | 1278 overflow_view->overflow_mode_ = true; |
| 1287 overflow_view->Init(); | 1279 overflow_view->Init(); |
| 1288 overflow_view->set_owner_overflow_bubble(overflow_bubble_.get()); | 1280 overflow_view->set_owner_overflow_bubble(overflow_bubble_.get()); |
| 1289 overflow_view->OnShelfAlignmentChanged(); | 1281 overflow_view->OnShelfAlignmentChanged(); |
| 1290 overflow_view->main_shelf_ = this; | 1282 overflow_view->main_shelf_ = this; |
| 1291 UpdateOverflowRange(overflow_view); | 1283 UpdateOverflowRange(overflow_view); |
| 1292 | 1284 |
| 1293 overflow_bubble_->Show(overflow_button_, overflow_view); | 1285 overflow_bubble_->Show(overflow_button_, overflow_view); |
| 1294 | 1286 |
| 1295 wm_shelf_->UpdateVisibilityState(); | 1287 wm_shelf_->UpdateVisibilityState(); |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1531 // item is ripped out from the shelf, its |view| is already invisible. | 1523 // item is ripped out from the shelf, its |view| is already invisible. |
| 1532 AnimateToIdealBounds(); | 1524 AnimateToIdealBounds(); |
| 1533 } | 1525 } |
| 1534 | 1526 |
| 1535 if (view == tooltip_.GetCurrentAnchorView()) | 1527 if (view == tooltip_.GetCurrentAnchorView()) |
| 1536 tooltip_.Close(); | 1528 tooltip_.Close(); |
| 1537 } | 1529 } |
| 1538 | 1530 |
| 1539 void ShelfView::ShelfItemChanged(int model_index, const ShelfItem& old_item) { | 1531 void ShelfView::ShelfItemChanged(int model_index, const ShelfItem& old_item) { |
| 1540 const ShelfItem& item(model_->items()[model_index]); | 1532 const ShelfItem& item(model_->items()[model_index]); |
| 1533 |
| 1534 // Bail if the view and shelf sizes do not match. ShelfItemChanged may be |
| 1535 // called here before ShelfItemAdded, due to ChromeLauncherController's |
| 1536 // item initialization, which calls SetItem during ShelfItemAdded. |
| 1537 if (static_cast<int>(model_->items().size()) != view_model_->view_size()) |
| 1538 return; |
| 1539 |
| 1541 if (old_item.type != item.type) { | 1540 if (old_item.type != item.type) { |
| 1542 // Type changed, swap the views. | 1541 // Type changed, swap the views. |
| 1543 model_index = CancelDrag(model_index); | 1542 model_index = CancelDrag(model_index); |
| 1544 std::unique_ptr<views::View> old_view(view_model_->view_at(model_index)); | 1543 std::unique_ptr<views::View> old_view(view_model_->view_at(model_index)); |
| 1545 bounds_animator_->StopAnimatingView(old_view.get()); | 1544 bounds_animator_->StopAnimatingView(old_view.get()); |
| 1546 // Removing and re-inserting a view in our view model will strip the ideal | 1545 // Removing and re-inserting a view in our view model will strip the ideal |
| 1547 // bounds from the item. To avoid recalculation of everything the bounds | 1546 // bounds from the item. To avoid recalculation of everything the bounds |
| 1548 // get remembered and restored after the insertion to the previous value. | 1547 // get remembered and restored after the insertion to the previous value. |
| 1549 gfx::Rect old_ideal_bounds = view_model_->ideal_bounds(model_index); | 1548 gfx::Rect old_ideal_bounds = view_model_->ideal_bounds(model_index); |
| 1550 view_model_->Remove(model_index); | 1549 view_model_->Remove(model_index); |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1761 | 1760 |
| 1762 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { | 1761 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { |
| 1763 const gfx::Rect bounds = GetBoundsInScreen(); | 1762 const gfx::Rect bounds = GetBoundsInScreen(); |
| 1764 int distance = wm_shelf_->SelectValueForShelfAlignment( | 1763 int distance = wm_shelf_->SelectValueForShelfAlignment( |
| 1765 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), | 1764 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), |
| 1766 bounds.x() - coordinate.x()); | 1765 bounds.x() - coordinate.x()); |
| 1767 return distance > 0 ? distance : 0; | 1766 return distance > 0 ? distance : 0; |
| 1768 } | 1767 } |
| 1769 | 1768 |
| 1770 } // namespace ash | 1769 } // namespace ash |
| OLD | NEW |