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 ATHENA_INPUT_PUBLIC_ACCELERATOR_MANAGER_H_ |
| 6 #define ATHENA_INPUT_PUBLIC_ACCELERATOR_MANAGER_H_ |
| 7 |
| 8 #include "athena/athena_export.h" |
| 9 #include "ui/events/keycodes/keyboard_codes.h" |
| 10 |
| 11 namespace ui { |
| 12 class Accelerator; |
| 13 } |
| 14 |
| 15 namespace athena { |
| 16 |
| 17 enum TriggerEvent { |
| 18 TRIGGER_ON_PRESS, |
| 19 TRIGGER_ON_RELEASE, |
| 20 }; |
| 21 |
| 22 // Accelerator flags. |
| 23 enum AcceleratorFlags { |
| 24 AF_NONE = 0, |
| 25 // Used for accelerators that should not be fired on auto repeated |
| 26 // key event, such as toggling fullscrren. |
| 27 AF_NON_AUTO_REPEATABLE = 1 << 0, |
| 28 // Most key events are sent to applications first as they may |
| 29 // want to consume them. Reserverd accelerators are reserved for OS |
| 30 // and cannot be consumed by apps. (such as window cycling) |
| 31 AF_RESERVED = 1 << 1, |
| 32 // Used for accelerators that are useful only in debug mode. |
| 33 AF_DEBUG = 1 << 2, |
| 34 }; |
| 35 |
| 36 struct AcceleratorData { |
| 37 // true if the accelerator should be triggered upon ui::ET_KEY_PRESSED |
| 38 TriggerEvent trigger_event; |
| 39 ui::KeyboardCode keycode; // KeyEvent event flags. |
| 40 int keyevent_flags; // Combination of ui::KeyEventFlags |
| 41 int command_id; // ID to distinguish |
| 42 int accelerator_flags; // Combination of AcceleratorFlags; |
| 43 }; |
| 44 |
| 45 // An interface that implements behavior for the set of |
| 46 // accelerators. |
| 47 class ATHENA_EXPORT AcceleratorHandler { |
| 48 public: |
| 49 virtual ~AcceleratorHandler() {} |
| 50 |
| 51 virtual bool IsCommandEnabled(int command_id) const = 0; |
| 52 virtual bool OnAcceleratorFired(int command_id, |
| 53 const ui::Accelerator& accelerator) = 0; |
| 54 }; |
| 55 |
| 56 class AcceleratorManager { |
| 57 public: |
| 58 virtual ~AcceleratorManager() {} |
| 59 |
| 60 // Register accelerators and its handler that will be invoked when |
| 61 // one of accelerator is fired. |
| 62 virtual void RegisterAccelerators(const AcceleratorData accelerators[], |
| 63 size_t num_accelerators, |
| 64 AcceleratorHandler* handler) = 0; |
| 65 |
| 66 // Enables accelerators that has a AF_DEBUG flag. |
| 67 virtual void EnableDebugAccelerators() = 0; |
| 68 }; |
| 69 |
| 70 } // namespace athena |
| 71 |
| 72 #endif // ATHENA_INPUT_PUBLIC_ACCELERATOR_MANAGER_H_ |
OLD | NEW |