1 |
/* |
2 |
* Copyright (C) 2013-2017 Andreas Persson |
3 |
* |
4 |
* This program is free software; you can redistribute it and/or |
5 |
* modify it under the terms of the GNU General Public License as |
6 |
* published by the Free Software Foundation; either version 2 of the |
7 |
* License, or (at your option) any later version. |
8 |
* |
9 |
* This program is distributed in the hope that it will be useful, but |
10 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 |
* General Public License for more details. |
13 |
* |
14 |
* You should have received a copy of the GNU General Public License |
15 |
* along with this program; if not, write to the Free Software |
16 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
17 |
* 02110-1301, USA. |
18 |
*/ |
19 |
|
20 |
#include "compat.h" |
21 |
#include "global.h" |
22 |
#include "midirules.h" |
23 |
|
24 |
#if HAS_GTKMM_STOCK |
25 |
# include <gtkmm/stock.h> |
26 |
#endif |
27 |
|
28 |
MidiRules::MidiRules() : |
29 |
label(_("Midi rule:")), |
30 |
#if HAS_GTKMM_STOCK |
31 |
quit_button(Gtk::Stock::CLOSE), |
32 |
#else |
33 |
quit_button(_("_Close"), true), |
34 |
#endif |
35 |
unknown(_("unknown")) |
36 |
{ |
37 |
if (!Settings::singleton()->autoRestoreWindowDimension) { |
38 |
//set_default_size(470, 390); |
39 |
set_position(Gtk::WIN_POS_MOUSE); |
40 |
} |
41 |
|
42 |
set_title(_("Midi Rules")); |
43 |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22) |
44 |
set_margin(6); |
45 |
#else |
46 |
set_border_width(6); |
47 |
#endif |
48 |
|
49 |
add(vbox); |
50 |
|
51 |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22) |
52 |
hbox.set_margin(6); |
53 |
#else |
54 |
hbox.set_border_width(6); |
55 |
#endif |
56 |
hbox.set_spacing(6); |
57 |
hbox.pack_start(label, Gtk::PACK_SHRINK); |
58 |
hbox.pack_start(combo, Gtk::PACK_SHRINK); |
59 |
const char* choices[] = { _("none"), _("Controller trigger"), |
60 |
_("Legato"), 0 }; |
61 |
for (int i = 0 ; choices[i] ; i++) { |
62 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 24) || GTKMM_MAJOR_VERSION < 2 |
63 |
combo.append_text(choices[i]); |
64 |
#else |
65 |
combo.append(choices[i]); |
66 |
#endif |
67 |
} |
68 |
combo.signal_changed().connect( |
69 |
sigc::mem_fun(*this, &MidiRules::combo_changed)); |
70 |
vbox.pack_start(hbox, Gtk::PACK_SHRINK); |
71 |
|
72 |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22) |
73 |
box.set_margin(6); |
74 |
#else |
75 |
box.set_border_width(6); |
76 |
#endif |
77 |
vbox.pack_start(box); |
78 |
|
79 |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22) |
80 |
button_box.set_margin(6); |
81 |
#else |
82 |
button_box.set_border_width(6); |
83 |
#endif |
84 |
button_box.set_layout(Gtk::BUTTONBOX_END); |
85 |
button_box.pack_start(quit_button); |
86 |
quit_button.set_can_default(); |
87 |
quit_button.grab_focus(); |
88 |
quit_button.signal_clicked().connect( |
89 |
sigc::mem_fun(*this, &MidiRules::hide)); |
90 |
vbox.pack_start(button_box, Gtk::PACK_SHRINK); |
91 |
|
92 |
legato.signal_changed().connect(sig_changed.make_slot()); |
93 |
ctrl_trigger.signal_changed().connect(sig_changed.make_slot()); |
94 |
|
95 |
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
96 |
show_all_children(); |
97 |
#endif |
98 |
} |
99 |
|
100 |
void MidiRules::combo_changed() { |
101 |
if (update_model) return; |
102 |
|
103 |
int rowno = combo.get_active_row_number(); |
104 |
|
105 |
if (remove_unknown_from_combo()) { |
106 |
rowno--; |
107 |
} |
108 |
|
109 |
gig::MidiRule* rule = m->GetMidiRule(0); |
110 |
switch (rowno) { |
111 |
case NONE: |
112 |
if (rule) { |
113 |
m->DeleteMidiRule(0); |
114 |
set_instrument(m); |
115 |
} |
116 |
break; |
117 |
case CTRL_TRIGGER: |
118 |
if (!dynamic_cast<gig::MidiRuleCtrlTrigger*>(rule)) { |
119 |
m->AddMidiRuleCtrlTrigger(); |
120 |
set_instrument(m); |
121 |
} |
122 |
break; |
123 |
case LEGATO: |
124 |
if (!dynamic_cast<gig::MidiRuleLegato*>(rule)) { |
125 |
m->AddMidiRuleLegato(); |
126 |
set_instrument(m); |
127 |
} |
128 |
break; |
129 |
} |
130 |
sig_changed(); |
131 |
} |
132 |
|
133 |
void MidiRules::set_instrument(gig::Instrument* instrument) { |
134 |
m = instrument; |
135 |
update_model++; |
136 |
|
137 |
std::vector<Widget*> children = box.get_children(); |
138 |
if (children.size() == 1) { |
139 |
box.remove(*children[0]); |
140 |
} |
141 |
|
142 |
gig::MidiRule* rule = instrument->GetMidiRule(0); |
143 |
int active = -1; |
144 |
if (!rule) { |
145 |
active = NONE; |
146 |
} else if (gig::MidiRuleLegato* r = |
147 |
dynamic_cast<gig::MidiRuleLegato*>(rule)) { |
148 |
active = LEGATO; |
149 |
box.add(legato); |
150 |
legato.set_rule(r); |
151 |
} else if (gig::MidiRuleCtrlTrigger* r = |
152 |
dynamic_cast<gig::MidiRuleCtrlTrigger*>(rule)) { |
153 |
active = CTRL_TRIGGER; |
154 |
box.add(ctrl_trigger); |
155 |
ctrl_trigger.set_rule(r); |
156 |
} else { |
157 |
if (combo.get_model()->children().size() == NUMBER_OF_RULES) { |
158 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 24) || GTKMM_MAJOR_VERSION < 2 |
159 |
combo.prepend_text(unknown); |
160 |
#else |
161 |
combo.prepend(unknown); |
162 |
#endif |
163 |
} |
164 |
combo.set_active(0); |
165 |
} |
166 |
if (active != -1) { |
167 |
remove_unknown_from_combo(); |
168 |
combo.set_active(active); |
169 |
} |
170 |
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
171 |
show_all_children(); |
172 |
#endif |
173 |
update_model--; |
174 |
} |
175 |
|
176 |
bool MidiRules::remove_unknown_from_combo() { |
177 |
if (combo.get_model()->children().size() == NUMBER_OF_RULES + 1) { |
178 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
179 |
combo.remove_text(unknown); |
180 |
#else |
181 |
combo.remove_text(0); |
182 |
#endif |
183 |
return true; |
184 |
} |
185 |
return false; |
186 |
} |
187 |
|
188 |
|
189 |
MidiRuleCtrlTrigger::MidiRuleCtrlTrigger() : |
190 |
table(2, 1), |
191 |
eControllerNumber(_("Controller")) |
192 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
193 |
, add_button(Gtk::Stock::ADD), |
194 |
remove_button(Gtk::Stock::REMOVE) |
195 |
#endif |
196 |
{ |
197 |
connect(eControllerNumber, &gig::MidiRuleCtrlTrigger::ControllerNumber); |
198 |
|
199 |
set_spacing(6); |
200 |
|
201 |
scrolled_window.set_size_request(-1, 120); |
202 |
|
203 |
list_store = Gtk::ListStore::create(columns); |
204 |
tree_view.set_model(list_store); |
205 |
list_store->signal_row_changed().connect( |
206 |
sigc::mem_fun(*this, &MidiRuleCtrlTrigger::row_changed)); |
207 |
list_store->signal_row_inserted().connect( |
208 |
sigc::mem_fun(*this, &MidiRuleCtrlTrigger::row_inserted)); |
209 |
list_store->signal_row_deleted().connect( |
210 |
sigc::mem_fun(*this, &MidiRuleCtrlTrigger::row_deleted)); |
211 |
|
212 |
append_num_column(_("Trigger point"), columns.trigger_point); |
213 |
tree_view.append_column_editable(_("Descending"), columns.descending); |
214 |
append_num_column(_("Vel sensitivity"), columns.vel_sensitivity, 1, 100); |
215 |
append_note_column(_("Key"), columns.key); |
216 |
tree_view.append_column_editable(_("Note off"), columns.note_off); |
217 |
tree_view.append_column_editable(_("Switch"), columns.switch_logic); |
218 |
|
219 |
int cols_count = append_num_column(_("Velocity"), columns.velocity); |
220 |
Gtk::TreeViewColumn* col = tree_view.get_column(cols_count - 1); |
221 |
col->add_attribute(*col->get_first_cell(), "visible", columns.switch_logic); |
222 |
cols_count = tree_view.append_column_editable(_("Override pedal"), |
223 |
columns.override_pedal); |
224 |
col = tree_view.get_column(cols_count - 1); |
225 |
col->add_attribute(*col->get_first_cell(), "visible", columns.note_off); |
226 |
|
227 |
tree_view.get_selection()->signal_changed().connect( |
228 |
sigc::mem_fun(*this, &MidiRuleCtrlTrigger::sel_changed)); |
229 |
|
230 |
scrolled_window.add(tree_view); |
231 |
scrolled_window.set_shadow_type(Gtk::SHADOW_IN); |
232 |
scrolled_window.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC); |
233 |
|
234 |
#if USE_GTKMM_GRID |
235 |
table.set_column_spacing(5); |
236 |
#else |
237 |
table.set_col_spacings(5); |
238 |
#endif |
239 |
|
240 |
table.add(eControllerNumber); |
241 |
pack_start(table, Gtk::PACK_SHRINK); |
242 |
|
243 |
vbox.add(scrolled_window); |
244 |
|
245 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
246 |
vbox.set_spacing(6); |
247 |
toolbar.set_layout(Gtk::BUTTONBOX_START); |
248 |
toolbar.set_homogeneous(); |
249 |
toolbar.set_spacing(6); |
250 |
#else |
251 |
toolbar.set_toolbar_style(Gtk::TOOLBAR_ICONS); |
252 |
toolbar.set_show_arrow(false); |
253 |
toolbar.set_icon_size(Gtk::IconSize(1)); |
254 |
toolbar.get_style_context()->add_class("inline-toolbar"); |
255 |
|
256 |
add_button.set_icon_name("list-add-symbolic"); |
257 |
remove_button.set_icon_name("list-remove-symbolic"); |
258 |
#endif |
259 |
|
260 |
add_button.signal_clicked().connect( |
261 |
sigc::mem_fun(*this, &MidiRuleCtrlTrigger::add_row)); |
262 |
toolbar.add(add_button); |
263 |
|
264 |
remove_button.signal_clicked().connect( |
265 |
sigc::mem_fun(*this, &MidiRuleCtrlTrigger::remove_row)); |
266 |
toolbar.add(remove_button); |
267 |
|
268 |
vbox.pack_start(toolbar, Gtk::PACK_SHRINK); |
269 |
add(vbox); |
270 |
} |
271 |
|
272 |
int MidiRuleCtrlTrigger::append_num_column( |
273 |
const char* title, |
274 |
const Gtk::TreeModelColumn<int>& column, |
275 |
int lower, int upper) { |
276 |
Gtk::CellRendererSpin* renderer = Gtk::manage(new Gtk::CellRendererSpin()); |
277 |
renderer->property_editable() = true; |
278 |
renderer->signal_editing_started().connect( |
279 |
sigc::bind( |
280 |
sigc::mem_fun(*this, &MidiRuleCtrlTrigger::num_editing_started), |
281 |
renderer)); |
282 |
renderer->signal_edited().connect( |
283 |
sigc::bind( |
284 |
sigc::mem_fun(*this, &MidiRuleCtrlTrigger::num_edited), |
285 |
column)); |
286 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
287 |
renderer->property_adjustment() = new Gtk::Adjustment(lower, lower, upper); |
288 |
#else |
289 |
renderer->property_adjustment() = |
290 |
Gtk::Adjustment::create(lower, lower, upper); |
291 |
#endif |
292 |
|
293 |
int cols_count = tree_view.append_column(title, *renderer); |
294 |
Gtk::TreeViewColumn* col = tree_view.get_column(cols_count - 1); |
295 |
col->add_attribute(*renderer, "text", column); |
296 |
col->set_min_width(92); |
297 |
return cols_count; |
298 |
} |
299 |
|
300 |
int MidiRuleCtrlTrigger::append_note_column( |
301 |
const char* title, |
302 |
const Gtk::TreeModelColumn<Glib::ustring>& column) { |
303 |
Gtk::CellRendererSpin* renderer = Gtk::manage(new Gtk::CellRendererSpin()); |
304 |
renderer->property_editable() = true; |
305 |
renderer->signal_editing_started().connect( |
306 |
sigc::bind( |
307 |
sigc::mem_fun(*this, &MidiRuleCtrlTrigger::note_editing_started), |
308 |
renderer)); |
309 |
renderer->signal_edited().connect( |
310 |
sigc::bind( |
311 |
sigc::mem_fun(*this, &MidiRuleCtrlTrigger::note_edited), |
312 |
column)); |
313 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
314 |
renderer->property_adjustment() = new Gtk::Adjustment(0, 0, 127); |
315 |
#else |
316 |
renderer->property_adjustment() = Gtk::Adjustment::create(0, 0, 127); |
317 |
#endif |
318 |
|
319 |
int cols_count = tree_view.append_column(title, *renderer); |
320 |
Gtk::TreeViewColumn* col = tree_view.get_column(cols_count - 1); |
321 |
col->add_attribute(*renderer, "text", column); |
322 |
col->set_min_width(98); |
323 |
return cols_count; |
324 |
} |
325 |
|
326 |
void MidiRuleCtrlTrigger::set_rule(gig::MidiRuleCtrlTrigger* r) { |
327 |
update_model++; |
328 |
update(r); |
329 |
list_store->clear(); |
330 |
for (int i = 0 ; i < r->Triggers ; i++) { |
331 |
Gtk::TreeModel::Row row = *list_store->append(); |
332 |
row[columns.trigger_point] = r->pTriggers[i].TriggerPoint; |
333 |
row[columns.descending] = r->pTriggers[i].Descending; |
334 |
row[columns.vel_sensitivity] = r->pTriggers[i].VelSensitivity; |
335 |
row[columns.key] = note_str(r->pTriggers[i].Key); |
336 |
row[columns.note_off] = r->pTriggers[i].NoteOff; |
337 |
row[columns.switch_logic] = r->pTriggers[i].Velocity != 255; |
338 |
if (r->pTriggers[i].Velocity != 255) { |
339 |
row[columns.velocity] = r->pTriggers[i].Velocity; |
340 |
} |
341 |
row[columns.override_pedal] = r->pTriggers[i].OverridePedal; |
342 |
} |
343 |
sel_changed(); |
344 |
add_button.set_sensitive(); |
345 |
if (r->Triggers == 32) add_button.set_sensitive(false); |
346 |
update_model--; |
347 |
} |
348 |
|
349 |
void MidiRuleCtrlTrigger::num_editing_started( |
350 |
Gtk::CellEditable* editable, |
351 |
const Glib::ustring& path, |
352 |
Gtk::CellRendererSpin* renderer) { |
353 |
int lower = renderer->property_adjustment().get_value()->get_lower(); |
354 |
int upper = renderer->property_adjustment().get_value()->get_upper(); |
355 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
356 |
renderer->property_adjustment() = new Gtk::Adjustment(lower, lower, upper); |
357 |
#else |
358 |
renderer->property_adjustment() = |
359 |
Gtk::Adjustment::create(lower, lower, upper); |
360 |
#endif |
361 |
Gtk::SpinButton* spin_button = dynamic_cast<Gtk::SpinButton*>(editable); |
362 |
if (spin_button) { |
363 |
spin_button->set_numeric(); |
364 |
} |
365 |
} |
366 |
|
367 |
void MidiRuleCtrlTrigger::note_editing_started( |
368 |
Gtk::CellEditable* editable, |
369 |
const Glib::ustring& path, |
370 |
Gtk::CellRendererSpin* renderer) { |
371 |
int value = note_value(renderer->property_text()); |
372 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
373 |
renderer->property_adjustment() = new Gtk::Adjustment(0, 0, 127); |
374 |
#else |
375 |
renderer->property_adjustment() = Gtk::Adjustment::create(0, 0, 127); |
376 |
#endif |
377 |
Gtk::SpinButton* spin_button = dynamic_cast<Gtk::SpinButton*>(editable); |
378 |
if (spin_button) { |
379 |
spin_button->get_adjustment()->set_value(value); |
380 |
spin_button_show_notes(*spin_button); |
381 |
} |
382 |
} |
383 |
|
384 |
void MidiRuleCtrlTrigger::num_edited( |
385 |
const Glib::ustring& path, |
386 |
const Glib::ustring& new_text, |
387 |
const Gtk::TreeModelColumn<int>& column) { |
388 |
Gtk::TreeModel::Row row = *list_store->get_iter(path); |
389 |
|
390 |
Gtk::TreeModel::Path cpath; |
391 |
Gtk::TreeViewColumn* col; |
392 |
tree_view.get_cursor(cpath, col); |
393 |
|
394 |
int lower = 0; |
395 |
int upper = 127; |
396 |
const Gtk::CellRenderer* r = col->get_first_cell(); |
397 |
if (const Gtk::CellRendererSpin* renderer = |
398 |
dynamic_cast<const Gtk::CellRendererSpin*>(r)) { |
399 |
lower = renderer->property_adjustment().get_value()->get_lower(); |
400 |
upper = renderer->property_adjustment().get_value()->get_upper(); |
401 |
} |
402 |
|
403 |
row[column] = std::max(lower, std::min(atoi(new_text.c_str()), upper)); |
404 |
} |
405 |
|
406 |
void MidiRuleCtrlTrigger::note_edited( |
407 |
const Glib::ustring& path, |
408 |
const Glib::ustring& new_text, |
409 |
const Gtk::TreeModelColumn<Glib::ustring>& column) { |
410 |
Gtk::TreeModel::Row row = *list_store->get_iter(path); |
411 |
|
412 |
row[column] = note_str(note_value(new_text)); |
413 |
} |
414 |
|
415 |
void MidiRuleCtrlTrigger::sel_changed() { |
416 |
Gtk::TreeModel::iterator it = tree_view.get_selection()->get_selected(); |
417 |
remove_button.set_sensitive(); |
418 |
if (!it) remove_button.set_sensitive(false); |
419 |
} |
420 |
|
421 |
void MidiRuleCtrlTrigger::add_row() { |
422 |
Gtk::TreeModel::Path path; |
423 |
Gtk::TreeViewColumn* col; |
424 |
tree_view.get_cursor(path, col); |
425 |
if (!path.empty()) tree_view.set_cursor(path); |
426 |
|
427 |
Gtk::TreeModel::iterator it = list_store->append(); |
428 |
Gtk::TreeModel::Row row = *it; |
429 |
|
430 |
update_model++; |
431 |
row[columns.trigger_point] = 64; |
432 |
row[columns.descending] = false; |
433 |
row[columns.vel_sensitivity] = 50; |
434 |
row[columns.key] = note_str(60); |
435 |
row[columns.note_off] = false; |
436 |
row[columns.switch_logic] = false; |
437 |
row[columns.override_pedal] = false; |
438 |
update_model--; |
439 |
|
440 |
//NOTE: was ->select(row) before, but did not compile with GTKMM4 development branch, probably going to be fixed before final GTKMM4 release though. |
441 |
tree_view.get_selection()->select(it); |
442 |
path = list_store->get_path(it); |
443 |
tree_view.scroll_to_row(path); |
444 |
tree_view.set_cursor(path); |
445 |
} |
446 |
|
447 |
void MidiRuleCtrlTrigger::remove_row() { |
448 |
Gtk::TreeModel::Path cpath; |
449 |
Gtk::TreeViewColumn* col; |
450 |
tree_view.get_cursor(cpath, col); |
451 |
if (!cpath.empty()) tree_view.set_cursor(cpath); |
452 |
|
453 |
Gtk::TreeModel::iterator it = tree_view.get_selection()->get_selected(); |
454 |
if (it) { |
455 |
Gtk::TreePath path = list_store->get_path(it); |
456 |
list_store->erase(it); |
457 |
|
458 |
it = tree_view.get_selection()->get_selected(); |
459 |
if (!it) { |
460 |
int i = path[0]; |
461 |
int n = list_store->children().size(); |
462 |
if (n) { |
463 |
if (i >= n) i = n - 1; |
464 |
path[0] = i; |
465 |
tree_view.get_selection()->select(path); |
466 |
} |
467 |
} |
468 |
} |
469 |
} |
470 |
|
471 |
void MidiRuleCtrlTrigger::row_changed(const Gtk::TreeModel::Path& path, |
472 |
const Gtk::TreeModel::iterator& iter) { |
473 |
if (update_model) return; |
474 |
|
475 |
Gtk::TreeModel::Row row = *iter; |
476 |
int i = path[0]; |
477 |
|
478 |
if (m->pTriggers[i].Velocity == 255 && row[columns.switch_logic]) { |
479 |
update_model++; |
480 |
row[columns.velocity] = 100; |
481 |
update_model--; |
482 |
} |
483 |
|
484 |
int key = note_value(row[columns.key]); |
485 |
|
486 |
if (m->pTriggers[i].TriggerPoint != row[columns.trigger_point] || |
487 |
m->pTriggers[i].Descending != row[columns.descending] || |
488 |
m->pTriggers[i].VelSensitivity != row[columns.vel_sensitivity] || |
489 |
m->pTriggers[i].Key != key || |
490 |
m->pTriggers[i].NoteOff != row[columns.note_off] || |
491 |
(m->pTriggers[i].Velocity != 255) != row[columns.switch_logic] || |
492 |
m->pTriggers[i].Velocity != row[columns.velocity] || |
493 |
m->pTriggers[i].OverridePedal != row[columns.override_pedal]) |
494 |
{ |
495 |
m->pTriggers[i].TriggerPoint = row[columns.trigger_point]; |
496 |
m->pTriggers[i].Descending = row[columns.descending]; |
497 |
m->pTriggers[i].VelSensitivity = row[columns.vel_sensitivity]; |
498 |
m->pTriggers[i].Key = key; |
499 |
m->pTriggers[i].NoteOff = row[columns.note_off]; |
500 |
m->pTriggers[i].Velocity = |
501 |
row[columns.switch_logic] ? row[columns.velocity] : 255; |
502 |
m->pTriggers[i].OverridePedal = row[columns.override_pedal]; |
503 |
sig_changed(); |
504 |
} |
505 |
} |
506 |
|
507 |
void MidiRuleCtrlTrigger::row_inserted(const Gtk::TreeModel::Path& path, |
508 |
const Gtk::TreeModel::iterator& iter) { |
509 |
if (update_model) return; |
510 |
int i = m->Triggers++; |
511 |
m->pTriggers[i].TriggerPoint = 64; |
512 |
m->pTriggers[i].Descending = false; |
513 |
m->pTriggers[i].VelSensitivity = 50; |
514 |
m->pTriggers[i].Key = 60; |
515 |
m->pTriggers[i].NoteOff = false; |
516 |
m->pTriggers[i].Velocity = 255; |
517 |
m->pTriggers[i].OverridePedal = false; |
518 |
add_button.set_sensitive(); |
519 |
if (m->Triggers == 32) add_button.set_sensitive(false); |
520 |
sig_changed(); |
521 |
} |
522 |
|
523 |
void MidiRuleCtrlTrigger::row_deleted(const Gtk::TreeModel::Path& path) { |
524 |
if (update_model) return; |
525 |
for (int i = path[0] + 1 ; i < m->Triggers ; i++) { |
526 |
m->pTriggers[i - 1] = m->pTriggers[i]; |
527 |
} |
528 |
m->Triggers--; |
529 |
add_button.set_sensitive(); |
530 |
sig_changed(); |
531 |
} |
532 |
|
533 |
|
534 |
|
535 |
MidiRuleLegato::MidiRuleLegato() : |
536 |
Table(2, 1), |
537 |
eBypassUseController(_("Bypass use controller")), |
538 |
eBypassKey(_("Bypass key")), |
539 |
eBypassController(_("Bypass controller")), |
540 |
eThresholdTime(_("Threshold time"), 10, 500), |
541 |
eReleaseTime(_("Release time"), 10, 500), |
542 |
eKeyRangeLow(_("Key range low")), |
543 |
eKeyRangeHigh(_("Key range high")), |
544 |
eReleaseTriggerKey(_("Release trigger key")), |
545 |
eAltSustain1Key(_("Alt sustain 1 key")), |
546 |
eAltSustain2Key(_("Alt sustain 2 key")) |
547 |
{ |
548 |
connect(eBypassUseController, &gig::MidiRuleLegato::BypassUseController); |
549 |
connect(eBypassKey, &gig::MidiRuleLegato::BypassKey); |
550 |
connect(eBypassController, &gig::MidiRuleLegato::BypassController); |
551 |
connect(eThresholdTime, &gig::MidiRuleLegato::ThresholdTime); |
552 |
connect(eReleaseTime, &gig::MidiRuleLegato::ReleaseTime); |
553 |
connect(eKeyRangeLow, eKeyRangeHigh, &gig::MidiRuleLegato::KeyRange); |
554 |
connect(eReleaseTriggerKey, &gig::MidiRuleLegato::ReleaseTriggerKey); |
555 |
connect(eAltSustain1Key, &gig::MidiRuleLegato::AltSustain1Key); |
556 |
connect(eAltSustain2Key, &gig::MidiRuleLegato::AltSustain2Key); |
557 |
|
558 |
#if USE_GTKMM_GRID |
559 |
set_column_spacing(5); |
560 |
#else |
561 |
set_col_spacings(5); |
562 |
#endif |
563 |
|
564 |
add(eBypassUseController); |
565 |
add(eBypassKey); |
566 |
add(eBypassController); |
567 |
add(eThresholdTime); |
568 |
add(eReleaseTime); |
569 |
add(eKeyRangeLow); |
570 |
add(eKeyRangeHigh); |
571 |
add(eReleaseTriggerKey); |
572 |
add(eAltSustain1Key); |
573 |
add(eAltSustain2Key); |
574 |
|
575 |
eBypassUseController.signal_value_changed().connect( |
576 |
sigc::mem_fun(*this, &MidiRuleLegato::BypassUseController_toggled)); |
577 |
} |
578 |
|
579 |
void MidiRuleLegato::BypassUseController_toggled() { |
580 |
bool useController = eBypassUseController.get_value(); |
581 |
eBypassKey.set_sensitive(!useController); |
582 |
eBypassController.set_sensitive(useController); |
583 |
} |
584 |
|
585 |
void MidiRuleLegato::set_rule(gig::MidiRuleLegato* r) { |
586 |
update_model++; |
587 |
update(r); |
588 |
BypassUseController_toggled(); |
589 |
update_model--; |
590 |
} |