/[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 3417 by schoenebeck, Fri Feb 9 15:29:13 2018 UTC revision 3418 by schoenebeck, Sat Feb 10 11:36:16 2018 UTC
# Line 1356  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 2636  void MainWindow::on_show_tooltips_change Line 2639  void MainWindow::on_show_tooltips_change
2639      dimreg_all_regions.set_has_tooltip(b);      dimreg_all_regions.set_has_tooltip(b);
2640      dimreg_all_dimregs.set_has_tooltip(b);      dimreg_all_dimregs.set_has_tooltip(b);
2641      dimreg_stereo.set_has_tooltip(b);      dimreg_stereo.set_has_tooltip(b);
2642      m_TreeView.set_has_tooltip(b);  
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);      m_TreeViewSamples.set_has_tooltip(b);
2647      m_TreeViewScripts.set_has_tooltip(b);      m_TreeViewScripts.set_has_tooltip(b);
2648    
# Line 2988  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 3017  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 3134  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 3180  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 3693  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 3783  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    

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

  ViewVC Help
Powered by ViewVC