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

Side by Side 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 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_COMMON_DEVTOOLS_UI_ELEMENT_H_
6 #define ASH_COMMON_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
18 namespace devtools {
19
20 class UIElementDelegate;
21
22 // UIElement type.
23 enum UIElementType { WINDOW, WIDGET, VIEW };
24
25 class ASH_EXPORT UIElement {
26 public:
27 int GetNodeId() const;
28 void SetNodeId(int node_id);
29
30 UIElement* GetParent();
31 void SetParent(UIElement* parent);
32
33 UIElementDelegate* GetUIElementDelegate();
34 void SetUIElementDelegate(UIElementDelegate* ui_element_delegate);
35
36 UIElementType GetType() const;
37 void SetType(UIElementType type);
38
39 std::vector<UIElement*>& GetChildren();
40 void SetChildren(std::vector<UIElement*>& children);
41
42 std::vector<UIElement*>::iterator RemoveChild();
43
44 virtual void Destroy() = 0;
45 virtual bool GetBounds(gfx::Rect* bounds) = 0;
46 virtual bool SetBounds(const gfx::Rect& bounds) = 0;
47 virtual bool GetVisible(bool* visible) = 0;
48 virtual bool SetVisible(bool visible) = 0;
49 virtual std::pair<aura::Window*, gfx::Rect> GetNodeWindowAndBounds() = 0;
50
51 template <typename BackingT, typename T>
52 static BackingT* GetBackingElement(UIElement* element) {
53 return T::From(element);
54 };
55
56 protected:
57 UIElement(UIElementType type,
58 UIElementDelegate* ui_element_delegate,
59 UIElement* parent);
60 virtual ~UIElement();
61
62 private:
63 int node_id_;
64 std::vector<UIElement*> children_;
65 UIElementType type_;
66 UIElement* parent_;
67 UIElementDelegate* ui_element_delegate_;
68
69 DISALLOW_COPY_AND_ASSIGN(UIElement);
70 };
71
72 } // namespace devtools
73 } // namespace ash
74
75 #endif // ASH_COMMON_DEVTOOLS_UI_ELEMENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698