1 |
/* |
/* |
2 |
* Copyright (C) 2006-2019 Andreas Persson |
* Copyright (C) 2006-2020 Andreas Persson |
3 |
* |
* |
4 |
* This program is free software; you can redistribute it and/or |
* This program is free software; you can redistribute it and/or |
5 |
* modify it under the terms of the GNU General Public License as |
* modify it under the terms of the GNU General Public License as |
21 |
#include <cstring> |
#include <cstring> |
22 |
|
|
23 |
#include "compat.h" |
#include "compat.h" |
|
// threads.h must be included first to be able to build with |
|
|
// G_DISABLE_DEPRECATED |
|
|
#if (GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION == 31 && GLIBMM_MICRO_VERSION >= 2) || \ |
|
|
(GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION > 31) || GLIBMM_MAJOR_VERSION > 2 |
|
|
#include <glibmm/threads.h> |
|
|
#endif |
|
24 |
|
|
25 |
#include <glibmm/convert.h> |
#include <glibmm/convert.h> |
26 |
#include <glibmm/dispatcher.h> |
#include <glibmm/dispatcher.h> |
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(895, 600); |
set_default_size(1010, -1); |
100 |
#else |
#else |
101 |
set_default_size(800, 600); |
set_default_size(915, -1); |
102 |
#endif |
#endif |
103 |
set_position(Gtk::WIN_POS_CENTER); |
set_position(Gtk::WIN_POS_CENTER); |
104 |
} |
} |
106 |
add(m_VBox); |
add(m_VBox); |
107 |
|
|
108 |
// Handle selection |
// Handle selection |
109 |
m_TreeView.get_selection()->signal_changed().connect( |
m_TreeViewInstruments.get_selection()->signal_changed().connect( |
110 |
sigc::mem_fun(*this, &MainWindow::on_sel_change)); |
sigc::mem_fun(*this, &MainWindow::on_sel_change)); |
111 |
|
|
112 |
// m_TreeView.set_reorderable(); |
// m_TreeViewInstruments.set_reorderable(); |
113 |
|
|
114 |
#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 |
#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 |
115 |
m_TreeView.signal_button_press_event().connect( |
m_TreeViewInstruments.signal_button_press_event().connect( |
116 |
sigc::mem_fun(*this, &MainWindow::on_button_release)); |
sigc::mem_fun(*this, &MainWindow::on_button_release)); |
117 |
#else |
#else |
118 |
m_TreeView.signal_button_press_event().connect_notify( |
m_TreeViewInstruments.signal_button_press_event().connect_notify( |
119 |
sigc::mem_fun(*this, &MainWindow::on_button_release)); |
sigc::mem_fun(*this, &MainWindow::on_button_release)); |
120 |
#endif |
#endif |
121 |
|
|
122 |
// Add the TreeView tab, inside a ScrolledWindow, with the button underneath: |
// Add the TreeView tab, inside a ScrolledWindow, with the button underneath: |
123 |
m_ScrolledWindow.add(m_TreeView); |
m_ScrolledWindow.add(m_TreeViewInstruments); |
124 |
// m_ScrolledWindow.set_size_request(200, 600); |
// m_ScrolledWindow.set_size_request(200, 600); |
125 |
m_ScrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); |
m_ScrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); |
126 |
|
|
451 |
m_actionGroup->add_action_bool("Statusbar", sigc::mem_fun(*this, &MainWindow::on_action_view_status_bar), true); |
m_actionGroup->add_action_bool("Statusbar", sigc::mem_fun(*this, &MainWindow::on_action_view_status_bar), true); |
452 |
m_actionToggleRestoreWinDim = |
m_actionToggleRestoreWinDim = |
453 |
m_actionGroup->add_action_bool("AutoRestoreWinDim", sigc::mem_fun(*this, &MainWindow::on_auto_restore_win_dim), Settings::singleton()->autoRestoreWindowDimension); |
m_actionGroup->add_action_bool("AutoRestoreWinDim", sigc::mem_fun(*this, &MainWindow::on_auto_restore_win_dim), Settings::singleton()->autoRestoreWindowDimension); |
454 |
|
m_actionInstrDoubleClickOpensProps = |
455 |
|
m_actionGroup->add_action_bool( |
456 |
|
"OpenInstrPropsByDoubleClick", |
457 |
|
sigc::mem_fun(*this, &MainWindow::on_instr_double_click_opens_props), |
458 |
|
Settings::singleton()->instrumentDoubleClickOpensProps |
459 |
|
); |
460 |
m_actionToggleShowTooltips = m_actionGroup->add_action_bool( |
m_actionToggleShowTooltips = m_actionGroup->add_action_bool( |
461 |
"ShowTooltips", sigc::mem_fun(*this, &MainWindow::on_action_show_tooltips), |
"ShowTooltips", sigc::mem_fun(*this, &MainWindow::on_action_show_tooltips), |
462 |
Settings::singleton()->showTooltips |
Settings::singleton()->showTooltips |
484 |
*this, &MainWindow::on_auto_restore_win_dim)); |
*this, &MainWindow::on_auto_restore_win_dim)); |
485 |
|
|
486 |
toggle_action = |
toggle_action = |
487 |
|
Gtk::ToggleAction::create("OpenInstrPropsByDoubleClick", _("Instrument Properties by Double Click")); |
488 |
|
toggle_action->set_active(Settings::singleton()->instrumentDoubleClickOpensProps); |
489 |
|
actionGroup->add(toggle_action, |
490 |
|
sigc::mem_fun( |
491 |
|
*this, &MainWindow::on_instr_double_click_opens_props)); |
492 |
|
|
493 |
|
toggle_action = |
494 |
Gtk::ToggleAction::create("ShowTooltips", _("Tooltips for Beginners")); |
Gtk::ToggleAction::create("ShowTooltips", _("Tooltips for Beginners")); |
495 |
toggle_action->set_active(Settings::singleton()->showTooltips); |
toggle_action->set_active(Settings::singleton()->showTooltips); |
496 |
actionGroup->add( |
actionGroup->add( |
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>" |
960 |
" <attribute name='label' translatable='yes'>Auto restore Window Dimensions</attribute>" |
" <attribute name='label' translatable='yes'>Auto restore Window Dimensions</attribute>" |
961 |
" <attribute name='action'>AppMenu.AutoRestoreWinDim</attribute>" |
" <attribute name='action'>AppMenu.AutoRestoreWinDim</attribute>" |
962 |
" </item>" |
" </item>" |
963 |
|
" <item id='OpenInstrPropsByDoubleClick'>" |
964 |
|
" <attribute name='label' translatable='yes'>Instrument Properties by Double Click</attribute>" |
965 |
|
" <attribute name='action'>AppMenu.OpenInstrPropsByDoubleClick</attribute>" |
966 |
|
" </item>" |
967 |
" </section>" |
" </section>" |
968 |
" <section>" |
" <section>" |
969 |
" <item id='RefreshAll'>" |
" <item id='RefreshAll'>" |
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'/>" |
1197 |
" <menuitem action='Statusbar'/>" |
" <menuitem action='Statusbar'/>" |
1198 |
" <menuitem action='ShowTooltips'/>" |
" <menuitem action='ShowTooltips'/>" |
1199 |
" <menuitem action='AutoRestoreWinDim'/>" |
" <menuitem action='AutoRestoreWinDim'/>" |
1200 |
|
" <menuitem action='OpenInstrPropsByDoubleClick'/>" |
1201 |
" <separator/>" |
" <separator/>" |
1202 |
" <menuitem action='RefreshAll'/>" |
" <menuitem action='RefreshAll'/>" |
1203 |
" </menu>" |
" </menu>" |
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'/>" |
1322 |
} |
} |
1323 |
{ |
{ |
1324 |
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
1325 |
|
uiManager->get_widget("/MenuBar/MenuView/OpenInstrPropsByDoubleClick")); |
1326 |
|
item->set_tooltip_text(_("If checked, double clicking an instrument opens its properties dialog.")); |
1327 |
|
} |
1328 |
|
{ |
1329 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
1330 |
uiManager->get_widget("/MenuBar/MenuTools/CombineInstruments")); |
uiManager->get_widget("/MenuBar/MenuTools/CombineInstruments")); |
1331 |
item->set_tooltip_text(_("Create combi sounds out of individual sounds of this .gig file.")); |
item->set_tooltip_text(_("Create combi sounds out of individual sounds of this .gig file.")); |
1332 |
} |
} |
1383 |
|
|
1384 |
|
|
1385 |
// Create the Tree model: |
// Create the Tree model: |
1386 |
m_refTreeModel = Gtk::ListStore::create(m_Columns); |
m_refInstrumentsTreeModel = Gtk::ListStore::create(m_InstrumentsModel); |
1387 |
m_refTreeModelFilter = Gtk::TreeModelFilter::create(m_refTreeModel); |
m_refInstrumentsModelFilter = Gtk::TreeModelFilter::create(m_refInstrumentsTreeModel); |
1388 |
m_refTreeModelFilter->set_visible_func( |
m_refInstrumentsModelFilter->set_visible_func( |
1389 |
sigc::mem_fun(*this, &MainWindow::instrument_row_visible) |
sigc::mem_fun(*this, &MainWindow::instrument_row_visible) |
1390 |
); |
); |
1391 |
m_TreeView.set_model(m_refTreeModelFilter); |
m_TreeViewInstruments.set_model(m_refInstrumentsModelFilter); |
1392 |
|
|
1393 |
m_TreeView.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE); |
m_TreeViewInstruments.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE); |
1394 |
m_TreeView.set_has_tooltip(true); |
m_TreeViewInstruments.set_has_tooltip(true); |
1395 |
m_TreeView.signal_query_tooltip().connect( |
m_TreeViewInstruments.signal_query_tooltip().connect( |
1396 |
sigc::mem_fun(*this, &MainWindow::onQueryTreeViewTooltip) |
sigc::mem_fun(*this, &MainWindow::onQueryTreeViewTooltip) |
1397 |
); |
); |
1398 |
instrument_name_connection = m_refTreeModel->signal_row_changed().connect( |
instrument_name_connection = m_refInstrumentsTreeModel->signal_row_changed().connect( |
1399 |
sigc::mem_fun(*this, &MainWindow::instrument_name_changed) |
sigc::mem_fun(*this, &MainWindow::instrument_name_changed) |
1400 |
); |
); |
1401 |
|
|
1402 |
// Add the TreeView's view columns: |
// Add the TreeView's view columns: |
1403 |
m_TreeView.append_column(_("Nr"), m_Columns.m_col_nr); |
m_TreeViewInstruments.append_column(_("Nr"), m_InstrumentsModel.m_col_nr); |
1404 |
m_TreeView.append_column_editable(_("Instrument"), m_Columns.m_col_name); |
m_TreeViewInstruments.append_column_editable(_("Instrument"), m_InstrumentsModel.m_col_name); |
1405 |
m_TreeView.append_column(_("Scripts"), m_Columns.m_col_scripts); |
m_TreeViewInstruments.append_column(_("Scripts"), m_InstrumentsModel.m_col_scripts); |
1406 |
m_TreeView.set_headers_visible(true); |
m_TreeViewInstruments.set_headers_visible(true); |
1407 |
|
|
1408 |
// establish drag&drop within the instrument tree view, allowing to reorder |
// establish drag&drop within the instrument tree view, allowing to reorder |
1409 |
// the sequence of instruments within the gig file |
// the sequence of instruments within the gig file |
1410 |
{ |
{ |
1411 |
std::vector<Gtk::TargetEntry> drag_target_instrument; |
std::vector<Gtk::TargetEntry> drag_target_instrument; |
1412 |
drag_target_instrument.push_back(Gtk::TargetEntry("gig::Instrument")); |
drag_target_instrument.push_back(Gtk::TargetEntry("gig::Instrument")); |
1413 |
m_TreeView.drag_source_set(drag_target_instrument); |
m_TreeViewInstruments.drag_source_set(drag_target_instrument); |
1414 |
m_TreeView.drag_dest_set(drag_target_instrument); |
m_TreeViewInstruments.drag_dest_set(drag_target_instrument); |
1415 |
m_TreeView.signal_drag_begin().connect( |
m_TreeViewInstruments.signal_drag_begin().connect( |
1416 |
sigc::mem_fun(*this, &MainWindow::on_instruments_treeview_drag_begin) |
sigc::mem_fun(*this, &MainWindow::on_instruments_treeview_drag_begin) |
1417 |
); |
); |
1418 |
m_TreeView.signal_drag_data_get().connect( |
m_TreeViewInstruments.signal_drag_data_get().connect( |
1419 |
sigc::mem_fun(*this, &MainWindow::on_instruments_treeview_drag_data_get) |
sigc::mem_fun(*this, &MainWindow::on_instruments_treeview_drag_data_get) |
1420 |
); |
); |
1421 |
m_TreeView.signal_drag_data_received().connect( |
m_TreeViewInstruments.signal_drag_data_received().connect( |
1422 |
sigc::mem_fun(*this, &MainWindow::on_instruments_treeview_drop_drag_data_received) |
sigc::mem_fun(*this, &MainWindow::on_instruments_treeview_drop_drag_data_received) |
1423 |
); |
); |
1424 |
} |
} |
1525 |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
1526 |
instrumentProps.signal_changed().connect( |
instrumentProps.signal_changed().connect( |
1527 |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
1528 |
propDialog.signal_changed().connect( |
sampleProps.signal_changed().connect( |
1529 |
|
sigc::mem_fun(*this, &MainWindow::file_changed)); |
1530 |
|
fileProps.signal_changed().connect( |
1531 |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
1532 |
midiRules.signal_changed().connect( |
midiRules.signal_changed().connect( |
1533 |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
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( |
1584 |
file_structure_to_be_changed_signal.make_slot(), |
file_structure_to_be_changed_signal.make_slot(), |
1585 |
|
#if SIGCXX_MAJOR_VERSION > 2 || (SIGCXX_MAJOR_VERSION == 2 && SIGCXX_MINOR_VERSION >= 8) |
1586 |
|
std::ref(this->file) |
1587 |
|
#else |
1588 |
sigc::ref(this->file) |
sigc::ref(this->file) |
1589 |
|
#endif |
1590 |
) |
) |
1591 |
) |
) |
1592 |
); |
); |
1594 |
sigc::hide( |
sigc::hide( |
1595 |
sigc::bind( |
sigc::bind( |
1596 |
file_structure_changed_signal.make_slot(), |
file_structure_changed_signal.make_slot(), |
1597 |
|
#if SIGCXX_MAJOR_VERSION > 2 || (SIGCXX_MAJOR_VERSION == 2 && SIGCXX_MINOR_VERSION >= 8) |
1598 |
|
std::ref(this->file) |
1599 |
|
#else |
1600 |
sigc::ref(this->file) |
sigc::ref(this->file) |
1601 |
|
#endif |
1602 |
) |
) |
1603 |
) |
) |
1604 |
); |
); |
1620 |
sigc::mem_fun(*this, &MainWindow::update_dimregs)); |
sigc::mem_fun(*this, &MainWindow::update_dimregs)); |
1621 |
|
|
1622 |
m_searchText.signal_changed().connect( |
m_searchText.signal_changed().connect( |
1623 |
sigc::mem_fun(m_refTreeModelFilter.operator->(), &Gtk::TreeModelFilter::refilter) |
sigc::mem_fun(*m_refInstrumentsModelFilter.operator->(), &Gtk::TreeModelFilter::refilter) |
1624 |
); |
); |
1625 |
|
|
1626 |
file = 0; |
file = 0; |
1734 |
#endif |
#endif |
1735 |
raise(); |
raise(); |
1736 |
present(); |
present(); |
1737 |
|
|
1738 |
|
// restore user specified splitter position |
1739 |
|
if (Settings::singleton()->mainWindowSplitterPosX >= 0 && |
1740 |
|
Settings::singleton()->autoRestoreWindowDimension) |
1741 |
|
{ |
1742 |
|
const int pos = Settings::singleton()->mainWindowSplitterPosX; |
1743 |
|
printf("Restoring user's preferred splitter position=%d\n", pos); |
1744 |
|
m_HPaned.set_position(pos); |
1745 |
|
} |
1746 |
|
// this signal handler is late-connected after the UI build-up has settled |
1747 |
|
// to prevent the UI build-up from overwriting user's setting for splitter |
1748 |
|
// position unintentionally |
1749 |
|
m_HPaned.property_position().signal_changed().connect([this]{ |
1750 |
|
if (!Settings::singleton()->autoRestoreWindowDimension) return; |
1751 |
|
const int pos = m_HPaned.get_position(); |
1752 |
|
printf("Saving user's preferred splitter position=%d\n", pos); |
1753 |
|
Settings::singleton()->mainWindowSplitterPosX = pos; |
1754 |
|
}); |
1755 |
} |
} |
1756 |
|
|
1757 |
void MainWindow::updateMacroMenu() { |
void MainWindow::updateMacroMenu() { |
1882 |
|
|
1883 |
gig::Instrument* MainWindow::get_instrument() |
gig::Instrument* MainWindow::get_instrument() |
1884 |
{ |
{ |
1885 |
gig::Instrument* instrument = 0; |
gig::Instrument* instrument = NULL; |
1886 |
std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows(); |
|
1887 |
|
// get indeces of visual selection |
1888 |
|
std::vector<Gtk::TreeModel::Path> rows = m_TreeViewInstruments.get_selection()->get_selected_rows(); |
1889 |
if (rows.empty()) return NULL; |
if (rows.empty()) return NULL; |
1890 |
|
|
1891 |
|
// convert index of visual selection (i.e. if filtered) to index of model |
1892 |
|
Gtk::TreeModel::Path path = m_refInstrumentsModelFilter->convert_path_to_child_path(rows[0]); |
1893 |
|
if (!path) return NULL; |
1894 |
|
|
1895 |
//NOTE: was const_iterator before, which did not compile with GTKMM4 development branch, probably going to be fixed before final GTKMM4 release though. |
//NOTE: was const_iterator before, which did not compile with GTKMM4 development branch, probably going to be fixed before final GTKMM4 release though. |
1896 |
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); |
Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(path); |
1897 |
if (it) { |
if (it) { |
1898 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
1899 |
instrument = row[m_Columns.m_col_instr]; |
instrument = row[m_InstrumentsModel.m_col_instr]; |
1900 |
} |
} |
1901 |
return instrument; |
return instrument; |
1902 |
} |
} |
1961 |
{ |
{ |
1962 |
#if !USE_GTKMM_BUILDER |
#if !USE_GTKMM_BUILDER |
1963 |
// select item in instrument menu |
// select item in instrument menu |
1964 |
std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows(); |
std::vector<Gtk::TreeModel::Path> rows = m_TreeViewInstruments.get_selection()->get_selected_rows(); |
1965 |
if (!rows.empty()) { |
if (!rows.empty()) { |
1966 |
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); |
// convert index of visual selection (i.e. if filtered) to index of model |
1967 |
|
Gtk::TreeModel::Path row = m_refInstrumentsModelFilter->convert_path_to_child_path(rows[0]); |
1968 |
|
Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(row); |
1969 |
if (it) { |
if (it) { |
1970 |
Gtk::TreePath path(it); |
Gtk::TreePath path(it); |
1971 |
int index = path[0]; |
int index = path[0]; |
1978 |
|
|
1979 |
updateScriptListOfMenu(); |
updateScriptListOfMenu(); |
1980 |
|
|
1981 |
m_RegionChooser.set_instrument(get_instrument()); |
gig::Instrument* instr = get_instrument(); |
1982 |
|
|
1983 |
|
m_RegionChooser.set_instrument(instr); |
1984 |
|
dimreg_edit.scriptVars.setInstrument(instr, true/*force update*/); |
1985 |
|
|
1986 |
if (Settings::singleton()->syncSamplerInstrumentSelection) { |
if (Settings::singleton()->syncSamplerInstrumentSelection) { |
1987 |
switch_sampler_instrument_signal.emit(get_instrument()); |
switch_sampler_instrument_signal.emit(get_instrument()); |
1988 |
} |
} |
1989 |
} |
} |
1990 |
|
|
1991 |
|
|
1992 |
|
LoaderSaverBase::LoaderSaverBase(const Glib::ustring filename, gig::File* gig) : |
1993 |
|
filename(filename), gig(gig), |
1994 |
|
#ifdef GLIB_THREADS |
1995 |
|
thread(0), |
1996 |
|
#endif |
1997 |
|
progress(0.f) |
1998 |
|
{ |
1999 |
|
} |
2000 |
|
|
2001 |
void loader_progress_callback(gig::progress_t* progress) |
void loader_progress_callback(gig::progress_t* progress) |
2002 |
{ |
{ |
2003 |
Loader* loader = static_cast<Loader*>(progress->custom); |
LoaderSaverBase* loader = static_cast<LoaderSaverBase*>(progress->custom); |
2004 |
loader->progress_callback(progress->factor); |
loader->progress_callback(progress->factor); |
2005 |
} |
} |
2006 |
|
|
2007 |
void Loader::progress_callback(float fraction) |
void LoaderSaverBase::progress_callback(float fraction) |
2008 |
{ |
{ |
2009 |
{ |
{ |
2010 |
|
#ifdef GLIB_THREADS |
2011 |
Glib::Threads::Mutex::Lock lock(progressMutex); |
Glib::Threads::Mutex::Lock lock(progressMutex); |
2012 |
|
#else |
2013 |
|
std::lock_guard<std::mutex> lock(progressMutex); |
2014 |
|
#endif |
2015 |
progress = fraction; |
progress = fraction; |
2016 |
} |
} |
2017 |
progress_dispatcher(); |
progress_dispatcher(); |
2021 |
// make sure stack is 16-byte aligned for SSE instructions |
// make sure stack is 16-byte aligned for SSE instructions |
2022 |
__attribute__((force_align_arg_pointer)) |
__attribute__((force_align_arg_pointer)) |
2023 |
#endif |
#endif |
2024 |
void Loader::thread_function() |
void LoaderSaverBase::thread_function() |
2025 |
{ |
{ |
2026 |
|
#ifdef GLIB_THREADS |
2027 |
printf("thread_function self=%p\n", |
printf("thread_function self=%p\n", |
2028 |
static_cast<void*>(Glib::Threads::Thread::self())); |
static_cast<void*>(Glib::Threads::Thread::self())); |
2029 |
|
#else |
2030 |
|
std::cout << "thread_function self=" << std::this_thread::get_id() << "\n"; |
2031 |
|
#endif |
2032 |
printf("Start %s\n", filename.c_str()); |
printf("Start %s\n", filename.c_str()); |
2033 |
try { |
try { |
|
RIFF::File* riff = new RIFF::File(filename); |
|
|
gig = new gig::File(riff); |
|
2034 |
gig::progress_t progress; |
gig::progress_t progress; |
2035 |
progress.callback = loader_progress_callback; |
progress.callback = loader_progress_callback; |
2036 |
progress.custom = this; |
progress.custom = this; |
2037 |
|
|
2038 |
gig->GetInstrument(0, &progress); |
thread_function_sub(progress); |
2039 |
printf("End\n"); |
printf("End\n"); |
2040 |
finished_dispatcher(); |
finished_dispatcher(); |
2041 |
} catch (RIFF::Exception e) { |
} catch (RIFF::Exception e) { |
2047 |
} |
} |
2048 |
} |
} |
2049 |
|
|
2050 |
Loader::Loader(const char* filename) |
void LoaderSaverBase::launch() |
|
: filename(filename), gig(0), thread(0), progress(0.f) |
|
|
{ |
|
|
} |
|
|
|
|
|
void Loader::launch() |
|
2051 |
{ |
{ |
2052 |
|
#ifdef GLIB_THREADS |
2053 |
#ifdef OLD_THREADS |
#ifdef OLD_THREADS |
2054 |
thread = Glib::Thread::create(sigc::mem_fun(*this, &Loader::thread_function), true); |
thread = Glib::Thread::create(sigc::mem_fun(*this, &LoaderSaverBase::thread_function), true); |
2055 |
#else |
#else |
2056 |
thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Loader::thread_function)); |
thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &LoaderSaverBase::thread_function)); |
2057 |
#endif |
#endif |
2058 |
printf("launch thread=%p\n", static_cast<void*>(thread)); |
printf("launch thread=%p\n", static_cast<void*>(thread)); |
2059 |
|
#else |
2060 |
|
thread = std::thread([this](){ thread_function(); }); |
2061 |
|
std::cout << "launch thread=" << thread.get_id() << "\n"; |
2062 |
|
#endif |
2063 |
} |
} |
2064 |
|
|
2065 |
float Loader::get_progress() |
float LoaderSaverBase::get_progress() |
2066 |
{ |
{ |
2067 |
float res; |
#ifdef GLIB_THREADS |
2068 |
{ |
Glib::Threads::Mutex::Lock lock(progressMutex); |
2069 |
Glib::Threads::Mutex::Lock lock(progressMutex); |
#else |
2070 |
res = progress; |
std::lock_guard<std::mutex> lock(progressMutex); |
2071 |
} |
#endif |
2072 |
return res; |
return progress; |
2073 |
} |
} |
2074 |
|
|
2075 |
Glib::Dispatcher& Loader::signal_progress() |
Glib::Dispatcher& LoaderSaverBase::signal_progress() |
2076 |
{ |
{ |
2077 |
return progress_dispatcher; |
return progress_dispatcher; |
2078 |
} |
} |
2079 |
|
|
2080 |
Glib::Dispatcher& Loader::signal_finished() |
Glib::Dispatcher& LoaderSaverBase::signal_finished() |
2081 |
{ |
{ |
2082 |
return finished_dispatcher; |
return finished_dispatcher; |
2083 |
} |
} |
2084 |
|
|
2085 |
Glib::Dispatcher& Loader::signal_error() |
Glib::Dispatcher& LoaderSaverBase::signal_error() |
2086 |
{ |
{ |
2087 |
return error_dispatcher; |
return error_dispatcher; |
2088 |
} |
} |
2089 |
|
|
2090 |
void saver_progress_callback(gig::progress_t* progress) |
void LoaderSaverBase::join() { |
2091 |
{ |
#ifdef GLIB_THREADS |
2092 |
Saver* saver = static_cast<Saver*>(progress->custom); |
thread->join(); |
2093 |
saver->progress_callback(progress->factor); |
#else |
2094 |
|
thread.join(); |
2095 |
|
#endif |
2096 |
} |
} |
2097 |
|
|
2098 |
void Saver::progress_callback(float fraction) |
|
2099 |
|
Loader::Loader(const char* filename) : |
2100 |
|
LoaderSaverBase(filename, 0) |
2101 |
{ |
{ |
|
{ |
|
|
Glib::Threads::Mutex::Lock lock(progressMutex); |
|
|
progress = fraction; |
|
|
} |
|
|
progress_dispatcher.emit(); |
|
2102 |
} |
} |
2103 |
|
|
2104 |
#if defined(WIN32) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) |
void Loader::thread_function_sub(gig::progress_t& progress) |
|
// make sure stack is 16-byte aligned for SSE instructions |
|
|
__attribute__((force_align_arg_pointer)) |
|
|
#endif |
|
|
void Saver::thread_function() |
|
2105 |
{ |
{ |
2106 |
printf("thread_function self=%p\n", |
RIFF::File* riff = new RIFF::File(filename); |
2107 |
static_cast<void*>(Glib::Threads::Thread::self())); |
// due to the multi-threaded scenario use separate file I/O handles for |
2108 |
printf("Start %s\n", filename.c_str()); |
// each thread to avoid file I/O concurrency issues with .gig file |
2109 |
try { |
riff->SetIOPerThread(true); |
|
gig::progress_t progress; |
|
|
progress.callback = saver_progress_callback; |
|
|
progress.custom = this; |
|
2110 |
|
|
2111 |
// if no filename was provided, that means "save", if filename was provided means "save as" |
gig = new gig::File(riff); |
|
if (filename.empty()) { |
|
|
if (!Settings::singleton()->saveWithTemporaryFile) { |
|
|
// save directly over the existing .gig file |
|
|
// (requires less disk space than solution below |
|
|
// but may be slower) |
|
|
gig->Save(&progress); |
|
|
} else { |
|
|
// save the file as separate temporary file first, |
|
|
// then move the saved file over the old file |
|
|
// (may result in performance speedup during save) |
|
|
gig::String tmpname = filename + ".TMP"; |
|
|
gig->Save(tmpname, &progress); |
|
|
#if defined(WIN32) |
|
|
if (!DeleteFile(filename.c_str())) { |
|
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file)."); |
|
|
} |
|
|
#else // POSIX ... |
|
|
if (unlink(filename.c_str())) { |
|
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file): " + gig::String(strerror(errno))); |
|
|
} |
|
|
#endif |
|
|
if (rename(tmpname.c_str(), filename.c_str())) { |
|
|
#if defined(WIN32) |
|
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file)."); |
|
|
#else |
|
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file): " + gig::String(strerror(errno))); |
|
|
#endif |
|
|
} |
|
|
} |
|
|
} else { |
|
|
gig->Save(filename, &progress); |
|
|
} |
|
2112 |
|
|
2113 |
printf("End\n"); |
gig->GetInstrument(0, &progress); |
|
finished_dispatcher.emit(); |
|
|
} catch (RIFF::Exception e) { |
|
|
error_message = e.Message; |
|
|
error_dispatcher.emit(); |
|
|
} catch (...) { |
|
|
error_message = _("Unknown exception occurred"); |
|
|
error_dispatcher.emit(); |
|
|
} |
|
2114 |
} |
} |
2115 |
|
|
2116 |
Saver::Saver(gig::File* file, Glib::ustring filename) |
|
2117 |
: gig(file), filename(filename), thread(0), progress(0.f) |
Saver::Saver(gig::File* file, Glib::ustring filename) : |
2118 |
|
LoaderSaverBase(filename, file) |
2119 |
{ |
{ |
2120 |
} |
} |
2121 |
|
|
2122 |
void Saver::launch() |
void Saver::thread_function_sub(gig::progress_t& progress) |
2123 |
{ |
{ |
2124 |
#ifdef OLD_THREADS |
// if no filename was provided, that means "save", if filename was provided means "save as" |
2125 |
thread = Glib::Thread::create(sigc::mem_fun(*this, &Saver::thread_function), true); |
if (filename.empty()) { |
2126 |
|
if (!Settings::singleton()->saveWithTemporaryFile) { |
2127 |
|
// save directly over the existing .gig file |
2128 |
|
// (requires less disk space than solution below |
2129 |
|
// but may be slower) |
2130 |
|
gig->Save(&progress); |
2131 |
|
} else { |
2132 |
|
// save the file as separate temporary file first, |
2133 |
|
// then move the saved file over the old file |
2134 |
|
// (may result in performance speedup during save) |
2135 |
|
gig::String tmpname = filename + ".TMP"; |
2136 |
|
gig->Save(tmpname, &progress); |
2137 |
|
#if defined(WIN32) |
2138 |
|
if (!DeleteFile(filename.c_str())) { |
2139 |
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file)."); |
2140 |
|
} |
2141 |
|
#else // POSIX ... |
2142 |
|
if (unlink(filename.c_str())) { |
2143 |
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file): " + gig::String(strerror(errno))); |
2144 |
|
} |
2145 |
|
#endif |
2146 |
|
if (rename(tmpname.c_str(), filename.c_str())) { |
2147 |
|
#if defined(WIN32) |
2148 |
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file)."); |
2149 |
#else |
#else |
2150 |
thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Saver::thread_function)); |
throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file): " + gig::String(strerror(errno))); |
2151 |
#endif |
#endif |
2152 |
printf("launch thread=%p\n", static_cast<void*>(thread)); |
} |
2153 |
} |
} |
2154 |
|
} else { |
2155 |
float Saver::get_progress() |
gig->Save(filename, &progress); |
|
{ |
|
|
float res; |
|
|
{ |
|
|
Glib::Threads::Mutex::Lock lock(progressMutex); |
|
|
res = progress; |
|
2156 |
} |
} |
|
return res; |
|
|
} |
|
|
|
|
|
Glib::Dispatcher& Saver::signal_progress() |
|
|
{ |
|
|
return progress_dispatcher; |
|
2157 |
} |
} |
2158 |
|
|
|
Glib::Dispatcher& Saver::signal_finished() |
|
|
{ |
|
|
return finished_dispatcher; |
|
|
} |
|
|
|
|
|
Glib::Dispatcher& Saver::signal_error() |
|
|
{ |
|
|
return error_dispatcher; |
|
|
} |
|
2159 |
|
|
2160 |
ProgressDialog::ProgressDialog(const Glib::ustring& title, Gtk::Window& parent) |
ProgressDialog::ProgressDialog(const Glib::ustring& title, Gtk::Window& parent) |
2161 |
: Gtk::Dialog(title, parent, true) |
: Gtk::Dialog(title, parent, true) |
2177 |
// forget all samples that ought to be imported |
// forget all samples that ought to be imported |
2178 |
m_SampleImportQueue.clear(); |
m_SampleImportQueue.clear(); |
2179 |
// clear the samples and instruments tree views |
// clear the samples and instruments tree views |
2180 |
m_refTreeModel->clear(); |
m_refInstrumentsTreeModel->clear(); |
2181 |
m_refSamplesTreeModel->clear(); |
m_refSamplesTreeModel->clear(); |
2182 |
m_refScriptsTreeModel->clear(); |
m_refScriptsTreeModel->clear(); |
2183 |
#if !USE_GTKMM_BUILDER |
#if !USE_GTKMM_BUILDER |
2194 |
|
|
2195 |
void MainWindow::__refreshEntireGUI() { |
void MainWindow::__refreshEntireGUI() { |
2196 |
// clear the samples and instruments tree views |
// clear the samples and instruments tree views |
2197 |
m_refTreeModel->clear(); |
m_refInstrumentsTreeModel->clear(); |
2198 |
m_refSamplesTreeModel->clear(); |
m_refSamplesTreeModel->clear(); |
2199 |
m_refScriptsTreeModel->clear(); |
m_refScriptsTreeModel->clear(); |
2200 |
#if !USE_GTKMM_BUILDER |
#if !USE_GTKMM_BUILDER |
2221 |
__clear(); |
__clear(); |
2222 |
// create a new .gig file (virtually yet) |
// create a new .gig file (virtually yet) |
2223 |
gig::File* pFile = new gig::File; |
gig::File* pFile = new gig::File; |
2224 |
|
// due to the multi-threaded scenario use separate file I/O handles for |
2225 |
|
// each thread to avoid file I/O concurrency issues with .gig file |
2226 |
|
RIFF::File* pRIFF = pFile->GetRiffFile(); |
2227 |
|
pRIFF->SetIOPerThread(true); |
2228 |
// already add one new instrument by default |
// already add one new instrument by default |
2229 |
gig::Instrument* pInstrument = pFile->AddInstrument(); |
gig::Instrument* pInstrument = pFile->AddInstrument(); |
2230 |
pInstrument->pInfo->Name = gig_from_utf8(_("Unnamed Instrument")); |
pInstrument->pInfo->Name = gig_from_utf8(_("Unnamed Instrument")); |
2315 |
dialog.set_current_folder(current_gig_dir); |
dialog.set_current_folder(current_gig_dir); |
2316 |
} |
} |
2317 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
2318 |
|
dialog.hide(); |
2319 |
std::string filename = dialog.get_filename(); |
std::string filename = dialog.get_filename(); |
2320 |
printf("filename=%s\n", filename.c_str()); |
printf("filename=%s\n", filename.c_str()); |
2321 |
|
#ifdef GLIB_THREADS |
2322 |
printf("on_action_file_open self=%p\n", |
printf("on_action_file_open self=%p\n", |
2323 |
static_cast<void*>(Glib::Threads::Thread::self())); |
static_cast<void*>(Glib::Threads::Thread::self())); |
2324 |
|
#else |
2325 |
|
std::cout << "on_action_file_open self=" << |
2326 |
|
std::this_thread::get_id() << "\n"; |
2327 |
|
#endif |
2328 |
load_file(filename.c_str()); |
load_file(filename.c_str()); |
2329 |
current_gig_dir = Glib::path_get_dirname(filename); |
current_gig_dir = Glib::path_get_dirname(filename); |
2330 |
} |
} |
2371 |
{ |
{ |
2372 |
if (instrument == instr) { |
if (instrument == instr) { |
2373 |
// select item in "instruments" tree view |
// select item in "instruments" tree view |
2374 |
m_TreeView.get_selection()->select(Gtk::TreePath(ToString(i))); |
m_TreeViewInstruments.get_selection()->select(Gtk::TreePath(ToString(i))); |
2375 |
// make sure the selected item in the "instruments" tree view is |
// make sure the selected item in the "instruments" tree view is |
2376 |
// visible (scroll to it) |
// visible (scroll to it) |
2377 |
m_TreeView.scroll_to_row(Gtk::TreePath(ToString(i))); |
m_TreeViewInstruments.scroll_to_row(Gtk::TreePath(ToString(i))); |
2378 |
#if !USE_GTKMM_BUILDER |
#if !USE_GTKMM_BUILDER |
2379 |
// select item in instrument menu |
// select item in instrument menu |
2380 |
{ |
{ |
2397 |
|
|
2398 |
void MainWindow::on_loader_finished() |
void MainWindow::on_loader_finished() |
2399 |
{ |
{ |
2400 |
|
loader->join(); |
2401 |
printf("Loader finished!\n"); |
printf("Loader finished!\n"); |
2402 |
|
#ifdef GLIB_THREADS |
2403 |
printf("on_loader_finished self=%p\n", |
printf("on_loader_finished self=%p\n", |
2404 |
static_cast<void*>(Glib::Threads::Thread::self())); |
static_cast<void*>(Glib::Threads::Thread::self())); |
2405 |
|
#else |
2406 |
|
std::cout << "on_loader_finished self=" << |
2407 |
|
std::this_thread::get_id() << "\n"; |
2408 |
|
#endif |
2409 |
load_gig(loader->gig, loader->filename.c_str()); |
load_gig(loader->gig, loader->filename.c_str()); |
2410 |
progress_dialog->hide(); |
progress_dialog->hide(); |
2411 |
} |
} |
2412 |
|
|
2413 |
void MainWindow::on_loader_error() |
void MainWindow::on_loader_error() |
2414 |
{ |
{ |
2415 |
|
loader->join(); |
2416 |
Glib::ustring txt = _("Could not load file: ") + loader->error_message; |
Glib::ustring txt = _("Could not load file: ") + loader->error_message; |
2417 |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
2418 |
msg.run(); |
msg.run(); |
2483 |
|
|
2484 |
void MainWindow::on_saver_error() |
void MainWindow::on_saver_error() |
2485 |
{ |
{ |
2486 |
|
saver->join(); |
2487 |
file_structure_changed_signal.emit(this->file); |
file_structure_changed_signal.emit(this->file); |
2488 |
Glib::ustring txt = _("Could not save file: ") + saver->error_message; |
Glib::ustring txt = _("Could not save file: ") + saver->error_message; |
2489 |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
2492 |
|
|
2493 |
void MainWindow::on_saver_finished() |
void MainWindow::on_saver_finished() |
2494 |
{ |
{ |
2495 |
|
saver->join(); |
2496 |
this->file = saver->gig; |
this->file = saver->gig; |
2497 |
this->filename = saver->filename; |
this->filename = saver->filename; |
2498 |
current_gig_dir = Glib::path_get_dirname(filename); |
current_gig_dir = Glib::path_get_dirname(filename); |
2584 |
#endif |
#endif |
2585 |
|
|
2586 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
2587 |
|
dialog.hide(); |
2588 |
std::string filename = dialog.get_filename(); |
std::string filename = dialog.get_filename(); |
2589 |
if (!Glib::str_has_suffix(filename, ".gig")) { |
if (!Glib::str_has_suffix(filename, ".gig")) { |
2590 |
filename += ".gig"; |
filename += ".gig"; |
2713 |
|
|
2714 |
void MainWindow::on_action_file_properties() |
void MainWindow::on_action_file_properties() |
2715 |
{ |
{ |
2716 |
propDialog.show(); |
fileProps.show(); |
2717 |
propDialog.deiconify(); |
fileProps.deiconify(); |
2718 |
} |
} |
2719 |
|
|
2720 |
void MainWindow::on_action_warn_user_on_extensions() { |
void MainWindow::on_action_warn_user_on_extensions() { |
2738 |
dimreg_stereo.set_has_tooltip(b); |
dimreg_stereo.set_has_tooltip(b); |
2739 |
|
|
2740 |
// Not doing this here, we let onQueryTreeViewTooltip() handle this per cell |
// Not doing this here, we let onQueryTreeViewTooltip() handle this per cell |
2741 |
//m_TreeView.set_has_tooltip(b); |
//m_TreeViewInstruments.set_has_tooltip(b); |
2742 |
|
|
2743 |
m_TreeViewSamples.set_has_tooltip(b); |
m_TreeViewSamples.set_has_tooltip(b); |
2744 |
m_TreeViewScripts.set_has_tooltip(b); |
m_TreeViewScripts.set_has_tooltip(b); |
2776 |
"backup your Gigasampler/GigaStudio files before editing them with " |
"backup your Gigasampler/GigaStudio files before editing them with " |
2777 |
"this application.\n" |
"this application.\n" |
2778 |
"\n" |
"\n" |
2779 |
"Please report bugs to: http://bugs.linuxsampler.org" |
"Please report bugs to: https://bugs.linuxsampler.org" |
2780 |
); |
); |
2781 |
dialog.set_comments(sComment.c_str()); |
dialog.set_comments(sComment.c_str()); |
2782 |
dialog.set_website("http://www.linuxsampler.org"); |
dialog.set_website("https://www.linuxsampler.org"); |
2783 |
dialog.set_website_label("http://www.linuxsampler.org"); |
dialog.set_website_label("https://www.linuxsampler.org"); |
2784 |
dialog.set_position(Gtk::WIN_POS_CENTER); |
dialog.set_position(Gtk::WIN_POS_CENTER); |
2785 |
dialog.run(); |
dialog.run(); |
2786 |
} |
} |
2787 |
|
|
2788 |
PropDialog::PropDialog() |
FilePropDialog::FilePropDialog() |
2789 |
: eFileFormat(_("File Format")), |
: eFileFormat(_("File Format")), |
2790 |
eName(_("Name")), |
eName(_("Name")), |
2791 |
eCreationDate(_("Creation date")), |
eCreationDate(_("Creation date")), |
2819 |
set_title(_("File Properties")); |
set_title(_("File Properties")); |
2820 |
eName.set_width_chars(50); |
eName.set_width_chars(50); |
2821 |
|
|
2822 |
|
connect(eFileFormat, &FilePropDialog::set_FileFormat); |
2823 |
connect(eName, &DLS::Info::Name); |
connect(eName, &DLS::Info::Name); |
2824 |
connect(eCreationDate, &DLS::Info::CreationDate); |
connect(eCreationDate, &DLS::Info::CreationDate); |
2825 |
connect(eComments, &DLS::Info::Comments); |
connect(eComments, &DLS::Info::Comments); |
2880 |
quitButton.set_can_default(); |
quitButton.set_can_default(); |
2881 |
quitButton.grab_focus(); |
quitButton.grab_focus(); |
2882 |
quitButton.signal_clicked().connect( |
quitButton.signal_clicked().connect( |
2883 |
sigc::mem_fun(*this, &PropDialog::hide)); |
sigc::mem_fun(*this, &FilePropDialog::hide)); |
|
eFileFormat.signal_value_changed().connect( |
|
|
sigc::mem_fun(*this, &PropDialog::onFileFormatChanged)); |
|
2884 |
|
|
2885 |
quitButton.show(); |
quitButton.show(); |
2886 |
vbox.show(); |
vbox.show(); |
2889 |
#endif |
#endif |
2890 |
} |
} |
2891 |
|
|
2892 |
void PropDialog::set_file(gig::File* file) |
void FilePropDialog::set_file(gig::File* file) |
2893 |
{ |
{ |
2894 |
m_file = file; |
m_file = file; |
2895 |
|
update(file->pInfo); |
2896 |
|
|
2897 |
// update file format version combo box |
// update file format version combo box |
2898 |
const std::string sGiga = "Gigasampler/GigaStudio v"; |
const std::string sGiga = "Gigasampler/GigaStudio v"; |
2908 |
std::vector<const char*> texts; |
std::vector<const char*> texts; |
2909 |
for (int i = 0; i < txts.size(); ++i) texts.push_back(txts[i].c_str()); |
for (int i = 0; i < txts.size(); ++i) texts.push_back(txts[i].c_str()); |
2910 |
texts.push_back(NULL); values.push_back(0); |
texts.push_back(NULL); values.push_back(0); |
2911 |
|
|
2912 |
|
update_model++; |
2913 |
eFileFormat.set_choices(&texts[0], &values[0]); |
eFileFormat.set_choices(&texts[0], &values[0]); |
2914 |
eFileFormat.set_value(major); |
eFileFormat.set_value(major); |
2915 |
|
update_model--; |
2916 |
} |
} |
2917 |
|
|
2918 |
void PropDialog::onFileFormatChanged() { |
void FilePropDialog::set_FileFormat(int value) |
|
const int major = eFileFormat.get_value(); |
|
|
if (m_file) m_file->pVersion->major = major; |
|
|
} |
|
|
|
|
|
void PropDialog::set_info(DLS::Info* info) |
|
2919 |
{ |
{ |
2920 |
update(info); |
m_file->pVersion->major = value; |
2921 |
} |
} |
2922 |
|
|
2923 |
|
|
2959 |
eIsDrum(_("Is drum")), |
eIsDrum(_("Is drum")), |
2960 |
eMIDIBank(_("MIDI bank"), 0, 16383), |
eMIDIBank(_("MIDI bank"), 0, 16383), |
2961 |
eMIDIProgram(_("MIDI program")), |
eMIDIProgram(_("MIDI program")), |
2962 |
eAttenuation(_("Attenuation"), 0, 96, 0, 1), |
eAttenuation(_("Attenuation (dB)"), -96, +96, 0, 1), |
|
eGainPlus6(_("Gain +6dB"), eAttenuation, -6), |
|
2963 |
eEffectSend(_("Effect send"), 0, 65535), |
eEffectSend(_("Effect send"), 0, 65535), |
2964 |
eFineTune(_("Fine tune"), -8400, 8400), |
eFineTune(_("Fine tune"), -8400, 8400), |
2965 |
ePitchbendRange(_("Pitchbend range"), 0, 48), |
ePitchbendRange(_("Pitchbend range (halftones)"), 0, 48), |
2966 |
ePianoReleaseMode(_("Piano release mode")), |
ePianoReleaseMode(_("Piano release mode")), |
2967 |
eDimensionKeyRangeLow(_("Keyswitching range low")), |
eDimensionKeyRangeLow(_("Keyswitching range low")), |
2968 |
eDimensionKeyRangeHigh(_("Keyswitching range high")) |
eDimensionKeyRangeHigh(_("Keyswitching range high")), |
2969 |
|
table2(2,1), |
2970 |
|
eName2(_("Name")), |
2971 |
|
eCreationDate(_("Creation date")), |
2972 |
|
eComments(_("Comments")), |
2973 |
|
eProduct(_("Product")), |
2974 |
|
eCopyright(_("Copyright")), |
2975 |
|
eArtists(_("Artists")), |
2976 |
|
eGenre(_("Genre")), |
2977 |
|
eKeywords(_("Keywords")), |
2978 |
|
eEngineer(_("Engineer")), |
2979 |
|
eTechnician(_("Technician")), |
2980 |
|
eSoftware(_("Software")), |
2981 |
|
eMedium(_("Medium")), |
2982 |
|
eSource(_("Source")), |
2983 |
|
eSourceForm(_("Source form")), |
2984 |
|
eCommissioned(_("Commissioned")), |
2985 |
|
eSubject(_("Subject")) |
2986 |
{ |
{ |
2987 |
if (!Settings::singleton()->autoRestoreWindowDimension) { |
if (!Settings::singleton()->autoRestoreWindowDimension) { |
2988 |
//set_default_size(470, 390); |
//set_default_size(470, 390); |
2991 |
|
|
2992 |
set_title(_("Instrument Properties")); |
set_title(_("Instrument Properties")); |
2993 |
|
|
2994 |
|
tabs.append_page(vbox[1], _("Settings")); |
2995 |
|
tabs.append_page(vbox[2], _("Info")); |
2996 |
|
|
2997 |
eDimensionKeyRangeLow.set_tip( |
eDimensionKeyRangeLow.set_tip( |
2998 |
_("start of the keyboard area which should switch the " |
_("start of the keyboard area which should switch the " |
2999 |
"\"keyswitching\" dimension") |
"\"keyswitching\" dimension") |
3008 |
connect(eMIDIBank, &InstrumentProps::set_MIDIBank); |
connect(eMIDIBank, &InstrumentProps::set_MIDIBank); |
3009 |
connect(eMIDIProgram, &InstrumentProps::set_MIDIProgram); |
connect(eMIDIProgram, &InstrumentProps::set_MIDIProgram); |
3010 |
connect(eAttenuation, &gig::Instrument::Attenuation); |
connect(eAttenuation, &gig::Instrument::Attenuation); |
|
connect(eGainPlus6, &gig::Instrument::Attenuation); |
|
3011 |
connect(eEffectSend, &gig::Instrument::EffectSend); |
connect(eEffectSend, &gig::Instrument::EffectSend); |
3012 |
connect(eFineTune, &gig::Instrument::FineTune); |
connect(eFineTune, &gig::Instrument::FineTune); |
3013 |
connect(ePitchbendRange, &gig::Instrument::PitchbendRange); |
connect(ePitchbendRange, &gig::Instrument::PitchbendRange); |
3017 |
|
|
3018 |
eName.signal_value_changed().connect(sig_name_changed.make_slot()); |
eName.signal_value_changed().connect(sig_name_changed.make_slot()); |
3019 |
|
|
3020 |
|
connect(eName2, &InstrumentProps::set_Name); |
3021 |
|
connectLambda(eCreationDate, [this](gig::String s) { |
3022 |
|
m->pInfo->CreationDate = s; |
3023 |
|
}); |
3024 |
|
connectLambda(eComments, [this](gig::String s) { |
3025 |
|
m->pInfo->Comments = s; |
3026 |
|
}); |
3027 |
|
connectLambda(eProduct, [this](gig::String s) { |
3028 |
|
m->pInfo->Product = s; |
3029 |
|
}); |
3030 |
|
connectLambda(eCopyright, [this](gig::String s) { |
3031 |
|
m->pInfo->Copyright = s; |
3032 |
|
}); |
3033 |
|
connectLambda(eArtists, [this](gig::String s) { |
3034 |
|
m->pInfo->Artists = s; |
3035 |
|
}); |
3036 |
|
connectLambda(eGenre, [this](gig::String s) { |
3037 |
|
m->pInfo->Genre = s; |
3038 |
|
}); |
3039 |
|
connectLambda(eKeywords, [this](gig::String s) { |
3040 |
|
m->pInfo->Keywords = s; |
3041 |
|
}); |
3042 |
|
connectLambda(eEngineer, [this](gig::String s) { |
3043 |
|
m->pInfo->Engineer = s; |
3044 |
|
}); |
3045 |
|
connectLambda(eTechnician, [this](gig::String s) { |
3046 |
|
m->pInfo->Technician = s; |
3047 |
|
}); |
3048 |
|
connectLambda(eSoftware, [this](gig::String s) { |
3049 |
|
m->pInfo->Software = s; |
3050 |
|
}); |
3051 |
|
connectLambda(eMedium, [this](gig::String s) { |
3052 |
|
m->pInfo->Medium = s; |
3053 |
|
}); |
3054 |
|
connectLambda(eSource, [this](gig::String s) { |
3055 |
|
m->pInfo->Source = s; |
3056 |
|
}); |
3057 |
|
connectLambda(eSourceForm, [this](gig::String s) { |
3058 |
|
m->pInfo->SourceForm = s; |
3059 |
|
}); |
3060 |
|
connectLambda(eCommissioned, [this](gig::String s) { |
3061 |
|
m->pInfo->Commissioned = s; |
3062 |
|
}); |
3063 |
|
connectLambda(eSubject, [this](gig::String s) { |
3064 |
|
m->pInfo->Subject = s; |
3065 |
|
}); |
3066 |
|
|
3067 |
|
// tab 1 |
3068 |
#if USE_GTKMM_GRID |
#if USE_GTKMM_GRID |
3069 |
table.set_column_spacing(5); |
table.set_column_spacing(5); |
3070 |
#else |
#else |
3071 |
table.set_col_spacings(5); |
table.set_col_spacings(5); |
3072 |
#endif |
#endif |
|
|
|
3073 |
table.add(eName); |
table.add(eName); |
3074 |
table.add(eIsDrum); |
table.add(eIsDrum); |
3075 |
table.add(eMIDIBank); |
table.add(eMIDIBank); |
3076 |
table.add(eMIDIProgram); |
table.add(eMIDIProgram); |
3077 |
table.add(eAttenuation); |
table.add(eAttenuation); |
|
table.add(eGainPlus6); |
|
3078 |
table.add(eEffectSend); |
table.add(eEffectSend); |
3079 |
table.add(eFineTune); |
table.add(eFineTune); |
3080 |
table.add(ePitchbendRange); |
table.add(ePitchbendRange); |
3082 |
table.add(eDimensionKeyRangeLow); |
table.add(eDimensionKeyRangeLow); |
3083 |
table.add(eDimensionKeyRangeHigh); |
table.add(eDimensionKeyRangeHigh); |
3084 |
|
|
3085 |
add(vbox); |
// tab 2 |
3086 |
|
#if USE_GTKMM_GRID |
3087 |
|
table2.set_column_spacing(5); |
3088 |
|
#else |
3089 |
|
table2.set_col_spacings(5); |
3090 |
|
#endif |
3091 |
|
table2.add(eName2); |
3092 |
|
table2.add(eCreationDate); |
3093 |
|
table2.add(eComments); |
3094 |
|
table2.add(eProduct); |
3095 |
|
table2.add(eCopyright); |
3096 |
|
table2.add(eArtists); |
3097 |
|
table2.add(eGenre); |
3098 |
|
table2.add(eKeywords); |
3099 |
|
table2.add(eEngineer); |
3100 |
|
table2.add(eTechnician); |
3101 |
|
table2.add(eSoftware); |
3102 |
|
table2.add(eMedium); |
3103 |
|
table2.add(eSource); |
3104 |
|
table2.add(eSourceForm); |
3105 |
|
table2.add(eCommissioned); |
3106 |
|
table2.add(eSubject); |
3107 |
|
|
3108 |
|
add(vbox[0]); |
3109 |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) |
3110 |
table.set_margin(5); |
table.set_margin(5); |
3111 |
#else |
#else |
3112 |
table.set_border_width(5); |
table.set_border_width(5); |
3113 |
#endif |
#endif |
3114 |
vbox.pack_start(table); |
vbox[1].pack_start(table); |
3115 |
|
vbox[2].pack_start(table2); |
3116 |
table.show(); |
table.show(); |
3117 |
vbox.pack_start(buttonBox, Gtk::PACK_SHRINK); |
table2.show(); |
3118 |
|
vbox[0].pack_start(tabs); |
3119 |
|
vbox[0].pack_start(buttonBox, Gtk::PACK_SHRINK); |
3120 |
buttonBox.set_layout(Gtk::BUTTONBOX_END); |
buttonBox.set_layout(Gtk::BUTTONBOX_END); |
3121 |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) |
3122 |
buttonBox.set_margin(5); |
buttonBox.set_margin(5); |
3132 |
sigc::mem_fun(*this, &InstrumentProps::hide)); |
sigc::mem_fun(*this, &InstrumentProps::hide)); |
3133 |
|
|
3134 |
quitButton.show(); |
quitButton.show(); |
3135 |
vbox.show(); |
vbox[0].show(); |
3136 |
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
3137 |
show_all_children(); |
show_all_children(); |
3138 |
#endif |
#endif |
3143 |
update(instrument); |
update(instrument); |
3144 |
|
|
3145 |
update_model++; |
update_model++; |
3146 |
|
|
3147 |
|
// tab 1 |
3148 |
eName.set_value(instrument->pInfo->Name); |
eName.set_value(instrument->pInfo->Name); |
3149 |
eIsDrum.set_value(instrument->IsDrum); |
eIsDrum.set_value(instrument->IsDrum); |
3150 |
eMIDIBank.set_value(instrument->MIDIBank); |
eMIDIBank.set_value(instrument->MIDIBank); |
3151 |
eMIDIProgram.set_value(instrument->MIDIProgram); |
eMIDIProgram.set_value(instrument->MIDIProgram); |
3152 |
|
// tab 2 |
3153 |
|
eName2.set_value(instrument->pInfo->Name); |
3154 |
|
eCreationDate.set_value(instrument->pInfo->CreationDate); |
3155 |
|
eComments.set_value(instrument->pInfo->Comments); |
3156 |
|
eProduct.set_value(instrument->pInfo->Product); |
3157 |
|
eCopyright.set_value(instrument->pInfo->Copyright); |
3158 |
|
eArtists.set_value(instrument->pInfo->Artists); |
3159 |
|
eGenre.set_value(instrument->pInfo->Genre); |
3160 |
|
eKeywords.set_value(instrument->pInfo->Keywords); |
3161 |
|
eEngineer.set_value(instrument->pInfo->Engineer); |
3162 |
|
eTechnician.set_value(instrument->pInfo->Technician); |
3163 |
|
eSoftware.set_value(instrument->pInfo->Software); |
3164 |
|
eMedium.set_value(instrument->pInfo->Medium); |
3165 |
|
eSource.set_value(instrument->pInfo->Source); |
3166 |
|
eSourceForm.set_value(instrument->pInfo->SourceForm); |
3167 |
|
eCommissioned.set_value(instrument->pInfo->Commissioned); |
3168 |
|
eSubject.set_value(instrument->pInfo->Subject); |
3169 |
|
|
3170 |
|
update_model--; |
3171 |
|
} |
3172 |
|
|
3173 |
|
|
3174 |
|
SampleProps::SampleProps() : |
3175 |
|
#if HAS_GTKMM_STOCK |
3176 |
|
quitButton(Gtk::Stock::CLOSE), |
3177 |
|
#else |
3178 |
|
quitButton(_("_Close")), |
3179 |
|
#endif |
3180 |
|
table(2,1), |
3181 |
|
eName(_("Name")), |
3182 |
|
eUnityNote(_("Unity Note")), |
3183 |
|
eSampleGroup(_("Sample Group")), |
3184 |
|
eSampleFormatInfo(_("Sample Format")), |
3185 |
|
eSampleID("Sample ID"), |
3186 |
|
eChecksum("Wave Data CRC-32"), |
3187 |
|
eLoopsCount(_("Loops"), 0, 1), // we might support more than 1 loop in future |
3188 |
|
eLoopStart(_("Loop start position"), 0, 9999999), |
3189 |
|
eLoopLength(_("Loop size"), 0, 9999999), |
3190 |
|
eLoopType(_("Loop type")), |
3191 |
|
eLoopPlayCount(_("Playback count")), |
3192 |
|
table2(2,1), |
3193 |
|
eName2(_("Name")), |
3194 |
|
eCreationDate(_("Creation date")), |
3195 |
|
eComments(_("Comments")), |
3196 |
|
eProduct(_("Product")), |
3197 |
|
eCopyright(_("Copyright")), |
3198 |
|
eArtists(_("Artists")), |
3199 |
|
eGenre(_("Genre")), |
3200 |
|
eKeywords(_("Keywords")), |
3201 |
|
eEngineer(_("Engineer")), |
3202 |
|
eTechnician(_("Technician")), |
3203 |
|
eSoftware(_("Software")), |
3204 |
|
eMedium(_("Medium")), |
3205 |
|
eSource(_("Source")), |
3206 |
|
eSourceForm(_("Source form")), |
3207 |
|
eCommissioned(_("Commissioned")), |
3208 |
|
eSubject(_("Subject")) |
3209 |
|
{ |
3210 |
|
if (!Settings::singleton()->autoRestoreWindowDimension) { |
3211 |
|
//set_default_size(470, 390); |
3212 |
|
set_position(Gtk::WIN_POS_MOUSE); |
3213 |
|
} |
3214 |
|
|
3215 |
|
set_title(_("Sample Properties")); |
3216 |
|
|
3217 |
|
tabs.append_page(vbox[1], _("Settings")); |
3218 |
|
tabs.append_page(vbox[2], _("Info")); |
3219 |
|
|
3220 |
|
connect(eName, &SampleProps::set_Name); |
3221 |
|
connect(eUnityNote, &gig::Sample::MIDIUnityNote); |
3222 |
|
connect(eLoopsCount, &gig::Sample::Loops); |
3223 |
|
connectLambda(eLoopStart, [this](uint32_t start){ |
3224 |
|
m->LoopStart = start; |
3225 |
|
m->LoopEnd = start + m->LoopSize; |
3226 |
|
}); |
3227 |
|
connectLambda(eLoopLength, [this](uint32_t length){ |
3228 |
|
m->LoopSize = length; |
3229 |
|
m->LoopEnd = m->LoopStart + length; |
3230 |
|
}); |
3231 |
|
{ |
3232 |
|
const char* choices[] = { _("normal"), _("bidirectional"), _("backward"), 0 }; |
3233 |
|
static const gig::loop_type_t values[] = { |
3234 |
|
gig::loop_type_normal, |
3235 |
|
gig::loop_type_bidirectional, |
3236 |
|
gig::loop_type_backward |
3237 |
|
}; |
3238 |
|
eLoopType.set_choices(choices, values); |
3239 |
|
} |
3240 |
|
connect(eLoopType, &gig::Sample::LoopType); |
3241 |
|
connect(eLoopPlayCount, &gig::Sample::LoopPlayCount); |
3242 |
|
|
3243 |
|
eName.signal_value_changed().connect(sig_name_changed.make_slot()); |
3244 |
|
|
3245 |
|
connect(eName2, &SampleProps::set_Name); |
3246 |
|
connectLambda(eCreationDate, [this](gig::String s) { |
3247 |
|
m->pInfo->CreationDate = s; |
3248 |
|
}); |
3249 |
|
connectLambda(eComments, [this](gig::String s) { |
3250 |
|
m->pInfo->Comments = s; |
3251 |
|
}); |
3252 |
|
connectLambda(eProduct, [this](gig::String s) { |
3253 |
|
m->pInfo->Product = s; |
3254 |
|
}); |
3255 |
|
connectLambda(eCopyright, [this](gig::String s) { |
3256 |
|
m->pInfo->Copyright = s; |
3257 |
|
}); |
3258 |
|
connectLambda(eArtists, [this](gig::String s) { |
3259 |
|
m->pInfo->Artists = s; |
3260 |
|
}); |
3261 |
|
connectLambda(eGenre, [this](gig::String s) { |
3262 |
|
m->pInfo->Genre = s; |
3263 |
|
}); |
3264 |
|
connectLambda(eKeywords, [this](gig::String s) { |
3265 |
|
m->pInfo->Keywords = s; |
3266 |
|
}); |
3267 |
|
connectLambda(eEngineer, [this](gig::String s) { |
3268 |
|
m->pInfo->Engineer = s; |
3269 |
|
}); |
3270 |
|
connectLambda(eTechnician, [this](gig::String s) { |
3271 |
|
m->pInfo->Technician = s; |
3272 |
|
}); |
3273 |
|
connectLambda(eSoftware, [this](gig::String s) { |
3274 |
|
m->pInfo->Software = s; |
3275 |
|
}); |
3276 |
|
connectLambda(eMedium, [this](gig::String s) { |
3277 |
|
m->pInfo->Medium = s; |
3278 |
|
}); |
3279 |
|
connectLambda(eSource, [this](gig::String s) { |
3280 |
|
m->pInfo->Source = s; |
3281 |
|
}); |
3282 |
|
connectLambda(eSourceForm, [this](gig::String s) { |
3283 |
|
m->pInfo->SourceForm = s; |
3284 |
|
}); |
3285 |
|
connectLambda(eCommissioned, [this](gig::String s) { |
3286 |
|
m->pInfo->Commissioned = s; |
3287 |
|
}); |
3288 |
|
connectLambda(eSubject, [this](gig::String s) { |
3289 |
|
m->pInfo->Subject = s; |
3290 |
|
}); |
3291 |
|
|
3292 |
|
// tab 1 |
3293 |
|
#if USE_GTKMM_GRID |
3294 |
|
table.set_column_spacing(5); |
3295 |
|
#else |
3296 |
|
table.set_col_spacings(5); |
3297 |
|
#endif |
3298 |
|
table.add(eName); |
3299 |
|
table.add(eUnityNote); |
3300 |
|
table.add(eSampleGroup); |
3301 |
|
table.add(eSampleFormatInfo); |
3302 |
|
table.add(eSampleID); |
3303 |
|
table.add(eChecksum); |
3304 |
|
table.add(eLoopsCount); |
3305 |
|
table.add(eLoopStart); |
3306 |
|
table.add(eLoopLength); |
3307 |
|
table.add(eLoopType); |
3308 |
|
table.add(eLoopPlayCount); |
3309 |
|
|
3310 |
|
// tab 2 |
3311 |
|
#if USE_GTKMM_GRID |
3312 |
|
table2.set_column_spacing(5); |
3313 |
|
#else |
3314 |
|
table2.set_col_spacings(5); |
3315 |
|
#endif |
3316 |
|
table2.add(eName2); |
3317 |
|
table2.add(eCreationDate); |
3318 |
|
table2.add(eComments); |
3319 |
|
table2.add(eProduct); |
3320 |
|
table2.add(eCopyright); |
3321 |
|
table2.add(eArtists); |
3322 |
|
table2.add(eGenre); |
3323 |
|
table2.add(eKeywords); |
3324 |
|
table2.add(eEngineer); |
3325 |
|
table2.add(eTechnician); |
3326 |
|
table2.add(eSoftware); |
3327 |
|
table2.add(eMedium); |
3328 |
|
table2.add(eSource); |
3329 |
|
table2.add(eSourceForm); |
3330 |
|
table2.add(eCommissioned); |
3331 |
|
table2.add(eSubject); |
3332 |
|
|
3333 |
|
add(vbox[0]); |
3334 |
|
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) |
3335 |
|
table.set_margin(5); |
3336 |
|
#else |
3337 |
|
table.set_border_width(5); |
3338 |
|
#endif |
3339 |
|
vbox[1].pack_start(table); |
3340 |
|
vbox[2].pack_start(table2); |
3341 |
|
table.show(); |
3342 |
|
table2.show(); |
3343 |
|
vbox[0].pack_start(tabs); |
3344 |
|
vbox[0].pack_start(buttonBox, Gtk::PACK_SHRINK); |
3345 |
|
buttonBox.set_layout(Gtk::BUTTONBOX_END); |
3346 |
|
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) |
3347 |
|
buttonBox.set_margin(5); |
3348 |
|
#else |
3349 |
|
buttonBox.set_border_width(5); |
3350 |
|
#endif |
3351 |
|
buttonBox.show(); |
3352 |
|
buttonBox.pack_start(quitButton); |
3353 |
|
quitButton.set_can_default(); |
3354 |
|
quitButton.grab_focus(); |
3355 |
|
|
3356 |
|
quitButton.signal_clicked().connect( |
3357 |
|
sigc::mem_fun(*this, &SampleProps::hide)); |
3358 |
|
|
3359 |
|
quitButton.show(); |
3360 |
|
vbox[0].show(); |
3361 |
|
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
3362 |
|
show_all_children(); |
3363 |
|
#endif |
3364 |
|
} |
3365 |
|
|
3366 |
|
void SampleProps::set_sample(gig::Sample* sample) |
3367 |
|
{ |
3368 |
|
update(sample); |
3369 |
|
|
3370 |
|
update_model++; |
3371 |
|
|
3372 |
|
// tab 1 |
3373 |
|
eName.set_value(sample->pInfo->Name); |
3374 |
|
eUnityNote.set_value(sample->MIDIUnityNote); |
3375 |
|
// show sample group name |
3376 |
|
{ |
3377 |
|
Glib::ustring s = "---"; |
3378 |
|
if (sample && sample->GetGroup()) |
3379 |
|
s = sample->GetGroup()->Name; |
3380 |
|
eSampleGroup.text.set_text(s); |
3381 |
|
} |
3382 |
|
// assemble sample format info string |
3383 |
|
{ |
3384 |
|
Glib::ustring s; |
3385 |
|
if (sample) { |
3386 |
|
switch (sample->Channels) { |
3387 |
|
case 1: s = _("Mono"); break; |
3388 |
|
case 2: s = _("Stereo"); break; |
3389 |
|
default: |
3390 |
|
s = ToString(sample->Channels) + _(" audio channels"); |
3391 |
|
break; |
3392 |
|
} |
3393 |
|
s += " " + ToString(sample->BitDepth) + " Bits"; |
3394 |
|
s += " " + ToString(sample->SamplesPerSecond/1000) + "." |
3395 |
|
+ ToString((sample->SamplesPerSecond%1000)/100) + " kHz"; |
3396 |
|
} else { |
3397 |
|
s = _("No sample assigned to this dimension region."); |
3398 |
|
} |
3399 |
|
eSampleFormatInfo.text.set_text(s); |
3400 |
|
} |
3401 |
|
// generate sample's memory address pointer string |
3402 |
|
{ |
3403 |
|
Glib::ustring s; |
3404 |
|
if (sample) { |
3405 |
|
char buf[64] = {}; |
3406 |
|
snprintf(buf, sizeof(buf), "%p", sample); |
3407 |
|
s = buf; |
3408 |
|
} else { |
3409 |
|
s = "---"; |
3410 |
|
} |
3411 |
|
eSampleID.text.set_text(s); |
3412 |
|
} |
3413 |
|
// generate raw wave form data CRC-32 checksum string |
3414 |
|
{ |
3415 |
|
Glib::ustring s = "---"; |
3416 |
|
if (sample) { |
3417 |
|
char buf[64] = {}; |
3418 |
|
snprintf(buf, sizeof(buf), "%x", sample->GetWaveDataCRC32Checksum()); |
3419 |
|
s = buf; |
3420 |
|
} |
3421 |
|
eChecksum.text.set_text(s); |
3422 |
|
} |
3423 |
|
eLoopsCount.set_value(sample->Loops); |
3424 |
|
eLoopStart.set_value(sample->LoopStart); |
3425 |
|
eLoopLength.set_value(sample->LoopSize); |
3426 |
|
eLoopType.set_value(sample->LoopType); |
3427 |
|
eLoopPlayCount.set_value(sample->LoopPlayCount); |
3428 |
|
// tab 2 |
3429 |
|
eName2.set_value(sample->pInfo->Name); |
3430 |
|
eCreationDate.set_value(sample->pInfo->CreationDate); |
3431 |
|
eComments.set_value(sample->pInfo->Comments); |
3432 |
|
eProduct.set_value(sample->pInfo->Product); |
3433 |
|
eCopyright.set_value(sample->pInfo->Copyright); |
3434 |
|
eArtists.set_value(sample->pInfo->Artists); |
3435 |
|
eGenre.set_value(sample->pInfo->Genre); |
3436 |
|
eKeywords.set_value(sample->pInfo->Keywords); |
3437 |
|
eEngineer.set_value(sample->pInfo->Engineer); |
3438 |
|
eTechnician.set_value(sample->pInfo->Technician); |
3439 |
|
eSoftware.set_value(sample->pInfo->Software); |
3440 |
|
eMedium.set_value(sample->pInfo->Medium); |
3441 |
|
eSource.set_value(sample->pInfo->Source); |
3442 |
|
eSourceForm.set_value(sample->pInfo->SourceForm); |
3443 |
|
eCommissioned.set_value(sample->pInfo->Commissioned); |
3444 |
|
eSubject.set_value(sample->pInfo->Subject); |
3445 |
|
|
3446 |
|
update_model--; |
3447 |
|
} |
3448 |
|
|
3449 |
|
void SampleProps::set_Name(const gig::String& name) |
3450 |
|
{ |
3451 |
|
m->pInfo->Name = name; |
3452 |
|
} |
3453 |
|
|
3454 |
|
void SampleProps::update_name() |
3455 |
|
{ |
3456 |
|
update_model++; |
3457 |
|
eName.set_value(m->pInfo->Name); |
3458 |
update_model--; |
update_model--; |
3459 |
} |
} |
3460 |
|
|
3490 |
|
|
3491 |
bool MainWindow::onQueryTreeViewTooltip(int x, int y, bool keyboardTip, const Glib::RefPtr<Gtk::Tooltip>& tooltip) { |
bool MainWindow::onQueryTreeViewTooltip(int x, int y, bool keyboardTip, const Glib::RefPtr<Gtk::Tooltip>& tooltip) { |
3492 |
Gtk::TreeModel::iterator iter; |
Gtk::TreeModel::iterator iter; |
3493 |
if (!m_TreeView.get_tooltip_context_iter(x, y, keyboardTip, iter)) { |
if (!m_TreeViewInstruments.get_tooltip_context_iter(x, y, keyboardTip, iter)) { |
3494 |
return false; |
return false; |
3495 |
} |
} |
3496 |
Gtk::TreeModel::Path path(iter); |
Gtk::TreeModel::Path path(iter); |
3500 |
{ |
{ |
3501 |
Gtk::TreeModel::Path path; // unused |
Gtk::TreeModel::Path path; // unused |
3502 |
int cellX, cellY; // unused |
int cellX, cellY; // unused |
3503 |
m_TreeView.get_path_at_pos(x, y, path, pointedColumn, cellX, cellY); |
m_TreeViewInstruments.get_path_at_pos(x, y, path, pointedColumn, cellX, cellY); |
3504 |
} |
} |
3505 |
Gtk::TreeViewColumn* scriptsColumn = m_TreeView.get_column(2); |
Gtk::TreeViewColumn* scriptsColumn = m_TreeViewInstruments.get_column(2); |
3506 |
if (pointedColumn == scriptsColumn) { // mouse hovers scripts column ... |
if (pointedColumn == scriptsColumn) { // mouse hovers scripts column ... |
3507 |
// show the script(s) assigned to the hovered instrument as tooltip |
// show the script(s) assigned to the hovered instrument as tooltip |
3508 |
tooltip->set_markup( row[m_Columns.m_col_tooltip] ); |
tooltip->set_markup( row[m_InstrumentsModel.m_col_tooltip] ); |
3509 |
m_TreeView.set_tooltip_cell(tooltip, &path, scriptsColumn, NULL); |
m_TreeViewInstruments.set_tooltip_cell(tooltip, &path, scriptsColumn, NULL); |
3510 |
} else { |
} else { |
3511 |
// if beginners' tooltips is disabled then don't show the following one |
// if beginners' tooltips is disabled then don't show the following one |
3512 |
if (!Settings::singleton()->showTooltips) |
if (!Settings::singleton()->showTooltips) |
3516 |
"Right click here for actions on instruments & MIDI Rules. " |
"Right click here for actions on instruments & MIDI Rules. " |
3517 |
"Drag & drop to change the order of instruments." |
"Drag & drop to change the order of instruments." |
3518 |
)); |
)); |
3519 |
m_TreeView.set_tooltip_cell(tooltip, &path, pointedColumn, NULL); |
m_TreeViewInstruments.set_tooltip_cell(tooltip, &path, pointedColumn, NULL); |
3520 |
} |
} |
3521 |
return true; |
return true; |
3522 |
} |
} |
3542 |
file = 0; |
file = 0; |
3543 |
set_file_is_shared(isSharedInstrument); |
set_file_is_shared(isSharedInstrument); |
3544 |
|
|
3545 |
|
// assuming libgig's file-IO-per-thread feature is enabled: by default |
3546 |
|
// the file stream is closed for individual threads (except of the original |
3547 |
|
// thread having opened the gig file), so open the file stream for this |
3548 |
|
// thread for being able to read the .gig file |
3549 |
|
// (see libgig's RIFF::File::SetIOPerThread() for details) |
3550 |
|
::RIFF::File* riff = gig->GetRiffFile(); |
3551 |
|
if (!riff->IsNew() && riff->GetMode() == ::RIFF::stream_mode_closed) { |
3552 |
|
try { |
3553 |
|
riff->SetMode(::RIFF::stream_mode_read); |
3554 |
|
} catch (...) { |
3555 |
|
printf("Failed opening '%s' in read mode\n", |
3556 |
|
riff->GetFileName().c_str()); |
3557 |
|
} |
3558 |
|
} |
3559 |
|
|
3560 |
this->filename = |
this->filename = |
3561 |
(filename && strlen(filename) > 0) ? |
(filename && strlen(filename) > 0) ? |
3562 |
filename : (!gig->GetFileName().empty()) ? |
filename : (!gig->GetFileName().empty()) ? |
3565 |
file_has_name = filename; |
file_has_name = filename; |
3566 |
file_is_changed = false; |
file_is_changed = false; |
3567 |
|
|
3568 |
propDialog.set_file(gig); |
fileProps.set_file(gig); |
|
propDialog.set_info(gig->pInfo); |
|
3569 |
|
|
3570 |
instrument_name_connection.block(); |
instrument_name_connection.block(); |
3571 |
int index = 0; |
int index = 0; |
3574 |
Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
3575 |
const int iScriptSlots = instrument->ScriptSlotCount(); |
const int iScriptSlots = instrument->ScriptSlotCount(); |
3576 |
|
|
3577 |
Gtk::TreeModel::iterator iter = m_refTreeModel->append(); |
Gtk::TreeModel::iterator iter = m_refInstrumentsTreeModel->append(); |
3578 |
Gtk::TreeModel::Row row = *iter; |
Gtk::TreeModel::Row row = *iter; |
3579 |
row[m_Columns.m_col_nr] = index; |
row[m_InstrumentsModel.m_col_nr] = index; |
3580 |
row[m_Columns.m_col_name] = name; |
row[m_InstrumentsModel.m_col_name] = name; |
3581 |
row[m_Columns.m_col_instr] = instrument; |
row[m_InstrumentsModel.m_col_instr] = instrument; |
3582 |
row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : ""; |
row[m_InstrumentsModel.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : ""; |
3583 |
row[m_Columns.m_col_tooltip] = scriptTooltipFor(instrument, index); |
row[m_InstrumentsModel.m_col_tooltip] = scriptTooltipFor(instrument, index); |
3584 |
|
|
3585 |
#if !USE_GTKMM_BUILDER |
#if !USE_GTKMM_BUILDER |
3586 |
add_instrument_to_menu(name); |
add_instrument_to_menu(name); |
3642 |
file = gig; |
file = gig; |
3643 |
|
|
3644 |
// select the first instrument |
// select the first instrument |
3645 |
m_TreeView.get_selection()->select(Gtk::TreePath("0")); |
m_TreeViewInstruments.get_selection()->select(Gtk::TreePath("0")); |
3646 |
|
|
3647 |
instr_props_set_instrument(); |
instr_props_set_instrument(); |
3648 |
gig::Instrument* instrument = get_instrument(); |
gig::Instrument* instrument = get_instrument(); |
3655 |
{ |
{ |
3656 |
instrumentProps.signal_name_changed().clear(); |
instrumentProps.signal_name_changed().clear(); |
3657 |
|
|
3658 |
std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows(); |
// get visual selection |
3659 |
|
std::vector<Gtk::TreeModel::Path> rows = m_TreeViewInstruments.get_selection()->get_selected_rows(); |
3660 |
if (rows.empty()) { |
if (rows.empty()) { |
3661 |
instrumentProps.hide(); |
instrumentProps.hide(); |
3662 |
return false; |
return false; |
3663 |
} |
} |
3664 |
|
|
3665 |
|
// convert index of visual selection (i.e. if filtered) to index of model |
3666 |
|
Gtk::TreeModel::Path path = m_refInstrumentsModelFilter->convert_path_to_child_path(rows[0]); |
3667 |
|
|
3668 |
//NOTE: was const_iterator before, which did not compile with GTKMM4 development branch, probably going to be fixed before final GTKMM4 release though. |
//NOTE: was const_iterator before, which did not compile with GTKMM4 development branch, probably going to be fixed before final GTKMM4 release though. |
3669 |
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); |
Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(path); |
3670 |
if (it) { |
if (it) { |
3671 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
3672 |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
gig::Instrument* instrument = row[m_InstrumentsModel.m_col_instr]; |
3673 |
|
|
3674 |
instrumentProps.set_instrument(instrument); |
instrumentProps.set_instrument(instrument); |
3675 |
|
|
3698 |
void MainWindow::instr_name_changed_by_instr_props(Gtk::TreeModel::iterator& it) |
void MainWindow::instr_name_changed_by_instr_props(Gtk::TreeModel::iterator& it) |
3699 |
{ |
{ |
3700 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
3701 |
Glib::ustring name = row[m_Columns.m_col_name]; |
Glib::ustring name = row[m_InstrumentsModel.m_col_name]; |
3702 |
|
|
3703 |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
gig::Instrument* instrument = row[m_InstrumentsModel.m_col_instr]; |
3704 |
Glib::ustring gigname(gig_to_utf8(instrument->pInfo->Name)); |
Glib::ustring gigname(gig_to_utf8(instrument->pInfo->Name)); |
3705 |
if (gigname != name) { |
if (gigname != name) { |
3706 |
Gtk::TreeModel::Path path(*it); |
Gtk::TreeModel::Path path(*it); |
3707 |
const int index = path[0]; |
const int index = path[0]; |
3708 |
row[m_Columns.m_col_name] = gigname; |
row[m_InstrumentsModel.m_col_name] = gigname; |
3709 |
row[m_Columns.m_col_tooltip] = scriptTooltipFor(instrument, index); |
row[m_InstrumentsModel.m_col_tooltip] = scriptTooltipFor(instrument, index); |
3710 |
|
} |
3711 |
|
} |
3712 |
|
|
3713 |
|
bool MainWindow::sample_props_set_sample() |
3714 |
|
{ |
3715 |
|
sampleProps.signal_name_changed().clear(); |
3716 |
|
|
3717 |
|
std::vector<Gtk::TreeModel::Path> rows = m_TreeViewSamples.get_selection()->get_selected_rows(); |
3718 |
|
if (rows.empty()) { |
3719 |
|
sampleProps.hide(); |
3720 |
|
return false; |
3721 |
|
} |
3722 |
|
//NOTE: was const_iterator before, which did not compile with GTKMM4 development branch, probably going to be fixed before final GTKMM4 release though. |
3723 |
|
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[0]); |
3724 |
|
if (it) { |
3725 |
|
Gtk::TreeModel::Row row = *it; |
3726 |
|
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
3727 |
|
|
3728 |
|
sampleProps.set_sample(sample); |
3729 |
|
|
3730 |
|
// make sure sample tree is updated when user changes the |
3731 |
|
// sample name in sample properties window |
3732 |
|
sampleProps.signal_name_changed().connect( |
3733 |
|
sigc::bind( |
3734 |
|
sigc::mem_fun(*this, |
3735 |
|
&MainWindow::sample_name_changed_by_sample_props |
3736 |
|
), it |
3737 |
|
) |
3738 |
|
); |
3739 |
|
} else { |
3740 |
|
sampleProps.hide(); |
3741 |
|
} |
3742 |
|
//NOTE: explicit boolean cast required for GTKMM4 development branch here |
3743 |
|
return it ? true : false; |
3744 |
|
} |
3745 |
|
|
3746 |
|
void MainWindow::show_sample_props() |
3747 |
|
{ |
3748 |
|
if (sample_props_set_sample()) { |
3749 |
|
sampleProps.show(); |
3750 |
|
sampleProps.deiconify(); |
3751 |
|
} |
3752 |
|
} |
3753 |
|
|
3754 |
|
void MainWindow::sample_name_changed_by_sample_props(Gtk::TreeModel::iterator& it) |
3755 |
|
{ |
3756 |
|
Gtk::TreeModel::Row row = *it; |
3757 |
|
Glib::ustring name = row[m_SamplesModel.m_col_name]; |
3758 |
|
|
3759 |
|
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
3760 |
|
Glib::ustring gigname(gig_to_utf8(sample->pInfo->Name)); |
3761 |
|
if (gigname != name) { |
3762 |
|
Gtk::TreeModel::Path path(*it); |
3763 |
|
row[m_SamplesModel.m_col_name] = gigname; |
3764 |
} |
} |
3765 |
} |
} |
3766 |
|
|
3776 |
|
|
3777 |
void MainWindow::show_script_slots() { |
void MainWindow::show_script_slots() { |
3778 |
if (!file) return; |
if (!file) return; |
3779 |
|
|
3780 |
// get selected instrument |
// get selected instrument |
3781 |
std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows(); |
gig::Instrument* instrument = get_instrument(); |
|
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]; |
|
3782 |
if (!instrument) return; |
if (!instrument) return; |
3783 |
|
|
3784 |
ScriptSlots* window = new ScriptSlots; |
ScriptSlots* window = new ScriptSlots; |
3794 |
if (!pInstrument) return; |
if (!pInstrument) return; |
3795 |
const int iScriptSlots = pInstrument->ScriptSlotCount(); |
const int iScriptSlots = pInstrument->ScriptSlotCount(); |
3796 |
|
|
3797 |
//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! |
//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! |
3798 |
//Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model(); |
//Glib::RefPtr<Gtk::TreeModel> model = m_TreeViewInstruments.get_model(); |
3799 |
Glib::RefPtr<Gtk::TreeModel> model = m_refTreeModelFilter->get_model(); |
Glib::RefPtr<Gtk::TreeModel> model = m_refInstrumentsModelFilter->get_model(); |
3800 |
|
|
3801 |
for (int i = 0; i < model->children().size(); ++i) { |
for (int i = 0; i < model->children().size(); ++i) { |
3802 |
Gtk::TreeModel::Row row = model->children()[i]; |
Gtk::TreeModel::Row row = model->children()[i]; |
3803 |
if (row[m_Columns.m_col_instr] != pInstrument) continue; |
if (row[m_InstrumentsModel.m_col_instr] != pInstrument) continue; |
3804 |
row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : ""; |
row[m_InstrumentsModel.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : ""; |
3805 |
row[m_Columns.m_col_tooltip] = scriptTooltipFor(pInstrument, i); |
row[m_InstrumentsModel.m_col_tooltip] = scriptTooltipFor(pInstrument, i); |
3806 |
break; |
break; |
3807 |
} |
} |
3808 |
|
|
3809 |
// causes the sampler to reload the instrument with the new script |
// causes the sampler to reload the instrument with the new script |
3810 |
on_sel_change(); |
on_sel_change(); |
3811 |
|
|
3812 |
|
// force script 'patch' variables editor ("Script" tab) to be refreshed |
3813 |
|
dimreg_edit.scriptVars.setInstrument(pInstrument, true/*force update*/); |
3814 |
} |
} |
3815 |
|
|
3816 |
void MainWindow::assignScript(gig::Script* pScript) { |
void MainWindow::assignScript(gig::Script* pScript) { |
3891 |
#endif |
#endif |
3892 |
} |
} |
3893 |
|
|
3894 |
|
void MainWindow::on_instr_double_click_opens_props() { |
3895 |
|
#if USE_GLIB_ACTION |
3896 |
|
bool active = false; |
3897 |
|
m_actionInstrDoubleClickOpensProps->get_state(active); |
3898 |
|
// for some reason toggle state does not change automatically |
3899 |
|
active = !active; |
3900 |
|
m_actionInstrDoubleClickOpensProps->change_state(active); |
3901 |
|
Settings::singleton()->instrumentDoubleClickOpensProps = active; |
3902 |
|
#else |
3903 |
|
Gtk::CheckMenuItem* item = |
3904 |
|
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/OpenInstrPropsByDoubleClick")); |
3905 |
|
if (!item) { |
3906 |
|
std::cerr << "/MenuBar/MenuView/OpenInstrPropsByDoubleClick == NULL\n"; |
3907 |
|
return; |
3908 |
|
} |
3909 |
|
Settings::singleton()->instrumentDoubleClickOpensProps = item->get_active(); |
3910 |
|
#endif |
3911 |
|
} |
3912 |
|
|
3913 |
void MainWindow::on_save_with_temporary_file() { |
void MainWindow::on_save_with_temporary_file() { |
3914 |
#if USE_GLIB_ACTION |
#if USE_GLIB_ACTION |
3915 |
bool active = false; |
bool active = false; |
3984 |
void MainWindow::on_button_release(GdkEventButton* button) { |
void MainWindow::on_button_release(GdkEventButton* button) { |
3985 |
#endif |
#endif |
3986 |
if (button->type == GDK_2BUTTON_PRESS) { |
if (button->type == GDK_2BUTTON_PRESS) { |
3987 |
show_instr_props(); |
if (Settings::singleton()->instrumentDoubleClickOpensProps) |
3988 |
|
show_instr_props(); |
3989 |
} else if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
} else if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
3990 |
// gig v2 files have no midi rules |
// gig v2 files have no midi rules |
3991 |
const bool bEnabled = !(file->pVersion && file->pVersion->major == 2); |
const bool bEnabled = !(file->pVersion && file->pVersion->major == 2); |
4017 |
find(children.begin(), children.end(), item); |
find(children.begin(), children.end(), item); |
4018 |
if (it != children.end()) { |
if (it != children.end()) { |
4019 |
int index = it - children.begin(); |
int index = it - children.begin(); |
4020 |
m_TreeView.get_selection()->select(Gtk::TreePath(ToString(index))); |
|
4021 |
|
// convert index of model to index of visual presentation (i.e. if filtered) |
4022 |
|
Gtk::TreeModel::Path path = m_refInstrumentsModelFilter->convert_child_path_to_path(Gtk::TreePath(ToString(index))); |
4023 |
|
|
4024 |
|
if (path) |
4025 |
|
m_TreeViewInstruments.get_selection()->select(path); |
4026 |
|
else |
4027 |
|
m_TreeViewInstruments.get_selection()->unselect_all(); |
4028 |
|
|
4029 |
m_RegionChooser.set_instrument(file->GetInstrument(index)); |
m_RegionChooser.set_instrument(file->GetInstrument(index)); |
4030 |
} |
} |
4032 |
} |
} |
4033 |
#endif |
#endif |
4034 |
|
|
4035 |
|
void MainWindow::on_action_move_instr() { |
4036 |
|
gig::Instrument* instr = get_instrument(); |
4037 |
|
if (!instr) return; |
4038 |
|
|
4039 |
|
int currentIndex = getIndexOf(instr); |
4040 |
|
|
4041 |
|
Gtk::Dialog dialog(_("Move Instrument"), true /*modal*/); |
4042 |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
4043 |
|
Gtk::Adjustment adjustment( |
4044 |
|
currentIndex, |
4045 |
|
0 /*min*/, file->CountInstruments() - 1 /*max*/ |
4046 |
|
); |
4047 |
|
Gtk::SpinButton spinBox(adjustment); |
4048 |
|
#else |
4049 |
|
Gtk::SpinButton spinBox( |
4050 |
|
Gtk::Adjustment::create( |
4051 |
|
currentIndex, |
4052 |
|
0 /*min*/, file->CountInstruments() - 1 /*max*/ |
4053 |
|
) |
4054 |
|
); |
4055 |
|
#endif |
4056 |
|
#if USE_GTKMM_BOX |
4057 |
|
dialog.get_content_area()->pack_start(spinBox); |
4058 |
|
#else |
4059 |
|
dialog.get_vbox()->pack_start(spinBox); |
4060 |
|
#endif |
4061 |
|
#if HAS_GTKMM_STOCK |
4062 |
|
Gtk::Button* okButton = dialog.add_button(Gtk::Stock::OK, 0); |
4063 |
|
dialog.add_button(Gtk::Stock::CANCEL, 1); |
4064 |
|
#else |
4065 |
|
Gtk::Button* okButton = dialog.add_button(_("_OK"), 0); |
4066 |
|
dialog.add_button(_("_Cancel"), 1); |
4067 |
|
#endif |
4068 |
|
okButton->set_sensitive(false); |
4069 |
|
// show the dialog at a reasonable screen position |
4070 |
|
dialog.set_position(Gtk::WIN_POS_MOUSE); |
4071 |
|
// only enable the 'OK' button if entered new index is not instrument's |
4072 |
|
// current index already |
4073 |
|
spinBox.signal_value_changed().connect([&]{ |
4074 |
|
okButton->set_sensitive( spinBox.get_value_as_int() != currentIndex ); |
4075 |
|
}); |
4076 |
|
// usability acceleration: if user hits enter key on the text entry field |
4077 |
|
// then auto trigger the 'OK' button |
4078 |
|
spinBox.signal_activate().connect([&]{ |
4079 |
|
if (okButton->get_sensitive()) |
4080 |
|
okButton->clicked(); |
4081 |
|
}); |
4082 |
|
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
4083 |
|
dialog.show_all_children(); |
4084 |
|
#endif |
4085 |
|
if (!dialog.run()) { // 'OK' selected ... |
4086 |
|
int newIndex = spinBox.get_value_as_int(); |
4087 |
|
printf("MOVE TO %d\n", newIndex); |
4088 |
|
gig::Instrument* dst = file->GetInstrument(newIndex); |
4089 |
|
instr->MoveTo(dst); |
4090 |
|
__refreshEntireGUI(); |
4091 |
|
select_instrument(instr); |
4092 |
|
} |
4093 |
|
} |
4094 |
|
|
4095 |
void MainWindow::select_instrument(gig::Instrument* instrument) { |
void MainWindow::select_instrument(gig::Instrument* instrument) { |
4096 |
if (!instrument) return; |
if (!instrument) return; |
4097 |
|
|
4098 |
//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! |
//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! |
4099 |
Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model(); |
Glib::RefPtr<Gtk::TreeModel> model = m_TreeViewInstruments.get_model(); |
4100 |
//Glib::RefPtr<Gtk::TreeModel> model = m_refTreeModelFilter->get_model(); |
//Glib::RefPtr<Gtk::TreeModel> model = m_refInstrumentsModelFilter->get_model(); |
4101 |
|
|
4102 |
for (int i = 0; i < model->children().size(); ++i) { |
for (int i = 0; i < model->children().size(); ++i) { |
4103 |
Gtk::TreeModel::Row row = model->children()[i]; |
Gtk::TreeModel::Row row = model->children()[i]; |
4104 |
if (row[m_Columns.m_col_instr] == instrument) { |
if (row[m_InstrumentsModel.m_col_instr] == instrument) { |
4105 |
// select and show the respective instrument in the list view |
// select and show the respective instrument in the list view |
4106 |
show_intruments_tab(); |
show_intruments_tab(); |
4107 |
m_TreeView.get_selection()->unselect_all(); |
m_TreeViewInstruments.get_selection()->unselect_all(); |
4108 |
|
|
4109 |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) |
4110 |
auto iterSel = model->children()[i].get_iter(); |
auto iterSel = model->children()[i].get_iter(); |
4111 |
m_TreeView.get_selection()->select(iterSel); |
m_TreeViewInstruments.get_selection()->select(iterSel); |
4112 |
#else |
#else |
4113 |
m_TreeView.get_selection()->select(model->children()[i]); |
m_TreeViewInstruments.get_selection()->select(model->children()[i]); |
4114 |
#endif |
#endif |
4115 |
std::vector<Gtk::TreeModel::Path> rows = |
std::vector<Gtk::TreeModel::Path> rows = |
4116 |
m_TreeView.get_selection()->get_selected_rows(); |
m_TreeViewInstruments.get_selection()->get_selected_rows(); |
4117 |
if (!rows.empty()) |
if (!rows.empty()) |
4118 |
m_TreeView.scroll_to_row(rows[0]); |
m_TreeViewInstruments.scroll_to_row(rows[0]); |
4119 |
on_sel_change(); // the regular instrument selection change callback |
on_sel_change(); // the regular instrument selection change callback |
4120 |
} |
} |
4121 |
} |
} |
4126 |
gig::Region* pRegion = (gig::Region*) dimRgn->GetParent(); |
gig::Region* pRegion = (gig::Region*) dimRgn->GetParent(); |
4127 |
gig::Instrument* pInstrument = (gig::Instrument*) pRegion->GetParent(); |
gig::Instrument* pInstrument = (gig::Instrument*) pRegion->GetParent(); |
4128 |
|
|
4129 |
//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! |
//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! |
4130 |
Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model(); |
Glib::RefPtr<Gtk::TreeModel> model = m_TreeViewInstruments.get_model(); |
4131 |
//Glib::RefPtr<Gtk::TreeModel> model = m_refTreeModelFilter->get_model(); |
//Glib::RefPtr<Gtk::TreeModel> model = m_refInstrumentsModelFilter->get_model(); |
4132 |
|
|
4133 |
for (int i = 0; i < model->children().size(); ++i) { |
for (int i = 0; i < model->children().size(); ++i) { |
4134 |
Gtk::TreeModel::Row row = model->children()[i]; |
Gtk::TreeModel::Row row = model->children()[i]; |
4135 |
if (row[m_Columns.m_col_instr] == pInstrument) { |
if (row[m_InstrumentsModel.m_col_instr] == pInstrument) { |
4136 |
// select and show the respective instrument in the list view |
// select and show the respective instrument in the list view |
4137 |
show_intruments_tab(); |
show_intruments_tab(); |
4138 |
m_TreeView.get_selection()->unselect_all(); |
m_TreeViewInstruments.get_selection()->unselect_all(); |
4139 |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) |
4140 |
auto iterSel = model->children()[i].get_iter(); |
auto iterSel = model->children()[i].get_iter(); |
4141 |
m_TreeView.get_selection()->select(iterSel); |
m_TreeViewInstruments.get_selection()->select(iterSel); |
4142 |
#else |
#else |
4143 |
m_TreeView.get_selection()->select(model->children()[i]); |
m_TreeViewInstruments.get_selection()->select(model->children()[i]); |
4144 |
#endif |
#endif |
4145 |
std::vector<Gtk::TreeModel::Path> rows = |
std::vector<Gtk::TreeModel::Path> rows = |
4146 |
m_TreeView.get_selection()->get_selected_rows(); |
m_TreeViewInstruments.get_selection()->get_selected_rows(); |
4147 |
if (!rows.empty()) |
if (!rows.empty()) |
4148 |
m_TreeView.scroll_to_row(rows[0]); |
m_TreeViewInstruments.scroll_to_row(rows[0]); |
4149 |
on_sel_change(); // the regular instrument selection change callback |
on_sel_change(); // the regular instrument selection change callback |
4150 |
|
|
4151 |
// select respective region in the region selector |
// select respective region in the region selector |
4430 |
|
|
4431 |
// update instrument tree view |
// update instrument tree view |
4432 |
instrument_name_connection.block(); |
instrument_name_connection.block(); |
4433 |
Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append(); |
Gtk::TreeModel::iterator iterInstr = m_refInstrumentsTreeModel->append(); |
4434 |
Gtk::TreeModel::Row rowInstr = *iterInstr; |
Gtk::TreeModel::Row rowInstr = *iterInstr; |
4435 |
const int index = m_refTreeModel->children().size() - 1; |
const int index = m_refInstrumentsTreeModel->children().size() - 1; |
4436 |
rowInstr[m_Columns.m_col_nr] = index; |
const int iScriptSlots = instrument->ScriptSlotCount(); |
4437 |
rowInstr[m_Columns.m_col_name] = name; |
rowInstr[m_InstrumentsModel.m_col_nr] = index; |
4438 |
rowInstr[m_Columns.m_col_instr] = instrument; |
rowInstr[m_InstrumentsModel.m_col_name] = name; |
4439 |
rowInstr[m_Columns.m_col_scripts] = ""; |
rowInstr[m_InstrumentsModel.m_col_instr] = instrument; |
4440 |
rowInstr[m_Columns.m_col_tooltip] = scriptTooltipFor(instrument, index); |
rowInstr[m_InstrumentsModel.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : ""; |
4441 |
|
rowInstr[m_InstrumentsModel.m_col_tooltip] = scriptTooltipFor(instrument, index); |
4442 |
instrument_name_connection.unblock(); |
instrument_name_connection.unblock(); |
4443 |
|
|
4444 |
#if !USE_GTKMM_BUILDER |
#if !USE_GTKMM_BUILDER |
4464 |
|
|
4465 |
// retrieve the currently selected instrument |
// retrieve the currently selected instrument |
4466 |
// (being the original instrument to be duplicated) |
// (being the original instrument to be duplicated) |
4467 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewInstruments.get_selection(); |
4468 |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
4469 |
for (int r = 0; r < rows.size(); ++r) { |
for (int r = 0; r < rows.size(); ++r) { |
4470 |
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]); |
// convert index of visual selection (i.e. if filtered) to index of model |
4471 |
|
Gtk::TreeModel::Path path = m_refInstrumentsModelFilter->convert_path_to_child_path(rows[r]); |
4472 |
|
Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(path); |
4473 |
if (it) { |
if (it) { |
4474 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
4475 |
gig::Instrument* instrOrig = row[m_Columns.m_col_instr]; |
gig::Instrument* instrOrig = row[m_InstrumentsModel.m_col_instr]; |
4476 |
if (instrOrig) { |
if (instrOrig) { |
4477 |
// duplicate the orginal instrument |
// duplicate the orginal instrument |
4478 |
gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig); |
gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig); |
4499 |
return; |
return; |
4500 |
} |
} |
4501 |
|
|
4502 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewInstruments.get_selection(); |
4503 |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
std::vector<Gtk::TreeModel::Path> rowsVisual = sel->get_selected_rows(); |
4504 |
|
|
4505 |
|
// convert indeces of visual selection (i.e. if filtered) to indeces of model |
4506 |
|
std::vector<Gtk::TreeModel::Path> rows; |
4507 |
|
for (int rv = 0; rv < rowsVisual.size(); ++rv) { |
4508 |
|
Gtk::TreeModel::Path path = m_refInstrumentsModelFilter->convert_path_to_child_path(rowsVisual[rv]); |
4509 |
|
if (path) |
4510 |
|
rows.push_back(path); |
4511 |
|
} |
4512 |
|
|
4513 |
for (int r = rows.size() - 1; r >= 0; --r) { |
for (int r = rows.size() - 1; r >= 0; --r) { |
4514 |
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]); |
Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(rows[r]); |
4515 |
if (!it) continue; |
if (!it) continue; |
4516 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
4517 |
gig::Instrument* instr = row[m_Columns.m_col_instr]; |
gig::Instrument* instr = row[m_InstrumentsModel.m_col_instr]; |
4518 |
try { |
try { |
4519 |
Gtk::TreePath path(it); |
Gtk::TreePath path(it); |
4520 |
int index = path[0]; |
int index = path[0]; |
4528 |
#endif |
#endif |
4529 |
|
|
4530 |
// remove row from instruments tree view |
// remove row from instruments tree view |
4531 |
m_refTreeModel->erase(it); |
m_refInstrumentsTreeModel->erase(it); |
4532 |
// update "Nr" column of all instrument rows |
// update "Nr" column of all instrument rows |
4533 |
{ |
{ |
4534 |
int index = 0; |
int index = 0; |
4535 |
for (Gtk::TreeModel::iterator it = m_refTreeModel->children().begin(); |
for (Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->children().begin(); |
4536 |
it != m_refTreeModel->children().end(); ++it, ++index) |
it != m_refInstrumentsTreeModel->children().end(); ++it, ++index) |
4537 |
{ |
{ |
4538 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
4539 |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
gig::Instrument* instrument = row[m_InstrumentsModel.m_col_instr]; |
4540 |
row[m_Columns.m_col_nr] = index; |
row[m_InstrumentsModel.m_col_nr] = index; |
4541 |
row[m_Columns.m_col_tooltip] = scriptTooltipFor(instrument, index); |
row[m_InstrumentsModel.m_col_tooltip] = scriptTooltipFor(instrument, index); |
4542 |
} |
} |
4543 |
} |
} |
4544 |
|
|
4545 |
#if GTKMM_MAJOR_VERSION < 3 |
#if GTKMM_MAJOR_VERSION < 3 |
4546 |
// select another instrument (in gtk3 this is done |
// select another instrument (in gtk3 this is done |
4547 |
// automatically) |
// automatically) |
4548 |
if (!m_refTreeModel->children().empty()) { |
if (!m_refInstrumentsTreeModel->children().empty()) { |
4549 |
if (index == m_refTreeModel->children().size()) { |
if (index == m_refInstrumentsTreeModel->children().size()) { |
4550 |
index--; |
index--; |
4551 |
} |
} |
4552 |
m_TreeView.get_selection()->select( |
m_TreeViewInstruments.get_selection()->select( |
4553 |
Gtk::TreePath(ToString(index))); |
Gtk::TreePath(ToString(index))); |
4554 |
} |
} |
4555 |
#endif |
#endif |
4568 |
} |
} |
4569 |
|
|
4570 |
void MainWindow::on_action_sample_properties() { |
void MainWindow::on_action_sample_properties() { |
4571 |
//TODO: show a dialog where the selected sample's properties can be edited |
show_sample_props(); |
|
Gtk::MessageDialog msg( |
|
|
*this, _("Sorry, yet to be implemented!"), false, Gtk::MESSAGE_INFO |
|
|
); |
|
|
msg.run(); |
|
4572 |
} |
} |
4573 |
|
|
4574 |
void MainWindow::on_action_add_script_group() { |
void MainWindow::on_action_add_script_group() { |
4631 |
if (!it) return; |
if (!it) return; |
4632 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
4633 |
gig::Script* script = row[m_ScriptsModel.m_col_script]; |
gig::Script* script = row[m_ScriptsModel.m_col_script]; |
4634 |
if (!script) return; |
editScript(script); |
4635 |
|
} |
4636 |
|
|
4637 |
|
void MainWindow::editScript(gig::Script* script) { |
4638 |
|
if (!script) return; |
4639 |
ScriptEditor* editor = new ScriptEditor; |
ScriptEditor* editor = new ScriptEditor; |
4640 |
editor->signal_script_to_be_changed.connect( |
editor->signal_script_to_be_changed.connect( |
4641 |
signal_script_to_be_changed.make_slot() |
signal_script_to_be_changed.make_slot() |
4642 |
); |
); |
4643 |
editor->signal_script_changed.connect( |
editor->signal_script_changed.connect([this](gig::Script* script) { |
4644 |
signal_script_changed.make_slot() |
// signal to sampler (which will reload the script due to this) |
4645 |
); |
signal_script_changed.emit(script); |
4646 |
|
// force script 'patch' variables editor ("Script" tab) to be refreshed |
4647 |
|
gig::Instrument* instr = get_instrument(); |
4648 |
|
dimreg_edit.scriptVars.setInstrument(instr, true/*force update*/); |
4649 |
|
}); |
4650 |
editor->setScript(script); |
editor->setScript(script); |
4651 |
//editor->reparent(*this); |
//editor->reparent(*this); |
4652 |
editor->show(); |
editor->show(); |
4794 |
dialog.set_current_folder(current_sample_dir); |
dialog.set_current_folder(current_sample_dir); |
4795 |
} |
} |
4796 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
4797 |
|
dialog.hide(); |
4798 |
current_sample_dir = dialog.get_current_folder(); |
current_sample_dir = dialog.get_current_folder(); |
4799 |
Glib::ustring error_files; |
Glib::ustring error_files; |
4800 |
std::vector<std::string> filenames = dialog.get_filenames(); |
std::vector<std::string> filenames = dialog.get_filenames(); |
4975 |
} |
} |
4976 |
if (dialog.run() == Gtk::RESPONSE_OK) |
if (dialog.run() == Gtk::RESPONSE_OK) |
4977 |
{ |
{ |
4978 |
|
dialog.hide(); |
4979 |
current_sample_dir = dialog.get_current_folder(); |
current_sample_dir = dialog.get_current_folder(); |
4980 |
Glib::ustring error_files; |
Glib::ustring error_files; |
4981 |
std::string folder = dialog.get_filename(); |
std::string folder = dialog.get_filename(); |
5104 |
if (!file) return; |
if (!file) return; |
5105 |
|
|
5106 |
// collect all samples that are not referenced by any instrument |
// collect all samples that are not referenced by any instrument |
5107 |
std::list<gig::Sample*> lsamples; |
std::list<gig::Sample*> lsamples = unusedSamples(file); |
|
for (int iSample = 0; file->GetSample(iSample); ++iSample) { |
|
|
gig::Sample* sample = file->GetSample(iSample); |
|
|
bool isUsed = false; |
|
|
for (gig::Instrument* instrument = file->GetFirstInstrument(); instrument; |
|
|
instrument = file->GetNextInstrument()) |
|
|
{ |
|
|
for (gig::Region* rgn = instrument->GetFirstRegion(); rgn; |
|
|
rgn = instrument->GetNextRegion()) |
|
|
{ |
|
|
for (int i = 0; i < 256; ++i) { |
|
|
if (!rgn->pDimensionRegions[i]) continue; |
|
|
if (rgn->pDimensionRegions[i]->pSample != sample) continue; |
|
|
isUsed = true; |
|
|
goto endOfRefSearch; |
|
|
} |
|
|
} |
|
|
} |
|
|
endOfRefSearch: |
|
|
if (!isUsed) lsamples.push_back(sample); |
|
|
} |
|
|
|
|
5108 |
if (lsamples.empty()) return; |
if (lsamples.empty()) return; |
5109 |
|
|
5110 |
// notify everybody that we're going to remove these samples |
// notify everybody that we're going to remove these samples |
5180 |
// get selected source instrument |
// get selected source instrument |
5181 |
gig::Instrument* src = NULL; |
gig::Instrument* src = NULL; |
5182 |
{ |
{ |
5183 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewInstruments.get_selection(); |
5184 |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
5185 |
if (!rows.empty()) { |
if (!rows.empty()) { |
5186 |
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); |
// convert index of visual selection (i.e. if filtered) to index of model |
5187 |
|
Gtk::TreeModel::Path path = m_refInstrumentsModelFilter->convert_path_to_child_path(rows[0]); |
5188 |
|
Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(path); |
5189 |
if (it) { |
if (it) { |
5190 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
5191 |
src = row[m_Columns.m_col_instr]; |
src = row[m_InstrumentsModel.m_col_instr]; |
5192 |
} |
} |
5193 |
} |
} |
5194 |
} |
} |
5210 |
gig::Instrument* dst = NULL; |
gig::Instrument* dst = NULL; |
5211 |
{ |
{ |
5212 |
Gtk::TreeModel::Path path; |
Gtk::TreeModel::Path path; |
5213 |
const bool found = m_TreeView.get_path_at_pos(x, y, path); |
const bool found = m_TreeViewInstruments.get_path_at_pos(x, y, path); |
5214 |
if (!found) return; |
if (!found) return; |
5215 |
|
|
5216 |
Gtk::TreeModel::iterator iter = m_refTreeModel->get_iter(path); |
// convert index of visual selection (i.e. if filtered) to index of model |
5217 |
|
path = m_refInstrumentsModelFilter->convert_path_to_child_path(path); |
5218 |
|
if (!path) return; |
5219 |
|
|
5220 |
|
Gtk::TreeModel::iterator iter = m_refInstrumentsTreeModel->get_iter(path); |
5221 |
if (!iter) return; |
if (!iter) return; |
5222 |
Gtk::TreeModel::Row row = *iter; |
Gtk::TreeModel::Row row = *iter; |
5223 |
dst = row[m_Columns.m_col_instr]; |
dst = row[m_InstrumentsModel.m_col_instr]; |
5224 |
} |
} |
5225 |
if (!dst) return; |
if (!dst) return; |
5226 |
|
|
5359 |
file_changed(); |
file_changed(); |
5360 |
} |
} |
5361 |
} |
} |
5362 |
|
// change name in the sample properties window |
5363 |
|
if (sampleProps.get_sample() == sample && sample) { |
5364 |
|
sampleProps.set_sample(sample); |
5365 |
|
} |
5366 |
} |
} |
5367 |
|
|
5368 |
void MainWindow::script_name_changed(const Gtk::TreeModel::Path& path, |
void MainWindow::script_name_changed(const Gtk::TreeModel::Path& path, |
5395 |
if (!iter) return; |
if (!iter) return; |
5396 |
Gtk::TreeModel::Row row = *iter; |
Gtk::TreeModel::Row row = *iter; |
5397 |
gig::Script* script = row[m_ScriptsModel.m_col_script]; |
gig::Script* script = row[m_ScriptsModel.m_col_script]; |
5398 |
if (!script) return; |
editScript(script); |
|
|
|
|
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(); |
|
5399 |
} |
} |
5400 |
|
|
5401 |
void MainWindow::instrument_name_changed(const Gtk::TreeModel::Path& path, |
void MainWindow::instrument_name_changed(const Gtk::TreeModel::Path& path, |
5402 |
const Gtk::TreeModel::iterator& iter) { |
const Gtk::TreeModel::iterator& iter) { |
5403 |
if (!iter) return; |
if (!iter) return; |
5404 |
Gtk::TreeModel::Row row = *iter; |
Gtk::TreeModel::Row row = *iter; |
5405 |
Glib::ustring name = row[m_Columns.m_col_name]; |
Glib::ustring name = row[m_InstrumentsModel.m_col_name]; |
5406 |
|
|
5407 |
#if !USE_GTKMM_BUILDER |
#if !USE_GTKMM_BUILDER |
5408 |
// change name in instrument menu |
// change name in instrument menu |
5420 |
#endif |
#endif |
5421 |
|
|
5422 |
// change name in gig |
// change name in gig |
5423 |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
gig::Instrument* instrument = row[m_InstrumentsModel.m_col_instr]; |
5424 |
gig::String gigname(gig_from_utf8(name)); |
gig::String gigname(gig_from_utf8(name)); |
5425 |
if (instrument && instrument->pInfo->Name != gigname) { |
if (instrument && instrument->pInfo->Name != gigname) { |
5426 |
instrument->pInfo->Name = gigname; |
instrument->pInfo->Name = gigname; |
5448 |
#else |
#else |
5449 |
Gtk::TreeModel::Row row = *iter; |
Gtk::TreeModel::Row row = *iter; |
5450 |
#endif |
#endif |
5451 |
Glib::ustring name = row[m_Columns.m_col_name]; |
Glib::ustring name = row[m_InstrumentsModel.m_col_name]; |
5452 |
name = name.lowercase(); |
name = name.lowercase(); |
5453 |
|
|
5454 |
std::vector<Glib::ustring> tokens = Glib::Regex::split_simple(" ", pattern); |
std::vector<Glib::ustring> tokens = Glib::Regex::split_simple(" ", pattern); |
5466 |
// list view as pre-selection |
// list view as pre-selection |
5467 |
std::set<int> indeces; |
std::set<int> indeces; |
5468 |
{ |
{ |
5469 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewInstruments.get_selection(); |
5470 |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
5471 |
for (int r = 0; r < rows.size(); ++r) { |
for (int r = 0; r < rows.size(); ++r) { |
5472 |
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]); |
// convert index of visual selection (i.e. if filtered) to index of model |
5473 |
|
Gtk::TreeModel::Path path = m_refInstrumentsModelFilter->convert_path_to_child_path(rows[r]); |
5474 |
|
Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(path); |
5475 |
if (it) { |
if (it) { |
5476 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
5477 |
int index = row[m_Columns.m_col_nr]; |
int index = row[m_InstrumentsModel.m_col_nr]; |
5478 |
indeces.insert(index); |
indeces.insert(index); |
5479 |
} |
} |
5480 |
} |
} |
5684 |
#endif |
#endif |
5685 |
|
|
5686 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
5687 |
|
dialog.hide(); |
5688 |
|
#ifdef GLIB_THREADS |
5689 |
printf("on_action_merge_files self=%p\n", |
printf("on_action_merge_files self=%p\n", |
5690 |
static_cast<void*>(Glib::Threads::Thread::self())); |
static_cast<void*>(Glib::Threads::Thread::self())); |
5691 |
|
#else |
5692 |
|
std::cout << "on_action_merge_files self=" << |
5693 |
|
std::this_thread::get_id() << "\n"; |
5694 |
|
#endif |
5695 |
std::vector<std::string> filenames = dialog.get_filenames(); |
std::vector<std::string> filenames = dialog.get_filenames(); |
5696 |
|
|
5697 |
// merge the selected files to the currently open .gig file |
// merge the selected files to the currently open .gig file |