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 |
} |
} |
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 |
} |
} |
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( |
1951 |
|
|
1952 |
updateScriptListOfMenu(); |
updateScriptListOfMenu(); |
1953 |
|
|
1954 |
m_RegionChooser.set_instrument(get_instrument()); |
gig::Instrument* instr = get_instrument(); |
1955 |
|
|
1956 |
|
m_RegionChooser.set_instrument(instr); |
1957 |
|
dimreg_edit.scriptVars.setInstrument(instr, true/*force update*/); |
1958 |
|
|
1959 |
if (Settings::singleton()->syncSamplerInstrumentSelection) { |
if (Settings::singleton()->syncSamplerInstrumentSelection) { |
1960 |
switch_sampler_instrument_signal.emit(get_instrument()); |
switch_sampler_instrument_signal.emit(get_instrument()); |
1963 |
|
|
1964 |
|
|
1965 |
LoaderSaverBase::LoaderSaverBase(const Glib::ustring filename, gig::File* gig) : |
LoaderSaverBase::LoaderSaverBase(const Glib::ustring filename, gig::File* gig) : |
1966 |
filename(filename), gig(gig), thread(0), progress(0.f) |
filename(filename), gig(gig), |
1967 |
|
#ifdef GLIB_THREADS |
1968 |
|
thread(0), |
1969 |
|
#endif |
1970 |
|
progress(0.f) |
1971 |
{ |
{ |
1972 |
} |
} |
1973 |
|
|
1980 |
void LoaderSaverBase::progress_callback(float fraction) |
void LoaderSaverBase::progress_callback(float fraction) |
1981 |
{ |
{ |
1982 |
{ |
{ |
1983 |
|
#ifdef GLIB_THREADS |
1984 |
Glib::Threads::Mutex::Lock lock(progressMutex); |
Glib::Threads::Mutex::Lock lock(progressMutex); |
1985 |
|
#else |
1986 |
|
std::lock_guard<std::mutex> lock(progressMutex); |
1987 |
|
#endif |
1988 |
progress = fraction; |
progress = fraction; |
1989 |
} |
} |
1990 |
progress_dispatcher(); |
progress_dispatcher(); |
1996 |
#endif |
#endif |
1997 |
void LoaderSaverBase::thread_function() |
void LoaderSaverBase::thread_function() |
1998 |
{ |
{ |
1999 |
|
#ifdef GLIB_THREADS |
2000 |
printf("thread_function self=%p\n", |
printf("thread_function self=%p\n", |
2001 |
static_cast<void*>(Glib::Threads::Thread::self())); |
static_cast<void*>(Glib::Threads::Thread::self())); |
2002 |
|
#else |
2003 |
|
std::cout << "thread_function self=" << std::this_thread::get_id() << "\n"; |
2004 |
|
#endif |
2005 |
printf("Start %s\n", filename.c_str()); |
printf("Start %s\n", filename.c_str()); |
2006 |
try { |
try { |
2007 |
gig::progress_t progress; |
gig::progress_t progress; |
2022 |
|
|
2023 |
void LoaderSaverBase::launch() |
void LoaderSaverBase::launch() |
2024 |
{ |
{ |
2025 |
|
#ifdef GLIB_THREADS |
2026 |
#ifdef OLD_THREADS |
#ifdef OLD_THREADS |
2027 |
thread = Glib::Thread::create(sigc::mem_fun(*this, &LoaderSaverBase::thread_function), true); |
thread = Glib::Thread::create(sigc::mem_fun(*this, &LoaderSaverBase::thread_function), true); |
2028 |
#else |
#else |
2029 |
thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &LoaderSaverBase::thread_function)); |
thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &LoaderSaverBase::thread_function)); |
2030 |
#endif |
#endif |
2031 |
printf("launch thread=%p\n", static_cast<void*>(thread)); |
printf("launch thread=%p\n", static_cast<void*>(thread)); |
2032 |
|
#else |
2033 |
|
thread = std::thread([this](){ thread_function(); }); |
2034 |
|
std::cout << "launch thread=" << thread.get_id() << "\n"; |
2035 |
|
#endif |
2036 |
} |
} |
2037 |
|
|
2038 |
float LoaderSaverBase::get_progress() |
float LoaderSaverBase::get_progress() |
2039 |
{ |
{ |
2040 |
|
#ifdef GLIB_THREADS |
2041 |
Glib::Threads::Mutex::Lock lock(progressMutex); |
Glib::Threads::Mutex::Lock lock(progressMutex); |
2042 |
|
#else |
2043 |
|
std::lock_guard<std::mutex> lock(progressMutex); |
2044 |
|
#endif |
2045 |
return progress; |
return progress; |
2046 |
} |
} |
2047 |
|
|
2061 |
} |
} |
2062 |
|
|
2063 |
void LoaderSaverBase::join() { |
void LoaderSaverBase::join() { |
2064 |
|
#ifdef GLIB_THREADS |
2065 |
thread->join(); |
thread->join(); |
2066 |
|
#else |
2067 |
|
thread.join(); |
2068 |
|
#endif |
2069 |
} |
} |
2070 |
|
|
2071 |
|
|
2280 |
dialog.set_current_folder(current_gig_dir); |
dialog.set_current_folder(current_gig_dir); |
2281 |
} |
} |
2282 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
2283 |
|
dialog.hide(); |
2284 |
std::string filename = dialog.get_filename(); |
std::string filename = dialog.get_filename(); |
2285 |
printf("filename=%s\n", filename.c_str()); |
printf("filename=%s\n", filename.c_str()); |
2286 |
|
#ifdef GLIB_THREADS |
2287 |
printf("on_action_file_open self=%p\n", |
printf("on_action_file_open self=%p\n", |
2288 |
static_cast<void*>(Glib::Threads::Thread::self())); |
static_cast<void*>(Glib::Threads::Thread::self())); |
2289 |
|
#else |
2290 |
|
std::cout << "on_action_file_open self=" << |
2291 |
|
std::this_thread::get_id() << "\n"; |
2292 |
|
#endif |
2293 |
load_file(filename.c_str()); |
load_file(filename.c_str()); |
2294 |
current_gig_dir = Glib::path_get_dirname(filename); |
current_gig_dir = Glib::path_get_dirname(filename); |
2295 |
} |
} |
2364 |
{ |
{ |
2365 |
loader->join(); |
loader->join(); |
2366 |
printf("Loader finished!\n"); |
printf("Loader finished!\n"); |
2367 |
|
#ifdef GLIB_THREADS |
2368 |
printf("on_loader_finished self=%p\n", |
printf("on_loader_finished self=%p\n", |
2369 |
static_cast<void*>(Glib::Threads::Thread::self())); |
static_cast<void*>(Glib::Threads::Thread::self())); |
2370 |
|
#else |
2371 |
|
std::cout << "on_loader_finished self=" << |
2372 |
|
std::this_thread::get_id() << "\n"; |
2373 |
|
#endif |
2374 |
load_gig(loader->gig, loader->filename.c_str()); |
load_gig(loader->gig, loader->filename.c_str()); |
2375 |
progress_dialog->hide(); |
progress_dialog->hide(); |
2376 |
} |
} |
2549 |
#endif |
#endif |
2550 |
|
|
2551 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
2552 |
|
dialog.hide(); |
2553 |
std::string filename = dialog.get_filename(); |
std::string filename = dialog.get_filename(); |
2554 |
if (!Glib::str_has_suffix(filename, ".gig")) { |
if (!Glib::str_has_suffix(filename, ".gig")) { |
2555 |
filename += ".gig"; |
filename += ".gig"; |
2678 |
|
|
2679 |
void MainWindow::on_action_file_properties() |
void MainWindow::on_action_file_properties() |
2680 |
{ |
{ |
2681 |
propDialog.show(); |
fileProps.show(); |
2682 |
propDialog.deiconify(); |
fileProps.deiconify(); |
2683 |
} |
} |
2684 |
|
|
2685 |
void MainWindow::on_action_warn_user_on_extensions() { |
void MainWindow::on_action_warn_user_on_extensions() { |
2741 |
"backup your Gigasampler/GigaStudio files before editing them with " |
"backup your Gigasampler/GigaStudio files before editing them with " |
2742 |
"this application.\n" |
"this application.\n" |
2743 |
"\n" |
"\n" |
2744 |
"Please report bugs to: http://bugs.linuxsampler.org" |
"Please report bugs to: https://bugs.linuxsampler.org" |
2745 |
); |
); |
2746 |
dialog.set_comments(sComment.c_str()); |
dialog.set_comments(sComment.c_str()); |
2747 |
dialog.set_website("http://www.linuxsampler.org"); |
dialog.set_website("https://www.linuxsampler.org"); |
2748 |
dialog.set_website_label("http://www.linuxsampler.org"); |
dialog.set_website_label("https://www.linuxsampler.org"); |
2749 |
dialog.set_position(Gtk::WIN_POS_CENTER); |
dialog.set_position(Gtk::WIN_POS_CENTER); |
2750 |
dialog.run(); |
dialog.run(); |
2751 |
} |
} |
2752 |
|
|
2753 |
PropDialog::PropDialog() |
FilePropDialog::FilePropDialog() |
2754 |
: eFileFormat(_("File Format")), |
: eFileFormat(_("File Format")), |
2755 |
eName(_("Name")), |
eName(_("Name")), |
2756 |
eCreationDate(_("Creation date")), |
eCreationDate(_("Creation date")), |
2784 |
set_title(_("File Properties")); |
set_title(_("File Properties")); |
2785 |
eName.set_width_chars(50); |
eName.set_width_chars(50); |
2786 |
|
|
2787 |
connect(eFileFormat, &PropDialog::set_FileFormat); |
connect(eFileFormat, &FilePropDialog::set_FileFormat); |
2788 |
connect(eName, &DLS::Info::Name); |
connect(eName, &DLS::Info::Name); |
2789 |
connect(eCreationDate, &DLS::Info::CreationDate); |
connect(eCreationDate, &DLS::Info::CreationDate); |
2790 |
connect(eComments, &DLS::Info::Comments); |
connect(eComments, &DLS::Info::Comments); |
2845 |
quitButton.set_can_default(); |
quitButton.set_can_default(); |
2846 |
quitButton.grab_focus(); |
quitButton.grab_focus(); |
2847 |
quitButton.signal_clicked().connect( |
quitButton.signal_clicked().connect( |
2848 |
sigc::mem_fun(*this, &PropDialog::hide)); |
sigc::mem_fun(*this, &FilePropDialog::hide)); |
2849 |
|
|
2850 |
quitButton.show(); |
quitButton.show(); |
2851 |
vbox.show(); |
vbox.show(); |
2854 |
#endif |
#endif |
2855 |
} |
} |
2856 |
|
|
2857 |
void PropDialog::set_file(gig::File* file) |
void FilePropDialog::set_file(gig::File* file) |
2858 |
{ |
{ |
2859 |
m_file = file; |
m_file = file; |
2860 |
update(file->pInfo); |
update(file->pInfo); |
2880 |
update_model--; |
update_model--; |
2881 |
} |
} |
2882 |
|
|
2883 |
void PropDialog::set_FileFormat(int value) |
void FilePropDialog::set_FileFormat(int value) |
2884 |
{ |
{ |
2885 |
m_file->pVersion->major = value; |
m_file->pVersion->major = value; |
2886 |
} |
} |
2924 |
eIsDrum(_("Is drum")), |
eIsDrum(_("Is drum")), |
2925 |
eMIDIBank(_("MIDI bank"), 0, 16383), |
eMIDIBank(_("MIDI bank"), 0, 16383), |
2926 |
eMIDIProgram(_("MIDI program")), |
eMIDIProgram(_("MIDI program")), |
2927 |
eAttenuation(_("Attenuation"), 0, 96, 0, 1), |
eAttenuation(_("Attenuation (dB)"), -96, +96, 0, 1), |
|
eGainPlus6(_("Gain +6dB"), eAttenuation, -6), |
|
2928 |
eEffectSend(_("Effect send"), 0, 65535), |
eEffectSend(_("Effect send"), 0, 65535), |
2929 |
eFineTune(_("Fine tune"), -8400, 8400), |
eFineTune(_("Fine tune"), -8400, 8400), |
2930 |
ePitchbendRange(_("Pitchbend range"), 0, 48), |
ePitchbendRange(_("Pitchbend range (halftones)"), 0, 48), |
2931 |
ePianoReleaseMode(_("Piano release mode")), |
ePianoReleaseMode(_("Piano release mode")), |
2932 |
eDimensionKeyRangeLow(_("Keyswitching range low")), |
eDimensionKeyRangeLow(_("Keyswitching range low")), |
2933 |
eDimensionKeyRangeHigh(_("Keyswitching range high")) |
eDimensionKeyRangeHigh(_("Keyswitching range high")), |
2934 |
|
table2(2,1), |
2935 |
|
eName2(_("Name")), |
2936 |
|
eCreationDate(_("Creation date")), |
2937 |
|
eComments(_("Comments")), |
2938 |
|
eProduct(_("Product")), |
2939 |
|
eCopyright(_("Copyright")), |
2940 |
|
eArtists(_("Artists")), |
2941 |
|
eGenre(_("Genre")), |
2942 |
|
eKeywords(_("Keywords")), |
2943 |
|
eEngineer(_("Engineer")), |
2944 |
|
eTechnician(_("Technician")), |
2945 |
|
eSoftware(_("Software")), |
2946 |
|
eMedium(_("Medium")), |
2947 |
|
eSource(_("Source")), |
2948 |
|
eSourceForm(_("Source form")), |
2949 |
|
eCommissioned(_("Commissioned")), |
2950 |
|
eSubject(_("Subject")) |
2951 |
{ |
{ |
2952 |
if (!Settings::singleton()->autoRestoreWindowDimension) { |
if (!Settings::singleton()->autoRestoreWindowDimension) { |
2953 |
//set_default_size(470, 390); |
//set_default_size(470, 390); |
2956 |
|
|
2957 |
set_title(_("Instrument Properties")); |
set_title(_("Instrument Properties")); |
2958 |
|
|
2959 |
|
tabs.append_page(vbox[1], _("Settings")); |
2960 |
|
tabs.append_page(vbox[2], _("Info")); |
2961 |
|
|
2962 |
eDimensionKeyRangeLow.set_tip( |
eDimensionKeyRangeLow.set_tip( |
2963 |
_("start of the keyboard area which should switch the " |
_("start of the keyboard area which should switch the " |
2964 |
"\"keyswitching\" dimension") |
"\"keyswitching\" dimension") |
2973 |
connect(eMIDIBank, &InstrumentProps::set_MIDIBank); |
connect(eMIDIBank, &InstrumentProps::set_MIDIBank); |
2974 |
connect(eMIDIProgram, &InstrumentProps::set_MIDIProgram); |
connect(eMIDIProgram, &InstrumentProps::set_MIDIProgram); |
2975 |
connect(eAttenuation, &gig::Instrument::Attenuation); |
connect(eAttenuation, &gig::Instrument::Attenuation); |
|
connect(eGainPlus6, &gig::Instrument::Attenuation); |
|
2976 |
connect(eEffectSend, &gig::Instrument::EffectSend); |
connect(eEffectSend, &gig::Instrument::EffectSend); |
2977 |
connect(eFineTune, &gig::Instrument::FineTune); |
connect(eFineTune, &gig::Instrument::FineTune); |
2978 |
connect(ePitchbendRange, &gig::Instrument::PitchbendRange); |
connect(ePitchbendRange, &gig::Instrument::PitchbendRange); |
2982 |
|
|
2983 |
eName.signal_value_changed().connect(sig_name_changed.make_slot()); |
eName.signal_value_changed().connect(sig_name_changed.make_slot()); |
2984 |
|
|
2985 |
|
connect(eName2, &InstrumentProps::set_Name); |
2986 |
|
connectLambda(eCreationDate, [this](gig::String s) { |
2987 |
|
m->pInfo->CreationDate = s; |
2988 |
|
}); |
2989 |
|
connectLambda(eComments, [this](gig::String s) { |
2990 |
|
m->pInfo->Comments = s; |
2991 |
|
}); |
2992 |
|
connectLambda(eProduct, [this](gig::String s) { |
2993 |
|
m->pInfo->Product = s; |
2994 |
|
}); |
2995 |
|
connectLambda(eCopyright, [this](gig::String s) { |
2996 |
|
m->pInfo->Copyright = s; |
2997 |
|
}); |
2998 |
|
connectLambda(eArtists, [this](gig::String s) { |
2999 |
|
m->pInfo->Artists = s; |
3000 |
|
}); |
3001 |
|
connectLambda(eGenre, [this](gig::String s) { |
3002 |
|
m->pInfo->Genre = s; |
3003 |
|
}); |
3004 |
|
connectLambda(eKeywords, [this](gig::String s) { |
3005 |
|
m->pInfo->Keywords = s; |
3006 |
|
}); |
3007 |
|
connectLambda(eEngineer, [this](gig::String s) { |
3008 |
|
m->pInfo->Engineer = s; |
3009 |
|
}); |
3010 |
|
connectLambda(eTechnician, [this](gig::String s) { |
3011 |
|
m->pInfo->Technician = s; |
3012 |
|
}); |
3013 |
|
connectLambda(eSoftware, [this](gig::String s) { |
3014 |
|
m->pInfo->Software = s; |
3015 |
|
}); |
3016 |
|
connectLambda(eMedium, [this](gig::String s) { |
3017 |
|
m->pInfo->Medium = s; |
3018 |
|
}); |
3019 |
|
connectLambda(eSource, [this](gig::String s) { |
3020 |
|
m->pInfo->Source = s; |
3021 |
|
}); |
3022 |
|
connectLambda(eSourceForm, [this](gig::String s) { |
3023 |
|
m->pInfo->SourceForm = s; |
3024 |
|
}); |
3025 |
|
connectLambda(eCommissioned, [this](gig::String s) { |
3026 |
|
m->pInfo->Commissioned = s; |
3027 |
|
}); |
3028 |
|
connectLambda(eSubject, [this](gig::String s) { |
3029 |
|
m->pInfo->Subject = s; |
3030 |
|
}); |
3031 |
|
|
3032 |
|
// tab 1 |
3033 |
#if USE_GTKMM_GRID |
#if USE_GTKMM_GRID |
3034 |
table.set_column_spacing(5); |
table.set_column_spacing(5); |
3035 |
#else |
#else |
3036 |
table.set_col_spacings(5); |
table.set_col_spacings(5); |
3037 |
#endif |
#endif |
|
|
|
3038 |
table.add(eName); |
table.add(eName); |
3039 |
table.add(eIsDrum); |
table.add(eIsDrum); |
3040 |
table.add(eMIDIBank); |
table.add(eMIDIBank); |
3041 |
table.add(eMIDIProgram); |
table.add(eMIDIProgram); |
3042 |
table.add(eAttenuation); |
table.add(eAttenuation); |
|
table.add(eGainPlus6); |
|
3043 |
table.add(eEffectSend); |
table.add(eEffectSend); |
3044 |
table.add(eFineTune); |
table.add(eFineTune); |
3045 |
table.add(ePitchbendRange); |
table.add(ePitchbendRange); |
3047 |
table.add(eDimensionKeyRangeLow); |
table.add(eDimensionKeyRangeLow); |
3048 |
table.add(eDimensionKeyRangeHigh); |
table.add(eDimensionKeyRangeHigh); |
3049 |
|
|
3050 |
add(vbox); |
// tab 2 |
3051 |
|
#if USE_GTKMM_GRID |
3052 |
|
table2.set_column_spacing(5); |
3053 |
|
#else |
3054 |
|
table2.set_col_spacings(5); |
3055 |
|
#endif |
3056 |
|
table2.add(eName2); |
3057 |
|
table2.add(eCreationDate); |
3058 |
|
table2.add(eComments); |
3059 |
|
table2.add(eProduct); |
3060 |
|
table2.add(eCopyright); |
3061 |
|
table2.add(eArtists); |
3062 |
|
table2.add(eGenre); |
3063 |
|
table2.add(eKeywords); |
3064 |
|
table2.add(eEngineer); |
3065 |
|
table2.add(eTechnician); |
3066 |
|
table2.add(eSoftware); |
3067 |
|
table2.add(eMedium); |
3068 |
|
table2.add(eSource); |
3069 |
|
table2.add(eSourceForm); |
3070 |
|
table2.add(eCommissioned); |
3071 |
|
table2.add(eSubject); |
3072 |
|
|
3073 |
|
add(vbox[0]); |
3074 |
#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) |
3075 |
table.set_margin(5); |
table.set_margin(5); |
3076 |
#else |
#else |
3077 |
table.set_border_width(5); |
table.set_border_width(5); |
3078 |
#endif |
#endif |
3079 |
vbox.pack_start(table); |
vbox[1].pack_start(table); |
3080 |
|
vbox[2].pack_start(table2); |
3081 |
table.show(); |
table.show(); |
3082 |
vbox.pack_start(buttonBox, Gtk::PACK_SHRINK); |
table2.show(); |
3083 |
|
vbox[0].pack_start(tabs); |
3084 |
|
vbox[0].pack_start(buttonBox, Gtk::PACK_SHRINK); |
3085 |
buttonBox.set_layout(Gtk::BUTTONBOX_END); |
buttonBox.set_layout(Gtk::BUTTONBOX_END); |
3086 |
#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) |
3087 |
buttonBox.set_margin(5); |
buttonBox.set_margin(5); |
3097 |
sigc::mem_fun(*this, &InstrumentProps::hide)); |
sigc::mem_fun(*this, &InstrumentProps::hide)); |
3098 |
|
|
3099 |
quitButton.show(); |
quitButton.show(); |
3100 |
vbox.show(); |
vbox[0].show(); |
3101 |
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
3102 |
show_all_children(); |
show_all_children(); |
3103 |
#endif |
#endif |
3108 |
update(instrument); |
update(instrument); |
3109 |
|
|
3110 |
update_model++; |
update_model++; |
3111 |
|
|
3112 |
|
// tab 1 |
3113 |
eName.set_value(instrument->pInfo->Name); |
eName.set_value(instrument->pInfo->Name); |
3114 |
eIsDrum.set_value(instrument->IsDrum); |
eIsDrum.set_value(instrument->IsDrum); |
3115 |
eMIDIBank.set_value(instrument->MIDIBank); |
eMIDIBank.set_value(instrument->MIDIBank); |
3116 |
eMIDIProgram.set_value(instrument->MIDIProgram); |
eMIDIProgram.set_value(instrument->MIDIProgram); |
3117 |
|
// tab 2 |
3118 |
|
eName2.set_value(instrument->pInfo->Name); |
3119 |
|
eCreationDate.set_value(instrument->pInfo->CreationDate); |
3120 |
|
eComments.set_value(instrument->pInfo->Comments); |
3121 |
|
eProduct.set_value(instrument->pInfo->Product); |
3122 |
|
eCopyright.set_value(instrument->pInfo->Copyright); |
3123 |
|
eArtists.set_value(instrument->pInfo->Artists); |
3124 |
|
eGenre.set_value(instrument->pInfo->Genre); |
3125 |
|
eKeywords.set_value(instrument->pInfo->Keywords); |
3126 |
|
eEngineer.set_value(instrument->pInfo->Engineer); |
3127 |
|
eTechnician.set_value(instrument->pInfo->Technician); |
3128 |
|
eSoftware.set_value(instrument->pInfo->Software); |
3129 |
|
eMedium.set_value(instrument->pInfo->Medium); |
3130 |
|
eSource.set_value(instrument->pInfo->Source); |
3131 |
|
eSourceForm.set_value(instrument->pInfo->SourceForm); |
3132 |
|
eCommissioned.set_value(instrument->pInfo->Commissioned); |
3133 |
|
eSubject.set_value(instrument->pInfo->Subject); |
3134 |
|
|
3135 |
|
update_model--; |
3136 |
|
} |
3137 |
|
|
3138 |
|
|
3139 |
|
SampleProps::SampleProps() : |
3140 |
|
#if HAS_GTKMM_STOCK |
3141 |
|
quitButton(Gtk::Stock::CLOSE), |
3142 |
|
#else |
3143 |
|
quitButton(_("_Close")), |
3144 |
|
#endif |
3145 |
|
table(2,1), |
3146 |
|
eName(_("Name")), |
3147 |
|
eUnityNote(_("Unity Note")), |
3148 |
|
eSampleGroup(_("Sample Group")), |
3149 |
|
eSampleFormatInfo(_("Sample Format")), |
3150 |
|
eSampleID("Sample ID"), |
3151 |
|
eChecksum("Wave Data CRC-32"), |
3152 |
|
eLoopsCount(_("Loops"), 0, 1), // we might support more than 1 loop in future |
3153 |
|
eLoopStart(_("Loop start position"), 0, 9999999), |
3154 |
|
eLoopLength(_("Loop size"), 0, 9999999), |
3155 |
|
eLoopType(_("Loop type")), |
3156 |
|
eLoopPlayCount(_("Playback count")), |
3157 |
|
table2(2,1), |
3158 |
|
eName2(_("Name")), |
3159 |
|
eCreationDate(_("Creation date")), |
3160 |
|
eComments(_("Comments")), |
3161 |
|
eProduct(_("Product")), |
3162 |
|
eCopyright(_("Copyright")), |
3163 |
|
eArtists(_("Artists")), |
3164 |
|
eGenre(_("Genre")), |
3165 |
|
eKeywords(_("Keywords")), |
3166 |
|
eEngineer(_("Engineer")), |
3167 |
|
eTechnician(_("Technician")), |
3168 |
|
eSoftware(_("Software")), |
3169 |
|
eMedium(_("Medium")), |
3170 |
|
eSource(_("Source")), |
3171 |
|
eSourceForm(_("Source form")), |
3172 |
|
eCommissioned(_("Commissioned")), |
3173 |
|
eSubject(_("Subject")) |
3174 |
|
{ |
3175 |
|
if (!Settings::singleton()->autoRestoreWindowDimension) { |
3176 |
|
//set_default_size(470, 390); |
3177 |
|
set_position(Gtk::WIN_POS_MOUSE); |
3178 |
|
} |
3179 |
|
|
3180 |
|
set_title(_("Sample Properties")); |
3181 |
|
|
3182 |
|
tabs.append_page(vbox[1], _("Settings")); |
3183 |
|
tabs.append_page(vbox[2], _("Info")); |
3184 |
|
|
3185 |
|
connect(eName, &SampleProps::set_Name); |
3186 |
|
connect(eUnityNote, &gig::Sample::MIDIUnityNote); |
3187 |
|
connect(eLoopsCount, &gig::Sample::Loops); |
3188 |
|
connectLambda(eLoopStart, [this](uint32_t start){ |
3189 |
|
m->LoopStart = start; |
3190 |
|
m->LoopEnd = start + m->LoopSize; |
3191 |
|
}); |
3192 |
|
connectLambda(eLoopLength, [this](uint32_t length){ |
3193 |
|
m->LoopSize = length; |
3194 |
|
m->LoopEnd = m->LoopStart + length; |
3195 |
|
}); |
3196 |
|
{ |
3197 |
|
const char* choices[] = { _("normal"), _("bidirectional"), _("backward"), 0 }; |
3198 |
|
static const gig::loop_type_t values[] = { |
3199 |
|
gig::loop_type_normal, |
3200 |
|
gig::loop_type_bidirectional, |
3201 |
|
gig::loop_type_backward |
3202 |
|
}; |
3203 |
|
eLoopType.set_choices(choices, values); |
3204 |
|
} |
3205 |
|
connect(eLoopType, &gig::Sample::LoopType); |
3206 |
|
connect(eLoopPlayCount, &gig::Sample::LoopPlayCount); |
3207 |
|
|
3208 |
|
eName.signal_value_changed().connect(sig_name_changed.make_slot()); |
3209 |
|
|
3210 |
|
connect(eName2, &SampleProps::set_Name); |
3211 |
|
connectLambda(eCreationDate, [this](gig::String s) { |
3212 |
|
m->pInfo->CreationDate = s; |
3213 |
|
}); |
3214 |
|
connectLambda(eComments, [this](gig::String s) { |
3215 |
|
m->pInfo->Comments = s; |
3216 |
|
}); |
3217 |
|
connectLambda(eProduct, [this](gig::String s) { |
3218 |
|
m->pInfo->Product = s; |
3219 |
|
}); |
3220 |
|
connectLambda(eCopyright, [this](gig::String s) { |
3221 |
|
m->pInfo->Copyright = s; |
3222 |
|
}); |
3223 |
|
connectLambda(eArtists, [this](gig::String s) { |
3224 |
|
m->pInfo->Artists = s; |
3225 |
|
}); |
3226 |
|
connectLambda(eGenre, [this](gig::String s) { |
3227 |
|
m->pInfo->Genre = s; |
3228 |
|
}); |
3229 |
|
connectLambda(eKeywords, [this](gig::String s) { |
3230 |
|
m->pInfo->Keywords = s; |
3231 |
|
}); |
3232 |
|
connectLambda(eEngineer, [this](gig::String s) { |
3233 |
|
m->pInfo->Engineer = s; |
3234 |
|
}); |
3235 |
|
connectLambda(eTechnician, [this](gig::String s) { |
3236 |
|
m->pInfo->Technician = s; |
3237 |
|
}); |
3238 |
|
connectLambda(eSoftware, [this](gig::String s) { |
3239 |
|
m->pInfo->Software = s; |
3240 |
|
}); |
3241 |
|
connectLambda(eMedium, [this](gig::String s) { |
3242 |
|
m->pInfo->Medium = s; |
3243 |
|
}); |
3244 |
|
connectLambda(eSource, [this](gig::String s) { |
3245 |
|
m->pInfo->Source = s; |
3246 |
|
}); |
3247 |
|
connectLambda(eSourceForm, [this](gig::String s) { |
3248 |
|
m->pInfo->SourceForm = s; |
3249 |
|
}); |
3250 |
|
connectLambda(eCommissioned, [this](gig::String s) { |
3251 |
|
m->pInfo->Commissioned = s; |
3252 |
|
}); |
3253 |
|
connectLambda(eSubject, [this](gig::String s) { |
3254 |
|
m->pInfo->Subject = s; |
3255 |
|
}); |
3256 |
|
|
3257 |
|
// tab 1 |
3258 |
|
#if USE_GTKMM_GRID |
3259 |
|
table.set_column_spacing(5); |
3260 |
|
#else |
3261 |
|
table.set_col_spacings(5); |
3262 |
|
#endif |
3263 |
|
table.add(eName); |
3264 |
|
table.add(eUnityNote); |
3265 |
|
table.add(eSampleGroup); |
3266 |
|
table.add(eSampleFormatInfo); |
3267 |
|
table.add(eSampleID); |
3268 |
|
table.add(eChecksum); |
3269 |
|
table.add(eLoopsCount); |
3270 |
|
table.add(eLoopStart); |
3271 |
|
table.add(eLoopLength); |
3272 |
|
table.add(eLoopType); |
3273 |
|
table.add(eLoopPlayCount); |
3274 |
|
|
3275 |
|
// tab 2 |
3276 |
|
#if USE_GTKMM_GRID |
3277 |
|
table2.set_column_spacing(5); |
3278 |
|
#else |
3279 |
|
table2.set_col_spacings(5); |
3280 |
|
#endif |
3281 |
|
table2.add(eName2); |
3282 |
|
table2.add(eCreationDate); |
3283 |
|
table2.add(eComments); |
3284 |
|
table2.add(eProduct); |
3285 |
|
table2.add(eCopyright); |
3286 |
|
table2.add(eArtists); |
3287 |
|
table2.add(eGenre); |
3288 |
|
table2.add(eKeywords); |
3289 |
|
table2.add(eEngineer); |
3290 |
|
table2.add(eTechnician); |
3291 |
|
table2.add(eSoftware); |
3292 |
|
table2.add(eMedium); |
3293 |
|
table2.add(eSource); |
3294 |
|
table2.add(eSourceForm); |
3295 |
|
table2.add(eCommissioned); |
3296 |
|
table2.add(eSubject); |
3297 |
|
|
3298 |
|
add(vbox[0]); |
3299 |
|
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) |
3300 |
|
table.set_margin(5); |
3301 |
|
#else |
3302 |
|
table.set_border_width(5); |
3303 |
|
#endif |
3304 |
|
vbox[1].pack_start(table); |
3305 |
|
vbox[2].pack_start(table2); |
3306 |
|
table.show(); |
3307 |
|
table2.show(); |
3308 |
|
vbox[0].pack_start(tabs); |
3309 |
|
vbox[0].pack_start(buttonBox, Gtk::PACK_SHRINK); |
3310 |
|
buttonBox.set_layout(Gtk::BUTTONBOX_END); |
3311 |
|
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) |
3312 |
|
buttonBox.set_margin(5); |
3313 |
|
#else |
3314 |
|
buttonBox.set_border_width(5); |
3315 |
|
#endif |
3316 |
|
buttonBox.show(); |
3317 |
|
buttonBox.pack_start(quitButton); |
3318 |
|
quitButton.set_can_default(); |
3319 |
|
quitButton.grab_focus(); |
3320 |
|
|
3321 |
|
quitButton.signal_clicked().connect( |
3322 |
|
sigc::mem_fun(*this, &SampleProps::hide)); |
3323 |
|
|
3324 |
|
quitButton.show(); |
3325 |
|
vbox[0].show(); |
3326 |
|
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
3327 |
|
show_all_children(); |
3328 |
|
#endif |
3329 |
|
} |
3330 |
|
|
3331 |
|
void SampleProps::set_sample(gig::Sample* sample) |
3332 |
|
{ |
3333 |
|
update(sample); |
3334 |
|
|
3335 |
|
update_model++; |
3336 |
|
|
3337 |
|
// tab 1 |
3338 |
|
eName.set_value(sample->pInfo->Name); |
3339 |
|
eUnityNote.set_value(sample->MIDIUnityNote); |
3340 |
|
// show sample group name |
3341 |
|
{ |
3342 |
|
Glib::ustring s = "---"; |
3343 |
|
if (sample && sample->GetGroup()) |
3344 |
|
s = sample->GetGroup()->Name; |
3345 |
|
eSampleGroup.text.set_text(s); |
3346 |
|
} |
3347 |
|
// assemble sample format info string |
3348 |
|
{ |
3349 |
|
Glib::ustring s; |
3350 |
|
if (sample) { |
3351 |
|
switch (sample->Channels) { |
3352 |
|
case 1: s = _("Mono"); break; |
3353 |
|
case 2: s = _("Stereo"); break; |
3354 |
|
default: |
3355 |
|
s = ToString(sample->Channels) + _(" audio channels"); |
3356 |
|
break; |
3357 |
|
} |
3358 |
|
s += " " + ToString(sample->BitDepth) + " Bits"; |
3359 |
|
s += " " + ToString(sample->SamplesPerSecond/1000) + "." |
3360 |
|
+ ToString((sample->SamplesPerSecond%1000)/100) + " kHz"; |
3361 |
|
} else { |
3362 |
|
s = _("No sample assigned to this dimension region."); |
3363 |
|
} |
3364 |
|
eSampleFormatInfo.text.set_text(s); |
3365 |
|
} |
3366 |
|
// generate sample's memory address pointer string |
3367 |
|
{ |
3368 |
|
Glib::ustring s; |
3369 |
|
if (sample) { |
3370 |
|
char buf[64] = {}; |
3371 |
|
snprintf(buf, sizeof(buf), "%p", sample); |
3372 |
|
s = buf; |
3373 |
|
} else { |
3374 |
|
s = "---"; |
3375 |
|
} |
3376 |
|
eSampleID.text.set_text(s); |
3377 |
|
} |
3378 |
|
// generate raw wave form data CRC-32 checksum string |
3379 |
|
{ |
3380 |
|
Glib::ustring s = "---"; |
3381 |
|
if (sample) { |
3382 |
|
char buf[64] = {}; |
3383 |
|
snprintf(buf, sizeof(buf), "%x", sample->GetWaveDataCRC32Checksum()); |
3384 |
|
s = buf; |
3385 |
|
} |
3386 |
|
eChecksum.text.set_text(s); |
3387 |
|
} |
3388 |
|
eLoopsCount.set_value(sample->Loops); |
3389 |
|
eLoopStart.set_value(sample->LoopStart); |
3390 |
|
eLoopLength.set_value(sample->LoopSize); |
3391 |
|
eLoopType.set_value(sample->LoopType); |
3392 |
|
eLoopPlayCount.set_value(sample->LoopPlayCount); |
3393 |
|
// tab 2 |
3394 |
|
eName2.set_value(sample->pInfo->Name); |
3395 |
|
eCreationDate.set_value(sample->pInfo->CreationDate); |
3396 |
|
eComments.set_value(sample->pInfo->Comments); |
3397 |
|
eProduct.set_value(sample->pInfo->Product); |
3398 |
|
eCopyright.set_value(sample->pInfo->Copyright); |
3399 |
|
eArtists.set_value(sample->pInfo->Artists); |
3400 |
|
eGenre.set_value(sample->pInfo->Genre); |
3401 |
|
eKeywords.set_value(sample->pInfo->Keywords); |
3402 |
|
eEngineer.set_value(sample->pInfo->Engineer); |
3403 |
|
eTechnician.set_value(sample->pInfo->Technician); |
3404 |
|
eSoftware.set_value(sample->pInfo->Software); |
3405 |
|
eMedium.set_value(sample->pInfo->Medium); |
3406 |
|
eSource.set_value(sample->pInfo->Source); |
3407 |
|
eSourceForm.set_value(sample->pInfo->SourceForm); |
3408 |
|
eCommissioned.set_value(sample->pInfo->Commissioned); |
3409 |
|
eSubject.set_value(sample->pInfo->Subject); |
3410 |
|
|
3411 |
|
update_model--; |
3412 |
|
} |
3413 |
|
|
3414 |
|
void SampleProps::set_Name(const gig::String& name) |
3415 |
|
{ |
3416 |
|
m->pInfo->Name = name; |
3417 |
|
} |
3418 |
|
|
3419 |
|
void SampleProps::update_name() |
3420 |
|
{ |
3421 |
|
update_model++; |
3422 |
|
eName.set_value(m->pInfo->Name); |
3423 |
update_model--; |
update_model--; |
3424 |
} |
} |
3425 |
|
|
3515 |
file_has_name = filename; |
file_has_name = filename; |
3516 |
file_is_changed = false; |
file_is_changed = false; |
3517 |
|
|
3518 |
propDialog.set_file(gig); |
fileProps.set_file(gig); |
3519 |
|
|
3520 |
instrument_name_connection.block(); |
instrument_name_connection.block(); |
3521 |
int index = 0; |
int index = 0; |
3655 |
} |
} |
3656 |
} |
} |
3657 |
|
|
3658 |
|
bool MainWindow::sample_props_set_sample() |
3659 |
|
{ |
3660 |
|
sampleProps.signal_name_changed().clear(); |
3661 |
|
|
3662 |
|
std::vector<Gtk::TreeModel::Path> rows = m_TreeViewSamples.get_selection()->get_selected_rows(); |
3663 |
|
if (rows.empty()) { |
3664 |
|
sampleProps.hide(); |
3665 |
|
return false; |
3666 |
|
} |
3667 |
|
//NOTE: was const_iterator before, which did not compile with GTKMM4 development branch, probably going to be fixed before final GTKMM4 release though. |
3668 |
|
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[0]); |
3669 |
|
if (it) { |
3670 |
|
Gtk::TreeModel::Row row = *it; |
3671 |
|
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
3672 |
|
|
3673 |
|
sampleProps.set_sample(sample); |
3674 |
|
|
3675 |
|
// make sure sample tree is updated when user changes the |
3676 |
|
// sample name in sample properties window |
3677 |
|
sampleProps.signal_name_changed().connect( |
3678 |
|
sigc::bind( |
3679 |
|
sigc::mem_fun(*this, |
3680 |
|
&MainWindow::sample_name_changed_by_sample_props |
3681 |
|
), it |
3682 |
|
) |
3683 |
|
); |
3684 |
|
} else { |
3685 |
|
sampleProps.hide(); |
3686 |
|
} |
3687 |
|
//NOTE: explicit boolean cast required for GTKMM4 development branch here |
3688 |
|
return it ? true : false; |
3689 |
|
} |
3690 |
|
|
3691 |
|
void MainWindow::show_sample_props() |
3692 |
|
{ |
3693 |
|
if (sample_props_set_sample()) { |
3694 |
|
sampleProps.show(); |
3695 |
|
sampleProps.deiconify(); |
3696 |
|
} |
3697 |
|
} |
3698 |
|
|
3699 |
|
void MainWindow::sample_name_changed_by_sample_props(Gtk::TreeModel::iterator& it) |
3700 |
|
{ |
3701 |
|
Gtk::TreeModel::Row row = *it; |
3702 |
|
Glib::ustring name = row[m_SamplesModel.m_col_name]; |
3703 |
|
|
3704 |
|
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
3705 |
|
Glib::ustring gigname(gig_to_utf8(sample->pInfo->Name)); |
3706 |
|
if (gigname != name) { |
3707 |
|
Gtk::TreeModel::Path path(*it); |
3708 |
|
row[m_SamplesModel.m_col_name] = gigname; |
3709 |
|
} |
3710 |
|
} |
3711 |
|
|
3712 |
void MainWindow::show_midi_rules() |
void MainWindow::show_midi_rules() |
3713 |
{ |
{ |
3714 |
if (gig::Instrument* instrument = get_instrument()) |
if (gig::Instrument* instrument = get_instrument()) |
3757 |
|
|
3758 |
// causes the sampler to reload the instrument with the new script |
// causes the sampler to reload the instrument with the new script |
3759 |
on_sel_change(); |
on_sel_change(); |
3760 |
|
|
3761 |
|
// force script 'patch' variables editor ("Script" tab) to be refreshed |
3762 |
|
dimreg_edit.scriptVars.setInstrument(pInstrument, true/*force update*/); |
3763 |
} |
} |
3764 |
|
|
3765 |
void MainWindow::assignScript(gig::Script* pScript) { |
void MainWindow::assignScript(gig::Script* pScript) { |
3840 |
#endif |
#endif |
3841 |
} |
} |
3842 |
|
|
3843 |
|
void MainWindow::on_instr_double_click_opens_props() { |
3844 |
|
#if USE_GLIB_ACTION |
3845 |
|
bool active = false; |
3846 |
|
m_actionInstrDoubleClickOpensProps->get_state(active); |
3847 |
|
// for some reason toggle state does not change automatically |
3848 |
|
active = !active; |
3849 |
|
m_actionInstrDoubleClickOpensProps->change_state(active); |
3850 |
|
Settings::singleton()->instrumentDoubleClickOpensProps = active; |
3851 |
|
#else |
3852 |
|
Gtk::CheckMenuItem* item = |
3853 |
|
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/OpenInstrPropsByDoubleClick")); |
3854 |
|
if (!item) { |
3855 |
|
std::cerr << "/MenuBar/MenuView/OpenInstrPropsByDoubleClick == NULL\n"; |
3856 |
|
return; |
3857 |
|
} |
3858 |
|
Settings::singleton()->instrumentDoubleClickOpensProps = item->get_active(); |
3859 |
|
#endif |
3860 |
|
} |
3861 |
|
|
3862 |
void MainWindow::on_save_with_temporary_file() { |
void MainWindow::on_save_with_temporary_file() { |
3863 |
#if USE_GLIB_ACTION |
#if USE_GLIB_ACTION |
3864 |
bool active = false; |
bool active = false; |
3933 |
void MainWindow::on_button_release(GdkEventButton* button) { |
void MainWindow::on_button_release(GdkEventButton* button) { |
3934 |
#endif |
#endif |
3935 |
if (button->type == GDK_2BUTTON_PRESS) { |
if (button->type == GDK_2BUTTON_PRESS) { |
3936 |
show_instr_props(); |
if (Settings::singleton()->instrumentDoubleClickOpensProps) |
3937 |
|
show_instr_props(); |
3938 |
} else if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
} else if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
3939 |
// gig v2 files have no midi rules |
// gig v2 files have no midi rules |
3940 |
const bool bEnabled = !(file->pVersion && file->pVersion->major == 2); |
const bool bEnabled = !(file->pVersion && file->pVersion->major == 2); |
3974 |
} |
} |
3975 |
#endif |
#endif |
3976 |
|
|
3977 |
|
void MainWindow::on_action_move_instr() { |
3978 |
|
gig::Instrument* instr = get_instrument(); |
3979 |
|
if (!instr) return; |
3980 |
|
|
3981 |
|
int currentIndex = getIndexOf(instr); |
3982 |
|
|
3983 |
|
Gtk::Dialog dialog(_("Move Instrument"), true /*modal*/); |
3984 |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
3985 |
|
Gtk::Adjustment adjustment( |
3986 |
|
currentIndex, |
3987 |
|
0 /*min*/, file->CountInstruments() - 1 /*max*/ |
3988 |
|
); |
3989 |
|
Gtk::SpinButton spinBox(adjustment); |
3990 |
|
#else |
3991 |
|
Gtk::SpinButton spinBox( |
3992 |
|
Gtk::Adjustment::create( |
3993 |
|
currentIndex, |
3994 |
|
0 /*min*/, file->CountInstruments() - 1 /*max*/ |
3995 |
|
) |
3996 |
|
); |
3997 |
|
#endif |
3998 |
|
#if USE_GTKMM_BOX |
3999 |
|
dialog.get_content_area()->pack_start(spinBox); |
4000 |
|
#else |
4001 |
|
dialog.get_vbox()->pack_start(spinBox); |
4002 |
|
#endif |
4003 |
|
#if HAS_GTKMM_STOCK |
4004 |
|
Gtk::Button* okButton = dialog.add_button(Gtk::Stock::OK, 0); |
4005 |
|
dialog.add_button(Gtk::Stock::CANCEL, 1); |
4006 |
|
#else |
4007 |
|
Gtk::Button* okButton = dialog.add_button(_("_OK"), 0); |
4008 |
|
dialog.add_button(_("_Cancel"), 1); |
4009 |
|
#endif |
4010 |
|
okButton->set_sensitive(false); |
4011 |
|
// show the dialog at a reasonable screen position |
4012 |
|
dialog.set_position(Gtk::WIN_POS_MOUSE); |
4013 |
|
// only enable the 'OK' button if entered new index is not instrument's |
4014 |
|
// current index already |
4015 |
|
spinBox.signal_value_changed().connect([&]{ |
4016 |
|
okButton->set_sensitive( spinBox.get_value_as_int() != currentIndex ); |
4017 |
|
}); |
4018 |
|
// usability acceleration: if user hits enter key on the text entry field |
4019 |
|
// then auto trigger the 'OK' button |
4020 |
|
spinBox.signal_activate().connect([&]{ |
4021 |
|
if (okButton->get_sensitive()) |
4022 |
|
okButton->clicked(); |
4023 |
|
}); |
4024 |
|
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
4025 |
|
dialog.show_all_children(); |
4026 |
|
#endif |
4027 |
|
if (!dialog.run()) { // 'OK' selected ... |
4028 |
|
int newIndex = spinBox.get_value_as_int(); |
4029 |
|
printf("MOVE TO %d\n", newIndex); |
4030 |
|
gig::Instrument* dst = file->GetInstrument(newIndex); |
4031 |
|
instr->MoveTo(dst); |
4032 |
|
__refreshEntireGUI(); |
4033 |
|
select_instrument(instr); |
4034 |
|
} |
4035 |
|
} |
4036 |
|
|
4037 |
void MainWindow::select_instrument(gig::Instrument* instrument) { |
void MainWindow::select_instrument(gig::Instrument* instrument) { |
4038 |
if (!instrument) return; |
if (!instrument) return; |
4039 |
|
|
4375 |
Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append(); |
Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append(); |
4376 |
Gtk::TreeModel::Row rowInstr = *iterInstr; |
Gtk::TreeModel::Row rowInstr = *iterInstr; |
4377 |
const int index = m_refTreeModel->children().size() - 1; |
const int index = m_refTreeModel->children().size() - 1; |
4378 |
|
const int iScriptSlots = instrument->ScriptSlotCount(); |
4379 |
rowInstr[m_Columns.m_col_nr] = index; |
rowInstr[m_Columns.m_col_nr] = index; |
4380 |
rowInstr[m_Columns.m_col_name] = name; |
rowInstr[m_Columns.m_col_name] = name; |
4381 |
rowInstr[m_Columns.m_col_instr] = instrument; |
rowInstr[m_Columns.m_col_instr] = instrument; |
4382 |
rowInstr[m_Columns.m_col_scripts] = ""; |
rowInstr[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : ""; |
4383 |
rowInstr[m_Columns.m_col_tooltip] = scriptTooltipFor(instrument, index); |
rowInstr[m_Columns.m_col_tooltip] = scriptTooltipFor(instrument, index); |
4384 |
instrument_name_connection.unblock(); |
instrument_name_connection.unblock(); |
4385 |
|
|
4499 |
} |
} |
4500 |
|
|
4501 |
void MainWindow::on_action_sample_properties() { |
void MainWindow::on_action_sample_properties() { |
4502 |
//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(); |
|
4503 |
} |
} |
4504 |
|
|
4505 |
void MainWindow::on_action_add_script_group() { |
void MainWindow::on_action_add_script_group() { |
4562 |
if (!it) return; |
if (!it) return; |
4563 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
4564 |
gig::Script* script = row[m_ScriptsModel.m_col_script]; |
gig::Script* script = row[m_ScriptsModel.m_col_script]; |
4565 |
if (!script) return; |
editScript(script); |
4566 |
|
} |
4567 |
|
|
4568 |
|
void MainWindow::editScript(gig::Script* script) { |
4569 |
|
if (!script) return; |
4570 |
ScriptEditor* editor = new ScriptEditor; |
ScriptEditor* editor = new ScriptEditor; |
4571 |
editor->signal_script_to_be_changed.connect( |
editor->signal_script_to_be_changed.connect( |
4572 |
signal_script_to_be_changed.make_slot() |
signal_script_to_be_changed.make_slot() |
4573 |
); |
); |
4574 |
editor->signal_script_changed.connect( |
editor->signal_script_changed.connect([this](gig::Script* script) { |
4575 |
signal_script_changed.make_slot() |
// signal to sampler (which will reload the script due to this) |
4576 |
); |
signal_script_changed.emit(script); |
4577 |
|
// force script 'patch' variables editor ("Script" tab) to be refreshed |
4578 |
|
gig::Instrument* instr = get_instrument(); |
4579 |
|
dimreg_edit.scriptVars.setInstrument(instr, true/*force update*/); |
4580 |
|
}); |
4581 |
editor->setScript(script); |
editor->setScript(script); |
4582 |
//editor->reparent(*this); |
//editor->reparent(*this); |
4583 |
editor->show(); |
editor->show(); |
4725 |
dialog.set_current_folder(current_sample_dir); |
dialog.set_current_folder(current_sample_dir); |
4726 |
} |
} |
4727 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
4728 |
|
dialog.hide(); |
4729 |
current_sample_dir = dialog.get_current_folder(); |
current_sample_dir = dialog.get_current_folder(); |
4730 |
Glib::ustring error_files; |
Glib::ustring error_files; |
4731 |
std::vector<std::string> filenames = dialog.get_filenames(); |
std::vector<std::string> filenames = dialog.get_filenames(); |
4906 |
} |
} |
4907 |
if (dialog.run() == Gtk::RESPONSE_OK) |
if (dialog.run() == Gtk::RESPONSE_OK) |
4908 |
{ |
{ |
4909 |
|
dialog.hide(); |
4910 |
current_sample_dir = dialog.get_current_folder(); |
current_sample_dir = dialog.get_current_folder(); |
4911 |
Glib::ustring error_files; |
Glib::ustring error_files; |
4912 |
std::string folder = dialog.get_filename(); |
std::string folder = dialog.get_filename(); |
5305 |
file_changed(); |
file_changed(); |
5306 |
} |
} |
5307 |
} |
} |
5308 |
|
// change name in the sample properties window |
5309 |
|
if (sampleProps.get_sample() == sample && sample) { |
5310 |
|
sampleProps.set_sample(sample); |
5311 |
|
} |
5312 |
} |
} |
5313 |
|
|
5314 |
void MainWindow::script_name_changed(const Gtk::TreeModel::Path& path, |
void MainWindow::script_name_changed(const Gtk::TreeModel::Path& path, |
5341 |
if (!iter) return; |
if (!iter) return; |
5342 |
Gtk::TreeModel::Row row = *iter; |
Gtk::TreeModel::Row row = *iter; |
5343 |
gig::Script* script = row[m_ScriptsModel.m_col_script]; |
gig::Script* script = row[m_ScriptsModel.m_col_script]; |
5344 |
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(); |
|
5345 |
} |
} |
5346 |
|
|
5347 |
void MainWindow::instrument_name_changed(const Gtk::TreeModel::Path& path, |
void MainWindow::instrument_name_changed(const Gtk::TreeModel::Path& path, |
5628 |
#endif |
#endif |
5629 |
|
|
5630 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
5631 |
|
dialog.hide(); |
5632 |
|
#ifdef GLIB_THREADS |
5633 |
printf("on_action_merge_files self=%p\n", |
printf("on_action_merge_files self=%p\n", |
5634 |
static_cast<void*>(Glib::Threads::Thread::self())); |
static_cast<void*>(Glib::Threads::Thread::self())); |
5635 |
|
#else |
5636 |
|
std::cout << "on_action_merge_files self=" << |
5637 |
|
std::this_thread::get_id() << "\n"; |
5638 |
|
#endif |
5639 |
std::vector<std::string> filenames = dialog.get_filenames(); |
std::vector<std::string> filenames = dialog.get_filenames(); |
5640 |
|
|
5641 |
// merge the selected files to the currently open .gig file |
// merge the selected files to the currently open .gig file |