Chromium Code Reviews| 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 | 8 |
| 9 #include "ash/ash_constants.h" | 9 #include "ash/ash_constants.h" |
| 10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
| 11 #include "ash/drag_drop/drag_image_view.h" | 11 #include "ash/drag_drop/drag_image_view.h" |
| 12 #include "ash/launcher/launcher_button.h" | 12 #include "ash/launcher/launcher_button.h" |
| 13 #include "ash/launcher/launcher_delegate.h" | 13 #include "ash/launcher/launcher_delegate.h" |
| 14 #include "ash/launcher/launcher_item_delegate.h" | 14 #include "ash/launcher/launcher_item_delegate.h" |
| 15 #include "ash/launcher/launcher_item_delegate_manager.h" | 15 #include "ash/launcher/launcher_item_delegate_manager.h" |
| 16 #include "ash/launcher/launcher_model.h" | 16 #include "ash/launcher/launcher_model.h" |
| 17 #include "ash/root_window_controller.h" | 17 #include "ash/root_window_controller.h" |
| 18 #include "ash/scoped_target_root_window.h" | 18 #include "ash/scoped_target_root_window.h" |
| 19 #include "ash/shelf/alternate_app_list_button.h" | 19 #include "ash/shelf/alternate_app_list_button.h" |
| 20 #include "ash/shelf/app_list_button.h" | 20 #include "ash/shelf/app_list_button.h" |
| 21 #include "ash/shelf/overflow_bubble.h" | 21 #include "ash/shelf/overflow_bubble.h" |
| 22 #include "ash/shelf/overflow_button.h" | 22 #include "ash/shelf/overflow_button.h" |
| 23 #include "ash/shelf/shelf_icon_observer.h" | 23 #include "ash/shelf/shelf_icon_observer.h" |
| 24 #include "ash/shelf/shelf_layout_manager.h" | 24 #include "ash/shelf/shelf_layout_manager.h" |
| 25 #include "ash/shelf/shelf_tooltip_manager.h" | 25 #include "ash/shelf/shelf_tooltip_manager.h" |
| 26 #include "ash/shelf/shelf_widget.h" | 26 #include "ash/shelf/shelf_widget.h" |
| 27 #include "ash/shell_delegate.h" | 27 #include "ash/shell_delegate.h" |
| 28 #include "base/auto_reset.h" | 28 #include "base/auto_reset.h" |
| 29 #include "base/memory/scoped_ptr.h" | 29 #include "base/memory/scoped_ptr.h" |
| 30 #include "base/metrics/histogram.h" | |
| 30 #include "grit/ash_resources.h" | 31 #include "grit/ash_resources.h" |
| 31 #include "grit/ash_strings.h" | 32 #include "grit/ash_strings.h" |
| 32 #include "ui/aura/client/screen_position_client.h" | 33 #include "ui/aura/client/screen_position_client.h" |
| 33 #include "ui/aura/root_window.h" | 34 #include "ui/aura/root_window.h" |
| 34 #include "ui/aura/window.h" | 35 #include "ui/aura/window.h" |
| 35 #include "ui/base/accessibility/accessible_view_state.h" | 36 #include "ui/base/accessibility/accessible_view_state.h" |
| 36 #include "ui/base/l10n/l10n_util.h" | 37 #include "ui/base/l10n/l10n_util.h" |
| 37 #include "ui/base/models/simple_menu_model.h" | 38 #include "ui/base/models/simple_menu_model.h" |
| 38 #include "ui/base/resource/resource_bundle.h" | 39 #include "ui/base/resource/resource_bundle.h" |
| 39 #include "ui/compositor/layer.h" | 40 #include "ui/compositor/layer.h" |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 51 #include "ui/views/view_model.h" | 52 #include "ui/views/view_model.h" |
| 52 #include "ui/views/view_model_utils.h" | 53 #include "ui/views/view_model_utils.h" |
| 53 #include "ui/views/widget/widget.h" | 54 #include "ui/views/widget/widget.h" |
| 54 | 55 |
| 55 using gfx::Animation; | 56 using gfx::Animation; |
| 56 using views::View; | 57 using views::View; |
| 57 | 58 |
| 58 namespace ash { | 59 namespace ash { |
| 59 namespace internal { | 60 namespace internal { |
| 60 | 61 |
| 62 const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_BOTTOM = 0; | |
|
James Cook
2013/11/01 05:06:28
Could these be shared with the other copy somehow?
| |
| 63 const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_LEFT = 1; | |
| 64 const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_RIGHT = 2; | |
| 65 const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_COUNT = 3; | |
| 66 | |
| 61 // Default amount content is inset on the left edge. | 67 // Default amount content is inset on the left edge. |
| 62 const int kDefaultLeadingInset = 8; | 68 const int kDefaultLeadingInset = 8; |
| 63 | 69 |
| 64 // Minimum distance before drag starts. | 70 // Minimum distance before drag starts. |
| 65 const int kMinimumDragDistance = 8; | 71 const int kMinimumDragDistance = 8; |
| 66 | 72 |
| 67 // Size between the buttons. | 73 // Size between the buttons. |
| 68 const int kButtonSpacing = 4; | 74 const int kButtonSpacing = 4; |
| 69 const int kAlternateButtonSpacing = 10; | 75 const int kAlternateButtonSpacing = 10; |
| 70 | 76 |
| (...skipping 1458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1529 if (index == -1) | 1535 if (index == -1) |
| 1530 return; | 1536 return; |
| 1531 | 1537 |
| 1532 LauncherItemDelegate* item_delegate = item_manager_->GetLauncherItemDelegate( | 1538 LauncherItemDelegate* item_delegate = item_manager_->GetLauncherItemDelegate( |
| 1533 model_->items()[index].id); | 1539 model_->items()[index].id); |
| 1534 if (view_model_->view_size() <= 1 || !item_delegate->IsDraggable()) | 1540 if (view_model_->view_size() <= 1 || !item_delegate->IsDraggable()) |
| 1535 return; // View is being deleted or not draggable, ignore request. | 1541 return; // View is being deleted or not draggable, ignore request. |
| 1536 | 1542 |
| 1537 drag_view_ = view; | 1543 drag_view_ = view; |
| 1538 drag_offset_ = layout_manager_->PrimaryAxisValue(event.x(), event.y()); | 1544 drag_offset_ = layout_manager_->PrimaryAxisValue(event.x(), event.y()); |
| 1545 UMA_HISTOGRAM_ENUMERATION("Ash.ShelfAlignmentUsage", | |
| 1546 layout_manager_->SelectValueForShelfAlignment( | |
| 1547 SHELF_ALIGNMENT_UMA_ENUM_VALUE_BOTTOM, | |
| 1548 SHELF_ALIGNMENT_UMA_ENUM_VALUE_LEFT, | |
| 1549 SHELF_ALIGNMENT_UMA_ENUM_VALUE_RIGHT, | |
| 1550 -1), | |
| 1551 SHELF_ALIGNMENT_UMA_ENUM_VALUE_COUNT); | |
| 1539 } | 1552 } |
| 1540 | 1553 |
| 1541 void ShelfView::PointerDraggedOnButton(views::View* view, | 1554 void ShelfView::PointerDraggedOnButton(views::View* view, |
| 1542 Pointer pointer, | 1555 Pointer pointer, |
| 1543 const ui::LocatedEvent& event) { | 1556 const ui::LocatedEvent& event) { |
| 1544 if (!dragging() && drag_view_ && | 1557 if (!dragging() && drag_view_ && |
| 1545 layout_manager_->PrimaryAxisValue(abs(event.x() - drag_offset_), | 1558 layout_manager_->PrimaryAxisValue(abs(event.x() - drag_offset_), |
| 1546 abs(event.y() - drag_offset_)) >= | 1559 abs(event.y() - drag_offset_)) >= |
| 1547 kMinimumDragDistance) { | 1560 kMinimumDragDistance) { |
| 1548 PrepareForDrag(pointer, event); | 1561 PrepareForDrag(pointer, event); |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1886 break; | 1899 break; |
| 1887 case ash::SHELF_ALIGNMENT_TOP: | 1900 case ash::SHELF_ALIGNMENT_TOP: |
| 1888 distance = coordinate.y() - bounds.bottom(); | 1901 distance = coordinate.y() - bounds.bottom(); |
| 1889 break; | 1902 break; |
| 1890 } | 1903 } |
| 1891 return distance > 0 ? distance : 0; | 1904 return distance > 0 ? distance : 0; |
| 1892 } | 1905 } |
| 1893 | 1906 |
| 1894 } // namespace internal | 1907 } // namespace internal |
| 1895 } // namespace ash | 1908 } // namespace ash |
| OLD | NEW |