| 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 ASH_MAGNIFIER_MAGNIFIER_KEY_SCROLLER_H_ | |
| 6 #define ASH_MAGNIFIER_MAGNIFIER_KEY_SCROLLER_H_ | |
| 7 | |
| 8 #include "ash/ash_export.h" | |
| 9 #include "ui/events/event_handler.h" | |
| 10 | |
| 11 namespace ui { | |
| 12 class KeyEvent; | |
| 13 } | |
| 14 | |
| 15 namespace ash { | |
| 16 | |
| 17 // This class implements the press and hold key-bindings (shift-arrow keys) | |
| 18 // to control magnified screen. | |
| 19 class ASH_EXPORT MagnifierKeyScroller : public ui::EventHandler { | |
| 20 public: | |
| 21 static bool IsEnabled(); | |
| 22 static void SetEnabled(bool enabled); | |
| 23 | |
| 24 MagnifierKeyScroller(); | |
| 25 virtual ~MagnifierKeyScroller(); | |
| 26 | |
| 27 // ui::EventHandler overrides: | |
| 28 virtual void OnKeyEvent(ui::KeyEvent* key_event) OVERRIDE; | |
| 29 | |
| 30 // A scoped object to enable and disable the magnifier accelerator for test. | |
| 31 class ScopedEnablerForTest { | |
| 32 public: | |
| 33 ScopedEnablerForTest() { | |
| 34 SetEnabled(true); | |
| 35 } | |
| 36 ~ScopedEnablerForTest() { | |
| 37 SetEnabled(false); | |
| 38 } | |
| 39 | |
| 40 private: | |
| 41 DISALLOW_COPY_AND_ASSIGN(ScopedEnablerForTest); | |
| 42 }; | |
| 43 | |
| 44 private: | |
| 45 // A state to keep track of one click and click and hold operation. | |
| 46 // | |
| 47 // One click: | |
| 48 // INITIAL --(first press)--> PRESSED --(release)--> INITIAL[SEND PRESS] | |
| 49 // | |
| 50 // Click and hold: | |
| 51 // INITIAL --(first press)--> PRESSED --(press)--> | |
| 52 // HOLD[scroll] --(press)--> HOLD[scroll] --(release)--> | |
| 53 // INITIAL[stop scroll] | |
| 54 enum State { | |
| 55 INITIAL, | |
| 56 PRESSED, | |
| 57 HOLD | |
| 58 }; | |
| 59 | |
| 60 State state_; | |
| 61 | |
| 62 DISALLOW_COPY_AND_ASSIGN(MagnifierKeyScroller); | |
| 63 }; | |
| 64 | |
| 65 } // namespace ash | |
| 66 | |
| 67 #endif // ASH_MAGNIFIER_MAGNIFIER_KEY_SCROLLER_H_ | |
| OLD | NEW |