blob: 871ceb6038f2ec36a5d8e8bbc5199ad83a649e6c (
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
// Copyright (c) 2011 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 AURA_WINDOW_H_
#define AURA_WINDOW_H_
#pragma once
#include <vector>
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "ui/gfx/rect.h"
class SkCanvas;
namespace ui {
class Compositor;
class Layer;
}
namespace aura {
class Desktop;
class MouseEvent;
class WindowDelegate;
// Aura window implementation. Interesting events are sent to the
// WindowDelegate.
class Window {
public:
enum Visibility {
// Don't display the window onscreen and don't let it receive mouse
// events. This is the default.
VISIBILITY_HIDDEN = 1,
// Display the window and let it receive mouse events.
VISIBILITY_SHOWN = 2,
// Display the window but prevent it from receiving mouse events.
VISIBILITY_SHOWN_NO_INPUT = 3,
};
explicit Window(WindowDelegate* delegate);
~Window();
void Init();
int id() const { return id_; }
void set_id(int id) { id_ = id; }
ui::Layer* layer() { return layer_.get(); }
const ui::Layer* layer() const { return layer_.get(); }
// Changes the visibility of the window.
void SetVisibility(Visibility visibility);
Visibility visibility() const { return visibility_; }
// Changes the bounds of the window.
void SetBounds(const gfx::Rect& bounds, int anim_ms);
const gfx::Rect& bounds() const { return bounds_; }
// Marks the window as needing to be painted.
void SchedulePaint(const gfx::Rect& bounds);
// Sets the contents of the window.
void SetCanvas(const SkCanvas& canvas, const gfx::Point& origin);
// Sets the parent window of the window. If NULL, the window is parented to
// the desktop's window.
void SetParent(Window* parent);
Window* parent() { return parent_; }
// Draw the window and its children.
void DrawTree();
// Tree operations.
// TODO(beng): Child windows are currently not owned by the hierarchy. We
// should change this.
void AddChild(Window* child);
void RemoveChild(Window* child);
// Handles a mouse event. Returns true if handled.
bool OnMouseEvent(const MouseEvent& event);
private:
typedef std::vector<Window*> Windows;
// If SchedulePaint has been invoked on the Window the delegate is notified.
void UpdateLayerCanvas();
// Draws the Window's contents.
void Draw();
WindowDelegate* delegate_;
Visibility visibility_;
scoped_ptr<ui::Layer> layer_;
// Union of regions passed to SchedulePaint. Cleaned when UpdateLayerCanvas is
// invoked.
gfx::Rect dirty_rect_;
// If true UpdateLayerCanvas paints all. This is set when the window is first
// created to trigger painting the complete bounds.
bool needs_paint_all_;
// Bounds of the window in the desktop's coordinate system.
gfx::Rect bounds_;
// The Window's parent.
// TODO(beng): Implement NULL-ness for toplevels.
Window* parent_;
// Child windows. Topmost is last.
Windows children_;
int id_;
DISALLOW_COPY_AND_ASSIGN(Window);
};
} // namespace aura
#endif // AURA_WINDOW_H_
|