app_list_view_util.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright 2022 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_APP_LIST_VIEWS_APP_LIST_VIEW_UTIL_H_
  5. #define ASH_APP_LIST_VIEWS_APP_LIST_VIEW_UTIL_H_
  6. #include "base/callback_forward.h"
  7. #include "third_party/abseil-cpp/absl/types/optional.h"
  8. #include "ui/gfx/animation/tween.h"
  9. namespace base {
  10. class TimeDelta;
  11. } // namespace base
  12. namespace views {
  13. class View;
  14. class AnimationSequenceBlock;
  15. } // namespace views
  16. namespace ash {
  17. // Prepares for a layer animation on `view`. Returns whether a layer is created
  18. // for `view`.
  19. bool PrepareForLayerAnimation(views::View* view);
  20. // Starts a vertical slide animation for `view` with `vertical_offset` as the
  21. // initial offset. The view must already have a layer. Runs the `end_callback`
  22. // when the animation ends or aborts.
  23. void StartSlideInAnimation(views::View* view,
  24. int vertical_offset,
  25. const base::TimeDelta& time_delta,
  26. gfx::Tween::Type tween_type,
  27. base::RepeatingClosure end_callback);
  28. // Similar to the method above. But use a specified animation sequence block
  29. // instead of creating a new one. Sets the animation duration if `time_delta`
  30. // is meaningful. NOTE: `sequence_block` can only set duration once.
  31. void SlideViewIntoPositionWithSequenceBlock(
  32. views::View* view,
  33. int vertical_offset,
  34. const absl::optional<base::TimeDelta>& time_delta,
  35. gfx::Tween::Type tween_type,
  36. views::AnimationSequenceBlock* sequence_block);
  37. } // namespace ash
  38. #endif // ASH_APP_LIST_VIEWS_APP_LIST_VIEW_UTIL_H_