46 |
#include "Settings.h" |
#include "Settings.h" |
47 |
#include "CombineInstrumentsDialog.h" |
#include "CombineInstrumentsDialog.h" |
48 |
#include "scripteditor.h" |
#include "scripteditor.h" |
49 |
|
#include "scriptslots.h" |
50 |
|
#include "ReferencesView.h" |
51 |
#include "../../gfx/status_attached.xpm" |
#include "../../gfx/status_attached.xpm" |
52 |
#include "../../gfx/status_detached.xpm" |
#include "../../gfx/status_detached.xpm" |
53 |
|
|
54 |
|
|
55 |
MainWindow::MainWindow() : |
MainWindow::MainWindow() : |
56 |
|
m_DimRegionChooser(*this), |
57 |
dimreg_label(_("Changes apply to:")), |
dimreg_label(_("Changes apply to:")), |
58 |
dimreg_all_regions(_("all regions")), |
dimreg_all_regions(_("all regions")), |
59 |
dimreg_all_dimregs(_("all dimension splits")), |
dimreg_all_dimregs(_("all dimension splits")), |
137 |
sigc::mem_fun( |
sigc::mem_fun( |
138 |
*this, &MainWindow::show_instr_props)); |
*this, &MainWindow::show_instr_props)); |
139 |
actionGroup->add(Gtk::Action::create("MidiRules", |
actionGroup->add(Gtk::Action::create("MidiRules", |
140 |
_("_Midi Rules")), |
_("_Midi Rules...")), |
141 |
sigc::mem_fun( |
sigc::mem_fun( |
142 |
*this, &MainWindow::show_midi_rules)); |
*this, &MainWindow::show_midi_rules)); |
143 |
|
actionGroup->add(Gtk::Action::create("ScriptSlots", |
144 |
|
_("_Script Slots...")), |
145 |
|
sigc::mem_fun( |
146 |
|
*this, &MainWindow::show_script_slots)); |
147 |
actionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT), |
actionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT), |
148 |
sigc::mem_fun( |
sigc::mem_fun( |
149 |
*this, &MainWindow::on_action_quit)); |
*this, &MainWindow::on_action_quit)); |
150 |
actionGroup->add(Gtk::Action::create("MenuInstrument", _("_Instrument"))); |
actionGroup->add( |
151 |
|
Gtk::Action::create("MenuSample", _("_Sample")), |
152 |
|
sigc::mem_fun(*this, &MainWindow::show_samples_tab) |
153 |
|
); |
154 |
|
actionGroup->add( |
155 |
|
Gtk::Action::create("MenuInstrument", _("_Instrument")), |
156 |
|
sigc::mem_fun(*this, &MainWindow::show_intruments_tab) |
157 |
|
); |
158 |
|
actionGroup->add( |
159 |
|
Gtk::Action::create("MenuScript", _("S_cript")), |
160 |
|
sigc::mem_fun(*this, &MainWindow::show_scripts_tab) |
161 |
|
); |
162 |
|
actionGroup->add(Gtk::Action::create("AllInstruments", _("_Select"))); |
163 |
|
|
164 |
actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit"))); |
actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit"))); |
165 |
|
|
249 |
sigc::mem_fun(*this, &MainWindow::on_action_remove_sample) |
sigc::mem_fun(*this, &MainWindow::on_action_remove_sample) |
250 |
); |
); |
251 |
actionGroup->add( |
actionGroup->add( |
252 |
|
Gtk::Action::create("ShowSampleRefs", _("Show References...")), |
253 |
|
sigc::mem_fun(*this, &MainWindow::on_action_view_references) |
254 |
|
); |
255 |
|
actionGroup->add( |
256 |
Gtk::Action::create("ReplaceAllSamplesInAllGroups", |
Gtk::Action::create("ReplaceAllSamplesInAllGroups", |
257 |
_("Replace All Samples in All Groups...")), |
_("Replace All Samples in All Groups...")), |
258 |
sigc::mem_fun(*this, &MainWindow::on_action_replace_all_samples_in_all_groups) |
sigc::mem_fun(*this, &MainWindow::on_action_replace_all_samples_in_all_groups) |
299 |
" <menuitem action='CopySampleTune'/>" |
" <menuitem action='CopySampleTune'/>" |
300 |
" <menuitem action='CopySampleLoop'/>" |
" <menuitem action='CopySampleLoop'/>" |
301 |
" </menu>" |
" </menu>" |
302 |
|
" <menu action='MenuSample'>" |
303 |
|
" <menuitem action='SampleProperties'/>" |
304 |
|
" <menuitem action='AddGroup'/>" |
305 |
|
" <menuitem action='AddSample'/>" |
306 |
|
" <menuitem action='ShowSampleRefs'/>" |
307 |
|
" <menuitem action='ReplaceAllSamplesInAllGroups' />" |
308 |
|
" <separator/>" |
309 |
|
" <menuitem action='RemoveSample'/>" |
310 |
|
" </menu>" |
311 |
" <menu action='MenuInstrument'>" |
" <menu action='MenuInstrument'>" |
312 |
|
" <menu action='AllInstruments'>" |
313 |
|
" </menu>" |
314 |
|
" <separator/>" |
315 |
|
" <menuitem action='InstrProperties'/>" |
316 |
|
" <menuitem action='MidiRules'/>" |
317 |
|
" <menuitem action='ScriptSlots'/>" |
318 |
|
" <menuitem action='AddInstrument'/>" |
319 |
|
" <menuitem action='DupInstrument'/>" |
320 |
|
" <separator/>" |
321 |
|
" <menuitem action='RemoveInstrument'/>" |
322 |
|
" </menu>" |
323 |
|
" <menu action='MenuScript'>" |
324 |
|
" <menuitem action='AddScriptGroup'/>" |
325 |
|
" <menuitem action='AddScript'/>" |
326 |
|
" <menuitem action='EditScript'/>" |
327 |
|
" <separator/>" |
328 |
|
" <menuitem action='RemoveScript'/>" |
329 |
" </menu>" |
" </menu>" |
330 |
" <menu action='MenuView'>" |
" <menu action='MenuView'>" |
331 |
" <menuitem action='Statusbar'/>" |
" <menuitem action='Statusbar'/>" |
344 |
" <popup name='PopupMenu'>" |
" <popup name='PopupMenu'>" |
345 |
" <menuitem action='InstrProperties'/>" |
" <menuitem action='InstrProperties'/>" |
346 |
" <menuitem action='MidiRules'/>" |
" <menuitem action='MidiRules'/>" |
347 |
|
" <menuitem action='ScriptSlots'/>" |
348 |
" <menuitem action='AddInstrument'/>" |
" <menuitem action='AddInstrument'/>" |
349 |
" <menuitem action='DupInstrument'/>" |
" <menuitem action='DupInstrument'/>" |
350 |
" <separator/>" |
" <separator/>" |
354 |
" <menuitem action='SampleProperties'/>" |
" <menuitem action='SampleProperties'/>" |
355 |
" <menuitem action='AddGroup'/>" |
" <menuitem action='AddGroup'/>" |
356 |
" <menuitem action='AddSample'/>" |
" <menuitem action='AddSample'/>" |
357 |
|
" <menuitem action='ShowSampleRefs'/>" |
358 |
" <menuitem action='ReplaceAllSamplesInAllGroups' />" |
" <menuitem action='ReplaceAllSamplesInAllGroups' />" |
359 |
" <separator/>" |
" <separator/>" |
360 |
" <menuitem action='RemoveSample'/>" |
" <menuitem action='RemoveSample'/>" |
408 |
|
|
409 |
|
|
410 |
instrument_menu = static_cast<Gtk::MenuItem*>( |
instrument_menu = static_cast<Gtk::MenuItem*>( |
411 |
uiManager->get_widget("/MenuBar/MenuInstrument"))->get_submenu(); |
uiManager->get_widget("/MenuBar/MenuInstrument/AllInstruments"))->get_submenu(); |
412 |
|
|
413 |
Gtk::Widget* menuBar = uiManager->get_widget("/MenuBar"); |
Gtk::Widget* menuBar = uiManager->get_widget("/MenuBar"); |
414 |
m_VBox.pack_start(*menuBar, Gtk::PACK_SHRINK); |
m_VBox.pack_start(*menuBar, Gtk::PACK_SHRINK); |
448 |
m_TreeViewSamples.set_model(m_refSamplesTreeModel); |
m_TreeViewSamples.set_model(m_refSamplesTreeModel); |
449 |
m_TreeViewSamples.set_tooltip_text(_("To actually use a sample, drag it from this list view to \"Sample\" -> \"Sample:\" on the region's settings pane on the right.\n\nRight click here for more actions on samples.")); |
m_TreeViewSamples.set_tooltip_text(_("To actually use a sample, drag it from this list view to \"Sample\" -> \"Sample:\" on the region's settings pane on the right.\n\nRight click here for more actions on samples.")); |
450 |
// m_TreeViewSamples.set_reorderable(); |
// m_TreeViewSamples.set_reorderable(); |
451 |
m_TreeViewSamples.append_column_editable("Samples", m_SamplesModel.m_col_name); |
m_TreeViewSamples.append_column_editable(_("Name"), m_SamplesModel.m_col_name); |
452 |
m_TreeViewSamples.set_headers_visible(false); |
m_TreeViewSamples.append_column(_("Referenced"), m_SamplesModel.m_col_refcount); |
453 |
|
{ |
454 |
|
Gtk::TreeViewColumn* column = m_TreeViewSamples.get_column(0); |
455 |
|
Gtk::CellRendererText* cellrenderer = |
456 |
|
dynamic_cast<Gtk::CellRendererText*>(column->get_first_cell()); |
457 |
|
column->add_attribute( |
458 |
|
cellrenderer->property_foreground(), m_SamplesModel.m_color |
459 |
|
); |
460 |
|
} |
461 |
|
{ |
462 |
|
Gtk::TreeViewColumn* column = m_TreeViewSamples.get_column(1); |
463 |
|
Gtk::CellRendererText* cellrenderer = |
464 |
|
dynamic_cast<Gtk::CellRendererText*>(column->get_first_cell()); |
465 |
|
column->add_attribute( |
466 |
|
cellrenderer->property_foreground(), m_SamplesModel.m_color |
467 |
|
); |
468 |
|
} |
469 |
|
m_TreeViewSamples.set_headers_visible(true); |
470 |
m_TreeViewSamples.signal_button_press_event().connect_notify( |
m_TreeViewSamples.signal_button_press_event().connect_notify( |
471 |
sigc::mem_fun(*this, &MainWindow::on_sample_treeview_button_release) |
sigc::mem_fun(*this, &MainWindow::on_sample_treeview_button_release) |
472 |
); |
); |
478 |
m_refScriptsTreeModel = ScriptsTreeStore::create(m_ScriptsModel); |
m_refScriptsTreeModel = ScriptsTreeStore::create(m_ScriptsModel); |
479 |
m_TreeViewScripts.set_model(m_refScriptsTreeModel); |
m_TreeViewScripts.set_model(m_refScriptsTreeModel); |
480 |
m_TreeViewScripts.set_tooltip_text(_( |
m_TreeViewScripts.set_tooltip_text(_( |
481 |
|
"Use CTRL + double click for editing a script." |
482 |
|
"\n\n" |
483 |
"Note: instrument scripts are a LinuxSampler extension of the gig " |
"Note: instrument scripts are a LinuxSampler extension of the gig " |
484 |
"format. This feature will not work with the GigaStudio software!" |
"format. This feature will not work with the GigaStudio software!" |
485 |
)); |
)); |
489 |
m_TreeViewScripts.signal_button_press_event().connect_notify( |
m_TreeViewScripts.signal_button_press_event().connect_notify( |
490 |
sigc::mem_fun(*this, &MainWindow::on_script_treeview_button_release) |
sigc::mem_fun(*this, &MainWindow::on_script_treeview_button_release) |
491 |
); |
); |
492 |
|
//FIXME: why the heck does this double click signal_row_activated() only fired while CTRL key is pressed ? |
493 |
|
m_TreeViewScripts.signal_row_activated().connect( |
494 |
|
sigc::mem_fun(*this, &MainWindow::script_double_clicked) |
495 |
|
); |
496 |
m_refScriptsTreeModel->signal_row_changed().connect( |
m_refScriptsTreeModel->signal_row_changed().connect( |
497 |
sigc::mem_fun(*this, &MainWindow::script_name_changed) |
sigc::mem_fun(*this, &MainWindow::script_name_changed) |
498 |
); |
); |
499 |
|
|
500 |
|
// establish drag&drop between scripts tree view and ScriptSlots window |
501 |
|
std::vector<Gtk::TargetEntry> drag_target_gig_script; |
502 |
|
drag_target_gig_script.push_back(Gtk::TargetEntry("gig::Script")); |
503 |
|
m_TreeViewScripts.drag_source_set(drag_target_gig_script); |
504 |
|
m_TreeViewScripts.signal_drag_begin().connect( |
505 |
|
sigc::mem_fun(*this, &MainWindow::on_scripts_treeview_drag_begin) |
506 |
|
); |
507 |
|
m_TreeViewScripts.signal_drag_data_get().connect( |
508 |
|
sigc::mem_fun(*this, &MainWindow::on_scripts_treeview_drag_data_get) |
509 |
|
); |
510 |
|
|
511 |
// establish drag&drop between samples tree view and dimension region 'Sample' text entry |
// establish drag&drop between samples tree view and dimension region 'Sample' text entry |
512 |
std::vector<Gtk::TargetEntry> drag_target_gig_sample; |
std::vector<Gtk::TargetEntry> drag_target_gig_sample; |
513 |
drag_target_gig_sample.push_back(Gtk::TargetEntry("gig::Sample")); |
drag_target_gig_sample.push_back(Gtk::TargetEntry("gig::Sample")); |
541 |
dimreg_changed_signal.make_slot()); |
dimreg_changed_signal.make_slot()); |
542 |
dimreg_edit.signal_sample_ref_changed().connect( |
dimreg_edit.signal_sample_ref_changed().connect( |
543 |
sample_ref_changed_signal.make_slot()); |
sample_ref_changed_signal.make_slot()); |
544 |
|
sample_ref_changed_signal.connect( |
545 |
|
sigc::mem_fun(*this, &MainWindow::on_sample_ref_changed) |
546 |
|
); |
547 |
|
samples_to_be_removed_signal.connect( |
548 |
|
sigc::mem_fun(*this, &MainWindow::on_samples_to_be_removed) |
549 |
|
); |
550 |
|
|
551 |
m_RegionChooser.signal_instrument_struct_to_be_changed().connect( |
m_RegionChooser.signal_instrument_struct_to_be_changed().connect( |
552 |
sigc::hide( |
sigc::hide( |
672 |
void MainWindow::dimreg_changed() |
void MainWindow::dimreg_changed() |
673 |
{ |
{ |
674 |
update_dimregs(); |
update_dimregs(); |
675 |
dimreg_edit.set_dim_region(m_DimRegionChooser.get_dimregion()); |
dimreg_edit.set_dim_region(m_DimRegionChooser.get_main_dimregion()); |
676 |
} |
} |
677 |
|
|
678 |
void MainWindow::on_sel_change() |
void MainWindow::on_sel_change() |
770 |
// clear the samples and instruments tree views |
// clear the samples and instruments tree views |
771 |
m_refTreeModel->clear(); |
m_refTreeModel->clear(); |
772 |
m_refSamplesTreeModel->clear(); |
m_refSamplesTreeModel->clear(); |
773 |
|
m_refScriptsTreeModel->clear(); |
774 |
// remove all entries from "Instrument" menu |
// remove all entries from "Instrument" menu |
775 |
while (!instrument_menu->get_children().empty()) { |
while (!instrument_menu->get_children().empty()) { |
776 |
remove_instrument_from_menu(0); |
remove_instrument_from_menu(0); |
785 |
// clear the samples and instruments tree views |
// clear the samples and instruments tree views |
786 |
m_refTreeModel->clear(); |
m_refTreeModel->clear(); |
787 |
m_refSamplesTreeModel->clear(); |
m_refSamplesTreeModel->clear(); |
788 |
|
m_refScriptsTreeModel->clear(); |
789 |
// remove all entries from "Instrument" menu |
// remove all entries from "Instrument" menu |
790 |
while (!instrument_menu->get_children().empty()) { |
while (!instrument_menu->get_children().empty()) { |
791 |
remove_instrument_from_menu(0); |
remove_instrument_from_menu(0); |
902 |
// load the instrument |
// load the instrument |
903 |
gig::File* pFile = (gig::File*) instr->GetParent(); |
gig::File* pFile = (gig::File*) instr->GetParent(); |
904 |
load_gig(pFile, 0 /*file name*/, true /*shared instrument*/); |
load_gig(pFile, 0 /*file name*/, true /*shared instrument*/); |
905 |
//TODO: automatically select the given instrument |
// automatically select the given instrument |
906 |
|
int i = 0; |
907 |
|
for (gig::Instrument* instrument = pFile->GetFirstInstrument(); instrument; |
908 |
|
instrument = pFile->GetNextInstrument(), ++i) |
909 |
|
{ |
910 |
|
if (instrument == instr) { |
911 |
|
// select item in "instruments" tree view |
912 |
|
m_TreeView.get_selection()->select(Gtk::TreePath(ToString(i))); |
913 |
|
// make sure the selected item in the "instruments" tree view is |
914 |
|
// visible (scroll to it) |
915 |
|
m_TreeView.scroll_to_row(Gtk::TreePath(ToString(i))); |
916 |
|
// select item in instrument menu |
917 |
|
{ |
918 |
|
const std::vector<Gtk::Widget*> children = |
919 |
|
instrument_menu->get_children(); |
920 |
|
static_cast<Gtk::RadioMenuItem*>(children[i])->set_active(); |
921 |
|
} |
922 |
|
// update region chooser and dimension region chooser |
923 |
|
m_RegionChooser.set_instrument(instr); |
924 |
|
break; |
925 |
|
} |
926 |
|
} |
927 |
} |
} |
928 |
|
|
929 |
void MainWindow::on_loader_progress() |
void MainWindow::on_loader_progress() |
1204 |
_( |
_( |
1205 |
"Gigedit is released under the GNU General Public License.\n" |
"Gigedit is released under the GNU General Public License.\n" |
1206 |
"\n" |
"\n" |
1207 |
"Please notice that this is still a very young instrument editor. " |
"This program is distributed WITHOUT ANY WARRANTY; So better " |
1208 |
"So better backup your Gigasampler files before editing them with " |
"backup your Gigasampler/GigaStudio files before editing them with " |
1209 |
"this application.\n" |
"this application.\n" |
1210 |
"\n" |
"\n" |
1211 |
"Please report bugs to: http://bugs.linuxsampler.org" |
"Please report bugs to: http://bugs.linuxsampler.org" |
1454 |
} |
} |
1455 |
} |
} |
1456 |
|
|
1457 |
|
void MainWindow::updateSampleRefCountMap(gig::File* gig) { |
1458 |
|
sample_ref_count.clear(); |
1459 |
|
|
1460 |
|
if (!gig) return; |
1461 |
|
|
1462 |
|
for (gig::Instrument* instrument = gig->GetFirstInstrument(); instrument; |
1463 |
|
instrument = gig->GetNextInstrument()) |
1464 |
|
{ |
1465 |
|
for (gig::Region* rgn = instrument->GetFirstRegion(); rgn; |
1466 |
|
rgn = instrument->GetNextRegion()) |
1467 |
|
{ |
1468 |
|
for (int i = 0; i < 256; ++i) { |
1469 |
|
if (!rgn->pDimensionRegions[i]) continue; |
1470 |
|
if (rgn->pDimensionRegions[i]->pSample) { |
1471 |
|
sample_ref_count[rgn->pDimensionRegions[i]->pSample]++; |
1472 |
|
} |
1473 |
|
} |
1474 |
|
} |
1475 |
|
} |
1476 |
|
} |
1477 |
|
|
1478 |
void MainWindow::load_gig(gig::File* gig, const char* filename, bool isSharedInstrument) |
void MainWindow::load_gig(gig::File* gig, const char* filename, bool isSharedInstrument) |
1479 |
{ |
{ |
1480 |
file = 0; |
file = 0; |
1501 |
add_instrument_to_menu(name); |
add_instrument_to_menu(name); |
1502 |
} |
} |
1503 |
instrument_name_connection.unblock(); |
instrument_name_connection.unblock(); |
1504 |
uiManager->get_widget("/MenuBar/MenuInstrument")->show(); |
uiManager->get_widget("/MenuBar/MenuInstrument/AllInstruments")->show(); |
1505 |
|
|
1506 |
|
updateSampleRefCountMap(gig); |
1507 |
|
|
1508 |
for (gig::Group* group = gig->GetFirstGroup(); group; group = gig->GetNextGroup()) { |
for (gig::Group* group = gig->GetFirstGroup(); group; group = gig->GetNextGroup()) { |
1509 |
if (group->Name != "") { |
if (group->Name != "") { |
1521 |
gig_to_utf8(sample->pInfo->Name); |
gig_to_utf8(sample->pInfo->Name); |
1522 |
rowSample[m_SamplesModel.m_col_sample] = sample; |
rowSample[m_SamplesModel.m_col_sample] = sample; |
1523 |
rowSample[m_SamplesModel.m_col_group] = NULL; |
rowSample[m_SamplesModel.m_col_group] = NULL; |
1524 |
|
int refcount = sample_ref_count.count(sample) ? sample_ref_count[sample] : 0; |
1525 |
|
rowSample[m_SamplesModel.m_col_refcount] = ToString(refcount) + " " + _("Refs."); |
1526 |
|
rowSample[m_SamplesModel.m_color] = refcount ? "black" : "red"; |
1527 |
} |
} |
1528 |
} |
} |
1529 |
} |
} |
1547 |
rowScript[m_ScriptsModel.m_col_group] = NULL; |
rowScript[m_ScriptsModel.m_col_group] = NULL; |
1548 |
} |
} |
1549 |
} |
} |
1550 |
// unfold all script groups by default |
// unfold all sample groups & script groups by default |
1551 |
|
m_TreeViewSamples.expand_all(); |
1552 |
m_TreeViewScripts.expand_all(); |
m_TreeViewScripts.expand_all(); |
1553 |
|
|
1554 |
file = gig; |
file = gig; |
1618 |
} |
} |
1619 |
} |
} |
1620 |
|
|
1621 |
|
void MainWindow::show_script_slots() { |
1622 |
|
if (!file) return; |
1623 |
|
// get selected instrument |
1624 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
1625 |
|
Gtk::TreeModel::iterator it = sel->get_selected(); |
1626 |
|
if (!it) return; |
1627 |
|
Gtk::TreeModel::Row row = *it; |
1628 |
|
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
1629 |
|
if (!instrument) return; |
1630 |
|
|
1631 |
|
ScriptSlots* window = new ScriptSlots; |
1632 |
|
window->setInstrument(instrument); |
1633 |
|
//window->reparent(*this); |
1634 |
|
window->show(); |
1635 |
|
} |
1636 |
|
|
1637 |
void MainWindow::on_action_view_status_bar() { |
void MainWindow::on_action_view_status_bar() { |
1638 |
Gtk::CheckMenuItem* item = |
Gtk::CheckMenuItem* item = |
1639 |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar")); |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar")); |
1681 |
show_instr_props(); |
show_instr_props(); |
1682 |
} else if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
} else if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
1683 |
// gig v2 files have no midi rules |
// gig v2 files have no midi rules |
1684 |
|
const bool bEnabled = !(file->pVersion && file->pVersion->major == 2); |
1685 |
|
static_cast<Gtk::MenuItem*>( |
1686 |
|
uiManager->get_widget("/MenuBar/MenuInstrument/MidiRules"))->set_sensitive( |
1687 |
|
bEnabled |
1688 |
|
); |
1689 |
static_cast<Gtk::MenuItem*>( |
static_cast<Gtk::MenuItem*>( |
1690 |
uiManager->get_widget("/PopupMenu/MidiRules"))->set_sensitive( |
uiManager->get_widget("/PopupMenu/MidiRules"))->set_sensitive( |
1691 |
!(file->pVersion && file->pVersion->major == 2)); |
bEnabled |
1692 |
|
); |
1693 |
popup_menu->popup(button->button, button->time); |
popup_menu->popup(button->button, button->time); |
1694 |
} |
} |
1695 |
} |
} |
1723 |
group_selected = row[m_SamplesModel.m_col_group]; |
group_selected = row[m_SamplesModel.m_col_group]; |
1724 |
sample_selected = row[m_SamplesModel.m_col_sample]; |
sample_selected = row[m_SamplesModel.m_col_sample]; |
1725 |
} |
} |
1726 |
|
|
1727 |
|
|
1728 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/SampleProperties"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/SampleProperties"))-> |
1729 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(group_selected || sample_selected); |
1730 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddSample"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddSample"))-> |
1731 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(group_selected || sample_selected); |
1732 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddGroup"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddGroup"))-> |
1733 |
set_sensitive(file); |
set_sensitive(file); |
1734 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/ShowSampleRefs"))-> |
1735 |
|
set_sensitive(sample_selected); |
1736 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/RemoveSample"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/RemoveSample"))-> |
1737 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(group_selected || sample_selected); |
1738 |
// show sample popup |
// show sample popup |
1739 |
sample_popup->popup(button->button, button->time); |
sample_popup->popup(button->button, button->time); |
1740 |
|
|
1741 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/SampleProperties"))-> |
1742 |
|
set_sensitive(group_selected || sample_selected); |
1743 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddSample"))-> |
1744 |
|
set_sensitive(group_selected || sample_selected); |
1745 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddGroup"))-> |
1746 |
|
set_sensitive(file); |
1747 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/ShowSampleRefs"))-> |
1748 |
|
set_sensitive(sample_selected); |
1749 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/RemoveSample"))-> |
1750 |
|
set_sensitive(group_selected || sample_selected); |
1751 |
} |
} |
1752 |
} |
} |
1753 |
|
|
1775 |
set_sensitive(group_selected || script_selected); |
set_sensitive(group_selected || script_selected); |
1776 |
// show sample popup |
// show sample popup |
1777 |
script_popup->popup(button->button, button->time); |
script_popup->popup(button->button, button->time); |
1778 |
|
|
1779 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/AddScript"))-> |
1780 |
|
set_sensitive(group_selected || script_selected); |
1781 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/AddScriptGroup"))-> |
1782 |
|
set_sensitive(file); |
1783 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/EditScript"))-> |
1784 |
|
set_sensitive(script_selected); |
1785 |
|
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuScript/RemoveScript"))-> |
1786 |
|
set_sensitive(group_selected || script_selected); |
1787 |
} |
} |
1788 |
} |
} |
1789 |
|
|
2414 |
} |
} |
2415 |
} |
} |
2416 |
|
|
2417 |
|
// see comment on on_sample_treeview_drag_begin() |
2418 |
|
void MainWindow::on_scripts_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context) |
2419 |
|
{ |
2420 |
|
first_call_to_drag_data_get = true; |
2421 |
|
} |
2422 |
|
|
2423 |
|
void MainWindow::on_scripts_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&, |
2424 |
|
Gtk::SelectionData& selection_data, guint, guint) |
2425 |
|
{ |
2426 |
|
if (!first_call_to_drag_data_get) return; |
2427 |
|
first_call_to_drag_data_get = false; |
2428 |
|
|
2429 |
|
// get selected script |
2430 |
|
gig::Script* script = NULL; |
2431 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewScripts.get_selection(); |
2432 |
|
Gtk::TreeModel::iterator it = sel->get_selected(); |
2433 |
|
if (it) { |
2434 |
|
Gtk::TreeModel::Row row = *it; |
2435 |
|
script = row[m_ScriptsModel.m_col_script]; |
2436 |
|
} |
2437 |
|
// pass the gig::Script as pointer |
2438 |
|
selection_data.set(selection_data.get_target(), 0/*unused*/, |
2439 |
|
(const guchar*)&script, |
2440 |
|
sizeof(script)/*length of data in bytes*/); |
2441 |
|
} |
2442 |
|
|
2443 |
// For some reason drag_data_get gets called two times for each |
// For some reason drag_data_get gets called two times for each |
2444 |
// drag'n'drop (at least when target is an Entry). This work-around |
// drag'n'drop (at least when target is an Entry). This work-around |
2445 |
// makes sure the code in drag_data_get and drop_drag_data_received is |
// makes sure the code in drag_data_get and drop_drag_data_received is |
2591 |
} |
} |
2592 |
} |
} |
2593 |
|
|
2594 |
|
void MainWindow::script_double_clicked(const Gtk::TreeModel::Path& path, |
2595 |
|
Gtk::TreeViewColumn* column) |
2596 |
|
{ |
2597 |
|
Gtk::TreeModel::iterator iter = m_refScriptsTreeModel->get_iter(path); |
2598 |
|
if (!iter) return; |
2599 |
|
Gtk::TreeModel::Row row = *iter; |
2600 |
|
gig::Script* script = row[m_ScriptsModel.m_col_script]; |
2601 |
|
if (!script) return; |
2602 |
|
|
2603 |
|
ScriptEditor* editor = new ScriptEditor; |
2604 |
|
editor->setScript(script); |
2605 |
|
//editor->reparent(*this); |
2606 |
|
editor->show(); |
2607 |
|
} |
2608 |
|
|
2609 |
void MainWindow::instrument_name_changed(const Gtk::TreeModel::Path& path, |
void MainWindow::instrument_name_changed(const Gtk::TreeModel::Path& path, |
2610 |
const Gtk::TreeModel::iterator& iter) { |
const Gtk::TreeModel::iterator& iter) { |
2611 |
if (!iter) return; |
if (!iter) return; |
2652 |
delete d; |
delete d; |
2653 |
} |
} |
2654 |
|
|
2655 |
|
void MainWindow::on_action_view_references() { |
2656 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
2657 |
|
Gtk::TreeModel::iterator it = sel->get_selected(); |
2658 |
|
if (!it) return; |
2659 |
|
Gtk::TreeModel::Row row = *it; |
2660 |
|
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
2661 |
|
if (!sample) return; |
2662 |
|
|
2663 |
|
ReferencesView* d = new ReferencesView(*this); |
2664 |
|
d->setSample(sample); |
2665 |
|
d->show_all(); |
2666 |
|
d->resize(500, 400); |
2667 |
|
d->run(); |
2668 |
|
delete d; |
2669 |
|
} |
2670 |
|
|
2671 |
void MainWindow::mergeFiles(const std::vector<std::string>& filenames) { |
void MainWindow::mergeFiles(const std::vector<std::string>& filenames) { |
2672 |
struct _Source { |
struct _Source { |
2673 |
std::vector<RIFF::File*> riffs; |
std::vector<RIFF::File*> riffs; |
2828 |
} |
} |
2829 |
} |
} |
2830 |
|
|
2831 |
|
void MainWindow::on_sample_ref_count_incremented(gig::Sample* sample, int offset) { |
2832 |
|
if (!sample) return; |
2833 |
|
sample_ref_count[sample] += offset; |
2834 |
|
const int refcount = sample_ref_count[sample]; |
2835 |
|
|
2836 |
|
Glib::RefPtr<Gtk::TreeModel> model = m_TreeViewSamples.get_model(); |
2837 |
|
for (int g = 0; g < model->children().size(); ++g) { |
2838 |
|
Gtk::TreeModel::Row rowGroup = model->children()[g]; |
2839 |
|
for (int s = 0; s < rowGroup.children().size(); ++s) { |
2840 |
|
Gtk::TreeModel::Row rowSample = rowGroup.children()[s]; |
2841 |
|
if (rowSample[m_SamplesModel.m_col_sample] != sample) continue; |
2842 |
|
rowSample[m_SamplesModel.m_col_refcount] = ToString(refcount) + " " + _("Refs."); |
2843 |
|
rowSample[m_SamplesModel.m_color] = refcount ? "black" : "red"; |
2844 |
|
} |
2845 |
|
} |
2846 |
|
} |
2847 |
|
|
2848 |
|
void MainWindow::on_sample_ref_changed(gig::Sample* oldSample, gig::Sample* newSample) { |
2849 |
|
on_sample_ref_count_incremented(oldSample, -1); |
2850 |
|
on_sample_ref_count_incremented(newSample, +1); |
2851 |
|
} |
2852 |
|
|
2853 |
|
void MainWindow::on_samples_to_be_removed(std::list<gig::Sample*> samples) { |
2854 |
|
// just in case a new sample is added later with exactly the same memory |
2855 |
|
// address, which would lead to incorrect refcount if not deleted here |
2856 |
|
for (std::list<gig::Sample*>::const_iterator it = samples.begin(); |
2857 |
|
it != samples.end(); ++it) |
2858 |
|
{ |
2859 |
|
sample_ref_count.erase(*it); |
2860 |
|
} |
2861 |
|
} |
2862 |
|
|
2863 |
|
void MainWindow::show_samples_tab() { |
2864 |
|
m_TreeViewNotebook.set_current_page(0); |
2865 |
|
} |
2866 |
|
|
2867 |
|
void MainWindow::show_intruments_tab() { |
2868 |
|
m_TreeViewNotebook.set_current_page(1); |
2869 |
|
} |
2870 |
|
|
2871 |
|
void MainWindow::show_scripts_tab() { |
2872 |
|
m_TreeViewNotebook.set_current_page(2); |
2873 |
|
} |
2874 |
|
|
2875 |
sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() { |
sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() { |
2876 |
return file_structure_to_be_changed_signal; |
return file_structure_to_be_changed_signal; |
2877 |
} |
} |