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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
|
/*
Rosegarden
A MIDI and audio sequencer and musical notation editor.
This program is Copyright 2000-2008
Guillaume Laurent <[email protected]>,
Chris Cannam <[email protected]>,
Richard Bown <[email protected]>
The moral rights of Guillaume Laurent, Chris Cannam, and Richard
Bown to claim authorship of this work have been asserted.
Other copyrights also apply to some parts of this work. Please
see the AUTHORS file and individual file headers for details.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version. See the file
COPYING included with this distribution for more information.
*/
#include "ControlParameterEditDialog.h"
#include <tqlayout.h>
#include <tdelocale.h>
#include "misc/Debug.h"
#include "misc/Strings.h"
#include "base/Colour.h"
#include "base/ColourMap.h"
#include "base/ControlParameter.h"
#include "base/Event.h"
#include "base/MidiTypes.h"
#include "document/RosegardenGUIDoc.h"
#include <kcombobox.h>
#include <kdialogbase.h>
#include <tqcolor.h>
#include <tqframe.h>
#include <tqgroupbox.h>
#include <tqlabel.h>
#include <tqlineedit.h>
#include <tqpixmap.h>
#include <tqspinbox.h>
#include <tqstring.h>
#include <tqvbox.h>
#include <tqwidget.h>
namespace Rosegarden
{
const TQString notShowing(i18n("<not showing>"));
ControlParameterEditDialog::ControlParameterEditDialog(
TQWidget *parent,
ControlParameter *control,
RosegardenGUIDoc *doc):
KDialogBase(parent, 0, true,
i18n("Edit Control Parameter"), Ok | Cancel),
m_doc(doc),
m_control(control)
{
m_dialogControl = *control; // copy in the ControlParameter
TQVBox *vbox = makeVBoxMainWidget();
TQGroupBox *groupBox = new TQGroupBox
(1, Qt::Horizontal, i18n("Control Event Properties"), vbox);
TQFrame *frame = new TQFrame(groupBox);
TQGridLayout *layout = new TQGridLayout(frame, 4, 3, 10, 5);
layout->addWidget(new TQLabel(i18n("Name:"), frame), 0, 0);
m_nameEdit = new TQLineEdit(frame);
layout->addWidget(m_nameEdit, 0, 1);
layout->addWidget(new TQLabel(i18n("Type:"), frame), 1, 0);
m_typeCombo = new KComboBox(frame);
layout->addMultiCellWidget(m_typeCombo, 1, 1, 1, 2);
layout->addWidget(new TQLabel(i18n("Description:"), frame), 2, 0);
m_description = new TQLineEdit(frame);
layout->addMultiCellWidget(m_description, 2, 2, 1, 2);
// hex value alongside decimal value
m_hexValue = new TQLabel(frame);
layout->addWidget(m_hexValue, 3, 1);
layout->addWidget(new TQLabel(i18n("Control Event value:"), frame), 3, 0);
m_controllerBox = new TQSpinBox(frame);
layout->addWidget(m_controllerBox, 3, 2);
layout->addWidget(new TQLabel(i18n("Minimum value:"), frame), 4, 0);
m_minBox = new TQSpinBox(frame);
layout->addMultiCellWidget(m_minBox, 4, 4, 1, 2);
layout->addWidget(new TQLabel(i18n("Maximum value:"), frame), 5, 0);
m_maxBox = new TQSpinBox(frame);
layout->addMultiCellWidget(m_maxBox, 5, 5, 1, 2);
layout->addWidget(new TQLabel(i18n("Default value:"), frame), 6, 0);
m_defaultBox = new TQSpinBox(frame);
layout->addMultiCellWidget(m_defaultBox, 6, 6, 1, 2);
layout->addWidget(new TQLabel(i18n("Color:"), frame), 7, 0);
m_colourCombo = new KComboBox(frame);
layout->addMultiCellWidget(m_colourCombo, 7, 7, 1, 2);
layout->addWidget(new TQLabel(i18n("Instrument Parameter Box position:"), frame), 8, 0);
m_ipbPosition = new KComboBox(frame);
layout->addMultiCellWidget(m_ipbPosition, 8, 8, 1, 2);
connect(m_nameEdit, TQT_SIGNAL(textChanged(const TQString&)),
TQT_SLOT(slotNameChanged(const TQString&)));
connect(m_typeCombo, TQT_SIGNAL(activated(int)),
TQT_SLOT(slotTypeChanged(int)));
connect(m_description, TQT_SIGNAL(textChanged(const TQString&)),
TQT_SLOT(slotDescriptionChanged(const TQString &)));
connect(m_controllerBox, TQT_SIGNAL(valueChanged(int)),
TQT_SLOT(slotControllerChanged(int)));
connect(m_minBox, TQT_SIGNAL(valueChanged(int)),
TQT_SLOT(slotMinChanged(int)));
connect(m_maxBox, TQT_SIGNAL(valueChanged(int)),
TQT_SLOT(slotMaxChanged(int)));
connect(m_defaultBox, TQT_SIGNAL(valueChanged(int)),
TQT_SLOT(slotDefaultChanged(int)));
connect(m_colourCombo, TQT_SIGNAL(activated(int)),
TQT_SLOT(slotColourChanged(int)));
connect(m_ipbPosition, TQT_SIGNAL(activated(int)),
TQT_SLOT(slotIPBPositionChanged(int)));
//m_nameEdit->selectAll();
//m_description->selectAll();
// set limits
m_controllerBox->setMinValue(0);
m_controllerBox->setMaxValue(127);
m_minBox->setMinValue(INT_MIN);
m_minBox->setMaxValue(INT_MAX);
m_maxBox->setMinValue(INT_MIN);
m_maxBox->setMaxValue(INT_MAX);
m_defaultBox->setMinValue(INT_MIN);
m_defaultBox->setMaxValue(INT_MAX);
// populate combos
m_typeCombo->insertItem(strtoqstr(Controller::EventType));
m_typeCombo->insertItem(strtoqstr(PitchBend::EventType));
/*
m_typeCombo->insertItem(strtoqstr(KeyPressure::EventType));
m_typeCombo->insertItem(strtoqstr(ChannelPressure::EventType));
*/
// Populate colour combo
//
//
ColourMap &colourMap = m_doc->getComposition().getGeneralColourMap();
RCMap::const_iterator it;
TQPixmap colourPixmap(16, 16);
for (it = colourMap.begin(); it != colourMap.end(); ++it) {
Colour c = it->second.first;
colourPixmap.fill(TQColor(c.getRed(), c.getGreen(), c.getBlue()));
m_colourCombo->insertItem(colourPixmap, strtoqstr(it->second.second));
}
// Populate IPB position combo
//
m_ipbPosition->insertItem(notShowing);
for (unsigned int i = 0; i < 32; i++)
m_ipbPosition->insertItem(TQString("%1").arg(i));
if (m_control->getType() == Controller::EventType)
m_typeCombo->setCurrentItem(0);
else if (m_control->getType() == PitchBend::EventType)
m_typeCombo->setCurrentItem(1);
/*
else if (m_control->getType() == KeyPressure::EventType)
m_typeCombo->setCurrentItem(2);
else if (m_control->getType() == ChannelPressure::EventType)
m_typeCombo->setCurrentItem(3);
*/
populate();
}
void
ControlParameterEditDialog::populate()
{
m_nameEdit->setText(strtoqstr(m_control->getName()));
m_description->setText(strtoqstr(m_control->getDescription()));
m_controllerBox->setValue(int(m_control->getControllerValue()));
TQString hexValue;
hexValue.sprintf("(0x%x)", m_control->getControllerValue());
m_hexValue->setText(hexValue);
m_minBox->setValue(m_control->getMin());
m_maxBox->setValue(m_control->getMax());
m_defaultBox->setValue(m_control->getDefault());
int pos = 0, setItem = 0;
ColourMap &colourMap = m_doc->getComposition().getGeneralColourMap();
RCMap::const_iterator it;
for (it = colourMap.begin(); it != colourMap.end(); ++it)
if (m_control->getColourIndex() == it->first)
setItem = pos++;
m_colourCombo->setCurrentItem(setItem);
// set combo position
m_ipbPosition->setCurrentItem(m_control->getIPBPosition() + 1);
// If the type has changed and there are no defaults then we have to
// supply some.
//
if (qstrtostr(m_typeCombo->currentText()) == PitchBend::EventType ||
qstrtostr(m_typeCombo->currentText()) == KeyPressure::EventType ||
qstrtostr(m_typeCombo->currentText()) == ChannelPressure::EventType) {
m_controllerBox->setEnabled(false);
m_ipbPosition->setEnabled(false);
m_colourCombo->setEnabled(false);
m_hexValue->setEnabled(false);
m_minBox->setEnabled(false);
m_maxBox->setEnabled(false);
m_defaultBox->setEnabled(false);
} else if (qstrtostr(m_typeCombo->currentText()) == Controller::EventType) {
m_controllerBox->setEnabled(true);
m_ipbPosition->setEnabled(true);
m_colourCombo->setEnabled(true);
m_hexValue->setEnabled(true);
m_minBox->setEnabled(true);
m_maxBox->setEnabled(true);
m_defaultBox->setEnabled(true);
}
}
void
ControlParameterEditDialog::slotNameChanged(const TQString &str)
{
RG_DEBUG << "ControlParameterEditDialog::slotNameChanged" << endl;
m_dialogControl.setName(qstrtostr(str));
}
void
ControlParameterEditDialog::slotTypeChanged(int value)
{
RG_DEBUG << "ControlParameterEditDialog::slotTypeChanged" << endl;
m_dialogControl.setType(qstrtostr(m_typeCombo->text(value)));
populate();
}
void
ControlParameterEditDialog::slotDescriptionChanged(const TQString &str)
{
RG_DEBUG << "ControlParameterEditDialog::slotDescriptionChanged" << endl;
m_dialogControl.setDescription(qstrtostr(str));
}
void
ControlParameterEditDialog::slotControllerChanged(int value)
{
RG_DEBUG << "ControlParameterEditDialog::slotControllerChanged" << endl;
m_dialogControl.setControllerValue(value);
// set hex value
TQString hexValue;
hexValue.sprintf("(0x%x)", value);
m_hexValue->setText(hexValue);
}
void
ControlParameterEditDialog::slotMinChanged(int value)
{
RG_DEBUG << "ControlParameterEditDialog::slotMinChanged" << endl;
m_dialogControl.setMin(value);
}
void
ControlParameterEditDialog::slotMaxChanged(int value)
{
RG_DEBUG << "ControlParameterEditDialog::slotMaxChanged" << endl;
m_dialogControl.setMax(value);
}
void
ControlParameterEditDialog::slotDefaultChanged(int value)
{
RG_DEBUG << "ControlParameterEditDialog::slotDefaultChanged" << endl;
m_dialogControl.setDefault(value);
}
void
ControlParameterEditDialog::slotColourChanged(int value)
{
RG_DEBUG << "ControlParameterEditDialog::slotColourChanged" << endl;
m_dialogControl.setColourIndex(value);
}
void
ControlParameterEditDialog::slotIPBPositionChanged(int value)
{
RG_DEBUG << "ControlParameterEditDialog::slotIPBPositionChanged" << endl;
m_dialogControl.setIPBPosition(value - 1);
}
}
#include "ControlParameterEditDialog.moc"
|