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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_MUS_PUBLIC_CPP_VIEW_OBSERVER_H_
6 #define COMPONENTS_MUS_PUBLIC_CPP_VIEW_OBSERVER_H_
10 #include "components/mus/public/cpp/view.h"
11 #include "ui/mojo/events/input_events.mojom.h"
17 // A note on -ing and -ed suffixes:
19 // -ing methods are called before changes are applied to the local view model.
20 // -ed methods are called after changes are applied to the local view model.
22 // If the change originated from another connection to the view manager, it's
23 // possible that the change has already been applied to the service-side model
24 // prior to being called, so for example in the case of OnViewDestroying(), it's
25 // possible the view has already been destroyed on the service side.
29 struct TreeChangeParams
{
37 virtual void OnTreeChanging(const TreeChangeParams
& params
) {}
38 virtual void OnTreeChanged(const TreeChangeParams
& params
) {}
40 virtual void OnViewReordering(View
* view
,
42 OrderDirection direction
) {}
43 virtual void OnViewReordered(View
* view
,
45 OrderDirection direction
) {}
47 virtual void OnViewDestroying(View
* view
) {}
48 virtual void OnViewDestroyed(View
* view
) {}
50 virtual void OnViewBoundsChanging(View
* view
,
51 const Rect
& old_bounds
,
52 const Rect
& new_bounds
) {}
53 virtual void OnViewBoundsChanged(View
* view
,
54 const Rect
& old_bounds
,
55 const Rect
& new_bounds
) {}
57 virtual void OnViewViewportMetricsChanged(
59 const ViewportMetrics
& old_metrics
,
60 const ViewportMetrics
& new_metrics
) {}
62 virtual void OnViewFocusChanged(View
* gained_focus
, View
* lost_focus
) {}
64 virtual void OnViewInputEvent(View
* view
, const EventPtr
& event
) {}
66 virtual void OnViewVisibilityChanging(View
* view
) {}
67 virtual void OnViewVisibilityChanged(View
* view
) {}
69 // Invoked when this View's shared properties have changed. This can either
70 // be caused by SetSharedProperty() being called locally, or by us receiving
71 // a mojo message that this property has changed. If this property has been
72 // added, |old_data| is null. If this property was removed, |new_data| is
74 virtual void OnViewSharedPropertyChanged(
76 const std::string
& name
,
77 const std::vector
<uint8_t>* old_data
,
78 const std::vector
<uint8_t>* new_data
) {}
80 // Invoked when SetProperty() or ClearProperty() is called on the window.
81 // |key| is either a WindowProperty<T>* (SetProperty, ClearProperty). Either
82 // way, it can simply be compared for equality with the property
83 // constant. |old| is the old property value, which must be cast to the
84 // appropriate type before use.
85 virtual void OnViewLocalPropertyChanged(View
* view
,
89 virtual void OnViewEmbeddedAppDisconnected(View
* view
) {}
91 // Sent when the drawn state changes. This is only sent for the root nodes
93 virtual void OnViewDrawnChanging(View
* view
) {}
94 virtual void OnViewDrawnChanged(View
* view
) {}
97 virtual ~ViewObserver() {}
102 #endif // COMPONENTS_MUS_PUBLIC_CPP_VIEW_OBSERVER_H_