Chromium Code Reviews| 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/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "chrome/browser/chromeos/ui/accessibility_cursor_ring_layer.h" | 15 #include "chrome/browser/chromeos/ui/accessibility_cursor_ring_layer.h" |
| 16 #include "chrome/browser/chromeos/ui/accessibility_focus_ring_layer.h" | 16 #include "chrome/browser/chromeos/ui/accessibility_focus_ring_layer.h" |
| 17 #include "third_party/skia/include/core/SkColor.h" | |
| 17 #include "ui/gfx/geometry/rect.h" | 18 #include "ui/gfx/geometry/rect.h" |
| 18 | 19 |
| 19 namespace chromeos { | 20 namespace chromeos { |
| 20 | 21 |
| 21 // AccessibilityFocusRingController handles drawing custom rings around | 22 // AccessibilityFocusRingController handles drawing custom rings around |
| 22 // the focused object, cursor, and/or caret for accessibility. | 23 // the focused object, cursor, and/or caret for accessibility. |
| 23 class AccessibilityFocusRingController : public FocusRingLayerDelegate { | 24 class AccessibilityFocusRingController : public FocusRingLayerDelegate { |
| 24 public: | 25 public: |
| 25 // Get the single instance of this class. | 26 // Get the single instance of this class. |
| 26 static AccessibilityFocusRingController* GetInstance(); | 27 static AccessibilityFocusRingController* GetInstance(); |
| 27 | 28 |
| 28 enum FocusRingBehavior { FADE_OUT_FOCUS_RING, PERSIST_FOCUS_RING }; | 29 enum FocusRingBehavior { FADE_OUT_FOCUS_RING, PERSIST_FOCUS_RING }; |
| 29 | 30 |
| 31 // Set the focus ring color, or reset it back to the default. | |
| 32 void SetFocusRingColor(SkColor color); | |
| 33 void ResetFocusRingColor(); | |
| 34 | |
| 30 // Draw a focus ring around the given set of rects, in global screen | 35 // Draw a focus ring around the given set of rects, in global screen |
| 31 // coordinates. Use |focus_ring_behavior| to specify whether the focus | 36 // coordinates. Use |focus_ring_behavior| to specify whether the focus |
| 32 // ring should persist or fade out. | 37 // ring should persist or fade out. |
| 33 void SetFocusRing(const std::vector<gfx::Rect>& rects, | 38 void SetFocusRing(const std::vector<gfx::Rect>& rects, |
| 34 FocusRingBehavior focus_ring_behavior); | 39 FocusRingBehavior focus_ring_behavior); |
| 35 void HideFocusRing(); | 40 void HideFocusRing(); |
| 36 | 41 |
| 37 // Draw a ring around the mouse cursor. It fades out automatically. | 42 // Draw a ring around the mouse cursor. It fades out automatically. |
| 38 void SetCursorRing(const gfx::Point& location); | 43 void SetCursorRing(const gfx::Point& location); |
| 39 void HideCursorRing(); | 44 void HideCursorRing(); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 void OnLayerChange(LayerAnimationInfo* animation_info); | 98 void OnLayerChange(LayerAnimationInfo* animation_info); |
| 94 void ComputeOpacity(LayerAnimationInfo* animation_info, | 99 void ComputeOpacity(LayerAnimationInfo* animation_info, |
| 95 base::TimeTicks timestamp); | 100 base::TimeTicks timestamp); |
| 96 | 101 |
| 97 LayerAnimationInfo focus_animation_info_; | 102 LayerAnimationInfo focus_animation_info_; |
| 98 std::vector<gfx::Rect> focus_rects_; | 103 std::vector<gfx::Rect> focus_rects_; |
| 99 std::vector<AccessibilityFocusRing> previous_focus_rings_; | 104 std::vector<AccessibilityFocusRing> previous_focus_rings_; |
| 100 std::vector<AccessibilityFocusRing> focus_rings_; | 105 std::vector<AccessibilityFocusRing> focus_rings_; |
| 101 std::vector<std::unique_ptr<AccessibilityFocusRingLayer>> focus_layers_; | 106 std::vector<std::unique_ptr<AccessibilityFocusRingLayer>> focus_layers_; |
| 102 FocusRingBehavior focus_ring_behavior_ = FADE_OUT_FOCUS_RING; | 107 FocusRingBehavior focus_ring_behavior_ = FADE_OUT_FOCUS_RING; |
| 108 bool has_focus_ring_color_ = false; | |
|
Devlin
2017/03/30 21:58:05
Drive-by: if you use a base::Optional<SkColor> for
dmazzoni
2017/03/31 20:24:05
Good idea! That's definitely cleaner.
| |
| 109 SkColor focus_ring_color_ = SK_ColorBLACK; | |
| 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 |