OLD | NEW |
| (Empty) |
1 // Copyright 2014 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 MOJO_SERVICES_VIEW_MANAGER_SERVER_VIEW_H_ | |
6 #define MOJO_SERVICES_VIEW_MANAGER_SERVER_VIEW_H_ | |
7 | |
8 #include <vector> | |
9 | |
10 #include "base/logging.h" | |
11 #include "cc/surfaces/surface_id.h" | |
12 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h" | |
13 #include "mojo/services/view_manager/ids.h" | |
14 #include "ui/gfx/geometry/rect.h" | |
15 | |
16 namespace mojo { | |
17 namespace service { | |
18 | |
19 class ServerViewDelegate; | |
20 | |
21 // Server side representation of a view. Delegate is informed of interesting | |
22 // events. | |
23 // | |
24 // It is assumed that all functions that mutate the tree have validated the | |
25 // mutation is possible before hand. For example, Reorder() assumes the supplied | |
26 // view is a child and not already in position. | |
27 class ServerView { | |
28 public: | |
29 ServerView(ServerViewDelegate* delegate, const ViewId& id); | |
30 virtual ~ServerView(); | |
31 | |
32 const ViewId& id() const { return id_; } | |
33 | |
34 void Add(ServerView* child); | |
35 void Remove(ServerView* child); | |
36 void Reorder(ServerView* child, | |
37 ServerView* relative, | |
38 OrderDirection direction); | |
39 | |
40 const gfx::Rect& bounds() const { return bounds_; } | |
41 void SetBounds(const gfx::Rect& bounds); | |
42 | |
43 const ServerView* parent() const { return parent_; } | |
44 ServerView* parent() { return parent_; } | |
45 | |
46 const ServerView* GetRoot() const; | |
47 ServerView* GetRoot() { | |
48 return const_cast<ServerView*>( | |
49 const_cast<const ServerView*>(this)->GetRoot()); | |
50 } | |
51 | |
52 std::vector<const ServerView*> GetChildren() const; | |
53 std::vector<ServerView*> GetChildren(); | |
54 | |
55 // Returns true if this contains |view| or is |view|. | |
56 bool Contains(const ServerView* view) const; | |
57 | |
58 // Returns true if the window is visible. This does not consider visibility | |
59 // of any ancestors. | |
60 bool visible() const { return visible_; } | |
61 void SetVisible(bool value); | |
62 | |
63 float opacity() const { return opacity_; } | |
64 void SetOpacity(float value); | |
65 | |
66 const std::map<std::string, std::vector<uint8_t>>& properties() const { | |
67 return properties_; | |
68 } | |
69 void SetProperty(const std::string& name, const std::vector<uint8_t>* value); | |
70 | |
71 // Returns true if this view is attached to |root| and all ancestors are | |
72 // visible. | |
73 bool IsDrawn(const ServerView* root) const; | |
74 | |
75 void SetSurfaceId(cc::SurfaceId surface_id); | |
76 const cc::SurfaceId surface_id() const { return surface_id_; } | |
77 | |
78 #if !defined(NDEBUG) | |
79 std::string GetDebugWindowHierarchy() const; | |
80 void BuildDebugInfo(const std::string& depth, std::string* result) const; | |
81 #endif | |
82 | |
83 private: | |
84 typedef std::vector<ServerView*> Views; | |
85 | |
86 // Implementation of removing a view. Doesn't send any notification. | |
87 void RemoveImpl(ServerView* view); | |
88 | |
89 ServerViewDelegate* delegate_; | |
90 const ViewId id_; | |
91 ServerView* parent_; | |
92 Views children_; | |
93 bool visible_; | |
94 gfx::Rect bounds_; | |
95 cc::SurfaceId surface_id_; | |
96 float opacity_; | |
97 | |
98 std::map<std::string, std::vector<uint8_t>> properties_; | |
99 | |
100 DISALLOW_COPY_AND_ASSIGN(ServerView); | |
101 }; | |
102 | |
103 } // namespace service | |
104 } // namespace mojo | |
105 | |
106 #endif // MOJO_SERVICES_VIEW_MANAGER_SERVER_VIEW_H_ | |
OLD | NEW |