1 |
/* |
/* |
2 |
* Copyright (C) 2006-2015 Andreas Persson |
* Copyright (C) 2006-2017 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 |
20 |
#include <iostream> |
#include <iostream> |
21 |
#include <cstring> |
#include <cstring> |
22 |
|
|
23 |
|
#include <glibmmconfig.h> |
24 |
|
// threads.h must be included first to be able to build with |
25 |
|
// G_DISABLE_DEPRECATED |
26 |
|
#if (GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION == 31 && GLIBMM_MICRO_VERSION >= 2) || \ |
27 |
|
(GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION > 31) || GLIBMM_MAJOR_VERSION > 2 |
28 |
|
#include <glibmm/threads.h> |
29 |
|
#endif |
30 |
|
|
31 |
#include <glibmm/convert.h> |
#include <glibmm/convert.h> |
32 |
#include <glibmm/dispatcher.h> |
#include <glibmm/dispatcher.h> |
33 |
#include <glibmm/miscutils.h> |
#include <glibmm/miscutils.h> |
39 |
#include <gtkmm/targetentry.h> |
#include <gtkmm/targetentry.h> |
40 |
#include <gtkmm/main.h> |
#include <gtkmm/main.h> |
41 |
#include <gtkmm/toggleaction.h> |
#include <gtkmm/toggleaction.h> |
42 |
|
#include <gtkmm/accelmap.h> |
43 |
#if GTKMM_MAJOR_VERSION < 3 |
#if GTKMM_MAJOR_VERSION < 3 |
44 |
#include "wrapLabel.hh" |
#include "wrapLabel.hh" |
45 |
#endif |
#endif |
59 |
#include "ReferencesView.h" |
#include "ReferencesView.h" |
60 |
#include "../../gfx/status_attached.xpm" |
#include "../../gfx/status_attached.xpm" |
61 |
#include "../../gfx/status_detached.xpm" |
#include "../../gfx/status_detached.xpm" |
62 |
|
#include "gfx/builtinpix.h" |
63 |
|
#include "MacroEditor.h" |
64 |
|
#include "MacrosSetup.h" |
65 |
|
|
66 |
MainWindow::MainWindow() : |
MainWindow::MainWindow() : |
67 |
m_DimRegionChooser(*this), |
m_DimRegionChooser(*this), |
68 |
dimreg_label(_("Changes apply to:")), |
dimreg_label(_("Changes apply to:")), |
69 |
dimreg_all_regions(_("all regions")), |
dimreg_all_regions(_("all regions")), |
70 |
dimreg_all_dimregs(_("all dimension splits")), |
dimreg_all_dimregs(_("all dimension splits")), |
71 |
dimreg_stereo(_("both channels")) |
dimreg_stereo(_("both channels")), |
72 |
|
labelLegend(_("Legend:")), |
73 |
|
labelNoSample(_(" No Sample")), |
74 |
|
labelMissingSample(_(" Missing some Sample(s)")), |
75 |
|
labelLooped(_(" Looped")), |
76 |
|
labelSomeLoops(_(" Some Loop(s)")) |
77 |
{ |
{ |
78 |
|
loadBuiltInPix(); |
79 |
|
|
80 |
// set_border_width(5); |
// set_border_width(5); |
81 |
// set_default_size(400, 200); |
// set_default_size(400, 200); |
82 |
|
|
|
|
|
83 |
add(m_VBox); |
add(m_VBox); |
84 |
|
|
85 |
// Handle selection |
// Handle selection |
113 |
dimreg_hbox.add(dimreg_stereo); |
dimreg_hbox.add(dimreg_stereo); |
114 |
dimreg_vbox.add(dimreg_edit); |
dimreg_vbox.add(dimreg_edit); |
115 |
dimreg_vbox.pack_start(dimreg_hbox, Gtk::PACK_SHRINK); |
dimreg_vbox.pack_start(dimreg_hbox, Gtk::PACK_SHRINK); |
116 |
|
{ |
117 |
|
legend_hbox.add(labelLegend); |
118 |
|
|
119 |
|
imageNoSample.set(redDot); |
120 |
|
imageNoSample.set_alignment(Gtk::ALIGN_END); |
121 |
|
labelNoSample.set_alignment(Gtk::ALIGN_START); |
122 |
|
legend_hbox.add(imageNoSample); |
123 |
|
legend_hbox.add(labelNoSample); |
124 |
|
|
125 |
|
imageMissingSample.set(yellowDot); |
126 |
|
imageMissingSample.set_alignment(Gtk::ALIGN_END); |
127 |
|
labelMissingSample.set_alignment(Gtk::ALIGN_START); |
128 |
|
legend_hbox.add(imageMissingSample); |
129 |
|
legend_hbox.add(labelMissingSample); |
130 |
|
|
131 |
|
imageLooped.set(blackLoop); |
132 |
|
imageLooped.set_alignment(Gtk::ALIGN_END); |
133 |
|
labelLooped.set_alignment(Gtk::ALIGN_START); |
134 |
|
legend_hbox.add(imageLooped); |
135 |
|
legend_hbox.add(labelLooped); |
136 |
|
|
137 |
|
imageSomeLoops.set(grayLoop); |
138 |
|
imageSomeLoops.set_alignment(Gtk::ALIGN_END); |
139 |
|
labelSomeLoops.set_alignment(Gtk::ALIGN_START); |
140 |
|
legend_hbox.add(imageSomeLoops); |
141 |
|
legend_hbox.add(labelSomeLoops); |
142 |
|
|
143 |
|
legend_hbox.show_all_children(); |
144 |
|
} |
145 |
|
dimreg_vbox.pack_start(legend_hbox, Gtk::PACK_SHRINK); |
146 |
m_HPaned.add2(dimreg_vbox); |
m_HPaned.add2(dimreg_vbox); |
147 |
|
|
148 |
dimreg_label.set_tooltip_text(_("To automatically apply your changes above globally to the entire instrument, check all 3 check boxes on the right.")); |
dimreg_label.set_tooltip_text(_("To automatically apply your changes above globally to the entire instrument, check all 3 check boxes on the right.")); |
203 |
sigc::mem_fun(*this, &MainWindow::show_intruments_tab) |
sigc::mem_fun(*this, &MainWindow::show_intruments_tab) |
204 |
); |
); |
205 |
actionGroup->add( |
actionGroup->add( |
206 |
Gtk::Action::create("MenuScript", _("S_cript")), |
Gtk::Action::create("MenuScript", _("Scr_ipt")), |
207 |
sigc::mem_fun(*this, &MainWindow::show_scripts_tab) |
sigc::mem_fun(*this, &MainWindow::show_scripts_tab) |
208 |
); |
); |
209 |
actionGroup->add(Gtk::Action::create("AllInstruments", _("_Select"))); |
actionGroup->add(Gtk::Action::create("AllInstruments", _("_Select"))); |
210 |
|
|
211 |
actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit"))); |
actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit"))); |
212 |
|
|
213 |
|
const Gdk::ModifierType primaryModifierKey = |
214 |
|
#if defined(__APPLE__) |
215 |
|
Gdk::META_MASK; // Cmd key on Mac |
216 |
|
#else |
217 |
|
Gdk::CONTROL_MASK; // Ctrl key on all other OSs |
218 |
|
#endif |
219 |
|
|
220 |
|
actionGroup->add(Gtk::Action::create("CopyDimRgn", |
221 |
|
_("Copy selected dimension region")), |
222 |
|
Gtk::AccelKey(GDK_KEY_c, Gdk::MOD1_MASK), |
223 |
|
sigc::mem_fun(*this, &MainWindow::copy_selected_dimrgn)); |
224 |
|
|
225 |
|
actionGroup->add(Gtk::Action::create("PasteDimRgn", |
226 |
|
_("Paste dimension region")), |
227 |
|
Gtk::AccelKey(GDK_KEY_v, Gdk::MOD1_MASK), |
228 |
|
sigc::mem_fun(*this, &MainWindow::paste_copied_dimrgn)); |
229 |
|
|
230 |
|
actionGroup->add(Gtk::Action::create("AdjustClipboard", |
231 |
|
_("Adjust Clipboard Content")), |
232 |
|
Gtk::AccelKey(GDK_KEY_x, Gdk::MOD1_MASK), |
233 |
|
sigc::mem_fun(*this, &MainWindow::adjust_clipboard_content)); |
234 |
|
|
235 |
|
actionGroup->add(Gtk::Action::create("SelectPrevRegion", |
236 |
|
_("Select Previous Region")), |
237 |
|
Gtk::AccelKey(GDK_KEY_Left, primaryModifierKey), |
238 |
|
sigc::mem_fun(*this, &MainWindow::select_prev_region)); |
239 |
|
|
240 |
|
actionGroup->add(Gtk::Action::create("SelectNextRegion", |
241 |
|
_("Select Next Region")), |
242 |
|
Gtk::AccelKey(GDK_KEY_Right, primaryModifierKey), |
243 |
|
sigc::mem_fun(*this, &MainWindow::select_next_region)); |
244 |
|
|
245 |
|
actionGroup->add(Gtk::Action::create("SelectPrevDimRgnZone", |
246 |
|
_("Select Previous Dimension Region Zone")), |
247 |
|
Gtk::AccelKey(GDK_KEY_Left, Gdk::MOD1_MASK), |
248 |
|
sigc::mem_fun(*this, &MainWindow::select_prev_dim_rgn_zone)); |
249 |
|
|
250 |
|
actionGroup->add(Gtk::Action::create("SelectNextDimRgnZone", |
251 |
|
_("Select Next Dimension Region Zone")), |
252 |
|
Gtk::AccelKey(GDK_KEY_Right, Gdk::MOD1_MASK), |
253 |
|
sigc::mem_fun(*this, &MainWindow::select_next_dim_rgn_zone)); |
254 |
|
|
255 |
|
actionGroup->add(Gtk::Action::create("SelectPrevDimension", |
256 |
|
_("Select Previous Dimension")), |
257 |
|
Gtk::AccelKey(GDK_KEY_Up, Gdk::MOD1_MASK), |
258 |
|
sigc::mem_fun(*this, &MainWindow::select_prev_dimension)); |
259 |
|
|
260 |
|
actionGroup->add(Gtk::Action::create("SelectNextDimension", |
261 |
|
_("Select Next Dimension")), |
262 |
|
Gtk::AccelKey(GDK_KEY_Down, Gdk::MOD1_MASK), |
263 |
|
sigc::mem_fun(*this, &MainWindow::select_next_dimension)); |
264 |
|
|
265 |
|
actionGroup->add(Gtk::Action::create("SelectAddPrevDimRgnZone", |
266 |
|
_("Add Previous Dimension Region Zone to Selection")), |
267 |
|
Gtk::AccelKey(GDK_KEY_Left, Gdk::MOD1_MASK | Gdk::SHIFT_MASK), |
268 |
|
sigc::mem_fun(*this, &MainWindow::select_add_prev_dim_rgn_zone)); |
269 |
|
|
270 |
|
actionGroup->add(Gtk::Action::create("SelectAddNextDimRgnZone", |
271 |
|
_("Add Next Dimension Region Zone to Selection")), |
272 |
|
Gtk::AccelKey(GDK_KEY_Right, Gdk::MOD1_MASK | Gdk::SHIFT_MASK), |
273 |
|
sigc::mem_fun(*this, &MainWindow::select_add_next_dim_rgn_zone)); |
274 |
|
|
275 |
Glib::RefPtr<Gtk::ToggleAction> toggle_action = |
Glib::RefPtr<Gtk::ToggleAction> toggle_action = |
276 |
Gtk::ToggleAction::create("CopySampleUnity", _("Copy Sample's _Unity Note")); |
Gtk::ToggleAction::create("CopySampleUnity", _("Copy Sample's _Unity Note")); |
277 |
toggle_action->set_active(true); |
toggle_action->set_active(true); |
288 |
actionGroup->add(toggle_action); |
actionGroup->add(toggle_action); |
289 |
|
|
290 |
|
|
291 |
actionGroup->add(Gtk::Action::create("MenuView", _("_View"))); |
actionGroup->add(Gtk::Action::create("MenuMacro", _("_Macro"))); |
292 |
|
|
293 |
|
|
294 |
|
actionGroup->add(Gtk::Action::create("MenuView", _("Vie_w"))); |
295 |
toggle_action = |
toggle_action = |
296 |
Gtk::ToggleAction::create("Statusbar", _("_Statusbar")); |
Gtk::ToggleAction::create("Statusbar", _("_Statusbar")); |
297 |
toggle_action->set_active(true); |
toggle_action->set_active(true); |
298 |
actionGroup->add(toggle_action, |
actionGroup->add(toggle_action, |
299 |
sigc::mem_fun( |
sigc::mem_fun( |
300 |
*this, &MainWindow::on_action_view_status_bar)); |
*this, &MainWindow::on_action_view_status_bar)); |
301 |
|
|
302 |
|
toggle_action = |
303 |
|
Gtk::ToggleAction::create("AutoRestoreWinDim", _("_Auto Restore Window Dimension")); |
304 |
|
toggle_action->set_active(Settings::singleton()->autoRestoreWindowDimension); |
305 |
|
actionGroup->add(toggle_action, |
306 |
|
sigc::mem_fun( |
307 |
|
*this, &MainWindow::on_auto_restore_win_dim)); |
308 |
|
|
309 |
|
toggle_action = |
310 |
|
Gtk::ToggleAction::create("SaveWithTemporaryFile", _("Save with _temporary file")); |
311 |
|
toggle_action->set_active(Settings::singleton()->saveWithTemporaryFile); |
312 |
|
actionGroup->add(toggle_action, |
313 |
|
sigc::mem_fun( |
314 |
|
*this, &MainWindow::on_save_with_temporary_file)); |
315 |
|
|
316 |
actionGroup->add( |
actionGroup->add( |
317 |
Gtk::Action::create("RefreshAll", _("_Refresh All")), |
Gtk::Action::create("RefreshAll", _("_Refresh All")), |
318 |
sigc::mem_fun(*this, &MainWindow::on_action_refresh_all) |
sigc::mem_fun(*this, &MainWindow::on_action_refresh_all) |
356 |
sigc::mem_fun(*this, &MainWindow::on_action_sync_sampler_instrument_selection) |
sigc::mem_fun(*this, &MainWindow::on_action_sync_sampler_instrument_selection) |
357 |
); |
); |
358 |
|
|
359 |
|
toggle_action = |
360 |
|
Gtk::ToggleAction::create("MoveRootNoteWithRegionMoved", _("Move root note with region moved")); |
361 |
|
toggle_action->set_active(Settings::singleton()->moveRootNoteWithRegionMoved); |
362 |
|
actionGroup->add( |
363 |
|
toggle_action, |
364 |
|
sigc::mem_fun(*this, &MainWindow::on_action_move_root_note_with_region_moved) |
365 |
|
); |
366 |
|
|
367 |
|
|
368 |
actionGroup->add(Gtk::Action::create("MenuTools", _("_Tools"))); |
actionGroup->add(Gtk::Action::create("MenuTools", _("_Tools"))); |
369 |
|
|
451 |
" <menuitem action='Quit'/>" |
" <menuitem action='Quit'/>" |
452 |
" </menu>" |
" </menu>" |
453 |
" <menu action='MenuEdit'>" |
" <menu action='MenuEdit'>" |
454 |
|
" <menuitem action='CopyDimRgn'/>" |
455 |
|
" <menuitem action='AdjustClipboard'/>" |
456 |
|
" <menuitem action='PasteDimRgn'/>" |
457 |
|
" <separator/>" |
458 |
|
" <menuitem action='SelectPrevRegion'/>" |
459 |
|
" <menuitem action='SelectNextRegion'/>" |
460 |
|
" <separator/>" |
461 |
|
" <menuitem action='SelectPrevDimension'/>" |
462 |
|
" <menuitem action='SelectNextDimension'/>" |
463 |
|
" <menuitem action='SelectPrevDimRgnZone'/>" |
464 |
|
" <menuitem action='SelectNextDimRgnZone'/>" |
465 |
|
" <menuitem action='SelectAddPrevDimRgnZone'/>" |
466 |
|
" <menuitem action='SelectAddNextDimRgnZone'/>" |
467 |
|
" <separator/>" |
468 |
" <menuitem action='CopySampleUnity'/>" |
" <menuitem action='CopySampleUnity'/>" |
469 |
" <menuitem action='CopySampleTune'/>" |
" <menuitem action='CopySampleTune'/>" |
470 |
" <menuitem action='CopySampleLoop'/>" |
" <menuitem action='CopySampleLoop'/>" |
471 |
" </menu>" |
" </menu>" |
472 |
|
" <menu action='MenuMacro'>" |
473 |
|
" </menu>" |
474 |
" <menu action='MenuSample'>" |
" <menu action='MenuSample'>" |
475 |
" <menuitem action='SampleProperties'/>" |
" <menuitem action='SampleProperties'/>" |
476 |
" <menuitem action='AddGroup'/>" |
" <menuitem action='AddGroup'/>" |
503 |
" </menu>" |
" </menu>" |
504 |
" <menu action='MenuView'>" |
" <menu action='MenuView'>" |
505 |
" <menuitem action='Statusbar'/>" |
" <menuitem action='Statusbar'/>" |
506 |
|
" <menuitem action='AutoRestoreWinDim'/>" |
507 |
" <separator/>" |
" <separator/>" |
508 |
" <menuitem action='RefreshAll'/>" |
" <menuitem action='RefreshAll'/>" |
509 |
" </menu>" |
" </menu>" |
514 |
" <menu action='MenuSettings'>" |
" <menu action='MenuSettings'>" |
515 |
" <menuitem action='WarnUserOnExtensions'/>" |
" <menuitem action='WarnUserOnExtensions'/>" |
516 |
" <menuitem action='SyncSamplerInstrumentSelection'/>" |
" <menuitem action='SyncSamplerInstrumentSelection'/>" |
517 |
|
" <menuitem action='MoveRootNoteWithRegionMoved'/>" |
518 |
|
" <menuitem action='SaveWithTemporaryFile'/>" |
519 |
" </menu>" |
" </menu>" |
520 |
" <menu action='MenuHelp'>" |
" <menu action='MenuHelp'>" |
521 |
" <menuitem action='About'/>" |
" <menuitem action='About'/>" |
584 |
} |
} |
585 |
{ |
{ |
586 |
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
587 |
|
uiManager->get_widget("/MenuBar/MenuSettings/MoveRootNoteWithRegionMoved")); |
588 |
|
item->set_tooltip_text(_("If checked, and when a region is moved by dragging it around on the virtual keyboard, the keybord position dependent pitch will move exactly with the amount of semi tones the region was moved around.")); |
589 |
|
} |
590 |
|
{ |
591 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
592 |
uiManager->get_widget("/MenuBar/MenuSample/RemoveUnusedSamples")); |
uiManager->get_widget("/MenuBar/MenuSample/RemoveUnusedSamples")); |
593 |
item->set_tooltip_text(_("Removes all samples that are not referenced by any instrument (i.e. red ones).")); |
item->set_tooltip_text(_("Removes all samples that are not referenced by any instrument (i.e. red ones).")); |
594 |
// copy tooltip to popup menu |
// copy tooltip to popup menu |
603 |
} |
} |
604 |
{ |
{ |
605 |
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
606 |
|
uiManager->get_widget("/MenuBar/MenuView/AutoRestoreWinDim")); |
607 |
|
item->set_tooltip_text(_("If checked, size and position of all windows will be saved and automatically restored next time.")); |
608 |
|
} |
609 |
|
{ |
610 |
|
Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>( |
611 |
uiManager->get_widget("/MenuBar/MenuTools/CombineInstruments")); |
uiManager->get_widget("/MenuBar/MenuTools/CombineInstruments")); |
612 |
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.")); |
613 |
} |
} |
645 |
// Create the Tree model: |
// Create the Tree model: |
646 |
m_refTreeModel = Gtk::ListStore::create(m_Columns); |
m_refTreeModel = Gtk::ListStore::create(m_Columns); |
647 |
m_TreeView.set_model(m_refTreeModel); |
m_TreeView.set_model(m_refTreeModel); |
648 |
|
m_TreeView.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE); |
649 |
m_TreeView.set_tooltip_text(_("Right click here for actions on instruments & MIDI Rules. Drag & drop to change the order of instruments.")); |
m_TreeView.set_tooltip_text(_("Right click here for actions on instruments & MIDI Rules. Drag & drop to change the order of instruments.")); |
650 |
instrument_name_connection = m_refTreeModel->signal_row_changed().connect( |
instrument_name_connection = m_refTreeModel->signal_row_changed().connect( |
651 |
sigc::mem_fun(*this, &MainWindow::instrument_name_changed) |
sigc::mem_fun(*this, &MainWindow::instrument_name_changed) |
652 |
); |
); |
653 |
|
|
654 |
// Add the TreeView's view columns: |
// Add the TreeView's view columns: |
655 |
m_TreeView.append_column_editable("Instrument", m_Columns.m_col_name); |
m_TreeView.append_column(_("Nr"), m_Columns.m_col_nr); |
656 |
m_TreeView.set_headers_visible(false); |
m_TreeView.append_column_editable(_("Instrument"), m_Columns.m_col_name); |
657 |
|
m_TreeView.append_column(_("Scripts"), m_Columns.m_col_scripts); |
658 |
|
m_TreeView.set_headers_visible(true); |
659 |
|
|
660 |
// establish drag&drop within the instrument tree view, allowing to reorder |
// establish drag&drop within the instrument tree view, allowing to reorder |
661 |
// the sequence of instruments within the gig file |
// the sequence of instruments within the gig file |
678 |
// create samples treeview (including its data model) |
// create samples treeview (including its data model) |
679 |
m_refSamplesTreeModel = SamplesTreeStore::create(m_SamplesModel); |
m_refSamplesTreeModel = SamplesTreeStore::create(m_SamplesModel); |
680 |
m_TreeViewSamples.set_model(m_refSamplesTreeModel); |
m_TreeViewSamples.set_model(m_refSamplesTreeModel); |
681 |
|
m_TreeViewSamples.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE); |
682 |
m_TreeViewSamples.set_tooltip_text(_("To actually use a sample, drag it from this list view to \"Sample\" -> \"Sample:\" on the region's settings pane on the right.\n\nRight click here for more actions on samples.")); |
m_TreeViewSamples.set_tooltip_text(_("To actually use a sample, drag it from this list view to \"Sample\" -> \"Sample:\" on the region's settings pane on the right.\n\nRight click here for more actions on samples.")); |
683 |
// m_TreeViewSamples.set_reorderable(); |
// m_TreeViewSamples.set_reorderable(); |
684 |
m_TreeViewSamples.append_column_editable(_("Name"), m_SamplesModel.m_col_name); |
m_TreeViewSamples.append_column_editable(_("Name"), m_SamplesModel.m_col_name); |
759 |
sigc::hide(sigc::mem_fun(*this, &MainWindow::file_changed))); |
sigc::hide(sigc::mem_fun(*this, &MainWindow::file_changed))); |
760 |
m_RegionChooser.signal_instrument_changed().connect( |
m_RegionChooser.signal_instrument_changed().connect( |
761 |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
762 |
|
m_RegionChooser.signal_instrument_changed().connect( |
763 |
|
sigc::mem_fun(*this, &MainWindow::region_changed)); |
764 |
m_DimRegionChooser.signal_region_changed().connect( |
m_DimRegionChooser.signal_region_changed().connect( |
765 |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
766 |
instrumentProps.signal_changed().connect( |
instrumentProps.signal_changed().connect( |
830 |
|
|
831 |
// select 'Instruments' tab by default |
// select 'Instruments' tab by default |
832 |
// (gtk allows this only if the tab childs are visible, thats why it's here) |
// (gtk allows this only if the tab childs are visible, thats why it's here) |
833 |
m_TreeViewNotebook.set_current_page(1); |
m_TreeViewNotebook.set_current_page(1); |
834 |
|
|
835 |
|
Gtk::Clipboard::get()->signal_owner_change().connect( |
836 |
|
sigc::mem_fun(*this, &MainWindow::on_clipboard_owner_change) |
837 |
|
); |
838 |
|
updateClipboardPasteAvailable(); |
839 |
|
updateClipboardCopyAvailable(); |
840 |
|
|
841 |
|
// setup macros and their keyboard accelerators |
842 |
|
{ |
843 |
|
Gtk::Menu* menuMacro = dynamic_cast<Gtk::MenuItem*>( |
844 |
|
uiManager->get_widget("/MenuBar/MenuMacro") |
845 |
|
)->get_submenu(); |
846 |
|
|
847 |
|
const Gdk::ModifierType primaryModifierKey = |
848 |
|
#if defined(__APPLE__) |
849 |
|
Gdk::META_MASK; // Cmd key on Mac |
850 |
|
#else |
851 |
|
Gdk::CONTROL_MASK; // Ctrl key on all other OSs |
852 |
|
#endif |
853 |
|
|
854 |
|
const Gdk::ModifierType noModifier = (Gdk::ModifierType)0; |
855 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_0", GDK_KEY_F1, noModifier); |
856 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_1", GDK_KEY_F2, noModifier); |
857 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_2", GDK_KEY_F3, noModifier); |
858 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_3", GDK_KEY_F4, noModifier); |
859 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_4", GDK_KEY_F5, noModifier); |
860 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_5", GDK_KEY_F6, noModifier); |
861 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_6", GDK_KEY_F7, noModifier); |
862 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_7", GDK_KEY_F8, noModifier); |
863 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_8", GDK_KEY_F9, noModifier); |
864 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_9", GDK_KEY_F10, noModifier); |
865 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_10", GDK_KEY_F11, noModifier); |
866 |
|
Gtk::AccelMap::add_entry("<Macros>/macro_11", GDK_KEY_F12, noModifier); |
867 |
|
Gtk::AccelMap::add_entry("<Macros>/SetupMacros", 'm', primaryModifierKey); |
868 |
|
|
869 |
|
Glib::RefPtr<Gtk::AccelGroup> accelGroup = this->get_accel_group(); |
870 |
|
menuMacro->set_accel_group(accelGroup); |
871 |
|
|
872 |
|
updateMacroMenu(); |
873 |
|
} |
874 |
} |
} |
875 |
|
|
876 |
MainWindow::~MainWindow() |
MainWindow::~MainWindow() |
877 |
{ |
{ |
878 |
} |
} |
879 |
|
|
880 |
|
void MainWindow::updateMacroMenu() { |
881 |
|
Gtk::Menu* menuMacro = dynamic_cast<Gtk::MenuItem*>( |
882 |
|
uiManager->get_widget("/MenuBar/MenuMacro") |
883 |
|
)->get_submenu(); |
884 |
|
|
885 |
|
// remove all entries from "Macro" menu |
886 |
|
{ |
887 |
|
const std::vector<Gtk::Widget*> children = menuMacro->get_children(); |
888 |
|
for (int i = 0; i < children.size(); ++i) { |
889 |
|
Gtk::Widget* child = children[i]; |
890 |
|
menuMacro->remove(*child); |
891 |
|
delete child; |
892 |
|
} |
893 |
|
} |
894 |
|
|
895 |
|
// (re)load all macros from config file |
896 |
|
try { |
897 |
|
Settings::singleton()->loadMacros(m_macros); |
898 |
|
} catch (Serialization::Exception e) { |
899 |
|
std::cerr << "Exception while loading macros: " << e.Message << std::endl; |
900 |
|
} catch (...) { |
901 |
|
std::cerr << "Unknown exception while loading macros!" << std::endl; |
902 |
|
} |
903 |
|
|
904 |
|
// add all configured macros as menu items to the "Macro" menu |
905 |
|
for (int iMacro = 0; iMacro < m_macros.size(); ++iMacro) { |
906 |
|
const Serialization::Archive& macro = m_macros[iMacro]; |
907 |
|
std::string name = |
908 |
|
macro.name().empty() ? |
909 |
|
(std::string(_("Unnamed Macro")) + " " + ToString(iMacro+1)) : macro.name(); |
910 |
|
Gtk::MenuItem* item = new Gtk::MenuItem(name); |
911 |
|
item->signal_activate().connect( |
912 |
|
sigc::bind( |
913 |
|
sigc::mem_fun(*this, &MainWindow::onMacroSelected), iMacro |
914 |
|
) |
915 |
|
); |
916 |
|
menuMacro->append(*item); |
917 |
|
item->set_accel_path("<Macros>/macro_" + ToString(iMacro)); |
918 |
|
Glib::ustring comment = macro.comment(); |
919 |
|
if (!comment.empty()) |
920 |
|
item->set_tooltip_text(comment); |
921 |
|
} |
922 |
|
// if there are no macros configured at all, then show a dummy entry instead |
923 |
|
if (m_macros.empty()) { |
924 |
|
Gtk::MenuItem* item = new Gtk::MenuItem(_("No Macros")); |
925 |
|
item->set_sensitive(false); |
926 |
|
menuMacro->append(*item); |
927 |
|
} |
928 |
|
|
929 |
|
// add separator line to menu |
930 |
|
menuMacro->append(*new Gtk::SeparatorMenuItem); |
931 |
|
|
932 |
|
{ |
933 |
|
Gtk::MenuItem* item = new Gtk::MenuItem(_("Setup Macros ...")); |
934 |
|
item->signal_activate().connect( |
935 |
|
sigc::mem_fun(*this, &MainWindow::setupMacros) |
936 |
|
); |
937 |
|
menuMacro->append(*item); |
938 |
|
item->set_accel_path("<Macros>/SetupMacros"); |
939 |
|
} |
940 |
|
|
941 |
|
menuMacro->show_all_children(); |
942 |
|
} |
943 |
|
|
944 |
|
void MainWindow::onMacroSelected(int iMacro) { |
945 |
|
printf("onMacroSelected(%d)\n", iMacro); |
946 |
|
if (iMacro < 0 || iMacro >= m_macros.size()) return; |
947 |
|
Glib::ustring errorText; |
948 |
|
try { |
949 |
|
applyMacro(m_macros[iMacro]); |
950 |
|
} catch (Serialization::Exception e) { |
951 |
|
errorText = e.Message; |
952 |
|
} catch (...) { |
953 |
|
errorText = _("Unknown exception while applying macro"); |
954 |
|
} |
955 |
|
if (!errorText.empty()) { |
956 |
|
Glib::ustring txt = _("Applying macro failed:\n") + errorText; |
957 |
|
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
958 |
|
msg.run(); |
959 |
|
} |
960 |
|
} |
961 |
|
|
962 |
|
void MainWindow::setupMacros() { |
963 |
|
MacrosSetup* setup = new MacrosSetup(); |
964 |
|
gig::DimensionRegion* pDimRgn = m_DimRegionChooser.get_main_dimregion(); |
965 |
|
setup->setMacros(m_macros, &m_serializationArchive, pDimRgn); |
966 |
|
setup->signal_macros_changed().connect( |
967 |
|
sigc::mem_fun(*this, &MainWindow::onMacrosSetupChanged) |
968 |
|
); |
969 |
|
setup->show(); |
970 |
|
} |
971 |
|
|
972 |
|
void MainWindow::onMacrosSetupChanged(const std::vector<Serialization::Archive>& macros) { |
973 |
|
m_macros = macros; |
974 |
|
Settings::singleton()->saveMacros(m_macros); |
975 |
|
updateMacroMenu(); |
976 |
|
} |
977 |
|
|
978 |
bool MainWindow::on_delete_event(GdkEventAny* event) |
bool MainWindow::on_delete_event(GdkEventAny* event) |
979 |
{ |
{ |
980 |
return !file_is_shared && file_is_changed && !close_confirmation_dialog(); |
return !file_is_shared && file_is_changed && !close_confirmation_dialog(); |
994 |
gig::Instrument* MainWindow::get_instrument() |
gig::Instrument* MainWindow::get_instrument() |
995 |
{ |
{ |
996 |
gig::Instrument* instrument = 0; |
gig::Instrument* instrument = 0; |
997 |
Gtk::TreeModel::const_iterator it = |
std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows(); |
998 |
m_TreeView.get_selection()->get_selected(); |
if (rows.empty()) return NULL; |
999 |
|
Gtk::TreeModel::const_iterator it = m_refTreeModel->get_iter(rows[0]); |
1000 |
if (it) { |
if (it) { |
1001 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
1002 |
instrument = row[m_Columns.m_col_instr]; |
instrument = row[m_Columns.m_col_instr]; |
1039 |
add_region_to_dimregs(region, stereo, all_dimregs); |
add_region_to_dimregs(region, stereo, all_dimregs); |
1040 |
} |
} |
1041 |
} |
} |
1042 |
|
|
1043 |
|
m_RegionChooser.setModifyAllRegions(all_regions); |
1044 |
|
m_DimRegionChooser.setModifyAllRegions(all_regions); |
1045 |
|
m_DimRegionChooser.setModifyAllDimensionRegions(all_dimregs); |
1046 |
|
m_DimRegionChooser.setModifyBothChannels(stereo); |
1047 |
|
|
1048 |
|
updateClipboardCopyAvailable(); |
1049 |
} |
} |
1050 |
|
|
1051 |
void MainWindow::dimreg_all_dimregs_toggled() |
void MainWindow::dimreg_all_dimregs_toggled() |
1063 |
void MainWindow::on_sel_change() |
void MainWindow::on_sel_change() |
1064 |
{ |
{ |
1065 |
// select item in instrument menu |
// select item in instrument menu |
1066 |
Gtk::TreeModel::iterator it = m_TreeView.get_selection()->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows(); |
1067 |
if (it) { |
if (!rows.empty()) { |
1068 |
Gtk::TreePath path(it); |
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); |
1069 |
int index = path[0]; |
if (it) { |
1070 |
const std::vector<Gtk::Widget*> children = |
Gtk::TreePath path(it); |
1071 |
instrument_menu->get_children(); |
int index = path[0]; |
1072 |
static_cast<Gtk::RadioMenuItem*>(children[index])->set_active(); |
const std::vector<Gtk::Widget*> children = |
1073 |
|
instrument_menu->get_children(); |
1074 |
|
static_cast<Gtk::RadioMenuItem*>(children[index])->set_active(); |
1075 |
|
} |
1076 |
} |
} |
1077 |
|
|
1078 |
m_RegionChooser.set_instrument(get_instrument()); |
m_RegionChooser.set_instrument(get_instrument()); |
1097 |
progress_dispatcher(); |
progress_dispatcher(); |
1098 |
} |
} |
1099 |
|
|
1100 |
|
#if defined(WIN32) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) |
1101 |
|
// make sure stack is 16-byte aligned for SSE instructions |
1102 |
|
__attribute__((force_align_arg_pointer)) |
1103 |
|
#endif |
1104 |
void Loader::thread_function() |
void Loader::thread_function() |
1105 |
{ |
{ |
1106 |
printf("thread_function self=%x\n", Glib::Threads::Thread::self()); |
printf("thread_function self=%p\n", |
1107 |
|
static_cast<void*>(Glib::Threads::Thread::self())); |
1108 |
printf("Start %s\n", filename.c_str()); |
printf("Start %s\n", filename.c_str()); |
1109 |
try { |
try { |
1110 |
RIFF::File* riff = new RIFF::File(filename); |
RIFF::File* riff = new RIFF::File(filename); |
1126 |
} |
} |
1127 |
|
|
1128 |
Loader::Loader(const char* filename) |
Loader::Loader(const char* filename) |
1129 |
: filename(filename), thread(0), progress(0.f) |
: filename(filename), gig(0), thread(0), progress(0.f) |
1130 |
{ |
{ |
1131 |
} |
} |
1132 |
|
|
1137 |
#else |
#else |
1138 |
thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Loader::thread_function)); |
thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Loader::thread_function)); |
1139 |
#endif |
#endif |
1140 |
printf("launch thread=%x\n", thread); |
printf("launch thread=%p\n", static_cast<void*>(thread)); |
1141 |
} |
} |
1142 |
|
|
1143 |
float Loader::get_progress() |
float Loader::get_progress() |
1180 |
progress_dispatcher.emit(); |
progress_dispatcher.emit(); |
1181 |
} |
} |
1182 |
|
|
1183 |
|
#if defined(WIN32) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) |
1184 |
|
// make sure stack is 16-byte aligned for SSE instructions |
1185 |
|
__attribute__((force_align_arg_pointer)) |
1186 |
|
#endif |
1187 |
void Saver::thread_function() |
void Saver::thread_function() |
1188 |
{ |
{ |
1189 |
printf("thread_function self=%x\n", Glib::Threads::Thread::self()); |
printf("thread_function self=%p\n", |
1190 |
|
static_cast<void*>(Glib::Threads::Thread::self())); |
1191 |
printf("Start %s\n", filename.c_str()); |
printf("Start %s\n", filename.c_str()); |
1192 |
try { |
try { |
1193 |
gig::progress_t progress; |
gig::progress_t progress; |
1196 |
|
|
1197 |
// if no filename was provided, that means "save", if filename was provided means "save as" |
// if no filename was provided, that means "save", if filename was provided means "save as" |
1198 |
if (filename.empty()) { |
if (filename.empty()) { |
1199 |
gig->Save(&progress); |
if (!Settings::singleton()->saveWithTemporaryFile) { |
1200 |
|
// save directly over the existing .gig file |
1201 |
|
// (requires less disk space than solution below |
1202 |
|
// but may be slower) |
1203 |
|
gig->Save(&progress); |
1204 |
|
} else { |
1205 |
|
// save the file as separate temporary file first, |
1206 |
|
// then move the saved file over the old file |
1207 |
|
// (may result in performance speedup during save) |
1208 |
|
gig::String tmpname = filename + ".TMP"; |
1209 |
|
gig->Save(tmpname, &progress); |
1210 |
|
#if defined(WIN32) |
1211 |
|
if (!DeleteFile(filename.c_str())) { |
1212 |
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file)."); |
1213 |
|
} |
1214 |
|
#else // POSIX ... |
1215 |
|
if (unlink(filename.c_str())) { |
1216 |
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to remove original file): " + gig::String(strerror(errno))); |
1217 |
|
} |
1218 |
|
#endif |
1219 |
|
if (rename(tmpname.c_str(), filename.c_str())) { |
1220 |
|
#if defined(WIN32) |
1221 |
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file)."); |
1222 |
|
#else |
1223 |
|
throw RIFF::Exception("Could not replace original file with temporary file (unable to rename temp file): " + gig::String(strerror(errno))); |
1224 |
|
#endif |
1225 |
|
} |
1226 |
|
} |
1227 |
} else { |
} else { |
1228 |
gig->Save(filename, &progress); |
gig->Save(filename, &progress); |
1229 |
} |
} |
1251 |
#else |
#else |
1252 |
thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Saver::thread_function)); |
thread = Glib::Threads::Thread::create(sigc::mem_fun(*this, &Saver::thread_function)); |
1253 |
#endif |
#endif |
1254 |
printf("launch thread=%x\n", thread); |
printf("launch thread=%p\n", static_cast<void*>(thread)); |
1255 |
} |
} |
1256 |
|
|
1257 |
float Saver::get_progress() |
float Saver::get_progress() |
1411 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
1412 |
std::string filename = dialog.get_filename(); |
std::string filename = dialog.get_filename(); |
1413 |
printf("filename=%s\n", filename.c_str()); |
printf("filename=%s\n", filename.c_str()); |
1414 |
printf("on_action_file_open self=%x\n", Glib::Threads::Thread::self()); |
printf("on_action_file_open self=%p\n", |
1415 |
|
static_cast<void*>(Glib::Threads::Thread::self())); |
1416 |
load_file(filename.c_str()); |
load_file(filename.c_str()); |
1417 |
current_gig_dir = Glib::path_get_dirname(filename); |
current_gig_dir = Glib::path_get_dirname(filename); |
1418 |
} |
} |
1482 |
void MainWindow::on_loader_finished() |
void MainWindow::on_loader_finished() |
1483 |
{ |
{ |
1484 |
printf("Loader finished!\n"); |
printf("Loader finished!\n"); |
1485 |
printf("on_loader_finished self=%x\n", Glib::Threads::Thread::self()); |
printf("on_loader_finished self=%p\n", |
1486 |
|
static_cast<void*>(Glib::Threads::Thread::self())); |
1487 |
load_gig(loader->gig, loader->filename.c_str()); |
load_gig(loader->gig, loader->filename.c_str()); |
1488 |
progress_dialog->hide(); |
progress_dialog->hide(); |
1489 |
} |
} |
1623 |
// show warning in the dialog |
// show warning in the dialog |
1624 |
Gtk::HBox descriptionArea; |
Gtk::HBox descriptionArea; |
1625 |
descriptionArea.set_spacing(15); |
descriptionArea.set_spacing(15); |
1626 |
Gtk::Image warningIcon(Gtk::Stock::DIALOG_WARNING, Gtk::IconSize(Gtk::ICON_SIZE_DIALOG)); |
Gtk::Image warningIcon; |
1627 |
|
warningIcon.set_from_icon_name("dialog-warning", |
1628 |
|
Gtk::IconSize(Gtk::ICON_SIZE_DIALOG)); |
1629 |
descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK); |
descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK); |
1630 |
#if GTKMM_MAJOR_VERSION < 3 |
#if GTKMM_MAJOR_VERSION < 3 |
1631 |
view::WrapLabel description; |
view::WrapLabel description; |
1677 |
void MainWindow::__import_queued_samples() { |
void MainWindow::__import_queued_samples() { |
1678 |
std::cout << "Starting sample import\n" << std::flush; |
std::cout << "Starting sample import\n" << std::flush; |
1679 |
Glib::ustring error_files; |
Glib::ustring error_files; |
1680 |
printf("Samples to import: %d\n", m_SampleImportQueue.size()); |
printf("Samples to import: %d\n", int(m_SampleImportQueue.size())); |
1681 |
for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
for (std::map<gig::Sample*, SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
1682 |
iter != m_SampleImportQueue.end(); ) { |
iter != m_SampleImportQueue.end(); ) { |
1683 |
printf("Importing sample %s\n",(*iter).sample_path.c_str()); |
printf("Importing sample %s\n",iter->second.sample_path.c_str()); |
1684 |
SF_INFO info; |
SF_INFO info; |
1685 |
info.format = 0; |
info.format = 0; |
1686 |
SNDFILE* hFile = sf_open((*iter).sample_path.c_str(), SFM_READ, &info); |
SNDFILE* hFile = sf_open(iter->second.sample_path.c_str(), SFM_READ, &info); |
1687 |
sf_command(hFile, SFC_SET_SCALE_FLOAT_INT_READ, 0, SF_TRUE); |
sf_command(hFile, SFC_SET_SCALE_FLOAT_INT_READ, 0, SF_TRUE); |
1688 |
try { |
try { |
1689 |
if (!hFile) throw std::string(_("could not open file")); |
if (!hFile) throw std::string(_("could not open file")); |
1706 |
throw std::string(_("format not supported")); // unsupported subformat (yet?) |
throw std::string(_("format not supported")); // unsupported subformat (yet?) |
1707 |
} |
} |
1708 |
|
|
1709 |
|
// reset write position for sample |
1710 |
|
iter->first->SetPos(0); |
1711 |
|
|
1712 |
const int bufsize = 10000; |
const int bufsize = 10000; |
1713 |
switch (bitdepth) { |
switch (bitdepth) { |
1714 |
case 16: { |
case 16: { |
1718 |
// libsndfile does the conversion for us (if needed) |
// libsndfile does the conversion for us (if needed) |
1719 |
int n = sf_readf_short(hFile, buffer, bufsize); |
int n = sf_readf_short(hFile, buffer, bufsize); |
1720 |
// write from buffer directly (physically) into .gig file |
// write from buffer directly (physically) into .gig file |
1721 |
iter->gig_sample->Write(buffer, n); |
iter->first->Write(buffer, n); |
1722 |
cnt -= n; |
cnt -= n; |
1723 |
} |
} |
1724 |
delete[] buffer; |
delete[] buffer; |
1738 |
dstbuf[j++] = srcbuf[i] >> 24; |
dstbuf[j++] = srcbuf[i] >> 24; |
1739 |
} |
} |
1740 |
// write from buffer directly (physically) into .gig file |
// write from buffer directly (physically) into .gig file |
1741 |
iter->gig_sample->Write(dstbuf, n); |
iter->first->Write(dstbuf, n); |
1742 |
cnt -= n; |
cnt -= n; |
1743 |
} |
} |
1744 |
delete[] srcbuf; |
delete[] srcbuf; |
1749 |
// cleanup |
// cleanup |
1750 |
sf_close(hFile); |
sf_close(hFile); |
1751 |
// let the sampler re-cache the sample if needed |
// let the sampler re-cache the sample if needed |
1752 |
sample_changed_signal.emit(iter->gig_sample); |
sample_changed_signal.emit(iter->first); |
1753 |
// on success we remove the sample from the import queue, |
// on success we remove the sample from the import queue, |
1754 |
// otherwise keep it, maybe it works the next time ? |
// otherwise keep it, maybe it works the next time ? |
1755 |
std::list<SampleImportItem>::iterator cur = iter; |
std::map<gig::Sample*, SampleImportItem>::iterator cur = iter; |
1756 |
++iter; |
++iter; |
1757 |
m_SampleImportQueue.erase(cur); |
m_SampleImportQueue.erase(cur); |
1758 |
} catch (std::string what) { |
} catch (std::string what) { |
1759 |
// remember the files that made trouble (and their cause) |
// remember the files that made trouble (and their cause) |
1760 |
if (!error_files.empty()) error_files += "\n"; |
if (!error_files.empty()) error_files += "\n"; |
1761 |
error_files += (*iter).sample_path += " (" + what + ")"; |
error_files += iter->second.sample_path += " (" + what + ")"; |
1762 |
++iter; |
++iter; |
1763 |
} |
} |
1764 |
} |
} |
1786 |
!Settings::singleton()->syncSamplerInstrumentSelection; |
!Settings::singleton()->syncSamplerInstrumentSelection; |
1787 |
} |
} |
1788 |
|
|
1789 |
|
void MainWindow::on_action_move_root_note_with_region_moved() { |
1790 |
|
Settings::singleton()->moveRootNoteWithRegionMoved = |
1791 |
|
!Settings::singleton()->moveRootNoteWithRegionMoved; |
1792 |
|
} |
1793 |
|
|
1794 |
void MainWindow::on_action_help_about() |
void MainWindow::on_action_help_about() |
1795 |
{ |
{ |
1796 |
Gtk::AboutDialog dialog; |
Gtk::AboutDialog dialog; |
1800 |
dialog.set_name("Gigedit"); |
dialog.set_name("Gigedit"); |
1801 |
#endif |
#endif |
1802 |
dialog.set_version(VERSION); |
dialog.set_version(VERSION); |
1803 |
dialog.set_copyright("Copyright (C) 2006-2015 Andreas Persson"); |
dialog.set_copyright("Copyright (C) 2006-2017 Andreas Persson"); |
1804 |
const std::string sComment = |
const std::string sComment = |
1805 |
_("Built " __DATE__ "\nUsing ") + |
_("Built " __DATE__ "\nUsing ") + |
1806 |
::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" + |
::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" + |
2095 |
propDialog.set_info(gig->pInfo); |
propDialog.set_info(gig->pInfo); |
2096 |
|
|
2097 |
instrument_name_connection.block(); |
instrument_name_connection.block(); |
2098 |
|
int index = 0; |
2099 |
for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ; |
for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ; |
2100 |
instrument = gig->GetNextInstrument()) { |
instrument = gig->GetNextInstrument(), ++index) { |
2101 |
Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
Glib::ustring name(gig_to_utf8(instrument->pInfo->Name)); |
2102 |
|
const int iScriptSlots = instrument->ScriptSlotCount(); |
2103 |
|
|
2104 |
Gtk::TreeModel::iterator iter = m_refTreeModel->append(); |
Gtk::TreeModel::iterator iter = m_refTreeModel->append(); |
2105 |
Gtk::TreeModel::Row row = *iter; |
Gtk::TreeModel::Row row = *iter; |
2106 |
|
row[m_Columns.m_col_nr] = index; |
2107 |
row[m_Columns.m_col_name] = name; |
row[m_Columns.m_col_name] = name; |
2108 |
row[m_Columns.m_col_instr] = instrument; |
row[m_Columns.m_col_instr] = instrument; |
2109 |
|
row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : ""; |
2110 |
|
|
2111 |
add_instrument_to_menu(name); |
add_instrument_to_menu(name); |
2112 |
} |
} |
2177 |
{ |
{ |
2178 |
instrumentProps.signal_name_changed().clear(); |
instrumentProps.signal_name_changed().clear(); |
2179 |
|
|
2180 |
Gtk::TreeModel::const_iterator it = |
std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows(); |
2181 |
m_TreeView.get_selection()->get_selected(); |
if (rows.empty()) { |
2182 |
|
instrumentProps.hide(); |
2183 |
|
return false; |
2184 |
|
} |
2185 |
|
Gtk::TreeModel::const_iterator it = m_refTreeModel->get_iter(rows[0]); |
2186 |
if (it) { |
if (it) { |
2187 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
2188 |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
2235 |
void MainWindow::show_script_slots() { |
void MainWindow::show_script_slots() { |
2236 |
if (!file) return; |
if (!file) return; |
2237 |
// get selected instrument |
// get selected instrument |
2238 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
std::vector<Gtk::TreeModel::Path> rows = m_TreeView.get_selection()->get_selected_rows(); |
2239 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
if (rows.empty()) return; |
2240 |
|
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); |
2241 |
if (!it) return; |
if (!it) return; |
2242 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
2243 |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
gig::Instrument* instrument = row[m_Columns.m_col_instr]; |
2245 |
|
|
2246 |
ScriptSlots* window = new ScriptSlots; |
ScriptSlots* window = new ScriptSlots; |
2247 |
window->setInstrument(instrument); |
window->setInstrument(instrument); |
2248 |
|
window->signal_script_slots_changed().connect( |
2249 |
|
sigc::mem_fun(*this, &MainWindow::onScriptSlotsModified) |
2250 |
|
); |
2251 |
//window->reparent(*this); |
//window->reparent(*this); |
2252 |
window->show(); |
window->show(); |
2253 |
} |
} |
2254 |
|
|
2255 |
|
void MainWindow::onScriptSlotsModified(gig::Instrument* pInstrument) { |
2256 |
|
if (!pInstrument) return; |
2257 |
|
const int iScriptSlots = pInstrument->ScriptSlotCount(); |
2258 |
|
|
2259 |
|
Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model(); |
2260 |
|
for (int i = 0; i < model->children().size(); ++i) { |
2261 |
|
Gtk::TreeModel::Row row = model->children()[i]; |
2262 |
|
if (row[m_Columns.m_col_instr] != pInstrument) continue; |
2263 |
|
row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : ""; |
2264 |
|
break; |
2265 |
|
} |
2266 |
|
} |
2267 |
|
|
2268 |
void MainWindow::on_action_refresh_all() { |
void MainWindow::on_action_refresh_all() { |
2269 |
__refreshEntireGUI(); |
__refreshEntireGUI(); |
2270 |
} |
} |
2280 |
else m_StatusBar.hide(); |
else m_StatusBar.hide(); |
2281 |
} |
} |
2282 |
|
|
2283 |
|
void MainWindow::on_auto_restore_win_dim() { |
2284 |
|
Gtk::CheckMenuItem* item = |
2285 |
|
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/AutoRestoreWinDim")); |
2286 |
|
if (!item) { |
2287 |
|
std::cerr << "/MenuBar/MenuView/AutoRestoreWinDim == NULL\n"; |
2288 |
|
return; |
2289 |
|
} |
2290 |
|
Settings::singleton()->autoRestoreWindowDimension = item->get_active(); |
2291 |
|
} |
2292 |
|
|
2293 |
|
void MainWindow::on_save_with_temporary_file() { |
2294 |
|
Gtk::CheckMenuItem* item = |
2295 |
|
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuSettings/SaveWithTemporaryFile")); |
2296 |
|
if (!item) { |
2297 |
|
std::cerr << "/MenuBar/MenuSettings/SaveWithTemporaryFile == NULL\n"; |
2298 |
|
return; |
2299 |
|
} |
2300 |
|
Settings::singleton()->saveWithTemporaryFile = item->get_active(); |
2301 |
|
} |
2302 |
|
|
2303 |
bool MainWindow::is_copy_samples_unity_note_enabled() const { |
bool MainWindow::is_copy_samples_unity_note_enabled() const { |
2304 |
Gtk::CheckMenuItem* item = |
Gtk::CheckMenuItem* item = |
2305 |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity")); |
dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity")); |
2373 |
if (row[m_Columns.m_col_instr] == instrument) { |
if (row[m_Columns.m_col_instr] == instrument) { |
2374 |
// select and show the respective instrument in the list view |
// select and show the respective instrument in the list view |
2375 |
show_intruments_tab(); |
show_intruments_tab(); |
2376 |
|
m_TreeView.get_selection()->unselect_all(); |
2377 |
m_TreeView.get_selection()->select(model->children()[i]); |
m_TreeView.get_selection()->select(model->children()[i]); |
2378 |
Gtk::TreePath path( |
std::vector<Gtk::TreeModel::Path> rows = |
2379 |
m_TreeView.get_selection()->get_selected() |
m_TreeView.get_selection()->get_selected_rows(); |
2380 |
); |
if (!rows.empty()) |
2381 |
m_TreeView.scroll_to_row(path); |
m_TreeView.scroll_to_row(rows[0]); |
2382 |
on_sel_change(); // the regular instrument selection change callback |
on_sel_change(); // the regular instrument selection change callback |
2383 |
} |
} |
2384 |
} |
} |
2395 |
if (row[m_Columns.m_col_instr] == pInstrument) { |
if (row[m_Columns.m_col_instr] == pInstrument) { |
2396 |
// select and show the respective instrument in the list view |
// select and show the respective instrument in the list view |
2397 |
show_intruments_tab(); |
show_intruments_tab(); |
2398 |
|
m_TreeView.get_selection()->unselect_all(); |
2399 |
m_TreeView.get_selection()->select(model->children()[i]); |
m_TreeView.get_selection()->select(model->children()[i]); |
2400 |
Gtk::TreePath path( |
std::vector<Gtk::TreeModel::Path> rows = |
2401 |
m_TreeView.get_selection()->get_selected() |
m_TreeView.get_selection()->get_selected_rows(); |
2402 |
); |
if (!rows.empty()) |
2403 |
m_TreeView.scroll_to_row(path); |
m_TreeView.scroll_to_row(rows[0]); |
2404 |
on_sel_change(); // the regular instrument selection change callback |
on_sel_change(); // the regular instrument selection change callback |
2405 |
|
|
2406 |
// select respective region in the region selector |
// select respective region in the region selector |
2426 |
Gtk::TreeModel::Row rowSample = rowGroup.children()[s]; |
Gtk::TreeModel::Row rowSample = rowGroup.children()[s]; |
2427 |
if (rowSample[m_SamplesModel.m_col_sample] == sample) { |
if (rowSample[m_SamplesModel.m_col_sample] == sample) { |
2428 |
show_samples_tab(); |
show_samples_tab(); |
2429 |
|
m_TreeViewSamples.get_selection()->unselect_all(); |
2430 |
m_TreeViewSamples.get_selection()->select(rowGroup.children()[s]); |
m_TreeViewSamples.get_selection()->select(rowGroup.children()[s]); |
2431 |
Gtk::TreePath path( |
std::vector<Gtk::TreeModel::Path> rows = |
2432 |
m_TreeViewSamples.get_selection()->get_selected() |
m_TreeViewSamples.get_selection()->get_selected_rows(); |
2433 |
); |
if (rows.empty()) return; |
2434 |
m_TreeViewSamples.scroll_to_row(path); |
m_TreeViewSamples.scroll_to_row(rows[0]); |
2435 |
return; |
return; |
2436 |
} |
} |
2437 |
} |
} |
2440 |
|
|
2441 |
void MainWindow::on_sample_treeview_button_release(GdkEventButton* button) { |
void MainWindow::on_sample_treeview_button_release(GdkEventButton* button) { |
2442 |
if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
if (button->type == GDK_BUTTON_PRESS && button->button == 3) { |
2443 |
|
// by default if Ctrl keys is pressed down, then a mouse right-click |
2444 |
|
// does not select the respective row, so we must assure this |
2445 |
|
// programmatically ... |
2446 |
|
/*{ |
2447 |
|
Gtk::TreeModel::Path path; |
2448 |
|
Gtk::TreeViewColumn* pColumn = NULL; |
2449 |
|
int cellX, cellY; |
2450 |
|
bool bSuccess = m_TreeViewSamples.get_path_at_pos( |
2451 |
|
(int)button->x, (int)button->y, |
2452 |
|
path, pColumn, cellX, cellY |
2453 |
|
); |
2454 |
|
if (bSuccess) { |
2455 |
|
if (m_TreeViewSamples.get_selection()->count_selected_rows() <= 0) { |
2456 |
|
printf("not selected !!!\n"); |
2457 |
|
m_TreeViewSamples.get_selection()->select(path); |
2458 |
|
} |
2459 |
|
} |
2460 |
|
}*/ |
2461 |
|
|
2462 |
Gtk::Menu* sample_popup = |
Gtk::Menu* sample_popup = |
2463 |
dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/SamplePopupMenu")); |
dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/SamplePopupMenu")); |
2464 |
// update enabled/disabled state of sample popup items |
// update enabled/disabled state of sample popup items |
2465 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
2466 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
2467 |
bool group_selected = false; |
const int n = rows.size(); |
2468 |
bool sample_selected = false; |
int nGroups = 0; |
2469 |
if (it) { |
int nSamples = 0; |
2470 |
|
for (int r = 0; r < n; ++r) { |
2471 |
|
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[r]); |
2472 |
|
if (!it) continue; |
2473 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
2474 |
group_selected = row[m_SamplesModel.m_col_group]; |
if (row[m_SamplesModel.m_col_group]) nGroups++; |
2475 |
sample_selected = row[m_SamplesModel.m_col_sample]; |
if (row[m_SamplesModel.m_col_sample]) nSamples++; |
2476 |
} |
} |
2477 |
|
|
|
|
|
2478 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/SampleProperties"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/SampleProperties"))-> |
2479 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(n == 1); |
2480 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddSample"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddSample"))-> |
2481 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(n); |
2482 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddGroup"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/AddGroup"))-> |
2483 |
set_sensitive(file); |
set_sensitive(file); |
2484 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/ShowSampleRefs"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/ShowSampleRefs"))-> |
2485 |
set_sensitive(sample_selected); |
set_sensitive(nSamples == 1); |
2486 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/RemoveSample"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/SamplePopupMenu/RemoveSample"))-> |
2487 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(n); |
2488 |
// show sample popup |
// show sample popup |
2489 |
sample_popup->popup(button->button, button->time); |
sample_popup->popup(button->button, button->time); |
2490 |
|
|
2491 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/SampleProperties"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/SampleProperties"))-> |
2492 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(n == 1); |
2493 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddSample"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddSample"))-> |
2494 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(n); |
2495 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddGroup"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/AddGroup"))-> |
2496 |
set_sensitive(file); |
set_sensitive(file); |
2497 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/ShowSampleRefs"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/ShowSampleRefs"))-> |
2498 |
set_sensitive(sample_selected); |
set_sensitive(nSamples == 1); |
2499 |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/RemoveSample"))-> |
dynamic_cast<Gtk::MenuItem*>(uiManager->get_widget("/MenuBar/MenuSample/RemoveSample"))-> |
2500 |
set_sensitive(group_selected || sample_selected); |
set_sensitive(n); |
2501 |
} |
} |
2502 |
} |
} |
2503 |
|
|
2576 |
instrument_name_connection.block(); |
instrument_name_connection.block(); |
2577 |
Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append(); |
Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append(); |
2578 |
Gtk::TreeModel::Row rowInstr = *iterInstr; |
Gtk::TreeModel::Row rowInstr = *iterInstr; |
2579 |
|
rowInstr[m_Columns.m_col_nr] = m_refTreeModel->children().size() - 1; |
2580 |
rowInstr[m_Columns.m_col_name] = name; |
rowInstr[m_Columns.m_col_name] = name; |
2581 |
rowInstr[m_Columns.m_col_instr] = instrument; |
rowInstr[m_Columns.m_col_instr] = instrument; |
2582 |
|
rowInstr[m_Columns.m_col_scripts] = ""; |
2583 |
instrument_name_connection.unblock(); |
instrument_name_connection.unblock(); |
2584 |
|
|
2585 |
add_instrument_to_menu(name); |
add_instrument_to_menu(name); |
2606 |
// retrieve the currently selected instrument |
// retrieve the currently selected instrument |
2607 |
// (being the original instrument to be duplicated) |
// (being the original instrument to be duplicated) |
2608 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
2609 |
Gtk::TreeModel::iterator itSelection = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
2610 |
if (!itSelection) return; |
for (int r = 0; r < rows.size(); ++r) { |
2611 |
Gtk::TreeModel::Row row = *itSelection; |
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]); |
2612 |
gig::Instrument* instrOrig = row[m_Columns.m_col_instr]; |
if (it) { |
2613 |
if (!instrOrig) return; |
Gtk::TreeModel::Row row = *it; |
2614 |
|
gig::Instrument* instrOrig = row[m_Columns.m_col_instr]; |
2615 |
// duplicate the orginal instrument |
if (instrOrig) { |
2616 |
gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig); |
// duplicate the orginal instrument |
2617 |
instrNew->pInfo->Name = |
gig::Instrument* instrNew = file->AddDuplicateInstrument(instrOrig); |
2618 |
instrOrig->pInfo->Name + |
instrNew->pInfo->Name = |
2619 |
gig_from_utf8(Glib::ustring(" (") + _("Copy") + ")"); |
instrOrig->pInfo->Name + |
2620 |
|
gig_from_utf8(Glib::ustring(" (") + _("Copy") + ")"); |
2621 |
|
|
2622 |
add_instrument(instrNew); |
add_instrument(instrNew); |
2623 |
|
} |
2624 |
|
} |
2625 |
|
} |
2626 |
} |
} |
2627 |
|
|
2628 |
void MainWindow::on_action_remove_instrument() { |
void MainWindow::on_action_remove_instrument() { |
2639 |
} |
} |
2640 |
|
|
2641 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
2642 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
2643 |
if (it) { |
for (int r = rows.size() - 1; r >= 0; --r) { |
2644 |
|
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[r]); |
2645 |
|
if (!it) continue; |
2646 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
2647 |
gig::Instrument* instr = row[m_Columns.m_col_instr]; |
gig::Instrument* instr = row[m_Columns.m_col_instr]; |
2648 |
try { |
try { |
2657 |
|
|
2658 |
// remove row from instruments tree view |
// remove row from instruments tree view |
2659 |
m_refTreeModel->erase(it); |
m_refTreeModel->erase(it); |
2660 |
|
// update "Nr" column of all instrument rows |
2661 |
|
{ |
2662 |
|
int index = 0; |
2663 |
|
for (Gtk::TreeModel::iterator it = m_refTreeModel->children().begin(); |
2664 |
|
it != m_refTreeModel->children().end(); ++it, ++index) |
2665 |
|
{ |
2666 |
|
Gtk::TreeModel::Row row = *it; |
2667 |
|
row[m_Columns.m_col_nr] = index; |
2668 |
|
} |
2669 |
|
} |
2670 |
|
|
2671 |
#if GTKMM_MAJOR_VERSION < 3 |
#if GTKMM_MAJOR_VERSION < 3 |
2672 |
// select another instrument (in gtk3 this is done |
// select another instrument (in gtk3 this is done |
2764 |
if (!script) return; |
if (!script) return; |
2765 |
|
|
2766 |
ScriptEditor* editor = new ScriptEditor; |
ScriptEditor* editor = new ScriptEditor; |
2767 |
|
editor->signal_script_to_be_changed.connect( |
2768 |
|
signal_script_to_be_changed.make_slot() |
2769 |
|
); |
2770 |
|
editor->signal_script_changed.connect( |
2771 |
|
signal_script_changed.make_slot() |
2772 |
|
); |
2773 |
editor->setScript(script); |
editor->setScript(script); |
2774 |
//editor->reparent(*this); |
//editor->reparent(*this); |
2775 |
editor->show(); |
editor->show(); |
2848 |
|
|
2849 |
// get selected group (and probably selected sample) |
// get selected group (and probably selected sample) |
2850 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
2851 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
2852 |
|
if (rows.empty()) return; |
2853 |
|
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[0]); |
2854 |
if (!it) return; |
if (!it) return; |
2855 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
2856 |
gig::Sample* sample = NULL; |
gig::Sample* sample = NULL; |
2999 |
SampleImportItem sched_item; |
SampleImportItem sched_item; |
3000 |
sched_item.gig_sample = sample; |
sched_item.gig_sample = sample; |
3001 |
sched_item.sample_path = *iter; |
sched_item.sample_path = *iter; |
3002 |
m_SampleImportQueue.push_back(sched_item); |
m_SampleImportQueue[sample] = sched_item; |
3003 |
// add sample to the tree view |
// add sample to the tree view |
3004 |
if (replace) { |
if (replace) { |
3005 |
row[m_SamplesModel.m_col_name] = gig_to_utf8(sample->pInfo->Name); |
row[m_SamplesModel.m_col_name] = gig_to_utf8(sample->pInfo->Name); |
3093 |
try |
try |
3094 |
{ |
{ |
3095 |
if (!hFile) throw std::string(_("could not open file")); |
if (!hFile) throw std::string(_("could not open file")); |
|
int bitdepth; |
|
3096 |
switch (info.format & 0xff) { |
switch (info.format & 0xff) { |
3097 |
case SF_FORMAT_PCM_S8: |
case SF_FORMAT_PCM_S8: |
3098 |
case SF_FORMAT_PCM_16: |
case SF_FORMAT_PCM_16: |
3099 |
case SF_FORMAT_PCM_U8: |
case SF_FORMAT_PCM_U8: |
|
bitdepth = 16; |
|
|
break; |
|
3100 |
case SF_FORMAT_PCM_24: |
case SF_FORMAT_PCM_24: |
3101 |
case SF_FORMAT_PCM_32: |
case SF_FORMAT_PCM_32: |
3102 |
case SF_FORMAT_FLOAT: |
case SF_FORMAT_FLOAT: |
3103 |
case SF_FORMAT_DOUBLE: |
case SF_FORMAT_DOUBLE: |
|
bitdepth = 24; |
|
3104 |
break; |
break; |
3105 |
default: |
default: |
3106 |
sf_close(hFile); |
sf_close(hFile); |
3109 |
SampleImportItem sched_item; |
SampleImportItem sched_item; |
3110 |
sched_item.gig_sample = sample; |
sched_item.gig_sample = sample; |
3111 |
sched_item.sample_path = filename; |
sched_item.sample_path = filename; |
3112 |
m_SampleImportQueue.push_back(sched_item); |
m_SampleImportQueue[sample] = sched_item; |
3113 |
sf_close(hFile); |
sf_close(hFile); |
3114 |
file_changed(); |
file_changed(); |
3115 |
} |
} |
3133 |
void MainWindow::on_action_remove_sample() { |
void MainWindow::on_action_remove_sample() { |
3134 |
if (!file) return; |
if (!file) return; |
3135 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
3136 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
3137 |
if (it) { |
for (int r = rows.size() - 1; r >= 0; --r) { |
3138 |
|
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[r]); |
3139 |
|
if (!it) continue; |
3140 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
3141 |
gig::Group* group = row[m_SamplesModel.m_col_group]; |
gig::Group* group = row[m_SamplesModel.m_col_group]; |
3142 |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
3161 |
// if sample(s) were just previously added, remove |
// if sample(s) were just previously added, remove |
3162 |
// them from the import queue |
// them from the import queue |
3163 |
for (std::list<gig::Sample*>::iterator member = members.begin(); |
for (std::list<gig::Sample*>::iterator member = members.begin(); |
3164 |
member != members.end(); ++member) { |
member != members.end(); ++member) |
3165 |
for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
{ |
3166 |
iter != m_SampleImportQueue.end(); ++iter) { |
if (m_SampleImportQueue.count(*member)) { |
3167 |
if ((*iter).gig_sample == *member) { |
printf("Removing previously added sample '%s' from group '%s'\n", |
3168 |
printf("Removing previously added sample '%s' from group '%s'\n", |
m_SampleImportQueue[sample].sample_path.c_str(), name.c_str()); |
3169 |
(*iter).sample_path.c_str(), name.c_str()); |
m_SampleImportQueue.erase(*member); |
|
m_SampleImportQueue.erase(iter); |
|
|
break; |
|
|
} |
|
3170 |
} |
} |
3171 |
} |
} |
3172 |
file_changed(); |
file_changed(); |
3181 |
samples_removed_signal.emit(); |
samples_removed_signal.emit(); |
3182 |
// if sample was just previously added, remove it from |
// if sample was just previously added, remove it from |
3183 |
// the import queue |
// the import queue |
3184 |
for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
if (m_SampleImportQueue.count(sample)) { |
3185 |
iter != m_SampleImportQueue.end(); ++iter) { |
printf("Removing previously added sample '%s'\n", |
3186 |
if ((*iter).gig_sample == sample) { |
m_SampleImportQueue[sample].sample_path.c_str()); |
3187 |
printf("Removing previously added sample '%s'\n", |
m_SampleImportQueue.erase(sample); |
|
(*iter).sample_path.c_str()); |
|
|
m_SampleImportQueue.erase(iter); |
|
|
break; |
|
|
} |
|
3188 |
} |
} |
3189 |
dimreg_changed(); |
dimreg_changed(); |
3190 |
file_changed(); |
file_changed(); |
3240 |
gig::Sample* sample = *itSample; |
gig::Sample* sample = *itSample; |
3241 |
// remove sample from the .gig file |
// remove sample from the .gig file |
3242 |
file->DeleteSample(sample); |
file->DeleteSample(sample); |
3243 |
// if sample was just previously added, remove it fro the import queue |
// if sample was just previously added, remove it from the import queue |
3244 |
for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
if (m_SampleImportQueue.count(sample)) { |
3245 |
iter != m_SampleImportQueue.end(); ++iter) |
printf("Removing previously added sample '%s'\n", |
3246 |
{ |
m_SampleImportQueue[sample].sample_path.c_str()); |
3247 |
if ((*iter).gig_sample == sample) { |
m_SampleImportQueue.erase(sample); |
|
printf("Removing previously added sample '%s'\n", |
|
|
(*iter).sample_path.c_str()); |
|
|
m_SampleImportQueue.erase(iter); |
|
|
break; |
|
|
} |
|
3248 |
} |
} |
3249 |
} |
} |
3250 |
} catch (RIFF::Exception e) { |
} catch (RIFF::Exception e) { |
3303 |
gig::Instrument* src = NULL; |
gig::Instrument* src = NULL; |
3304 |
{ |
{ |
3305 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeView.get_selection(); |
3306 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
3307 |
if (it) { |
if (!rows.empty()) { |
3308 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(rows[0]); |
3309 |
src = row[m_Columns.m_col_instr]; |
if (it) { |
3310 |
|
Gtk::TreeModel::Row row = *it; |
3311 |
|
src = row[m_Columns.m_col_instr]; |
3312 |
|
} |
3313 |
} |
} |
3314 |
} |
} |
3315 |
if (!src) return; |
if (!src) return; |
3364 |
// get selected sample |
// get selected sample |
3365 |
gig::Sample* sample = NULL; |
gig::Sample* sample = NULL; |
3366 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
3367 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
3368 |
if (it) { |
if (!rows.empty()) { |
3369 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[0]); |
3370 |
sample = row[m_SamplesModel.m_col_sample]; |
if (it) { |
3371 |
|
Gtk::TreeModel::Row row = *it; |
3372 |
|
sample = row[m_SamplesModel.m_col_sample]; |
3373 |
|
} |
3374 |
} |
} |
3375 |
// pass the gig::Sample as pointer |
// pass the gig::Sample as pointer |
3376 |
selection_data.set(selection_data.get_target(), 0/*unused*/, (const guchar*)&sample, |
selection_data.set(selection_data.get_target(), 0/*unused*/, (const guchar*)&sample, |
3510 |
if (!script) return; |
if (!script) return; |
3511 |
|
|
3512 |
ScriptEditor* editor = new ScriptEditor; |
ScriptEditor* editor = new ScriptEditor; |
3513 |
|
editor->signal_script_to_be_changed.connect( |
3514 |
|
signal_script_to_be_changed.make_slot() |
3515 |
|
); |
3516 |
|
editor->signal_script_changed.connect( |
3517 |
|
signal_script_changed.make_slot() |
3518 |
|
); |
3519 |
editor->setScript(script); |
editor->setScript(script); |
3520 |
//editor->reparent(*this); |
//editor->reparent(*this); |
3521 |
editor->show(); |
editor->show(); |
3569 |
|
|
3570 |
void MainWindow::on_action_view_references() { |
void MainWindow::on_action_view_references() { |
3571 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewSamples.get_selection(); |
3572 |
Gtk::TreeModel::iterator it = sel->get_selected(); |
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows(); |
3573 |
|
if (rows.empty()) return; |
3574 |
|
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[0]); |
3575 |
if (!it) return; |
if (!it) return; |
3576 |
Gtk::TreeModel::Row row = *it; |
Gtk::TreeModel::Row row = *it; |
3577 |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
3712 |
// show warning in the file picker dialog |
// show warning in the file picker dialog |
3713 |
Gtk::HBox descriptionArea; |
Gtk::HBox descriptionArea; |
3714 |
descriptionArea.set_spacing(15); |
descriptionArea.set_spacing(15); |
3715 |
Gtk::Image warningIcon(Gtk::Stock::DIALOG_WARNING, Gtk::IconSize(Gtk::ICON_SIZE_DIALOG)); |
Gtk::Image warningIcon; |
3716 |
|
warningIcon.set_from_icon_name("dialog-warning", |
3717 |
|
Gtk::IconSize(Gtk::ICON_SIZE_DIALOG)); |
3718 |
descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK); |
descriptionArea.pack_start(warningIcon, Gtk::PACK_SHRINK); |
3719 |
#if GTKMM_MAJOR_VERSION < 3 |
#if GTKMM_MAJOR_VERSION < 3 |
3720 |
view::WrapLabel description; |
view::WrapLabel description; |
3737 |
descriptionArea.show_all(); |
descriptionArea.show_all(); |
3738 |
|
|
3739 |
if (dialog.run() == Gtk::RESPONSE_OK) { |
if (dialog.run() == Gtk::RESPONSE_OK) { |
3740 |
printf("on_action_merge_files self=%x\n", Glib::Threads::Thread::self()); |
printf("on_action_merge_files self=%p\n", |
3741 |
|
static_cast<void*>(Glib::Threads::Thread::self())); |
3742 |
std::vector<std::string> filenames = dialog.get_filenames(); |
std::vector<std::string> filenames = dialog.get_filenames(); |
3743 |
|
|
3744 |
// merge the selected files to the currently open .gig file |
// merge the selected files to the currently open .gig file |
3820 |
m_TreeViewNotebook.set_current_page(2); |
m_TreeViewNotebook.set_current_page(2); |
3821 |
} |
} |
3822 |
|
|
3823 |
|
void MainWindow::select_prev_region() { |
3824 |
|
m_RegionChooser.select_prev_region(); |
3825 |
|
} |
3826 |
|
|
3827 |
|
void MainWindow::select_next_region() { |
3828 |
|
m_RegionChooser.select_next_region(); |
3829 |
|
} |
3830 |
|
|
3831 |
|
void MainWindow::select_next_dim_rgn_zone() { |
3832 |
|
if (m_DimRegionChooser.has_focus()) return; // avoid conflict with key stroke handler of DimenionRegionChooser |
3833 |
|
m_DimRegionChooser.select_next_dimzone(); |
3834 |
|
} |
3835 |
|
|
3836 |
|
void MainWindow::select_prev_dim_rgn_zone() { |
3837 |
|
if (m_DimRegionChooser.has_focus()) return; // avoid conflict with key stroke handler of DimenionRegionChooser |
3838 |
|
m_DimRegionChooser.select_prev_dimzone(); |
3839 |
|
} |
3840 |
|
|
3841 |
|
void MainWindow::select_add_next_dim_rgn_zone() { |
3842 |
|
m_DimRegionChooser.select_next_dimzone(true); |
3843 |
|
} |
3844 |
|
|
3845 |
|
void MainWindow::select_add_prev_dim_rgn_zone() { |
3846 |
|
m_DimRegionChooser.select_prev_dimzone(true); |
3847 |
|
} |
3848 |
|
|
3849 |
|
void MainWindow::select_prev_dimension() { |
3850 |
|
if (m_DimRegionChooser.has_focus()) return; // avoid conflict with key stroke handler of DimenionRegionChooser |
3851 |
|
m_DimRegionChooser.select_prev_dimension(); |
3852 |
|
} |
3853 |
|
|
3854 |
|
void MainWindow::select_next_dimension() { |
3855 |
|
if (m_DimRegionChooser.has_focus()) return; // avoid conflict with key stroke handler of DimenionRegionChooser |
3856 |
|
m_DimRegionChooser.select_next_dimension(); |
3857 |
|
} |
3858 |
|
|
3859 |
|
#define CLIPBOARD_DIMENSIONREGION_TARGET \ |
3860 |
|
("libgig.DimensionRegion." + m_serializationArchive.rawDataFormat()) |
3861 |
|
|
3862 |
|
void MainWindow::copy_selected_dimrgn() { |
3863 |
|
gig::DimensionRegion* pDimRgn = m_DimRegionChooser.get_main_dimregion(); |
3864 |
|
if (!pDimRgn) { |
3865 |
|
updateClipboardPasteAvailable(); |
3866 |
|
updateClipboardCopyAvailable(); |
3867 |
|
return; |
3868 |
|
} |
3869 |
|
|
3870 |
|
std::vector<Gtk::TargetEntry> targets; |
3871 |
|
targets.push_back( Gtk::TargetEntry(CLIPBOARD_DIMENSIONREGION_TARGET) ); |
3872 |
|
|
3873 |
|
Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get(); |
3874 |
|
clipboard->set( |
3875 |
|
targets, |
3876 |
|
sigc::mem_fun(*this, &MainWindow::on_clipboard_get), |
3877 |
|
sigc::mem_fun(*this, &MainWindow::on_clipboard_clear) |
3878 |
|
); |
3879 |
|
|
3880 |
|
m_serializationArchive.serialize(pDimRgn); |
3881 |
|
|
3882 |
|
updateClipboardPasteAvailable(); |
3883 |
|
} |
3884 |
|
|
3885 |
|
void MainWindow::paste_copied_dimrgn() { |
3886 |
|
Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get(); |
3887 |
|
clipboard->request_contents( |
3888 |
|
CLIPBOARD_DIMENSIONREGION_TARGET, |
3889 |
|
sigc::mem_fun(*this, &MainWindow::on_clipboard_received) |
3890 |
|
); |
3891 |
|
updateClipboardPasteAvailable(); |
3892 |
|
} |
3893 |
|
|
3894 |
|
void MainWindow::adjust_clipboard_content() { |
3895 |
|
MacroEditor* editor = new MacroEditor(); |
3896 |
|
editor->setMacro(&m_serializationArchive, true); |
3897 |
|
editor->show(); |
3898 |
|
} |
3899 |
|
|
3900 |
|
void MainWindow::updateClipboardPasteAvailable() { |
3901 |
|
Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get(); |
3902 |
|
clipboard->request_targets( |
3903 |
|
sigc::mem_fun(*this, &MainWindow::on_clipboard_received_targets) |
3904 |
|
); |
3905 |
|
} |
3906 |
|
|
3907 |
|
void MainWindow::updateClipboardCopyAvailable() { |
3908 |
|
bool bDimensionRegionCopyIsPossible = m_DimRegionChooser.get_main_dimregion(); |
3909 |
|
static_cast<Gtk::MenuItem*>( |
3910 |
|
uiManager->get_widget("/MenuBar/MenuEdit/CopyDimRgn") |
3911 |
|
)->set_sensitive(bDimensionRegionCopyIsPossible); |
3912 |
|
} |
3913 |
|
|
3914 |
|
void MainWindow::on_clipboard_owner_change(GdkEventOwnerChange* event) { |
3915 |
|
updateClipboardPasteAvailable(); |
3916 |
|
} |
3917 |
|
|
3918 |
|
void MainWindow::on_clipboard_get(Gtk::SelectionData& selection_data, guint /*info*/) { |
3919 |
|
const std::string target = selection_data.get_target(); |
3920 |
|
if (target == CLIPBOARD_DIMENSIONREGION_TARGET) { |
3921 |
|
selection_data.set( |
3922 |
|
CLIPBOARD_DIMENSIONREGION_TARGET, 8 /* "format": probably unused*/, |
3923 |
|
&m_serializationArchive.rawData()[0], |
3924 |
|
m_serializationArchive.rawData().size() |
3925 |
|
); |
3926 |
|
} else { |
3927 |
|
std::cerr << "Clipboard: content for unknown target '" << target << "' requested\n"; |
3928 |
|
} |
3929 |
|
} |
3930 |
|
|
3931 |
|
void MainWindow::on_clipboard_clear() { |
3932 |
|
m_serializationArchive.clear(); |
3933 |
|
updateClipboardPasteAvailable(); |
3934 |
|
updateClipboardCopyAvailable(); |
3935 |
|
} |
3936 |
|
|
3937 |
|
//NOTE: Might throw exception !!! |
3938 |
|
void MainWindow::applyMacro(Serialization::Archive& macro) { |
3939 |
|
gig::DimensionRegion* pDimRgn = m_DimRegionChooser.get_main_dimregion(); |
3940 |
|
if (!pDimRgn) return; |
3941 |
|
|
3942 |
|
for (std::set<gig::DimensionRegion*>::iterator itDimReg = dimreg_edit.dimregs.begin(); |
3943 |
|
itDimReg != dimreg_edit.dimregs.end(); ++itDimReg) |
3944 |
|
{ |
3945 |
|
gig::DimensionRegion* pDimRgn = *itDimReg; |
3946 |
|
DimRegionChangeGuard(this, pDimRgn); |
3947 |
|
macro.deserialize(pDimRgn); |
3948 |
|
} |
3949 |
|
//region_changed() |
3950 |
|
file_changed(); |
3951 |
|
dimreg_changed(); |
3952 |
|
} |
3953 |
|
|
3954 |
|
void MainWindow::on_clipboard_received(const Gtk::SelectionData& selection_data) { |
3955 |
|
const std::string target = selection_data.get_target(); |
3956 |
|
if (target == CLIPBOARD_DIMENSIONREGION_TARGET) { |
3957 |
|
Glib::ustring errorText; |
3958 |
|
try { |
3959 |
|
m_serializationArchive.decode( |
3960 |
|
selection_data.get_data(), selection_data.get_length() |
3961 |
|
); |
3962 |
|
applyMacro(m_serializationArchive); |
3963 |
|
} catch (Serialization::Exception e) { |
3964 |
|
errorText = e.Message; |
3965 |
|
} catch (...) { |
3966 |
|
errorText = _("Unknown exception while pasting DimensionRegion"); |
3967 |
|
} |
3968 |
|
if (!errorText.empty()) { |
3969 |
|
Glib::ustring txt = _("Pasting DimensionRegion failed:\n") + errorText; |
3970 |
|
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
3971 |
|
msg.run(); |
3972 |
|
} |
3973 |
|
} |
3974 |
|
} |
3975 |
|
|
3976 |
|
void MainWindow::on_clipboard_received_targets(const std::vector<Glib::ustring>& targets) { |
3977 |
|
const bool bDimensionRegionPasteIsPossible = |
3978 |
|
std::find(targets.begin(), targets.end(), |
3979 |
|
CLIPBOARD_DIMENSIONREGION_TARGET) != targets.end(); |
3980 |
|
|
3981 |
|
static_cast<Gtk::MenuItem*>( |
3982 |
|
uiManager->get_widget("/MenuBar/MenuEdit/PasteDimRgn") |
3983 |
|
)->set_sensitive(bDimensionRegionPasteIsPossible); |
3984 |
|
|
3985 |
|
static_cast<Gtk::MenuItem*>( |
3986 |
|
uiManager->get_widget("/MenuBar/MenuEdit/AdjustClipboard") |
3987 |
|
)->set_sensitive(bDimensionRegionPasteIsPossible); |
3988 |
|
} |
3989 |
|
|
3990 |
sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() { |
sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() { |
3991 |
return file_structure_to_be_changed_signal; |
return file_structure_to_be_changed_signal; |
3992 |
} |
} |