Chromium Code Reviews| 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..a049a31525c439e94a9448cc88d1d304d8bc2510 |
| --- /dev/null |
| +++ b/ash/devtools/ui_element.h |
| @@ -0,0 +1,75 @@ |
| +// 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() const; |
| + void SetNodeId(int node_id); |
| + |
| + 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!
|
| + UIElementDelegate* delegate() const; |
| + UIElementType GetType() const; |
| + std::string GetTypeString() const; |
| + |
| + const std::vector<UIElement*>& GetChildren() const; |
| + 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.
|
| + void RemoveChild(UIElement* child); |
| + // Move child to position new_index in |children_|. Return previous sibling of |
| + // the child after reordered if sibling exists or return nullptr otherwise. |
| + UIElement* ReorderChild(UIElement* child, int new_index); |
| + |
| + virtual void Destroy() = 0; |
| + virtual void GetBounds(gfx::Rect* bounds) const = 0; |
| + virtual void SetBounds(const gfx::Rect& bounds) = 0; |
| + virtual void GetVisible(bool* visible) const = 0; |
| + virtual void 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() |
| + const = 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_ |