Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(385)

Side by Side Diff: ash/shelf/shelf_view.cc

Issue 2035543004: Shuffles and renames ash/common/wm classes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: random changes for chrome tests Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/ash_switches.h" 11 #include "ash/ash_switches.h"
12 #include "ash/aura/wm_window_aura.h"
12 #include "ash/common/wm/root_window_finder.h" 13 #include "ash/common/wm/root_window_finder.h"
13 #include "ash/drag_drop/drag_image_view.h" 14 #include "ash/drag_drop/drag_image_view.h"
14 #include "ash/metrics/user_metrics_recorder.h" 15 #include "ash/metrics/user_metrics_recorder.h"
15 #include "ash/scoped_target_root_window.h" 16 #include "ash/scoped_target_root_window.h"
16 #include "ash/shelf/app_list_button.h" 17 #include "ash/shelf/app_list_button.h"
17 #include "ash/shelf/overflow_bubble.h" 18 #include "ash/shelf/overflow_bubble.h"
18 #include "ash/shelf/overflow_bubble_view.h" 19 #include "ash/shelf/overflow_bubble_view.h"
19 #include "ash/shelf/overflow_button.h" 20 #include "ash/shelf/overflow_button.h"
20 #include "ash/shelf/shelf.h" 21 #include "ash/shelf/shelf.h"
21 #include "ash/shelf/shelf_button.h" 22 #include "ash/shelf/shelf_button.h"
22 #include "ash/shelf/shelf_constants.h" 23 #include "ash/shelf/shelf_constants.h"
23 #include "ash/shelf/shelf_delegate.h" 24 #include "ash/shelf/shelf_delegate.h"
24 #include "ash/shelf/shelf_icon_observer.h" 25 #include "ash/shelf/shelf_icon_observer.h"
25 #include "ash/shelf/shelf_item_delegate_manager.h" 26 #include "ash/shelf/shelf_item_delegate_manager.h"
26 #include "ash/shelf/shelf_menu_model.h" 27 #include "ash/shelf/shelf_menu_model.h"
27 #include "ash/shelf/shelf_model.h" 28 #include "ash/shelf/shelf_model.h"
28 #include "ash/shelf/shelf_widget.h" 29 #include "ash/shelf/shelf_widget.h"
29 #include "ash/shell.h" 30 #include "ash/shell.h"
30 #include "ash/shell_delegate.h" 31 #include "ash/shell_delegate.h"
31 #include "ash/wm/aura/wm_window_aura.h"
32 #include "base/auto_reset.h" 32 #include "base/auto_reset.h"
33 #include "base/metrics/histogram.h" 33 #include "base/metrics/histogram.h"
34 #include "grit/ash_strings.h" 34 #include "grit/ash_strings.h"
35 #include "ui/accessibility/ax_view_state.h" 35 #include "ui/accessibility/ax_view_state.h"
36 #include "ui/aura/client/screen_position_client.h" 36 #include "ui/aura/client/screen_position_client.h"
37 #include "ui/aura/window.h" 37 #include "ui/aura/window.h"
38 #include "ui/aura/window_event_dispatcher.h" 38 #include "ui/aura/window_event_dispatcher.h"
39 #include "ui/base/l10n/l10n_util.h" 39 #include "ui/base/l10n/l10n_util.h"
40 #include "ui/base/models/simple_menu_model.h" 40 #include "ui/base/models/simple_menu_model.h"
41 #include "ui/base/resource/resource_bundle.h" 41 #include "ui/base/resource/resource_bundle.h"
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 // for now. That has to be done by reducing the size since the visibility will 649 // for now. That has to be done by reducing the size since the visibility will
650 // change once a regrouping animation is performed. 650 // change once a regrouping animation is performed.
651 pre_drag_and_drop_size_ = drag_and_drop_view->size(); 651 pre_drag_and_drop_size_ = drag_and_drop_view->size();
652 drag_and_drop_view->SetSize(gfx::Size()); 652 drag_and_drop_view->SetSize(gfx::Size());
653 653
654 // First we have to center the mouse cursor over the item. 654 // First we have to center the mouse cursor over the item.
655 gfx::Point pt = drag_and_drop_view->GetBoundsInScreen().CenterPoint(); 655 gfx::Point pt = drag_and_drop_view->GetBoundsInScreen().CenterPoint();
656 views::View::ConvertPointFromScreen(drag_and_drop_view, &pt); 656 views::View::ConvertPointFromScreen(drag_and_drop_view, &pt);
657 gfx::Point point_in_root = location_in_screen_coordinates; 657 gfx::Point point_in_root = location_in_screen_coordinates;
658 ::wm::ConvertPointFromScreen( 658 ::wm::ConvertPointFromScreen(
659 wm::WmWindowAura::GetAuraWindow( 659 WmWindowAura::GetAuraWindow(
660 ash::wm::GetRootWindowAt(location_in_screen_coordinates)), 660 ash::wm::GetRootWindowAt(location_in_screen_coordinates)),
661 &point_in_root); 661 &point_in_root);
662 ui::MouseEvent event(ui::ET_MOUSE_PRESSED, pt, point_in_root, 662 ui::MouseEvent event(ui::ET_MOUSE_PRESSED, pt, point_in_root,
663 ui::EventTimeForNow(), 0, 0); 663 ui::EventTimeForNow(), 0, 0);
664 PointerPressedOnButton(drag_and_drop_view, DRAG_AND_DROP, event); 664 PointerPressedOnButton(drag_and_drop_view, DRAG_AND_DROP, event);
665 665
666 // Drag the item where it really belongs. 666 // Drag the item where it really belongs.
667 Drag(location_in_screen_coordinates); 667 Drag(location_in_screen_coordinates);
668 return true; 668 return true;
669 } 669 }
670 670
671 bool ShelfView::Drag(const gfx::Point& location_in_screen_coordinates) { 671 bool ShelfView::Drag(const gfx::Point& location_in_screen_coordinates) {
672 if (!drag_and_drop_shelf_id_ || 672 if (!drag_and_drop_shelf_id_ ||
673 !GetBoundsInScreen().Contains(location_in_screen_coordinates)) 673 !GetBoundsInScreen().Contains(location_in_screen_coordinates))
674 return false; 674 return false;
675 675
676 gfx::Point pt = location_in_screen_coordinates; 676 gfx::Point pt = location_in_screen_coordinates;
677 views::View* drag_and_drop_view = view_model_->view_at( 677 views::View* drag_and_drop_view = view_model_->view_at(
678 model_->ItemIndexByID(drag_and_drop_shelf_id_)); 678 model_->ItemIndexByID(drag_and_drop_shelf_id_));
679 ConvertPointFromScreen(drag_and_drop_view, &pt); 679 ConvertPointFromScreen(drag_and_drop_view, &pt);
680 gfx::Point point_in_root = location_in_screen_coordinates; 680 gfx::Point point_in_root = location_in_screen_coordinates;
681 ::wm::ConvertPointFromScreen( 681 ::wm::ConvertPointFromScreen(
682 wm::WmWindowAura::GetAuraWindow( 682 WmWindowAura::GetAuraWindow(
683 ash::wm::GetRootWindowAt(location_in_screen_coordinates)), 683 ash::wm::GetRootWindowAt(location_in_screen_coordinates)),
684 &point_in_root); 684 &point_in_root);
685 ui::MouseEvent event(ui::ET_MOUSE_DRAGGED, pt, point_in_root, 685 ui::MouseEvent event(ui::ET_MOUSE_DRAGGED, pt, point_in_root,
686 ui::EventTimeForNow(), 0, 0); 686 ui::EventTimeForNow(), 0, 0);
687 PointerDraggedOnButton(drag_and_drop_view, DRAG_AND_DROP, event); 687 PointerDraggedOnButton(drag_and_drop_view, DRAG_AND_DROP, event);
688 return true; 688 return true;
689 } 689 }
690 690
691 void ShelfView::EndDrag(bool cancel) { 691 void ShelfView::EndDrag(bool cancel) {
692 if (!drag_and_drop_shelf_id_) 692 if (!drag_and_drop_shelf_id_)
(...skipping 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after
1891 1891
1892 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { 1892 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const {
1893 const gfx::Rect bounds = GetBoundsInScreen(); 1893 const gfx::Rect bounds = GetBoundsInScreen();
1894 int distance = shelf_->SelectValueForShelfAlignment( 1894 int distance = shelf_->SelectValueForShelfAlignment(
1895 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), 1895 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(),
1896 bounds.x() - coordinate.x()); 1896 bounds.x() - coordinate.x());
1897 return distance > 0 ? distance : 0; 1897 return distance > 0 ? distance : 0;
1898 } 1898 }
1899 1899
1900 } // namespace ash 1900 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698