[email protected] | 99b6ee4 | 2014-01-16 23:51:28 | [diff] [blame] | 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 ASH_STICKY_KEYS_STICKY_KEYS_OVERLAY_H_ |
| 6 | #define ASH_STICKY_KEYS_STICKY_KEYS_OVERLAY_H_ |
| 7 | |
dcheng | a9454747 | 2016-04-08 08:41:11 | [diff] [blame] | 8 | #include <memory> |
| 9 | |
[email protected] | 99b6ee4 | 2014-01-16 23:51:28 | [diff] [blame] | 10 | #include "ash/ash_export.h" |
| 11 | #include "ash/sticky_keys/sticky_keys_state.h" |
[email protected] | 99b6ee4 | 2014-01-16 23:51:28 | [diff] [blame] | 12 | #include "ui/compositor/layer_animation_observer.h" |
| 13 | #include "ui/events/event_constants.h" |
| 14 | #include "ui/gfx/geometry/size.h" |
| 15 | |
| 16 | namespace gfx { |
| 17 | class Rect; |
| 18 | } |
| 19 | |
| 20 | namespace views { |
| 21 | class Widget; |
| 22 | } |
| 23 | |
| 24 | namespace ash { |
| 25 | |
| 26 | class StickyKeysOverlayView; |
| 27 | |
| 28 | // Controls the overlay UI for sticky keys, an accessibility feature allowing |
| 29 | // use of modifier keys without holding them down. This overlay will appear as |
| 30 | // a transparent window on the top left of the screen, showing the state of |
| 31 | // each sticky key modifier. |
| 32 | class ASH_EXPORT StickyKeysOverlay : public ui::LayerAnimationObserver { |
| 33 | public: |
| 34 | StickyKeysOverlay(); |
dcheng | 1f4538e | 2014-10-27 23:57:05 | [diff] [blame] | 35 | ~StickyKeysOverlay() override; |
[email protected] | 99b6ee4 | 2014-01-16 23:51:28 | [diff] [blame] | 36 | |
| 37 | // Shows or hides the overlay. |
| 38 | void Show(bool visible); |
| 39 | |
[email protected] | 1488a035f | 2014-03-28 21:12:07 | [diff] [blame] | 40 | void SetModifierVisible(ui::EventFlags modifier, bool visible); |
| 41 | |
[email protected] | 25de8a1 | 2014-04-10 02:06:10 | [diff] [blame] | 42 | bool GetModifierVisible(ui::EventFlags modifier); |
| 43 | |
[email protected] | 99b6ee4 | 2014-01-16 23:51:28 | [diff] [blame] | 44 | // Updates the overlay with the current state of a sticky key modifier. |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 45 | void SetModifierKeyState(ui::EventFlags modifier, StickyKeyState state); |
[email protected] | 99b6ee4 | 2014-01-16 23:51:28 | [diff] [blame] | 46 | |
| 47 | // Get the current state of the sticky key modifier in the overlay. |
| 48 | StickyKeyState GetModifierKeyState(ui::EventFlags modifier); |
| 49 | |
| 50 | // Returns true if the overlay is currently visible. If the overlay is |
| 51 | // animating, the returned value is the target of the animation. |
| 52 | bool is_visible() { return is_visible_; } |
| 53 | |
tengs | f98986c | 2014-12-06 01:42:21 | [diff] [blame] | 54 | // Returns the underlying views::Widget for testing purposes. The returned |
| 55 | // widget is owned by StickyKeysOverlay. |
| 56 | views::Widget* GetWidgetForTesting(); |
| 57 | |
[email protected] | 99b6ee4 | 2014-01-16 23:51:28 | [diff] [blame] | 58 | private: |
| 59 | // Returns the current bounds of the overlay, which is based on visibility. |
| 60 | gfx::Rect CalculateOverlayBounds(); |
| 61 | |
| 62 | // gfx::LayerAnimationObserver overrides: |
dcheng | 1f4538e | 2014-10-27 23:57:05 | [diff] [blame] | 63 | void OnLayerAnimationEnded(ui::LayerAnimationSequence* sequence) override; |
| 64 | void OnLayerAnimationAborted(ui::LayerAnimationSequence* sequence) override; |
| 65 | void OnLayerAnimationScheduled(ui::LayerAnimationSequence* sequence) override; |
[email protected] | 99b6ee4 | 2014-01-16 23:51:28 | [diff] [blame] | 66 | |
| 67 | bool is_visible_; |
dcheng | a9454747 | 2016-04-08 08:41:11 | [diff] [blame] | 68 | std::unique_ptr<views::Widget> overlay_widget_; |
| 69 | std::unique_ptr<StickyKeysOverlayView> overlay_view_; |
[email protected] | 99b6ee4 | 2014-01-16 23:51:28 | [diff] [blame] | 70 | gfx::Size widget_size_; |
| 71 | }; |
| 72 | |
| 73 | } // namespace ash |
| 74 | |
| 75 | #endif // ASH_STICKY_KEYS_STICKY_KEYS_OVERLAY_H_ |