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

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

Issue 1411833006: Refactoring to make adding ink drop animations easier (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Attempt to refactor ink drop animations (moving more stuff into InkDropDelegate) Created 5 years, 1 month 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 #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
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
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->Layout();
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 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 } 1013 }
1009 1014
1010 void View::OnScrollEvent(ui::ScrollEvent* event) { 1015 void View::OnScrollEvent(ui::ScrollEvent* event) {
1011 } 1016 }
1012 1017
1013 void View::OnTouchEvent(ui::TouchEvent* event) { 1018 void View::OnTouchEvent(ui::TouchEvent* event) {
1014 NOTREACHED() << "Views should not receive touch events."; 1019 NOTREACHED() << "Views should not receive touch events.";
1015 } 1020 }
1016 1021
1017 void View::OnGestureEvent(ui::GestureEvent* event) { 1022 void View::OnGestureEvent(ui::GestureEvent* event) {
1023 InkDropDelegate* ink_drop_delegate = GetInkDropDelegate();
1024 if (ink_drop_delegate)
1025 ink_drop_delegate->OnGestureEvent(*event);
1018 } 1026 }
1019 1027
1020 const ui::InputMethod* View::GetInputMethod() const { 1028 const ui::InputMethod* View::GetInputMethod() const {
1021 Widget* widget = const_cast<Widget*>(GetWidget()); 1029 Widget* widget = const_cast<Widget*>(GetWidget());
1022 return widget ? const_cast<const ui::InputMethod*>(widget->GetInputMethod()) 1030 return widget ? const_cast<const ui::InputMethod*>(widget->GetInputMethod())
1023 : nullptr; 1031 : nullptr;
1024 } 1032 }
1025 1033
1026 scoped_ptr<ViewTargeter> 1034 scoped_ptr<ViewTargeter>
1027 View::SetEventTargeter(scoped_ptr<ViewTargeter> targeter) { 1035 View::SetEventTargeter(scoped_ptr<ViewTargeter> targeter) {
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 } 1255 }
1248 1256
1249 void View::OnDragExited() { 1257 void View::OnDragExited() {
1250 } 1258 }
1251 1259
1252 int View::OnPerformDrop(const ui::DropTargetEvent& event) { 1260 int View::OnPerformDrop(const ui::DropTargetEvent& event) {
1253 return ui::DragDropTypes::DRAG_NONE; 1261 return ui::DragDropTypes::DRAG_NONE;
1254 } 1262 }
1255 1263
1256 void View::OnDragDone() { 1264 void View::OnDragDone() {
1265 InkDropDelegate* ink_drop_delegate = GetInkDropDelegate();
1266 if (ink_drop_delegate)
1267 ink_drop_delegate->OnActionComplete();
1257 } 1268 }
1258 1269
1259 // static 1270 // static
1260 bool View::ExceededDragThreshold(const gfx::Vector2d& delta) { 1271 bool View::ExceededDragThreshold(const gfx::Vector2d& delta) {
1261 return (abs(delta.x()) > GetHorizontalDragThreshold() || 1272 return (abs(delta.x()) > GetHorizontalDragThreshold() ||
1262 abs(delta.y()) > GetVerticalDragThreshold()); 1273 abs(delta.y()) > GetVerticalDragThreshold());
1263 } 1274 }
1264 1275
1265 // Accessibility---------------------------------------------------------------- 1276 // Accessibility----------------------------------------------------------------
1266 1277
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
1512 // Iterate backwards through the children so that a child with a layer 1523 // 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 1524 // which is further to the back is stacked above one which is further to
1514 // the front. 1525 // the front.
1515 for (Views::reverse_iterator it(children_.rbegin()); 1526 for (Views::reverse_iterator it(children_.rbegin());
1516 it != children_.rend(); ++it) { 1527 it != children_.rend(); ++it) {
1517 (*it)->ReorderChildLayers(parent_layer); 1528 (*it)->ReorderChildLayers(parent_layer);
1518 } 1529 }
1519 } 1530 }
1520 } 1531 }
1521 1532
1533 // Animations ----------------------------------------------------------------
1534
1535 InkDropDelegate* View::GetInkDropDelegate() const {
1536 return nullptr;
1537 }
1538
1522 // Input ----------------------------------------------------------------------- 1539 // Input -----------------------------------------------------------------------
1523 1540
1524 View::DragInfo* View::GetDragInfo() { 1541 View::DragInfo* View::GetDragInfo() {
1525 return parent_ ? parent_->GetDragInfo() : NULL; 1542 return parent_ ? parent_->GetDragInfo() : NULL;
1526 } 1543 }
1527 1544
1528 // Focus ----------------------------------------------------------------------- 1545 // Focus -----------------------------------------------------------------------
1529 1546
1530 void View::OnFocus() { 1547 void View::OnFocus() {
1531 // TODO(beng): Investigate whether it's possible for us to move this to 1548 // 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
2354 // Message the RootView to do the drag and drop. That way if we're removed 2371 // 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. 2372 // the RootView can detect it and avoid calling us back.
2356 gfx::Point widget_location(event.location()); 2373 gfx::Point widget_location(event.location());
2357 ConvertPointToWidget(this, &widget_location); 2374 ConvertPointToWidget(this, &widget_location);
2358 widget->RunShellDrag(this, data, widget_location, drag_operations, source); 2375 widget->RunShellDrag(this, data, widget_location, drag_operations, source);
2359 // WARNING: we may have been deleted. 2376 // WARNING: we may have been deleted.
2360 return true; 2377 return true;
2361 } 2378 }
2362 2379
2363 } // namespace views 2380 } // namespace views
OLDNEW
« ui/views/animation/ink_drop_host.h ('K') | « ui/views/view.h ('k') | ui/views/views.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698