blob: 975afbf29d4bb2a8e3ac879775594525157635e3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_V2_PUBLIC_VIEW_H_
#define UI_V2_PUBLIC_VIEW_H_
#include <vector>
#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
#include "ui/gfx/rect.h"
#include "ui/v2/public/layout.h"
#include "ui/v2/public/painter.h"
#include "ui/v2/public/v2_export.h"
namespace v2 {
class Layout;
class Painter;
class ViewObserver;
class V2_EXPORT View /* : public EventTarget */ {
public:
typedef std::vector<View*> Children;
View();
virtual ~View();
// Configuration.
void set_owned_by_parent(bool owned_by_parent) {
owned_by_parent_ = owned_by_parent;
}
// View takes ownership.
void SetPainter(Painter* painter);
// View takes ownership.
void SetLayout(Layout* layout);
// Observation.
void AddObserver(ViewObserver* observer);
void RemoveObserver(ViewObserver* observer);
// Disposition.
void SetBounds(const gfx::Rect& bounds);
gfx::Rect bounds() const { return bounds_; }
void SetVisible(bool visible);
bool visible() const { return visible_; }
// Tree.
View* parent() { return parent_; }
const View* parent() const { return parent_; }
const Children& children() const { return children_; }
void AddChild(View* child);
void RemoveChild(View* child);
bool Contains(View* child) const;
void StackChildAtTop(View* child);
void StackChildAtBottom(View* child);
void StackChildAbove(View* child, View* other);
void StackChildBelow(View* child, View* other);
private:
friend class Layout;
friend class ViewObserversAccessor;
void SetBoundsInternal(const gfx::Rect& bounds);
// Disposition attributes.
gfx::Rect bounds_;
bool visible_;
scoped_ptr<Painter> painter_;
scoped_ptr<Layout> layout_;
// Tree.
bool owned_by_parent_;
View* parent_;
Children children_;
ObserverList<ViewObserver> observers_;
DISALLOW_COPY_AND_ASSIGN(View);
};
} // namespace v2
#endif // UI_V2_PUBLIC_VIEW_H_
|