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

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

Issue 2776543002: Create a unified UIElement interface for Widget, View and Window. (Closed)
Patch Set: rebase 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 "ash/wm_window.h"
12 #include "base/macros.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 UIElement();
sadrul 2017/04/19 18:21:39 Move this into a protected ctor. Change the ctor
thanhph 2017/04/24 15:56:50 Done. I also added parent as an input.
28 virtual ~UIElement();
29
30 int GetNodeId() const;
31 void SetNodeId(int node_id);
32
33 UIElement* GetParent();
34 void SetParent(UIElement* parent);
35
36 UIElementDelegate* GetUIElementDelegate();
37 void SetUIElementDelegate(UIElementDelegate* ui_element_delegate);
38
39 UIElementType GetType() const;
40 void SetType(UIElementType type);
41
42 std::vector<UIElement*>& GetChildren();
43 void SetChildren(std::vector<UIElement*>& children);
44
45 virtual void Destroy() = 0;
46 virtual bool GetBounds(gfx::Rect* bounds) = 0;
47 virtual bool SetBounds(const gfx::Rect& bounds) = 0;
48 virtual bool GetVisible(bool* visible) = 0;
49 virtual bool SetVisible(bool visible) = 0;
50 virtual std::pair<WmWindow*, gfx::Rect> GetNodeWindowAndBounds() = 0;
51
52 template <typename BackingT, typename T>
53 static BackingT* GetBackingElement(UIElement* element) {
54 return T::From(element);
55 };
56
57 private:
58 int node_id_;
59 std::vector<UIElement*> children_;
60 UIElementType type_;
61 UIElement* parent_;
62 UIElementDelegate* ui_element_delegate_;
63
64 DISALLOW_COPY_AND_ASSIGN(UIElement);
65 };
66
67 } // namespace devtools
68 } // namespace ash
69
70 #endif // ASH_COMMON_DEVTOOLS_UI_ELEMENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698