blob: ebfef9016b58b556af62fd0f57f2263082b7cb8e [file] [log] [blame]
[email protected]99b6ee42014-01-16 23:51:281// 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
dchenga94547472016-04-08 08:41:118#include <memory>
9
[email protected]99b6ee42014-01-16 23:51:2810#include "ash/ash_export.h"
11#include "ash/sticky_keys/sticky_keys_state.h"
[email protected]99b6ee42014-01-16 23:51:2812#include "ui/compositor/layer_animation_observer.h"
13#include "ui/events/event_constants.h"
14#include "ui/gfx/geometry/size.h"
15
16namespace gfx {
17class Rect;
18}
19
20namespace views {
21class Widget;
22}
23
24namespace ash {
25
26class 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.
32class ASH_EXPORT StickyKeysOverlay : public ui::LayerAnimationObserver {
33 public:
34 StickyKeysOverlay();
dcheng1f4538e2014-10-27 23:57:0535 ~StickyKeysOverlay() override;
[email protected]99b6ee42014-01-16 23:51:2836
37 // Shows or hides the overlay.
38 void Show(bool visible);
39
[email protected]1488a035f2014-03-28 21:12:0740 void SetModifierVisible(ui::EventFlags modifier, bool visible);
41
[email protected]25de8a12014-04-10 02:06:1042 bool GetModifierVisible(ui::EventFlags modifier);
43
[email protected]99b6ee42014-01-16 23:51:2844 // Updates the overlay with the current state of a sticky key modifier.
jamescookb8dcef522016-06-25 14:42:5545 void SetModifierKeyState(ui::EventFlags modifier, StickyKeyState state);
[email protected]99b6ee42014-01-16 23:51:2846
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
tengsf98986c2014-12-06 01:42:2154 // Returns the underlying views::Widget for testing purposes. The returned
55 // widget is owned by StickyKeysOverlay.
56 views::Widget* GetWidgetForTesting();
57
[email protected]99b6ee42014-01-16 23:51:2858 private:
59 // Returns the current bounds of the overlay, which is based on visibility.
60 gfx::Rect CalculateOverlayBounds();
61
62 // gfx::LayerAnimationObserver overrides:
dcheng1f4538e2014-10-27 23:57:0563 void OnLayerAnimationEnded(ui::LayerAnimationSequence* sequence) override;
64 void OnLayerAnimationAborted(ui::LayerAnimationSequence* sequence) override;
65 void OnLayerAnimationScheduled(ui::LayerAnimationSequence* sequence) override;
[email protected]99b6ee42014-01-16 23:51:2866
67 bool is_visible_;
dchenga94547472016-04-08 08:41:1168 std::unique_ptr<views::Widget> overlay_widget_;
69 std::unique_ptr<StickyKeysOverlayView> overlay_view_;
[email protected]99b6ee42014-01-16 23:51:2870 gfx::Size widget_size_;
71};
72
73} // namespace ash
74
75#endif // ASH_STICKY_KEYS_STICKY_KEYS_OVERLAY_H_