summaryrefslogtreecommitdiffstats
path: root/ash/display/display_animator_chromeos.h
blob: a4fc768ff9ca32f659e54401c850e2756916e753 (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
// Copyright 2014 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 ASH_DISPLAY_DISPLAY_ANIMATOR_CHROMEOS_H_
#define ASH_DISPLAY_DISPLAY_ANIMATOR_CHROMEOS_H_

#include <map>

#include "ash/ash_export.h"
#include "ash/display/display_animator.h"
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/timer/timer.h"
#include "ui/display/chromeos/display_configurator.h"

namespace aura {
class RootWindow;
class Window;
}  // namespace aura

namespace ui {
class Layer;
}  // namespace ui

namespace ash {

// DisplayAnimatorChromeOS provides the visual effects for
// ui::DisplayConfigurator, such like fade-out/in during changing
// the display mode.
class ASH_EXPORT DisplayAnimatorChromeOS
    : public DisplayAnimator,
      public ui::DisplayConfigurator::Observer {
 public:
  DisplayAnimatorChromeOS();
  ~DisplayAnimatorChromeOS() override;

  // DisplayAnimator
  void StartFadeOutAnimation(base::Closure callback) override;
  void StartFadeInAnimation() override;

 protected:
  // ui::DisplayConfigurator::Observer overrides:
  void OnDisplayModeChanged(
      const ui::DisplayConfigurator::DisplayStateList& outputs) override;
  void OnDisplayModeChangeFailed(
      const ui::DisplayConfigurator::DisplayStateList& displays,
      ui::MultipleDisplayState failed_new_state) override;

 private:
  // Clears all hiding layers.  Note that in case that this method is called
  // during an animation, the method call will cancel all of the animations
  // and *not* call the registered callback.
  void ClearHidingLayers();

  std::map<aura::Window*, ui::Layer*> hiding_layers_;
  scoped_ptr<base::OneShotTimer> timer_;
  base::WeakPtrFactory<DisplayAnimatorChromeOS> weak_ptr_factory_;

  DISALLOW_COPY_AND_ASSIGN(DisplayAnimatorChromeOS);
};

}  // namespace ash

#endif  // ASH_DISPLAY_DISPLAY_ANIMATOR_CHROMEOS_H_