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.
5 #ifndef MOJO_SERVICES_VIEW_MANAGER_SERVER_VIEW_H_
6 #define MOJO_SERVICES_VIEW_MANAGER_SERVER_VIEW_H_
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 "mojo/services/view_manager/view_manager_export.h"
15 #include "ui/gfx/geometry/rect.h"
20 class ServerViewDelegate;
22 // Server side representation of a view. Delegate is informed of interesting
25 // It is assumed that all functions that mutate the tree have validated the
26 // mutation is possible before hand. For example, Reorder() assumes the supplied
27 // view is a child and not already in position.
28 class MOJO_VIEW_MANAGER_EXPORT ServerView {
30 ServerView(ServerViewDelegate* delegate, const ViewId& id);
31 virtual ~ServerView();
33 const ViewId& id() const { return id_; }
35 void Add(ServerView* child);
36 void Remove(ServerView* child);
37 void Reorder(ServerView* child,
39 OrderDirection direction);
41 const gfx::Rect& bounds() const { return bounds_; }
42 void SetBounds(const gfx::Rect& bounds);
44 const ServerView* parent() const { return parent_; }
45 ServerView* parent() { return parent_; }
47 const ServerView* GetRoot() const;
48 ServerView* GetRoot() {
49 return const_cast<ServerView*>(
50 const_cast<const ServerView*>(this)->GetRoot());
53 std::vector<const ServerView*> GetChildren() const;
54 std::vector<ServerView*> GetChildren();
56 // Returns true if this contains |view| or is |view|.
57 bool Contains(const ServerView* view) const;
59 // Returns true if the window is visible. This does not consider visibility
61 bool visible() const { return visible_; }
62 void SetVisible(bool value);
64 // Returns true if this view is attached to |root| and all ancestors are
66 bool IsDrawn(const ServerView* root) const;
68 void SetSurfaceId(cc::SurfaceId surface_id);
69 const cc::SurfaceId surface_id() const { return surface_id_; }
72 typedef std::vector<ServerView*> Views;
74 // Implementation of removing a view. Doesn't send any notification.
75 void RemoveImpl(ServerView* view);
77 ServerViewDelegate* delegate_;
83 cc::SurfaceId surface_id_;
85 DISALLOW_COPY_AND_ASSIGN(ServerView);
88 } // namespace service
91 #endif // MOJO_SERVICES_VIEW_MANAGER_SERVER_VIEW_H_