/[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 2683 by schoenebeck, Mon Dec 29 16:30:21 2014 UTC revision 2695 by schoenebeck, Tue Jan 6 18:11:27 2015 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright (C) 2006-2014 Andreas Persson   * Copyright (C) 2006-2015 Andreas Persson
3   *   *
4   * This program is free software; you can redistribute it and/or   * This program is free software; you can redistribute it and/or
5   * modify it under the terms of the GNU General Public License as   * modify it under the terms of the GNU General Public License as
# Line 217  MainWindow::MainWindow() : Line 217  MainWindow::MainWindow() :
217          sigc::mem_fun(*this, &MainWindow::on_action_warn_user_on_extensions)          sigc::mem_fun(*this, &MainWindow::on_action_warn_user_on_extensions)
218      );      );
219    
220        toggle_action =
221            Gtk::ToggleAction::create("SyncSamplerInstrumentSelection", _("Synchronize sampler's instrument selection"));
222        toggle_action->set_active(Settings::singleton()->syncSamplerInstrumentSelection);
223        actionGroup->add(
224            toggle_action,
225            sigc::mem_fun(*this, &MainWindow::on_action_sync_sampler_instrument_selection)
226        );
227    
228    
229      actionGroup->add(Gtk::Action::create("MenuTools", _("_Tools")));      actionGroup->add(Gtk::Action::create("MenuTools", _("_Tools")));
230    
# Line 336  MainWindow::MainWindow() : Line 344  MainWindow::MainWindow() :
344          "    </menu>"          "    </menu>"
345          "    <menu action='MenuSettings'>"          "    <menu action='MenuSettings'>"
346          "      <menuitem action='WarnUserOnExtensions'/>"          "      <menuitem action='WarnUserOnExtensions'/>"
347            "      <menuitem action='SyncSamplerInstrumentSelection'/>"
348          "    </menu>"          "    </menu>"
349          "    <menu action='MenuHelp'>"          "    <menu action='MenuHelp'>"
350          "      <menuitem action='About'/>"          "      <menuitem action='About'/>"
# Line 397  MainWindow::MainWindow() : Line 406  MainWindow::MainWindow() :
406      }      }
407      {      {
408          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
409                uiManager->get_widget("/MenuBar/MenuSettings/SyncSamplerInstrumentSelection"));
410            item->set_tooltip_text(_("If checked, the sampler's current instrument will automatically be switched whenever another instrument was selected in gigedit (only available in live-mode)."));
411        }
412        {
413            Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
414              uiManager->get_widget("/MenuBar/MenuTools/CombineInstruments"));              uiManager->get_widget("/MenuBar/MenuTools/CombineInstruments"));
415          item->set_tooltip_text(_("Create combi sounds out of individual sounds of this .gig file."));          item->set_tooltip_text(_("Create combi sounds out of individual sounds of this .gig file."));
416      }      }
# Line 489  MainWindow::MainWindow() : Line 503  MainWindow::MainWindow() :
503      m_TreeViewScripts.signal_button_press_event().connect_notify(      m_TreeViewScripts.signal_button_press_event().connect_notify(
504          sigc::mem_fun(*this, &MainWindow::on_script_treeview_button_release)          sigc::mem_fun(*this, &MainWindow::on_script_treeview_button_release)
505      );      );
506      //FIXME: why the heck does this double click signal_row_activated() only fired while CTRL key is pressed ?      //FIXME: why the heck does this double click signal_row_activated() only fire while CTRL key is pressed ?
507      m_TreeViewScripts.signal_row_activated().connect(      m_TreeViewScripts.signal_row_activated().connect(
508          sigc::mem_fun(*this, &MainWindow::script_double_clicked)          sigc::mem_fun(*this, &MainWindow::script_double_clicked)
509      );      );
# Line 548  MainWindow::MainWindow() : Line 562  MainWindow::MainWindow() :
562          sigc::mem_fun(*this, &MainWindow::on_samples_to_be_removed)          sigc::mem_fun(*this, &MainWindow::on_samples_to_be_removed)
563      );      );
564    
565        dimreg_edit.signal_select_sample().connect(
566            sigc::mem_fun(*this, &MainWindow::select_sample)
567        );
568    
569      m_RegionChooser.signal_instrument_struct_to_be_changed().connect(      m_RegionChooser.signal_instrument_struct_to_be_changed().connect(
570          sigc::hide(          sigc::hide(
571              sigc::bind(              sigc::bind(
# Line 688  void MainWindow::on_sel_change() Line 706  void MainWindow::on_sel_change()
706      }      }
707    
708      m_RegionChooser.set_instrument(get_instrument());      m_RegionChooser.set_instrument(get_instrument());
709    
710        if (Settings::singleton()->syncSamplerInstrumentSelection) {
711            switch_sampler_instrument_signal.emit(get_instrument());
712        }
713  }  }
714    
715  void loader_progress_callback(gig::progress_t* progress)  void loader_progress_callback(gig::progress_t* progress)
# Line 925  bool MainWindow::close_confirmation_dial Line 947  bool MainWindow::close_confirmation_dial
947      int response = dialog.run();      int response = dialog.run();
948      dialog.hide();      dialog.hide();
949    
950        // user decided to exit app without saving
951        if (response == Gtk::RESPONSE_NO) return true;
952    
953        // user cancelled dialog, thus don't close app
954        if (response == Gtk::RESPONSE_CANCEL) return false;
955    
956      // TODO: the following return valid is disabled and hard coded instead for      // TODO: the following return valid is disabled and hard coded instead for
957      // now, due to the fact that saving with progress bar is now implemented      // now, due to the fact that saving with progress bar is now implemented
958      // asynchronously, as a result the app does not close automatically anymore      // asynchronously, as a result the app does not close automatically anymore
# Line 1339  void MainWindow::on_action_warn_user_on_ Line 1367  void MainWindow::on_action_warn_user_on_
1367          !Settings::singleton()->warnUserOnExtensions;          !Settings::singleton()->warnUserOnExtensions;
1368  }  }
1369    
1370    void MainWindow::on_action_sync_sampler_instrument_selection() {
1371        Settings::singleton()->syncSamplerInstrumentSelection =
1372            !Settings::singleton()->syncSamplerInstrumentSelection;
1373    }
1374    
1375  void MainWindow::on_action_help_about()  void MainWindow::on_action_help_about()
1376  {  {
1377      Gtk::AboutDialog dialog;      Gtk::AboutDialog dialog;
# Line 1348  void MainWindow::on_action_help_about() Line 1381  void MainWindow::on_action_help_about()
1381      dialog.set_name("Gigedit");      dialog.set_name("Gigedit");
1382  #endif  #endif
1383      dialog.set_version(VERSION);      dialog.set_version(VERSION);
1384      dialog.set_copyright("Copyright (C) 2006-2014 Andreas Persson");      dialog.set_copyright("Copyright (C) 2006-2015 Andreas Persson");
1385      const std::string sComment =      const std::string sComment =
1386          _("Built " __DATE__ "\nUsing ") +          _("Built " __DATE__ "\nUsing ") +
1387          ::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" +          ::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" +
# Line 1860  void MainWindow::on_instrument_selection Line 1893  void MainWindow::on_instrument_selection
1893      }      }
1894  }  }
1895    
1896    /// Returns true if requested dimension region was successfully selected and scrolled to in the list view, false on error.
1897    bool MainWindow::select_dimension_region(gig::DimensionRegion* dimRgn) {
1898        gig::Region* pRegion = (gig::Region*) dimRgn->GetParent();
1899        gig::Instrument* pInstrument = (gig::Instrument*) pRegion->GetParent();
1900    
1901        Glib::RefPtr<Gtk::TreeModel> model = m_TreeView.get_model();
1902        for (int i = 0; i < model->children().size(); ++i) {
1903            Gtk::TreeModel::Row row = model->children()[i];
1904            if (row[m_Columns.m_col_instr] == pInstrument) {
1905                // select and show the respective instrument in the list view
1906                show_intruments_tab();
1907                m_TreeView.get_selection()->select(model->children()[i]);
1908                Gtk::TreePath path(
1909                    m_TreeView.get_selection()->get_selected()
1910                );
1911                m_TreeView.scroll_to_row(path);
1912                on_sel_change(); // the regular instrument selection change callback
1913    
1914                // select respective region in the region selector
1915                m_RegionChooser.set_region(pRegion);
1916    
1917                // select and show the respective dimension region in the editor
1918                //update_dimregs();
1919                if (!m_DimRegionChooser.select_dimregion(dimRgn)) return false;
1920                //dimreg_edit.set_dim_region(dimRgn);
1921    
1922                return true;
1923            }
1924        }
1925    
1926        return false;
1927    }
1928    
1929    void MainWindow::select_sample(gig::Sample* sample) {
1930        Glib::RefPtr<Gtk::TreeModel> model = m_TreeViewSamples.get_model();
1931        for (int g = 0; g < model->children().size(); ++g) {
1932            Gtk::TreeModel::Row rowGroup = model->children()[g];
1933            for (int s = 0; s < rowGroup.children().size(); ++s) {
1934                Gtk::TreeModel::Row rowSample = rowGroup.children()[s];
1935                if (rowSample[m_SamplesModel.m_col_sample] == sample) {
1936                    show_samples_tab();
1937                    m_TreeViewSamples.get_selection()->select(rowGroup.children()[s]);
1938                    Gtk::TreePath path(
1939                        m_TreeViewSamples.get_selection()->get_selected()
1940                    );
1941                    m_TreeViewSamples.scroll_to_row(path);
1942                    return;
1943                }
1944            }
1945        }
1946    }
1947    
1948  void MainWindow::on_sample_treeview_button_release(GdkEventButton* button) {  void MainWindow::on_sample_treeview_button_release(GdkEventButton* button) {
1949      if (button->type == GDK_BUTTON_PRESS && button->button == 3) {      if (button->type == GDK_BUTTON_PRESS && button->button == 3) {
1950          Gtk::Menu* sample_popup =          Gtk::Menu* sample_popup =
# Line 2813  void MainWindow::on_action_view_referenc Line 2898  void MainWindow::on_action_view_referenc
2898    
2899      ReferencesView* d = new ReferencesView(*this);      ReferencesView* d = new ReferencesView(*this);
2900      d->setSample(sample);      d->setSample(sample);
2901        d->dimension_region_selected.connect(
2902            sigc::mem_fun(*this, &MainWindow::select_dimension_region)
2903        );
2904      d->show_all();      d->show_all();
2905      d->resize(500, 400);      d->resize(500, 400);
2906      d->run();      d->run();
# Line 2996  void MainWindow::set_file_is_shared(bool Line 3084  void MainWindow::set_file_is_shared(bool
3084              Gdk::Pixbuf::create_from_xpm_data(status_detached_xpm)              Gdk::Pixbuf::create_from_xpm_data(status_detached_xpm)
3085          );          );
3086      }      }
3087    
3088        {
3089            Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
3090                uiManager->get_widget("/MenuBar/MenuSettings/SyncSamplerInstrumentSelection"));
3091            if (item) item->set_sensitive(b);
3092        }
3093  }  }
3094    
3095  void MainWindow::on_sample_ref_count_incremented(gig::Sample* sample, int offset) {  void MainWindow::on_sample_ref_count_incremented(gig::Sample* sample, int offset) {
# Line 3097  sigc::signal<void, int/*key*/, int/*velo Line 3191  sigc::signal<void, int/*key*/, int/*velo
3191  sigc::signal<void, int/*key*/, int/*velocity*/>& MainWindow::signal_keyboard_key_released() {  sigc::signal<void, int/*key*/, int/*velocity*/>& MainWindow::signal_keyboard_key_released() {
3192      return m_RegionChooser.signal_keyboard_key_released();      return m_RegionChooser.signal_keyboard_key_released();
3193  }  }
3194    
3195    sigc::signal<void, gig::Instrument*>& MainWindow::signal_switch_sampler_instrument() {
3196        return switch_sampler_instrument_signal;
3197    }

Legend:
Removed from v.2683  
changed lines
  Added in v.2695

  ViewVC Help
Powered by ViewVC