summaryrefslogtreecommitdiffstats
path: root/ash/rotator/screen_rotation_animator.h
blob: 6aff4327e7c8b574d59834b9b6a1ea4225dbf51e (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
// Copyright 2015 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_ROTATOR_SCREEN_ROTATION_ANIMATOR_H_
#define ASH_ROTATOR_SCREEN_ROTATION_ANIMATOR_H_

#include "ash/ash_export.h"
#include "base/basictypes.h"
#include "ui/gfx/display.h"

namespace ash {

// Utility to perform a screen rotation with an animation.
class ASH_EXPORT ScreenRotationAnimator {
 public:
  explicit ScreenRotationAnimator(int64 display_id);
  ~ScreenRotationAnimator();

  // Returns true if the screen rotation animation can be completed
  // successfully. For example an animation is not possible if |display_id_|
  // specifies a gfx::Display that is not currently active. See
  // www.crbug.com/479503.
  bool CanAnimate() const;

  // Rotates the gfx::Display specified by |display_id_| to the |new_rotation|
  // orientation, for the given |source|. The rotation will also become active.
  // Clients should only call |Rotate(gfx::Display::Rotation)| if |CanAnimate()|
  // returns true.
  void Rotate(gfx::Display::Rotation new_rotation,
              gfx::Display::RotationSource source);

 private:
  // The id of the display to rotate.
  int64 display_id_;

  DISALLOW_COPY_AND_ASSIGN(ScreenRotationAnimator);
};

}  // namespace ash

#endif  // ASH_ROTATOR_SCREEN_ROTATION_ANIMATOR_H_