| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_UI_ACCESSIBILITY_FOCUS_RING_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_UI_ACCESSIBILITY_FOCUS_RING_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_UI_ACCESSIBILITY_FOCUS_RING_CONTROLLER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_UI_ACCESSIBILITY_FOCUS_RING_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
| 14 #include "base/optional.h" |
| 14 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 15 #include "chrome/browser/chromeos/ui/accessibility_cursor_ring_layer.h" | 16 #include "chrome/browser/chromeos/ui/accessibility_cursor_ring_layer.h" |
| 16 #include "chrome/browser/chromeos/ui/accessibility_focus_ring_layer.h" | 17 #include "chrome/browser/chromeos/ui/accessibility_focus_ring_layer.h" |
| 18 #include "third_party/skia/include/core/SkColor.h" |
| 17 #include "ui/gfx/geometry/rect.h" | 19 #include "ui/gfx/geometry/rect.h" |
| 18 | 20 |
| 19 namespace chromeos { | 21 namespace chromeos { |
| 20 | 22 |
| 21 // AccessibilityFocusRingController handles drawing custom rings around | 23 // AccessibilityFocusRingController handles drawing custom rings around |
| 22 // the focused object, cursor, and/or caret for accessibility. | 24 // the focused object, cursor, and/or caret for accessibility. |
| 23 class AccessibilityFocusRingController : public FocusRingLayerDelegate { | 25 class AccessibilityFocusRingController : public FocusRingLayerDelegate { |
| 24 public: | 26 public: |
| 25 // Get the single instance of this class. | 27 // Get the single instance of this class. |
| 26 static AccessibilityFocusRingController* GetInstance(); | 28 static AccessibilityFocusRingController* GetInstance(); |
| 27 | 29 |
| 28 enum FocusRingBehavior { FADE_OUT_FOCUS_RING, PERSIST_FOCUS_RING }; | 30 enum FocusRingBehavior { FADE_OUT_FOCUS_RING, PERSIST_FOCUS_RING }; |
| 29 | 31 |
| 32 // Set the focus ring color, or reset it back to the default. |
| 33 void SetFocusRingColor(SkColor color); |
| 34 void ResetFocusRingColor(); |
| 35 |
| 30 // Draw a focus ring around the given set of rects, in global screen | 36 // Draw a focus ring around the given set of rects, in global screen |
| 31 // coordinates. Use |focus_ring_behavior| to specify whether the focus | 37 // coordinates. Use |focus_ring_behavior| to specify whether the focus |
| 32 // ring should persist or fade out. | 38 // ring should persist or fade out. |
| 33 void SetFocusRing(const std::vector<gfx::Rect>& rects, | 39 void SetFocusRing(const std::vector<gfx::Rect>& rects, |
| 34 FocusRingBehavior focus_ring_behavior); | 40 FocusRingBehavior focus_ring_behavior); |
| 35 void HideFocusRing(); | 41 void HideFocusRing(); |
| 36 | 42 |
| 37 // Draw a ring around the mouse cursor. It fades out automatically. | 43 // Draw a ring around the mouse cursor. It fades out automatically. |
| 38 void SetCursorRing(const gfx::Point& location); | 44 void SetCursorRing(const gfx::Point& location); |
| 39 void HideCursorRing(); | 45 void HideCursorRing(); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 void OnLayerChange(LayerAnimationInfo* animation_info); | 99 void OnLayerChange(LayerAnimationInfo* animation_info); |
| 94 void ComputeOpacity(LayerAnimationInfo* animation_info, | 100 void ComputeOpacity(LayerAnimationInfo* animation_info, |
| 95 base::TimeTicks timestamp); | 101 base::TimeTicks timestamp); |
| 96 | 102 |
| 97 LayerAnimationInfo focus_animation_info_; | 103 LayerAnimationInfo focus_animation_info_; |
| 98 std::vector<gfx::Rect> focus_rects_; | 104 std::vector<gfx::Rect> focus_rects_; |
| 99 std::vector<AccessibilityFocusRing> previous_focus_rings_; | 105 std::vector<AccessibilityFocusRing> previous_focus_rings_; |
| 100 std::vector<AccessibilityFocusRing> focus_rings_; | 106 std::vector<AccessibilityFocusRing> focus_rings_; |
| 101 std::vector<std::unique_ptr<AccessibilityFocusRingLayer>> focus_layers_; | 107 std::vector<std::unique_ptr<AccessibilityFocusRingLayer>> focus_layers_; |
| 102 FocusRingBehavior focus_ring_behavior_ = FADE_OUT_FOCUS_RING; | 108 FocusRingBehavior focus_ring_behavior_ = FADE_OUT_FOCUS_RING; |
| 109 base::Optional<SkColor> focus_ring_color_; |
| 103 | 110 |
| 104 LayerAnimationInfo cursor_animation_info_; | 111 LayerAnimationInfo cursor_animation_info_; |
| 105 gfx::Point cursor_location_; | 112 gfx::Point cursor_location_; |
| 106 std::unique_ptr<AccessibilityCursorRingLayer> cursor_layer_; | 113 std::unique_ptr<AccessibilityCursorRingLayer> cursor_layer_; |
| 107 | 114 |
| 108 LayerAnimationInfo caret_animation_info_; | 115 LayerAnimationInfo caret_animation_info_; |
| 109 gfx::Point caret_location_; | 116 gfx::Point caret_location_; |
| 110 std::unique_ptr<AccessibilityCursorRingLayer> caret_layer_; | 117 std::unique_ptr<AccessibilityCursorRingLayer> caret_layer_; |
| 111 | 118 |
| 112 friend struct base::DefaultSingletonTraits<AccessibilityFocusRingController>; | 119 friend struct base::DefaultSingletonTraits<AccessibilityFocusRingController>; |
| 113 | 120 |
| 114 DISALLOW_COPY_AND_ASSIGN(AccessibilityFocusRingController); | 121 DISALLOW_COPY_AND_ASSIGN(AccessibilityFocusRingController); |
| 115 }; | 122 }; |
| 116 | 123 |
| 117 } // namespace chromeos | 124 } // namespace chromeos |
| 118 | 125 |
| 119 #endif // CHROME_BROWSER_CHROMEOS_UI_ACCESSIBILITY_FOCUS_RING_CONTROLLER_H_ | 126 #endif // CHROME_BROWSER_CHROMEOS_UI_ACCESSIBILITY_FOCUS_RING_CONTROLLER_H_ |
| OLD | NEW |