--- gigedit/trunk/src/gigedit/mainwindow.cpp 2007/10/10 15:48:54 1396 +++ gigedit/trunk/src/gigedit/mainwindow.cpp 2007/10/27 12:28:33 1460 @@ -24,6 +24,7 @@ #include #include #include +#include #include "global.h" @@ -49,6 +50,9 @@ #include "mainwindow.h" +#include "../../gfx/status_attached.xpm" +#include "../../gfx/status_detached.xpm" + template inline std::string ToString(T o) { std::stringstream ss; ss << o; @@ -126,6 +130,14 @@ *this, &MainWindow::on_action_quit)); actionGroup->add(Gtk::Action::create("MenuInstrument", _("_Instrument"))); + actionGroup->add(Gtk::Action::create("MenuView", _("_View"))); + Glib::RefPtr toggle_action = + Gtk::ToggleAction::create("Statusbar", _("_Statusbar")); + toggle_action->set_active(true); + actionGroup->add(toggle_action, + sigc::mem_fun( + *this, &MainWindow::on_action_view_status_bar)); + action = Gtk::Action::create("MenuHelp", Gtk::Stock::HELP); actionGroup->add(Gtk::Action::create("MenuHelp", action->property_label())); @@ -181,6 +193,9 @@ " " " " " " + " " + " " + " " #ifdef ABOUT_DIALOG " " " " @@ -210,6 +225,12 @@ m_VBox.pack_start(m_HPaned); m_VBox.pack_start(m_RegionChooser, Gtk::PACK_SHRINK); m_VBox.pack_start(m_DimRegionChooser, Gtk::PACK_SHRINK); + m_VBox.pack_start(m_StatusBar, Gtk::PACK_SHRINK); + + // Status Bar: + m_StatusBar.pack_start(m_AttachedStateLabel, Gtk::PACK_SHRINK); + m_StatusBar.pack_start(m_AttachedStateImage, Gtk::PACK_SHRINK); + m_StatusBar.show(); m_RegionChooser.signal_region_selected().connect( sigc::mem_fun(*this, &MainWindow::region_changed) ); @@ -294,7 +315,7 @@ file = 0; file_is_changed = false; - file_is_shared = false; + set_file_is_shared(false); show_all_children(); @@ -429,7 +450,7 @@ // free libgig's gig::File instance if (file && !file_is_shared) delete file; file = NULL; - file_is_shared = false; + set_file_is_shared(false); } void MainWindow::on_action_file_new() @@ -765,6 +786,18 @@ #ifdef ABOUT_DIALOG Gtk::AboutDialog dialog; dialog.set_version(VERSION); + dialog.set_copyright("Copyright (C) 2006,2007 Andreas Persson"); + dialog.set_comments( + "Released under the GNU General Public License.\n" + "\n" + "Please notice that this is still a very young instrument editor. " + "So better backup your Gigasampler files before editing them with " + "this application.\n" + "\n" + "Please report bugs to: http://bugs.linuxsampler.org" + ); + dialog.set_website("http://www.linuxsampler.org"); + dialog.set_website_label("http://www.linuxsampler.org"); dialog.run(); #endif } @@ -825,12 +858,42 @@ entry[15].set_text(info->Subject); } +void InstrumentProps::set_IsDrum(bool value) +{ + instrument->IsDrum = value; +} + +void InstrumentProps::set_MIDIBank(uint16_t value) +{ + instrument->MIDIBank = value; +} + +void InstrumentProps::set_MIDIProgram(uint32_t value) +{ + instrument->MIDIProgram = value; +} + +void InstrumentProps::set_DimensionKeyRange_low(uint8_t value) +{ + instrument->DimensionKeyRange.low = value; + if (value > instrument->DimensionKeyRange.high) { + eDimensionKeyRangeHigh.set_value(value); + } +} + +void InstrumentProps::set_DimensionKeyRange_high(uint8_t value) +{ + instrument->DimensionKeyRange.high = value; + if (value < instrument->DimensionKeyRange.low) { + eDimensionKeyRangeLow.set_value(value); + } +} + void InstrumentProps::add_prop(BoolEntry& boolentry) { table.attach(boolentry.widget, 0, 2, rowno, rowno + 1, Gtk::FILL, Gtk::SHRINK); rowno++; - boolentry.signal_changed_by_user().connect(instrument_changed.make_slot()); } void InstrumentProps::add_prop(BoolEntryPlus6& boolentry) @@ -838,7 +901,6 @@ table.attach(boolentry.widget, 0, 2, rowno, rowno + 1, Gtk::FILL, Gtk::SHRINK); rowno++; - boolentry.signal_changed_by_user().connect(instrument_changed.make_slot()); } void InstrumentProps::add_prop(LabelWidget& prop) @@ -848,7 +910,6 @@ table.attach(prop.widget, 1, 2, rowno, rowno + 1, Gtk::FILL | Gtk::EXPAND, Gtk::SHRINK); rowno++; - prop.signal_changed_by_user().connect(instrument_changed.make_slot()); } InstrumentProps::InstrumentProps() @@ -865,10 +926,25 @@ ePitchbendRange("Pitchbend range", 0, 12), ePianoReleaseMode("Piano release mode"), eDimensionKeyRangeLow("Dimension key range low"), - eDimensionKeyRangeHigh("Dimension key range high") + eDimensionKeyRangeHigh("Dimension key range high"), + update_model(0) { set_title("Instrument properties"); + connect(eIsDrum, &InstrumentProps::set_IsDrum); + connect(eMIDIBank, &InstrumentProps::set_MIDIBank); + connect(eMIDIProgram, &InstrumentProps::set_MIDIProgram); + connect(eAttenuation, &gig::Instrument::Attenuation); + connect(eGainPlus6, &gig::Instrument::Attenuation); + connect(eEffectSend, &gig::Instrument::EffectSend); + connect(eFineTune, &gig::Instrument::FineTune); + connect(ePitchbendRange, &gig::Instrument::PitchbendRange); + connect(ePianoReleaseMode, &gig::Instrument::PianoReleaseMode); + connect(eDimensionKeyRangeLow, + &InstrumentProps::set_DimensionKeyRange_low); + connect(eDimensionKeyRangeHigh, + &InstrumentProps::set_DimensionKeyRange_high); + rowno = 0; table.set_col_spacings(5); @@ -885,11 +961,6 @@ add_prop(eDimensionKeyRangeLow); add_prop(eDimensionKeyRangeHigh); - eDimensionKeyRangeLow.signal_changed_by_user().connect( - sigc::mem_fun(*this, &InstrumentProps::key_range_low_changed)); - eDimensionKeyRangeHigh.signal_changed_by_user().connect( - sigc::mem_fun(*this, &InstrumentProps::key_range_high_changed)); - add(vbox); table.set_border_width(5); vbox.pack_start(table); @@ -912,34 +983,22 @@ void InstrumentProps::set_instrument(gig::Instrument* instrument) { + this->instrument = instrument; + + update_model++; eName.set_ptr(&instrument->pInfo->Name); - eIsDrum.set_ptr(&instrument->IsDrum); - eMIDIBank.set_ptr(&instrument->MIDIBank); - eMIDIProgram.set_ptr(&instrument->MIDIProgram); - eAttenuation.set_ptr(&instrument->Attenuation); - eGainPlus6.set_ptr(&instrument->Attenuation); - eEffectSend.set_ptr(&instrument->EffectSend); - eFineTune.set_ptr(&instrument->FineTune); - ePitchbendRange.set_ptr(&instrument->PitchbendRange); - ePianoReleaseMode.set_ptr(&instrument->PianoReleaseMode); - eDimensionKeyRangeLow.set_ptr(0); - eDimensionKeyRangeHigh.set_ptr(0); - eDimensionKeyRangeLow.set_ptr(&instrument->DimensionKeyRange.low); - eDimensionKeyRangeHigh.set_ptr(&instrument->DimensionKeyRange.high); -} - -void InstrumentProps::key_range_low_changed() -{ - double l = eDimensionKeyRangeLow.get_value(); - double h = eDimensionKeyRangeHigh.get_value(); - if (h < l) eDimensionKeyRangeHigh.set_value(l); -} - -void InstrumentProps::key_range_high_changed() -{ - double l = eDimensionKeyRangeLow.get_value(); - double h = eDimensionKeyRangeHigh.get_value(); - if (h < l) eDimensionKeyRangeLow.set_value(h); + eIsDrum.set_value(instrument->IsDrum); + eMIDIBank.set_value(instrument->MIDIBank); + eMIDIProgram.set_value(instrument->MIDIProgram); + eAttenuation.set_value(instrument->Attenuation); + eGainPlus6.set_value(instrument->Attenuation); + eEffectSend.set_value(instrument->EffectSend); + eFineTune.set_value(instrument->FineTune); + ePitchbendRange.set_value(instrument->PitchbendRange); + ePianoReleaseMode.set_value(instrument->PianoReleaseMode); + eDimensionKeyRangeLow.set_value(instrument->DimensionKeyRange.low); + eDimensionKeyRangeHigh.set_value(instrument->DimensionKeyRange.high); + update_model--; } sigc::signal& InstrumentProps::signal_instrument_changed() @@ -958,7 +1017,7 @@ void MainWindow::load_gig(gig::File* gig, const char* filename, bool isSharedInstrument) { file = 0; - file_is_shared = isSharedInstrument; + set_file_is_shared(isSharedInstrument); this->filename = filename ? filename : _("Unsaved Gig File"); set_title(Glib::filename_display_basename(this->filename)); @@ -1035,6 +1094,17 @@ } } +void MainWindow::on_action_view_status_bar() { + Gtk::CheckMenuItem* item = + dynamic_cast(uiManager->get_widget("/MenuBar/MenuView/Statusbar")); + if (!item) { + std::cerr << "/MenuBar/MenuView/Statusbar == NULL\n"; + return; + } + if (item->get_active()) m_StatusBar.show(); + else m_StatusBar.hide(); +} + void MainWindow::on_button_release(GdkEventButton* button) { if (button->type == GDK_2BUTTON_PRESS) { @@ -1462,6 +1532,8 @@ // notify we're done with altering region_changed_signal.emit(region); + file_changed(); + return; } // drop failed @@ -1502,6 +1574,22 @@ } } +void MainWindow::set_file_is_shared(bool b) { + this->file_is_shared = b; + + if (file_is_shared) { + m_AttachedStateLabel.set_label(_("live-mode")); + m_AttachedStateImage.set( + Gdk::Pixbuf::create_from_xpm_data(status_attached_xpm) + ); + } else { + m_AttachedStateLabel.set_label(_("stand-alone")); + m_AttachedStateImage.set( + Gdk::Pixbuf::create_from_xpm_data(status_detached_xpm) + ); + } +} + sigc::signal& MainWindow::signal_file_structure_to_be_changed() { return file_structure_to_be_changed_signal; }