/
ResponseEditor.h
138 lines (109 loc) · 3.31 KB
/
ResponseEditor.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#pragma once
#include "ClassEditor.h"
#include "wxutil/XmlResourceBasedWidget.h"
#include "wxutil/TreeView.h"
#include <memory>
namespace ui
{
class ResponseEditor :
public ClassEditor,
private wxutil::XmlResourceBasedWidget
{
private:
struct ListContextMenu
{
std::unique_ptr<wxMenu> menu;
wxMenuItem* remove;
wxMenuItem* add;
wxMenuItem* enable;
wxMenuItem* disable;
wxMenuItem* duplicate;
} _contextMenu;
struct EffectWidgets
{
wxutil::TreeView* view;
std::unique_ptr<wxMenu> contextMenu;
wxMenuItem* deleteMenuItem;
wxMenuItem* addMenuItem;
wxMenuItem* editMenuItem;
wxMenuItem* upMenuItem;
wxMenuItem* downMenuItem;
} _effectWidgets;
struct PropertyWidgets
{
wxCheckBox* active;
wxCheckBox* chanceToggle;
wxSpinCtrlDouble* chanceEntry;
wxCheckBox* randomEffectsToggle;
wxTextCtrl* randomEffectsEntry;
} _propertyWidgets;
wxWindow* _mainPanel;
public:
// Constructor is setting up the response edit controls
ResponseEditor(wxWindow* mainPanel, StimTypes& stimTypes);
/** greebo: Sets the new entity (updates the treeviews)
*/
virtual void setEntity(const SREntityPtr& entity) override;
/** greebo: Updates the widgets (e.g. after a selection change)
*/
void update() override;
void reloadStimTypes();
private:
/** greebo: Updates the associated text fields when a check box
* is toggled.
*/
void checkBoxToggled(wxCheckBox* toggleButton) override;
/** greebo: Adds a new response effect to the list.
*/
void addEffect();
/** greebo: Removes the currently selected response effect
*/
void removeEffect();
/** greebo: Edits the currently selected effect
*/
void editEffect();
/** greebo: Moves the selected effect up or down (i.e. increasing
* or decreasing its index).
*
* @direction: +1 for moving it down (increasing the index)
* -1 for moving it up (decreasing the index)
*/
void moveEffect(int direction);
/** greebo: Updates the sensitivity of the effects context menu
*/
void updateEffectContextMenu();
/** greebo: Selects the effect with the given index in the treeview.
*/
void selectEffectIndex(const unsigned int index);
/** greebo: Returns the ID of the currently selected response effect
*
* @returns: the index of the selected effect or -1 on failure
*/
int getEffectIdFromSelection();
/** greebo: Adds a new default response to the entity
*/
void addSR() override;
// Widget creator helpers
void createContextMenu();
void createEffectWidgets(); // Response effect list
/** greebo: Gets called when the response selection gets changed
*/
virtual void selectionChanged() override;
void openSRListContextMenu() override;
void setupPage();
// Context menu callbacks
void onContextMenuAdd(wxCommandEvent& ev);
void onContextMenuDelete(wxCommandEvent& ev);
void onEffectMenuDelete(wxCommandEvent& ev);
void onEffectMenuEdit(wxCommandEvent& ev);
void onEffectMenuAdd(wxCommandEvent& ev);
void onEffectMenuEffectUp(wxCommandEvent& ev);
void onEffectMenuEffectDown(wxCommandEvent& ev);
// To catch double-clicks in the response effect list
void onEffectItemActivated(wxDataViewEvent& ev);
// Context menu handler for effects view
void onEffectItemContextMenu(wxDataViewEvent& ev);
// Callback for Stim/Response and effect selection changes
void onEffectSelectionChange(wxDataViewEvent& ev);
};
} // namespace ui