/[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 2464 by schoenebeck, Thu Sep 5 00:49:13 2013 UTC revision 2550 by schoenebeck, Wed May 14 01:31:30 2014 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright (C) 2006-2013 Andreas Persson   * Copyright (C) 2006-2014 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 42  Line 42 
42  #include <sndfile.h>  #include <sndfile.h>
43    
44  #include "mainwindow.h"  #include "mainwindow.h"
45    #include "Settings.h"
46    #include "CombineInstrumentsDialog.h"
47  #include "../../gfx/status_attached.xpm"  #include "../../gfx/status_attached.xpm"
48  #include "../../gfx/status_detached.xpm"  #include "../../gfx/status_detached.xpm"
49    
# Line 89  MainWindow::MainWindow() : Line 90  MainWindow::MainWindow() :
90      dimreg_vbox.pack_start(dimreg_hbox, Gtk::PACK_SHRINK);      dimreg_vbox.pack_start(dimreg_hbox, Gtk::PACK_SHRINK);
91      m_HPaned.add2(dimreg_vbox);      m_HPaned.add2(dimreg_vbox);
92    
93        dimreg_label.set_tooltip_text(_("To automatically apply your changes above globally to the entire instrument, check all 3 check boxes on the right."));
94        dimreg_all_regions.set_tooltip_text(_("If checked: all changes you perform above will automatically be applied to all regions of this instrument as well."));
95        dimreg_all_dimregs.set_tooltip_text(_("If checked: all changes you perform above will automatically be applied as well to all dimension splits of the region selected below."));
96        dimreg_stereo.set_tooltip_text(_("If checked: all changes you perform above will automatically be applied to both audio channel splits (only if a \"stereo\" dimension is defined below)."));
97    
98      m_TreeViewNotebook.append_page(m_ScrolledWindowSamples, _("Samples"));      m_TreeViewNotebook.append_page(m_ScrolledWindowSamples, _("Samples"));
99      m_TreeViewNotebook.append_page(m_ScrolledWindow, _("Instruments"));      m_TreeViewNotebook.append_page(m_ScrolledWindow, _("Instruments"));
# Line 123  MainWindow::MainWindow() : Line 128  MainWindow::MainWindow() :
128                                           Gtk::Stock::PROPERTIES),                                           Gtk::Stock::PROPERTIES),
129                       sigc::mem_fun(                       sigc::mem_fun(
130                           *this, &MainWindow::show_instr_props));                           *this, &MainWindow::show_instr_props));
131        actionGroup->add(Gtk::Action::create("MidiRules",
132                                             _("_Midi Rules")),
133                         sigc::mem_fun(
134                             *this, &MainWindow::show_midi_rules));
135      actionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT),      actionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT),
136                       sigc::mem_fun(                       sigc::mem_fun(
137                           *this, &MainWindow::on_action_quit));                           *this, &MainWindow::on_action_quit));
# Line 132  MainWindow::MainWindow() : Line 141  MainWindow::MainWindow() :
141      actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit")));      actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit")));
142    
143      Glib::RefPtr<Gtk::ToggleAction> toggle_action =      Glib::RefPtr<Gtk::ToggleAction> toggle_action =
144          Gtk::ToggleAction::create("CopySampleUnity", _("Copy Sample's _Unity Note"), "ffaga");          Gtk::ToggleAction::create("CopySampleUnity", _("Copy Sample's _Unity Note"));
145      toggle_action->set_active(true);      toggle_action->set_active(true);
     //FIXME: doesn't work, why?  
     toggle_action->set_tooltip(_("Used when dragging a sample to a region's sample reference field."));  
146      actionGroup->add(toggle_action);      actionGroup->add(toggle_action);
147    
148      toggle_action =      toggle_action =
149          Gtk::ToggleAction::create("CopySampleTune", _("Copy Sample's _Fine Tune"));          Gtk::ToggleAction::create("CopySampleTune", _("Copy Sample's _Fine Tune"));
150      toggle_action->set_active(true);      toggle_action->set_active(true);
     //FIXME: doesn't work, why?  
     toggle_action->set_tooltip(_("Used when dragging a sample to a region's sample reference field."));  
