X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fsurfaces%2Fpush2%2Fgui.cc;h=13d457d0beab299e2db0dc913c97bac657696f98;hb=df2b0e33b913f842ed9964cce4c870c45cd02b38;hp=2606418eabf12eb1a0605fc4b7ed9c5f3ae41e57;hpb=66453868cd18704babd08b52d4fd4ee5fcb67322;p=ardour.git diff --git a/libs/surfaces/push2/gui.cc b/libs/surfaces/push2/gui.cc index 2606418eab..13d457d0be 100644 --- a/libs/surfaces/push2/gui.cc +++ b/libs/surfaces/push2/gui.cc @@ -31,11 +31,12 @@ #include "ardour/audioengine.h" #include "ardour/filesystem_paths.h" +#include "ardour/parameter_descriptor.h" #include "push2.h" #include "gui.h" -#include "i18n.h" +#include "pbd/i18n.h" using namespace PBD; using namespace ARDOUR; @@ -81,7 +82,7 @@ P2GUI::P2GUI (Push2& p) , table (2, 5) , action_table (5, 4) , ignore_active_change (false) - , pad_table (8, 8) + , pressure_mode_label (_("Pressure Mode")) { set_border_width (12); @@ -123,14 +124,20 @@ P2GUI::P2GUI (Push2& p) table.attach (output_combo, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0); row++; + table.attach (pressure_mode_label, 0, 1, row, row+1, AttachOptions (0), AttachOptions (0)); + table.attach (pressure_mode_selector, 1, 2, row, row+1, AttachOptions (FILL|EXPAND), AttachOptions (0)); + row++; + hpacker.pack_start (table, true, true); - build_pad_table (); + pressure_mode_selector.set_model (build_pressure_mode_columns()); + pressure_mode_selector.pack_start (pressure_mode_columns.name); + pressure_mode_selector.set_active ((int) p2.pressure_mode()); + pressure_mode_selector.signal_changed().connect (sigc::mem_fun (*this, &P2GUI::reprogram_pressure_mode)); set_spacing (12); pack_start (hpacker, false, false); - pack_start (pad_table, true, true); /* update the port connection combos */ @@ -138,8 +145,8 @@ P2GUI::P2GUI (Push2& p) /* catch future changes to connection state */ - // p2.ConnectionChange.connect (connection_change_connection, invalidator (*this), boost::bind (&P2GUI::connection_handler, this), gui_context()); - p2.PadChange.connect (p2_connections, invalidator (*this), boost::bind (&P2GUI::build_pad_table, this), gui_context()); + ARDOUR::AudioEngine::instance()->PortRegisteredOrUnregistered.connect (port_reg_connection, invalidator (*this), boost::bind (&P2GUI::connection_handler, this), gui_context()); + p2.ConnectionChange.connect (connection_change_connection, invalidator (*this), boost::bind (&P2GUI::connection_handler, this), gui_context()); } P2GUI::~P2GUI () @@ -214,141 +221,6 @@ P2GUI::update_port_combos () } } -void -P2GUI::build_available_action_menu () -{ - /* build a model of all available actions (needs to be tree structured - * more) - */ - - available_action_model = TreeStore::create (action_columns); - - vector paths; - vector labels; - vector tooltips; - vector keys; - vector > actions; - - Gtkmm2ext::ActionMap::get_all_actions (paths, labels, tooltips, keys, actions); - - typedef std::map NodeMap; - NodeMap nodes; - NodeMap::iterator r; - - - vector::iterator k; - vector::iterator p; - vector::iterator t; - vector::iterator l; - - available_action_model->clear (); - - TreeIter rowp; - TreeModel::Row parent; - - /* Disabled item (row 0) */ - - rowp = available_action_model->append(); - parent = *(rowp); - parent[action_columns.name] = _("Disabled"); - - /* Key aliasing */ - - rowp = available_action_model->append(); - parent = *(rowp); - parent[action_columns.name] = _("Shift"); - rowp = available_action_model->append(); - parent = *(rowp); - parent[action_columns.name] = _("Control"); - rowp = available_action_model->append(); - parent = *(rowp); - parent[action_columns.name] = _("Option"); - rowp = available_action_model->append(); - parent = *(rowp); - parent[action_columns.name] = _("CmdAlt"); - - - for (l = labels.begin(), k = keys.begin(), p = paths.begin(), t = tooltips.begin(); l != labels.end(); ++k, ++p, ++t, ++l) { - - TreeModel::Row row; - vector parts; - - parts.clear (); - - split (*p, parts, '/'); - - if (parts.empty()) { - continue; - } - - //kinda kludgy way to avoid displaying menu items as mappable - if ( parts[1] == _("Main_menu") ) - continue; - if ( parts[1] == _("JACK") ) - continue; - if ( parts[1] == _("redirectmenu") ) - continue; - if ( parts[1] == _("Editor_menus") ) - continue; - if ( parts[1] == _("RegionList") ) - continue; - if ( parts[1] == _("ProcessorMenu") ) - continue; - - if ((r = nodes.find (parts[1])) == nodes.end()) { - - /* top level is missing */ - - TreeIter rowp; - TreeModel::Row parent; - rowp = available_action_model->append(); - nodes[parts[1]] = rowp; - parent = *(rowp); - parent[action_columns.name] = parts[1]; - - row = *(available_action_model->append (parent.children())); - - } else { - - row = *(available_action_model->append ((*r->second)->children())); - - } - - /* add this action */ - - if (l->empty ()) { - row[action_columns.name] = *t; - action_map[*t] = *p; - } else { - row[action_columns.name] = *l; - action_map[*l] = *p; - } - - string path = (*p); - /* ControlProtocol::access_action() is not interested in the - legacy "/" prefix part of a path. - */ - path = path.substr (strlen ("/")); - - row[action_columns.path] = path; - } -} - - -bool -P2GUI::find_action_in_model (const TreeModel::iterator& iter, std::string const & action_path, TreeModel::iterator* found) -{ - TreeModel::Row row = *iter; - string path = row[action_columns.path]; - - if (path == action_path) { - *found = iter; - return true; - } - - return false; -} - Glib::RefPtr P2GUI::build_midi_port_list (vector const & ports, bool for_input) { @@ -405,18 +277,40 @@ P2GUI::active_port_changed (Gtk::ComboBox* combo, bool for_input) } } -void -P2GUI::build_pad_table () +Glib::RefPtr +P2GUI::build_pressure_mode_columns () { - container_clear (pad_table); + Glib::RefPtr store = ListStore::create (pressure_mode_columns); + TreeModel::Row row; + + row = *store->append(); + row[pressure_mode_columns.name] = _("AfterTouch (Channel Pressure)"); + row[pressure_mode_columns.mode] = Push2::AfterTouch; + + row = *store->append(); + row[pressure_mode_columns.name] = _("Polyphonic Pressure (Note Pressure)"); + row[pressure_mode_columns.mode] = Push2::PolyPressure; - for (int row = 0; row < 8; ++row) { - for (int col = 0; col < 8; ++col) { + return store; +} - Gtk::Button* b = manage (new Button (string_compose ("%1", (int) p2.pad_note (row, col)))); - b->show (); +void +P2GUI::reprogram_pressure_mode () +{ + Gtk::TreeModel::iterator iter = pressure_mode_selector.get_active(); + Push2::PressureMode pm; - pad_table.attach (*b, col, col+1, row, row + 1); + if (iter) { + Gtk::TreeModel::Row row = *iter; + if (row) { + pm = row[pressure_mode_columns.mode]; + } else { + pm = Push2::AfterTouch; } + } else { + pm = Push2::AfterTouch; } + + cerr << "Reprogram pm to " << pm << endl; + p2.set_pressure_mode (pm); }