window_scale_animation.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // Copyright 2019 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_SHELF_WINDOW_SCALE_ANIMATION_H_
  5. #define ASH_SHELF_WINDOW_SCALE_ANIMATION_H_
  6. #include <memory>
  7. #include <vector>
  8. #include "ash/ash_export.h"
  9. #include "base/auto_reset.h"
  10. #include "base/callback.h"
  11. #include "base/callback_helpers.h"
  12. #include "base/scoped_observation.h"
  13. #include "ui/aura/window.h"
  14. namespace ash {
  15. enum class BackdropWindowMode;
  16. // The class which does the scale-down animation to shelf or scale-up to restore
  17. // to its original bounds for all windows in the transient tree of |window_|
  18. // after drag ends. Window(s) will be minimized with the descending order
  19. // in the transient tree after animation completes if we're scaling down to
  20. // shelf.
  21. class ASH_EXPORT WindowScaleAnimation {
  22. public:
  23. enum class WindowScaleType {
  24. kScaleDownToShelf,
  25. kScaleUpToRestore,
  26. };
  27. WindowScaleAnimation(aura::Window* window,
  28. WindowScaleType scale_type,
  29. base::OnceClosure opt_callback);
  30. WindowScaleAnimation(const WindowScaleAnimation&) = delete;
  31. WindowScaleAnimation& operator=(const WindowScaleAnimation&) = delete;
  32. ~WindowScaleAnimation();
  33. // Starts animating and creating animation observers for all window(s) in the
  34. // transient tree of `window_` in a descending order,
  35. void Start();
  36. // For tests only:
  37. static base::AutoReset<bool>
  38. EnableScopedFastAnimationForTransientChildForTest();
  39. private:
  40. class AnimationObserver;
  41. void DestroyWindowAnimationObserver(
  42. WindowScaleAnimation::AnimationObserver* animation_observer);
  43. void OnScaleWindowsOnAnimationsCompleted();
  44. aura::Window* window_;
  45. base::OnceClosure opt_callback_;
  46. const WindowScaleType scale_type_;
  47. // Each window in the transient tree has its own |WindowAnimationObserver|.
  48. std::vector<std::unique_ptr<AnimationObserver>> window_animation_observers_;
  49. };
  50. } // namespace ash
  51. #endif // ASH_SHELF_WINDOW_SCALE_ANIMATION_H_