/[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 1101 by schoenebeck, Sat Mar 17 17:46:09 2007 UTC revision 1138 by persson, Sat Mar 31 09:33:40 2007 UTC
# Line 54  MainWindow::MainWindow() Line 54  MainWindow::MainWindow()
54      // Handle selection      // Handle selection
55      Glib::RefPtr<Gtk::TreeSelection> tree_sel_ref = m_TreeView.get_selection();      Glib::RefPtr<Gtk::TreeSelection> tree_sel_ref = m_TreeView.get_selection();
56      tree_sel_ref->signal_changed().connect(      tree_sel_ref->signal_changed().connect(
57          sigc::mem_fun(*this, &MainWindow::on_sel_change));          sigc::mem_fun(*this, &MainWindow::on_sel_change));
58    
59      // m_TreeView.set_reorderable();      // m_TreeView.set_reorderable();
60    
# Line 201  MainWindow::MainWindow() Line 201  MainWindow::MainWindow()
201      m_VBox.pack_start(m_DimRegionChooser, Gtk::PACK_SHRINK);      m_VBox.pack_start(m_DimRegionChooser, Gtk::PACK_SHRINK);
202    
203      m_RegionChooser.signal_sel_changed().connect(      m_RegionChooser.signal_sel_changed().connect(
204          sigc::mem_fun(*this, &MainWindow::region_changed) );          sigc::mem_fun(*this, &MainWindow::region_changed) );
205      m_DimRegionChooser.signal_sel_changed().connect(      m_DimRegionChooser.signal_sel_changed().connect(
206          sigc::mem_fun(*this, &MainWindow::dimreg_changed) );          sigc::mem_fun(*this, &MainWindow::dimreg_changed) );
207    
208    
209      // Create the Tree model:      // Create the Tree model:
# Line 266  void MainWindow::on_sel_change() Line 266  void MainWindow::on_sel_change()
266      Glib::RefPtr<Gtk::TreeSelection> tree_sel_ref = m_TreeView.get_selection();      Glib::RefPtr<Gtk::TreeSelection> tree_sel_ref = m_TreeView.get_selection();
267    
268      Gtk::TreeModel::iterator it = tree_sel_ref->get_selected();      Gtk::TreeModel::iterator it = tree_sel_ref->get_selected();
269      if (it)      if (it) {
270      {          Gtk::TreeModel::Row row = *it;
271          Gtk::TreeModel::Row row = *it;          std::cout << row[m_Columns.m_col_name] << std::endl;
         std::cout << row[m_Columns.m_col_name] << std::endl;  
272    
273          if (row[m_Columns.m_col_instr])          m_RegionChooser.set_instrument(row[m_Columns.m_col_instr]);
274              m_RegionChooser.set_instrument(row[m_Columns.m_col_instr]);      } else {
275            m_RegionChooser.set_instrument(0);
276      }      }
277  }  }
278    
# Line 418  void MainWindow::on_loader_finished() Line 418  void MainWindow::on_loader_finished()
418      printf("Loader finished!\n");      printf("Loader finished!\n");
419      printf("on_loader_finished self=%x\n", Glib::Thread::self());      printf("on_loader_finished self=%x\n", Glib::Thread::self());
420      load_gig(loader->gig, loader->filename);      load_gig(loader->gig, loader->filename);
   
     Glib::RefPtr<Gtk::TreeSelection> tree_sel_ref = m_TreeView.get_selection();  
     tree_sel_ref->select(Gtk::TreePath("0"));  
   
