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

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

Issue 1260453006: ui: events: Add a class to hold common touch and stylus properties (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address build problems, add accessor and unit tests. Created 5 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
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 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 // change once a regrouping animation is performed. 616 // change once a regrouping animation is performed.
617 pre_drag_and_drop_size_ = drag_and_drop_view->size(); 617 pre_drag_and_drop_size_ = drag_and_drop_view->size();
618 drag_and_drop_view->SetSize(gfx::Size()); 618 drag_and_drop_view->SetSize(gfx::Size());
619 619
620 // First we have to center the mouse cursor over the item. 620 // First we have to center the mouse cursor over the item.
621 gfx::Point pt = drag_and_drop_view->GetBoundsInScreen().CenterPoint(); 621 gfx::Point pt = drag_and_drop_view->GetBoundsInScreen().CenterPoint();
622 views::View::ConvertPointFromScreen(drag_and_drop_view, &pt); 622 views::View::ConvertPointFromScreen(drag_and_drop_view, &pt);
623 gfx::Point point_in_root = location_in_screen_coordinates; 623 gfx::Point point_in_root = location_in_screen_coordinates;
624 ::wm::ConvertPointFromScreen( 624 ::wm::ConvertPointFromScreen(
625 ash::wm::GetRootWindowAt(location_in_screen_coordinates), &point_in_root); 625 ash::wm::GetRootWindowAt(location_in_screen_coordinates), &point_in_root);
626 ui::MouseEvent event(ui::ET_MOUSE_PRESSED, pt, point_in_root, 626 ui::MouseEvent event(
627 ui::EventTimeForNow(), 0, 0); 627 ui::ET_MOUSE_PRESSED, pt, point_in_root, ui::EventTimeForNow(), 0, 0,
628 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
628 PointerPressedOnButton(drag_and_drop_view, 629 PointerPressedOnButton(drag_and_drop_view,
629 ShelfButtonHost::DRAG_AND_DROP, 630 ShelfButtonHost::DRAG_AND_DROP,
630 event); 631 event);
631 632
632 // Drag the item where it really belongs. 633 // Drag the item where it really belongs.
633 Drag(location_in_screen_coordinates); 634 Drag(location_in_screen_coordinates);
634 return true; 635 return true;
635 } 636 }
636 637
637 bool ShelfView::Drag(const gfx::Point& location_in_screen_coordinates) { 638 bool ShelfView::Drag(const gfx::Point& location_in_screen_coordinates) {
638 if (!drag_and_drop_shelf_id_ || 639 if (!drag_and_drop_shelf_id_ ||
639 !GetBoundsInScreen().Contains(location_in_screen_coordinates)) 640 !GetBoundsInScreen().Contains(location_in_screen_coordinates))
640 return false; 641 return false;
641 642
642 gfx::Point pt = location_in_screen_coordinates; 643 gfx::Point pt = location_in_screen_coordinates;
643 views::View* drag_and_drop_view = view_model_->view_at( 644 views::View* drag_and_drop_view = view_model_->view_at(
644 model_->ItemIndexByID(drag_and_drop_shelf_id_)); 645 model_->ItemIndexByID(drag_and_drop_shelf_id_));
645 ConvertPointFromScreen(drag_and_drop_view, &pt); 646 ConvertPointFromScreen(drag_and_drop_view, &pt);
646 gfx::Point point_in_root = location_in_screen_coordinates; 647 gfx::Point point_in_root = location_in_screen_coordinates;
647 ::wm::ConvertPointFromScreen( 648 ::wm::ConvertPointFromScreen(
648 ash::wm::GetRootWindowAt(location_in_screen_coordinates), &point_in_root); 649 ash::wm::GetRootWindowAt(location_in_screen_coordinates), &point_in_root);
649 ui::MouseEvent event(ui::ET_MOUSE_DRAGGED, pt, point_in_root, 650 ui::MouseEvent event(
650 ui::EventTimeForNow(), 0, 0); 651 ui::ET_MOUSE_DRAGGED, pt, point_in_root, ui::EventTimeForNow(), 0, 0,
652 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
651 PointerDraggedOnButton(drag_and_drop_view, 653 PointerDraggedOnButton(drag_and_drop_view,
652 ShelfButtonHost::DRAG_AND_DROP, 654 ShelfButtonHost::DRAG_AND_DROP,
653 event); 655 event);
654 return true; 656 return true;
655 } 657 }
656 658
657 void ShelfView::EndDrag(bool cancel) { 659 void ShelfView::EndDrag(bool cancel) {
658 if (!drag_and_drop_shelf_id_) 660 if (!drag_and_drop_shelf_id_)
659 return; 661 return;
660 662
(...skipping 1307 matching lines...) Expand 10 before | Expand all | Expand 10 after
1968 distance = bounds.x() - coordinate.x(); 1970 distance = bounds.x() - coordinate.x();
1969 break; 1971 break;
1970 case SHELF_ALIGNMENT_TOP: 1972 case SHELF_ALIGNMENT_TOP:
1971 distance = coordinate.y() - bounds.bottom(); 1973 distance = coordinate.y() - bounds.bottom();
1972 break; 1974 break;
1973 } 1975 }
1974 return distance > 0 ? distance : 0; 1976 return distance > 0 ? distance : 0;
1975 } 1977 }
1976 1978
1977 } // namespace ash 1979 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698