window_rotation.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright (c) 2012 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_WINDOW_ROTATION_H_
  5. #define ASH_ROTATOR_WINDOW_ROTATION_H_
  6. #include <memory>
  7. #include "ash/ash_export.h"
  8. #include "ui/compositor/layer_animation_element.h"
  9. #include "ui/gfx/geometry/point.h"
  10. namespace ui {
  11. class InterpolatedTransform;
  12. class Layer;
  13. }
  14. namespace ash {
  15. // A window rotation represents a single transition from one window orientation
  16. // to another. The intended usage is that a new instance of the class is
  17. // created for every transition. It is possible to update the target orientation
  18. // in the middle of a transition.
  19. class ASH_EXPORT WindowRotation : public ui::LayerAnimationElement {
  20. public:
  21. // |degrees| are clockwise. |layer| is the target of the animation. Does not
  22. // take ownership of |layer|.
  23. WindowRotation(int degrees, ui::Layer* layer);
  24. WindowRotation(const WindowRotation&) = delete;
  25. WindowRotation& operator=(const WindowRotation&) = delete;
  26. ~WindowRotation() override;
  27. private:
  28. // Generates the intermediate transformation matrices used during the
  29. // animation.
  30. void InitTransform(ui::Layer* layer);
  31. // Implementation of ui::LayerAnimationDelegate
  32. void OnStart(ui::LayerAnimationDelegate* delegate) override;
  33. bool OnProgress(double t, ui::LayerAnimationDelegate* delegate) override;
  34. void OnGetTarget(TargetValue* target) const override;
  35. void OnAbort(ui::LayerAnimationDelegate* delegate) override;
  36. std::unique_ptr<ui::InterpolatedTransform> interpolated_transform_;
  37. // The number of degrees to rotate.
  38. int degrees_;
  39. // The target origin.
  40. gfx::Point new_origin_;
  41. };
  42. } // namespace ash
  43. #endif // ASH_ROTATOR_WINDOW_ROTATION_H_