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 "mojo/services/public/interfaces/view_manager/view_manager.mojom.h"
12 #include "mojo/services/view_manager/ids.h"
13 #include "mojo/services/view_manager/view_manager_export.h"
14 #include "third_party/skia/include/core/SkBitmap.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 bool Contains(const ServerView
* view
) const;
58 // Returns true if the window is visible. This does not consider visibility
60 bool visible() const { return visible_
; }
61 void SetVisible(bool value
);
63 void SetBitmap(const SkBitmap
& contents
);
64 const SkBitmap
& bitmap() const { return bitmap_
; }
67 typedef std::vector
<ServerView
*> Views
;
69 // Implementation of removing a view. Doesn't send any notification.
70 void RemoveImpl(ServerView
* view
);
72 ServerViewDelegate
* delegate_
;
80 DISALLOW_COPY_AND_ASSIGN(ServerView
);
83 } // namespace service
86 #endif // MOJO_SERVICES_VIEW_MANAGER_SERVER_VIEW_H_