OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 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 ASH_DEVTOOLS_UI_ELEMENT_H_ | |
6 #define ASH_DEVTOOLS_UI_ELEMENT_H_ | |
7 | |
8 #include <vector> | |
9 | |
10 #include "ash/ash_export.h" | |
11 #include "base/macros.h" | |
12 #include "ui/aura/window.h" | |
13 #include "ui/gfx/geometry/rect.h" | |
14 #include "ui/views/view.h" | |
15 | |
16 namespace ash { | |
17 namespace devtools { | |
18 | |
19 class UIElementDelegate; | |
20 | |
21 // UIElement type. | |
22 enum UIElementType { WINDOW, WIDGET, VIEW }; | |
23 | |
24 class ASH_EXPORT UIElement { | |
25 public: | |
26 int node_id() const { return node_id_; }; | |
27 std::string GetTypeName() const; | |
28 UIElement* parent() const { return parent_; }; | |
29 UIElementDelegate* delegate() const { return delegate_; }; | |
30 UIElementType type() const { return type_; }; | |
31 const std::vector<UIElement*>& children() const { return children_; }; | |
32 | |
33 // |child| is inserted in front of |before|. If |before| is null, it | |
34 // is inserted at the end. | |
sadrul
2017/05/17 21:54:13
Add a comment that the parent takes ownership of t
thanhph
2017/05/18 14:28:15
Done.
| |
35 void AddChild(UIElement* child, UIElement* before = nullptr); | |
36 | |
37 // Remove |child| out of vector |children_|. | |
sadrul
2017/05/17 21:54:13
Make a note that |child| is not destroyed when rem
thanhph
2017/05/18 14:28:15
Done.
| |
38 void RemoveChild(UIElement* child); | |
39 | |
40 // Move |child| to position new_index in |children_|. | |
41 void ReorderChild(UIElement* child, int new_index); | |
42 | |
43 virtual void Destroy() = 0; | |
sadrul
2017/05/17 21:54:13
All the overrides just do 'delete this'. Can the c
thanhph
2017/05/18 14:28:16
Yes, done. I move ~UIElement() back to public meth
| |
44 virtual void GetBounds(gfx::Rect* bounds) const = 0; | |
45 virtual void SetBounds(const gfx::Rect& bounds) = 0; | |
46 virtual void GetVisible(bool* visible) const = 0; | |
47 virtual void SetVisible(bool visible) = 0; | |
48 | |
49 // If element exists, return its associated native window and its bounds. | |
50 // Otherwise, return null and empty bounds. | |
51 virtual std::pair<aura::Window*, gfx::Rect> GetNodeWindowAndBounds() | |
52 const = 0; | |
53 | |
54 template <typename BackingT, typename T> | |
55 static BackingT* GetBackingElement(UIElement* element) { | |
56 return T::From(element); | |
57 }; | |
58 | |
59 protected: | |
60 UIElement(const UIElementType type, | |
61 UIElementDelegate* delegate, | |
62 UIElement* parent); | |
63 virtual ~UIElement(); | |
64 | |
65 private: | |
66 const int node_id_; | |
67 const UIElementType type_; | |
68 std::vector<UIElement*> children_; | |
69 UIElement* parent_; | |
70 UIElementDelegate* delegate_; | |
71 | |
72 DISALLOW_COPY_AND_ASSIGN(UIElement); | |
73 }; | |
74 | |
75 } // namespace devtools | |
76 } // namespace ash | |
77 | |
78 #endif // ASH_DEVTOOLS_UI_ELEMENT_H_ | |
OLD | NEW |