ambient_animation_attribution_transformer.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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_AMBIENT_UI_AMBIENT_ANIMATION_ATTRIBUTION_TRANSFORMER_H_
  5. #define ASH_AMBIENT_UI_AMBIENT_ANIMATION_ATTRIBUTION_TRANSFORMER_H_
  6. #include "ash/ash_export.h"
  7. namespace views {
  8. class AnimatedImageView;
  9. } // namespace views
  10. namespace ash {
  11. // "Attribution" refers to the text credits that may optionally accompany each
  12. // photo that's assigned to a dynamic asset in an animation. The Lottie files
  13. // for ambient mode have a placeholder for each dynamic asset where its
  14. // attribution text should go.
  15. //
  16. // The attribution text box's coordinates must be baked into the Lottie file.
  17. // However, UX requires that it is positioned such that the bottom-right of the
  18. // text box has 24 pixels of padding from the bottom-right of the view.
  19. // Additionally, the text box's width should extend from the left side of the
  20. // view all the way to (width - 24) to account for long attributions.
  21. // Visually, it looks like this:
  22. //
  23. // View:
  24. // +-----------------------------------------------+
  25. // | |
  26. // | |
  27. // | |
  28. // | |
  29. // | |
  30. // | |
  31. // | |
  32. // | |
  33. // | |
  34. // |-------------------------------------------+ |
  35. // | Attribution Text| |
  36. // |-------------------------------------------+ |
  37. // | |
  38. // +-----------------------------------------------+
  39. //
  40. // The animation already right-aligns the text within the box, but since the
  41. // view's boundaries can vary from device to device, it is impossible to
  42. // specify text box coordinates in the lottie file that work for all devices.
  43. //
  44. // To accomplish this, AmbientAnimationAttributionTransformer uses Skottie's
  45. // text/transform property observer API to intercept and modify the text box's
  46. // coordinates.
  47. class ASH_EXPORT AmbientAnimationAttributionTransformer {
  48. public:
  49. // Modifies the lottie animation embedded within the |animated_image_view|
  50. // such that its attribution text box matches the UX requirements described
  51. // above.
  52. static void TransformTextBox(views::AnimatedImageView& animated_image_view);
  53. };
  54. } // namespace ash
  55. #endif // ASH_AMBIENT_UI_AMBIENT_ANIMATION_ATTRIBUTION_TRANSFORMER_H_