summaryrefslogtreecommitdiffstats
path: root/aura/window.h
blob: 14c3ea4c2bb0d5739ae96d7d201ad1b911c16617 (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
// 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 "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/rect.h"

class SkCanvas;

namespace ui {
class Layer;
}

namespace aura {

class Desktop;
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(Desktop* desktop);
  ~Window();

  void set_delegate(WindowDelegate* d) { delegate_ = d; }

  // Changes the visbility 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);

  // If the window is visible its layer is drawn.
  void Draw();

  // If SchedulePaint has been invoked on the Window the delegate is notified.
  void UpdateLayerCanvas();

 private:
  // The desktop we're in.
  Desktop* desktop_;

  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_;

  DISALLOW_COPY_AND_ASSIGN(Window);
};

}  // namespace aura

#endif  // AURA_WINDOW_H_