File: view_observer.h

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (104 lines) | stat: -rw-r--r-- 4,131 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_VIEWS_VIEW_OBSERVER_H_
#define UI_VIEWS_VIEW_OBSERVER_H_

#include <stdint.h>

#include "ui/views/views_export.h"

namespace views {

class View;
struct ViewHierarchyChangedDetails;

// ViewObserver is used to observe changes to a View. The first argument to all
// ViewObserver functions is the View the observer was added to.
class VIEWS_EXPORT ViewObserver {
 public:
  // Called when |child| is added as a child to |observed_view|.
  virtual void OnChildViewAdded(View* observed_view, View* child) {}

  // Called when |child| is removed as a child of |observed_view|.
  virtual void OnChildViewRemoved(View* observed_view, View* child) {}

  // Called when |observed_view|, an ancestor, or its Widget has its visibility
  // changed. |starting_view| is who |View::SetVisible()| was called on (or null
  // if the Widget visibility changed).
  virtual void OnViewVisibilityChanged(View* observed_view,
                                       View* starting_view) {}

  // Called from View::PreferredSizeChanged().
  virtual void OnViewPreferredSizeChanged(View* observed_view) {}

  // Called when the bounds of |observed_view| change.
  virtual void OnViewBoundsChanged(View* observed_view) {}

  // Called when the view layer's bounds are set, whether or not the bounds have
  // changed.
  virtual void OnViewLayerBoundsSet(View* observed_view) {}

  // Called when the `observed_view`'s layer transform changes.
  // TODO(crbug.com/40763515): This is temporarily added to support a migration.
  // Do not use for new call sites, we should instead figure out how to
  // migrate this method (and possibly others) into callbacks.
  virtual void OnViewLayerTransformed(View* observed_view) {}

  // Called when `observed_view`'s layer clip rect changes.
  virtual void OnViewLayerClipRectChanged(View* observed_view) {}

  // Called when View::ViewHierarchyChanged() is called.
  virtual void OnViewHierarchyChanged(
      View* observed_view,
      const ViewHierarchyChangedDetails& details) {}

  // Called when View::AddedToWidget() is called.
  virtual void OnViewAddedToWidget(View* observed_view) {}

  // Called when View::RemovedFromWidget() is called.
  virtual void OnViewRemovedFromWidget(View* observed_view) {}

  // Called when a child is reordered among its siblings, specifically
  // View::ReorderChildView() is called on |observed_view|.
  virtual void OnChildViewReordered(View* observed_view, View* child) {}

  // Called when the active UI theme or NativeTheme has changed for
  // |observed_view|.
  virtual void OnViewThemeChanged(View* observed_view) {}

  // Called from ~View.
  virtual void OnViewIsDeleting(View* observed_view) {}

  // Called from the very beginning of ~View (before child views are deleted) to
  // indicate that destruction is starting at the hierarchy owned by
  // `observed_view`.
  virtual void OnViewHierarchyWillBeDeleted(View* observed_view) {}

  // Called immediately after |observed_view| has gained focus.
  virtual void OnViewFocused(View* observed_view) {}

  // Called immediately after |observed_view| has lost focus.
  virtual void OnViewBlurred(View* observed_view) {}

  // Called immediately after the property associated with the specified
  // |key| has been changed for the |observed_view|. The |old_value| must be
  // cast to the appropriate type before use, see |ui::ClassPropertyCaster|.
  virtual void OnViewPropertyChanged(View* observed_view,
                                     const void* key,
                                     int64_t old_value) {}

  // Called when the observed view's layout is invalidated.
  // This is useful to invalidate other views in response to the observed
  // view's layout invalidation, for example, when the view to be invalidated
  // has style dependency on the observed view.
  virtual void OnViewLayoutInvalidated(View* observed_view) {}

 protected:
  virtual ~ViewObserver() = default;
};

}  // namespace views

#endif  // UI_VIEWS_VIEW_OBSERVER_H_