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/common/shelf/shelf_view.h" | 5 #include "ash/common/shelf/shelf_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "ash/common/ash_constants.h" | 10 #include "ash/common/ash_constants.h" |
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
689 // This could happen if mouse / touch operations overlap. | 689 // This could happen if mouse / touch operations overlap. |
690 if (drag_and_drop_shelf_id_ || | 690 if (drag_and_drop_shelf_id_ || |
691 !GetBoundsInScreen().Contains(location_in_screen_coordinates)) | 691 !GetBoundsInScreen().Contains(location_in_screen_coordinates)) |
692 return false; | 692 return false; |
693 | 693 |
694 // If the AppsGridView (which was dispatching this event) was opened by our | 694 // If the AppsGridView (which was dispatching this event) was opened by our |
695 // button, ShelfView dragging operations are locked and we have to unlock. | 695 // button, ShelfView dragging operations are locked and we have to unlock. |
696 CancelDrag(-1); | 696 CancelDrag(-1); |
697 drag_and_drop_item_pinned_ = false; | 697 drag_and_drop_item_pinned_ = false; |
698 drag_and_drop_app_id_ = app_id; | 698 drag_and_drop_app_id_ = app_id; |
699 drag_and_drop_shelf_id_ = | 699 drag_and_drop_shelf_id_ = delegate_->GetShelfIDForAppID( |
700 delegate_->GetShelfIDForAppID(drag_and_drop_app_id_); | 700 drag_and_drop_app_id_, drag_and_drop_app_id_); |
stevenjb
2016/08/29 15:56:30
If we use a single method, we should use "" for th
Andra Paraschiv
2016/08/30 09:58:24
Done.
| |
701 // Check if the application is known and pinned - if not, we have to pin it so | 701 // Check if the application is known and pinned - if not, we have to pin it so |
702 // that we can re-arrange the shelf order accordingly. Note that items have | 702 // that we can re-arrange the shelf order accordingly. Note that items have |
703 // to be pinned to give them the same (order) possibilities as a shortcut. | 703 // to be pinned to give them the same (order) possibilities as a shortcut. |
704 // When an item is dragged from overflow to shelf, IsShowingOverflowBubble() | 704 // When an item is dragged from overflow to shelf, IsShowingOverflowBubble() |
705 // returns true. At this time, we don't need to pin the item. | 705 // returns true. At this time, we don't need to pin the item. |
706 if (!IsShowingOverflowBubble() && | 706 if (!IsShowingOverflowBubble() && |
707 (!drag_and_drop_shelf_id_ || !delegate_->IsAppPinned(app_id))) { | 707 (!drag_and_drop_shelf_id_ || !delegate_->IsAppPinned(app_id))) { |
708 delegate_->PinAppWithID(app_id); | 708 delegate_->PinAppWithID(app_id); |
709 drag_and_drop_shelf_id_ = | 709 drag_and_drop_shelf_id_ = delegate_->GetShelfIDForAppID( |
710 delegate_->GetShelfIDForAppID(drag_and_drop_app_id_); | 710 drag_and_drop_app_id_, drag_and_drop_app_id_); |
711 if (!drag_and_drop_shelf_id_) | 711 if (!drag_and_drop_shelf_id_) |
712 return false; | 712 return false; |
713 drag_and_drop_item_pinned_ = true; | 713 drag_and_drop_item_pinned_ = true; |
714 } | 714 } |
715 views::View* drag_and_drop_view = | 715 views::View* drag_and_drop_view = |
716 view_model_->view_at(model_->ItemIndexByID(drag_and_drop_shelf_id_)); | 716 view_model_->view_at(model_->ItemIndexByID(drag_and_drop_shelf_id_)); |
717 DCHECK(drag_and_drop_view); | 717 DCHECK(drag_and_drop_view); |
718 | 718 |
719 // Since there is already an icon presented by the caller, we hide this item | 719 // Since there is already an icon presented by the caller, we hide this item |
720 // for now. That has to be done by reducing the size since the visibility will | 720 // for now. That has to be done by reducing the size since the visibility will |
(...skipping 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1913 | 1913 |
1914 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { | 1914 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { |
1915 const gfx::Rect bounds = GetBoundsInScreen(); | 1915 const gfx::Rect bounds = GetBoundsInScreen(); |
1916 int distance = wm_shelf_->SelectValueForShelfAlignment( | 1916 int distance = wm_shelf_->SelectValueForShelfAlignment( |
1917 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), | 1917 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), |
1918 bounds.x() - coordinate.x()); | 1918 bounds.x() - coordinate.x()); |
1919 return distance > 0 ? distance : 0; | 1919 return distance > 0 ? distance : 0; |
1920 } | 1920 } |
1921 | 1921 |
1922 } // namespace ash | 1922 } // namespace ash |
OLD | NEW |