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 GetNodeId() const; | |
27 void SetNodeId(int node_id); | |
28 | |
29 UIElement* GetParent() const; | |
sadrul
2017/05/05 20:19:34
Since these are simple accessors, these should use
thanhph
2017/05/08 17:03:30
Done, thanks!
| |
30 UIElementDelegate* delegate() const; | |
31 UIElementType GetType() const; | |
32 std::string GetTypeString() const; | |
33 | |
34 const std::vector<UIElement*>& GetChildren() const; | |
35 void AddChild(UIElement* child, UIElement* before = nullptr); | |
sadrul
2017/05/05 20:19:33
Document that |child| is inserted in front of |bef
thanhph
2017/05/08 17:03:30
Done.
| |
36 void RemoveChild(UIElement* child); | |
37 // Move child to position new_index in |children_|. Return previous sibling of | |
38 // the child after reordered if sibling exists or return nullptr otherwise. | |
39 UIElement* ReorderChild(UIElement* child, int new_index); | |
40 | |
41 virtual void Destroy() = 0; | |
42 virtual void GetBounds(gfx::Rect* bounds) const = 0; | |
43 virtual void SetBounds(const gfx::Rect& bounds) = 0; | |
44 virtual void GetVisible(bool* visible) const = 0; | |
45 virtual void SetVisible(bool visible) = 0; | |
46 // If element exists, return its associated native window and its bounds. | |
47 // Otherwise, return null and empty bounds. | |
48 virtual std::pair<aura::Window*, gfx::Rect> GetNodeWindowAndBounds() | |
49 const = 0; | |
50 | |
51 template <typename BackingT, typename T> | |
52 static BackingT* GetBackingElement(UIElement* element) { | |
53 return T::From(element); | |
54 }; | |
55 | |
56 protected: | |
57 UIElement(const UIElementType type, | |
58 UIElementDelegate* ui_element_delegate, | |
59 UIElement* parent); | |
60 virtual ~UIElement(); | |
61 | |
62 private: | |
63 int node_id_; | |
64 std::vector<UIElement*> children_; | |
65 const UIElementType type_; | |
66 UIElement* parent_; | |
67 UIElementDelegate* ui_element_delegate_; | |
68 | |
69 DISALLOW_COPY_AND_ASSIGN(UIElement); | |
70 }; | |
71 | |
72 } // namespace devtools | |
73 } // namespace ash | |
74 | |
75 #endif // ASH_DEVTOOLS_UI_ELEMENT_H_ | |
OLD | NEW |