Updating trunk VERSION from 848.0 to 849.0
[chromium-blink-merge.git] / aura / window.h
blob14c3ea4c2bb0d5739ae96d7d201ad1b911c16617
1 // Copyright (c) 2011 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 AURA_WINDOW_H_
6 #define AURA_WINDOW_H_
7 #pragma once
9 #include "base/basictypes.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "ui/gfx/native_widget_types.h"
12 #include "ui/gfx/rect.h"
14 class SkCanvas;
16 namespace ui {
17 class Layer;
20 namespace aura {
22 class Desktop;
23 class WindowDelegate;
25 // Aura window implementation. Interesting events are sent to the
26 // WindowDelegate.
27 class Window {
28 public:
29 enum Visibility {
30 // Don't display the window onscreen and don't let it receive mouse
31 // events. This is the default.
32 VISIBILITY_HIDDEN = 1,
34 // Display the window and let it receive mouse events.
35 VISIBILITY_SHOWN = 2,
37 // Display the window but prevent it from receiving mouse events.
38 VISIBILITY_SHOWN_NO_INPUT = 3,
41 explicit Window(Desktop* desktop);
42 ~Window();
44 void set_delegate(WindowDelegate* d) { delegate_ = d; }
46 // Changes the visbility of the window.
47 void SetVisibility(Visibility visibility);
48 Visibility visibility() const { return visibility_; }
50 // Changes the bounds of the window.
51 void SetBounds(const gfx::Rect& bounds, int anim_ms);
52 const gfx::Rect& bounds() const { return bounds_; }
54 // Marks the window as needing to be painted.
55 void SchedulePaint(const gfx::Rect& bounds);
57 // Sets the contents of the window.
58 void SetCanvas(const SkCanvas& canvas, const gfx::Point& origin);
60 // If the window is visible its layer is drawn.
61 void Draw();
63 // If SchedulePaint has been invoked on the Window the delegate is notified.
64 void UpdateLayerCanvas();
66 private:
67 // The desktop we're in.
68 Desktop* desktop_;
70 WindowDelegate* delegate_;
72 Visibility visibility_;
74 scoped_ptr<ui::Layer> layer_;
76 // Union of regions passed to SchedulePaint. Cleaned when UpdateLayerCanvas is
77 // invoked.
78 gfx::Rect dirty_rect_;
80 // If true UpdateLayerCanvas paints all. This is set when the window is first
81 // created to trigger painting the complete bounds.
82 bool needs_paint_all_;
84 // Bounds of the window in the desktop's coordinate system.
85 gfx::Rect bounds_;
87 DISALLOW_COPY_AND_ASSIGN(Window);
90 } // namespace aura
92 #endif // AURA_WINDOW_H_