autoclick_ring_handler.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // Copyright 2016 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_ACCESSIBILITY_AUTOCLICK_AUTOCLICK_RING_HANDLER_H_
  5. #define ASH_ACCESSIBILITY_AUTOCLICK_AUTOCLICK_RING_HANDLER_H_
  6. #include "base/time/time.h"
  7. #include "base/timer/timer.h"
  8. #include "ui/gfx/animation/linear_animation.h"
  9. #include "ui/gfx/geometry/point.h"
  10. #include "ui/views/widget/widget.h"
  11. namespace ash {
  12. // AutoclickRingHandler displays an animated affordance that is shown
  13. // on autoclick gesture. The animation is a semi-transparent ring which
  14. // fills with white.
  15. class AutoclickRingHandler : public gfx::LinearAnimation {
  16. public:
  17. AutoclickRingHandler();
  18. AutoclickRingHandler(const AutoclickRingHandler&) = delete;
  19. AutoclickRingHandler& operator=(const AutoclickRingHandler&) = delete;
  20. ~AutoclickRingHandler() override;
  21. void StartGesture(base::TimeDelta duration,
  22. const gfx::Point& center_point_in_screen,
  23. views::Widget* widget);
  24. void StopGesture();
  25. void SetGestureCenter(const gfx::Point& center_point_in_screen,
  26. views::Widget* widget);
  27. void SetSize(int radius);
  28. private:
  29. class AutoclickRingView;
  30. // The default values of the autoclick ring widget size.
  31. const int kAutoclickRingInnerRadius = 20;
  32. enum class AnimationType {
  33. NONE,
  34. GROW_ANIMATION,
  35. };
  36. void StartAnimation(base::TimeDelta duration);
  37. void StopAutoclickRing();
  38. // Overridden from gfx::LinearAnimation.
  39. void AnimateToState(double state) override;
  40. void AnimationStopped() override;
  41. AutoclickRingView* view_ = nullptr;
  42. views::Widget* ring_widget_ = nullptr;
  43. // Location of the simulated mouse event from auto click in screen
  44. // coordinates.
  45. gfx::Point tap_down_location_;
  46. AnimationType current_animation_type_ = AnimationType::NONE;
  47. base::TimeDelta animation_duration_;
  48. int radius_ = kAutoclickRingInnerRadius;
  49. };
  50. } // namespace ash
  51. #endif // ASH_ACCESSIBILITY_AUTOCLICK_AUTOCLICK_RING_HANDLER_H_