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_COMMON_DEVTOOLS_UI_ELEMENT_H_ | |
6 #define ASH_COMMON_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() const; | |
28 void SetNodeId(int node_id); | |
29 | |
30 UIElement* GetParent(); | |
31 void SetParent(UIElement* parent); | |
32 | |
33 UIElementDelegate* GetUIElementDelegate(); | |
sadrul
2017/05/01 16:22:27
UIElementDelegate* delegate() { return ui_element_
thanhph
2017/05/03 21:58:10
Done.
| |
34 void SetUIElementDelegate(UIElementDelegate* ui_element_delegate); | |
sadrul
2017/05/01 16:22:26
This should no longer be needed?
thanhph
2017/05/03 21:58:10
Done.
| |
35 | |
36 UIElementType GetType() const; | |
37 void SetType(UIElementType type); | |
sadrul
2017/05/01 16:22:27
This should no longer be needed.
thanhph
2017/05/03 21:58:10
Done.
| |
38 | |
39 std::vector<UIElement*>& GetChildren(); | |
sadrul
2017/05/01 16:22:27
this should return a const-ref. (i.e. the callers
thanhph
2017/05/03 21:58:10
Done.
| |
40 void SetChildren(std::vector<UIElement*>& children); | |
sadrul
2017/05/01 16:22:27
SetChildren() seems a bit odd ... Can this be AddC
thanhph
2017/05/03 21:58:10
Done.
| |
41 | |
42 // Remove ui_element from parent's children and return its next sibling. | |
43 std::vector<UIElement*>::iterator RemoveChildFromParent(); | |
44 | |
45 virtual void Destroy() = 0; | |
46 virtual bool GetBounds(gfx::Rect* bounds) = 0; | |
47 virtual bool SetBounds(const gfx::Rect& bounds) = 0; | |
48 virtual bool GetVisible(bool* visible) = 0; | |
49 virtual bool SetVisible(bool visible) = 0; | |
50 virtual std::pair<aura::Window*, gfx::Rect> GetNodeWindowAndBounds() = 0; | |
sadrul
2017/05/01 16:22:26
Document what the return value should be (e.g. wha
thanhph
2017/05/03 21:58:10
Done.
| |
51 | |
52 template <typename BackingT, typename T> | |
53 static BackingT* GetBackingElement(UIElement* element) { | |
54 return T::From(element); | |
55 }; | |
56 | |
57 protected: | |
58 UIElement(UIElementType type, | |
59 UIElementDelegate* ui_element_delegate, | |
60 UIElement* parent); | |
61 virtual ~UIElement(); | |
62 | |
63 private: | |
64 int node_id_; | |
65 std::vector<UIElement*> children_; | |
66 UIElementType type_; | |
sadrul
2017/05/01 16:22:27
Make this a const, so that it never changes after
thanhph
2017/05/03 21:58:10
Done.
| |
67 UIElement* parent_; | |
68 UIElementDelegate* ui_element_delegate_; | |
69 | |
70 DISALLOW_COPY_AND_ASSIGN(UIElement); | |
71 }; | |
72 | |
73 } // namespace devtools | |
74 } // namespace ash | |
75 | |
76 #endif // ASH_COMMON_DEVTOOLS_UI_ELEMENT_H_ | |
OLD | NEW |