Index: ash/devtools/ui_element.h |
diff --git a/ash/devtools/ui_element.h b/ash/devtools/ui_element.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f3aa44b8248cd15a2f925e1ccdcb4fb580e063b8 |
--- /dev/null |
+++ b/ash/devtools/ui_element.h |
@@ -0,0 +1,76 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef ASH_COMMON_DEVTOOLS_UI_ELEMENT_H_ |
+#define ASH_COMMON_DEVTOOLS_UI_ELEMENT_H_ |
+ |
+#include <vector> |
+ |
+#include "ash/ash_export.h" |
+#include "base/macros.h" |
+#include "ui/aura/window.h" |
+#include "ui/gfx/geometry/rect.h" |
+#include "ui/views/view.h" |
+ |
+namespace ash { |
+ |
+namespace devtools { |
+ |
+class UIElementDelegate; |
+ |
+// UIElement type. |
+enum UIElementType { WINDOW, WIDGET, VIEW }; |
+ |
+class ASH_EXPORT UIElement { |
+ public: |
+ int GetNodeId() const; |
+ void SetNodeId(int node_id); |
+ |
+ UIElement* GetParent(); |
+ void SetParent(UIElement* parent); |
+ |
+ UIElementDelegate* GetUIElementDelegate(); |
sadrul
2017/05/01 16:22:27
UIElementDelegate* delegate() { return ui_element_
thanhph
2017/05/03 21:58:10
Done.
|
+ 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.
|
+ |
+ UIElementType GetType() const; |
+ 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.
|
+ |
+ 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.
|
+ 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.
|
+ |
+ // Remove ui_element from parent's children and return its next sibling. |
+ std::vector<UIElement*>::iterator RemoveChildFromParent(); |
+ |
+ virtual void Destroy() = 0; |
+ virtual bool GetBounds(gfx::Rect* bounds) = 0; |
+ virtual bool SetBounds(const gfx::Rect& bounds) = 0; |
+ virtual bool GetVisible(bool* visible) = 0; |
+ virtual bool SetVisible(bool visible) = 0; |
+ 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.
|
+ |
+ template <typename BackingT, typename T> |
+ static BackingT* GetBackingElement(UIElement* element) { |
+ return T::From(element); |
+ }; |
+ |
+ protected: |
+ UIElement(UIElementType type, |
+ UIElementDelegate* ui_element_delegate, |
+ UIElement* parent); |
+ virtual ~UIElement(); |
+ |
+ private: |
+ int node_id_; |
+ std::vector<UIElement*> children_; |
+ 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.
|
+ UIElement* parent_; |
+ UIElementDelegate* ui_element_delegate_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(UIElement); |
+}; |
+ |
+} // namespace devtools |
+} // namespace ash |
+ |
+#endif // ASH_COMMON_DEVTOOLS_UI_ELEMENT_H_ |