| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_NODE_OBSERVER_H_ | 5 #ifndef MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_OBSERVER_H_ |
| 6 #define MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_NODE_OBSERVER_H_ | 6 #define MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_OBSERVER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 | 11 |
| 12 #include "mojo/services/public/cpp/view_manager/node.h" | 12 #include "mojo/services/public/cpp/view_manager/view.h" |
| 13 #include "mojo/services/public/interfaces/input_events/input_events.mojom.h" | 13 #include "mojo/services/public/interfaces/input_events/input_events.mojom.h" |
| 14 | 14 |
| 15 namespace gfx { | 15 namespace gfx { |
| 16 class Rect; | 16 class Rect; |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace mojo { | 19 namespace mojo { |
| 20 | 20 |
| 21 class Node; | |
| 22 class View; | 21 class View; |
| 23 | 22 |
| 24 // A note on -ing and -ed suffixes: | 23 // A note on -ing and -ed suffixes: |
| 25 // | 24 // |
| 26 // -ing methods are called before changes are applied to the local node model. | 25 // -ing methods are called before changes are applied to the local view model. |
| 27 // -ed methods are called after changes are applied to the local node model. | 26 // -ed methods are called after changes are applied to the local view model. |
| 28 // | 27 // |
| 29 // If the change originated from another connection to the view manager, it's | 28 // If the change originated from another connection to the view manager, it's |
| 30 // possible that the change has already been applied to the service-side model | 29 // possible that the change has already been applied to the service-side model |
| 31 // prior to being called, so for example in the case of OnNodeDestroying(), it's | 30 // prior to being called, so for example in the case of OnViewDestroying(), it's |
| 32 // possible the node has already been destroyed on the service side. | 31 // possible the view has already been destroyed on the service side. |
| 33 | 32 |
| 34 class NodeObserver { | 33 class ViewObserver { |
| 35 public: | 34 public: |
| 36 struct TreeChangeParams { | 35 struct TreeChangeParams { |
| 37 TreeChangeParams(); | 36 TreeChangeParams(); |
| 38 Node* target; | 37 View* target; |
| 39 Node* old_parent; | 38 View* old_parent; |
| 40 Node* new_parent; | 39 View* new_parent; |
| 41 Node* receiver; | 40 View* receiver; |
| 42 }; | 41 }; |
| 43 | 42 |
| 44 virtual void OnTreeChanging(const TreeChangeParams& params) {} | 43 virtual void OnTreeChanging(const TreeChangeParams& params) {} |
| 45 virtual void OnTreeChanged(const TreeChangeParams& params) {} | 44 virtual void OnTreeChanged(const TreeChangeParams& params) {} |
| 46 | 45 |
| 47 virtual void OnNodeReordering(Node* node, | 46 virtual void OnViewReordering(View* view, |
| 48 Node* relative_node, | 47 View* relative_view, |
| 49 OrderDirection direction) {} | 48 OrderDirection direction) {} |
| 50 virtual void OnNodeReordered(Node* node, | 49 virtual void OnViewReordered(View* view, |
| 51 Node* relative_node, | 50 View* relative_view, |
| 52 OrderDirection direction) {} | 51 OrderDirection direction) {} |
| 53 | 52 |
| 54 virtual void OnNodeDestroying(Node* node) {} | 53 virtual void OnViewDestroying(View* view) {} |
| 55 virtual void OnNodeDestroyed(Node* node) {} | 54 virtual void OnViewDestroyed(View* view) {} |
| 56 | 55 |
| 57 virtual void OnNodeBoundsChanging(Node* node, | 56 virtual void OnViewBoundsChanging(View* view, |
| 58 const gfx::Rect& old_bounds, | 57 const gfx::Rect& old_bounds, |
| 59 const gfx::Rect& new_bounds) {} | 58 const gfx::Rect& new_bounds) {} |
| 60 virtual void OnNodeBoundsChanged(Node* node, | 59 virtual void OnViewBoundsChanged(View* view, |
| 61 const gfx::Rect& old_bounds, | 60 const gfx::Rect& old_bounds, |
| 62 const gfx::Rect& new_bounds) {} | 61 const gfx::Rect& new_bounds) {} |
| 63 | 62 |
| 64 virtual void OnNodeFocusChanged(Node* gained_focus, Node* lost_focus) {} | 63 virtual void OnViewFocusChanged(View* gained_focus, View* lost_focus) {} |
| 65 | 64 |
| 66 virtual void OnNodeInputEvent(Node* node, const EventPtr& event) {} | 65 virtual void OnViewInputEvent(View* view, const EventPtr& event) {} |
| 67 | 66 |
| 68 protected: | 67 protected: |
| 69 virtual ~NodeObserver() {} | 68 virtual ~ViewObserver() {} |
| 70 }; | 69 }; |
| 71 | 70 |
| 72 } // namespace mojo | 71 } // namespace mojo |
| 73 | 72 |
| 74 #endif // MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_NODE_OBSERVER_H_ | 73 #endif // MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_OBSERVER_H_ |
| OLD | NEW |