pulsing_block_view.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright (c) 2012 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_PULSING_BLOCK_VIEW_H_
  5. #define ASH_APP_LIST_VIEWS_PULSING_BLOCK_VIEW_H_
  6. #include "base/compiler_specific.h"
  7. #include "base/timer/timer.h"
  8. #include "ui/views/view.h"
  9. namespace gfx {
  10. class Size;
  11. }
  12. namespace ash {
  13. // PulsingBlockView shows a pulsing white circle via layer animation.
  14. class PulsingBlockView : public views::View {
  15. public:
  16. // Constructs a PulsingBlockView of |size|. Starts the pulsing animation after
  17. // a |animation_delay|.
  18. PulsingBlockView(const gfx::Size& size, base::TimeDelta animation_delay);
  19. PulsingBlockView(const PulsingBlockView&) = delete;
  20. PulsingBlockView& operator=(const PulsingBlockView&) = delete;
  21. ~PulsingBlockView() override;
  22. // views::View:
  23. const char* GetClassName() const override;
  24. void OnThemeChanged() override;
  25. // Returns true if the view has a layer animator attached and is currently
  26. // running.
  27. bool IsAnimating();
  28. // Starts the animation by immediately firing `start_delay_timer`. Returns
  29. // false if the timer was not running.
  30. bool FireAnimationTimerForTest();
  31. private:
  32. void OnStartDelayTimer();
  33. // views::View overrides:
  34. void OnPaint(gfx::Canvas* canvas) override;
  35. base::OneShotTimer start_delay_timer_;
  36. views::View* background_color_view_ = nullptr;
  37. const gfx::Size block_size_;
  38. };
  39. } // namespace ash
  40. #endif // ASH_APP_LIST_VIEWS_PULSING_BLOCK_VIEW_H_