151      actionGroup->add(toggle_action);      actionGroup->add(toggle_action);
152    
153      toggle_action =      toggle_action =
154          Gtk::ToggleAction::create("CopySampleLoop", _("Copy Sample's _Loop Points"));          Gtk::ToggleAction::create("CopySampleLoop", _("Copy Sample's _Loop Points"));
155      toggle_action->set_active(true);      toggle_action->set_active(true);
     //FIXME: doesn't work, why?  
     toggle_action->set_tooltip(_("Used when dragging a sample to a region's sample reference field."));  
156      actionGroup->add(toggle_action);      actionGroup->add(toggle_action);
157    
158    
# Line 180  MainWindow::MainWindow() : Line 183  MainWindow::MainWindow() :
183          sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument)          sigc::mem_fun(*this, &MainWindow::on_action_remove_instrument)
184      );      );
185    
186    
187        actionGroup->add(Gtk::Action::create("MenuSettings", _("_Settings")));
188        
189        toggle_action =
190            Gtk::ToggleAction::create("WarnUserOnExtensions", _("Show warning on format _extensions"));
191        toggle_action->set_active(Settings::singleton()->warnUserOnExtensions);
192        actionGroup->add(
193            toggle_action,
194            sigc::mem_fun(*this, &MainWindow::on_action_warn_user_on_extensions)
195        );
196    
197    
198        actionGroup->add(Gtk::Action::create("MenuTools", _("_Tools")));
199    
200        actionGroup->add(
201            Gtk::Action::create("CombineInstruments", _("_Combine Instruments...")),
202            sigc::mem_fun(*this, &MainWindow::on_action_combine_instruments)
203        );
204    
205    
206      // sample right-click popup actions      // sample right-click popup actions
207      actionGroup->add(      actionGroup->add(
208          Gtk::Action::create("SampleProperties", Gtk::Stock::PROPERTIES),          Gtk::Action::create("SampleProperties", Gtk::Stock::PROPERTIES),
# Line 231  MainWindow::MainWindow() : Line 254  MainWindow::MainWindow() :
254          "    <menu action='MenuView'>"          "    <menu action='MenuView'>"
255          "      <menuitem action='Statusbar'/>"          "      <menuitem action='Statusbar'/>"
256          "    </menu>"          "    </menu>"
257            "    <menu action='MenuTools'>"
258            "      <menuitem action='CombineInstruments'/>"
259            "    </menu>"
260            "    <menu action='MenuSettings'>"
261            "      <menuitem action='WarnUserOnExtensions'/>"
262            "    </menu>"
263          "    <menu action='MenuHelp'>"          "    <menu action='MenuHelp'>"
264          "      <menuitem action='About'/>"          "      <menuitem action='About'/>"
265          "    </menu>"          "    </menu>"
266          "  </menubar>"          "  </menubar>"
267          "  <popup name='PopupMenu'>"          "  <popup name='PopupMenu'>"
268          "    <menuitem action='InstrProperties'/>"          "    <menuitem action='InstrProperties'/>"
269            "    <menuitem action='MidiRules'/>"
270          "    <menuitem action='AddInstrument'/>"          "    <menuitem action='AddInstrument'/>"
271          "    <menuitem action='DupInstrument'/>"          "    <menuitem action='DupInstrument'/>"
272          "    <separator/>"          "    <separator/>"
# Line 254  MainWindow::MainWindow() : Line 284  MainWindow::MainWindow() :
284      uiManager->add_ui_from_string(ui_info);      uiManager->add_ui_from_string(ui_info);
285    
286      popup_menu = dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/PopupMenu"));      popup_menu = dynamic_cast<Gtk::Menu*>(uiManager->get_widget("/PopupMenu"));
287        
288        // Set tooltips for menu items (for some reason, setting a tooltip on the
289        // respective Gtk::Action objects above will simply be ignored, no matter
290        // if using Gtk::Action::set_tooltip() or passing the tooltip string on
291        // Gtk::Action::create()).
292        {
293            Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
294                uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity"));
295            item->set_tooltip_text(_("Used when dragging a sample to a region's sample reference field. You may disable this for example if you want to replace an existing sample in a region with a new sample, but don't want that the region's current unity note setting will be altered by this action."));
296        }
297        {
298            Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
299                uiManager->get_widget("/MenuBar/MenuEdit/CopySampleTune"));
300            item->set_tooltip_text(_("Used when dragging a sample to a region's sample reference field. You may disable this for example if you want to replace an existing sample in a region with a new sample, but don't want that the region's current sample playback tuning will be altered by this action."));
301        }
302        {
303            Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
304                uiManager->get_widget("/MenuBar/MenuEdit/CopySampleLoop"));
305            item->set_tooltip_text(_("Used when dragging a sample to a region's sample reference field. You may disable this for example if you want to replace an existing sample in a region with a new sample, but don't want that the region's current loop informations to be altered by this action."));
306        }
307        {
308            Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
309                uiManager->get_widget("/MenuBar/MenuSettings/WarnUserOnExtensions"));
310            item->set_tooltip_text(_("If checked, a warning will be shown whenever you try to use a feature which is based on a LinuxSampler extension ontop of the original gig format, which would not work with the Gigasampler/GigaStudio application."));
311        }
312    
313      instrument_menu = static_cast<Gtk::MenuItem*>(      instrument_menu = static_cast<Gtk::MenuItem*>(
314          uiManager->get_widget("/MenuBar/MenuInstrument"))->get_submenu();          uiManager->get_widget("/MenuBar/MenuInstrument"))->get_submenu();
# Line 282  MainWindow::MainWindow() : Line 337  MainWindow::MainWindow() :
337      // Create the Tree model:      // Create the Tree model:
338      m_refTreeModel = Gtk::ListStore::create(m_Columns);      m_refTreeModel = Gtk::ListStore::create(m_Columns);
339      m_TreeView.set_model(m_refTreeModel);      m_TreeView.set_model(m_refTreeModel);
340        m_TreeView.set_tooltip_text(_("Right click here for actions on instruments & MIDI Rules."));
341      instrument_name_connection = m_refTreeModel->signal_row_changed().connect(      instrument_name_connection = m_refTreeModel->signal_row_changed().connect(
342          sigc::mem_fun(*this, &MainWindow::instrument_name_changed)          sigc::mem_fun(*this, &MainWindow::instrument_name_changed)
343      );      );
# Line 293  MainWindow::MainWindow() : Line 349  MainWindow::MainWindow() :
349      // create samples treeview (including its data model)      // create samples treeview (including its data model)
350      m_refSamplesTreeModel = SamplesTreeStore::create(m_SamplesModel);      m_refSamplesTreeModel = SamplesTreeStore::create(m_SamplesModel);
351      m_TreeViewSamples.set_model(m_refSamplesTreeModel);      m_TreeViewSamples.set_model(m_refSamplesTreeModel);
352        m_TreeViewSamples.set_tooltip_text(_("To actually use a sample, drag it from this list view to \"Sample\" -> \"Sample:\" on the region's settings pane on the right.\n\nRight click here for more actions on samples."));
353      // m_TreeViewSamples.set_reorderable();      // m_TreeViewSamples.set_reorderable();
354      m_TreeViewSamples.append_column_editable("Samples", m_SamplesModel.m_col_name);      m_TreeViewSamples.append_column_editable("Samples", m_SamplesModel.m_col_name);
355      m_TreeViewSamples.set_headers_visible(false);      m_TreeViewSamples.set_headers_visible(false);
# Line 327  MainWindow::MainWindow() : Line 384  MainWindow::MainWindow() :
384          sigc::mem_fun(*this, &MainWindow::file_changed));          sigc::mem_fun(*this, &MainWindow::file_changed));
385      propDialog.signal_changed().connect(      propDialog.signal_changed().connect(
386          sigc::mem_fun(*this, &MainWindow::file_changed));          sigc::mem_fun(*this, &MainWindow::file_changed));
387        midiRules.signal_changed().connect(
388            sigc::mem_fun(*this, &MainWindow::file_changed));
389    
390      dimreg_edit.signal_dimreg_to_be_changed().connect(      dimreg_edit.signal_dimreg_to_be_changed().connect(
391          dimreg_to_be_changed_signal.make_slot());          dimreg_to_be_changed_signal.make_slot());
# Line 375  MainWindow::MainWindow() : Line 434  MainWindow::MainWindow() :
434    
435      // start with a new gig file by default      // start with a new gig file by default
436      on_action_file_new();      on_action_file_new();
437    
438        // select 'Instruments' tab by default
439        // (gtk allows this only if the tab childs are visible, thats why it's here)
440        m_TreeViewNotebook.set_current_page(1);
441  }  }
442    
443  MainWindow::~MainWindow()  MainWindow::~MainWindow()
# Line 927  void MainWindow::on_action_file_properti Line 990  void MainWindow::on_action_file_properti
990      propDialog.deiconify();      propDialog.deiconify();
991  }  }
992    
993    void MainWindow::on_action_warn_user_on_extensions() {
994        Settings::singleton()->warnUserOnExtensions =
995            !Settings::singleton()->warnUserOnExtensions;
996    }
997    
998  void MainWindow::on_action_help_about()  void MainWindow::on_action_help_about()
999  {  {
1000      Gtk::AboutDialog dialog;      Gtk::AboutDialog dialog;
# Line 936  void MainWindow::on_action_help_about() Line 1004  void MainWindow::on_action_help_about()
1004      dialog.set_name("Gigedit");      dialog.set_name("Gigedit");
1005  #endif  #endif
1006      dialog.set_version(VERSION);      dialog.set_version(VERSION);
1007      dialog.set_copyright("Copyright (C) 2006-2013 Andreas Persson");      dialog.set_copyright("Copyright (C) 2006-2014 Andreas Persson");
1008      dialog.set_comments(_(      const std::string sComment =
1009          "Released under the GNU General Public License.\n"          _("Built " __DATE__ "\nUsing ") +
1010          "\n"          ::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" +
1011          "Please notice that this is still a very young instrument editor. "          _(
1012          "So better backup your Gigasampler files before editing them with "              "Gigedit is released under the GNU General Public License.\n"
1013          "this application.\n"              "\n"
1014          "\n"              "Please notice that this is still a very young instrument editor. "
1015          "Please report bugs to: http://bugs.linuxsampler.org")              "So better backup your Gigasampler files before editing them with "
1016      );              "this application.\n"
1017                "\n"
1018                "Please report bugs to: http://bugs.linuxsampler.org"
1019            );
1020        dialog.set_comments(sComment.c_str());
1021      dialog.set_website("http://www.linuxsampler.org");      dialog.set_website("http://www.linuxsampler.org");
1022      dialog.set_website_label("http://www.linuxsampler.org");      dialog.set_website_label("http://www.linuxsampler.org");
1023      dialog.run();      dialog.run();
# Line 1211  void MainWindow::load_gig(gig::File* gig Line 1283  void MainWindow::load_gig(gig::File* gig
1283      m_TreeView.get_selection()->select(Gtk::TreePath("0"));      m_TreeView.get_selection()->select(Gtk::TreePath("0"));
1284    
1285      instr_props_set_instrument();      instr_props_set_instrument();
1286        gig::Instrument* instrument = get_instrument();
1287        if (instrument) {
1288            midiRules.set_instrument(instrument);
1289        }
1290  }  }
1291    
1292  bool MainWindow::instr_props_set_instrument()  bool MainWindow::instr_props_set_instrument()
# Line 1258  void MainWindow::instr_name_changed_by_i Line 1334  void MainWindow::instr_name_changed_by_i
1334      }      }
1335  }  }
1336    
1337    void MainWindow::show_midi_rules()
1338    {
1339        if (gig::Instrument* instrument = get_instrument())
1340        {
1341            midiRules.set_instrument(instrument);
1342            midiRules.show();
1343            midiRules.deiconify();
1344        }
1345    }
1346    
1347  void MainWindow::on_action_view_status_bar() {  void MainWindow::on_action_view_status_bar() {
1348      Gtk::CheckMenuItem* item =      Gtk::CheckMenuItem* item =
1349          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar"));          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar"));
# Line 1304  void MainWindow::on_button_release(GdkEv Line 1390  void MainWindow::on_button_release(GdkEv
1390      if (button->type == GDK_2BUTTON_PRESS) {      if (button->type == GDK_2BUTTON_PRESS) {
1391          show_instr_props();          show_instr_props();
1392      } else if (button->type == GDK_BUTTON_PRESS && button->button == 3) {      } else if (button->type == GDK_BUTTON_PRESS && button->button == 3) {
1393            // gig v2 files have no midi rules
1394            static_cast<Gtk::MenuItem*>(
1395                uiManager->get_widget("/PopupMenu/MidiRules"))->set_sensitive(
1396                    !(file->pVersion && file->pVersion->major == 2));
1397          popup_menu->popup(button->button, button->time);          popup_menu->popup(button->button, button->time);
1398      }      }
1399  }  }
# Line 1476  void MainWindow::on_action_remove_instru Line 1566  void MainWindow::on_action_remove_instru
1566              }              }
1567  #endif  #endif
1568              instr_props_set_instrument();              instr_props_set_instrument();
1569                instr = get_instrument();
1570                if (instr) {
1571                    midiRules.set_instrument(instr);
1572                } else {
1573                    midiRules.hide();
1574                }
1575          } catch (RIFF::Exception e) {          } catch (RIFF::Exception e) {
1576              Gtk::MessageDialog msg(*this, e.Message.c_str(), false, Gtk::MESSAGE_ERROR);              Gtk::MessageDialog msg(*this, e.Message.c_str(), false, Gtk::MESSAGE_ERROR);
1577              msg.run();              msg.run();
# Line 1624  void MainWindow::on_action_add_sample() Line 1720  void MainWindow::on_action_add_sample()
1720                                 &instrument, sizeof(instrument)) != SF_FALSE)                                 &instrument, sizeof(instrument)) != SF_FALSE)
1721                  {                  {
1722                      sample->MIDIUnityNote = instrument.basenote;                      sample->MIDIUnityNote = instrument.basenote;
1723                        sample->FineTune      = instrument.detune;
1724    
1725                      if (instrument.loop_count && instrument.loops[0].mode != SF_LOOP_NONE) {                      if (instrument.loop_count && instrument.loops[0].mode != SF_LOOP_NONE) {
1726                          sample->Loops = 1;                          sample->Loops = 1;
# Line 1917  void MainWindow::on_sample_label_drop_dr Line 2014  void MainWindow::on_sample_label_drop_dr
2014          bool channels_changed = false;          bool channels_changed = false;
2015          if (sample->Channels == 1 && stereo_dimension) {          if (sample->Channels == 1 && stereo_dimension) {
2016              // remove the samplechannel dimension              // remove the samplechannel dimension
2017    /* commented out, because it makes it impossible building up an instrument from scratch using two separate L/R samples
2018              region->DeleteDimension(stereo_dimension);              region->DeleteDimension(stereo_dimension);
2019              channels_changed = true;              channels_changed = true;
2020              region_changed();              region_changed();
2021    */
2022          }          }
2023          dimreg_edit.set_sample(          dimreg_edit.set_sample(
2024              sample,              sample,
# Line 2019  void MainWindow::instrument_name_changed Line 2118  void MainWindow::instrument_name_changed
2118      }      }
2119  }  }
2120    
2121    void MainWindow::on_action_combine_instruments() {
2122        CombineInstrumentsDialog* d = new CombineInstrumentsDialog(*this, file);
2123        d->show_all();
2124        d->resize(500, 400);
2125        d->run();
2126        if (d->fileWasChanged()) {
2127            // update GUI with new instrument just created
2128            add_instrument(d->newCombinedInstrument());
2129        }
2130        delete d;
2131    }
2132    
2133  void MainWindow::set_file_is_shared(bool b) {  void MainWindow::set_file_is_shared(bool b) {
2134      this->file_is_shared = b;      this->file_is_shared = b;
2135    

Legend:
Removed from v.2464  
changed lines
  Added in v.2550

  ViewVC Help
Powered by ViewVC