Debian Codegraph @

plugins/dm.stimresponse/EffectEditor.h

raw
1 #pragma once
2
3 #include "wxutil/dialog/DialogBase.h"
4
5 #include "StimResponse.h"
6 #include "ResponseEffectTypes.h"
7 #include "EffectArgumentItem.h"
8 #include <memory>
9 #include <wx/arrstr.h>
10
11 class wxCheckBox;
12 class wxFlexGridSizer;
13
14 namespace ui
15 {
16
17 class ResponseEditor;
18
19 class EffectEditor :
20 public wxutil::DialogBase
21 {
22 private:
23 wxFlexGridSizer* _argTable;
24
25 // The list containing the possible effect types
26 ResponseEffectTypeMap _effectTypes;
27
28 wxChoice* _effectTypeCombo;
29
30 // The list of argument items
31 typedef std::shared_ptr<EffectArgumentItem> ArgumentItemPtr;
32 typedef std::vector<ArgumentItemPtr> ArgumentItemList;
33 ArgumentItemList _argumentItems;
34
35 wxCheckBox* _stateToggle;
36
37 // The references to the object we're editing here
38 StimResponse& _response;
39 unsigned int _effectIndex;
40
41 // The saved StimResponse to revert the changes on cancel
42 ResponseEffect _backup;
43
44 // For calling update() when finished editing
45 ResponseEditor& _editor;
46
47 StimTypes& _stimTypes;
48
49 wxArrayString _entityChoices;
50
51 public:
52 /** greebo: Constructor, needs information about parent and the edit target.
53 *
54 * @parent: The parent this window is child of.
55 *
56 * @response: The Stim/Response object the effect is associated with
57 * (this should be a response, although stims work as well).
58 *
59 * @effectIndex: The response effect index within the given Response.
60 *
61 * @stimTypes: The StimTypes helper class
62 *
63 * @editor: The ResponseEditor for calling update() on exit.
64 */
65 EffectEditor(wxWindow* parent,
66 StimResponse& response,
67 const unsigned int effectIndex,
68 StimTypes& stimTypes,
69 ResponseEditor& editor);
70
71 /** greebo: Creates the widgets
72 */
73 void populateWindow();
74
75 int ShowModal();
76
77 private:
78 /** greebo: Reverts the changes and loads the values from the
79 * backup effect object into the edited one.
80 */
81 void revert();
82
83 /** greebo: Gets called on effect type changes to update the argument
84 * widgets accordingly.
85 */
86 void effectTypeChanged();
87
88 /** greebo: Populate the entity list store by traversing the
89 * scene graph searching for entities. The names of
90 * the entities are stored into the member _entityStore
91 */
92 void populateEntityListStore();
93
94 /** greebo: Saves the widget contents into the arguments.
95 */
96 void save();
97
98 /** greebo: Parses the response effect for necessary arguments
99 * and creates the according widgets.
100 */
101 void createArgumentWidgets(ResponseEffect& effect);
102
103 void onEffectTypeChange(wxCommandEvent& ev);
104 void onStateToggle(wxCommandEvent& ev);
105 };
106
107 } // namespace ui