Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3033)

Unified Diff: ash/devtools/ui_element.h

Issue 2776543002: Create a unified UIElement interface for Widget, View and Window. (Closed)
Patch Set: . Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/devtools/ash_devtools_unittest.cc ('k') | ash/devtools/ui_element.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..e7b96ed8aca6826c9d827fda8d3ec40761aadfea
--- /dev/null
+++ b/ash/devtools/ui_element.h
@@ -0,0 +1,80 @@
+// 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_DEVTOOLS_UI_ELEMENT_H_
+#define ASH_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();
+ void SetNodeId(int node_id);
+
+ UIElement* GetParent();
+
+ UIElementDelegate* delegate();
+ UIElementType GetType();
+
+ const std::vector<UIElement*>& GetChildren() const;
+ void AddChild(std::vector<UIElement*>::iterator index, UIElement* child);
+ void PushBackChild(UIElement* child);
+ void RemoveChild(std::vector<UIElement*>::iterator index);
+ void RemoveChildFromParent();
+ UIElement* LastChild();
+
+ std::vector<UIElement*>::iterator FindChildIterator(UIElement* child);
+ std::vector<UIElement*>::iterator BeginChildIterator();
+ std::vector<UIElement*>::iterator LastChildIterator();
+ 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!
+
+ 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;
+ // If element exists, return its associated native window and its bounds.
+ // Otherwise, return null and empty bounds.
+ virtual std::pair<aura::Window*, gfx::Rect> GetNodeWindowAndBounds() = 0;
+
+ template <typename BackingT, typename T>
+ static BackingT* GetBackingElement(UIElement* element) {
+ return T::From(element);
+ };
+
+ protected:
+ UIElement(const UIElementType type,
+ UIElementDelegate* ui_element_delegate,
+ UIElement* parent);
+ virtual ~UIElement();
+
+ private:
+ int node_id_;
+ std::vector<UIElement*> children_;
+ const UIElementType type_;
+ UIElement* parent_;
+ UIElementDelegate* ui_element_delegate_;
+
+ DISALLOW_COPY_AND_ASSIGN(UIElement);
+};
+
+} // namespace devtools
+} // namespace ash
+
+#endif // ASH_DEVTOOLS_UI_ELEMENT_H_
« no previous file with comments | « ash/devtools/ash_devtools_unittest.cc ('k') | ash/devtools/ui_element.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698