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

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, 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
« no previous file with comments | « ash/devtools/ash_devtools_unittest.cc ('k') | ash/devtools/ui_element.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
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();
28 void SetNodeId(int node_id);
29
30 UIElement* GetParent();
31
32 UIElementDelegate* delegate();
33 UIElementType GetType();
34
35 const std::vector<UIElement*>& GetChildren() const;
36 void AddChild(std::vector<UIElement*>::iterator index, UIElement* child);
37 void PushBackChild(UIElement* child);
38 void RemoveChild(std::vector<UIElement*>::iterator index);
39 void RemoveChildFromParent();
40 UIElement* LastChild();
41
42 std::vector<UIElement*>::iterator FindChildIterator(UIElement* child);
43 std::vector<UIElement*>::iterator BeginChildIterator();
44 std::vector<UIElement*>::iterator LastChildIterator();
45 std::vector<UIElement*>::iterator ChildIndexFromParent();
sadrul 2017/05/03 03:02:06 These ... seem unnecessarily complicated. The tre
thanhph 2017/05/03 21:58:11 Removed, thanks!
46
47 virtual void Destroy() = 0;
48 virtual bool GetBounds(gfx::Rect* bounds) = 0;
49 virtual bool SetBounds(const gfx::Rect& bounds) = 0;
50 virtual bool GetVisible(bool* visible) = 0;
51 virtual bool SetVisible(bool visible) = 0;
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() = 0;
55
56 template <typename BackingT, typename T>
57 static BackingT* GetBackingElement(UIElement* element) {
58 return T::From(element);
59 };
60
61 protected:
62 UIElement(const UIElementType type,
63 UIElementDelegate* ui_element_delegate,
64 UIElement* parent);
65 virtual ~UIElement();
66
67 private:
68 int node_id_;
69 std::vector<UIElement*> children_;
70 const UIElementType type_;
71 UIElement* parent_;
72 UIElementDelegate* ui_element_delegate_;
73
74 DISALLOW_COPY_AND_ASSIGN(UIElement);
75 };
76
77 } // namespace devtools
78 } // namespace ash
79
80 #endif // ASH_DEVTOOLS_UI_ELEMENT_H_
OLDNEW
« no previous file with comments | « ash/devtools/ash_devtools_unittest.cc ('k') | ash/devtools/ui_element.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698