/[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 2446 by persson, Sun Apr 28 15:40:43 2013 UTC revision 2507 by persson, Sun Jan 12 19:37:55 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 123  MainWindow::MainWindow() : Line 123  MainWindow::MainWindow() :
123                                           Gtk::Stock::PROPERTIES),                                           Gtk::Stock::PROPERTIES),
124                       sigc::mem_fun(                       sigc::mem_fun(
125                           *this, &MainWindow::show_instr_props));                           *this, &MainWindow::show_instr_props));
126        actionGroup->add(Gtk::Action::create("MidiRules",
127                                             _("_Midi Rules")),
128                         sigc::mem_fun(
129                             *this, &MainWindow::show_midi_rules));
130      actionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT),      actionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT),
131                       sigc::mem_fun(                       sigc::mem_fun(
132                           *this, &MainWindow::on_action_quit));                           *this, &MainWindow::on_action_quit));
133      actionGroup->add(Gtk::Action::create("MenuInstrument", _("_Instrument")));      actionGroup->add(Gtk::Action::create("MenuInstrument", _("_Instrument")));
134    
135      actionGroup->add(Gtk::Action::create("MenuView", _("_View")));  
136        actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit")));
137    
138      Glib::RefPtr<Gtk::ToggleAction> toggle_action =      Glib::RefPtr<Gtk::ToggleAction> toggle_action =
139            Gtk::ToggleAction::create("CopySampleUnity", _("Copy Sample's _Unity Note"), "ffaga");
140        toggle_action->set_active(true);
141        //FIXME: doesn't work, why?
142        toggle_action->set_tooltip(_("Used when dragging a sample to a region's sample reference field."));
143        actionGroup->add(toggle_action);
144    
145        toggle_action =
146            Gtk::ToggleAction::create("CopySampleTune", _("Copy Sample's _Fine Tune"));
147        toggle_action->set_active(true);
148        //FIXME: doesn't work, why?
149        toggle_action->set_tooltip(_("Used when dragging a sample to a region's sample reference field."));
150        actionGroup->add(toggle_action);
151    
152        toggle_action =
153            Gtk::ToggleAction::create("CopySampleLoop", _("Copy Sample's _Loop Points"));
154        toggle_action->set_active(true);
155        //FIXME: doesn't work, why?
156        toggle_action->set_tooltip(_("Used when dragging a sample to a region's sample reference field."));
157        actionGroup->add(toggle_action);
158    
159    
160        actionGroup->add(Gtk::Action::create("MenuView", _("_View")));
161        toggle_action =
162          Gtk::ToggleAction::create("Statusbar", _("_Statusbar"));          Gtk::ToggleAction::create("Statusbar", _("_Statusbar"));
163      toggle_action->set_active(true);      toggle_action->set_active(true);
164      actionGroup->add(toggle_action,      actionGroup->add(toggle_action,
# Line 196  MainWindow::MainWindow() : Line 225  MainWindow::MainWindow() :
225          "      <separator/>"          "      <separator/>"
226          "      <menuitem action='Quit'/>"          "      <menuitem action='Quit'/>"
227          "    </menu>"          "    </menu>"
228            "    <menu action='MenuEdit'>"
229            "      <menuitem action='CopySampleUnity'/>"
230            "      <menuitem action='CopySampleTune'/>"
231            "      <menuitem action='CopySampleLoop'/>"
232            "    </menu>"
233          "    <menu action='MenuInstrument'>"          "    <menu action='MenuInstrument'>"
234          "    </menu>"          "    </menu>"
235          "    <menu action='MenuView'>"          "    <menu action='MenuView'>"
# Line 207  MainWindow::MainWindow() : Line 241  MainWindow::MainWindow() :
241          "  </menubar>"          "  </menubar>"
242          "  <popup name='PopupMenu'>"          "  <popup name='PopupMenu'>"
243          "    <menuitem action='InstrProperties'/>"          "    <menuitem action='InstrProperties'/>"
244            "    <menuitem action='MidiRules'/>"
245          "    <menuitem action='AddInstrument'/>"          "    <menuitem action='AddInstrument'/>"
246          "    <menuitem action='DupInstrument'/>"          "    <menuitem action='DupInstrument'/>"
247          "    <separator/>"          "    <separator/>"
# Line 297  MainWindow::MainWindow() : Line 332  MainWindow::MainWindow() :
332          sigc::mem_fun(*this, &MainWindow::file_changed));          sigc::mem_fun(*this, &MainWindow::file_changed));
333      propDialog.signal_changed().connect(      propDialog.signal_changed().connect(
334          sigc::mem_fun(*this, &MainWindow::file_changed));          sigc::mem_fun(*this, &MainWindow::file_changed));
335        midiRules.signal_changed().connect(
336            sigc::mem_fun(*this, &MainWindow::file_changed));
337    
338      dimreg_edit.signal_dimreg_to_be_changed().connect(      dimreg_edit.signal_dimreg_to_be_changed().connect(
339          dimreg_to_be_changed_signal.make_slot());          dimreg_to_be_changed_signal.make_slot());
# Line 906  void MainWindow::on_action_help_about() Line 943  void MainWindow::on_action_help_about()
943      dialog.set_name("Gigedit");      dialog.set_name("Gigedit");
944  #endif  #endif
945      dialog.set_version(VERSION);      dialog.set_version(VERSION);
946      dialog.set_copyright("Copyright (C) 2006-2013 Andreas Persson");      dialog.set_copyright("Copyright (C) 2006-2014 Andreas Persson");
947      dialog.set_comments(_(      const std::string sComment =
948          "Released under the GNU General Public License.\n"          _("Built " __DATE__ "\nUsing ") +
949          "\n"          ::gig::libraryName() + " " + ::gig::libraryVersion() + "\n\n" +
950          "Please notice that this is still a very young instrument editor. "          _(
951          "So better backup your Gigasampler files before editing them with "              "Gigedit is released under the GNU General Public License.\n"
952          "this application.\n"              "\n"
953          "\n"              "Please notice that this is still a very young instrument editor. "
954          "Please report bugs to: http://bugs.linuxsampler.org")              "So better backup your Gigasampler files before editing them with "
955      );              "this application.\n"
956                "\n"
957                "Please report bugs to: http://bugs.linuxsampler.org"
958            );
959        dialog.set_comments(sComment.c_str());
960      dialog.set_website("http://www.linuxsampler.org");      dialog.set_website("http://www.linuxsampler.org");
961      dialog.set_website_label("http://www.linuxsampler.org");      dialog.set_website_label("http://www.linuxsampler.org");
962      dialog.run();      dialog.run();
# Line 1181  void MainWindow::load_gig(gig::File* gig Line 1222  void MainWindow::load_gig(gig::File* gig
1222      m_TreeView.get_selection()->select(Gtk::TreePath("0"));      m_TreeView.get_selection()->select(Gtk::TreePath("0"));
1223    
1224      instr_props_set_instrument();      instr_props_set_instrument();
1225        gig::Instrument* instrument = get_instrument();
1226        if (instrument) {
1227            midiRules.set_instrument(instrument);
1228        }
1229  }  }
1230    
1231  bool MainWindow::instr_props_set_instrument()  bool MainWindow::instr_props_set_instrument()
# Line 1228  void MainWindow::instr_name_changed_by_i Line 1273  void MainWindow::instr_name_changed_by_i
1273      }      }
1274  }  }
1275    
1276    void MainWindow::show_midi_rules()
1277    {
1278        if (gig::Instrument* instrument = get_instrument())
1279        {
1280            midiRules.set_instrument(instrument);
1281            midiRules.show();
1282            midiRules.deiconify();
1283        }
1284    }
1285    
1286  void MainWindow::on_action_view_status_bar() {  void MainWindow::on_action_view_status_bar() {
1287      Gtk::CheckMenuItem* item =      Gtk::CheckMenuItem* item =
1288          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar"));          dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuView/Statusbar"));
# Line 1239  void MainWindow::on_action_view_status_b Line 1294  void MainWindow::on_action_view_status_b
1294      else                    m_StatusBar.hide();      else                    m_StatusBar.hide();
1295  }  }
1296    
1297    bool MainWindow::is_copy_samples_unity_note_enabled() const {
1298        Gtk::CheckMenuItem* item =
1299            dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleUnity"));
1300        if (!item) {
1301            std::cerr << "/MenuBar/MenuEdit/CopySampleUnity == NULL\n";
1302            return true;
1303        }
1304        return item->get_active();
1305    }
1306    
1307    bool MainWindow::is_copy_samples_fine_tune_enabled() const {
1308        Gtk::CheckMenuItem* item =
1309            dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleTune"));
1310        if (!item) {
1311            std::cerr << "/MenuBar/MenuEdit/CopySampleTune == NULL\n";
1312            return true;
1313        }
1314        return item->get_active();
1315    }
1316    
1317    bool MainWindow::is_copy_samples_loop_enabled() const {
1318        Gtk::CheckMenuItem* item =
1319            dynamic_cast<Gtk::CheckMenuItem*>(uiManager->get_widget("/MenuBar/MenuEdit/CopySampleLoop"));
1320        if (!item) {
1321            std::cerr << "/MenuBar/MenuEdit/CopySampleLoop == NULL\n";
1322            return true;
1323        }
1324        return item->get_active();
1325    }
1326    
1327  void MainWindow::on_button_release(GdkEventButton* button)  void MainWindow::on_button_release(GdkEventButton* button)
1328  {  {
1329      if (button->type == GDK_2BUTTON_PRESS) {      if (button->type == GDK_2BUTTON_PRESS) {
1330          show_instr_props();          show_instr_props();
1331      } else if (button->type == GDK_BUTTON_PRESS && button->button == 3) {      } else if (button->type == GDK_BUTTON_PRESS && button->button == 3) {
1332            // gig v2 files have no midi rules
1333            static_cast<Gtk::MenuItem*>(
1334                uiManager->get_widget("/PopupMenu/MidiRules"))->set_sensitive(
1335                    !(file->pVersion && file->pVersion->major == 2));
1336          popup_menu->popup(button->button, button->time);          popup_menu->popup(button->button, button->time);
1337      }      }
1338  }  }
# Line 1416  void MainWindow::on_action_remove_instru Line 1505  void MainWindow::on_action_remove_instru
1505              }              }
1506  #endif  #endif
1507              instr_props_set_instrument();              instr_props_set_instrument();
1508                instr = get_instrument();
1509                if (instr) {
1510                    midiRules.set_instrument(instr);
1511                } else {
1512                    midiRules.hide();
1513                }
1514          } catch (RIFF::Exception e) {          } catch (RIFF::Exception e) {
1515              Gtk::MessageDialog msg(*this, e.Message.c_str(), false, Gtk::MESSAGE_ERROR);              Gtk::MessageDialog msg(*this, e.Message.c_str(), false, Gtk::MESSAGE_ERROR);
1516              msg.run();              msg.run();
# Line 1564  void MainWindow::on_action_add_sample() Line 1659  void MainWindow::on_action_add_sample()
1659                                 &instrument, sizeof(instrument)) != SF_FALSE)                                 &instrument, sizeof(instrument)) != SF_FALSE)
1660                  {                  {
1661                      sample->MIDIUnityNote = instrument.basenote;                      sample->MIDIUnityNote = instrument.basenote;
1662                        sample->FineTune      = instrument.detune;
1663    
1664                      if (instrument.loop_count && instrument.loops[0].mode != SF_LOOP_NONE) {                      if (instrument.loop_count && instrument.loops[0].mode != SF_LOOP_NONE) {
1665                          sample->Loops = 1;                          sample->Loops = 1;
# Line 1861  void MainWindow::on_sample_label_drop_dr Line 1957  void MainWindow::on_sample_label_drop_dr
1957              channels_changed = true;              channels_changed = true;
1958              region_changed();              region_changed();
1959          }          }
1960          dimreg_edit.set_sample(sample);          dimreg_edit.set_sample(
1961                sample,
1962                is_copy_samples_unity_note_enabled(),
1963                is_copy_samples_fine_tune_enabled(),
1964                is_copy_samples_loop_enabled()
1965            );
1966    
1967          if (sample->Channels == 2 && !stereo_dimension) {          if (sample->Channels == 2 && !stereo_dimension) {
1968              // add samplechannel dimension              // add samplechannel dimension

Legend:
Removed from v.2446  
changed lines
  Added in v.2507

  ViewVC Help
Powered by ViewVC