24 |
#include <gtkmm/messagedialog.h> |
#include <gtkmm/messagedialog.h> |
25 |
#include <gtkmm/stock.h> |
#include <gtkmm/stock.h> |
26 |
#include <gtkmm/targetentry.h> |
#include <gtkmm/targetentry.h> |
27 |
|
#include <gtkmm/main.h> |
28 |
|
|
29 |
#if GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 6 |
#if GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 6 |
30 |
#define ABOUT_DIALOG |
#define ABOUT_DIALOG |
409 |
loader->launch(); |
loader->launch(); |
410 |
} |
} |
411 |
|
|
412 |
|
void MainWindow::load_instrument(gig::Instrument* instr) { |
413 |
|
if (!instr) { |
414 |
|
Glib::ustring txt = "Provided instrument is NULL!\n"; |
415 |
|
Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); |
416 |
|
msg.run(); |
417 |
|
Gtk::Main::quit(); |
418 |
|
} |
419 |
|
gig::File* pFile = (gig::File*) instr->GetParent(); |
420 |
|
load_gig(pFile, NULL /*file name*/); |
421 |
|
//TODO: automatically select the given instrument |
422 |
|
} |
423 |
|
|
424 |
void MainWindow::on_loader_progress() |
void MainWindow::on_loader_progress() |
425 |
{ |
{ |
426 |
load_dialog->set_fraction(loader->get_progress()); |
load_dialog->set_fraction(loader->get_progress()); |
574 |
: table(2,1) |
: table(2,1) |
575 |
{ |
{ |
576 |
table.set_col_spacings(5); |
table.set_col_spacings(5); |
577 |
char* propLabels[] = { |
const char* propLabels[] = { |
578 |
"Name:", |
"Name:", |
579 |
"CreationDate:", |
"CreationDate:", |
580 |
"Comments:", // TODO: multiline |
"Comments:", // TODO: multiline |
626 |
entry[15].set_text(info->Subject); |
entry[15].set_text(info->Subject); |
627 |
} |
} |
628 |
|
|
629 |
namespace { |
void InstrumentProps::add_prop(LabelWidget& prop) |
630 |
uint16_t& access_MIDIBank(gig::Instrument* instr) |
{ |
631 |
{ |
table.attach(prop.label, 0, 1, rowno, rowno + 1, |
632 |
// TODO: update MIDIBankCoarse/Fine too? |
Gtk::FILL, Gtk::SHRINK); |
633 |
return instr->MIDIBank; |
table.attach(prop.widget, 1, 2, rowno, rowno + 1, |
634 |
} |
Gtk::FILL | Gtk::EXPAND, Gtk::SHRINK); |
635 |
uint32_t& access_MIDIProgram(gig::Instrument* instr) |
rowno++; |
|
{ |
|
|
return instr->MIDIProgram; |
|
|
} |
|
636 |
} |
} |
637 |
|
|
638 |
InstrumentProps::InstrumentProps() |
InstrumentProps::InstrumentProps() |
639 |
: table(2,1), |
: table(2,1), |
640 |
quitButton(Gtk::Stock::CLOSE), |
quitButton(Gtk::Stock::CLOSE), |
641 |
eMIDIBank("MIDIBank", &access_MIDIBank, 0, 16383), |
eName("Name"), |
642 |
eMIDIProgram("MIDIProgram", &access_MIDIProgram), |
eIsDrum("IsDrum"), |
643 |
eAttenuation("Attenuation", &gig::Instrument::Attenuation), |
eMIDIBank("MIDIBank", 0, 16383), |
644 |
eEffectSend("EffectSend", &gig::Instrument::EffectSend, 0, 65536), |
eMIDIProgram("MIDIProgram"), |
645 |
eFineTune("FineTune", &gig::Instrument::FineTune, -8400, 8400), |
eAttenuation("Attenuation", 0, 96, 0, 1), |
646 |
ePianoReleaseMode("PianoReleaseMode", &gig::Instrument::PianoReleaseMode) |
eGainPlus6("Gain +6dB", eAttenuation, -6), |
647 |
|
eEffectSend("EffectSend", 0, 65535), |
648 |
|
eFineTune("FineTune", -8400, 8400), |
649 |
|
ePitchbendRange("PitchbendRange", 0, 12), |
650 |
|
ePianoReleaseMode("PianoReleaseMode"), |
651 |
|
eDimensionKeyRangeLow("DimensionKeyRangeLow"), |
652 |
|
eDimensionKeyRangeHigh("DimensionKeyRangeHigh") |
653 |
{ |
{ |
654 |
|
set_title("Instrument properties"); |
655 |
|
|
656 |
|
rowno = 0; |
657 |
table.set_col_spacings(5); |
table.set_col_spacings(5); |
|
char* propLabels[] = { |
|
|
"Name:", |
|
|
"IsDrum:", |
|
|
"MIDIBank:", |
|
|
"MIDIProgram:", |
|
|
"Attenuation:", |
|
|
"EffectSend:", |
|
|
"FineTune:", |
|
|
"PitchbendRange:", |
|
|
"PianoReleaseMode:", |
|
|
"DimensionKeyRange:", |
|
|
}; |
|
|
int entryIdx = 0, checkIdx = 0; |
|
|
for (int i = 0 ; i < sizeof(propLabels) / sizeof(char*) ; i++) { |
|
|
#if 0 |
|
|
if (i == 3) { |
|
|
table.attach(eMIDIProgram.label, 0, 1, i, i + 1, |
|
|
Gtk::FILL, Gtk::SHRINK); |
|
|
table.attach(eMIDIProgram.widget, 1, 2, i, i + 1, |
|
|
Gtk::FILL | Gtk::EXPAND, Gtk::SHRINK); |
|
|
continue; |
|
|
} |
|
|
#endif |
|
|
label[i].set_text(propLabels[i]); |
|
|
label[i].set_alignment(Gtk::ALIGN_LEFT); |
|
|
table.attach(label[i], 0, 1, i, i + 1, Gtk::FILL, Gtk::SHRINK); |
|
|
if (i == 1 || i == 8) |
|
|
table.attach(check[checkIdx++], 1, 2, i, i + 1, |
|
|
Gtk::FILL | Gtk::EXPAND, Gtk::SHRINK); |
|
|
else |
|
|
table.attach(entry[entryIdx++], 1, 2, i, i + 1, |
|
|
Gtk::FILL | Gtk::EXPAND, Gtk::SHRINK); |
|
|
} |
|
658 |
|
|
659 |
// vbox { table buttonBox { quitButton } } |
add_prop(eName); |
660 |
|
add_prop(eIsDrum); |
661 |
|
add_prop(eMIDIBank); |
662 |
|
add_prop(eMIDIProgram); |
663 |
|
add_prop(eAttenuation); |
664 |
|
add_prop(eGainPlus6); |
665 |
|
add_prop(eEffectSend); |
666 |
|
add_prop(eFineTune); |
667 |
|
add_prop(ePitchbendRange); |
668 |
|
add_prop(ePianoReleaseMode); |
669 |
|
add_prop(eDimensionKeyRangeLow); |
670 |
|
add_prop(eDimensionKeyRangeHigh); |
671 |
|
|
672 |
|
eDimensionKeyRangeLow.signal_value_changed().connect( |
673 |
|
sigc::mem_fun(*this, &InstrumentProps::key_range_low_changed)); |
674 |
|
eDimensionKeyRangeHigh.signal_value_changed().connect( |
675 |
|
sigc::mem_fun(*this, &InstrumentProps::key_range_high_changed)); |
676 |
|
|
|
//get_vbox()->pack_start(table); |
|
|
// set_border_width(6); |
|
677 |
add(vbox); |
add(vbox); |
678 |
table.set_border_width(2); |
table.set_border_width(5); |
679 |
vbox.pack_start(table); |
vbox.pack_start(table); |
680 |
table.show(); |
table.show(); |
681 |
vbox.pack_start(buttonBox); |
vbox.pack_start(buttonBox, Gtk::PACK_SHRINK); |
682 |
buttonBox.set_layout(Gtk::BUTTONBOX_END); |
buttonBox.set_layout(Gtk::BUTTONBOX_END); |
683 |
buttonBox.set_border_width(5); |
buttonBox.set_border_width(5); |
684 |
buttonBox.show(); |
buttonBox.show(); |
689 |
quitButton.signal_clicked().connect( |
quitButton.signal_clicked().connect( |
690 |
sigc::mem_fun(*this, &InstrumentProps::hide)); |
sigc::mem_fun(*this, &InstrumentProps::hide)); |
691 |
|
|
|
// quitButton.grab_default(); |
|
692 |
quitButton.show(); |
quitButton.show(); |
|
// add(table); |
|
693 |
vbox.show(); |
vbox.show(); |
694 |
show_all_children(); |
show_all_children(); |
695 |
} |
} |
696 |
|
|
|
extern char* notes[]; |
|
|
|
|
697 |
void InstrumentProps::set_instrument(gig::Instrument* instrument) |
void InstrumentProps::set_instrument(gig::Instrument* instrument) |
698 |
{ |
{ |
699 |
char buf[100]; |
update_gui = false; |
700 |
|
eName.set_ptr(&instrument->pInfo->Name); |
701 |
int entryIdx = 0, checkIdx = 0; |
eIsDrum.set_ptr(&instrument->IsDrum); |
702 |
entry[entryIdx++].set_text(instrument->pInfo->Name); |
eMIDIBank.set_ptr(&instrument->MIDIBank); |
703 |
check[checkIdx++].set_active(instrument->IsDrum); |
eMIDIProgram.set_ptr(&instrument->MIDIProgram); |
704 |
sprintf(buf, "%d", instrument->MIDIBank); |
eAttenuation.set_ptr(&instrument->Attenuation); |
705 |
entry[entryIdx++].set_text(buf); |
eGainPlus6.set_ptr(&instrument->Attenuation); |
706 |
sprintf(buf, "%d", instrument->MIDIProgram); |
eEffectSend.set_ptr(&instrument->EffectSend); |
707 |
entry[entryIdx++].set_text(buf); |
eFineTune.set_ptr(&instrument->FineTune); |
708 |
sprintf(buf, "%d", instrument->Attenuation); |
ePitchbendRange.set_ptr(&instrument->PitchbendRange); |
709 |
entry[entryIdx++].set_text(buf); |
ePianoReleaseMode.set_ptr(&instrument->PianoReleaseMode); |
710 |
sprintf(buf, "%d", instrument->EffectSend); |
eDimensionKeyRangeLow.set_ptr(&instrument->DimensionKeyRange.low); |
711 |
entry[entryIdx++].set_text(buf); |
eDimensionKeyRangeHigh.set_ptr(&instrument->DimensionKeyRange.high); |
712 |
sprintf(buf, "%d", instrument->FineTune); |
update_gui = true; |
713 |
entry[entryIdx++].set_text(buf); |
} |
714 |
sprintf(buf, "%d", instrument->PitchbendRange); |
|
715 |
entry[entryIdx++].set_text(buf); |
void InstrumentProps::key_range_low_changed() |
716 |
check[checkIdx++].set_active(instrument->PianoReleaseMode); |
{ |
717 |
sprintf(buf, "%s%d (%d)..%s%d (%d)", |
double l = eDimensionKeyRangeLow.get_value(); |
718 |
notes[instrument->DimensionKeyRange.low % 12], |
double h = eDimensionKeyRangeHigh.get_value(); |
719 |
instrument->DimensionKeyRange.low / 12 - 1, |
if (h < l) eDimensionKeyRangeHigh.set_value(l); |
720 |
instrument->DimensionKeyRange.low, |
} |
721 |
notes[instrument->DimensionKeyRange.high % 12], |
|
722 |
instrument->DimensionKeyRange.high / 12 - 1, |
void InstrumentProps::key_range_high_changed() |
723 |
instrument->DimensionKeyRange.high); |
{ |
724 |
entry[entryIdx].set_text(buf); |
double l = eDimensionKeyRangeLow.get_value(); |
725 |
|
double h = eDimensionKeyRangeHigh.get_value(); |
726 |
|
if (h < l) eDimensionKeyRangeLow.set_value(h); |
727 |
} |
} |
728 |
|
|
729 |
void MainWindow::load_gig(gig::File* gig, const char* filename) |
void MainWindow::load_gig(gig::File* gig, const char* filename) |
1128 |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
1129 |
if (group) { |
if (group) { |
1130 |
group->Name = name; |
group->Name = name; |
|
std::cout << "Group name changed\n" << std::flush; |
|
1131 |
} else if (sample) { |
} else if (sample) { |
1132 |
sample->pInfo->Name = name.raw(); |
sample->pInfo->Name = name.raw(); |
|
std::cout << "Sample name changed\n" << std::flush; |
|
1133 |
} |
} |
1134 |
} |
} |
1135 |
|
|
1136 |
void MainWindow::instrument_name_changed(const Gtk::TreeModel::Path& path, |
void MainWindow::instrument_name_changed(const Gtk::TreeModel::Path& path, |
1137 |
const Gtk::TreeModel::iterator& iter) { |
const Gtk::TreeModel::iterator& iter) { |
|
std::cout << "Instrument name changed\n" << std::flush; |
|
1138 |
if (!iter) return; |
if (!iter) return; |
1139 |
Gtk::TreeModel::Row row = *iter; |
Gtk::TreeModel::Row row = *iter; |
1140 |
Glib::ustring name = row[m_Columns.m_col_name]; |
Glib::ustring name = row[m_Columns.m_col_name]; |