| 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 namespace devtools { |  | 
| 18 |  | 
| 19 class UIElementDelegate; |  | 
| 20 |  | 
| 21 // UIElement type. |  | 
| 22 enum UIElementType { WINDOW, WIDGET, VIEW }; |  | 
| 23 |  | 
| 24 class ASH_EXPORT UIElement { |  | 
| 25  public: |  | 
| 26   virtual ~UIElement(); |  | 
| 27   int node_id() const { return node_id_; }; |  | 
| 28   std::string GetTypeName() const; |  | 
| 29   UIElement* parent() const { return parent_; }; |  | 
| 30   UIElementDelegate* delegate() const { return delegate_; }; |  | 
| 31   UIElementType type() const { return type_; }; |  | 
| 32   const std::vector<UIElement*>& children() const { return children_; }; |  | 
| 33 |  | 
| 34   // |child| is inserted in front of |before|. If |before| is null, it |  | 
| 35   // is inserted at the end. Parent takes ownership of the added child. |  | 
| 36   void AddChild(UIElement* child, UIElement* before = nullptr); |  | 
| 37 |  | 
| 38   // Remove |child| out of vector |children_| but |child| is not destroyed. |  | 
| 39   // The caller is responsible for destroying |child|. |  | 
| 40   void RemoveChild(UIElement* child); |  | 
| 41 |  | 
| 42   // Move |child| to position new_index in |children_|. |  | 
| 43   void ReorderChild(UIElement* child, int new_index); |  | 
| 44 |  | 
| 45   virtual void GetBounds(gfx::Rect* bounds) const = 0; |  | 
| 46   virtual void SetBounds(const gfx::Rect& bounds) = 0; |  | 
| 47   virtual void GetVisible(bool* visible) const = 0; |  | 
| 48   virtual void SetVisible(bool visible) = 0; |  | 
| 49 |  | 
| 50   // If element exists, return its associated native window and its bounds. |  | 
| 51   // Otherwise, return null and empty bounds. |  | 
| 52   virtual std::pair<aura::Window*, gfx::Rect> GetNodeWindowAndBounds() |  | 
| 53       const = 0; |  | 
| 54 |  | 
| 55   template <typename BackingT, typename T> |  | 
| 56   static BackingT* GetBackingElement(UIElement* element) { |  | 
| 57     return T::From(element); |  | 
| 58   }; |  | 
| 59 |  | 
| 60  protected: |  | 
| 61   UIElement(const UIElementType type, |  | 
| 62             UIElementDelegate* delegate, |  | 
| 63             UIElement* parent); |  | 
| 64 |  | 
| 65  private: |  | 
| 66   const int node_id_; |  | 
| 67   const UIElementType type_; |  | 
| 68   std::vector<UIElement*> children_; |  | 
| 69   UIElement* parent_; |  | 
| 70   UIElementDelegate* delegate_; |  | 
| 71 |  | 
| 72   DISALLOW_COPY_AND_ASSIGN(UIElement); |  | 
| 73 }; |  | 
| 74 |  | 
| 75 }  // namespace devtools |  | 
| 76 }  // namespace ash |  | 
| 77 |  | 
| 78 #endif  // ASH_DEVTOOLS_UI_ELEMENT_H_ |  | 
| OLD | NEW | 
|---|