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

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

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

revision 3808 by schoenebeck, Fri Aug 14 11:24:09 2020 UTC revision 3831 by schoenebeck, Thu Oct 15 18:08:49 2020 UTC
# Line 1734  void MainWindow::bringToFront() { Line 1734  void MainWindow::bringToFront() {
1734      #endif      #endif
1735      raise();      raise();
1736      present();      present();
1737    
1738        // restore user specified splitter position
1739        if (Settings::singleton()->mainWindowSplitterPosX >= 0 &&
1740            Settings::singleton()->autoRestoreWindowDimension)
1741        {
1742            const int pos = Settings::singleton()->mainWindowSplitterPosX;
1743            printf("Restoring user's preferred splitter position=%d\n", pos);
1744            m_HPaned.set_position(pos);
1745        }
1746        // this signal handler is late-connected after the UI build-up has settled
1747        // to prevent the UI build-up from overwriting user's setting for splitter
1748        // position unintentionally
1749        m_HPaned.property_position().signal_changed().connect([this]{
1750            if (!Settings::singleton()->autoRestoreWindowDimension) return;
1751            const int pos = m_HPaned.get_position();
1752            printf("Saving user's preferred splitter position=%d\n", pos);
1753            Settings::singleton()->mainWindowSplitterPosX = pos;
1754        });
1755  }  }
1756    
1757  void MainWindow::updateMacroMenu() {  void MainWindow::updateMacroMenu() {
# Line 1945  void MainWindow::on_sel_change() Line 1963  void MainWindow::on_sel_change()
1963      // select item in instrument menu      // select item in instrument menu
1964      std::vector<Gtk::TreeModel::Path> rows = m_TreeViewInstruments.get_selection()->get_selected_rows();      std::vector<Gtk::TreeModel::Path> rows = m_TreeViewInstruments.get_selection()->get_selected_rows();
1965      if (!rows.empty()) {      if (!rows.empty()) {
1966          Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(rows[0]);          // convert index of visual selection (i.e. if filtered) to index of model
1967            Gtk::TreeModel::Path row = m_refInstrumentsModelFilter->convert_path_to_child_path(rows[0]);
1968            Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(row);
1969          if (it) {          if (it) {
1970              Gtk::TreePath path(it);              Gtk::TreePath path(it);
1971              int index = path[0];              int index = path[0];
# Line 3612  bool MainWindow::instr_props_set_instrum Line 3632  bool MainWindow::instr_props_set_instrum
3632  {  {
3633      instrumentProps.signal_name_changed().clear();      instrumentProps.signal_name_changed().clear();
3634    
3635        // get visual selection
3636      std::vector<Gtk::TreeModel::Path> rows = m_TreeViewInstruments.get_selection()->get_selected_rows();      std::vector<Gtk::TreeModel::Path> rows = m_TreeViewInstruments.get_selection()->get_selected_rows();
3637      if (rows.empty()) {      if (rows.empty()) {
3638          instrumentProps.hide();          instrumentProps.hide();
3639          return false;          return false;
3640      }      }
3641    
3642        // convert index of visual selection (i.e. if filtered) to index of model
3643        Gtk::TreeModel::Path path = m_refInstrumentsModelFilter->convert_path_to_child_path(rows[0]);
3644    
3645      //NOTE: was const_iterator before, which did not compile with GTKMM4 development branch, probably going to be fixed before final GTKMM4 release though.      //NOTE: was const_iterator before, which did not compile with GTKMM4 development branch, probably going to be fixed before final GTKMM4 release though.
3646      Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(rows[0]);      Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(path);
3647      if (it) {      if (it) {
3648          Gtk::TreeModel::Row row = *it;          Gtk::TreeModel::Row row = *it;
3649          gig::Instrument* instrument = row[m_InstrumentsModel.m_col_instr];          gig::Instrument* instrument = row[m_InstrumentsModel.m_col_instr];
# Line 3969  void MainWindow::on_instrument_selection Line 3994  void MainWindow::on_instrument_selection
3994              find(children.begin(), children.end(), item);              find(children.begin(), children.end(), item);
3995          if (it != children.end()) {          if (it != children.end()) {
3996              int index = it - children.begin();              int index = it - children.begin();
3997              m_TreeViewInstruments.get_selection()->select(Gtk::TreePath(ToString(index)));  
3998                // convert index of model to index of visual presentation (i.e. if filtered)
3999                Gtk::TreeModel::Path path = m_refInstrumentsModelFilter->convert_child_path_to_path(Gtk::TreePath(ToString(index)));
4000    
4001                if (path)
4002                    m_TreeViewInstruments.get_selection()->select(path);
4003                else
4004                    m_TreeViewInstruments.get_selection()->unselect_all();
4005    
4006              m_RegionChooser.set_instrument(file->GetInstrument(index));              m_RegionChooser.set_instrument(file->GetInstrument(index));
4007          }          }
# Line 4412  void MainWindow::on_action_duplicate_ins Line 4444  void MainWindow::on_action_duplicate_ins
4444      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewInstruments.get_selection();      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewInstruments.get_selection();
4445      std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();      std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
4446      for (int r = 0; r < rows.size(); ++r) {      for (int r = 0; r < rows.size(); ++r) {
4447          Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(rows[r]);          // convert index of visual selection (i.e. if filtered) to index of model
4448            Gtk::TreeModel::Path path = m_refInstrumentsModelFilter->convert_path_to_child_path(rows[r]);
4449            Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(path);
4450          if (it) {          if (it) {
4451              Gtk::TreeModel::Row row = *it;              Gtk::TreeModel::Row row = *it;
4452              gig::Instrument* instrOrig = row[m_InstrumentsModel.m_col_instr];              gig::Instrument* instrOrig = row[m_InstrumentsModel.m_col_instr];
# Line 4443  void MainWindow::on_action_remove_instru Line 4477  void MainWindow::on_action_remove_instru
4477      }      }
4478    
4479      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewInstruments.get_selection();      Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewInstruments.get_selection();
4480      std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();      std::vector<Gtk::TreeModel::Path> rowsVisual = sel->get_selected_rows();
4481    
4482        // convert indeces of visual selection (i.e. if filtered) to indeces of model
4483        std::vector<Gtk::TreeModel::Path> rows;
4484        for (int rv = 0; rv < rowsVisual.size(); ++rv) {
4485            Gtk::TreeModel::Path path = m_refInstrumentsModelFilter->convert_path_to_child_path(rowsVisual[rv]);
4486            if (path)
4487                rows.push_back(path);
4488        }
4489    
4490      for (int r = rows.size() - 1; r >= 0; --r) {      for (int r = rows.size() - 1; r >= 0; --r) {
4491          Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(rows[r]);          Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(rows[r]);
4492          if (!it) continue;          if (!it) continue;
# Line 5038  void MainWindow::on_action_remove_unused Line 5081  void MainWindow::on_action_remove_unused
5081      if (!file) return;      if (!file) return;
5082    
5083      // collect all samples that are not referenced by any instrument      // collect all samples that are not referenced by any instrument
5084      std::list<gig::Sample*> lsamples;      std::list<gig::Sample*> lsamples = unusedSamples(file);
     for (int iSample = 0; file->GetSample(iSample); ++iSample) {  
         gig::Sample* sample = file->GetSample(iSample);  
         bool isUsed = false;  
         for (gig::Instrument* instrument = file->GetFirstInstrument(); instrument;  
                               instrument = file->GetNextInstrument())  
         {  
             for (gig::Region* rgn = instrument->GetFirstRegion(); rgn;  
                               rgn = instrument->GetNextRegion())  
             {  
                 for (int i = 0; i < 256; ++i) {  
                     if (!rgn->pDimensionRegions[i]) continue;  
                     if (rgn->pDimensionRegions[i]->pSample != sample) continue;  
                     isUsed = true;  
                     goto endOfRefSearch;  
                 }  
             }  
         }  
         endOfRefSearch:  
         if (!isUsed) lsamples.push_back(sample);  
     }  
   
5085      if (lsamples.empty()) return;      if (lsamples.empty()) return;
5086    
5087      // notify everybody that we're going to remove these samples      // notify everybody that we're going to remove these samples
# Line 5138  void MainWindow::on_instruments_treeview Line 5160  void MainWindow::on_instruments_treeview
5160          Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewInstruments.get_selection();          Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewInstruments.get_selection();
5161          std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();          std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
5162          if (!rows.empty()) {          if (!rows.empty()) {
5163              Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(rows[0]);              // convert index of visual selection (i.e. if filtered) to index of model
5164                Gtk::TreeModel::Path path = m_refInstrumentsModelFilter->convert_path_to_child_path(rows[0]);
5165                Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(path);
5166              if (it) {              if (it) {
5167                  Gtk::TreeModel::Row row = *it;                  Gtk::TreeModel::Row row = *it;
5168                  src = row[m_InstrumentsModel.m_col_instr];                  src = row[m_InstrumentsModel.m_col_instr];
# Line 5166  void MainWindow::on_instruments_treeview Line 5190  void MainWindow::on_instruments_treeview
5190          const bool found = m_TreeViewInstruments.get_path_at_pos(x, y, path);          const bool found = m_TreeViewInstruments.get_path_at_pos(x, y, path);
5191          if (!found) return;          if (!found) return;
5192    
5193            // convert index of visual selection (i.e. if filtered) to index of model
5194            path = m_refInstrumentsModelFilter->convert_path_to_child_path(path);
5195            if (!path) return;
5196    
5197          Gtk::TreeModel::iterator iter = m_refInstrumentsTreeModel->get_iter(path);          Gtk::TreeModel::iterator iter = m_refInstrumentsTreeModel->get_iter(path);
5198          if (!iter) return;          if (!iter) return;
5199          Gtk::TreeModel::Row row = *iter;          Gtk::TreeModel::Row row = *iter;
# Line 5418  void MainWindow::on_action_combine_instr Line 5446  void MainWindow::on_action_combine_instr
5446          Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewInstruments.get_selection();          Glib::RefPtr<Gtk::TreeSelection> sel = m_TreeViewInstruments.get_selection();
5447          std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();          std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
5448          for (int r = 0; r < rows.size(); ++r) {          for (int r = 0; r < rows.size(); ++r) {
5449              Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(rows[r]);              // convert index of visual selection (i.e. if filtered) to index of model
5450                Gtk::TreeModel::Path path = m_refInstrumentsModelFilter->convert_path_to_child_path(rows[r]);
5451                Gtk::TreeModel::iterator it = m_refInstrumentsTreeModel->get_iter(path);
5452              if (it) {              if (it) {
5453                  Gtk::TreeModel::Row row = *it;                  Gtk::TreeModel::Row row = *it;
5454                  int index = row[m_InstrumentsModel.m_col_nr];                  int index = row[m_InstrumentsModel.m_col_nr];

Legend:
Removed from v.3808  
changed lines
  Added in v.3831

  ViewVC Help
Powered by ViewVC