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

Side by Side Diff: ash/devtools/ui_element.h

Issue 2776543002: Create a unified UIElement interface for Widget, View and Window. (Closed)
Patch Set: nits Created 3 years, 7 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 unified diff | Download patch
OLDNEW
(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 int node_id() const { return node_id_; };
27 void SetNodeId(int node_id);
sadrul 2017/05/09 04:58:06 SetNodeId() should no longer be needed, right?
thanhph 2017/05/09 20:52:46 Done.
28
29 std::string GetTypeName() const;
30
31 UIElement* parent() const { return parent_; };
32 UIElementDelegate* delegate() const { return delegate_; };
33 UIElementType type() const { return type_; };
34 const std::vector<UIElement*>& children() const { return children_; };
35
36 // |child| is inserted in front of |before|. If |before| is null, it
37 // is inserted at the end.
38 void AddChild(UIElement* child, UIElement* before = nullptr);
39
40 // Remove |child| out of vector |children_|.
41 void RemoveChild(UIElement* child);
42
43 // Move |child| to position new_index in |children_|.
44 void ReorderChild(UIElement* child, int new_index);
45
46 virtual void Destroy() = 0;
47 virtual void GetBounds(gfx::Rect* bounds) const = 0;
48 virtual void SetBounds(const gfx::Rect& bounds) = 0;
49 virtual void GetVisible(bool* visible) const = 0;
50 virtual void SetVisible(bool visible) = 0;
51
52 // If element exists, return its associated native window and its bounds.
53 // Otherwise, return null and empty bounds.
54 virtual std::pair<aura::Window*, gfx::Rect> GetNodeWindowAndBounds()
55 const = 0;
56
57 template <typename BackingT, typename T>
58 static BackingT* GetBackingElement(UIElement* element) {
59 return T::From(element);
60 };
61
62 protected:
63 UIElement(const UIElementType type,
64 UIElementDelegate* delegate,
65 UIElement* parent);
66 virtual ~UIElement();
67
68 private:
69 int node_id_;
sadrul 2017/05/09 04:58:06 const int node_id_;
thanhph 2017/05/09 20:52:46 Done.
70 std::vector<UIElement*> children_;
71 const UIElementType type_;
72 UIElement* parent_;
73 UIElementDelegate* delegate_;
74
75 DISALLOW_COPY_AND_ASSIGN(UIElement);
76 };
77
78 } // namespace devtools
79 } // namespace ash
80
81 #endif // ASH_DEVTOOLS_UI_ELEMENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698