/[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 3711 by schoenebeck, Fri Jan 10 14:22:25 2020 UTC revision 3749 by schoenebeck, Sun Feb 16 18:39:53 2020 UTC
# Line 96  MainWindow::MainWindow() : Line 96  MainWindow::MainWindow() :
96    
97      if (!Settings::singleton()->autoRestoreWindowDimension) {      if (!Settings::singleton()->autoRestoreWindowDimension) {
98  #if GTKMM_MAJOR_VERSION >= 3  #if GTKMM_MAJOR_VERSION >= 3
99          set_default_size(960, 600);          set_default_size(1010, -1);
100  #else  #else
101          set_default_size(865, 600);          set_default_size(915, -1);
102  #endif  #endif
103          set_position(Gtk::WIN_POS_CENTER);          set_position(Gtk::WIN_POS_CENTER);
104      }      }
# Line 522  MainWindow::MainWindow() : Line 522  MainWindow::MainWindow() :
522          "DupInstrument", sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument)          "DupInstrument", sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument)
523      );      );
524      m_actionGroup->add_action(      m_actionGroup->add_action(
525            "MoveInstrument", sigc::mem_fun(*this, &MainWindow::on_action_move_instr)
526        );
527        m_actionGroup->add_action(
528          "CombInstruments", sigc::mem_fun(*this, &MainWindow::on_action_combine_instruments)          "CombInstruments", sigc::mem_fun(*this, &MainWindow::on_action_combine_instruments)
529      );      );
530      m_actionGroup->add_action(      m_actionGroup->add_action(
# Line 543  MainWindow::MainWindow() : Line 546  MainWindow::MainWindow() :
546          sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument)          sigc::mem_fun(*this, &MainWindow::on_action_duplicate_instrument)
547      );      );
548      actionGroup->add(      actionGroup->add(
549            Gtk::Action::create("MoveInstrument", _("Move _Instrument To ...")),
550            Gtk::AccelKey(GDK_KEY_i, primaryModifierKey),
551            sigc::mem_fun(*this, &MainWindow::on_action_move_instr)
552        );
553        actionGroup->add(
554          Gtk::Action::create("CombInstruments", _("_Combine Instruments ...")),          Gtk::Action::create("CombInstruments", _("_Combine Instruments ...")),
555          Gtk::AccelKey(GDK_KEY_j, primaryModifierKey),          Gtk::AccelKey(GDK_KEY_j, primaryModifierKey),
556          sigc::mem_fun(*this, &MainWindow::on_action_combine_instruments)          sigc::mem_fun(*this, &MainWindow::on_action_combine_instruments)
# Line 898  MainWindow::MainWindow() : Line 906  MainWindow::MainWindow() :
906          "          <attribute name='label' translatable='yes'>Duplicate Instrument</attribute>"          "          <attribute name='label' translatable='yes'>Duplicate Instrument</attribute>"
907          "          <attribute name='action'>AppMenu.DupInstrument</attribute>"          "          <attribute name='action'>AppMenu.DupInstrument</attribute>"
908          "        </item>"          "        </item>"
909            "        <item id='MoveInstrument'>"
910            "          <attribute name='label' translatable='yes'>Move Instrument To ...</attribute>"
911            "          <attribute name='action'>AppMenu.MoveInstrument</attribute>"
912            "        </item>"
913          "        <item id='CombInstruments'>"          "        <item id='CombInstruments'>"
914          "          <attribute name='label' translatable='yes'>Combine Instrument</attribute>"          "          <attribute name='label' translatable='yes'>Combine Instrument</attribute>"
915          "          <attribute name='action'>AppMenu.CombInstruments</attribute>"          "          <attribute name='action'>AppMenu.CombInstruments</attribute>"
# Line 1027  MainWindow::MainWindow() : Line 1039  MainWindow::MainWindow() :
1039          "        <attribute name='label' translatable='yes'>Duplicate Instrument</attribute>"          "        <attribute name='label' translatable='yes'>Duplicate Instrument</attribute>"
1040          "        <attribute name='action'>AppMenu.DupInstrument</attribute>"          "        <attribute name='action'>AppMenu.DupInstrument</attribute>"
1041          "      </item>"          "      </item>"
1042            "      <item id='MoveInstrument'>"
1043            "        <attribute name='label' translatable='yes'>Move Instrument To ...</attribute>"
1044            "        <attribute name='action'>AppMenu.MoveInstrument</attribute>"
1045            "      </item>"
1046          "      <item id='CombInstruments'>"          "      <item id='CombInstruments'>"
1047          "        <attribute name='label' translatable='yes'>Combine Instruments</attribute>"          "        <attribute name='label' translatable='yes'>Combine Instruments</attribute>"
1048          "        <attribute name='action'>AppMenu.CombInstruments</attribute>"          "        <attribute name='action'>AppMenu.CombInstruments</attribute>"
# Line 1165  MainWindow::MainWindow() : Line 1181  MainWindow::MainWindow() :
1181          "      <menu action='AssignScripts'/>"          "      <menu action='AssignScripts'/>"
1182          "      <menuitem action='AddInstrument'/>"          "      <menuitem action='AddInstrument'/>"
1183          "      <menuitem action='DupInstrument'/>"          "      <menuitem action='DupInstrument'/>"
1184            "      <menuitem action='MoveInstrument'/>"
1185          "      <menuitem action='CombInstruments'/>"          "      <menuitem action='CombInstruments'/>"
1186          "      <separator/>"          "      <separator/>"
1187          "      <menuitem action='RemoveInstrument'/>"          "      <menuitem action='RemoveInstrument'/>"
# Line 1204  MainWindow::MainWindow() : Line 1221  MainWindow::MainWindow() :
1221          "    <menuitem action='ScriptSlots'/>"          "    <menuitem action='ScriptSlots'/>"
1222          "    <menuitem action='AddInstrument'/>"          "    <menuitem action='AddInstrument'/>"
1223          "    <menuitem action='DupInstrument'/>"          "    <menuitem action='DupInstrument'/>"
1224            "    <menuitem action='MoveInstrument'/>"
1225          "    <menuitem action='CombInstruments'/>"          "    <menuitem action='CombInstruments'/>"
1226          "    <separator/>"          "    <separator/>"
1227          "    <menuitem action='RemoveInstrument'/>"          "    <menuitem action='RemoveInstrument'/>"
# Line 1531  MainWindow::MainWindow() : Line 1549  MainWindow::MainWindow() :
1549          sigc::mem_fun(*this, &MainWindow::select_sample)          sigc::mem_fun(*this, &MainWindow::select_sample)
1550      );      );
1551    
1552        dimreg_edit.editScriptSlotsButton.signal_clicked().connect(
1553            sigc::mem_fun(*this, &MainWindow::show_script_slots)
1554        );
1555        // simply sending the same signal (pair) to the sampler on 'patch' variable
1556        // changes as the already existing signal (pair) when the user edits the
1557        // script's source code, because the sampler would reload the source code
1558        // and the 'patch' variables from the instrument on this signal anyway
1559        dimreg_edit.scriptVars.signal_vars_to_be_changed.connect(
1560            [this](gig::Instrument* instr) {
1561                for (int i = 0; i < instr->ScriptSlotCount(); ++i) {
1562                    gig::Script* script = instr->GetScriptOfSlot(i);
1563                    signal_script_to_be_changed.emit(script);
1564                }
1565            }
1566        );
1567        dimreg_edit.scriptVars.signal_vars_changed.connect(
1568            [this](gig::Instrument* instr) {
1569                for (int i = 0; i < instr->ScriptSlotCount(); ++i) {
1570                    gig::Script* script = instr->GetScriptOfSlot(i);
1571                    signal_script_changed.emit(script);
1572                }
1573            }
1574        );
1575        dimreg_edit.scriptVars.signal_edit_script.connect(
1576            [this](gig::Script* script) {
1577                editScript(script);
1578            }
1579        );
1580    
1581      m_RegionChooser.signal_instrument_struct_to_be_changed().connect(      m_RegionChooser.signal_instrument_struct_to_be_changed().connect(
1582          sigc::hide(          sigc::hide(
1583              sigc::bind(              sigc::bind(
# Line 1904  void MainWindow::on_sel_change() Line 1951  void MainWindow::on_sel_change()
1951    
1952      updateScriptListOfMenu();      updateScriptListOfMenu();
1953    
1954      m_RegionChooser.set_instrument(get_instrument());      gig::Instrument* instr = get_instrument();
1955    
1956        m_RegionChooser.set_instrument(instr);
1957        dimreg_edit.scriptVars.setInstrument(instr, true/*force update*/);
1958    
1959      if (Settings::singleton()->syncSamplerInstrumentSelection) {      if (Settings::singleton()->syncSamplerInstrumentSelection) {
1960          switch_sampler_instrument_signal.emit(get_instrument());          switch_sampler_instrument_signal.emit(get_instrument());
# Line 3921  void MainWindow::on_instrument_selection Line 3971  void MainWindow::on_instrument_selection
3971  }  }
3972  #endif  #endif
3973    
3974    void MainWindow::on_action_move_instr() {
3975        gig::Instrument* instr = get_instrument();
3976        if (!instr) return;
3977    
3978        int currentIndex = getIndexOf(instr);
3979    
3980        Gtk::Dialog dialog(_("Move Instrument"), true /*modal*/);
3981    #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
3982        Gtk::Adjustment adjustment(
3983            currentIndex,
3984            0 /*min*/, file->CountInstruments() - 1 /*max*/
3985        );
3986        Gtk::SpinButton spinBox(adjustment);
3987    #else
3988        Gtk::SpinButton spinBox(
3989            Gtk::Adjustment::create(
3990                currentIndex,
3991                0 /*min*/, file->CountInstruments() - 1 /*max*/
3992            )
3993        );
3994    #endif
3995    #if USE_GTKMM_BOX
3996        dialog.get_content_area()->pack_start(spinBox);
3997    #else
3998        dialog.get_vbox()->pack_start(spinBox);
3999    #endif
4000    #if HAS_GTKMM_STOCK
4001        Gtk::Button* okButton = dialog.add_button(Gtk::Stock::OK, 0);
4002        dialog.add_button(Gtk::Stock::CANCEL, 1);
4003    #else
4004        Gtk::Button* okButton = dialog.add_button(_("_OK"), 0);
4005        dialog.add_button(_("_Cancel"), 1);
4006    #endif
4007        okButton->set_sensitive(false);
4008        // show the dialog at a reasonable screen position
4009        dialog.set_position(Gtk::WIN_POS_MOUSE);
4010        // only enable the 'OK' button if entered new index is not instrument's
4011        // current index already
4012        spinBox.signal_value_changed().connect([&]{
4013            okButton->set_sensitive( spinBox.get_value_as_int() != currentIndex );
4014        });
4015        // usability acceleration: if user hits enter key on the text entry field
4016        // then auto trigger the 'OK' button
4017        spinBox.signal_activate().connect([&]{
4018            if (okButton->get_sensitive())
4019                okButton->clicked();
4020        });
4021    #if HAS_GTKMM_SHOW_ALL_CHILDREN
4022        dialog.show_all_children();
4023    #endif
4024        if (!dialog.run()) { // 'OK' selected ...
4025            int newIndex = spinBox.get_value_as_int();
4026            printf("MOVE TO %d\n", newIndex);
4027            gig::Instrument* dst = file->GetInstrument(newIndex);
4028            instr->MoveTo(dst);
4029            __refreshEntireGUI();
4030            select_instrument(instr);
4031        }
4032    }
4033    
4034  void MainWindow::select_instrument(gig::Instrument* instrument) {  void MainWindow::select_instrument(gig::Instrument* instrument) {
4035      if (!instrument) return;      if (!instrument) return;
4036    
# Line 4448  void MainWindow::on_action_edit_script() Line 4558  void MainWindow::on_action_edit_script()
4558      if (!it) return;      if (!it) return;
4559      Gtk::TreeModel::Row row = *it;      Gtk::TreeModel::Row row = *it;
4560      gig::Script* script = row[m_ScriptsModel.m_col_script];      gig::Script* script = row[m_ScriptsModel.m_col_script];
4561      if (!script) return;      editScript(script);
4562    }
4563    
4564    void MainWindow::editScript(gig::Script* script) {
4565        if (!script) return;
4566      ScriptEditor* editor = new ScriptEditor;      ScriptEditor* editor = new ScriptEditor;
4567      editor->signal_script_to_be_changed.connect(      editor->signal_script_to_be_changed.connect(
4568          signal_script_to_be_changed.make_slot()          signal_script_to_be_changed.make_slot()

Legend:
Removed from v.3711  
changed lines
  Added in v.3749

  ViewVC Help
Powered by ViewVC