--- gigedit/trunk/src/gigedit/mainwindow.cpp 2020/02/01 20:39:39 3737 +++ gigedit/trunk/src/gigedit/mainwindow.cpp 2020/08/14 11:45:08 3810 @@ -106,21 +106,21 @@ add(m_VBox); // Handle selection - m_TreeView.get_selection()->signal_changed().connect( + m_TreeViewInstruments.get_selection()->signal_changed().connect( sigc::mem_fun(*this, &MainWindow::on_sel_change)); - // m_TreeView.set_reorderable(); + // m_TreeViewInstruments.set_reorderable(); #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2 - m_TreeView.signal_button_press_event().connect( + m_TreeViewInstruments.signal_button_press_event().connect( sigc::mem_fun(*this, &MainWindow::on_button_release)); #else - m_TreeView.signal_button_press_event().connect_notify( + m_TreeViewInstruments.signal_button_press_event().connect_notify( sigc::mem_fun(*this, &MainWindow::on_button_release)); #endif // Add the TreeView tab, inside a ScrolledWindow, with the button underneath: - m_ScrolledWindow.add(m_TreeView); + m_ScrolledWindow.add(m_TreeViewInstruments); // m_ScrolledWindow.set_size_request(200, 600); m_ScrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); @@ -1383,42 +1383,42 @@ // Create the Tree model: - m_refTreeModel = Gtk::ListStore::create(m_Columns); - m_refTreeModelFilter = Gtk::TreeModelFilter::create(m_refTreeModel); - m_refTreeModelFilter->set_visible_func( + m_refInstrumentsTreeModel = Gtk::ListStore::create(m_InstrumentsModel); + m_refInstrumentsModelFilter = Gtk::TreeModelFilter::create(m_refInstrumentsTreeModel); + m_refInstrumentsModelFilter->set_visible_func( sigc::mem_fun(*this, &MainWindow::instrument_row_visible) ); - m_TreeView.set_model(m_refTreeModelFilter); + m_TreeViewInstruments.set_model(m_refInstrumentsModelFilter); - m_TreeView.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE); - m_TreeView.set_has_tooltip(true); - m_TreeView.signal_query_tooltip().connect( + m_TreeViewInstruments.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE); + m_TreeViewInstruments.set_has_tooltip(true); + m_TreeViewInstruments.signal_query_tooltip().connect( sigc::mem_fun(*this, &MainWindow::onQueryTreeViewTooltip) ); - instrument_name_connection = m_refTreeModel->signal_row_changed().connect( + instrument_name_connection = m_refInstrumentsTreeModel->signal_row_changed().connect( sigc::mem_fun(*this, &MainWindow::instrument_name_changed) ); // Add the TreeView's view columns: - m_TreeView.append_column(_("Nr"), m_Columns.m_col_nr); - m_TreeView.append_column_editable(_("Instrument"), m_Columns.m_col_name); - m_TreeView.append_column(_("Scripts"), m_Columns.m_col_scripts); - m_TreeView.set_headers_visible(true); + m_TreeViewInstruments.append_column(_("Nr"), m_InstrumentsModel.m_col_nr); + m_TreeViewInstruments.append_column_editable(_("Instrument"), m_InstrumentsModel.m_col_name); + m_TreeViewInstruments.append_column(_("Scripts"), m_InstrumentsModel.m_col_scripts); + m_TreeViewInstruments.set_headers_visible(true); // establish drag&drop within the instrument tree view, allowing to reorder // the sequence of instruments within the gig file { std::vector drag_target_instrument; drag_target_instrument.push_back(Gtk::TargetEntry("gig::Instrument")); - m_TreeView.drag_source_set(drag_target_instrument); - m_TreeView.drag_dest_set(drag_target_instrument); - m_TreeView.signal_drag_begin().connect( + m_TreeViewInstruments.drag_source_set(drag_target_instrument); + m_TreeViewInstruments.drag_dest_set(drag_target_instrument); + m_TreeViewInstruments.signal_drag_begin().connect( sigc::mem_fun(*this, &MainWindow::on_instruments_treeview_drag_begin) ); - m_TreeView.signal_drag_data_get().connect( + m_TreeViewInstruments.signal_drag_data_get().connect( sigc::mem_fun(*this, &MainWindow::on_instruments_treeview_drag_data_get) ); - m_TreeView.signal_drag_data_received().connect( + m_TreeViewInstruments.signal_drag_data_received().connect( sigc::mem_fun(*this, &MainWindow::on_instruments_treeview_drop_drag_data_received) ); } @@ -1572,6 +1572,11 @@ } } ); + dimreg_edit.scriptVars.signal_edit_script.connect( + [this](gig::Script* script) { + editScript(script); + } + ); m_RegionChooser.signal_instrument_struct_to_be_changed().connect( sigc::hide( @@ -1615,7 +1620,7 @@ sigc::mem_fun(*this, &MainWindow::update_dimregs)); m_searchText.signal_changed().connect( - sigc::mem_fun(*m_refTreeModelFilter.operator->(), &Gtk::TreeModelFilter::refilter) + sigc::mem_fun(*m_refInstrumentsModelFilter.operator->(), &Gtk::TreeModelFilter::refilter) ); file = 0; @@ -1859,14 +1864,21 @@ gig::Instrument* MainWindow::get_instrument() { - gig::Instrument* instrument = 0; - std::vector rows = m_TreeView.get_selection()->get_selected_rows(); + gig::Instrument* instrument = NULL; + + // get indeces of visual selection + std::vector rows = m_TreeViewInstruments.get_selection()->get_selected_rows(); if (rows.empty()) return NULL; + + // convert index of visual selection (i.e. if filtered) to index of model + Gtk::TreeModel::Path path = m_refInstrumentsModelFilter->convert_path_to_child_path(rows[0]); + if (!path) return NULL; + //NOTE: was const_iterator before, which did not compile with GTKMM4 development branch, probably going to be fixed before final GTKMM4 release though. - Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); + Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(path); if (it) { Gtk::TreeModel::Row row = *it; - instrument = row[m_Columns.m_col_instr]; + instrument = row[m_InstrumentsModel.m_col_instr]; } return instrument; } @@ -1931,9 +1943,11 @@ { #if !USE_GTKMM_BUILDER // select item in instrument menu - std::vector rows = m_TreeView.get_selection()->get_selected_rows(); + std::vector rows = m_TreeViewInstruments.get_selection()->get_selected_rows(); if (!rows.empty()) { - Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); + // convert index of visual selection (i.e. if filtered) to index of model + Gtk::TreeModel::Path row = m_refInstrumentsModelFilter->convert_path_to_child_path(rows[0]); + Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(row); if (it) { Gtk::TreePath path(it); int index = path[0]; @@ -2141,7 +2155,7 @@ // forget all samples that ought to be imported m_SampleImportQueue.clear(); // clear the samples and instruments tree views - m_refTreeModel->clear(); + m_refInstrumentsTreeModel->clear(); m_refSamplesTreeModel->clear(); m_refScriptsTreeModel->clear(); #if !USE_GTKMM_BUILDER @@ -2158,7 +2172,7 @@ void MainWindow::__refreshEntireGUI() { // clear the samples and instruments tree views - m_refTreeModel->clear(); + m_refInstrumentsTreeModel->clear(); m_refSamplesTreeModel->clear(); m_refScriptsTreeModel->clear(); #if !USE_GTKMM_BUILDER @@ -2331,10 +2345,10 @@ { if (instrument == instr) { // select item in "instruments" tree view - m_TreeView.get_selection()->select(Gtk::TreePath(ToString(i))); + m_TreeViewInstruments.get_selection()->select(Gtk::TreePath(ToString(i))); // make sure the selected item in the "instruments" tree view is // visible (scroll to it) - m_TreeView.scroll_to_row(Gtk::TreePath(ToString(i))); + m_TreeViewInstruments.scroll_to_row(Gtk::TreePath(ToString(i))); #if !USE_GTKMM_BUILDER // select item in instrument menu { @@ -2698,7 +2712,7 @@ dimreg_stereo.set_has_tooltip(b); // Not doing this here, we let onQueryTreeViewTooltip() handle this per cell - //m_TreeView.set_has_tooltip(b); + //m_TreeViewInstruments.set_has_tooltip(b); m_TreeViewSamples.set_has_tooltip(b); m_TreeViewScripts.set_has_tooltip(b); @@ -3450,7 +3464,7 @@ bool MainWindow::onQueryTreeViewTooltip(int x, int y, bool keyboardTip, const Glib::RefPtr& tooltip) { Gtk::TreeModel::iterator iter; - if (!m_TreeView.get_tooltip_context_iter(x, y, keyboardTip, iter)) { + if (!m_TreeViewInstruments.get_tooltip_context_iter(x, y, keyboardTip, iter)) { return false; } Gtk::TreeModel::Path path(iter); @@ -3460,13 +3474,13 @@ { Gtk::TreeModel::Path path; // unused int cellX, cellY; // unused - m_TreeView.get_path_at_pos(x, y, path, pointedColumn, cellX, cellY); + m_TreeViewInstruments.get_path_at_pos(x, y, path, pointedColumn, cellX, cellY); } - Gtk::TreeViewColumn* scriptsColumn = m_TreeView.get_column(2); + Gtk::TreeViewColumn* scriptsColumn = m_TreeViewInstruments.get_column(2); if (pointedColumn == scriptsColumn) { // mouse hovers scripts column ... // show the script(s) assigned to the hovered instrument as tooltip - tooltip->set_markup( row[m_Columns.m_col_tooltip] ); - m_TreeView.set_tooltip_cell(tooltip, &path, scriptsColumn, NULL); + tooltip->set_markup( row[m_InstrumentsModel.m_col_tooltip] ); + m_TreeViewInstruments.set_tooltip_cell(tooltip, &path, scriptsColumn, NULL); } else { // if beginners' tooltips is disabled then don't show the following one if (!Settings::singleton()->showTooltips) @@ -3476,7 +3490,7 @@ "Right click here for actions on instruments & MIDI Rules. " "Drag & drop to change the order of instruments." )); - m_TreeView.set_tooltip_cell(tooltip, &path, pointedColumn, NULL); + m_TreeViewInstruments.set_tooltip_cell(tooltip, &path, pointedColumn, NULL); } return true; } @@ -3519,13 +3533,13 @@ Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); const int iScriptSlots = instrument->ScriptSlotCount(); - Gtk::TreeModel::iterator iter = m_refTreeModel->append(); + Gtk::TreeModel::iterator iter = m_refInstrumentsTreeModel->append(); Gtk::TreeModel::Row row = *iter; - row[m_Columns.m_col_nr] = index; - row[m_Columns.m_col_name] = name; - row[m_Columns.m_col_instr] = instrument; - row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : ""; - row[m_Columns.m_col_tooltip] = scriptTooltipFor(instrument, index); + row[m_InstrumentsModel.m_col_nr] = index; + row[m_InstrumentsModel.m_col_name] = name; + row[m_InstrumentsModel.m_col_instr] = instrument; + row[m_InstrumentsModel.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : ""; + row[m_InstrumentsModel.m_col_tooltip] = scriptTooltipFor(instrument, index); #if !USE_GTKMM_BUILDER add_instrument_to_menu(name); @@ -3587,7 +3601,7 @@ file = gig; // select the first instrument - m_TreeView.get_selection()->select(Gtk::TreePath("0")); + m_TreeViewInstruments.get_selection()->select(Gtk::TreePath("0")); instr_props_set_instrument(); gig::Instrument* instrument = get_instrument(); @@ -3600,16 +3614,21 @@ { instrumentProps.signal_name_changed().clear(); - std::vector rows = m_TreeView.get_selection()->get_selected_rows(); + // get visual selection + std::vector rows = m_TreeViewInstruments.get_selection()->get_selected_rows(); if (rows.empty()) { instrumentProps.hide(); return false; } + + // convert index of visual selection (i.e. if filtered) to index of model + Gtk::TreeModel::Path path = m_refInstrumentsModelFilter->convert_path_to_child_path(rows[0]); + //NOTE: was const_iterator before, which did not compile with GTKMM4 development branch, probably going to be fixed before final GTKMM4 release though. - Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); + Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(path); if (it) { Gtk::TreeModel::Row row = *it; - gig::Instrument* instrument = row[m_Columns.m_col_instr]; + gig::Instrument* instrument = row[m_InstrumentsModel.m_col_instr]; instrumentProps.set_instrument(instrument); @@ -3638,15 +3657,15 @@ void MainWindow::instr_name_changed_by_instr_props(Gtk::TreeModel::iterator& it) { Gtk::TreeModel::Row row = *it; - Glib::ustring name = row[m_Columns.m_col_name]; + Glib::ustring name = row[m_InstrumentsModel.m_col_name]; - gig::Instrument* instrument = row[m_Columns.m_col_instr]; + gig::Instrument* instrument = row[m_InstrumentsModel.m_col_instr]; Glib::ustring gigname(gig_to_utf8(instrument->pInfo->Name)); if (gigname != name) { Gtk::TreeModel::Path path(*it); const int index = path[0]; - row[m_Columns.m_col_name] = gigname; - row[m_Columns.m_col_tooltip] = scriptTooltipFor(instrument, index); + row[m_InstrumentsModel.m_col_name] = gigname; + row[m_InstrumentsModel.m_col_tooltip] = scriptTooltipFor(instrument, index); } } @@ -3716,13 +3735,9 @@ void MainWindow::show_script_slots() { if (!file) return; + // get selected instrument - std::vector rows = m_TreeView.get_selection()->get_selected_rows(); - if (rows.empty()) return; - Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); - if (!it) return; - Gtk::TreeModel::Row row = *it; - gig::Instrument* instrument = row[m_Columns.m_col_instr]; + gig::Instrument* instrument = get_instrument(); if (!instrument) return; ScriptSlots* window = new ScriptSlots; @@ -3738,20 +3753,23 @@ if (!pInstrument) return; const int iScriptSlots = pInstrument->ScriptSlotCount(); - //NOTE: This is a big mess! Sometimes GTK requires m_TreeView.get_model(), here we need m_refTreeModelFilter->get_model(), otherwise accessing children below causes an error! - //Glib::RefPtr model = m_TreeView.get_model(); - Glib::RefPtr model = m_refTreeModelFilter->get_model(); + //NOTE: This is a big mess! Sometimes GTK requires m_TreeViewInstruments.get_model(), here we need m_refInstrumentsModelFilter->get_model(), otherwise accessing children below causes an error! + //Glib::RefPtr model = m_TreeViewInstruments.get_model(); + Glib::RefPtr model = m_refInstrumentsModelFilter->get_model(); for (int i = 0; i < model->children().size(); ++i) { Gtk::TreeModel::Row row = model->children()[i]; - if (row[m_Columns.m_col_instr] != pInstrument) continue; - row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : ""; - row[m_Columns.m_col_tooltip] = scriptTooltipFor(pInstrument, i); + if (row[m_InstrumentsModel.m_col_instr] != pInstrument) continue; + row[m_InstrumentsModel.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : ""; + row[m_InstrumentsModel.m_col_tooltip] = scriptTooltipFor(pInstrument, i); break; } // causes the sampler to reload the instrument with the new script on_sel_change(); + + // force script 'patch' variables editor ("Script" tab) to be refreshed + dimreg_edit.scriptVars.setInstrument(pInstrument, true/*force update*/); } void MainWindow::assignScript(gig::Script* pScript) { @@ -3958,7 +3976,7 @@ find(children.begin(), children.end(), item); if (it != children.end()) { int index = it - children.begin(); - m_TreeView.get_selection()->select(Gtk::TreePath(ToString(index))); + m_TreeViewInstruments.get_selection()->select(Gtk::TreePath(ToString(index))); m_RegionChooser.set_instrument(file->GetInstrument(index)); } @@ -4029,27 +4047,27 @@ void MainWindow::select_instrument(gig::Instrument* instrument) { if (!instrument) return; - //NOTE: This is a big mess! Sometimes GTK requires m_refTreeModelFilter->get_model(), here we need m_TreeView.get_model(), otherwise treeview selection below causes an error! - Glib::RefPtr model = m_TreeView.get_model(); - //Glib::RefPtr model = m_refTreeModelFilter->get_model(); + //NOTE: This is a big mess! Sometimes GTK requires m_refInstrumentsModelFilter->get_model(), here we need m_TreeViewInstruments.get_model(), otherwise treeview selection below causes an error! + Glib::RefPtr model = m_TreeViewInstruments.get_model(); + //Glib::RefPtr model = m_refInstrumentsModelFilter->get_model(); for (int i = 0; i < model->children().size(); ++i) { Gtk::TreeModel::Row row = model->children()[i]; - if (row[m_Columns.m_col_instr] == instrument) { + if (row[m_InstrumentsModel.m_col_instr] == instrument) { // select and show the respective instrument in the list view show_intruments_tab(); - m_TreeView.get_selection()->unselect_all(); + m_TreeViewInstruments.get_selection()->unselect_all(); #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) auto iterSel = model->children()[i].get_iter(); - m_TreeView.get_selection()->select(iterSel); + m_TreeViewInstruments.get_selection()->select(iterSel); #else - m_TreeView.get_selection()->select(model->children()[i]); + m_TreeViewInstruments.get_selection()->select(model->children()[i]); #endif std::vector rows = - m_TreeView.get_selection()->get_selected_rows(); + m_TreeViewInstruments.get_selection()->get_selected_rows(); if (!rows.empty()) - m_TreeView.scroll_to_row(rows[0]); + m_TreeViewInstruments.scroll_to_row(rows[0]); on_sel_change(); // the regular instrument selection change callback } } @@ -4060,26 +4078,26 @@ gig::Region* pRegion = (gig::Region*) dimRgn->GetParent(); gig::Instrument* pInstrument = (gig::Instrument*) pRegion->GetParent(); - //NOTE: This is a big mess! Sometimes GTK requires m_refTreeModelFilter->get_model(), here we need m_TreeView.get_model(), otherwise treeview selection below causes an error! - Glib::RefPtr model = m_TreeView.get_model(); - //Glib::RefPtr model = m_refTreeModelFilter->get_model(); + //NOTE: This is a big mess! Sometimes GTK requires m_refInstrumentsModelFilter->get_model(), here we need m_TreeViewInstruments.get_model(), otherwise treeview selection below causes an error! + Glib::RefPtr model = m_TreeViewInstruments.get_model(); + //Glib::RefPtr model = m_refInstrumentsModelFilter->get_model(); for (int i = 0; i < model->children().size(); ++i) { Gtk::TreeModel::Row row = model->children()[i]; - if (row[m_Columns.m_col_instr] == pInstrument) { + if (row[m_InstrumentsModel.m_col_instr] == pInstrument) { // select and show the respective instrument in the list view show_intruments_tab(); - m_TreeView.get_selection()->unselect_all(); + m_TreeViewInstruments.get_selection()->unselect_all(); #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) auto iterSel = model->children()[i].get_iter(); - m_TreeView.get_selection()->select(iterSel); + m_TreeViewInstruments.get_selection()->select(iterSel); #else - m_TreeView.get_selection()->select(model->children()[i]); + m_TreeViewInstruments.get_selection()->select(model->children()[i]); #endif std::vector rows = - m_TreeView.get_selection()->get_selected_rows(); + m_TreeViewInstruments.get_selection()->get_selected_rows(); if (!rows.empty()) - m_TreeView.scroll_to_row(rows[0]); + m_TreeViewInstruments.scroll_to_row(rows[0]); on_sel_change(); // the regular instrument selection change callback // select respective region in the region selector @@ -4364,14 +4382,15 @@ // update instrument tree view instrument_name_connection.block(); - Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append(); + Gtk::TreeModel::iterator iterInstr = m_refInstrumentsTreeModel->append(); Gtk::TreeModel::Row rowInstr = *iterInstr; - const int index = m_refTreeModel->children().size() - 1; - rowInstr[m_Columns.m_col_nr] = index; - rowInstr[m_Columns.m_col_name] = name; - rowInstr[m_Columns.m_col_instr] = instrument; - rowInstr[m_Columns.m_col_scripts] = ""; - rowInstr[m_Columns.m_col_tooltip] = scriptTooltipFor(instrument, index); + const int index = m_refInstrumentsTreeModel->children().size() - 1; + const int iScriptSlots = instrument->ScriptSlotCount(); + rowInstr[m_InstrumentsModel.m_col_nr] = index; + rowInstr[m_InstrumentsModel.m_col_name] = name; + rowInstr[m_InstrumentsModel.m_col_instr] = instrument; + rowInstr[m_InstrumentsModel.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : ""; + rowInstr[m_InstrumentsModel.m_col_tooltip] = scriptTooltipFor(instrument, index); instrument_name_connection.unblock(); #if !USE_GTKMM_BUILDER @@ -4397,13 +4416,13 @@ // retrieve the currently selected instrument // (being the original instrument to be duplicated) - Glib::RefPtr sel = m_TreeView.get_selection(); + Glib::RefPtr sel = m_TreeViewInstruments.get_selection(); std::vector rows = sel->get_selected_rows(); for (int r = 0; r < rows.size(); ++r) { - Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]); + Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(rows[r]); if (it) { Gtk::TreeModel::Row row = *it; - gig::Instrument* instrOrig = row[m_Columns.m_col_instr]; + gig::Instrument* instrOrig = row[m_InstrumentsModel.m_col_instr]; if (instrOrig) { // duplicate the orginal instrument gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig); @@ -4430,13 +4449,13 @@ return; } - Glib::RefPtr sel = m_TreeView.get_selection(); + Glib::RefPtr sel = m_TreeViewInstruments.get_selection(); std::vector rows = sel->get_selected_rows(); for (int r = rows.size() - 1; r >= 0; --r) { - Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]); + Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(rows[r]); if (!it) continue; Gtk::TreeModel::Row row = *it; - gig::Instrument* instr = row[m_Columns.m_col_instr]; + gig::Instrument* instr = row[m_InstrumentsModel.m_col_instr]; try { Gtk::TreePath path(it); int index = path[0]; @@ -4450,28 +4469,28 @@ #endif // remove row from instruments tree view - m_refTreeModel->erase(it); + m_refInstrumentsTreeModel->erase(it); // update "Nr" column of all instrument rows { int index = 0; - for (Gtk::TreeModel::iterator it = m_refTreeModel->children().begin(); - it != m_refTreeModel->children().end(); ++it, ++index) + for (Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->children().begin(); + it != m_refInstrumentsTreeModel->children().end(); ++it, ++index) { Gtk::TreeModel::Row row = *it; - gig::Instrument* instrument = row[m_Columns.m_col_instr]; - row[m_Columns.m_col_nr] = index; - row[m_Columns.m_col_tooltip] = scriptTooltipFor(instrument, index); + gig::Instrument* instrument = row[m_InstrumentsModel.m_col_instr]; + row[m_InstrumentsModel.m_col_nr] = index; + row[m_InstrumentsModel.m_col_tooltip] = scriptTooltipFor(instrument, index); } } #if GTKMM_MAJOR_VERSION < 3 // select another instrument (in gtk3 this is done // automatically) - if (!m_refTreeModel->children().empty()) { - if (index == m_refTreeModel->children().size()) { + if (!m_refInstrumentsTreeModel->children().empty()) { + if (index == m_refInstrumentsTreeModel->children().size()) { index--; } - m_TreeView.get_selection()->select( + m_TreeViewInstruments.get_selection()->select( Gtk::TreePath(ToString(index))); } #endif @@ -4553,15 +4572,22 @@ if (!it) return; Gtk::TreeModel::Row row = *it; gig::Script* script = row[m_ScriptsModel.m_col_script]; - if (!script) return; + editScript(script); +} +void MainWindow::editScript(gig::Script* script) { + if (!script) return; ScriptEditor* editor = new ScriptEditor; editor->signal_script_to_be_changed.connect( signal_script_to_be_changed.make_slot() ); - editor->signal_script_changed.connect( - signal_script_changed.make_slot() - ); + editor->signal_script_changed.connect([this](gig::Script* script) { + // signal to sampler (which will reload the script due to this) + signal_script_changed.emit(script); + // force script 'patch' variables editor ("Script" tab) to be refreshed + gig::Instrument* instr = get_instrument(); + dimreg_edit.scriptVars.setInstrument(instr, true/*force update*/); + }); editor->setScript(script); //editor->reparent(*this); editor->show(); @@ -5116,13 +5142,13 @@ // get selected source instrument gig::Instrument* src = NULL; { - Glib::RefPtr sel = m_TreeView.get_selection(); + Glib::RefPtr sel = m_TreeViewInstruments.get_selection(); std::vector rows = sel->get_selected_rows(); if (!rows.empty()) { - Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); + Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(rows[0]); if (it) { Gtk::TreeModel::Row row = *it; - src = row[m_Columns.m_col_instr]; + src = row[m_InstrumentsModel.m_col_instr]; } } } @@ -5144,13 +5170,13 @@ gig::Instrument* dst = NULL; { Gtk::TreeModel::Path path; - const bool found = m_TreeView.get_path_at_pos(x, y, path); + const bool found = m_TreeViewInstruments.get_path_at_pos(x, y, path); if (!found) return; - Gtk::TreeModel::iterator iter = m_refTreeModel->get_iter(path); + Gtk::TreeModel::iterator iter = m_refInstrumentsTreeModel->get_iter(path); if (!iter) return; Gtk::TreeModel::Row row = *iter; - dst = row[m_Columns.m_col_instr]; + dst = row[m_InstrumentsModel.m_col_instr]; } if (!dst) return; @@ -5325,25 +5351,14 @@ if (!iter) return; Gtk::TreeModel::Row row = *iter; gig::Script* script = row[m_ScriptsModel.m_col_script]; - if (!script) return; - - ScriptEditor* editor = new ScriptEditor; - editor->signal_script_to_be_changed.connect( - signal_script_to_be_changed.make_slot() - ); - editor->signal_script_changed.connect( - signal_script_changed.make_slot() - ); - editor->setScript(script); - //editor->reparent(*this); - editor->show(); + editScript(script); } void MainWindow::instrument_name_changed(const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator& iter) { if (!iter) return; Gtk::TreeModel::Row row = *iter; - Glib::ustring name = row[m_Columns.m_col_name]; + Glib::ustring name = row[m_InstrumentsModel.m_col_name]; #if !USE_GTKMM_BUILDER // change name in instrument menu @@ -5361,7 +5376,7 @@ #endif // change name in gig - gig::Instrument* instrument = row[m_Columns.m_col_instr]; + gig::Instrument* instrument = row[m_InstrumentsModel.m_col_instr]; gig::String gigname(gig_from_utf8(name)); if (instrument && instrument->pInfo->Name != gigname) { instrument->pInfo->Name = gigname; @@ -5389,7 +5404,7 @@ #else Gtk::TreeModel::Row row = *iter; #endif - Glib::ustring name = row[m_Columns.m_col_name]; + Glib::ustring name = row[m_InstrumentsModel.m_col_name]; name = name.lowercase(); std::vector tokens = Glib::Regex::split_simple(" ", pattern); @@ -5407,13 +5422,13 @@ // list view as pre-selection std::set indeces; { - Glib::RefPtr sel = m_TreeView.get_selection(); + Glib::RefPtr sel = m_TreeViewInstruments.get_selection(); std::vector rows = sel->get_selected_rows(); for (int r = 0; r < rows.size(); ++r) { - Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]); + Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(rows[r]); if (it) { Gtk::TreeModel::Row row = *it; - int index = row[m_Columns.m_col_nr]; + int index = row[m_InstrumentsModel.m_col_nr]; indeces.insert(index); } }