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 | |
18 namespace devtools { | |
19 | |
20 class UIElementDelegate; | |
21 | |
22 // UIElement type. | |
23 enum UIElementType { WINDOW, WIDGET, VIEW }; | |
24 | |
25 class ASH_EXPORT UIElement { | |
26 public: | |
27 int GetNodeId(); | |
28 void SetNodeId(int node_id); | |
29 | |
30 UIElement* GetParent(); | |
31 | |
32 UIElementDelegate* delegate(); | |
33 UIElementType GetType(); | |
34 | |
35 const std::vector<UIElement*>& GetChildren() const; | |
36 void AddChild(std::vector<UIElement*>::iterator index, UIElement* child); | |
37 void PushBackChild(UIElement* child); | |
38 void RemoveChild(std::vector<UIElement*>::iterator index); | |
39 void RemoveChildFromParent(); | |
40 UIElement* LastChild(); | |
41 | |
42 std::vector<UIElement*>::iterator FindChildIterator(UIElement* child); | |
43 std::vector<UIElement*>::iterator BeginChildIterator(); | |
44 std::vector<UIElement*>::iterator LastChildIterator(); | |
45 std::vector<UIElement*>::iterator ChildIndexFromParent(); | |
sadrul
2017/05/03 03:02:06
These ... seem unnecessarily complicated.
The tre
thanhph
2017/05/03 21:58:11
Removed, thanks!
| |
46 | |
47 virtual void Destroy() = 0; | |
48 virtual bool GetBounds(gfx::Rect* bounds) = 0; | |
49 virtual bool SetBounds(const gfx::Rect& bounds) = 0; | |
50 virtual bool GetVisible(bool* visible) = 0; | |
51 virtual bool SetVisible(bool visible) = 0; | |
52 // If element exists, return its associated native window and its bounds. | |
53 // Otherwise, return null and empty bounds. | |
54 virtual std::pair<aura::Window*, gfx::Rect> GetNodeWindowAndBounds() = 0; | |
55 | |
56 template <typename BackingT, typename T> | |
57 static BackingT* GetBackingElement(UIElement* element) { | |
58 return T::From(element); | |
59 }; | |
60 | |
61 protected: | |
62 UIElement(const UIElementType type, | |
63 UIElementDelegate* ui_element_delegate, | |
64 UIElement* parent); | |
65 virtual ~UIElement(); | |
66 | |
67 private: | |
68 int node_id_; | |
69 std::vector<UIElement*> children_; | |
70 const UIElementType type_; | |
71 UIElement* parent_; | |
72 UIElementDelegate* ui_element_delegate_; | |
73 | |
74 DISALLOW_COPY_AND_ASSIGN(UIElement); | |
75 }; | |
76 | |
77 } // namespace devtools | |
78 } // namespace ash | |
79 | |
80 #endif // ASH_DEVTOOLS_UI_ELEMENT_H_ | |
OLD | NEW |