Upstream version 11.39.266.0
[platform/framework/web/crosswalk.git] / src / ui / v2 / public / view_observer.h
1 // Copyright (c) 2013 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.
4
5 #ifndef UI_V2_PUBLIC_VIEW_OBSERVER_H_
6 #define UI_V2_PUBLIC_VIEW_OBSERVER_H_
7
8 #include "ui/v2/public/v2_export.h"
9
10 namespace gfx {
11 class Rect;
12 }
13
14 namespace v2 {
15
16 class View;
17
18 // Observe View disposition changes. -ing methods are called before the change
19 // is committed, -ed methods are called after.
20 class V2_EXPORT ViewObserver {
21  public:
22   // Whether a notification is being sent before or after some property has
23   // changed.
24   enum DispositionChangePhase {
25     DISPOSITION_CHANGING,
26     DISPOSITION_CHANGED
27   };
28
29   // Tree.
30   struct TreeChangeParams {
31     TreeChangeParams();
32     View* target;
33     View* old_parent;
34     View* new_parent;
35     View* receiver;
36     DispositionChangePhase phase;
37   };
38
39   // Called when a node is added or removed. Notifications are sent to the
40   // following hierarchies in this order:
41   // 1. |target|.
42   // 2. |target|'s child hierarchy.
43   // 3. |target|'s parent hierarchy in its |old_parent|
44   //        (only for Changing notifications).
45   // 3. |target|'s parent hierarchy in its |new_parent|.
46   //        (only for Changed notifications).
47   // This sequence is performed via the OnTreeChange notification below before
48   // and after the change is committed.
49   virtual void OnViewTreeChange(const TreeChangeParams& params) {}
50
51   // Disposition.
52   virtual void OnViewDestroy(View* view, DispositionChangePhase phase) {}
53   virtual void OnViewBoundsChanged(View* view,
54                                    const gfx::Rect& old_bounds,
55                                    const gfx::Rect& new_bounds) {}
56   virtual void OnViewVisibilityChange(View* view,
57                                       DispositionChangePhase phase) {}
58
59  protected:
60   virtual ~ViewObserver() {}
61 };
62
63 }  // namespace v2
64
65 #endif  // UI_V2_PUBLIC_VIEW_OBSERVER_H_