1 // Copyright (c) 2013 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 UI_V2_PUBLIC_VIEW_H_
6 #define UI_V2_PUBLIC_VIEW_H_
10 #include "base/memory/scoped_ptr.h"
11 #include "base/observer_list.h"
12 #include "ui/compositor/layer_type.h"
13 #include "ui/gfx/rect.h"
14 #include "ui/v2/public/layout.h"
15 #include "ui/v2/public/painter.h"
16 #include "ui/v2/public/v2_export.h"
29 class V2_EXPORT View /* : public EventTarget */ {
31 typedef std::vector<View*> Children;
38 void set_owned_by_parent(bool owned_by_parent) {
39 owned_by_parent_ = owned_by_parent;
42 // View takes ownership.
43 void SetPainter(Painter* painter);
45 // See documentation in layout.h. A layout manager's rules apply to this
47 // View takes ownership.
48 void SetLayout(Layout* layout);
52 void AddObserver(ViewObserver* observer);
53 void RemoveObserver(ViewObserver* observer);
57 void SetBounds(const gfx::Rect& bounds);
58 gfx::Rect bounds() const { return bounds_; }
60 void SetVisible(bool visible);
61 bool visible() const { return visible_; }
65 View* parent() { return parent_; }
66 const View* parent() const { return parent_; }
67 const Children& children() const { return children_; }
69 void AddChild(View* child);
70 void RemoveChild(View* child);
72 bool Contains(View* child) const;
74 void StackChildAtTop(View* child);
75 void StackChildAtBottom(View* child);
76 void StackChildAbove(View* child, View* other);
77 void StackChildBelow(View* child, View* other);
81 inline const ui::Layer* layer() const;
82 inline ui::Layer* layer();
83 bool HasLayer() const;
84 void CreateLayer(ui::LayerType layer_type);
86 ui::Layer* AcquireLayer();
89 friend class ViewPrivate;
91 // Disposition attributes.
95 scoped_ptr<Painter> painter_;
96 scoped_ptr<Layout> layout_;
99 bool owned_by_parent_;
104 scoped_ptr<ViewLayerOwner> layer_owner_;
106 ObserverList<ViewObserver> observers_;
108 DISALLOW_COPY_AND_ASSIGN(View);
113 #endif // UI_V2_PUBLIC_VIEW_H_