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 SERVICES_VIEW_MANAGER_SERVER_VIEW_H_ |
| 6 #define 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/view_manager/ids.h" |
| 13 #include "third_party/mojo_services/src/view_manager/public/interfaces/view_mana
ger.mojom.h" |
| 14 #include "ui/gfx/geometry/rect.h" |
| 15 #include "ui/gfx/transform.h" |
| 16 |
| 17 namespace view_manager { |
| 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 mojo::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 gfx::Transform& transform() const { return transform_; } |
| 67 void SetTransform(const gfx::Transform& transform); |
| 68 |
| 69 const std::map<std::string, std::vector<uint8_t>>& properties() const { |
| 70 return properties_; |
| 71 } |
| 72 void SetProperty(const std::string& name, const std::vector<uint8_t>* value); |
| 73 |
| 74 // Returns true if this view is attached to |root| and all ancestors are |
| 75 // visible. |
| 76 bool IsDrawn(const ServerView* root) const; |
| 77 |
| 78 void SetSurfaceId(cc::SurfaceId surface_id); |
| 79 const cc::SurfaceId& surface_id() const { return surface_id_; } |
| 80 |
| 81 #if !defined(NDEBUG) |
| 82 std::string GetDebugWindowHierarchy() const; |
| 83 void BuildDebugInfo(const std::string& depth, std::string* result) const; |
| 84 #endif |
| 85 |
| 86 private: |
| 87 typedef std::vector<ServerView*> Views; |
| 88 |
| 89 // Implementation of removing a view. Doesn't send any notification. |
| 90 void RemoveImpl(ServerView* view); |
| 91 |
| 92 ServerViewDelegate* delegate_; |
| 93 const ViewId id_; |
| 94 ServerView* parent_; |
| 95 Views children_; |
| 96 bool visible_; |
| 97 gfx::Rect bounds_; |
| 98 cc::SurfaceId surface_id_; |
| 99 float opacity_; |
| 100 gfx::Transform transform_; |
| 101 |
| 102 std::map<std::string, std::vector<uint8_t>> properties_; |
| 103 |
| 104 DISALLOW_COPY_AND_ASSIGN(ServerView); |
| 105 }; |
| 106 |
| 107 } // namespace view_manager |
| 108 |
| 109 #endif // SERVICES_VIEW_MANAGER_SERVER_VIEW_H_ |
OLD | NEW |