OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_UI_ACCESSIBILITY_FOCUS_RING_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_UI_ACCESSIBILITY_FOCUS_RING_CONTROLLER_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/singleton.h" |
| 11 #include "chrome/browser/chromeos/ui/accessibility_focus_ring_layer.h" |
| 12 #include "ui/gfx/rect.h" |
| 13 |
| 14 namespace chromeos { |
| 15 |
| 16 // AccessibilityFocusRingController manages a custom focus ring (or multiple |
| 17 // rings) for accessibility. |
| 18 class AccessibilityFocusRingController : public FocusRingLayerDelegate { |
| 19 public: |
| 20 // Get the single instance of this class. |
| 21 static AccessibilityFocusRingController* GetInstance(); |
| 22 |
| 23 // Draw a focus ring around the given set of rects, in global screen |
| 24 // coordinates. |
| 25 void SetFocusRing(const std::vector<gfx::Rect>& rects); |
| 26 |
| 27 protected: |
| 28 AccessibilityFocusRingController(); |
| 29 virtual ~AccessibilityFocusRingController(); |
| 30 |
| 31 // Given an unordered vector of bounding rectangles that cover everything |
| 32 // that currently has focus, populate a vector of one or more |
| 33 // AccessibilityFocusRings that surround the rectangles. Adjacent or |
| 34 // overlapping rectangles are combined first. This function is protected |
| 35 // so it can be unit-tested. |
| 36 void RectsToRings(const std::vector<gfx::Rect>& rects, |
| 37 std::vector<AccessibilityFocusRing>* rings) const; |
| 38 |
| 39 virtual int GetMargin() const; |
| 40 |
| 41 private: |
| 42 // FocusRingLayerDelegate. |
| 43 virtual void OnDeviceScaleFactorChanged() OVERRIDE; |
| 44 |
| 45 void Update(); |
| 46 |
| 47 AccessibilityFocusRing RingFromSortedRects( |
| 48 const std::vector<gfx::Rect>& rects) const; |
| 49 void SplitIntoParagraphShape( |
| 50 const std::vector<gfx::Rect>& rects, |
| 51 gfx::Rect* top, |
| 52 gfx::Rect* middle, |
| 53 gfx::Rect* bottom) const; |
| 54 bool Intersects(const gfx::Rect& r1, const gfx::Rect& r2) const; |
| 55 |
| 56 std::vector<gfx::Rect> rects_; |
| 57 std::vector<AccessibilityFocusRing> rings_; |
| 58 scoped_ptr<AccessibilityFocusRingLayer> main_focus_ring_layer_; |
| 59 std::vector<scoped_ptr<AccessibilityFocusRingLayer> > extra_layers_; |
| 60 |
| 61 friend struct DefaultSingletonTraits<AccessibilityFocusRingController>; |
| 62 |
| 63 DISALLOW_COPY_AND_ASSIGN(AccessibilityFocusRingController); |
| 64 }; |
| 65 |
| 66 } // namespace chromeos |
| 67 |
| 68 #endif // CHROME_BROWSER_CHROMEOS_UI_ACCESSIBILITY_FOCUS_RING_CONTROLLER_H_ |
OLD | NEW |