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

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

Issue 445703005: Revert of Moving coordinate conversion methods from ash/wm to ui/wm. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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
« no previous file with comments | « ash/shelf/shelf_bezel_event_filter.cc ('k') | ash/shelf/shelf_view_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #include "ui/gfx/point.h" 48 #include "ui/gfx/point.h"
49 #include "ui/views/animation/bounds_animator.h" 49 #include "ui/views/animation/bounds_animator.h"
50 #include "ui/views/border.h" 50 #include "ui/views/border.h"
51 #include "ui/views/controls/button/image_button.h" 51 #include "ui/views/controls/button/image_button.h"
52 #include "ui/views/controls/menu/menu_model_adapter.h" 52 #include "ui/views/controls/menu/menu_model_adapter.h"
53 #include "ui/views/controls/menu/menu_runner.h" 53 #include "ui/views/controls/menu/menu_runner.h"
54 #include "ui/views/focus/focus_search.h" 54 #include "ui/views/focus/focus_search.h"
55 #include "ui/views/view_model.h" 55 #include "ui/views/view_model.h"
56 #include "ui/views/view_model_utils.h" 56 #include "ui/views/view_model_utils.h"
57 #include "ui/views/widget/widget.h" 57 #include "ui/views/widget/widget.h"
58 #include "ui/wm/core/coordinate_conversion.h"
59 58
60 using gfx::Animation; 59 using gfx::Animation;
61 using views::View; 60 using views::View;
62 61
63 namespace ash { 62 namespace ash {
64 63
65 const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_BOTTOM = 0; 64 const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_BOTTOM = 0;
66 const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_LEFT = 1; 65 const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_LEFT = 1;
67 const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_RIGHT = 2; 66 const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_RIGHT = 2;
68 const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_COUNT = 3; 67 const int SHELF_ALIGNMENT_UMA_ENUM_VALUE_COUNT = 3;
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 // Since there is already an icon presented by the caller, we hide this item 610 // Since there is already an icon presented by the caller, we hide this item
612 // for now. That has to be done by reducing the size since the visibility will 611 // for now. That has to be done by reducing the size since the visibility will
613 // change once a regrouping animation is performed. 612 // change once a regrouping animation is performed.
614 pre_drag_and_drop_size_ = drag_and_drop_view->size(); 613 pre_drag_and_drop_size_ = drag_and_drop_view->size();
615 drag_and_drop_view->SetSize(gfx::Size()); 614 drag_and_drop_view->SetSize(gfx::Size());
616 615
617 // First we have to center the mouse cursor over the item. 616 // First we have to center the mouse cursor over the item.
618 gfx::Point pt = drag_and_drop_view->GetBoundsInScreen().CenterPoint(); 617 gfx::Point pt = drag_and_drop_view->GetBoundsInScreen().CenterPoint();
619 views::View::ConvertPointFromScreen(drag_and_drop_view, &pt); 618 views::View::ConvertPointFromScreen(drag_and_drop_view, &pt);
620 gfx::Point point_in_root = location_in_screen_coordinates; 619 gfx::Point point_in_root = location_in_screen_coordinates;
621 ::wm::ConvertPointFromScreen( 620 ash::wm::ConvertPointFromScreen(
622 ash::wm::GetRootWindowAt(location_in_screen_coordinates), &point_in_root); 621 ash::wm::GetRootWindowAt(location_in_screen_coordinates),
622 &point_in_root);
623 ui::MouseEvent event(ui::ET_MOUSE_PRESSED, pt, point_in_root, 0, 0); 623 ui::MouseEvent event(ui::ET_MOUSE_PRESSED, pt, point_in_root, 0, 0);
624 PointerPressedOnButton(drag_and_drop_view, 624 PointerPressedOnButton(drag_and_drop_view,
625 ShelfButtonHost::DRAG_AND_DROP, 625 ShelfButtonHost::DRAG_AND_DROP,
626 event); 626 event);
627 627
628 // Drag the item where it really belongs. 628 // Drag the item where it really belongs.
629 Drag(location_in_screen_coordinates); 629 Drag(location_in_screen_coordinates);
630 return true; 630 return true;
631 } 631 }
632 632
633 bool ShelfView::Drag(const gfx::Point& location_in_screen_coordinates) { 633 bool ShelfView::Drag(const gfx::Point& location_in_screen_coordinates) {
634 if (!drag_and_drop_shelf_id_ || 634 if (!drag_and_drop_shelf_id_ ||
635 !GetBoundsInScreen().Contains(location_in_screen_coordinates)) 635 !GetBoundsInScreen().Contains(location_in_screen_coordinates))
636 return false; 636 return false;
637 637
638 gfx::Point pt = location_in_screen_coordinates; 638 gfx::Point pt = location_in_screen_coordinates;
639 views::View* drag_and_drop_view = view_model_->view_at( 639 views::View* drag_and_drop_view = view_model_->view_at(
640 model_->ItemIndexByID(drag_and_drop_shelf_id_)); 640 model_->ItemIndexByID(drag_and_drop_shelf_id_));
641 ConvertPointFromScreen(drag_and_drop_view, &pt); 641 ConvertPointFromScreen(drag_and_drop_view, &pt);
642 gfx::Point point_in_root = location_in_screen_coordinates; 642 gfx::Point point_in_root = location_in_screen_coordinates;
643 ::wm::ConvertPointFromScreen( 643 ash::wm::ConvertPointFromScreen(
644 ash::wm::GetRootWindowAt(location_in_screen_coordinates), &point_in_root); 644 ash::wm::GetRootWindowAt(location_in_screen_coordinates),
645 &point_in_root);
645 ui::MouseEvent event(ui::ET_MOUSE_DRAGGED, pt, point_in_root, 0, 0); 646 ui::MouseEvent event(ui::ET_MOUSE_DRAGGED, pt, point_in_root, 0, 0);
646 PointerDraggedOnButton(drag_and_drop_view, 647 PointerDraggedOnButton(drag_and_drop_view,
647 ShelfButtonHost::DRAG_AND_DROP, 648 ShelfButtonHost::DRAG_AND_DROP,
648 event); 649 event);
649 return true; 650 return true;
650 } 651 }
651 652
652 void ShelfView::EndDrag(bool cancel) { 653 void ShelfView::EndDrag(bool cancel) {
653 if (!drag_and_drop_shelf_id_) 654 if (!drag_and_drop_shelf_id_)
654 return; 655 return;
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 bounds_animator_->StopAnimatingView(drag_view_); 1003 bounds_animator_->StopAnimatingView(drag_view_);
1003 } 1004 }
1004 1005
1005 bool ShelfView::HandleRipOffDrag(const ui::LocatedEvent& event) { 1006 bool ShelfView::HandleRipOffDrag(const ui::LocatedEvent& event) {
1006 int current_index = view_model_->GetIndexOfView(drag_view_); 1007 int current_index = view_model_->GetIndexOfView(drag_view_);
1007 DCHECK_NE(-1, current_index); 1008 DCHECK_NE(-1, current_index);
1008 std::string dragged_app_id = 1009 std::string dragged_app_id =
1009 delegate_->GetAppIDForShelfID(model_->items()[current_index].id); 1010 delegate_->GetAppIDForShelfID(model_->items()[current_index].id);
1010 1011
1011 gfx::Point screen_location = event.root_location(); 1012 gfx::Point screen_location = event.root_location();
1012 ::wm::ConvertPointToScreen(GetWidget()->GetNativeWindow()->GetRootWindow(), 1013 ash::wm::ConvertPointToScreen(GetWidget()->GetNativeWindow()->GetRootWindow(),
1013 &screen_location); 1014 &screen_location);
1014 1015
1015 // To avoid ugly forwards and backwards flipping we use different constants 1016 // To avoid ugly forwards and backwards flipping we use different constants
1016 // for ripping off / re-inserting the items. 1017 // for ripping off / re-inserting the items.
1017 if (dragged_off_shelf_) { 1018 if (dragged_off_shelf_) {
1018 // If the shelf/overflow bubble bounds contains |screen_location| we insert 1019 // If the shelf/overflow bubble bounds contains |screen_location| we insert
1019 // the item back into the shelf. 1020 // the item back into the shelf.
1020 if (GetBoundsForDragInsertInScreen().Contains(screen_location)) { 1021 if (GetBoundsForDragInsertInScreen().Contains(screen_location)) {
1021 if (dragged_off_from_overflow_to_shelf_) { 1022 if (dragged_off_from_overflow_to_shelf_) {
1022 // During the dragging an item from Shelf to Overflow, it can enter here 1023 // During the dragging an item from Shelf to Overflow, it can enter here
1023 // directly because both are located very closly. 1024 // directly because both are located very closly.
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after
1917 distance = bounds.x() - coordinate.x(); 1918 distance = bounds.x() - coordinate.x();
1918 break; 1919 break;
1919 case SHELF_ALIGNMENT_TOP: 1920 case SHELF_ALIGNMENT_TOP:
1920 distance = coordinate.y() - bounds.bottom(); 1921 distance = coordinate.y() - bounds.bottom();
1921 break; 1922 break;
1922 } 1923 }
1923 return distance > 0 ? distance : 0; 1924 return distance > 0 ? distance : 0;
1924 } 1925 }
1925 1926
1926 } // namespace ash 1927 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/shelf_bezel_event_filter.cc ('k') | ash/shelf/shelf_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698