screen_rotation_animation.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // Copyright 2015 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.
  4. #ifndef ASH_ROTATOR_SCREEN_ROTATION_ANIMATION_H_
  5. #define ASH_ROTATOR_SCREEN_ROTATION_ANIMATION_H_
  6. #include <stdint.h>
  7. #include <memory>
  8. #include "ash/ash_export.h"
  9. #include "base/time/time.h"
  10. #include "ui/compositor/layer_animation_element.h"
  11. #include "ui/gfx/animation/tween.h"
  12. #include "ui/gfx/geometry/point.h"
  13. namespace ui {
  14. class InterpolatedTransform;
  15. class Layer;
  16. }
  17. namespace ash {
  18. // A LayerAnimationElement that will animate a layer by rotating it around a
  19. // pivot point.
  20. class ASH_EXPORT ScreenRotationAnimation : public ui::LayerAnimationElement {
  21. public:
  22. // Creates an animation element that will rotate |layer| from |start_degrees|
  23. // to |end_degrees| around the given |pivot| and will take |duration| amount
  24. // of time.
  25. ScreenRotationAnimation(ui::Layer* layer,
  26. int start_degrees,
  27. int end_degrees,
  28. float initial_opacity,
  29. float target_opacity,
  30. gfx::Point pivot,
  31. base::TimeDelta duration,
  32. gfx::Tween::Type twen_type);
  33. ScreenRotationAnimation(const ScreenRotationAnimation&) = delete;
  34. ScreenRotationAnimation& operator=(const ScreenRotationAnimation&) = delete;
  35. ~ScreenRotationAnimation() override;
  36. private:
  37. // Implementation of ui::LayerAnimationElement:
  38. void OnStart(ui::LayerAnimationDelegate* delegate) override;
  39. bool OnProgress(double current,
  40. ui::LayerAnimationDelegate* delegate) override;
  41. void OnGetTarget(TargetValue* target) const override;
  42. void OnAbort(ui::LayerAnimationDelegate* delegate) override;
  43. // The root InterpolatedTransform that defines the animation.
  44. std::unique_ptr<ui::InterpolatedTransform> interpolated_transform_;
  45. // The Tween type to use for the animation.
  46. gfx::Tween::Type tween_type_;
  47. // The initial layer opacity to start the animation with.
  48. float initial_opacity_;
  49. // The target layer opacity to end the animation with.
  50. float target_opacity_;
  51. };
  52. } // namespace ash
  53. #endif // ASH_ROTATOR_SCREEN_ROTATION_ANIMATION_H_