421      load_dialog->hide();      load_dialog->hide();
422  }  }
423    
# Line 617  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 665  InstrumentProps::InstrumentProps() Line 674  InstrumentProps::InstrumentProps()
674      quitButton.grab_focus();      quitButton.grab_focus();
675    
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      int entryIdx = 0, checkIdx = 0;      eIsDrum.set_ptr(&instrument->IsDrum);
689      entry[entryIdx++].set_text(instrument->pInfo->Name);      eMIDIBank.set_ptr(&instrument->MIDIBank);
690      check[checkIdx++].set_active(instrument->IsDrum);      eMIDIProgram.set_ptr(&instrument->MIDIProgram);
691      sprintf(buf, "%d", instrument->MIDIBank);      eAttenuation.set_ptr(&instrument->Attenuation);
692      entry[entryIdx++].set_text(buf);      eGainPlus6.set_ptr(&instrument->Attenuation);
693      sprintf(buf, "%d", instrument->MIDIProgram);      eEffectSend.set_ptr(&instrument->EffectSend);
694      entry[entryIdx++].set_text(buf);      eFineTune.set_ptr(&instrument->FineTune);
695      sprintf(buf, "%d", instrument->Attenuation);      ePitchbendRange.set_ptr(&instrument->PitchbendRange);
696      entry[entryIdx++].set_text(buf);      ePianoReleaseMode.set_ptr(&instrument->PianoReleaseMode);
697      sprintf(buf, "%d", instrument->EffectSend);      eDimensionKeyRangeLow.set_ptr(&instrument->DimensionKeyRange.low);
698      entry[entryIdx++].set_text(buf);      eDimensionKeyRangeHigh.set_ptr(&instrument->DimensionKeyRange.high);
699      sprintf(buf, "%d", instrument->FineTune);      update_gui = true;
700      entry[entryIdx++].set_text(buf);  }
701      sprintf(buf, "%d", instrument->PitchbendRange);  
702      entry[entryIdx++].set_text(buf);  void InstrumentProps::key_range_low_changed()
703      check[checkIdx++].set_active(instrument->PianoReleaseMode);  {
704      sprintf(buf, "%s%d (%d)..%s%d (%d)",      double l = eDimensionKeyRangeLow.get_value();
705              notes[instrument->DimensionKeyRange.low % 12],      double h = eDimensionKeyRangeHigh.get_value();
706              instrument->DimensionKeyRange.low / 12 - 1,      if (h < l) eDimensionKeyRangeHigh.set_value(l);
707              instrument->DimensionKeyRange.low,  }
708              notes[instrument->DimensionKeyRange.high % 12],  
709              instrument->DimensionKeyRange.high / 12 - 1,  void InstrumentProps::key_range_high_changed()
710              instrument->DimensionKeyRange.high);  {
711      entry[entryIdx].set_text(buf);      double l = eDimensionKeyRangeLow.get_value();
712        double h = eDimensionKeyRangeHigh.get_value();
713        if (h < l) eDimensionKeyRangeLow.set_value(h);
714  }  }
715    
716  void MainWindow::load_gig(gig::File* gig, const char* filename)  void MainWindow::load_gig(gig::File* gig, const char* filename)
# Line 726  void MainWindow::load_gig(gig::File* gig Line 733  void MainWindow::load_gig(gig::File* gig
733      int instrument_index = 0;      int instrument_index = 0;
734      Gtk::RadioMenuItem::Group instrument_group;      Gtk::RadioMenuItem::Group instrument_group;
735      for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ;      for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ;
736           instrument = gig->GetNextInstrument()) {           instrument = gig->GetNextInstrument()) {
737          Gtk::TreeModel::iterator iter = m_refTreeModel->append();          Gtk::TreeModel::iterator iter = m_refTreeModel->append();
738          Gtk::TreeModel::Row row = *iter;          Gtk::TreeModel::Row row = *iter;
739          row[m_Columns.m_col_name] = instrument->pInfo->Name.c_str();          row[m_Columns.m_col_name] = instrument->pInfo->Name.c_str();
740          row[m_Columns.m_col_instr] = instrument;          row[m_Columns.m_col_instr] = instrument;
741          // create a menu item for this instrument          // create a menu item for this instrument
742          Gtk::RadioMenuItem* item =          Gtk::RadioMenuItem* item =
743              new Gtk::RadioMenuItem(instrument_group, instrument->pInfo->Name.c_str());              new Gtk::RadioMenuItem(instrument_group, instrument->pInfo->Name.c_str());
# Line 764  void MainWindow::load_gig(gig::File* gig Line 771  void MainWindow::load_gig(gig::File* gig
771              }              }
772          }          }
773      }      }
774    
775        // select the first instrument
776        Glib::RefPtr<Gtk::TreeSelection> tree_sel_ref = m_TreeView.get_selection();
777        tree_sel_ref->select(Gtk::TreePath("0"));
778  }  }
779    
780  void MainWindow::show_instr_props()  void MainWindow::show_instr_props()
# Line 827  void MainWindow::on_action_add_instrumen Line 838  void MainWindow::on_action_add_instrumen
838      if (!file) return;      if (!file) return;
839      gig::Instrument* instrument = file->AddInstrument();      gig::Instrument* instrument = file->AddInstrument();
840      __instrument_indexer++;      __instrument_indexer++;
841      instrument->pInfo->Name =      instrument->pInfo->Name =
842          "Unnamed Instrument " + ToString(__instrument_indexer);          "Unnamed Instrument " + ToString(__instrument_indexer);
843      // update instrument tree view      // update instrument tree view
844      Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append();      Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append();
# 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.1101  
changed lines
  Added in v.1138

  ViewVC Help
Powered by ViewVC