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 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. | 5 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. |
6 | 6 |
7 #include "ui/views/view.h" | 7 #include "ui/views/view.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "ui/gfx/geometry/point3_f.h" | 32 #include "ui/gfx/geometry/point3_f.h" |
33 #include "ui/gfx/geometry/point_conversions.h" | 33 #include "ui/gfx/geometry/point_conversions.h" |
34 #include "ui/gfx/interpolated_transform.h" | 34 #include "ui/gfx/interpolated_transform.h" |
35 #include "ui/gfx/path.h" | 35 #include "ui/gfx/path.h" |
36 #include "ui/gfx/scoped_canvas.h" | 36 #include "ui/gfx/scoped_canvas.h" |
37 #include "ui/gfx/screen.h" | 37 #include "ui/gfx/screen.h" |
38 #include "ui/gfx/skia_util.h" | 38 #include "ui/gfx/skia_util.h" |
39 #include "ui/gfx/transform.h" | 39 #include "ui/gfx/transform.h" |
40 #include "ui/native_theme/native_theme.h" | 40 #include "ui/native_theme/native_theme.h" |
41 #include "ui/views/accessibility/native_view_accessibility.h" | 41 #include "ui/views/accessibility/native_view_accessibility.h" |
| 42 #include "ui/views/animation/ink_drop_delegate.h" |
42 #include "ui/views/background.h" | 43 #include "ui/views/background.h" |
43 #include "ui/views/border.h" | 44 #include "ui/views/border.h" |
44 #include "ui/views/context_menu_controller.h" | 45 #include "ui/views/context_menu_controller.h" |
45 #include "ui/views/drag_controller.h" | 46 #include "ui/views/drag_controller.h" |
46 #include "ui/views/focus/view_storage.h" | 47 #include "ui/views/focus/view_storage.h" |
47 #include "ui/views/layout/layout_manager.h" | 48 #include "ui/views/layout/layout_manager.h" |
48 #include "ui/views/views_delegate.h" | 49 #include "ui/views/views_delegate.h" |
49 #include "ui/views/widget/native_widget_private.h" | 50 #include "ui/views/widget/native_widget_private.h" |
50 #include "ui/views/widget/root_view.h" | 51 #include "ui/views/widget/root_view.h" |
51 #include "ui/views/widget/tooltip_manager.h" | 52 #include "ui/views/widget/tooltip_manager.h" |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 // just propagate the Layout() call down the hierarchy, so whoever receives | 512 // just propagate the Layout() call down the hierarchy, so whoever receives |
512 // the call can take appropriate action. | 513 // the call can take appropriate action. |
513 for (int i = 0, count = child_count(); i < count; ++i) { | 514 for (int i = 0, count = child_count(); i < count; ++i) { |
514 View* child = child_at(i); | 515 View* child = child_at(i); |
515 if (child->needs_layout_ || !layout_manager_.get()) { | 516 if (child->needs_layout_ || !layout_manager_.get()) { |
516 TRACE_EVENT1("views", "View::Layout", "class", child->GetClassName()); | 517 TRACE_EVENT1("views", "View::Layout", "class", child->GetClassName()); |
517 child->needs_layout_ = false; | 518 child->needs_layout_ = false; |
518 child->Layout(); | 519 child->Layout(); |
519 } | 520 } |
520 } | 521 } |
| 522 |
| 523 InkDropDelegate* ink_drop_delegate = GetInkDropDelegate(); |
| 524 if (ink_drop_delegate) |
| 525 ink_drop_delegate->OnLayout(); |
521 } | 526 } |
522 | 527 |
523 void View::InvalidateLayout() { | 528 void View::InvalidateLayout() { |
524 // Always invalidate up. This is needed to handle the case of us already being | 529 // Always invalidate up. This is needed to handle the case of us already being |
525 // valid, but not our parent. | 530 // valid, but not our parent. |
526 needs_layout_ = true; | 531 needs_layout_ = true; |
527 if (parent_) | 532 if (parent_) |
528 parent_->InvalidateLayout(); | 533 parent_->InvalidateLayout(); |
529 } | 534 } |
530 | 535 |
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1247 } | 1252 } |
1248 | 1253 |
1249 void View::OnDragExited() { | 1254 void View::OnDragExited() { |
1250 } | 1255 } |
1251 | 1256 |
1252 int View::OnPerformDrop(const ui::DropTargetEvent& event) { | 1257 int View::OnPerformDrop(const ui::DropTargetEvent& event) { |
1253 return ui::DragDropTypes::DRAG_NONE; | 1258 return ui::DragDropTypes::DRAG_NONE; |
1254 } | 1259 } |
1255 | 1260 |
1256 void View::OnDragDone() { | 1261 void View::OnDragDone() { |
| 1262 InkDropDelegate* ink_drop_delegate = GetInkDropDelegate(); |
| 1263 if (ink_drop_delegate) |
| 1264 ink_drop_delegate->OnActionComplete(); |
1257 } | 1265 } |
1258 | 1266 |
1259 // static | 1267 // static |
1260 bool View::ExceededDragThreshold(const gfx::Vector2d& delta) { | 1268 bool View::ExceededDragThreshold(const gfx::Vector2d& delta) { |
1261 return (abs(delta.x()) > GetHorizontalDragThreshold() || | 1269 return (abs(delta.x()) > GetHorizontalDragThreshold() || |
1262 abs(delta.y()) > GetVerticalDragThreshold()); | 1270 abs(delta.y()) > GetVerticalDragThreshold()); |
1263 } | 1271 } |
1264 | 1272 |
1265 // Accessibility---------------------------------------------------------------- | 1273 // Accessibility---------------------------------------------------------------- |
1266 | 1274 |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1512 // Iterate backwards through the children so that a child with a layer | 1520 // Iterate backwards through the children so that a child with a layer |
1513 // which is further to the back is stacked above one which is further to | 1521 // which is further to the back is stacked above one which is further to |
1514 // the front. | 1522 // the front. |
1515 for (Views::reverse_iterator it(children_.rbegin()); | 1523 for (Views::reverse_iterator it(children_.rbegin()); |
1516 it != children_.rend(); ++it) { | 1524 it != children_.rend(); ++it) { |
1517 (*it)->ReorderChildLayers(parent_layer); | 1525 (*it)->ReorderChildLayers(parent_layer); |
1518 } | 1526 } |
1519 } | 1527 } |
1520 } | 1528 } |
1521 | 1529 |
| 1530 // Animations ---------------------------------------------------------------- |
| 1531 |
| 1532 InkDropDelegate* View::GetInkDropDelegate() const { |
| 1533 return nullptr; |
| 1534 } |
| 1535 |
1522 // Input ----------------------------------------------------------------------- | 1536 // Input ----------------------------------------------------------------------- |
1523 | 1537 |
1524 View::DragInfo* View::GetDragInfo() { | 1538 View::DragInfo* View::GetDragInfo() { |
1525 return parent_ ? parent_->GetDragInfo() : NULL; | 1539 return parent_ ? parent_->GetDragInfo() : NULL; |
1526 } | 1540 } |
1527 | 1541 |
1528 // Focus ----------------------------------------------------------------------- | 1542 // Focus ----------------------------------------------------------------------- |
1529 | 1543 |
1530 void View::OnFocus() { | 1544 void View::OnFocus() { |
1531 // TODO(beng): Investigate whether it's possible for us to move this to | 1545 // TODO(beng): Investigate whether it's possible for us to move this to |
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2354 // Message the RootView to do the drag and drop. That way if we're removed | 2368 // Message the RootView to do the drag and drop. That way if we're removed |
2355 // the RootView can detect it and avoid calling us back. | 2369 // the RootView can detect it and avoid calling us back. |
2356 gfx::Point widget_location(event.location()); | 2370 gfx::Point widget_location(event.location()); |
2357 ConvertPointToWidget(this, &widget_location); | 2371 ConvertPointToWidget(this, &widget_location); |
2358 widget->RunShellDrag(this, data, widget_location, drag_operations, source); | 2372 widget->RunShellDrag(this, data, widget_location, drag_operations, source); |
2359 // WARNING: we may have been deleted. | 2373 // WARNING: we may have been deleted. |
2360 return true; | 2374 return true; |
2361 } | 2375 } |
2362 | 2376 |
2363 } // namespace views | 2377 } // namespace views |
OLD | NEW |