/[svn]/gigedit/trunk/src/mainwindow.cpp
ViewVC logotype

Diff of /gigedit/trunk/src/mainwindow.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1104 by persson, Sun Mar 18 17:15:00 2007 UTC revision 1138 by persson, Sat Mar 31 09:33:40 2007 UTC
# Line 613  void PropDialog::set_info(DLS::Info* inf Line 613  void PropDialog::set_info(DLS::Info* inf
613      entry[15].set_text(info->Subject);      entry[15].set_text(info->Subject);
614  }  }
615    
616    void InstrumentProps::add_prop(LabelWidget& prop)
617    {
618        table.attach(prop.label, 0, 1, rowno, rowno + 1,
619                     Gtk::FILL, Gtk::SHRINK);
620        table.attach(prop.widget, 1, 2, rowno, rowno + 1,
621                     Gtk::FILL | Gtk::EXPAND, Gtk::SHRINK);
622        rowno++;
623    }
624    
625  InstrumentProps::InstrumentProps()  InstrumentProps::InstrumentProps()
626      : table(2,1),      : table(2,1),
627        quitButton(Gtk::Stock::CLOSE)        quitButton(Gtk::Stock::CLOSE),
628          eName("Name"),
629          eIsDrum("IsDrum"),
630          eMIDIBank("MIDIBank", 0, 16383),
631          eMIDIProgram("MIDIProgram"),
632          eAttenuation("Attenuation", 0, 96, 0, 1),
633          eGainPlus6("Gain +6dB", eAttenuation, -6),
634          eEffectSend("EffectSend", 0, 65535),
635          eFineTune("FineTune", -8400, 8400),
636          ePitchbendRange("PitchbendRange", 0, 12),
637          ePianoReleaseMode("PianoReleaseMode"),
638          eDimensionKeyRangeLow("DimensionKeyRangeLow"),
639          eDimensionKeyRangeHigh("DimensionKeyRangeHigh")
640  {  {
641        set_title("Instrument properties");
642    
643        rowno = 0;
644      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++) {  
         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);  
     }  
645    
646      // vbox { table buttonBox { quitButton } }      add_prop(eName);
647        add_prop(eIsDrum);
648        add_prop(eMIDIBank);
649        add_prop(eMIDIProgram);
650        add_prop(eAttenuation);
651        add_prop(eGainPlus6);
652        add_prop(eEffectSend);
653        add_prop(eFineTune);
654        add_prop(ePitchbendRange);
655        add_prop(ePianoReleaseMode);
656        add_prop(eDimensionKeyRangeLow);
657        add_prop(eDimensionKeyRangeHigh);
658    
659        eDimensionKeyRangeLow.signal_value_changed().connect(
660            sigc::mem_fun(*this, &InstrumentProps::key_range_low_changed));
661        eDimensionKeyRangeHigh.signal_value_changed().connect(
662            sigc::mem_fun(*this, &InstrumentProps::key_range_high_changed));
663    
     //get_vbox()->pack_start(table);  
     // set_border_width(6);  
664      add(vbox);      add(vbox);
665      table.set_border_width(2);      table.set_border_width(5);
666      vbox.pack_start(table);      vbox.pack_start(table);
667      table.show();      table.show();
668      vbox.pack_start(buttonBox);      vbox.pack_start(buttonBox, Gtk::PACK_SHRINK);
669      buttonBox.set_layout(Gtk::BUTTONBOX_END);      buttonBox.set_layout(Gtk::BUTTONBOX_END);
670      buttonBox.set_border_width(5);      buttonBox.set_border_width(5);
671      buttonBox.show();      buttonBox.show();
# Line 663  InstrumentProps::InstrumentProps() Line 676  InstrumentProps::InstrumentProps()
676      quitButton.signal_clicked().connect(      quitButton.signal_clicked().connect(
677          sigc::mem_fun(*this, &InstrumentProps::hide));          sigc::mem_fun(*this, &InstrumentProps::hide));
678    
     // quitButton.grab_default();  
679      quitButton.show();      quitButton.show();
     // add(table);  
680      vbox.show();      vbox.show();
681      show_all_children();      show_all_children();
682  }  }
683    
 extern char* notes[];  
   
