| 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/aura/wm_window_aura.h" | 10 #include "ash/aura/wm_window_aura.h" |
| 11 #include "ash/common/ash_constants.h" | 11 #include "ash/common/ash_constants.h" |
| 12 #include "ash/common/ash_switches.h" | 12 #include "ash/common/ash_switches.h" |
| 13 #include "ash/common/shelf/shelf_constants.h" | 13 #include "ash/common/shelf/shelf_constants.h" |
| 14 #include "ash/common/shelf/shelf_item_delegate_manager.h" | 14 #include "ash/common/shelf/shelf_item_delegate_manager.h" |
| 15 #include "ash/common/shelf/shelf_menu_model.h" | 15 #include "ash/common/shelf/shelf_menu_model.h" |
| 16 #include "ash/common/shelf/shelf_model.h" | 16 #include "ash/common/shelf/shelf_model.h" |
| 17 #include "ash/common/wm/root_window_finder.h" | 17 #include "ash/common/wm/root_window_finder.h" |
| 18 #include "ash/common/wm_shell.h" |
| 18 #include "ash/drag_drop/drag_image_view.h" | 19 #include "ash/drag_drop/drag_image_view.h" |
| 19 #include "ash/metrics/user_metrics_recorder.h" | |
| 20 #include "ash/scoped_target_root_window.h" | 20 #include "ash/scoped_target_root_window.h" |
| 21 #include "ash/shelf/app_list_button.h" | 21 #include "ash/shelf/app_list_button.h" |
| 22 #include "ash/shelf/overflow_bubble.h" | 22 #include "ash/shelf/overflow_bubble.h" |
| 23 #include "ash/shelf/overflow_bubble_view.h" | 23 #include "ash/shelf/overflow_bubble_view.h" |
| 24 #include "ash/shelf/overflow_button.h" | 24 #include "ash/shelf/overflow_button.h" |
| 25 #include "ash/shelf/shelf.h" | 25 #include "ash/shelf/shelf.h" |
| 26 #include "ash/shelf/shelf_button.h" | 26 #include "ash/shelf/shelf_button.h" |
| 27 #include "ash/shelf/shelf_delegate.h" | 27 #include "ash/shelf/shelf_delegate.h" |
| 28 #include "ash/shelf/shelf_icon_observer.h" | 28 #include "ash/shelf/shelf_icon_observer.h" |
| 29 #include "ash/shelf/shelf_widget.h" | 29 #include "ash/shelf/shelf_widget.h" |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 return this; | 578 return this; |
| 579 } | 579 } |
| 580 | 580 |
| 581 void ShelfView::CreateDragIconProxy( | 581 void ShelfView::CreateDragIconProxy( |
| 582 const gfx::Point& location_in_screen_coordinates, | 582 const gfx::Point& location_in_screen_coordinates, |
| 583 const gfx::ImageSkia& icon, | 583 const gfx::ImageSkia& icon, |
| 584 views::View* replaced_view, | 584 views::View* replaced_view, |
| 585 const gfx::Vector2d& cursor_offset_from_center, | 585 const gfx::Vector2d& cursor_offset_from_center, |
| 586 float scale_factor) { | 586 float scale_factor) { |
| 587 drag_replaced_view_ = replaced_view; | 587 drag_replaced_view_ = replaced_view; |
| 588 drag_image_.reset(new ash::DragImageView( | 588 drag_image_.reset(new DragImageView( |
| 589 drag_replaced_view_->GetWidget()->GetNativeWindow()->GetRootWindow(), | 589 drag_replaced_view_->GetWidget()->GetNativeWindow()->GetRootWindow(), |
| 590 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE)); | 590 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE)); |
| 591 drag_image_->SetImage(icon); | 591 drag_image_->SetImage(icon); |
| 592 gfx::Size size = drag_image_->GetPreferredSize(); | 592 gfx::Size size = drag_image_->GetPreferredSize(); |
| 593 size.set_width(size.width() * scale_factor); | 593 size.set_width(size.width() * scale_factor); |
| 594 size.set_height(size.height() * scale_factor); | 594 size.set_height(size.height() * scale_factor); |
| 595 drag_image_offset_ = gfx::Vector2d(size.width() / 2, size.height() / 2) + | 595 drag_image_offset_ = gfx::Vector2d(size.width() / 2, size.height() / 2) + |
| 596 cursor_offset_from_center; | 596 cursor_offset_from_center; |
| 597 gfx::Rect drag_image_bounds( | 597 gfx::Rect drag_image_bounds( |
| 598 location_in_screen_coordinates - drag_image_offset_, | 598 location_in_screen_coordinates - drag_image_offset_, |
| (...skipping 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1724 slowing_animations.reset(new ui::ScopedAnimationDurationScaleMode( | 1724 slowing_animations.reset(new ui::ScopedAnimationDurationScaleMode( |
| 1725 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION)); | 1725 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION)); |
| 1726 } | 1726 } |
| 1727 | 1727 |
| 1728 // Collect usage statistics before we decide what to do with the click. | 1728 // Collect usage statistics before we decide what to do with the click. |
| 1729 switch (model_->items()[last_pressed_index_].type) { | 1729 switch (model_->items()[last_pressed_index_].type) { |
| 1730 case TYPE_APP_SHORTCUT: | 1730 case TYPE_APP_SHORTCUT: |
| 1731 case TYPE_WINDOWED_APP: | 1731 case TYPE_WINDOWED_APP: |
| 1732 case TYPE_PLATFORM_APP: | 1732 case TYPE_PLATFORM_APP: |
| 1733 case TYPE_BROWSER_SHORTCUT: | 1733 case TYPE_BROWSER_SHORTCUT: |
| 1734 Shell::GetInstance()->metrics()->RecordUserMetricsAction( | 1734 WmShell::Get()->RecordUserMetricsAction( |
| 1735 UMA_LAUNCHER_CLICK_ON_APP); | 1735 UMA_LAUNCHER_CLICK_ON_APP); |
| 1736 break; | 1736 break; |
| 1737 | 1737 |
| 1738 case TYPE_APP_LIST: | 1738 case TYPE_APP_LIST: |
| 1739 Shell::GetInstance()->metrics()->RecordUserMetricsAction( | 1739 WmShell::Get()->RecordUserMetricsAction( |
| 1740 UMA_LAUNCHER_CLICK_ON_APPLIST_BUTTON); | 1740 UMA_LAUNCHER_CLICK_ON_APPLIST_BUTTON); |
| 1741 break; | 1741 break; |
| 1742 | 1742 |
| 1743 case TYPE_APP_PANEL: | 1743 case TYPE_APP_PANEL: |
| 1744 case TYPE_DIALOG: | 1744 case TYPE_DIALOG: |
| 1745 case TYPE_IME_MENU: | 1745 case TYPE_IME_MENU: |
| 1746 break; | 1746 break; |
| 1747 | 1747 |
| 1748 case TYPE_UNDEFINED: | 1748 case TYPE_UNDEFINED: |
| 1749 NOTREACHED() << "ShelfItemType must be set."; | 1749 NOTREACHED() << "ShelfItemType must be set."; |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1916 | 1916 |
| 1917 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { | 1917 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { |
| 1918 const gfx::Rect bounds = GetBoundsInScreen(); | 1918 const gfx::Rect bounds = GetBoundsInScreen(); |
| 1919 int distance = shelf_->SelectValueForShelfAlignment( | 1919 int distance = shelf_->SelectValueForShelfAlignment( |
| 1920 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), | 1920 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), |
| 1921 bounds.x() - coordinate.x()); | 1921 bounds.x() - coordinate.x()); |
| 1922 return distance > 0 ? distance : 0; | 1922 return distance > 0 ? distance : 0; |
| 1923 } | 1923 } |
| 1924 | 1924 |
| 1925 } // namespace ash | 1925 } // namespace ash |
| OLD | NEW |