OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef ATHENA_INPUT_PUBLIC_ACCELERATOR_MANAGER_H_ | 5 #ifndef ATHENA_INPUT_PUBLIC_ACCELERATOR_MANAGER_H_ |
6 #define ATHENA_INPUT_PUBLIC_ACCELERATOR_MANAGER_H_ | 6 #define ATHENA_INPUT_PUBLIC_ACCELERATOR_MANAGER_H_ |
7 | 7 |
8 #include "athena/athena_export.h" | 8 #include "athena/athena_export.h" |
| 9 #include "base/memory/scoped_ptr.h" |
9 #include "ui/events/keycodes/keyboard_codes.h" | 10 #include "ui/events/keycodes/keyboard_codes.h" |
10 | 11 |
11 namespace ui { | 12 namespace ui { |
12 class Accelerator; | 13 class Accelerator; |
13 } | 14 } |
14 | 15 |
| 16 namespace views { |
| 17 class FocusManager; |
| 18 } |
| 19 |
15 namespace athena { | 20 namespace athena { |
16 | 21 |
17 enum TriggerEvent { | 22 enum TriggerEvent { |
18 TRIGGER_ON_PRESS, | 23 TRIGGER_ON_PRESS, |
19 TRIGGER_ON_RELEASE, | 24 TRIGGER_ON_RELEASE, |
20 }; | 25 }; |
21 | 26 |
22 // Accelerator flags. | 27 // Accelerator flags. |
23 enum AcceleratorFlags { | 28 enum AcceleratorFlags { |
24 AF_NONE = 0, | 29 AF_NONE = 0, |
(...skipping 21 matching lines...) Expand all Loading... |
46 // accelerators. | 51 // accelerators. |
47 class ATHENA_EXPORT AcceleratorHandler { | 52 class ATHENA_EXPORT AcceleratorHandler { |
48 public: | 53 public: |
49 virtual ~AcceleratorHandler() {} | 54 virtual ~AcceleratorHandler() {} |
50 | 55 |
51 virtual bool IsCommandEnabled(int command_id) const = 0; | 56 virtual bool IsCommandEnabled(int command_id) const = 0; |
52 virtual bool OnAcceleratorFired(int command_id, | 57 virtual bool OnAcceleratorFired(int command_id, |
53 const ui::Accelerator& accelerator) = 0; | 58 const ui::Accelerator& accelerator) = 0; |
54 }; | 59 }; |
55 | 60 |
56 class AcceleratorManager { | 61 class ATHENA_EXPORT AcceleratorManager { |
57 public: | 62 public: |
| 63 // Returns an AccelerarManager for global acelerators. |
58 static AcceleratorManager* Get(); | 64 static AcceleratorManager* Get(); |
59 | 65 |
| 66 // Creates an AcceleratorManager for application windows that |
| 67 // define their own accelerators. |
| 68 static scoped_ptr<AcceleratorManager> CreateForFocusManager( |
| 69 views::FocusManager* focus_manager); |
| 70 |
60 virtual ~AcceleratorManager() {} | 71 virtual ~AcceleratorManager() {} |
61 | 72 |
| 73 // Tells if the accelerator is registered with the given flag. If |
| 74 // flags is AF_NONE, it simply tells if the accelerator is |
| 75 // registered with any flags. |
| 76 virtual bool IsRegistered(const ui::Accelerator& accelerator, |
| 77 int flags) const = 0; |
| 78 |
62 // Register accelerators and its handler that will be invoked when | 79 // Register accelerators and its handler that will be invoked when |
63 // one of accelerator is fired. | 80 // one of accelerator is fired. |
64 virtual void RegisterAccelerators(const AcceleratorData accelerators[], | 81 virtual void RegisterAccelerators(const AcceleratorData accelerators[], |
65 size_t num_accelerators, | 82 size_t num_accelerators, |
66 AcceleratorHandler* handler) = 0; | 83 AcceleratorHandler* handler) = 0; |
67 | 84 |
68 // Enables/Disables accelerators that has a AF_DEBUG flag. | 85 // Enables/Disables accelerators that has a AF_DEBUG flag. |
69 virtual void SetDebugAcceleratorsEnabled(bool enabled) = 0; | 86 virtual void SetDebugAcceleratorsEnabled(bool enabled) = 0; |
70 }; | 87 }; |
71 | 88 |
72 } // namespace athena | 89 } // namespace athena |
73 | 90 |
74 #endif // ATHENA_INPUT_PUBLIC_ACCELERATOR_MANAGER_H_ | 91 #endif // ATHENA_INPUT_PUBLIC_ACCELERATOR_MANAGER_H_ |
OLD | NEW |