1 |
/* |
/* |
2 |
* Copyright (C) 2006-2016 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 |
57 |
#include "ReferencesView.h" |
#include "ReferencesView.h" |
58 |
#include "../../gfx/status_attached.xpm" |
#include "../../gfx/status_attached.xpm" |
59 |
#include "../../gfx/status_detached.xpm" |
#include "../../gfx/status_detached.xpm" |
60 |
|
#include "gfx/builtinpix.h" |
61 |
|
#include "MacroEditor.h" |
62 |
|
|
63 |
MainWindow::MainWindow() : |
MainWindow::MainWindow() : |
64 |
m_DimRegionChooser(*this), |
m_DimRegionChooser(*this), |
65 |
dimreg_label(_("Changes apply to:")), |
dimreg_label(_("Changes apply to:")), |
66 |
dimreg_all_regions(_("all regions")), |
dimreg_all_regions(_("all regions")), |
67 |
dimreg_all_dimregs(_("all dimension splits")), |
dimreg_all_dimregs(_("all dimension splits")), |
68 |
dimreg_stereo(_("both channels")) |
dimreg_stereo(_("both channels")), |
69 |
|
labelLegend(_("Legend:")), |
70 |
|
labelNoSample(_(" No Sample")), |
71 |
|
labelMissingSample(_(" Missing some Sample(s)")), |
72 |
|
labelLooped(_(" Looped")), |
73 |
|
labelSomeLoops(_(" Some Loop(s)")) |
74 |
{ |
{ |
75 |
|
loadBuiltInPix(); |
76 |
|
|
77 |
// set_border_width(5); |
// set_border_width(5); |
78 |
// set_default_size(400, 200); |
// set_default_size(400, 200); |
79 |
|
|
|
|
|
80 |
add(m_VBox); |
add(m_VBox); |
81 |
|
|
82 |
// Handle selection |
// Handle selection |
110 |
dimreg_hbox.add(dimreg_stereo); |
dimreg_hbox.add(dimreg_stereo); |
111 |
dimreg_vbox.add(dimreg_edit); |
dimreg_vbox.add(dimreg_edit); |
112 |
dimreg_vbox.pack_start(dimreg_hbox, Gtk::PACK_SHRINK); |
dimreg_vbox.pack_start(dimreg_hbox, Gtk::PACK_SHRINK); |
113 |
|
{ |
114 |
|
legend_hbox.add(labelLegend); |
115 |
|
|
116 |
|
imageNoSample.set(redDot); |
117 |
|
imageNoSample.set_alignment(Gtk::ALIGN_END); |
118 |
|
labelNoSample.set_alignment(Gtk::ALIGN_START); |
119 |
|
legend_hbox.add(imageNoSample); |
120 |
|
legend_hbox.add(labelNoSample); |
121 |
|
|
122 |
|
imageMissingSample.set(yellowDot); |
123 |
|
imageMissingSample.set_alignment(Gtk::ALIGN_END); |
124 |
|
labelMissingSample.set_alignment(Gtk::ALIGN_START); |
125 |
|
legend_hbox.add(imageMissingSample); |
126 |
|
legend_hbox.add(labelMissingSample); |
127 |
|
|
128 |
|
imageLooped.set(blackLoop); |
129 |
|
imageLooped.set_alignment(Gtk::ALIGN_END); |
130 |
|
labelLooped.set_alignment(Gtk::ALIGN_START); |
131 |
|
legend_hbox.add(imageLooped); |
132 |
|
legend_hbox.add(labelLooped); |
133 |
|
|
134 |
|
imageSomeLoops.set(grayLoop); |
135 |
|
imageSomeLoops.set_alignment(Gtk::ALIGN_END); |
136 |
|
labelSomeLoops.set_alignment(Gtk::ALIGN_START); |
137 |
|
legend_hbox.add(imageSomeLoops); |
138 |
|
legend_hbox.add(labelSomeLoops); |
139 |
|
|
140 |
|
legend_hbox.show_all_children(); |
141 |
|
} |
142 |
|
dimreg_vbox.pack_start(legend_hbox, Gtk::PACK_SHRINK); |
143 |
m_HPaned.add2(dimreg_vbox); |
m_HPaned.add2(dimreg_vbox); |
144 |
|
|
145 |
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.")); |
199 |
sigc::mem_fun(*this, &MainWindow::show_intruments_tab) |
sigc::mem_fun(*this, &MainWindow::show_intruments_tab) |
200 |
); |
); |
201 |
actionGroup->add( |
actionGroup->add( |
202 |
Gtk::Action::create("MenuScript", _("S_cript")), |
Gtk::Action::create("MenuScript", _("Scr_ipt")), |
203 |
sigc::mem_fun(*this, &MainWindow::show_scripts_tab) |
sigc::mem_fun(*this, &MainWindow::show_scripts_tab) |
204 |
); |
); |
205 |
actionGroup->add(Gtk::Action::create("AllInstruments", _("_Select"))); |
actionGroup->add(Gtk::Action::create("AllInstruments", _("_Select"))); |
206 |
|
|
207 |
actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit"))); |
actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit"))); |
208 |
|
|
209 |
|
const Gdk::ModifierType primaryModifierKey = |
210 |
|
#if defined(__APPLE__) |
211 |
|
Gdk::META_MASK; // Cmd key on Mac |
212 |
|
#else |
213 |
|
Gdk::CONTROL_MASK; // Ctrl key on all other OSs |
214 |
|
#endif |
215 |
|
|
216 |
|
actionGroup->add(Gtk::Action::create("CopyDimRgn", |
217 |
|
_("Copy selected dimension region")), |
218 |
|
Gtk::AccelKey(GDK_KEY_c, Gdk::MOD1_MASK), |
219 |
|
sigc::mem_fun(*this, &MainWindow::copy_selected_dimrgn)); |
220 |
|
|
221 |
|
actionGroup->add(Gtk::Action::create("PasteDimRgn", |
222 |
|
_("Paste dimension region")), |
223 |
|
Gtk::AccelKey(GDK_KEY_v, Gdk::MOD1_MASK), |
224 |
|
sigc::mem_fun(*this, &MainWindow::paste_copied_dimrgn)); |
225 |
|
|
226 |
|
actionGroup->add(Gtk::Action::create("AdjustClipboard", |
227 |
|
_("Adjust Clipboard Content")), |
228 |
|
Gtk::AccelKey(GDK_KEY_x, Gdk::MOD1_MASK), |
229 |
|
sigc::mem_fun(*this, &MainWindow::adjust_clipboard_content)); |
230 |
|
|
231 |
|
actionGroup->add(Gtk::Action::create("SelectPrevRegion", |
232 |
|
_("Select Previous Region")), |
233 |
|
Gtk::AccelKey(GDK_KEY_Left, primaryModifierKey), |
234 |
|
sigc::mem_fun(*this, &MainWindow::select_prev_region)); |
235 |
|
|
236 |
|
actionGroup->add(Gtk::Action::create("SelectNextRegion", |
237 |
|
_("Select Next Region")), |
238 |
|
Gtk::AccelKey(GDK_KEY_Right, primaryModifierKey), |
239 |
|
sigc::mem_fun(*this, &MainWindow::select_next_region)); |
240 |
|
|
241 |
|
actionGroup->add(Gtk::Action::create("SelectPrevDimRgnZone", |
242 |
|
_("Select Previous Dimension Region Zone")), |
243 |
|
Gtk::AccelKey(GDK_KEY_Left, Gdk::MOD1_MASK), |
244 |
|
sigc::mem_fun(*this, &MainWindow::select_prev_dim_rgn_zone)); |
245 |
|
|
246 |
|
actionGroup->add(Gtk::Action::create("SelectNextDimRgnZone", |
247 |
|
_("Select Next Dimension Region Zone")), |
248 |
|
Gtk::AccelKey(GDK_KEY_Right, Gdk::MOD1_MASK), |
249 |
|
sigc::mem_fun(*this, &MainWindow::select_next_dim_rgn_zone)); |
250 |
|
|
251 |
|
actionGroup->add(Gtk::Action::create("SelectPrevDimension", |
252 |
|
_("Select Previous Dimension")), |
253 |
|
Gtk::AccelKey(GDK_KEY_Up, Gdk::MOD1_MASK), |
254 |
|
sigc::mem_fun(*this, &MainWindow::select_prev_dimension)); |
255 |
|
|
256 |
|
actionGroup->add(Gtk::Action::create("SelectNextDimension", |
257 |
|
_("Select Next Dimension")), |
258 |
|
Gtk::AccelKey(GDK_KEY_Down, Gdk::MOD1_MASK), |
259 |
|
sigc::mem_fun(*this, &MainWindow::select_next_dimension)); |
260 |
|
|
261 |
|
actionGroup->add(Gtk::Action::create("SelectAddPrevDimRgnZone", |
262 |
|
_("Add Previous Dimension Region Zone to Selection")), |
263 |
|
Gtk::AccelKey(GDK_KEY_Left, Gdk::MOD1_MASK | Gdk::SHIFT_MASK), |
264 |
|
sigc::mem_fun(*this, &MainWindow::select_add_prev_dim_rgn_zone)); |
265 |
|
|
266 |
|
actionGroup->add(Gtk::Action::create("SelectAddNextDimRgnZone", |
267 |
|
_("Add Next Dimension Region Zone to Selection")), |
268 |
|
Gtk::AccelKey(GDK_KEY_Right, Gdk::MOD1_MASK | Gdk::SHIFT_MASK), |
269 |
|
sigc::mem_fun(*this, &MainWindow::select_add_next_dim_rgn_zone)); |
270 |
|
|
271 |
Glib::RefPtr<Gtk::ToggleAction> toggle_action = |
Glib::RefPtr<Gtk::ToggleAction> toggle_action = |
272 |
Gtk::ToggleAction::create("CopySampleUnity", _("Copy Sample's _Unity Note")); |
Gtk::ToggleAction::create("CopySampleUnity", _("Copy Sample's _Unity Note")); |
273 |
toggle_action->set_active(true); |
toggle_action->set_active(true); |
284 |
actionGroup->add(toggle_action); |
actionGroup->add(toggle_action); |
285 |
|
|
286 |
|
|
287 |
actionGroup->add(Gtk::Action::create("MenuView", _("_View"))); |
actionGroup->add(Gtk::Action::create("MenuView", _("Vie_w"))); |
288 |
toggle_action = |
toggle_action = |
289 |
Gtk::ToggleAction::create("Statusbar", _("_Statusbar")); |
Gtk::ToggleAction::create("Statusbar", _("_Statusbar")); |
290 |
toggle_action->set_active(true); |
toggle_action->set_active(true); |
442 |
" <menuitem action='Quit'/>" |
" <menuitem action='Quit'/>" |
443 |
" </menu>" |
" </menu>" |
444 |
" <menu action='MenuEdit'>" |
" <menu action='MenuEdit'>" |
445 |
|
" <menuitem action='CopyDimRgn'/>" |
446 |
|
" <menuitem action='AdjustClipboard'/>" |
447 |
|
" <menuitem action='PasteDimRgn'/>" |
448 |
|
" <separator/>" |
449 |
|
" <menuitem action='SelectPrevRegion'/>" |
450 |
|
" <menuitem action='SelectNextRegion'/>" |
451 |
|
" <separator/>" |
452 |
|
" <menuitem action='SelectPrevDimension'/>" |
453 |
|
" <menuitem action='SelectNextDimension'/>" |
454 |
|
" <menuitem action='SelectPrevDimRgnZone'/>" |
455 |
|
" <menuitem action='SelectNextDimRgnZone'/>" |
456 |
|
" <menuitem action='SelectAddPrevDimRgnZone'/>" |
457 |
|
" <menuitem action='SelectAddNextDimRgnZone'/>" |
458 |
|
" <separator/>" |
459 |
" <menuitem action='CopySampleUnity'/>" |
" <menuitem action='CopySampleUnity'/>" |
460 |
" <menuitem action='CopySampleTune'/>" |
" <menuitem action='CopySampleTune'/>" |
461 |
" <menuitem action='CopySampleLoop'/>" |
" <menuitem action='CopySampleLoop'/>" |
818 |
|
|
819 |
// select 'Instruments' tab by default |
// select 'Instruments' tab by default |
820 |
// (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) |
821 |
m_TreeViewNotebook.set_current_page(1); |
m_TreeViewNotebook.set_current_page(1); |
822 |
|
|
823 |
|
Gtk::Clipboard::get()->signal_owner_change().connect( |
824 |
|
sigc::mem_fun(*this, &MainWindow::on_clipboard_owner_change) |
825 |
|
); |
826 |
|
updateClipboardPasteAvailable(); |
827 |
|
updateClipboardCopyAvailable(); |
828 |
} |
} |
829 |
|
|
830 |
MainWindow::~MainWindow() |
MainWindow::~MainWindow() |
895 |
add_region_to_dimregs(region, stereo, all_dimregs); |
add_region_to_dimregs(region, stereo, all_dimregs); |
896 |
} |
} |
897 |
} |
} |
898 |
|
|
899 |
|
m_RegionChooser.setModifyAllRegions(all_regions); |
900 |
|
m_DimRegionChooser.setModifyAllRegions(all_regions); |
901 |
|
m_DimRegionChooser.setModifyAllDimensionRegions(all_dimregs); |
902 |
|
m_DimRegionChooser.setModifyBothChannels(stereo); |
903 |
|
|
904 |
|
updateClipboardCopyAvailable(); |
905 |
} |
} |
906 |
|
|
907 |
void MainWindow::dimreg_all_dimregs_toggled() |
void MainWindow::dimreg_all_dimregs_toggled() |
953 |
progress_dispatcher(); |
progress_dispatcher(); |
954 |
} |
} |
955 |
|
|
956 |
|
#if defined(WIN32) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) |
957 |
|
// make sure stack is 16-byte aligned for SSE instructions |
958 |
|
__attribute__((force_align_arg_pointer)) |
959 |
|
#endif |
960 |
void Loader::thread_function() |
void Loader::thread_function() |
961 |
{ |
{ |
962 |
printf("thread_function self=%p\n", |
printf("thread_function self=%p\n", |
1036 |
progress_dispatcher.emit(); |
progress_dispatcher.emit(); |
1037 |
} |
} |
1038 |
|
|
1039 |
|
#if defined(WIN32) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) |
1040 |
|
// make sure stack is 16-byte aligned for SSE instructions |
1041 |
|
__attribute__((force_align_arg_pointer)) |
1042 |
|
#endif |
1043 |
void Saver::thread_function() |
void Saver::thread_function() |
1044 |
{ |
{ |
1045 |
printf("thread_function self=%p\n", |
printf("thread_function self=%p\n", |
1534 |
std::cout << "Starting sample import\n" << std::flush; |
std::cout << "Starting sample import\n" << std::flush; |
1535 |
Glib::ustring error_files; |
Glib::ustring error_files; |
1536 |
printf("Samples to import: %d\n", int(m_SampleImportQueue.size())); |
printf("Samples to import: %d\n", int(m_SampleImportQueue.size())); |
1537 |
for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
for (std::map<gig::Sample*, SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
1538 |
iter != m_SampleImportQueue.end(); ) { |
iter != m_SampleImportQueue.end(); ) { |
1539 |
printf("Importing sample %s\n",(*iter).sample_path.c_str()); |
printf("Importing sample %s\n",iter->second.sample_path.c_str()); |
1540 |
SF_INFO info; |
SF_INFO info; |
1541 |
info.format = 0; |
info.format = 0; |
1542 |
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); |
1543 |
sf_command(hFile, SFC_SET_SCALE_FLOAT_INT_READ, 0, SF_TRUE); |
sf_command(hFile, SFC_SET_SCALE_FLOAT_INT_READ, 0, SF_TRUE); |
1544 |
try { |
try { |
1545 |
if (!hFile) throw std::string(_("could not open file")); |
if (!hFile) throw std::string(_("could not open file")); |
1562 |
throw std::string(_("format not supported")); // unsupported subformat (yet?) |
throw std::string(_("format not supported")); // unsupported subformat (yet?) |
1563 |
} |
} |
1564 |
|
|
1565 |
|
// reset write position for sample |
1566 |
|
iter->first->SetPos(0); |
1567 |
|
|
1568 |
const int bufsize = 10000; |
const int bufsize = 10000; |
1569 |
switch (bitdepth) { |
switch (bitdepth) { |
1570 |
case 16: { |
case 16: { |
1574 |
// libsndfile does the conversion for us (if needed) |
// libsndfile does the conversion for us (if needed) |
1575 |
int n = sf_readf_short(hFile, buffer, bufsize); |
int n = sf_readf_short(hFile, buffer, bufsize); |
1576 |
// write from buffer directly (physically) into .gig file |
// write from buffer directly (physically) into .gig file |
1577 |
iter->gig_sample->Write(buffer, n); |
iter->first->Write(buffer, n); |
1578 |
cnt -= n; |
cnt -= n; |
1579 |
} |
} |
1580 |
delete[] buffer; |
delete[] buffer; |
1594 |
dstbuf[j++] = srcbuf[i] >> 24; |
dstbuf[j++] = srcbuf[i] >> 24; |
1595 |
} |
} |
1596 |
// write from buffer directly (physically) into .gig file |
// write from buffer directly (physically) into .gig file |
1597 |
iter->gig_sample->Write(dstbuf, n); |
iter->first->Write(dstbuf, n); |
1598 |
cnt -= n; |
cnt -= n; |
1599 |
} |
} |
1600 |
delete[] srcbuf; |
delete[] srcbuf; |
1605 |
// cleanup |
// cleanup |
1606 |
sf_close(hFile); |
sf_close(hFile); |
1607 |
// let the sampler re-cache the sample if needed |
// let the sampler re-cache the sample if needed |
1608 |
sample_changed_signal.emit(iter->gig_sample); |
sample_changed_signal.emit(iter->first); |
1609 |
// on success we remove the sample from the import queue, |
// on success we remove the sample from the import queue, |
1610 |
// otherwise keep it, maybe it works the next time ? |
// otherwise keep it, maybe it works the next time ? |
1611 |
std::list<SampleImportItem>::iterator cur = iter; |
std::map<gig::Sample*, SampleImportItem>::iterator cur = iter; |
1612 |
++iter; |
++iter; |
1613 |
m_SampleImportQueue.erase(cur); |
m_SampleImportQueue.erase(cur); |
1614 |
} catch (std::string what) { |
} catch (std::string what) { |
1615 |
// remember the files that made trouble (and their cause) |
// remember the files that made trouble (and their cause) |
1616 |
if (!error_files.empty()) error_files += "\n"; |
if (!error_files.empty()) error_files += "\n"; |
1617 |
error_files += (*iter).sample_path += " (" + what + ")"; |
error_files += iter->second.sample_path += " (" + what + ")"; |
1618 |
++iter; |
++iter; |
1619 |
} |
} |
1620 |
} |
} |
1656 |
dialog.set_name("Gigedit"); |
dialog.set_name("Gigedit"); |
1657 |
#endif |
#endif |
1658 |
dialog.set_version(VERSION); |
dialog.set_version(VERSION); |
1659 |
dialog.set_copyright("Copyright (C) 2006-2016 Andreas Persson"); |
dialog.set_copyright("Copyright (C) 2006-2017 Andreas Persson"); |
1660 |
const std::string sComment = |
const std::string sComment = |
1661 |
_("Built " __DATE__ "\nUsing ") + |
_("Built " __DATE__ "\nUsing ") + |
1662 |
::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" + |
::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" + |
2836 |
SampleImportItem sched_item; |
SampleImportItem sched_item; |
2837 |
sched_item.gig_sample = sample; |
sched_item.gig_sample = sample; |
2838 |
sched_item.sample_path = *iter; |
sched_item.sample_path = *iter; |
2839 |
m_SampleImportQueue.push_back(sched_item); |
m_SampleImportQueue[sample] = sched_item; |
2840 |
// add sample to the tree view |
// add sample to the tree view |
2841 |
if (replace) { |
if (replace) { |
2842 |
row[m_SamplesModel.m_col_name] = gig_to_utf8(sample->pInfo->Name); |
row[m_SamplesModel.m_col_name] = gig_to_utf8(sample->pInfo->Name); |
2946 |
SampleImportItem sched_item; |
SampleImportItem sched_item; |
2947 |
sched_item.gig_sample = sample; |
sched_item.gig_sample = sample; |
2948 |
sched_item.sample_path = filename; |
sched_item.sample_path = filename; |
2949 |
m_SampleImportQueue.push_back(sched_item); |
m_SampleImportQueue[sample] = sched_item; |
2950 |
sf_close(hFile); |
sf_close(hFile); |
2951 |
file_changed(); |
file_changed(); |
2952 |
} |
} |
2998 |
// if sample(s) were just previously added, remove |
// if sample(s) were just previously added, remove |
2999 |
// them from the import queue |
// them from the import queue |
3000 |
for (std::list<gig::Sample*>::iterator member = members.begin(); |
for (std::list<gig::Sample*>::iterator member = members.begin(); |
3001 |
member != members.end(); ++member) { |
member != members.end(); ++member) |
3002 |
for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
{ |
3003 |
iter != m_SampleImportQueue.end(); ++iter) { |
if (m_SampleImportQueue.count(*member)) { |
3004 |
if ((*iter).gig_sample == *member) { |
printf("Removing previously added sample '%s' from group '%s'\n", |
3005 |
printf("Removing previously added sample '%s' from group '%s'\n", |
m_SampleImportQueue[sample].sample_path.c_str(), name.c_str()); |
3006 |
(*iter).sample_path.c_str(), name.c_str()); |
m_SampleImportQueue.erase(*member); |
|
m_SampleImportQueue.erase(iter); |
|
|
break; |
|
|
} |
|
3007 |
} |
} |
3008 |
} |
} |
3009 |
file_changed(); |
file_changed(); |
3018 |
samples_removed_signal.emit(); |
samples_removed_signal.emit(); |
3019 |
// if sample was just previously added, remove it from |
// if sample was just previously added, remove it from |
3020 |
// the import queue |
// the import queue |
3021 |
for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
if (m_SampleImportQueue.count(sample)) { |
3022 |
iter != m_SampleImportQueue.end(); ++iter) { |
printf("Removing previously added sample '%s'\n", |
3023 |
if ((*iter).gig_sample == sample) { |
m_SampleImportQueue[sample].sample_path.c_str()); |
3024 |
printf("Removing previously added sample '%s'\n", |
m_SampleImportQueue.erase(sample); |
|
(*iter).sample_path.c_str()); |
|
|
m_SampleImportQueue.erase(iter); |
|
|
break; |
|
|
} |
|
3025 |
} |
} |
3026 |
dimreg_changed(); |
dimreg_changed(); |
3027 |
file_changed(); |
file_changed(); |
3077 |
gig::Sample* sample = *itSample; |
gig::Sample* sample = *itSample; |
3078 |
// remove sample from the .gig file |
// remove sample from the .gig file |
3079 |
file->DeleteSample(sample); |
file->DeleteSample(sample); |
3080 |
// if sample was just previously added, remove it fro the import queue |
// if sample was just previously added, remove it from the import queue |
3081 |
for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
if (m_SampleImportQueue.count(sample)) { |
3082 |
iter != m_SampleImportQueue.end(); ++iter) |
printf("Removing previously added sample '%s'\n", |
3083 |
{ |
m_SampleImportQueue[sample].sample_path.c_str()); |
3084 |
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; |
|
|
} |
|
3085 |
} |
} |
3086 |
} |
} |
3087 |
} catch (RIFF::Exception e) { |
} catch (RIFF::Exception e) { |
3657 |
m_TreeViewNotebook.set_current_page(2); |
m_TreeViewNotebook.set_current_page(2); |
3658 |
} |
} |
3659 |
|
|
3660 |
|
void MainWindow::select_prev_region() { |
3661 |
|
m_RegionChooser.select_prev_region(); |
3662 |
|
} |
3663 |
|
|
3664 |
|
void MainWindow::select_next_region() { |
3665 |
|
m_RegionChooser.select_next_region(); |
3666 |
|
} |
3667 |
|
|
3668 |
|
void MainWindow::select_next_dim_rgn_zone() { |
3669 |
|
if (m_DimRegionChooser.has_focus()) return; // avoid conflict with key stroke handler of DimenionRegionChooser |
3670 |
|
m_DimRegionChooser.select_next_dimzone(); |
3671 |
|
} |
3672 |
|
|
3673 |
|
void MainWindow::select_prev_dim_rgn_zone() { |
3674 |
|
if (m_DimRegionChooser.has_focus()) return; // avoid conflict with key stroke handler of DimenionRegionChooser |
3675 |
|
m_DimRegionChooser.select_prev_dimzone(); |
3676 |
|
} |
3677 |
|
|
3678 |
|
void MainWindow::select_add_next_dim_rgn_zone() { |
3679 |
|
m_DimRegionChooser.select_next_dimzone(true); |
3680 |
|
} |
3681 |
|
|
3682 |
|
void MainWindow::select_add_prev_dim_rgn_zone() { |
3683 |
|
m_DimRegionChooser.select_prev_dimzone(true); |
3684 |
|
} |
3685 |
|
|
3686 |
|
void MainWindow::select_prev_dimension() { |
3687 |
|
if (m_DimRegionChooser.has_focus()) return; // avoid conflict with key stroke handler of DimenionRegionChooser |
3688 |
|
m_DimRegionChooser.select_prev_dimension(); |
3689 |
|
} |
3690 |
|
|
3691 |
|
void MainWindow::select_next_dimension() { |
3692 |
|
if (m_DimRegionChooser.has_focus()) return; // avoid conflict with key stroke handler of DimenionRegionChooser |
3693 |
|
m_DimRegionChooser.select_next_dimension(); |
3694 |
|
} |
3695 |
|
|
3696 |
|
#define CLIPBOARD_DIMENSIONREGION_TARGET \ |
3697 |
|
("libgig.DimensionRegion." + m_serializationArchive.rawDataFormat()) |
3698 |
|
|
3699 |
|
void MainWindow::copy_selected_dimrgn() { |
3700 |
|
gig::DimensionRegion* pDimRgn = m_DimRegionChooser.get_main_dimregion(); |
3701 |
|
if (!pDimRgn) { |
3702 |
|
updateClipboardPasteAvailable(); |
3703 |
|
updateClipboardCopyAvailable(); |
3704 |
|
return; |
3705 |
|
} |
3706 |
|
|
3707 |
|
std::vector<Gtk::TargetEntry> targets; |
3708 |
|
targets.push_back( Gtk::TargetEntry(CLIPBOARD_DIMENSIONREGION_TARGET) ); |
3709 |
|
|
3710 |
|
Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get(); |
3711 |
|
clipboard->set( |
3712 |
|
targets, |
3713 |
|
sigc::mem_fun(*this, &MainWindow::on_clipboard_get), |
3714 |
|
sigc::mem_fun(*this, &MainWindow::on_clipboard_clear) |
3715 |
|
); |
3716 |
|
|
3717 |
|
m_serializationArchive.serialize(pDimRgn); |
3718 |
|
|
3719 |
|
updateClipboardPasteAvailable(); |
3720 |
|
} |
3721 |
|
|
3722 |
|
void MainWindow::paste_copied_dimrgn() { |
3723 |
|
Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get(); |
3724 |
|
clipboard->request_contents( |
3725 |
|
CLIPBOARD_DIMENSIONREGION_TARGET, |
3726 |
|
sigc::mem_fun(*this, &MainWindow::on_clipboard_received) |
3727 |
|
); |
3728 |
|
updateClipboardPasteAvailable(); |
3729 |
|
} |
3730 |
|
|
3731 |
|
void MainWindow::adjust_clipboard_content() { |
3732 |
|
MacroEditor* editor = new MacroEditor; |
3733 |
|
editor->setMacro(&m_serializationArchive); |
3734 |
|
editor->show(); |
3735 |
|
} |
3736 |
|
|
3737 |
|
void MainWindow::updateClipboardPasteAvailable() { |
3738 |
|
Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get(); |
3739 |
|
clipboard->request_targets( |
3740 |
|
sigc::mem_fun(*this, &MainWindow::on_clipboard_received_targets) |
3741 |
|
); |
3742 |
|
} |
3743 |
|
|
3744 |
|
void MainWindow::updateClipboardCopyAvailable() { |
3745 |
|
bool bDimensionRegionCopyIsPossible = m_DimRegionChooser.get_main_dimregion(); |
3746 |
|
static_cast<Gtk::MenuItem*>( |
3747 |
|
uiManager->get_widget("/MenuBar/MenuEdit/CopyDimRgn") |
3748 |
|
)->set_sensitive(bDimensionRegionCopyIsPossible); |
3749 |
|
} |
3750 |
|
|
3751 |
|
void MainWindow::on_clipboard_owner_change(GdkEventOwnerChange* event) { |
3752 |
|
updateClipboardPasteAvailable(); |
3753 |
|
} |
3754 |
|
|
3755 |
|
void MainWindow::on_clipboard_get(Gtk::SelectionData& selection_data, guint /*info*/) { |
3756 |
|
const std::string target = selection_data.get_target(); |
3757 |
|
if (target == CLIPBOARD_DIMENSIONREGION_TARGET) { |
3758 |
|
selection_data.set( |
3759 |
|
CLIPBOARD_DIMENSIONREGION_TARGET, 8 /* "format": probably unused*/, |
3760 |
|
&m_serializationArchive.rawData()[0], |
3761 |
|
m_serializationArchive.rawData().size() |
3762 |
|
); |
3763 |
|
} else { |
3764 |
|
std::cerr << "Clipboard: content for unknown target '" << target << "' requested\n"; |
3765 |
|
} |
3766 |
|
} |
3767 |
|
|
3768 |
|
void MainWindow::on_clipboard_clear() { |
3769 |
|
m_serializationArchive.clear(); |
3770 |
|
updateClipboardPasteAvailable(); |
3771 |
|
updateClipboardCopyAvailable(); |
3772 |
|
} |
3773 |
|
|
3774 |
|
void MainWindow::on_clipboard_received(const Gtk::SelectionData& selection_data) { |
3775 |
|
const std::string target = selection_data.get_target(); |
3776 |
|
if (target == CLIPBOARD_DIMENSIONREGION_TARGET) { |
3777 |
|
gig::DimensionRegion* pDimRgn = m_DimRegionChooser.get_main_dimregion(); |
3778 |
|
if (!pDimRgn) return; |
3779 |
|
|
3780 |
|
Glib::ustring errorText; |
3781 |
|
try { |
3782 |
|
m_serializationArchive.decode( |
3783 |
|
selection_data.get_data(), selection_data.get_length() |
3784 |
|
); |
3785 |
|
|
3786 |
|
for (std::set<gig::DimensionRegion*>::iterator itDimReg = dimreg_edit.dimregs.begin(); |
3787 |
|
itDimReg != dimreg_edit.dimregs.end(); ++itDimReg) |
3788 |
|
{ |
3789 |
|
gig::DimensionRegion* pDimRgn = *itDimReg; |
3790 |
|
|
3791 |
|
dimreg_to_be_changed_signal.emit(pDimRgn); |
3792 |
|
|
3793 |
|
m_serializationArchive.deserialize(pDimRgn); |
3794 |
|
|
3795 |
|
dimreg_changed_signal.emit(pDimRgn); |
3796 |
|
} |
3797 |
|
|
3798 |
|
//region_changed() |
3799 |
|
file_changed(); |
3800 |
|
dimreg_changed(); |
3801 |
|
|
3802 |
|
} catch (Serialization::Exception e) { |
3803 |
|
errorText = e.Message; |
3804 |
|
} catch (...) { |
3805 |
|
errorText = _("Unknown exception during deserialization decoding"); |
3806 |
|
} |
3807 |
|
if (!errorText.empty()) { |
3808 |
|
Glib::ustring txt = _("Pasting DimensionRegion failed:\n") + errorText; |
3809 |
|
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
3810 |
|
msg.run(); |
3811 |
|
} |
3812 |
|
} |
3813 |
|
} |
3814 |
|
|
3815 |
|
void MainWindow::on_clipboard_received_targets(const std::vector<Glib::ustring>& targets) { |
3816 |
|
const bool bDimensionRegionPasteIsPossible = |
3817 |
|
std::find(targets.begin(), targets.end(), |
3818 |
|
CLIPBOARD_DIMENSIONREGION_TARGET) != targets.end(); |
3819 |
|
|
3820 |
|
static_cast<Gtk::MenuItem*>( |
3821 |
|
uiManager->get_widget("/MenuBar/MenuEdit/PasteDimRgn") |
3822 |
|
)->set_sensitive(bDimensionRegionPasteIsPossible); |
3823 |
|
|
3824 |
|
static_cast<Gtk::MenuItem*>( |
3825 |
|
uiManager->get_widget("/MenuBar/MenuEdit/AdjustClipboard") |
3826 |
|
)->set_sensitive(bDimensionRegionPasteIsPossible); |
3827 |
|
} |
3828 |
|
|
3829 |
sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() { |
sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() { |
3830 |
return file_structure_to_be_changed_signal; |
return file_structure_to_be_changed_signal; |
3831 |
} |
} |