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

Side by Side Diff: ui/views/view.cc

Issue 10832282: Replace views::MouseEvent with ui::MouseEvent (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/view.h ('k') | ui/views/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 "ui/views/view.h" 5 #include "ui/views/view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 continue; 757 continue;
758 758
759 gfx::Point point_in_child_coords(point); 759 gfx::Point point_in_child_coords(point);
760 ConvertPointToTarget(this, child, &point_in_child_coords); 760 ConvertPointToTarget(this, child, &point_in_child_coords);
761 if (child->HitTestPoint(point_in_child_coords)) 761 if (child->HitTestPoint(point_in_child_coords))
762 return child->GetEventHandlerForPoint(point_in_child_coords); 762 return child->GetEventHandlerForPoint(point_in_child_coords);
763 } 763 }
764 return this; 764 return this;
765 } 765 }
766 766
767 gfx::NativeCursor View::GetCursor(const MouseEvent& event) { 767 gfx::NativeCursor View::GetCursor(const ui::MouseEvent& event) {
768 #if defined(OS_WIN) && !defined(USE_AURA) 768 #if defined(OS_WIN) && !defined(USE_AURA)
769 static HCURSOR arrow = LoadCursor(NULL, IDC_ARROW); 769 static HCURSOR arrow = LoadCursor(NULL, IDC_ARROW);
770 return arrow; 770 return arrow;
771 #else 771 #else
772 return gfx::kNullCursor; 772 return gfx::kNullCursor;
773 #endif 773 #endif
774 } 774 }
775 775
776 bool View::HitTestPoint(const gfx::Point& point) const { 776 bool View::HitTestPoint(const gfx::Point& point) const {
777 return HitTestRect(gfx::Rect(point, gfx::Size(1, 1))); 777 return HitTestRect(gfx::Rect(point, gfx::Size(1, 1)));
(...skipping 17 matching lines...) Expand all
795 return RectInRegion(rgn, &r) != 0; 795 return RectInRegion(rgn, &r) != 0;
796 #endif 796 #endif
797 } 797 }
798 // No mask, but inside our bounds. 798 // No mask, but inside our bounds.
799 return true; 799 return true;
800 } 800 }
801 // Outside our bounds. 801 // Outside our bounds.
802 return false; 802 return false;
803 } 803 }
804 804
805 bool View::OnMousePressed(const MouseEvent& event) { 805 bool View::OnMousePressed(const ui::MouseEvent& event) {
806 return false; 806 return false;
807 } 807 }
808 808
809 bool View::OnMouseDragged(const MouseEvent& event) { 809 bool View::OnMouseDragged(const ui::MouseEvent& event) {
810 return false; 810 return false;
811 } 811 }
812 812
813 void View::OnMouseReleased(const MouseEvent& event) { 813 void View::OnMouseReleased(const ui::MouseEvent& event) {
814 } 814 }
815 815
816 void View::OnMouseCaptureLost() { 816 void View::OnMouseCaptureLost() {
817 } 817 }
818 818
819 void View::OnMouseMoved(const MouseEvent& event) { 819 void View::OnMouseMoved(const ui::MouseEvent& event) {
820 } 820 }
821 821
822 void View::OnMouseEntered(const MouseEvent& event) { 822 void View::OnMouseEntered(const ui::MouseEvent& event) {
823 } 823 }
824 824
825 void View::OnMouseExited(const MouseEvent& event) { 825 void View::OnMouseExited(const ui::MouseEvent& event) {
826 } 826 }
827 827
828 ui::TouchStatus View::OnTouchEvent(const TouchEvent& event) { 828 ui::TouchStatus View::OnTouchEvent(const TouchEvent& event) {
829 return ui::TOUCH_STATUS_UNKNOWN; 829 return ui::TOUCH_STATUS_UNKNOWN;
830 } 830 }
831 831
832 ui::GestureStatus View::OnGestureEvent(const GestureEvent& event) { 832 ui::GestureStatus View::OnGestureEvent(const GestureEvent& event) {
833 return ui::GESTURE_STATUS_UNKNOWN; 833 return ui::GESTURE_STATUS_UNKNOWN;
834 } 834 }
835 835
(...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after
1893 1893
1894 SchedulePaint(); 1894 SchedulePaint();
1895 1895
1896 Widget* widget = GetWidget(); 1896 Widget* widget = GetWidget();
1897 if (widget) 1897 if (widget)
1898 widget->UpdateRootLayers(); 1898 widget->UpdateRootLayers();
1899 } 1899 }
1900 1900
1901 // Input ----------------------------------------------------------------------- 1901 // Input -----------------------------------------------------------------------
1902 1902
1903 bool View::ProcessMousePressed(const MouseEvent& event, DragInfo* drag_info) { 1903 bool View::ProcessMousePressed(const ui::MouseEvent& event, DragInfo* drag_info) {
1904 int drag_operations = 1904 int drag_operations =
1905 (enabled_ && event.IsOnlyLeftMouseButton() && 1905 (enabled_ && event.IsOnlyLeftMouseButton() &&
1906 HitTestPoint(event.location())) ? 1906 HitTestPoint(event.location())) ?
1907 GetDragOperations(event.location()) : 0; 1907 GetDragOperations(event.location()) : 0;
1908 ContextMenuController* context_menu_controller = event.IsRightMouseButton() ? 1908 ContextMenuController* context_menu_controller = event.IsRightMouseButton() ?
1909 context_menu_controller_ : 0; 1909 context_menu_controller_ : 0;
1910 1910
1911 const bool enabled = enabled_; 1911 const bool enabled = enabled_;
1912 const bool result = OnMousePressed(event); 1912 const bool result = OnMousePressed(event);
1913 // WARNING: we may have been deleted, don't use any View variables. 1913 // WARNING: we may have been deleted, don't use any View variables.
1914 1914
1915 if (!enabled) 1915 if (!enabled)
1916 return result; 1916 return result;
1917 1917
1918 if (drag_operations != ui::DragDropTypes::DRAG_NONE) { 1918 if (drag_operations != ui::DragDropTypes::DRAG_NONE) {
1919 drag_info->PossibleDrag(event.location()); 1919 drag_info->PossibleDrag(event.location());
1920 return true; 1920 return true;
1921 } 1921 }
1922 return !!context_menu_controller || result; 1922 return !!context_menu_controller || result;
1923 } 1923 }
1924 1924
1925 bool View::ProcessMouseDragged(const MouseEvent& event, DragInfo* drag_info) { 1925 bool View::ProcessMouseDragged(const ui::MouseEvent& event, DragInfo* drag_info) {
1926 // Copy the field, that way if we're deleted after drag and drop no harm is 1926 // Copy the field, that way if we're deleted after drag and drop no harm is
1927 // done. 1927 // done.
1928 ContextMenuController* context_menu_controller = context_menu_controller_; 1928 ContextMenuController* context_menu_controller = context_menu_controller_;
1929 const bool possible_drag = drag_info->possible_drag; 1929 const bool possible_drag = drag_info->possible_drag;
1930 if (possible_drag && ExceededDragThreshold( 1930 if (possible_drag && ExceededDragThreshold(
1931 drag_info->start_pt.x() - event.x(), 1931 drag_info->start_pt.x() - event.x(),
1932 drag_info->start_pt.y() - event.y())) { 1932 drag_info->start_pt.y() - event.y())) {
1933 if (!drag_controller_ || 1933 if (!drag_controller_ ||
1934 drag_controller_->CanStartDragForView( 1934 drag_controller_->CanStartDragForView(
1935 this, drag_info->start_pt, event.location())) 1935 this, drag_info->start_pt, event.location()))
1936 DoDrag(event, drag_info->start_pt); 1936 DoDrag(event, drag_info->start_pt);
1937 } else { 1937 } else {
1938 if (OnMouseDragged(event)) 1938 if (OnMouseDragged(event))
1939 return true; 1939 return true;
1940 // Fall through to return value based on context menu controller. 1940 // Fall through to return value based on context menu controller.
1941 } 1941 }
1942 // WARNING: we may have been deleted. 1942 // WARNING: we may have been deleted.
1943 return (context_menu_controller != NULL) || possible_drag; 1943 return (context_menu_controller != NULL) || possible_drag;
1944 } 1944 }
1945 1945
1946 void View::ProcessMouseReleased(const MouseEvent& event) { 1946 void View::ProcessMouseReleased(const ui::MouseEvent& event) {
1947 if (context_menu_controller_ && event.IsOnlyRightMouseButton()) { 1947 if (context_menu_controller_ && event.IsOnlyRightMouseButton()) {
1948 // Assume that if there is a context menu controller we won't be deleted 1948 // Assume that if there is a context menu controller we won't be deleted
1949 // from mouse released. 1949 // from mouse released.
1950 gfx::Point location(event.location()); 1950 gfx::Point location(event.location());
1951 OnMouseReleased(event); 1951 OnMouseReleased(event);
1952 if (HitTestPoint(location)) { 1952 if (HitTestPoint(location)) {
1953 ConvertPointToScreen(this, &location); 1953 ConvertPointToScreen(this, &location);
1954 ShowContextMenu(location, true); 1954 ShowContextMenu(location, true);
1955 } 1955 }
1956 } else { 1956 } else {
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
2113 gfx::Point widget_location(event.location()); 2113 gfx::Point widget_location(event.location());
2114 ConvertPointToWidget(this, &widget_location); 2114 ConvertPointToWidget(this, &widget_location);
2115 GetWidget()->RunShellDrag(this, data, widget_location, drag_operations); 2115 GetWidget()->RunShellDrag(this, data, widget_location, drag_operations);
2116 return true; 2116 return true;
2117 #else 2117 #else
2118 return false; 2118 return false;
2119 #endif // !defined(OS_MACOSX) 2119 #endif // !defined(OS_MACOSX)
2120 } 2120 }
2121 2121
2122 } // namespace views 2122 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/view.h ('k') | ui/views/view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698