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 "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 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 | 594 |
595 View* View::GetSelectedViewForGroup(int group) { | 595 View* View::GetSelectedViewForGroup(int group) { |
596 Views views; | 596 Views views; |
597 GetWidget()->GetRootView()->GetViewsInGroup(group, &views); | 597 GetWidget()->GetRootView()->GetViewsInGroup(group, &views); |
598 return views.empty() ? NULL : views[0]; | 598 return views.empty() ? NULL : views[0]; |
599 } | 599 } |
600 | 600 |
601 // Coordinate conversion ------------------------------------------------------- | 601 // Coordinate conversion ------------------------------------------------------- |
602 | 602 |
603 // static | 603 // static |
604 void View::ConvertPointToView(const View* source, | 604 void View::ConvertPointToTarget(const View* source, |
605 const View* target, | 605 const View* target, |
606 gfx::Point* point) { | 606 gfx::Point* point) { |
607 if (source == target) | 607 if (source == target) |
608 return; | 608 return; |
609 | 609 |
610 // |source| can be NULL. | 610 // |source| can be NULL. |
611 const View* root = GetHierarchyRoot(target); | 611 const View* root = GetHierarchyRoot(target); |
612 if (source) { | 612 if (source) { |
613 CHECK_EQ(GetHierarchyRoot(source), root); | 613 CHECK_EQ(GetHierarchyRoot(source), root); |
614 | 614 |
615 if (source != root) | 615 if (source != root) |
616 source->ConvertPointForAncestor(root, point); | 616 source->ConvertPointForAncestor(root, point); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 | 750 |
751 View* View::GetEventHandlerForPoint(const gfx::Point& point) { | 751 View* View::GetEventHandlerForPoint(const gfx::Point& point) { |
752 // Walk the child Views recursively looking for the View that most | 752 // Walk the child Views recursively looking for the View that most |
753 // tightly encloses the specified point. | 753 // tightly encloses the specified point. |
754 for (int i = child_count() - 1; i >= 0; --i) { | 754 for (int i = child_count() - 1; i >= 0; --i) { |
755 View* child = child_at(i); | 755 View* child = child_at(i); |
756 if (!child->visible()) | 756 if (!child->visible()) |
757 continue; | 757 continue; |
758 | 758 |
759 gfx::Point point_in_child_coords(point); | 759 gfx::Point point_in_child_coords(point); |
760 View::ConvertPointToView(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 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; |
(...skipping 1321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2092 Widget* widget = GetWidget(); | 2092 Widget* widget = GetWidget(); |
2093 // TODO(beng): The TooltipManager NULL check can be removed when we | 2093 // TODO(beng): The TooltipManager NULL check can be removed when we |
2094 // consolidate Init() methods and make views_unittests Init() all | 2094 // consolidate Init() methods and make views_unittests Init() all |
2095 // Widgets that it uses. | 2095 // Widgets that it uses. |
2096 if (widget && widget->native_widget_private()->GetTooltipManager()) | 2096 if (widget && widget->native_widget_private()->GetTooltipManager()) |
2097 widget->native_widget_private()->GetTooltipManager()->UpdateTooltip(); | 2097 widget->native_widget_private()->GetTooltipManager()->UpdateTooltip(); |
2098 } | 2098 } |
2099 | 2099 |
2100 // Drag and drop --------------------------------------------------------------- | 2100 // Drag and drop --------------------------------------------------------------- |
2101 | 2101 |
2102 bool View::DoDrag(const LocatedEvent& event, const gfx::Point& press_pt) { | 2102 bool View::DoDrag(const ui::LocatedEvent& event, const gfx::Point& press_pt) { |
2103 #if !defined(OS_MACOSX) | 2103 #if !defined(OS_MACOSX) |
2104 int drag_operations = GetDragOperations(press_pt); | 2104 int drag_operations = GetDragOperations(press_pt); |
2105 if (drag_operations == ui::DragDropTypes::DRAG_NONE) | 2105 if (drag_operations == ui::DragDropTypes::DRAG_NONE) |
2106 return false; | 2106 return false; |
2107 | 2107 |
2108 OSExchangeData data; | 2108 OSExchangeData data; |
2109 WriteDragData(press_pt, &data); | 2109 WriteDragData(press_pt, &data); |
2110 | 2110 |
2111 // Message the RootView to do the drag and drop. That way if we're removed | 2111 // Message the RootView to do the drag and drop. That way if we're removed |
2112 // the RootView can detect it and avoid calling us back. | 2112 // the RootView can detect it and avoid calling us back. |
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 |
OLD | NEW |