ScummVM API documentation
remap-widget.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef REMAP_WIDGET_H
23 #define REMAP_WIDGET_H
24 
25 #include "common/scummsys.h"
26 #include "common/hash-ptr.h"
27 
28 #include "gui/widget.h"
29 
30 namespace GUI {
31 class ButtonWidget;
32 class DropdownButtonWidget;
33 class PopUpWidget;
34 class ScrollContainerWidget;
35 class StaticTextWidget;
36 }
37 
38 namespace Common {
39 
40 struct Action;
41 class Keymap;
42 class Keymapper;
43 class InputWatcher;
44 
46 public:
48 
49  RemapWidget(GuiObject *boss, const Common::String &name, const KeymapArray &keymaps);
50  ~RemapWidget() override;
51  void load() override;
52  bool save() override;
53  void handleInputChanged();
54  void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) override;
55  void handleMouseDown(int x, int y, int button, int clickCount) override;
56  void handleTickle() override;
57 
58 protected:
59  struct ActionRow {
60  Keymap *keymap;
61  Common::Action *action;
62 
63  GUI::StaticTextWidget *actionText;
64  GUI::DropdownButtonWidget *keyButton;
65 
66  ActionRow() : keymap(nullptr), action(nullptr), actionText(nullptr), keyButton(nullptr) {}
67  };
68 
69  struct KeymapTitleRow {
70  GUI::StaticTextWidget *descriptionText;
71  GUI::ButtonWidget *resetButton;
72 
73  KeymapTitleRow() : descriptionText(nullptr), resetButton(nullptr) {}
74  };
75 
76  void loadKeymap();
77  void refreshKeymap();
78  void reflowActionWidgets();
79  void clearMapping(uint actionIndex);
80  void resetMapping(uint actionIndex);
81  void resetKeymap(uint actionIndex);
82  void startRemapping(uint actionIndex);
83  void stopRemapping();
84 
85  KeymapArray _keymapTable;
86 
87  InputWatcher *_remapInputWatcher;
88  Keymap *_remapKeymap;
89  Action *_remapAction;
90  uint32 _remapTimeout;
91 
92  static const uint32 kRemapMinTimeoutDelay = 3000;
93 
94  bool _changes;
95 
96  Array<ActionRow> _actions;
97  HashMap<Keymap *, KeymapTitleRow> _keymapSeparators;
98 };
99 
100 } // End of namespace Common
101 
102 #endif // #ifndef REMAP_WIDGET_H
Definition: keymap.h:66
Definition: remap-widget.h:59
Definition: str.h:59
Definition: remap-widget.h:69
Definition: action.h:41
Definition: remap-widget.h:45
Definition: widget.h:204
Definition: system.h:45
Definition: widget.h:528
Definition: hashmap.h:85
Definition: algorithm.h:29
Definition: widget.h:268
Definition: widget.h:231
Definition: input-watcher.h:43
Definition: object.h:40