87 |
{ |
{ |
88 |
loadBuiltInPix(); |
loadBuiltInPix(); |
89 |
|
|
90 |
|
this->file = NULL; |
91 |
|
|
92 |
// set_border_width(5); |
// set_border_width(5); |
93 |
|
|
94 |
if (!Settings::singleton()->autoRestoreWindowDimension) { |
if (!Settings::singleton()->autoRestoreWindowDimension) { |
223 |
sigc::mem_fun(*this, &MainWindow::show_scripts_tab) |
sigc::mem_fun(*this, &MainWindow::show_scripts_tab) |
224 |
); |
); |
225 |
actionGroup->add(Gtk::Action::create("AllInstruments", _("_Select"))); |
actionGroup->add(Gtk::Action::create("AllInstruments", _("_Select"))); |
226 |
|
actionGroup->add(Gtk::Action::create("AssignScripts", _("Assign Script"))); |
227 |
|
|
228 |
actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit"))); |
actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit"))); |
229 |
|
|
249 |
Gtk::AccelKey(GDK_KEY_x, Gdk::MOD1_MASK), |
Gtk::AccelKey(GDK_KEY_x, Gdk::MOD1_MASK), |
250 |
sigc::mem_fun(*this, &MainWindow::adjust_clipboard_content)); |
sigc::mem_fun(*this, &MainWindow::adjust_clipboard_content)); |
251 |
|
|
252 |
|
actionGroup->add(Gtk::Action::create("SelectPrevInstr", |
253 |
|
_("Select Previous Instrument")), |
254 |
|
Gtk::AccelKey(GDK_KEY_Up, primaryModifierKey), |
255 |
|
sigc::mem_fun(*this, &MainWindow::select_prev_instrument)); |
256 |
|
|
257 |
|
actionGroup->add(Gtk::Action::create("SelectNextInstr", |
258 |
|
_("Select Next Instrument")), |
259 |
|
Gtk::AccelKey(GDK_KEY_Down, primaryModifierKey), |
260 |
|
sigc::mem_fun(*this, &MainWindow::select_next_instrument)); |
261 |
|
|
262 |
actionGroup->add(Gtk::Action::create("SelectPrevRegion", |
actionGroup->add(Gtk::Action::create("SelectPrevRegion", |
263 |
_("Select Previous Region")), |
_("Select Previous Region")), |
264 |
Gtk::AccelKey(GDK_KEY_Left, primaryModifierKey), |
Gtk::AccelKey(GDK_KEY_Left, primaryModifierKey), |
487 |
" <menuitem action='AdjustClipboard'/>" |
" <menuitem action='AdjustClipboard'/>" |
488 |
" <menuitem action='PasteDimRgn'/>" |
" <menuitem action='PasteDimRgn'/>" |
489 |
" <separator/>" |
" <separator/>" |
490 |
|
" <menuitem action='SelectPrevInstr'/>" |
491 |
|
" <menuitem action='SelectNextInstr'/>" |
492 |
|
" <separator/>" |
493 |
" <menuitem action='SelectPrevRegion'/>" |
" <menuitem action='SelectPrevRegion'/>" |
494 |
" <menuitem action='SelectNextRegion'/>" |
" <menuitem action='SelectNextRegion'/>" |
495 |
" <separator/>" |
" <separator/>" |
524 |
" <menuitem action='InstrProperties'/>" |
" <menuitem action='InstrProperties'/>" |
525 |
" <menuitem action='MidiRules'/>" |
" <menuitem action='MidiRules'/>" |
526 |
" <menuitem action='ScriptSlots'/>" |
" <menuitem action='ScriptSlots'/>" |
527 |
|
" <menu action='AssignScripts'/>" |
528 |
" <menuitem action='AddInstrument'/>" |
" <menuitem action='AddInstrument'/>" |
529 |
" <menuitem action='DupInstrument'/>" |
" <menuitem action='DupInstrument'/>" |
530 |
" <menuitem action='CombInstruments'/>" |
" <menuitem action='CombInstruments'/>" |
659 |
instrument_menu = static_cast<Gtk::MenuItem*>( |
instrument_menu = static_cast<Gtk::MenuItem*>( |
660 |
uiManager->get_widget("/MenuBar/MenuInstrument/AllInstruments"))->get_submenu(); |
uiManager->get_widget("/MenuBar/MenuInstrument/AllInstruments"))->get_submenu(); |
661 |
|
|
662 |
|
assign_scripts_menu = static_cast<Gtk::MenuItem*>( |
663 |
|
uiManager->get_widget("/MenuBar/MenuInstrument/AssignScripts"))->get_submenu(); |
664 |
|
|
665 |
Gtk::Widget* menuBar = uiManager->get_widget("/MenuBar"); |
Gtk::Widget* menuBar = uiManager->get_widget("/MenuBar"); |
666 |
m_VBox.pack_start(*menuBar, Gtk::PACK_SHRINK); |
m_VBox.pack_start(*menuBar, Gtk::PACK_SHRINK); |
667 |
m_VBox.pack_start(m_HPaned); |
m_VBox.pack_start(m_HPaned); |
906 |
updateMacroMenu(); |
updateMacroMenu(); |
907 |
} |
} |
908 |
|
|
909 |
|
// setup "Assign Scripts" keyboard accelerators |
910 |
|
{ |
911 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_0", GDK_KEY_F1, Gdk::SHIFT_MASK); |
912 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_1", GDK_KEY_F2, Gdk::SHIFT_MASK); |
913 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_2", GDK_KEY_F3, Gdk::SHIFT_MASK); |
914 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_3", GDK_KEY_F4, Gdk::SHIFT_MASK); |
915 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_4", GDK_KEY_F5, Gdk::SHIFT_MASK); |
916 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_5", GDK_KEY_F6, Gdk::SHIFT_MASK); |
917 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_6", GDK_KEY_F7, Gdk::SHIFT_MASK); |
918 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_7", GDK_KEY_F8, Gdk::SHIFT_MASK); |
919 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_8", GDK_KEY_F9, Gdk::SHIFT_MASK); |
920 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_9", GDK_KEY_F10, Gdk::SHIFT_MASK); |
921 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_10", GDK_KEY_F11, Gdk::SHIFT_MASK); |
922 |
|
Gtk::AccelMap::add_entry("<Scripts>/script_11", GDK_KEY_F12, Gdk::SHIFT_MASK); |
923 |
|
|
924 |
|
Glib::RefPtr<Gtk::AccelGroup> accelGroup = this->get_accel_group(); |
925 |
|
assign_scripts_menu->set_accel_group(accelGroup); |
926 |
|
} |
927 |
|
|
928 |
Glib::signal_idle().connect_once( |
Glib::signal_idle().connect_once( |
929 |
sigc::mem_fun(*this, &MainWindow::bringToFront), |
sigc::mem_fun(*this, &MainWindow::bringToFront), |
930 |
200 |
200 |
1141 |
} |
} |
1142 |
} |
} |
1143 |
|
|
1144 |
|
updateScriptListOfMenu(); |
1145 |
|
|
1146 |
m_RegionChooser.set_instrument(get_instrument()); |
m_RegionChooser.set_instrument(get_instrument()); |
1147 |
|
|
1148 |
if (Settings::singleton()->syncSamplerInstrumentSelection) { |
if (Settings::singleton()->syncSamplerInstrumentSelection) { |
2342 |
row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : ""; |
row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : ""; |
2343 |
break; |
break; |
2344 |
} |
} |
2345 |
|
|
2346 |
|
// causes the sampler to reload the instrument with the new script |
2347 |
|
on_sel_change(); |
2348 |
|
} |
2349 |
|
|
2350 |
|
void MainWindow::assignScript(gig::Script* pScript) { |
2351 |
|
if (!pScript) { |
2352 |
|
printf("assignScript() : !script\n"); |
2353 |
|
return; |
2354 |
|
} |
2355 |
|
printf("assignScript('%s')\n", pScript->Name.c_str()); |
2356 |
|
|
2357 |
|
gig::Instrument* pInstrument = get_instrument(); |
2358 |
|
if (!pInstrument) { |
2359 |
|
printf("!instrument\n"); |
2360 |
|
return; |
2361 |
|
} |
2362 |
|
|
2363 |
|
pInstrument->AddScriptSlot(pScript); |
2364 |
|
|
2365 |
|
onScriptSlotsModified(pInstrument); |
2366 |
} |
} |
2367 |
|
|
2368 |
void MainWindow::on_action_refresh_all() { |
void MainWindow::on_action_refresh_all() { |
2637 |
} |
} |
2638 |
} |
} |
2639 |
|
|
2640 |
|
void MainWindow::updateScriptListOfMenu() { |
2641 |
|
// remove all entries from "Assign Script" menu |
2642 |
|
{ |
2643 |
|
const std::vector<Gtk::Widget*> children = assign_scripts_menu->get_children(); |
2644 |
|
for (int i = 0; i < children.size(); ++i) { |
2645 |
|
Gtk::Widget* child = children[i]; |
2646 |
|
assign_scripts_menu->remove(*child); |
2647 |
|
delete child; |
2648 |
|
} |
2649 |
|
} |
2650 |
|
|
2651 |
|
int iTotalScripts = 0; |
2652 |
|
|
2653 |
|
if (!file) goto noScripts; |
2654 |
|
|
2655 |
|
// add all configured macros as menu items to the "Macro" menu |
2656 |
|
for (int iGroup = 0; file->GetScriptGroup(iGroup); ++iGroup) { |
2657 |
|
gig::ScriptGroup* pGroup = file->GetScriptGroup(iGroup); |
2658 |
|
for (int iScript = 0; pGroup->GetScript(iScript); ++iScript, ++iTotalScripts) { |
2659 |
|
gig::Script* pScript = pGroup->GetScript(iScript); |
2660 |
|
std::string name = pScript->Name; |
2661 |
|
|
2662 |
|
Gtk::MenuItem* item = new Gtk::MenuItem(name); |
2663 |
|
item->signal_activate().connect( |
2664 |
|
sigc::bind( |
2665 |
|
sigc::mem_fun(*this, &MainWindow::assignScript), pScript |
2666 |
|
) |
2667 |
|
); |
2668 |
|
assign_scripts_menu->append(*item); |
2669 |
|
item->set_accel_path("<Scripts>/script_" + ToString(iTotalScripts)); |
2670 |
|
//item->set_tooltip_text(comment); |
2671 |
|
} |
2672 |
|
} |
2673 |
|
|
2674 |
|
noScripts: |
2675 |
|
|
2676 |
|
// if there are no macros configured at all, then show a dummy entry instead |
2677 |
|
if (!iTotalScripts) { |
2678 |
|
Gtk::MenuItem* item = new Gtk::MenuItem(_("No Scripts")); |
2679 |
|
item->set_sensitive(false); |
2680 |
|
assign_scripts_menu->append(*item); |
2681 |
|
} |
2682 |
|
|
2683 |
|
assign_scripts_menu->show_all_children(); |
2684 |
|
} |
2685 |
|
|
2686 |
Gtk::RadioMenuItem* MainWindow::add_instrument_to_menu( |
Gtk::RadioMenuItem* MainWindow::add_instrument_to_menu( |
2687 |
const Glib::ustring& name, int position) { |
const Glib::ustring& name, int position) { |
2688 |
|
|
2729 |
instrument_name_connection.unblock(); |
instrument_name_connection.unblock(); |
2730 |
|
|
2731 |
add_instrument_to_menu(name); |
add_instrument_to_menu(name); |
2732 |
|
select_instrument(instrument); |
|
m_TreeView.get_selection()->select(iterInstr); |
|
|
m_TreeView.scroll_to_row(Gtk::TreePath(iterInstr)); |
|
|
|
|
2733 |
file_changed(); |
file_changed(); |
2734 |
} |
} |
2735 |
|
|
3981 |
m_TreeViewNotebook.set_current_page(2); |
m_TreeViewNotebook.set_current_page(2); |
3982 |
} |
} |
3983 |
|
|
3984 |
|
void MainWindow::select_instrument_by_dir(int dir) { |
3985 |
|
if (!file) return; |
3986 |
|
gig::Instrument* pInstrument = get_instrument(); |
3987 |
|
if (!pInstrument) { |
3988 |
|
select_instrument( file->GetInstrument(0) ); |
3989 |
|
return; |
3990 |
|
} |
3991 |
|
for (int i = 0; file->GetInstrument(i); ++i) { |
3992 |
|
if (file->GetInstrument(i) == pInstrument) { |
3993 |
|
select_instrument( file->GetInstrument(i + dir) ); |
3994 |
|
return; |
3995 |
|
} |
3996 |
|
} |
3997 |
|
} |
3998 |
|
|
3999 |
|
void MainWindow::select_prev_instrument() { |
4000 |
|
select_instrument_by_dir(-1); |
4001 |
|
} |
4002 |
|
|
4003 |
|
void MainWindow::select_next_instrument() { |
4004 |
|
select_instrument_by_dir(1); |
4005 |
|
} |
4006 |
|
|
4007 |
void MainWindow::select_prev_region() { |
void MainWindow::select_prev_region() { |
4008 |
m_RegionChooser.select_prev_region(); |
m_RegionChooser.select_prev_region(); |
4009 |
} |
} |