684  void InstrumentProps::set_instrument(gig::Instrument* instrument)  void InstrumentProps::set_instrument(gig::Instrument* instrument)
685  {  {
686      char buf[100];      update_gui = false;
687        eName.set_ptr(&instrument->pInfo->Name);
688        eIsDrum.set_ptr(&instrument->IsDrum);
689        eMIDIBank.set_ptr(&instrument->MIDIBank);
690        eMIDIProgram.set_ptr(&instrument->MIDIProgram);
691        eAttenuation.set_ptr(&instrument->Attenuation);
692        eGainPlus6.set_ptr(&instrument->Attenuation);
693        eEffectSend.set_ptr(&instrument->EffectSend);
694        eFineTune.set_ptr(&instrument->FineTune);
695        ePitchbendRange.set_ptr(&instrument->PitchbendRange);
696        ePianoReleaseMode.set_ptr(&instrument->PianoReleaseMode);
697        eDimensionKeyRangeLow.set_ptr(&instrument->DimensionKeyRange.low);
698        eDimensionKeyRangeHigh.set_ptr(&instrument->DimensionKeyRange.high);
699        update_gui = true;
700    }
701    
702      int entryIdx = 0, checkIdx = 0;  void InstrumentProps::key_range_low_changed()
703      entry[entryIdx++].set_text(instrument->pInfo->Name);  {
704      check[checkIdx++].set_active(instrument->IsDrum);      double l = eDimensionKeyRangeLow.get_value();
705      sprintf(buf, "%d", instrument->MIDIBank);      double h = eDimensionKeyRangeHigh.get_value();
706      entry[entryIdx++].set_text(buf);      if (h < l) eDimensionKeyRangeHigh.set_value(l);
707      sprintf(buf, "%d", instrument->MIDIProgram);  }
708      entry[entryIdx++].set_text(buf);  
709      sprintf(buf, "%d", instrument->Attenuation);  void InstrumentProps::key_range_high_changed()
710      entry[entryIdx++].set_text(buf);  {
711      sprintf(buf, "%d", instrument->EffectSend);      double l = eDimensionKeyRangeLow.get_value();
712      entry[entryIdx++].set_text(buf);      double h = eDimensionKeyRangeHigh.get_value();
713      sprintf(buf, "%d", instrument->FineTune);      if (h < l) eDimensionKeyRangeLow.set_value(h);
     entry[entryIdx++].set_text(buf);  
     sprintf(buf, "%d", instrument->PitchbendRange);  
     entry[entryIdx++].set_text(buf);  
     check[checkIdx++].set_active(instrument->PianoReleaseMode);  
     sprintf(buf, "%s%d (%d)..%s%d (%d)",  
             notes[instrument->DimensionKeyRange.low % 12],  
             instrument->DimensionKeyRange.low / 12 - 1,  
             instrument->DimensionKeyRange.low,  
             notes[instrument->DimensionKeyRange.high % 12],  
             instrument->DimensionKeyRange.high / 12 - 1,  
             instrument->DimensionKeyRange.high);  
     entry[entryIdx].set_text(buf);  
714  }  }
715    
716  void MainWindow::load_gig(gig::File* gig, const char* filename)  void MainWindow::load_gig(gig::File* gig, const char* filename)
# Line 1104  void MainWindow::sample_name_changed(con Line 1115  void MainWindow::sample_name_changed(con
1115      gig::Sample* sample = row[m_SamplesModel.m_col_sample];      gig::Sample* sample = row[m_SamplesModel.m_col_sample];
1116      if (group) {      if (group) {
1117          group->Name = name;          group->Name = name;
         std::cout << "Group name changed\n" << std::flush;  
1118      } else if (sample) {      } else if (sample) {
1119          sample->pInfo->Name = name.raw();          sample->pInfo->Name = name.raw();
         std::cout << "Sample name changed\n" << std::flush;  
1120      }      }
1121  }  }
1122    
1123  void MainWindow::instrument_name_changed(const Gtk::TreeModel::Path& path,  void MainWindow::instrument_name_changed(const Gtk::TreeModel::Path& path,
1124                                           const Gtk::TreeModel::iterator& iter) {                                           const Gtk::TreeModel::iterator& iter) {
     std::cout << "Instrument name changed\n" << std::flush;  
1125      if (!iter) return;      if (!iter) return;
1126      Gtk::TreeModel::Row row = *iter;      Gtk::TreeModel::Row row = *iter;
1127      Glib::ustring name = row[m_Columns.m_col_name];      Glib::ustring name = row[m_Columns.m_col_name];

Legend:
Removed from v.1104  
changed lines
  Added in v.1138

  ViewVC Help
Powered by ViewVC