/[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 3409 by schoenebeck, Tue Jan 23 16:30:56 2018 UTC revision 3419 by schoenebeck, Sat Feb 10 12:01:09 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 1597  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 1619  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            Gtk::AccelMap::add_entry("<Scripts>/DropAllScriptSlots", GDK_KEY_BackSpace, Gdk::SHIFT_MASK);
1640    
1641          Glib::RefPtr<Gtk::AccelGroup> accelGroup = this->get_accel_group();          Glib::RefPtr<Gtk::AccelGroup> accelGroup = this->get_accel_group();
1642          assign_scripts_menu->set_accel_group(accelGroup);          assign_scripts_menu->set_accel_group(accelGroup);
# Line 2622  void MainWindow::on_show_tooltips_change Line 2640  void MainWindow::on_show_tooltips_change
2640      dimreg_all_regions.set_has_tooltip(b);      dimreg_all_regions.set_has_tooltip(b);
2641      dimreg_all_dimregs.set_has_tooltip(b);      dimreg_all_dimregs.set_has_tooltip(b);
2642      dimreg_stereo.set_has_tooltip(b);      dimreg_stereo.set_has_tooltip(b);
2643      m_TreeView.set_has_tooltip(b);  
2644        // Not doing this here, we let onQueryTreeViewTooltip() handle this per cell
2645        //m_TreeView.set_has_tooltip(b);
2646    
2647      m_TreeViewSamples.set_has_tooltip(b);      m_TreeViewSamples.set_has_tooltip(b);
2648      m_TreeViewScripts.set_has_tooltip(b);      m_TreeViewScripts.set_has_tooltip(b);
2649    
# Line 2974  void MainWindow::updateSampleRefCountMap Line 2995  void MainWindow::updateSampleRefCountMap
2995      }      }
2996  }  }
2997    
2998    bool MainWindow::onQueryTreeViewTooltip(int x, int y, bool keyboardTip, const Glib::RefPtr<Gtk::Tooltip>& tooltip) {
2999        Gtk::TreeModel::iterator iter;
3000        m_TreeView.get_tooltip_context_iter(x, y, keyboardTip, iter);
3001        Gtk::TreeModel::Path path(iter);
3002        Gtk::TreeModel::Row row = *iter;
3003        Gtk::TreeViewColumn* pointedColumn = NULL;
3004        // resolve the precise table column the mouse points to
3005        {
3006            Gtk::TreeModel::Path path; // unused
3007            int cellX, cellY; // unused
3008            m_TreeView.get_path_at_pos(x, y, path, pointedColumn, cellX, cellY);
3009        }
3010        Gtk::TreeViewColumn* scriptsColumn = m_TreeView.get_column(2);
3011        if (pointedColumn == scriptsColumn) { // mouse hovers scripts column ...
3012            // show the script(s) assigned to the hovered instrument as tooltip
3013            tooltip->set_markup( row[m_Columns.m_col_tooltip] );
3014            m_TreeView.set_tooltip_cell(tooltip, &path, scriptsColumn, NULL);
3015        } else {
3016            // if beginners' tooltips is disabled then don't show the following one
3017            if (!Settings::singleton()->showTooltips)
3018                return false;
3019            // yeah, a beginners tooltip
3020            tooltip->set_text(_(
3021                "Right click here for actions on instruments & MIDI Rules. "
3022                "Drag & drop to change the order of instruments."
3023            ));
3024            m_TreeView.set_tooltip_cell(tooltip, &path, pointedColumn, NULL);
3025        }
3026        return true;
3027    }
3028    
3029    static Glib::ustring scriptTooltipFor(gig::Instrument* instrument, int index) {
3030        Glib::ustring name(gig_to_utf8(instrument->pInfo->Name));
3031        const int iScriptSlots = instrument->ScriptSlotCount();
3032        Glib::ustring tooltip = "<u>(" + ToString(index) + ") „"  + name + "”</u>\n\n";
3033        if (!iScriptSlots)
3034            tooltip += "<span foreground='red'><i>No script assigned</i></span>";
3035        else {
3036            for (int i = 0; i < iScriptSlots; ++i) {
3037                tooltip += "• " + ToString(i+1) + ". Script:  „<span foreground='#46DEFF'><b>" +
3038                           instrument->GetScriptOfSlot(i)->Name + "</b></span>”";
3039                if (i + 1 < iScriptSlots) tooltip += "\n\n";
3040            }
3041        }
3042        return tooltip;
3043    }
3044    
3045  void MainWindow::load_gig(gig::File* gig, const char* filename, bool isSharedInstrument)  void MainWindow::load_gig(gig::File* gig, const char* filename, bool isSharedInstrument)
3046  {  {
3047      file = 0;      file = 0;
# Line 3003  void MainWindow::load_gig(gig::File* gig Line 3071  void MainWindow::load_gig(gig::File* gig
3071          row[m_Columns.m_col_name] = name;          row[m_Columns.m_col_name] = name;
3072          row[m_Columns.m_col_instr] = instrument;          row[m_Columns.m_col_instr] = instrument;
3073          row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : "";          row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : "";
3074            row[m_Columns.m_col_tooltip] = scriptTooltipFor(instrument, index);
3075    
3076  #if !USE_GTKMM_BUILDER  #if !USE_GTKMM_BUILDER
3077          add_instrument_to_menu(name);          add_instrument_to_menu(name);
# Line 3120  void MainWindow::instr_name_changed_by_i Line 3189  void MainWindow::instr_name_changed_by_i
3189      gig::Instrument* instrument = row[m_Columns.m_col_instr];      gig::Instrument* instrument = row[m_Columns.m_col_instr];
3190      Glib::ustring gigname(gig_to_utf8(instrument->pInfo->Name));      Glib::ustring gigname(gig_to_utf8(instrument->pInfo->Name));
3191      if (gigname != name) {      if (gigname != name) {
3192            Gtk::TreeModel::Path path(*it);
3193            const int index = path[0];
3194          row[m_Columns.m_col_name] = gigname;          row[m_Columns.m_col_name] = gigname;
3195            row[m_Columns.m_col_tooltip] = scriptTooltipFor(instrument, index);
3196      }      }
3197  }  }
3198    
# Line 3166  void MainWindow::onScriptSlotsModified(g Line 3238  void MainWindow::onScriptSlotsModified(g
3238          Gtk::TreeModel::Row row = model->children()[i];          Gtk::TreeModel::Row row = model->children()[i];
3239          if (row[m_Columns.m_col_instr] != pInstrument) continue;          if (row[m_Columns.m_col_instr] != pInstrument) continue;
3240          row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : "";          row[m_Columns.m_col_scripts] = iScriptSlots ? ToString(iScriptSlots) : "";
3241            row[m_Columns.m_col_tooltip] = scriptTooltipFor(pInstrument, i);
3242          break;          break;
3243      }      }
3244    
# Line 3191  void MainWindow::assignScript(gig::Scrip Line 3264  void MainWindow::assignScript(gig::Scrip
3264      onScriptSlotsModified(pInstrument);      onScriptSlotsModified(pInstrument);
3265  }  }
3266    
3267    void MainWindow::dropAllScriptSlots() {
3268        gig::Instrument* pInstrument = get_instrument();
3269        if (!pInstrument) {
3270            printf("!instrument\n");
3271            return;
3272        }
3273    
3274        const int iScriptSlots = pInstrument->ScriptSlotCount();
3275        for (int i = iScriptSlots - 1; i >= 0; --i)
3276            pInstrument->RemoveScriptSlot(i);
3277    
3278        onScriptSlotsModified(pInstrument);
3279    }
3280    
3281  void MainWindow::on_action_refresh_all() {  void MainWindow::on_action_refresh_all() {
3282      __refreshEntireGUI();      __refreshEntireGUI();
3283  }  }
# Line 3631  void MainWindow::updateScriptListOfMenu( Line 3718  void MainWindow::updateScriptListOfMenu(
3718          assign_scripts_menu->append(*item);          assign_scripts_menu->append(*item);
3719      }      }
3720    
3721        // add separator line to menu
3722        assign_scripts_menu->append(*new Gtk::SeparatorMenuItem);
3723    
3724        {
3725            Gtk::MenuItem* item = new Gtk::MenuItem(_("Unassign All Scripts"));
3726            item->signal_activate().connect(
3727                sigc::mem_fun(*this, &MainWindow::dropAllScriptSlots)
3728            );
3729            assign_scripts_menu->append(*item);
3730            item->set_accel_path("<Scripts>/DropAllScriptSlots");
3731        }
3732    
3733  #if HAS_GTKMM_SHOW_ALL_CHILDREN  #if HAS_GTKMM_SHOW_ALL_CHILDREN
3734      assign_scripts_menu->show_all_children();      assign_scripts_menu->show_all_children();
3735  #endif  #endif
# Line 3679  void MainWindow::add_instrument(gig::Ins Line 3778  void MainWindow::add_instrument(gig::Ins
3778      instrument_name_connection.block();      instrument_name_connection.block();
3779      Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append();      Gtk::TreeModel::iterator iterInstr = m_refTreeModel->append();
3780      Gtk::TreeModel::Row rowInstr = *iterInstr;      Gtk::TreeModel::Row rowInstr = *iterInstr;
3781      rowInstr[m_Columns.m_col_nr] = m_refTreeModel->children().size() - 1;      const int index = m_refTreeModel->children().size() - 1;
3782        rowInstr[m_Columns.m_col_nr] = index;
3783      rowInstr[m_Columns.m_col_name] = name;      rowInstr[m_Columns.m_col_name] = name;
3784      rowInstr[m_Columns.m_col_instr] = instrument;      rowInstr[m_Columns.m_col_instr] = instrument;
3785      rowInstr[m_Columns.m_col_scripts] = "";      rowInstr[m_Columns.m_col_scripts] = "";
3786        rowInstr[m_Columns.m_col_tooltip] = scriptTooltipFor(instrument, index);
3787      instrument_name_connection.unblock();      instrument_name_connection.unblock();
3788    
3789  #if !USE_GTKMM_BUILDER  #if !USE_GTKMM_BUILDER
# Line 3769  void MainWindow::on_action_remove_instru Line 3870  void MainWindow::on_action_remove_instru
3870                       it != m_refTreeModel->children().end(); ++it, ++index)                       it != m_refTreeModel->children().end(); ++it, ++index)
3871                  {                  {
3872                      Gtk::TreeModel::Row row = *it;                      Gtk::TreeModel::Row row = *it;
3873                        gig::Instrument* instrument = row[m_Columns.m_col_instr];
3874                      row[m_Columns.m_col_nr] = index;                      row[m_Columns.m_col_nr] = index;
3875                        row[m_Columns.m_col_tooltip] = scriptTooltipFor(instrument, index);
3876                  }                  }
3877              }              }
3878    

Legend:
Removed from v.3409  
changed lines
  Added in v.3419

  ViewVC Help
Powered by ViewVC