| 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" |
| 11 #include "ash/common/drag_drop/drag_image_view.h" | 11 #include "ash/common/drag_drop/drag_image_view.h" |
| 12 #include "ash/common/scoped_root_window_for_new_windows.h" | 12 #include "ash/common/scoped_root_window_for_new_windows.h" |
| 13 #include "ash/common/shelf/app_list_button.h" | 13 #include "ash/common/shelf/app_list_button.h" |
| 14 #include "ash/common/shelf/overflow_bubble.h" | 14 #include "ash/common/shelf/overflow_bubble.h" |
| 15 #include "ash/common/shelf/overflow_bubble_view.h" | 15 #include "ash/common/shelf/overflow_bubble_view.h" |
| 16 #include "ash/common/shelf/overflow_button.h" | 16 #include "ash/common/shelf/overflow_button.h" |
| 17 #include "ash/common/shelf/shelf_application_menu_model.h" | 17 #include "ash/common/shelf/shelf_application_menu_model.h" |
| 18 #include "ash/common/shelf/shelf_button.h" | 18 #include "ash/common/shelf/shelf_button.h" |
| 19 #include "ash/common/shelf/shelf_constants.h" | 19 #include "ash/common/shelf/shelf_constants.h" |
| 20 #include "ash/common/shelf/shelf_delegate.h" | 20 #include "ash/common/shelf/shelf_delegate.h" |
| 21 #include "ash/common/shelf/shelf_model.h" | 21 #include "ash/common/shelf/shelf_model.h" |
| 22 #include "ash/common/shelf/shelf_widget.h" | 22 #include "ash/common/shelf/shelf_widget.h" |
| 23 #include "ash/common/shelf/wm_shelf.h" | 23 #include "ash/common/shelf/wm_shelf.h" |
| 24 #include "ash/common/shell_delegate.h" | 24 #include "ash/common/shell_delegate.h" |
| 25 #include "ash/common/wm/root_window_finder.h" | 25 #include "ash/common/wm/root_window_finder.h" |
| 26 #include "ash/common/wm_shell.h" | 26 #include "ash/common/wm_shell.h" |
| 27 #include "ash/common/wm_window.h" | 27 #include "ash/common/wm_window.h" |
| 28 #include "ash/public/cpp/shelf_item_delegate.h" |
| 28 #include "ash/shell.h" | 29 #include "ash/shell.h" |
| 29 #include "ash/strings/grit/ash_strings.h" | 30 #include "ash/strings/grit/ash_strings.h" |
| 30 #include "base/auto_reset.h" | 31 #include "base/auto_reset.h" |
| 31 #include "base/memory/ptr_util.h" | 32 #include "base/memory/ptr_util.h" |
| 32 #include "base/metrics/histogram_macros.h" | 33 #include "base/metrics/histogram_macros.h" |
| 33 #include "ui/accessibility/ax_node_data.h" | 34 #include "ui/accessibility/ax_node_data.h" |
| 34 #include "ui/base/l10n/l10n_util.h" | 35 #include "ui/base/l10n/l10n_util.h" |
| 35 #include "ui/base/models/simple_menu_model.h" | 36 #include "ui/base/models/simple_menu_model.h" |
| 36 #include "ui/compositor/layer.h" | 37 #include "ui/compositor/layer.h" |
| 37 #include "ui/compositor/layer_animator.h" | 38 #include "ui/compositor/layer_animator.h" |
| (...skipping 1538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1576 void ShelfView::ShelfItemMoved(int start_index, int target_index) { | 1577 void ShelfView::ShelfItemMoved(int start_index, int target_index) { |
| 1577 view_model_->Move(start_index, target_index); | 1578 view_model_->Move(start_index, target_index); |
| 1578 // When cancelling a drag due to a shelf item being added, the currently | 1579 // When cancelling a drag due to a shelf item being added, the currently |
| 1579 // dragged item is moved back to its initial position. AnimateToIdealBounds | 1580 // dragged item is moved back to its initial position. AnimateToIdealBounds |
| 1580 // will be called again when the new item is added to the |view_model_| but | 1581 // will be called again when the new item is added to the |view_model_| but |
| 1581 // at this time the |view_model_| is inconsistent with the |model_|. | 1582 // at this time the |view_model_| is inconsistent with the |model_|. |
| 1582 if (!cancelling_drag_model_changed_) | 1583 if (!cancelling_drag_model_changed_) |
| 1583 AnimateToIdealBounds(); | 1584 AnimateToIdealBounds(); |
| 1584 } | 1585 } |
| 1585 | 1586 |
| 1586 void ShelfView::OnSetShelfItemDelegate(ShelfID, mojom::ShelfItemDelegate*) {} | 1587 void ShelfView::OnSetShelfItemDelegate(ShelfID, ShelfItemDelegate*) {} |
| 1587 | 1588 |
| 1588 void ShelfView::AfterItemSelected( | 1589 void ShelfView::AfterItemSelected( |
| 1589 const ShelfItem& item, | 1590 const ShelfItem& item, |
| 1590 views::Button* sender, | 1591 views::Button* sender, |
| 1591 std::unique_ptr<ui::Event> event, | 1592 std::unique_ptr<ui::Event> event, |
| 1592 views::InkDrop* ink_drop, | 1593 views::InkDrop* ink_drop, |
| 1593 ShelfAction action, | 1594 ShelfAction action, |
| 1594 base::Optional<std::vector<mojom::MenuItemPtr>> menu_items) { | 1595 base::Optional<std::vector<mojom::MenuItemPtr>> menu_items) { |
| 1595 shelf_button_pressed_metric_tracker_.ButtonPressed(*event, sender, action); | 1596 shelf_button_pressed_metric_tracker_.ButtonPressed(*event, sender, action); |
| 1596 | 1597 |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1756 | 1757 |
| 1757 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { | 1758 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { |
| 1758 const gfx::Rect bounds = GetBoundsInScreen(); | 1759 const gfx::Rect bounds = GetBoundsInScreen(); |
| 1759 int distance = wm_shelf_->SelectValueForShelfAlignment( | 1760 int distance = wm_shelf_->SelectValueForShelfAlignment( |
| 1760 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), | 1761 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), |
| 1761 bounds.x() - coordinate.x()); | 1762 bounds.x() - coordinate.x()); |
| 1762 return distance > 0 ? distance : 0; | 1763 return distance > 0 ? distance : 0; |
| 1763 } | 1764 } |
| 1764 | 1765 |
| 1765 } // namespace ash | 1766 } // namespace ash |
| OLD | NEW |