96 |
|
|
97 |
if (!Settings::singleton()->autoRestoreWindowDimension) { |
if (!Settings::singleton()->autoRestoreWindowDimension) { |
98 |
#if GTKMM_MAJOR_VERSION >= 3 |
#if GTKMM_MAJOR_VERSION >= 3 |
99 |
set_default_size(960, 600); |
set_default_size(1010, -1); |
100 |
#else |
#else |
101 |
set_default_size(865, 600); |
set_default_size(915, -1); |
102 |
#endif |
#endif |
103 |
set_position(Gtk::WIN_POS_CENTER); |
set_position(Gtk::WIN_POS_CENTER); |
104 |
} |
} |
522 |
"DupInstrument", sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument) |
"DupInstrument", sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument) |
523 |
); |
); |
524 |
m_actionGroup->add_action( |
m_actionGroup->add_action( |
525 |
|
"MoveInstrument", sigc::mem_fun(*this, &MainWindow::on_action_move_instr) |
526 |
|
); |
527 |
|
m_actionGroup->add_action( |
528 |
"CombInstruments", sigc::mem_fun(*this, &MainWindow::on_action_combine_instruments) |
"CombInstruments", sigc::mem_fun(*this, &MainWindow::on_action_combine_instruments) |
529 |
); |
); |
530 |
m_actionGroup->add_action( |
m_actionGroup->add_action( |
546 |
sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument) |
sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument) |
547 |
); |
); |
548 |
actionGroup->add( |
actionGroup->add( |
549 |
|
Gtk::Action::create("MoveInstrument", _("Move _Instrument To ...")), |
550 |
|
Gtk::AccelKey(GDK_KEY_i, primaryModifierKey), |
551 |
|
sigc::mem_fun(*this, &MainWindow::on_action_move_instr) |
552 |
|
); |
553 |
|
actionGroup->add( |
554 |
Gtk::Action::create("CombInstruments", _("_Combine Instruments ...")), |
Gtk::Action::create("CombInstruments", _("_Combine Instruments ...")), |
555 |
Gtk::AccelKey(GDK_KEY_j, primaryModifierKey), |
Gtk::AccelKey(GDK_KEY_j, primaryModifierKey), |
556 |
sigc::mem_fun(*this, &MainWindow::on_action_combine_instruments) |
sigc::mem_fun(*this, &MainWindow::on_action_combine_instruments) |
906 |
" <attribute name='label' translatable='yes'>Duplicate Instrument</attribute>" |
" <attribute name='label' translatable='yes'>Duplicate Instrument</attribute>" |
907 |
" <attribute name='action'>AppMenu.DupInstrument</attribute>" |
" <attribute name='action'>AppMenu.DupInstrument</attribute>" |
908 |
" </item>" |
" </item>" |
909 |
|
" <item id='MoveInstrument'>" |
910 |
|
" <attribute name='label' translatable='yes'>Move Instrument To ...</attribute>" |
911 |
|
" <attribute name='action'>AppMenu.MoveInstrument</attribute>" |
912 |
|
" </item>" |
913 |
" <item id='CombInstruments'>" |
" <item id='CombInstruments'>" |
914 |
" <attribute name='label' translatable='yes'>Combine Instrument</attribute>" |
" <attribute name='label' translatable='yes'>Combine Instrument</attribute>" |
915 |
" <attribute name='action'>AppMenu.CombInstruments</attribute>" |
" <attribute name='action'>AppMenu.CombInstruments</attribute>" |
1039 |
" <attribute name='label' translatable='yes'>Duplicate Instrument</attribute>" |
" <attribute name='label' translatable='yes'>Duplicate Instrument</attribute>" |
1040 |
" <attribute name='action'>AppMenu.DupInstrument</attribute>" |
" <attribute name='action'>AppMenu.DupInstrument</attribute>" |
1041 |
" </item>" |
" </item>" |
1042 |
|
" <item id='MoveInstrument'>" |
1043 |
|
" <attribute name='label' translatable='yes'>Move Instrument To ...</attribute>" |
1044 |
|
" <attribute name='action'>AppMenu.MoveInstrument</attribute>" |
1045 |
|
" </item>" |
1046 |
" <item id='CombInstruments'>" |
" <item id='CombInstruments'>" |
1047 |
" <attribute name='label' translatable='yes'>Combine Instruments</attribute>" |
" <attribute name='label' translatable='yes'>Combine Instruments</attribute>" |
1048 |
" <attribute name='action'>AppMenu.CombInstruments</attribute>" |
" <attribute name='action'>AppMenu.CombInstruments</attribute>" |
1181 |
" <menu action='AssignScripts'/>" |
" <menu action='AssignScripts'/>" |
1182 |
" <menuitem action='AddInstrument'/>" |
" <menuitem action='AddInstrument'/>" |
1183 |
" <menuitem action='DupInstrument'/>" |
" <menuitem action='DupInstrument'/>" |
1184 |
|
" <menuitem action='MoveInstrument'/>" |
1185 |
" <menuitem action='CombInstruments'/>" |
" <menuitem action='CombInstruments'/>" |
1186 |
" <separator/>" |
" <separator/>" |
1187 |
" <menuitem action='RemoveInstrument'/>" |
" <menuitem action='RemoveInstrument'/>" |
1221 |
" <menuitem action='ScriptSlots'/>" |
" <menuitem action='ScriptSlots'/>" |
1222 |
" <menuitem action='AddInstrument'/>" |
" <menuitem action='AddInstrument'/>" |
1223 |
" <menuitem action='DupInstrument'/>" |
" <menuitem action='DupInstrument'/>" |
1224 |
|
" <menuitem action='MoveInstrument'/>" |
1225 |
" <menuitem action='CombInstruments'/>" |
" <menuitem action='CombInstruments'/>" |
1226 |
" <separator/>" |
" <separator/>" |
1227 |
" <menuitem action='RemoveInstrument'/>" |
" <menuitem action='RemoveInstrument'/>" |
1549 |
sigc::mem_fun(*this, &MainWindow::select_sample) |
sigc::mem_fun(*this, &MainWindow::select_sample) |
1550 |
); |
); |
1551 |
|
|
1552 |
|
dimreg_edit.editScriptSlotsButton.signal_clicked().connect( |
1553 |
|
sigc::mem_fun(*this, &MainWindow::show_script_slots) |
1554 |
|
); |
1555 |
|
// simply sending the same signal (pair) to the sampler on 'patch' variable |
1556 |
|
// changes as the already existing signal (pair) when the user edits the |
1557 |
|
// script's source code, because the sampler would reload the source code |
1558 |
|
// and the 'patch' variables from the instrument on this signal anyway |
1559 |
|
dimreg_edit.scriptVars.signal_vars_to_be_changed.connect( |
1560 |
|
[this](gig::Instrument* instr) { |
1561 |
|
for (int i = 0; i < instr->ScriptSlotCount(); ++i) { |
1562 |
|
gig::Script* script = instr->GetScriptOfSlot(i); |
1563 |
|
signal_script_to_be_changed.emit(script); |
1564 |
|
} |
1565 |
|
} |
1566 |
|
); |
1567 |
|
dimreg_edit.scriptVars.signal_vars_changed.connect( |
1568 |
|
[this](gig::Instrument* instr) { |
1569 |
|
for (int i = 0; i < instr->ScriptSlotCount(); ++i) { |
1570 |
|
gig::Script* script = instr->GetScriptOfSlot(i); |
1571 |
|
signal_script_changed.emit(script); |
1572 |
|
} |
1573 |
|
} |
1574 |
|
); |
1575 |
|
dimreg_edit.scriptVars.signal_edit_script.connect( |
1576 |
|
[this](gig::Script* script) { |
1577 |
|
editScript(script); |
1578 |
|
} |
1579 |
|
); |
1580 |
|
|
1581 |
m_RegionChooser.signal_instrument_struct_to_be_changed().connect( |
m_RegionChooser.signal_instrument_struct_to_be_changed().connect( |
1582 |
sigc::hide( |
sigc::hide( |
1583 |
sigc::bind( |
sigc::bind( |
1951 |
|
|
1952 |
updateScriptListOfMenu(); |
updateScriptListOfMenu(); |
1953 |
|
|
1954 |
m_RegionChooser.set_instrument(get_instrument()); |
gig::Instrument* instr = get_instrument(); |
1955 |
|
|
1956 |
|
m_RegionChooser.set_instrument(instr); |
1957 |
|
dimreg_edit.scriptVars.setInstrument(instr, true/*force update*/); |
1958 |
|
|
1959 |
if (Settings::singleton()->syncSamplerInstrumentSelection) { |
if (Settings::singleton()->syncSamplerInstrumentSelection) { |
1960 |
switch_sampler_instrument_signal.emit(get_instrument()); |
switch_sampler_instrument_signal.emit(get_instrument()); |
3971 |
} |
} |
3972 |
#endif |
#endif |
3973 |
|
|
3974 |
|
void MainWindow::on_action_move_instr() { |
3975 |
|
gig::Instrument* instr = get_instrument(); |
3976 |
|
if (!instr) return; |
3977 |
|
|
3978 |
|
int currentIndex = getIndexOf(instr); |
3979 |
|
|
3980 |
|
Gtk::Dialog dialog(_("Move Instrument"), true /*modal*/); |
3981 |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
3982 |
|
Gtk::Adjustment adjustment( |
3983 |
|
currentIndex, |
3984 |
|
0 /*min*/, file->CountInstruments() - 1 /*max*/ |
3985 |
|
); |
3986 |
|
Gtk::SpinButton spinBox(adjustment); |
3987 |
|
#else |
3988 |
|
Gtk::SpinButton spinBox( |
3989 |
|
Gtk::Adjustment::create( |
3990 |
|
currentIndex, |
3991 |
|
0 /*min*/, file->CountInstruments() - 1 /*max*/ |
3992 |
|
) |
3993 |
|
); |
3994 |
|
#endif |
3995 |
|
#if USE_GTKMM_BOX |
3996 |
|
dialog.get_content_area()->pack_start(spinBox); |
3997 |
|
#else |
3998 |
|
dialog.get_vbox()->pack_start(spinBox); |
3999 |
|
#endif |
4000 |
|
#if HAS_GTKMM_STOCK |
4001 |
|
Gtk::Button* okButton = dialog.add_button(Gtk::Stock::OK, 0); |
4002 |
|
dialog.add_button(Gtk::Stock::CANCEL, 1); |
4003 |
|
#else |
4004 |
|
Gtk::Button* okButton = dialog.add_button(_("_OK"), 0); |
4005 |
|
dialog.add_button(_("_Cancel"), 1); |
4006 |
|
#endif |
4007 |
|
okButton->set_sensitive(false); |
4008 |
|
// show the dialog at a reasonable screen position |
4009 |
|
dialog.set_position(Gtk::WIN_POS_MOUSE); |
4010 |
|
// only enable the 'OK' button if entered new index is not instrument's |
4011 |
|
// current index already |
4012 |
|
spinBox.signal_value_changed().connect([&]{ |
4013 |
|
okButton->set_sensitive( spinBox.get_value_as_int() != currentIndex ); |
4014 |
|
}); |
4015 |
|
// usability acceleration: if user hits enter key on the text entry field |
4016 |
|
// then auto trigger the 'OK' button |
4017 |
|
spinBox.signal_activate().connect([&]{ |
4018 |
|
if (okButton->get_sensitive()) |
4019 |
|
okButton->clicked(); |
4020 |
|
}); |
4021 |
|
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
4022 |
|
dialog.show_all_children(); |
4023 |
|
#endif |
4024 |
|
if (!dialog.run()) { // 'OK' selected ... |
4025 |
|
int newIndex = spinBox.get_value_as_int(); |
4026 |
|
printf("MOVE TO %d\n", newIndex); |
4027 |
|
gig::Instrument* dst = file->GetInstrument(newIndex); |
4028 |
|
instr->MoveTo(dst); |
4029 |
|
__refreshEntireGUI(); |
4030 |
|
select_instrument(instr); |
4031 |
|
} |
4032 |
|
} |
4033 |
|
|
4034 |
void MainWindow::select_instrument(gig::Instrument* instrument) { |
void MainWindow::select_instrument(gig::Instrument* instrument) { |
4035 |
if (!instrument) return; |
if (!instrument) return; |
4036 |
|
|
4558 |
if (!it) return; |
if (!it) return; |
4559 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
4560 |
gig::Script* script = row[m_ScriptsModel.m_col_script]; |
gig::Script* script = row[m_ScriptsModel.m_col_script]; |
4561 |
if (!script) return; |
editScript(script); |
4562 |
|
} |
4563 |
|
|
4564 |
|
void MainWindow::editScript(gig::Script* script) { |
4565 |
|
if (!script) return; |
4566 |
ScriptEditor* editor = new ScriptEditor; |
ScriptEditor* editor = new ScriptEditor; |
4567 |
editor->signal_script_to_be_changed.connect( |
editor->signal_script_to_be_changed.connect( |
4568 |
signal_script_to_be_changed.make_slot() |
signal_script_to_be_changed.make_slot() |