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 |
96 |
|
|
97 |
if (!Settings::singleton()->autoRestoreWindowDimension) { |
if (!Settings::singleton()->autoRestoreWindowDimension) { |
98 |
#if GTKMM_MAJOR_VERSION >= 3 |
#if GTKMM_MAJOR_VERSION >= 3 |
99 |
set_default_size(960, 600); |
set_default_size(1010, -1); |
100 |
#else |
#else |
101 |
set_default_size(865, 600); |
set_default_size(915, -1); |
102 |
#endif |
#endif |
103 |
set_position(Gtk::WIN_POS_CENTER); |
set_position(Gtk::WIN_POS_CENTER); |
104 |
} |
} |
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 |
|
sampleProps.signal_changed().connect( |
1529 |
|
sigc::mem_fun(*this, &MainWindow::file_changed)); |
1530 |
fileProps.signal_changed().connect( |
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( |
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()); |
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")), |
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); |
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); |
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--; |
3424 |
|
} |
3425 |
|
|
3426 |
|
|
3427 |
void MainWindow::file_changed() |
void MainWindow::file_changed() |
3428 |
{ |
{ |
3429 |
if (file && !file_is_changed) { |
if (file && !file_is_changed) { |
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()) |
3837 |
#endif |
#endif |
3838 |
} |
} |
3839 |
|
|
3840 |
|
void MainWindow::on_instr_double_click_opens_props() { |
3841 |
|
#if USE_GLIB_ACTION |
3842 |
|
bool active = false; |
3843 |
|
m_actionInstrDoubleClickOpensProps->get_state(active); |
3844 |
|
// for some reason toggle state does not change automatically |
3845 |
|
active = !active; |
3846 |
|
m_actionInstrDoubleClickOpensProps->change_state(active); |
3847 |
|
Settings::singleton()->instrumentDoubleClickOpensProps = active; |
3848 |
|
#else |
3849 |
|
Gtk::CheckMenuItem* item = |
3850 |
|
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/OpenInstrPropsByDoubleClick")); |
3851 |
|
if (!item) { |
3852 |
|
std::cerr << "/MenuBar/MenuView/OpenInstrPropsByDoubleClick == NULL\n"; |
3853 |
|
return; |
3854 |
|
} |
3855 |
|
Settings::singleton()->instrumentDoubleClickOpensProps = item->get_active(); |
3856 |
|
#endif |
3857 |
|
} |
3858 |
|
|
3859 |
void MainWindow::on_save_with_temporary_file() { |
void MainWindow::on_save_with_temporary_file() { |
3860 |
#if USE_GLIB_ACTION |
#if USE_GLIB_ACTION |
3861 |
bool active = false; |
bool active = false; |
3930 |
void MainWindow::on_button_release(GdkEventButton* button) { |
void MainWindow::on_button_release(GdkEventButton* button) { |
3931 |
#endif |
#endif |
3932 |
if (button->type == GDK_2BUTTON_PRESS) { |
if (button->type == GDK_2BUTTON_PRESS) { |
3933 |
show_instr_props(); |
if (Settings::singleton()->instrumentDoubleClickOpensProps) |
3934 |
|
show_instr_props(); |
3935 |
} else if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
} else if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
3936 |
// gig v2 files have no midi rules |
// gig v2 files have no midi rules |
3937 |
const bool bEnabled = !(file->pVersion && file->pVersion->major == 2); |
const bool bEnabled = !(file->pVersion && file->pVersion->major == 2); |
3971 |
} |
} |
3972 |
#endif |
#endif |
3973 |
|
|
3974 |
|
void MainWindow::on_action_move_instr() { |
3975 |
|
gig::Instrument* instr = get_instrument(); |
3976 |
|
if (!instr) return; |
3977 |
|
|
3978 |
|
int currentIndex = getIndexOf(instr); |
3979 |
|
|
3980 |
|
Gtk::Dialog dialog(_("Move Instrument"), true /*modal*/); |
3981 |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
3982 |
|
Gtk::Adjustment adjustment( |
3983 |
|
currentIndex, |
3984 |
|
0 /*min*/, file->CountInstruments() - 1 /*max*/ |
3985 |
|
); |
3986 |
|
Gtk::SpinButton spinBox(adjustment); |
3987 |
|
#else |
3988 |
|
Gtk::SpinButton spinBox( |
3989 |
|
Gtk::Adjustment::create( |
3990 |
|
currentIndex, |
3991 |
|
0 /*min*/, file->CountInstruments() - 1 /*max*/ |
3992 |
|
) |
3993 |
|
); |
3994 |
|
#endif |
3995 |
|
#if USE_GTKMM_BOX |
3996 |
|
dialog.get_content_area()->pack_start(spinBox); |
3997 |
|
#else |
3998 |
|
dialog.get_vbox()->pack_start(spinBox); |
3999 |
|
#endif |
4000 |
|
#if HAS_GTKMM_STOCK |
4001 |
|
Gtk::Button* okButton = dialog.add_button(Gtk::Stock::OK, 0); |
4002 |
|
dialog.add_button(Gtk::Stock::CANCEL, 1); |
4003 |
|
#else |
4004 |
|
Gtk::Button* okButton = dialog.add_button(_("_OK"), 0); |
4005 |
|
dialog.add_button(_("_Cancel"), 1); |
4006 |
|
#endif |
4007 |
|
okButton->set_sensitive(false); |
4008 |
|
// show the dialog at a reasonable screen position |
4009 |
|
dialog.set_position(Gtk::WIN_POS_MOUSE); |
4010 |
|
// only enable the 'OK' button if entered new index is not instrument's |
4011 |
|
// current index already |
4012 |
|
spinBox.signal_value_changed().connect([&]{ |
4013 |
|
okButton->set_sensitive( spinBox.get_value_as_int() != currentIndex ); |
4014 |
|
}); |
4015 |
|
// usability acceleration: if user hits enter key on the text entry field |
4016 |
|
// then auto trigger the 'OK' button |
4017 |
|
spinBox.signal_activate().connect([&]{ |
4018 |
|
if (okButton->get_sensitive()) |
4019 |
|
okButton->clicked(); |
4020 |
|
}); |
4021 |
|
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
4022 |
|
dialog.show_all_children(); |
4023 |
|
#endif |
4024 |
|
if (!dialog.run()) { // 'OK' selected ... |
4025 |
|
int newIndex = spinBox.get_value_as_int(); |
4026 |
|
printf("MOVE TO %d\n", newIndex); |
4027 |
|
gig::Instrument* dst = file->GetInstrument(newIndex); |
4028 |
|
instr->MoveTo(dst); |
4029 |
|
__refreshEntireGUI(); |
4030 |
|
select_instrument(instr); |
4031 |
|
} |
4032 |
|
} |
4033 |
|
|
4034 |
void MainWindow::select_instrument(gig::Instrument* instrument) { |
void MainWindow::select_instrument(gig::Instrument* instrument) { |
4035 |
if (!instrument) return; |
if (!instrument) return; |
4036 |
|
|
4495 |
} |
} |
4496 |
|
|
4497 |
void MainWindow::on_action_sample_properties() { |
void MainWindow::on_action_sample_properties() { |
4498 |
//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(); |
|
4499 |
} |
} |
4500 |
|
|
4501 |
void MainWindow::on_action_add_script_group() { |
void MainWindow::on_action_add_script_group() { |
4558 |
if (!it) return; |
if (!it) return; |
4559 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
4560 |
gig::Script* script = row[m_ScriptsModel.m_col_script]; |
gig::Script* script = row[m_ScriptsModel.m_col_script]; |
4561 |
if (!script) return; |
editScript(script); |
4562 |
|
} |
4563 |
|
|
4564 |
|
void MainWindow::editScript(gig::Script* script) { |
4565 |
|
if (!script) return; |
4566 |
ScriptEditor* editor = new ScriptEditor; |
ScriptEditor* editor = new ScriptEditor; |
4567 |
editor->signal_script_to_be_changed.connect( |
editor->signal_script_to_be_changed.connect( |
4568 |
signal_script_to_be_changed.make_slot() |
signal_script_to_be_changed.make_slot() |
5297 |
file_changed(); |
file_changed(); |
5298 |
} |
} |
5299 |
} |
} |
5300 |
|
// change name in the sample properties window |
5301 |
|
if (sampleProps.get_sample() == sample && sample) { |
5302 |
|
sampleProps.set_sample(sample); |
5303 |
|
} |
5304 |
} |
} |
5305 |
|
|
5306 |
void MainWindow::script_name_changed(const Gtk::TreeModel::Path& path, |
void MainWindow::script_name_changed(const Gtk::TreeModel::Path& path, |