/[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 1137 by persson, Sat Mar 24 14:04:30 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  namespace {  void InstrumentProps::add_prop(LabelWidget& prop)
617      uint16_t& access_MIDIBank(gig::Instrument* instr)  {
618      {      table.attach(prop.label, 0, 1, rowno, rowno + 1,
619          // TODO: update MIDIBankCoarse/Fine too?                   Gtk::FILL, Gtk::SHRINK);
620          return instr->MIDIBank;      table.attach(prop.widget, 1, 2, rowno, rowno + 1,
621      }                   Gtk::FILL | Gtk::EXPAND, Gtk::SHRINK);
622      uint32_t& access_MIDIProgram(gig::Instrument* instr)      rowno++;
     {  
         return instr->MIDIProgram;  
     }  
623  }  }
624    
625  InstrumentProps::InstrumentProps()  InstrumentProps::InstrumentProps()
626      : table(2,1),      : table(2,1),
627        quitButton(Gtk::Stock::CLOSE),        quitButton(Gtk::Stock::CLOSE),
628        eMIDIBank("MIDIBank", &access_MIDIBank, 0, 16383),        eName("Name"),
629        eMIDIProgram("MIDIProgram", &access_MIDIProgram),        eIsDrum("IsDrum"),
630        eAttenuation("Attenuation", &gig::Instrument::Attenuation),        eMIDIBank("MIDIBank", 0, 16383),
631        eEffectSend("EffectSend", &gig::Instrument::EffectSend, 0, 65536),        eMIDIProgram("MIDIProgram"),
632        eFineTune("FineTune", &gig::Instrument::FineTune, -8400, 8400),        eAttenuation("Attenuation", 0, 96, 0, 1),
633        ePianoReleaseMode("PianoReleaseMode", &gig::Instrument::PianoReleaseMode)        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++) {  
 #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);  
     }  
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 689  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    void InstrumentProps::key_range_low_changed()
703    {
704        double l = eDimensionKeyRangeLow.get_value();
705        double h = eDimensionKeyRangeHigh.get_value();
706        if (h < l) eDimensionKeyRangeHigh.set_value(l);
707    }
708    
709      int entryIdx = 0, checkIdx = 0;  void InstrumentProps::key_range_high_changed()
710      entry[entryIdx++].set_text(instrument->pInfo->Name);  {
711      check[checkIdx++].set_active(instrument->IsDrum);      double l = eDimensionKeyRangeLow.get_value();
712      sprintf(buf, "%d", instrument->MIDIBank);      double h = eDimensionKeyRangeHigh.get_value();
713      entry[entryIdx++].set_text(buf);      if (h < l) eDimensionKeyRangeLow.set_value(h);
     sprintf(buf, "%d", instrument->MIDIProgram);  
     entry[entryIdx++].set_text(buf);  
     sprintf(buf, "%d", instrument->Attenuation);  
     entry[entryIdx++].set_text(buf);  
     sprintf(buf, "%d", instrument->EffectSend);  
     entry[entryIdx++].set_text(buf);  
     sprintf(buf, "%d", instrument->FineTune);  
     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)

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

  ViewVC Help
Powered by ViewVC