/[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 1119 by persson, Sat Mar 24 14:04:30 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    namespace {
617        uint16_t& access_MIDIBank(gig::Instrument* instr)
618        {
619            // TODO: update MIDIBankCoarse/Fine too?
620            return instr->MIDIBank;
621        }
622        uint32_t& access_MIDIProgram(gig::Instrument* instr)
623        {
624            return instr->MIDIProgram;
625        }
626    }
627    
628  InstrumentProps::InstrumentProps()  InstrumentProps::InstrumentProps()
629      : table(2,1),      : table(2,1),
630        quitButton(Gtk::Stock::CLOSE)        quitButton(Gtk::Stock::CLOSE),
631          eMIDIBank("MIDIBank", &access_MIDIBank, 0, 16383),
632          eMIDIProgram("MIDIProgram", &access_MIDIProgram),
633          eAttenuation("Attenuation", &gig::Instrument::Attenuation),
634          eEffectSend("EffectSend", &gig::Instrument::EffectSend, 0, 65536),
635          eFineTune("FineTune", &gig::Instrument::FineTune, -8400, 8400),
636          ePianoReleaseMode("PianoReleaseMode", &gig::Instrument::PianoReleaseMode)
637  {  {
638      table.set_col_spacings(5);      table.set_col_spacings(5);
639      char* propLabels[] = {      char* propLabels[] = {
# Line 637  InstrumentProps::InstrumentProps() Line 650  InstrumentProps::InstrumentProps()
650      };      };
651      int entryIdx = 0, checkIdx = 0;      int entryIdx = 0, checkIdx = 0;
652      for (int i = 0 ; i < sizeof(propLabels) / sizeof(char*) ; i++) {      for (int i = 0 ; i < sizeof(propLabels) / sizeof(char*) ; i++) {
653    #if 0
654            if (i == 3) {
655                table.attach(eMIDIProgram.label, 0, 1, i, i + 1,
656                             Gtk::FILL, Gtk::SHRINK);
657                table.attach(eMIDIProgram.widget, 1, 2, i, i + 1,
658                             Gtk::FILL | Gtk::EXPAND, Gtk::SHRINK);
659                continue;
660            }
661    #endif
662          label[i].set_text(propLabels[i]);          label[i].set_text(propLabels[i]);
663          label[i].set_alignment(Gtk::ALIGN_LEFT);          label[i].set_alignment(Gtk::ALIGN_LEFT);
664          table.attach(label[i], 0, 1, i, i + 1, Gtk::FILL, Gtk::SHRINK);          table.attach(label[i], 0, 1, i, i + 1, Gtk::FILL, Gtk::SHRINK);
# Line 665  InstrumentProps::InstrumentProps() Line 687  InstrumentProps::InstrumentProps()
687      quitButton.grab_focus();      quitButton.grab_focus();
688    
689      quitButton.signal_clicked().connect(      quitButton.signal_clicked().connect(
690          sigc::mem_fun(*this, &InstrumentProps::hide));          sigc::mem_fun(*this, &InstrumentProps::hide));
691    
692      // quitButton.grab_default();      // quitButton.grab_default();
693      quitButton.show();      quitButton.show();
# Line 726  void MainWindow::load_gig(gig::File* gig Line 748  void MainWindow::load_gig(gig::File* gig
748      int instrument_index = 0;      int instrument_index = 0;
749      Gtk::RadioMenuItem::Group instrument_group;      Gtk::RadioMenuItem::Group instrument_group;
750      for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ;      for (gig::Instrument* instrument = gig->GetFirstInstrument() ; instrument ;
751           instrument = gig->GetNextInstrument()) {           instrument = gig->GetNextInstrument()) {
752          Gtk::TreeModel::iterator iter = m_refTreeModel->append();          Gtk::TreeModel::iterator iter = m_refTreeModel->append();
753          Gtk::TreeModel::Row row = *iter;          Gtk::TreeModel::Row row = *iter;
754          row[m_Columns.m_col_name] = instrument->pInfo->Name.c_str();          row[m_Columns.m_col_name] = instrument->pInfo->Name.c_str();
755          row[m_Columns.m_col_instr] = instrument;          row[m_Columns.m_col_instr] = instrument;
756          // create a menu item for this instrument          // create a menu item for this instrument
757          Gtk::RadioMenuItem* item =          Gtk::RadioMenuItem* item =
758              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 786  void MainWindow::load_gig(gig::File* gig
786              }              }
787          }          }
788      }      }
789    
790        // select the first instrument
791        Glib::RefPtr<Gtk::TreeSelection> tree_sel_ref = m_TreeView.get_selection();
792        tree_sel_ref->select(Gtk::TreePath("0"));
793  }  }
794    
795  void MainWindow::show_instr_props()  void MainWindow::show_instr_props()
# Line 827  void MainWindow::on_action_add_instrumen Line 853  void MainWindow::on_action_add_instrumen
853      if (!file) return;      if (!file) return;
854      gig::Instrument* instrument = file->AddInstrument();      gig::Instrument* instrument = file->AddInstrument();
855      __instrument_indexer++;      __instrument_indexer++;
856      instrument->pInfo->Name =      instrument->pInfo->Name =
857          "Unnamed Instrument " + ToString(__instrument_indexer);          "Unnamed Instrument " + ToString(__instrument_indexer);
858      // update instrument tree view      // update instrument tree view
859      Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append();      Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append();
# Line 1104  void MainWindow::sample_name_changed(con Line 1130  void MainWindow::sample_name_changed(con
1130      gig::Sample* sample = row[m_SamplesModel.m_col_sample];      gig::Sample* sample = row[m_SamplesModel.m_col_sample];
1131      if (group) {      if (group) {
1132          group->Name = name;          group->Name = name;
         std::cout << "Group name changed\n" << std::flush;  
1133      } else if (sample) {      } else if (sample) {
1134          sample->pInfo->Name = name.raw();          sample->pInfo->Name = name.raw();
         std::cout << "Sample name changed\n" << std::flush;  
1135      }      }
1136  }  }
1137    
1138  void MainWindow::instrument_name_changed(const Gtk::TreeModel::Path& path,  void MainWindow::instrument_name_changed(const Gtk::TreeModel::Path& path,
1139                                           const Gtk::TreeModel::iterator& iter) {                                           const Gtk::TreeModel::iterator& iter) {
     std::cout << "Instrument name changed\n" << std::flush;  
1140      if (!iter) return;      if (!iter) return;
1141      Gtk::TreeModel::Row row = *iter;      Gtk::TreeModel::Row row = *iter;
1142      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.1119

  ViewVC Help
Powered by ViewVC