/[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 3364 by schoenebeck, Tue Nov 14 18:07:25 2017 UTC revision 3418 by schoenebeck, Sat Feb 10 11:36:16 2018 UTC
# Line 101  MainWindow::MainWindow() : Line 101  MainWindow::MainWindow() :
101  //    set_border_width(5);  //    set_border_width(5);
102    
103      if (!Settings::singleton()->autoRestoreWindowDimension) {      if (!Settings::singleton()->autoRestoreWindowDimension) {
104    #if GTKMM_MAJOR_VERSION >= 3
105            set_default_size(895, 600);
106    #else
107          set_default_size(800, 600);          set_default_size(800, 600);
108    #endif
109          set_position(Gtk::WIN_POS_CENTER);          set_position(Gtk::WIN_POS_CENTER);
110      }      }
111    
# Line 132  MainWindow::MainWindow() : Line 136  MainWindow::MainWindow() :
136      m_ScrolledWindowScripts.add(m_TreeViewScripts);      m_ScrolledWindowScripts.add(m_TreeViewScripts);
137      m_ScrolledWindowScripts.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);      m_ScrolledWindowScripts.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
138    
139    #if GTKMM_MAJOR_VERSION < 3
140      m_TreeViewNotebook.set_size_request(300);      m_TreeViewNotebook.set_size_request(300);
141    #endif
142    
143      m_searchLabel.set_text(Glib::ustring(" ") + _("Filter:"));      m_searchLabel.set_text(Glib::ustring(" ") + _("Filter:"));
144      m_searchField.pack_start(m_searchLabel, Gtk::PACK_SHRINK);      m_searchField.pack_start(m_searchLabel, Gtk::PACK_SHRINK);
# Line 452  MainWindow::MainWindow() : Line 457  MainWindow::MainWindow() :
457          m_actionGroup->add_action_bool("Statusbar", sigc::mem_fun(*this, &MainWindow::on_action_view_status_bar), true);          m_actionGroup->add_action_bool("Statusbar", sigc::mem_fun(*this, &MainWindow::on_action_view_status_bar), true);
458      m_actionToggleRestoreWinDim =      m_actionToggleRestoreWinDim =
459          m_actionGroup->add_action_bool("AutoRestoreWinDim", sigc::mem_fun(*this, &MainWindow::on_auto_restore_win_dim), Settings::singleton()->autoRestoreWindowDimension);          m_actionGroup->add_action_bool("AutoRestoreWinDim", sigc::mem_fun(*this, &MainWindow::on_auto_restore_win_dim), Settings::singleton()->autoRestoreWindowDimension);
460        m_actionToggleShowTooltips = m_actionGroup->add_action_bool(
461            "ShowTooltips", sigc::mem_fun(*this, &MainWindow::on_action_show_tooltips),
462            Settings::singleton()->showTooltips
463        );
464      m_actionToggleSaveWithTempFile =      m_actionToggleSaveWithTempFile =
465          m_actionGroup->add_action_bool("SaveWithTemporaryFile", sigc::mem_fun(*this, &MainWindow::on_save_with_temporary_file), Settings::singleton()->saveWithTemporaryFile);          m_actionGroup->add_action_bool("SaveWithTemporaryFile", sigc::mem_fun(*this, &MainWindow::on_save_with_temporary_file), Settings::singleton()->saveWithTemporaryFile);
466      m_actionGroup->add_action("RefreshAll", sigc::mem_fun(*this, &MainWindow::on_action_refresh_all));      m_actionGroup->add_action("RefreshAll", sigc::mem_fun(*this, &MainWindow::on_action_refresh_all));
# Line 475  MainWindow::MainWindow() : Line 484  MainWindow::MainWindow() :
484                           *this, &MainWindow::on_auto_restore_win_dim));                           *this, &MainWindow::on_auto_restore_win_dim));
485    
486      toggle_action =      toggle_action =
487            Gtk::ToggleAction::create("ShowTooltips", _("Tooltips for Beginners"));
488        toggle_action->set_active(Settings::singleton()->showTooltips);
489        actionGroup->add(
490            toggle_action,
491            sigc::mem_fun(*this, &MainWindow::on_action_show_tooltips)
492        );
493    
494        toggle_action =
495          Gtk::ToggleAction::create("SaveWithTemporaryFile", _("Save with _temporary file"));          Gtk::ToggleAction::create("SaveWithTemporaryFile", _("Save with _temporary file"));
496      toggle_action->set_active(Settings::singleton()->saveWithTemporaryFile);      toggle_action->set_active(Settings::singleton()->saveWithTemporaryFile);
497      actionGroup->add(toggle_action,      actionGroup->add(toggle_action,
# Line 916  MainWindow::MainWindow() : Line 933  MainWindow::MainWindow() :
933          "          <attribute name='label' translatable='yes'>Statusbar</attribute>"          "          <attribute name='label' translatable='yes'>Statusbar</attribute>"
934          "          <attribute name='action'>AppMenu.Statusbar</attribute>"          "          <attribute name='action'>AppMenu.Statusbar</attribute>"
935          "        </item>"          "        </item>"
936            "        <item id='ShowTooltips'>"
937            "          <attribute name='label' translatable='yes'>Tooltips for Beginners</attribute>"
938            "          <attribute name='action'>AppMenu.ShowTooltips</attribute>"
939            "        </item>"
940          "        <item id='AutoRestoreWinDim'>"          "        <item id='AutoRestoreWinDim'>"
941          "          <attribute name='label' translatable='yes'>Auto restore Window Dimensions</attribute>"          "          <attribute name='label' translatable='yes'>Auto restore Window Dimensions</attribute>"
942          "          <attribute name='action'>AppMenu.AutoRestoreWinDim</attribute>"          "          <attribute name='action'>AppMenu.AutoRestoreWinDim</attribute>"
# Line 1146  MainWindow::MainWindow() : Line 1167  MainWindow::MainWindow() :
1167          "    </menu>"          "    </menu>"
1168          "    <menu action='MenuView'>"          "    <menu action='MenuView'>"
1169          "      <menuitem action='Statusbar'/>"          "      <menuitem action='Statusbar'/>"
1170            "      <menuitem action='ShowTooltips'/>"
1171          "      <menuitem action='AutoRestoreWinDim'/>"          "      <menuitem action='AutoRestoreWinDim'/>"
1172          "      <separator/>"          "      <separator/>"
1173          "      <menuitem action='RefreshAll'/>"          "      <menuitem action='RefreshAll'/>"
# Line 1232  MainWindow::MainWindow() : Line 1254  MainWindow::MainWindow() :
1254      {      {
1255          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
1256              uiManager->get_widget("/MenuBar/MenuEdit/CopySampleLoop"));              uiManager->get_widget("/MenuBar/MenuEdit/CopySampleLoop"));
1257          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."));          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 information to be altered by this action."));
1258      }      }
1259      {      {
1260          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
# Line 1247  MainWindow::MainWindow() : Line 1269  MainWindow::MainWindow() :
1269      {      {
1270          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
1271              uiManager->get_widget("/MenuBar/MenuSettings/MoveRootNoteWithRegionMoved"));              uiManager->get_widget("/MenuBar/MenuSettings/MoveRootNoteWithRegionMoved"));
1272          item->set_tooltip_text(_("If checked, and when a region is moved by dragging it around on the virtual keyboard, the keybord position dependent pitch will move exactly with the amount of semi tones the region was moved around."));          item->set_tooltip_text(_("If checked, and when a region is moved by dragging it around on the virtual keyboard, the keyboard position dependent pitch will move exactly with the amount of semi tones the region was moved around."));
1273      }      }
1274      {      {
1275          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(          Gtk::MenuItem* item = dynamic_cast<Gtk::MenuItem*>(
# Line 1334  MainWindow::MainWindow() : Line 1356  MainWindow::MainWindow() :
1356      m_TreeView.set_model(m_refTreeModelFilter);      m_TreeView.set_model(m_refTreeModelFilter);
1357    
1358      m_TreeView.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE);      m_TreeView.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE);
1359      m_TreeView.set_tooltip_text(_("Right click here for actions on instruments & MIDI Rules. Drag & drop to change the order of instruments."));      m_TreeView.set_has_tooltip(true);
1360        m_TreeView.signal_query_tooltip().connect(
1361            sigc::mem_fun(*this, &MainWindow::onQueryTreeViewTooltip)
1362        );
1363      instrument_name_connection = m_refTreeModel->signal_row_changed().connect(      instrument_name_connection = m_refTreeModel->signal_row_changed().connect(
1364          sigc::mem_fun(*this, &MainWindow::instrument_name_changed)          sigc::mem_fun(*this, &MainWindow::instrument_name_changed)
1365      );      );
# Line 1575  MainWindow::MainWindow() : Line 1600  MainWindow::MainWindow() :
1600          Gtk::AccelMap::add_entry("<Macros>/macro_9", GDK_KEY_F10, noModifier);          Gtk::AccelMap::add_entry("<Macros>/macro_9", GDK_KEY_F10, noModifier);
1601          Gtk::AccelMap::add_entry("<Macros>/macro_10", GDK_KEY_F11, noModifier);          Gtk::AccelMap::add_entry("<Macros>/macro_10", GDK_KEY_F11, noModifier);
1602          Gtk::AccelMap::add_entry("<Macros>/macro_11", GDK_KEY_F12, noModifier);          Gtk::AccelMap::add_entry("<Macros>/macro_11", GDK_KEY_F12, noModifier);
1603            Gtk::AccelMap::add_entry("<Macros>/macro_12", GDK_KEY_F13, noModifier);
1604            Gtk::AccelMap::add_entry("<Macros>/macro_13", GDK_KEY_F14, noModifier);
1605            Gtk::AccelMap::add_entry("<Macros>/macro_14", GDK_KEY_F15, noModifier);
1606            Gtk::AccelMap::add_entry("<Macros>/macro_15", GDK_KEY_F16, noModifier);
1607            Gtk::AccelMap::add_entry("<Macros>/macro_16", GDK_KEY_F17, noModifier);
1608            Gtk::AccelMap::add_entry("<Macros>/macro_17", GDK_KEY_F18, noModifier);
1609            Gtk::AccelMap::add_entry("<Macros>/macro_18", GDK_KEY_F19, noModifier);
1610          Gtk::AccelMap::add_entry("<Macros>/SetupMacros", 'm', primaryModifierKey);          Gtk::AccelMap::add_entry("<Macros>/SetupMacros", 'm', primaryModifierKey);
1611    
1612          Glib::RefPtr<Gtk::AccelGroup> accelGroup = this->get_accel_group();          Glib::RefPtr<Gtk::AccelGroup> accelGroup = this->get_accel_group();
# Line 1597  MainWindow::MainWindow() : Line 1629  MainWindow::MainWindow() :
1629          Gtk::AccelMap::add_entry("<Scripts>/script_9", GDK_KEY_F10, Gdk::SHIFT_MASK);          Gtk::AccelMap::add_entry("<Scripts>/script_9", GDK_KEY_F10, Gdk::SHIFT_MASK);
1630          Gtk::AccelMap::add_entry("<Scripts>/script_10", GDK_KEY_F11, Gdk::SHIFT_MASK);          Gtk::AccelMap::add_entry("<Scripts>/script_10", GDK_KEY_F11, Gdk::SHIFT_MASK);
1631          Gtk::AccelMap::add_entry("<Scripts>/script_11", GDK_KEY_F12, Gdk::SHIFT_MASK);          Gtk::AccelMap::add_entry("<Scripts>/script_11", GDK_KEY_F12, Gdk::SHIFT_MASK);
1632            Gtk::AccelMap::add_entry("<Scripts>/script_12", GDK_KEY_F13, Gdk::SHIFT_MASK);
1633            Gtk::AccelMap::add_entry("<Scripts>/script_13", GDK_KEY_F14, Gdk::SHIFT_MASK);
1634            Gtk::AccelMap::add_entry("<Scripts>/script_14", GDK_KEY_F15, Gdk::SHIFT_MASK);
1635            Gtk::AccelMap::add_entry("<Scripts>/script_15", GDK_KEY_F16, Gdk::SHIFT_MASK);
1636            Gtk::AccelMap::add_entry("<Scripts>/script_16", GDK_KEY_F17, Gdk::SHIFT_MASK);
1637            Gtk::AccelMap::add_entry("<Scripts>/script_17", GDK_KEY_F18, Gdk::SHIFT_MASK);
1638            Gtk::AccelMap::add_entry("<Scripts>/script_18", GDK_KEY_F19, Gdk::SHIFT_MASK);
1639    
1640          Glib::RefPtr<Gtk::AccelGroup> accelGroup = this->get_accel_group();          Glib::RefPtr<Gtk::AccelGroup> accelGroup = this->get_accel_group();
1641          assign_scripts_menu->set_accel_group(accelGroup);          assign_scripts_menu->set_accel_group(accelGroup);
1642      }      }
1643    
1644        on_show_tooltips_changed();
1645    
1646      Glib::signal_idle().connect_once(      Glib::signal_idle().connect_once(
1647          sigc::mem_fun(*this, &MainWindow::bringToFront),          sigc::mem_fun(*this, &MainWindow::bringToFront),
1648          200          200
# Line 2584  void MainWindow::on_action_warn_user_on_ Line 2625  void MainWindow::on_action_warn_user_on_
2625          !Settings::singleton()->warnUserOnExtensions;          !Settings::singleton()->warnUserOnExtensions;
2626  }  }
2627    
2628    void MainWindow::on_action_show_tooltips() {
2629        Settings::singleton()->showTooltips =
2630            !Settings::singleton()->showTooltips;
2631    
2632        on_show_tooltips_changed();
2633    }
2634    
2635    void MainWindow::on_show_tooltips_changed() {
2636        const bool b = Settings::singleton()->showTooltips;
2637    
2638        dimreg_label.set_has_tooltip(b);
2639        dimreg_all_regions.set_has_tooltip(b);
2640        dimreg_all_dimregs.set_has_tooltip(b);
2641        dimreg_stereo.set_has_tooltip(b);
2642    
2643        // Not doing this here, we let onQueryTreeViewTooltip() handle this per cell
2644        //m_TreeView.set_has_tooltip(b);
2645    
2646        m_TreeViewSamples.set_has_tooltip(b);
2647        m_TreeViewScripts.set_has_tooltip(b);
2648    
2649        set_has_tooltip(b);
2650    }
2651    
2652  void MainWindow::on_action_sync_sampler_instrument_selection() {  void MainWindow::on_action_sync_sampler_instrument_selection() {
2653      Settings::singleton()->syncSamplerInstrumentSelection =      Settings::singleton()->syncSamplerInstrumentSelection =
2654          !Settings::singleton()->syncSamplerInstrumentSelection;          !Settings::singleton()->syncSamplerInstrumentSelection;
# Line 2929  void MainWindow::updateSampleRefCountMap Line 2994  void MainWindow::updateSampleRefCountMap
2994      }      }
2995  }  }
2996    
2997    bool MainWindow::onQueryTreeViewTooltip(int x, int y, bool keyboardTip, const Glib::RefPtr<Gtk::Tooltip>& tooltip) {
2998        Gtk::TreeModel::iterator iter;
2999        m_TreeView.get_tooltip_context_iter(x, y, keyboardTip, iter);
3000        Gtk::TreeModel::Path path(iter);
3001        Gtk::TreeModel::Row row = *iter;
3002        Gtk::TreeViewColumn* pointedColumn = NULL;
3003        // resolve the precise table column the mouse points to
3004        {
3005            Gtk::TreeModel::Path path; // unused
3006            int cellX, cellY; // unused
3007            m_TreeView.get_path_at_pos(x, y, path, pointedColumn, cellX, cellY);
3008        }
3009        Gtk::TreeViewColumn* scriptsColumn = m_TreeView.get_column(2);
3010        if (pointedColumn == scriptsColumn) { // mouse hovers scripts column ...
3011            // show the script(s) assigned to the hovered instrument as tooltip
3012            tooltip->set_markup( row[m_Columns.m_col_tooltip] );
3013            m_TreeView.set_tooltip_cell(tooltip, &path, scriptsColumn, NULL);
3014        } else {
3015            // if beginners' tooltips is disabled then don't show the following one
3016            if (!Settings::singleton()->showTooltips)
3017                return false;
3018            // yeah, a beginners tooltip
3019            tooltip->set_text(_(
3020                "Right click here for actions on instruments & MIDI Rules. "
3021                "Drag & drop to change the order of instruments."
3022            ));
3023            m_TreeView.set_tooltip_cell(tooltip, &path, pointedColumn, NULL);
3024        }
3025        return true;
3026    }
3027    
3028    static Glib::ustring scriptTooltipFor(gig::Instrument* instrument, int index) {
3029        Glib::ustring name(gig_to_utf8(instrument->pInfo->Name));
3030        const int iScriptSlots = instrument->ScriptSlotCount();
3031        Glib::ustring tooltip = "<u>(" + ToString(index) + ") „"  + name + "”</u>\n\n";
3032        if (!iScriptSlots)
3033            tooltip += "<span foreground='red'><i>No script assigned</i></span>";
3034        else {
3035            for (int i = 0; i < iScriptSlots; ++i) {
3036                tooltip += "• " + ToString(i+1) + ". Script:  „<span foreground='#46DEFF'><b>" +
3037                           instrument->GetScriptOfSlot(i)->Name + "</b></span>”";
3038                if (i + 1 < iScriptSlots) tooltip += "\n\n";
3039            }
3040        }
3041        return tooltip;
3042    }
3043    
3044  void MainWindow::load_gig(gig::File* gig, const char* filename, bool isSharedInstrument)  void MainWindow::load_gig(gig::File* gig, const char* filename, bool isSharedInstrument)
3045  {  {
3046      file = 0;      file = 0;
# Line 2958  void MainWindow::load_gig(gig::File* gig Line 3070  void MainWindow::load_gig(gig::File* gig
3070          row[m_Columns.m_col_name] = name;          row[m_Columns.m_col_name] = name;
3071          row[m_Columns.m_col_instr] = instrument;          row[m_Columns.m_col_instr] = instrument;
3072          row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : "";          row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : "";
3073            row[m_Columns.m_col_tooltip] = scriptTooltipFor(instrument, index);
3074    
3075  #if !USE_GTKMM_BUILDER  #if !USE_GTKMM_BUILDER
3076          add_instrument_to_menu(name);          add_instrument_to_menu(name);
# Line 3075  void MainWindow::instr_name_changed_by_i Line 3188  void MainWindow::instr_name_changed_by_i
3188      gig::Instrument* instrument = row[m_Columns.m_col_instr];      gig::Instrument* instrument = row[m_Columns.m_col_instr];
3189      Glib::ustring gigname(gig_to_utf8(instrument->pInfo->Name));      Glib::ustring gigname(gig_to_utf8(instrument->pInfo->Name));
3190      if (gigname != name) {      if (gigname != name) {
3191            Gtk::TreeModel::Path path(*it);
3192            const int index = path[0];
3193          row[m_Columns.m_col_name] = gigname;          row[m_Columns.m_col_name] = gigname;
3194            row[m_Columns.m_col_tooltip] = scriptTooltipFor(instrument, index);
3195      }      }
3196  }  }
3197    
# Line 3121  void MainWindow::onScriptSlotsModified(g Line 3237  void MainWindow::onScriptSlotsModified(g
3237          Gtk::TreeModel::Row row = model->children()[i];          Gtk::TreeModel::Row row = model->children()[i];
3238          if (row[m_Columns.m_col_instr] != pInstrument) continue;          if (row[m_Columns.m_col_instr] != pInstrument) continue;
3239          row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : "";          row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : "";
3240            row[m_Columns.m_col_tooltip] = scriptTooltipFor(pInstrument, i);
3241          break;          break;
3242      }      }
3243    
# Line 3634  void MainWindow::add_instrument(gig::Ins Line 3751  void MainWindow::add_instrument(gig::Ins
3751      instrument_name_connection.block();      instrument_name_connection.block();
3752      Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append();      Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append();
3753      Gtk::TreeModel::Row rowInstr = *iterInstr;      Gtk::TreeModel::Row rowInstr = *iterInstr;
3754      rowInstr[m_Columns.m_col_nr] = m_refTreeModel->children().size() - 1;      const int index = m_refTreeModel->children().size() - 1;
3755        rowInstr[m_Columns.m_col_nr] = index;
3756      rowInstr[m_Columns.m_col_name] = name;      rowInstr[m_Columns.m_col_name] = name;
3757      rowInstr[m_Columns.m_col_instr] = instrument;      rowInstr[m_Columns.m_col_instr] = instrument;
3758      rowInstr[m_Columns.m_col_scripts] = "";      rowInstr[m_Columns.m_col_scripts] = "";
3759        rowInstr[m_Columns.m_col_tooltip] = scriptTooltipFor(instrument, index);
3760      instrument_name_connection.unblock();      instrument_name_connection.unblock();
3761    
3762  #if !USE_GTKMM_BUILDER  #if !USE_GTKMM_BUILDER
# Line 3724  void MainWindow::on_action_remove_instru Line 3843  void MainWindow::on_action_remove_instru
3843                       it != m_refTreeModel->children().end(); ++it, ++index)                       it != m_refTreeModel->children().end(); ++it, ++index)
3844                  {                  {
3845                      Gtk::TreeModel::Row row = *it;                      Gtk::TreeModel::Row row = *it;
3846                        gig::Instrument* instrument = row[m_Columns.m_col_instr];
3847                      row[m_Columns.m_col_nr] = index;                      row[m_Columns.m_col_nr] = index;
3848                        row[m_Columns.m_col_tooltip] = scriptTooltipFor(instrument, index);
3849                  }                  }
3850              }              }
3851    
# Line 3983  void MainWindow::add_or_replace_sample(b Line 4104  void MainWindow::add_or_replace_sample(b
4104          for (std::vector<std::string>::iterator iter = filenames.begin();          for (std::vector<std::string>::iterator iter = filenames.begin();
4105               iter != filenames.end(); ++iter) {               iter != filenames.end(); ++iter) {
4106              printf("Adding sample %s\n",(*iter).c_str());              printf("Adding sample %s\n",(*iter).c_str());
4107              // use libsndfile to retrieve file informations              // use libsndfile to retrieve file information
4108              SF_INFO info;              SF_INFO info;
4109              info.format = 0;              info.format = 0;
4110              SNDFILE* hFile = sf_open((*iter).c_str(), SFM_READ, &info);              SNDFILE* hFile = sf_open((*iter).c_str(), SFM_READ, &info);

Legend:
Removed from v.3364  
changed lines
  Added in v.3418

  ViewVC Help
Powered by ViewVC