1 // Copyright 2017 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 5 #ifndef ASH_LOGIN_UI_USER_SWITCH_FLIP_ANIMATION_H_ 6 #define ASH_LOGIN_UI_USER_SWITCH_FLIP_ANIMATION_H_ 7 8 #include <stdint.h> 9 10 #include <memory> 11 12 #include "ash/ash_export.h" 13 #include "base/callback.h" 14 #include "base/macros.h" 15 #include "base/time/time.h" 16 #include "ui/compositor/layer_animation_element.h" 17 #include "ui/gfx/animation/tween.h" 18 19 namespace ui { 20 class InterpolatedTransform; 21 } // namespace ui 22 23 namespace ash { 24 25 // A LayerAnimationElement that will animate a layer by rotating it around the 26 // y-axis. 27 class ASH_EXPORT UserSwitchFlipAnimation : public ui::LayerAnimationElement { 28 public: 29 // Creates an animation element that will rotate from |start_degrees| to 30 // |midpoint_degrees| to |end_degrees| around the y axis, taking |duration| 31 // amount of time, animating using |tween_type|. 32 UserSwitchFlipAnimation(int width, 33 int start_degrees, 34 int midpoint_degrees, 35 int end_degrees, 36 base::TimeDelta duration, 37 gfx::Tween::Type tween_type, 38 base::OnceClosure on_midpoint); 39 ~UserSwitchFlipAnimation() override; 40 41 // ui::LayerAnimationElement: 42 void OnStart(ui::LayerAnimationDelegate* delegate) override; 43 bool OnProgress(double current, 44 ui::LayerAnimationDelegate* delegate) override; 45 void OnGetTarget(TargetValue* target) const override; 46 void OnAbort(ui::LayerAnimationDelegate* delegate) override; 47 48 private: 49 // The root InterpolatedTransform that defines the animation. 50 std::unique_ptr<ui::InterpolatedTransform> first_half_transform_; 51 std::unique_ptr<ui::InterpolatedTransform> second_half_transform_; 52 53 // The tween type to use for the animation. 54 gfx::Tween::Type tween_type_; 55 56 // Called when the animation is 50% complete. 57 base::OnceClosure on_midpoint_; 58 59 DISALLOW_COPY_AND_ASSIGN(UserSwitchFlipAnimation); 60 }; 61 62 } // namespace ash 63 64 #endif // ASH_LOGIN_UI_USER_SWITCH_FLIP_ANIMATION_H_ 65