summaryrefslogtreecommitdiffstats
path: root/views/desktop/desktop_window_view.h
blob: 3ae9c1804dabf76bde517904ff837e099901525d (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
// 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 VIEWS_DESKTOP_DESKTOP_WINDOW_VIEW_H_
#define VIEWS_DESKTOP_DESKTOP_WINDOW_VIEW_H_

#include "base/observer_list.h"
#include "ui/gfx/compositor/layer_animation_observer.h"
#include "views/view.h"
#include "views/widget/widget_delegate.h"

namespace ui {
class LayerAnimationSequence;
}  // namespace ui

namespace views {

class Widget;

namespace desktop {

class DesktopWindowView : public WidgetDelegateView,
                          public ui::LayerAnimationObserver {
 public:
  // Observers can listen to various events on the desktop.
  class Observer {
   public:
    virtual void OnDesktopBoundsChanged(const gfx::Rect& previous_bounds) = 0;

   protected:
    virtual ~Observer() {}
  };

  // The look and feel will be slightly different for different kinds of
  // desktop.
  enum DesktopType {
    DESKTOP_DEFAULT,
    DESKTOP_NETBOOK,
    DESKTOP_OTHER
  };

  static DesktopWindowView* desktop_window_view;

  explicit DesktopWindowView(DesktopType type);
  virtual ~DesktopWindowView();

  static void CreateDesktopWindow(DesktopType type);

  void CreateTestWindow(const string16& title,
                        SkColor color,
                        gfx::Rect initial_bounds,
                        bool rotate);

  DesktopType type() const { return type_; }

  // Add/remove observer.
  void AddObserver(Observer* observer);
  void RemoveObserver(Observer* observer);
  bool HasObserver(Observer* observer);

 private:
  // Overridden from View:
  virtual void Layout() OVERRIDE;
  virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE;
  virtual void ViewHierarchyChanged(
      bool is_add, View* parent, View* child) OVERRIDE;

  // Overridden from WidgetDelegate:
  virtual Widget* GetWidget() OVERRIDE;
  virtual const Widget* GetWidget() const OVERRIDE;
  virtual bool CanResize() const OVERRIDE;
  virtual bool CanMaximize() const OVERRIDE;
  virtual string16 GetWindowTitle() const OVERRIDE;
  virtual SkBitmap GetWindowAppIcon() OVERRIDE;
  virtual SkBitmap GetWindowIcon() OVERRIDE;
  virtual bool ShouldShowWindowIcon() const OVERRIDE;
  virtual void WindowClosing() OVERRIDE;
  virtual View* GetContentsView() OVERRIDE;
  virtual NonClientFrameView* CreateNonClientFrameView() OVERRIDE;

  // Implementation of ui::LayerAnimationObserver:
  virtual void OnLayerAnimationEnded(
      const ui::LayerAnimationSequence* animation) OVERRIDE;
  virtual void OnLayerAnimationScheduled(
      const ui::LayerAnimationSequence* animation) OVERRIDE;
  virtual void OnLayerAnimationAborted(
      const ui::LayerAnimationSequence* animation) OVERRIDE;

  ObserverList<Observer> observers_;
  DesktopType type_;
  Widget* widget_;

  DISALLOW_COPY_AND_ASSIGN(DesktopWindowView);
};

}  // namespace desktop
}  // namespace views

#endif  // VIEWS_DESKTOP_DESKTOP_WINDOW_VIEW_H_