network_icon_animation.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright (c) 2013 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_SYSTEM_NETWORK_NETWORK_ICON_ANIMATION_H_
  5. #define ASH_SYSTEM_NETWORK_NETWORK_ICON_ANIMATION_H_
  6. #include "ash/ash_export.h"
  7. #include "base/observer_list.h"
  8. #include "ui/gfx/animation/animation_delegate.h"
  9. #include "ui/gfx/animation/throb_animation.h"
  10. namespace ash {
  11. namespace network_icon {
  12. class AnimationObserver;
  13. // Single instance class to handle icon animations and keep them in sync.
  14. class ASH_EXPORT NetworkIconAnimation : public gfx::AnimationDelegate {
  15. public:
  16. NetworkIconAnimation();
  17. ~NetworkIconAnimation() override;
  18. // Returns the current animation value, [0-1].
  19. double GetAnimation();
  20. // The animation stops when all observers have been removed.
  21. // Be sure to remove observers when no associated icons are animating.
  22. void AddObserver(AnimationObserver* observer);
  23. void RemoveObserver(AnimationObserver* observer);
  24. // gfx::AnimationDelegate implementation.
  25. void AnimationProgressed(const gfx::Animation* animation) override;
  26. static NetworkIconAnimation* GetInstance();
  27. private:
  28. gfx::ThrobAnimation animation_;
  29. base::ObserverList<AnimationObserver>::Unchecked observers_;
  30. };
  31. } // namespace network_icon
  32. } // namespace ash
  33. #endif // ASH_SYSTEM_NETWORK_NETWORK_ICON_ANIMATION_H_