mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-18 20:56:28 +01:00
Use ActionModel API in the Control Surfaces that can make use of it
This commit is contained in:
parent
b141d17274
commit
5b7bcec529
10 changed files with 78 additions and 630 deletions
|
|
@ -27,6 +27,7 @@
|
||||||
#include "pbd/file_utils.h"
|
#include "pbd/file_utils.h"
|
||||||
|
|
||||||
#include "gtkmm2ext/actions.h"
|
#include "gtkmm2ext/actions.h"
|
||||||
|
#include "gtkmm2ext/action_model.h"
|
||||||
#include "gtkmm2ext/bindings.h"
|
#include "gtkmm2ext/bindings.h"
|
||||||
#include "gtkmm2ext/gtk_ui.h"
|
#include "gtkmm2ext/gtk_ui.h"
|
||||||
#include "gtkmm2ext/gui_thread.h"
|
#include "gtkmm2ext/gui_thread.h"
|
||||||
|
|
@ -84,6 +85,7 @@ CC121GUI::CC121GUI (CC121& p)
|
||||||
, table (2, 5)
|
, table (2, 5)
|
||||||
, action_table (5, 4)
|
, action_table (5, 4)
|
||||||
, ignore_active_change (false)
|
, ignore_active_change (false)
|
||||||
|
, action_model (ActionManager::ActionModel::instance ())
|
||||||
{
|
{
|
||||||
set_border_width (12);
|
set_border_width (12);
|
||||||
|
|
||||||
|
|
@ -127,8 +129,6 @@ CC121GUI::CC121GUI (CC121& p)
|
||||||
table.attach (output_combo, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
|
table.attach (output_combo, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
|
||||||
row++;
|
row++;
|
||||||
|
|
||||||
build_available_action_menu ();
|
|
||||||
|
|
||||||
build_user_action_combo (function1_combo, CC121::ButtonState(0), CC121::Function1);
|
build_user_action_combo (function1_combo, CC121::ButtonState(0), CC121::Function1);
|
||||||
build_user_action_combo (function2_combo, CC121::ButtonState(0), CC121::Function2);
|
build_user_action_combo (function2_combo, CC121::ButtonState(0), CC121::Function2);
|
||||||
build_user_action_combo (function3_combo, CC121::ButtonState(0), CC121::Function3);
|
build_user_action_combo (function3_combo, CC121::ButtonState(0), CC121::Function3);
|
||||||
|
|
@ -364,107 +364,11 @@ CC121GUI::update_port_combos ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
CC121GUI::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<string> paths;
|
|
||||||
vector<string> labels;
|
|
||||||
vector<string> tooltips;
|
|
||||||
vector<string> keys;
|
|
||||||
vector<Glib::RefPtr<Gtk::Action> > actions;
|
|
||||||
|
|
||||||
ActionManager::get_all_actions (paths, labels, tooltips, keys, actions);
|
|
||||||
|
|
||||||
typedef std::map<string,TreeIter> NodeMap;
|
|
||||||
NodeMap nodes;
|
|
||||||
NodeMap::iterator r;
|
|
||||||
|
|
||||||
|
|
||||||
vector<string>::iterator k;
|
|
||||||
vector<string>::iterator p;
|
|
||||||
vector<string>::iterator t;
|
|
||||||
vector<string>::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");
|
|
||||||
|
|
||||||
for (l = labels.begin(), k = keys.begin(), p = paths.begin(), t = tooltips.begin(); l != labels.end(); ++k, ++p, ++t, ++l) {
|
|
||||||
|
|
||||||
TreeModel::Row row;
|
|
||||||
vector<string> parts;
|
|
||||||
|
|
||||||
parts.clear ();
|
|
||||||
|
|
||||||
split (*p, parts, '/');
|
|
||||||
|
|
||||||
if (parts.empty()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//kinda kludgy way to avoid displaying menu items as mappable
|
|
||||||
if (parts[0] == _("Main Menu") )
|
|
||||||
continue;
|
|
||||||
if (parts[0] == _("JACK") )
|
|
||||||
continue;
|
|
||||||
if (parts[0] == _("redirectmenu") )
|
|
||||||
continue;
|
|
||||||
if (parts[0] == _("RegionList") )
|
|
||||||
continue;
|
|
||||||
if (parts[0] == _("ProcessorMenu") )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if ((r = nodes.find (parts[0])) == nodes.end()) {
|
|
||||||
|
|
||||||
/* top level is missing */
|
|
||||||
|
|
||||||
TreeIter rowp;
|
|
||||||
TreeModel::Row parent;
|
|
||||||
rowp = available_action_model->append();
|
|
||||||
nodes[parts[0]] = rowp;
|
|
||||||
parent = *(rowp);
|
|
||||||
parent[action_columns.name] = parts[0];
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
row[action_columns.path] = *p;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CC121GUI::action_changed (Gtk::ComboBox* cb, CC121::ButtonID id, CC121::ButtonState bs)
|
CC121GUI::action_changed (Gtk::ComboBox* cb, CC121::ButtonID id, CC121::ButtonState bs)
|
||||||
{
|
{
|
||||||
TreeModel::const_iterator row = cb->get_active ();
|
TreeModel::const_iterator row = cb->get_active ();
|
||||||
string action_path = (*row)[action_columns.path];
|
string action_path = (*row)[action_model.path()];
|
||||||
|
|
||||||
/* release binding */
|
/* release binding */
|
||||||
fp.set_action (id, action_path, false, bs);
|
fp.set_action (id, action_path, false, bs);
|
||||||
|
|
@ -473,7 +377,7 @@ CC121GUI::action_changed (Gtk::ComboBox* cb, CC121::ButtonID id, CC121::ButtonSt
|
||||||
void
|
void
|
||||||
CC121GUI::build_action_combo (Gtk::ComboBox& cb, vector<pair<string,string> > const & actions, CC121::ButtonID id, CC121::ButtonState bs)
|
CC121GUI::build_action_combo (Gtk::ComboBox& cb, vector<pair<string,string> > const & actions, CC121::ButtonID id, CC121::ButtonState bs)
|
||||||
{
|
{
|
||||||
Glib::RefPtr<Gtk::ListStore> model (Gtk::ListStore::create (action_columns));
|
Glib::RefPtr<Gtk::ListStore> model (Gtk::ListStore::create (action_model.columns()));
|
||||||
TreeIter rowp;
|
TreeIter rowp;
|
||||||
TreeModel::Row row;
|
TreeModel::Row row;
|
||||||
string current_action = fp.get_action (id, false, bs); /* lookup release action */
|
string current_action = fp.get_action (id, false, bs); /* lookup release action */
|
||||||
|
|
@ -483,8 +387,8 @@ CC121GUI::build_action_combo (Gtk::ComboBox& cb, vector<pair<string,string> > co
|
||||||
|
|
||||||
rowp = model->append();
|
rowp = model->append();
|
||||||
row = *(rowp);
|
row = *(rowp);
|
||||||
row[action_columns.name] = _("Disabled");
|
row[action_model.name()] = _("Disabled");
|
||||||
row[action_columns.path] = string();
|
row[action_model.path()] = string();
|
||||||
|
|
||||||
if (current_action.empty()) {
|
if (current_action.empty()) {
|
||||||
active_row = 0;
|
active_row = 0;
|
||||||
|
|
@ -493,15 +397,15 @@ CC121GUI::build_action_combo (Gtk::ComboBox& cb, vector<pair<string,string> > co
|
||||||
for (i = actions.begin(), n = 0; i != actions.end(); ++i, ++n) {
|
for (i = actions.begin(), n = 0; i != actions.end(); ++i, ++n) {
|
||||||
rowp = model->append();
|
rowp = model->append();
|
||||||
row = *(rowp);
|
row = *(rowp);
|
||||||
row[action_columns.name] = i->first;
|
row[action_model.name()] = i->first;
|
||||||
row[action_columns.path] = i->second;
|
row[action_model.path()] = i->second;
|
||||||
if (current_action == i->second) {
|
if (current_action == i->second) {
|
||||||
active_row = n+1;
|
active_row = n+1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cb.set_model (model);
|
cb.set_model (model);
|
||||||
cb.pack_start (action_columns.name);
|
cb.pack_start (action_model.name());
|
||||||
|
|
||||||
if (active_row >= 0) {
|
if (active_row >= 0) {
|
||||||
cb.set_active (active_row);
|
cb.set_active (active_row);
|
||||||
|
|
@ -528,7 +432,7 @@ bool
|
||||||
CC121GUI::find_action_in_model (const TreeModel::iterator& iter, std::string const & action_path, TreeModel::iterator* found)
|
CC121GUI::find_action_in_model (const TreeModel::iterator& iter, std::string const & action_path, TreeModel::iterator* found)
|
||||||
{
|
{
|
||||||
TreeModel::Row row = *iter;
|
TreeModel::Row row = *iter;
|
||||||
string path = row[action_columns.path];
|
string path = row[action_model.path()];
|
||||||
|
|
||||||
if (path == action_path) {
|
if (path == action_path) {
|
||||||
*found = iter;
|
*found = iter;
|
||||||
|
|
@ -541,8 +445,8 @@ CC121GUI::find_action_in_model (const TreeModel::iterator& iter, std::string con
|
||||||
void
|
void
|
||||||
CC121GUI::build_user_action_combo (Gtk::ComboBox& cb, CC121::ButtonState bs, CC121::ButtonID id)
|
CC121GUI::build_user_action_combo (Gtk::ComboBox& cb, CC121::ButtonState bs, CC121::ButtonID id)
|
||||||
{
|
{
|
||||||
cb.set_model (available_action_model);
|
cb.set_model (action_model.model());
|
||||||
cb.pack_start (action_columns.name);
|
cb.pack_start (action_model.name());
|
||||||
cb.signal_changed().connect (sigc::bind (sigc::mem_fun (*this, &CC121GUI::action_changed), &cb, id, bs));
|
cb.signal_changed().connect (sigc::bind (sigc::mem_fun (*this, &CC121GUI::action_changed), &cb, id, bs));
|
||||||
|
|
||||||
/* set the active "row" to the right value for the current button binding */
|
/* set the active "row" to the right value for the current button binding */
|
||||||
|
|
@ -554,11 +458,11 @@ CC121GUI::build_user_action_combo (Gtk::ComboBox& cb, CC121::ButtonState bs, CC1
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TreeModel::iterator iter = available_action_model->children().end();
|
TreeModel::iterator iter = action_model.model()->children().end();
|
||||||
|
|
||||||
available_action_model->foreach_iter (sigc::bind (sigc::mem_fun (*this, &CC121GUI::find_action_in_model), current_action, &iter));
|
action_model.model()->foreach_iter (sigc::bind (sigc::mem_fun (*this, &CC121GUI::find_action_in_model), current_action, &iter));
|
||||||
|
|
||||||
if (iter != available_action_model->children().end()) {
|
if (iter != action_model.model()->children().end()) {
|
||||||
cb.set_active (iter);
|
cb.set_active (iter);
|
||||||
} else {
|
} else {
|
||||||
cb.set_active (0);
|
cb.set_active (0);
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,10 @@ namespace Gtk {
|
||||||
|
|
||||||
#include "cc121.h"
|
#include "cc121.h"
|
||||||
|
|
||||||
|
namespace ActionManager {
|
||||||
|
class ActionModel;
|
||||||
|
}
|
||||||
|
|
||||||
namespace ArdourSurface {
|
namespace ArdourSurface {
|
||||||
|
|
||||||
class CC121GUI : public Gtk::VBox
|
class CC121GUI : public Gtk::VBox
|
||||||
|
|
@ -87,16 +91,8 @@ private:
|
||||||
Glib::RefPtr<Gtk::ListStore> build_midi_port_list (std::vector<std::string> const & ports, bool for_input);
|
Glib::RefPtr<Gtk::ListStore> build_midi_port_list (std::vector<std::string> const & ports, bool for_input);
|
||||||
void active_port_changed (Gtk::ComboBox*,bool for_input);
|
void active_port_changed (Gtk::ComboBox*,bool for_input);
|
||||||
|
|
||||||
struct ActionColumns : public Gtk::TreeModel::ColumnRecord {
|
const ActionManager::ActionModel& action_model;
|
||||||
ActionColumns() {
|
|
||||||
add (name);
|
|
||||||
add (path);
|
|
||||||
}
|
|
||||||
Gtk::TreeModelColumn<std::string> name;
|
|
||||||
Gtk::TreeModelColumn<std::string> path;
|
|
||||||
};
|
|
||||||
|
|
||||||
ActionColumns action_columns;
|
|
||||||
Glib::RefPtr<Gtk::TreeStore> available_action_model;
|
Glib::RefPtr<Gtk::TreeStore> available_action_model;
|
||||||
std::map<std::string,std::string> action_map; // map from action names to paths
|
std::map<std::string,std::string> action_map; // map from action names to paths
|
||||||
|
|
||||||
|
|
@ -104,7 +100,6 @@ private:
|
||||||
void build_user_action_combo (Gtk::ComboBox&, CC121::ButtonState, CC121::ButtonID);
|
void build_user_action_combo (Gtk::ComboBox&, CC121::ButtonState, CC121::ButtonID);
|
||||||
void build_foot_action_combo (Gtk::ComboBox&, CC121::ButtonState);
|
void build_foot_action_combo (Gtk::ComboBox&, CC121::ButtonState);
|
||||||
|
|
||||||
void build_available_action_menu ();
|
|
||||||
void action_changed (Gtk::ComboBox*, CC121::ButtonID, CC121::ButtonState);
|
void action_changed (Gtk::ComboBox*, CC121::ButtonID, CC121::ButtonState);
|
||||||
|
|
||||||
bool find_action_in_model (const Gtk::TreeModel::iterator& iter, std::string const & action_path, Gtk::TreeModel::iterator* found);
|
bool find_action_in_model (const Gtk::TreeModel::iterator& iter, std::string const & action_path, Gtk::TreeModel::iterator* found);
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
#include "pbd/unwind.h"
|
#include "pbd/unwind.h"
|
||||||
|
|
||||||
#include "gtkmm2ext/actions.h"
|
#include "gtkmm2ext/actions.h"
|
||||||
|
#include "gtkmm2ext/action_model.h"
|
||||||
#include "gtkmm2ext/bindings.h"
|
#include "gtkmm2ext/bindings.h"
|
||||||
#include "gtkmm2ext/gtk_ui.h"
|
#include "gtkmm2ext/gtk_ui.h"
|
||||||
#include "gtkmm2ext/gui_thread.h"
|
#include "gtkmm2ext/gui_thread.h"
|
||||||
|
|
@ -83,6 +84,7 @@ FPGUI::FPGUI (FaderPort& p)
|
||||||
, table (2, 5)
|
, table (2, 5)
|
||||||
, action_table (5, 4)
|
, action_table (5, 4)
|
||||||
, ignore_active_change (false)
|
, ignore_active_change (false)
|
||||||
|
, action_model (ActionManager::ActionModel::instance ())
|
||||||
{
|
{
|
||||||
set_border_width (12);
|
set_border_width (12);
|
||||||
|
|
||||||
|
|
@ -137,8 +139,6 @@ FPGUI::FPGUI (FaderPort& p)
|
||||||
build_trns_action_combo (trns_combo[1], FaderPort::ShiftDown);
|
build_trns_action_combo (trns_combo[1], FaderPort::ShiftDown);
|
||||||
build_trns_action_combo (trns_combo[2], FaderPort::LongPress);
|
build_trns_action_combo (trns_combo[2], FaderPort::LongPress);
|
||||||
|
|
||||||
build_available_action_menu ();
|
|
||||||
|
|
||||||
build_foot_action_combo (foot_combo[0], FaderPort::ButtonState(0));
|
build_foot_action_combo (foot_combo[0], FaderPort::ButtonState(0));
|
||||||
build_foot_action_combo (foot_combo[1], FaderPort::ShiftDown);
|
build_foot_action_combo (foot_combo[1], FaderPort::ShiftDown);
|
||||||
build_foot_action_combo (foot_combo[2], FaderPort::LongPress);
|
build_foot_action_combo (foot_combo[2], FaderPort::LongPress);
|
||||||
|
|
@ -345,123 +345,11 @@ FPGUI::update_port_combos ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
FPGUI::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<string> paths;
|
|
||||||
vector<string> labels;
|
|
||||||
vector<string> tooltips;
|
|
||||||
vector<string> keys;
|
|
||||||
vector<Glib::RefPtr<Gtk::Action> > actions;
|
|
||||||
|
|
||||||
ActionManager::get_all_actions (paths, labels, tooltips, keys, actions);
|
|
||||||
|
|
||||||
typedef std::map<string,TreeIter> NodeMap;
|
|
||||||
NodeMap nodes;
|
|
||||||
NodeMap::iterator r;
|
|
||||||
|
|
||||||
|
|
||||||
vector<string>::iterator k;
|
|
||||||
vector<string>::iterator p;
|
|
||||||
vector<string>::iterator t;
|
|
||||||
vector<string>::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<string> parts;
|
|
||||||
|
|
||||||
parts.clear ();
|
|
||||||
|
|
||||||
split (*p, parts, '/');
|
|
||||||
|
|
||||||
if (parts.empty()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//kinda kludgy way to avoid displaying menu items as mappable
|
|
||||||
if (parts[0] == _("Main Menu") )
|
|
||||||
continue;
|
|
||||||
if (parts[0] == _("JACK") )
|
|
||||||
continue;
|
|
||||||
if (parts[0] == _("redirectmenu") )
|
|
||||||
continue;
|
|
||||||
if (parts[0] == _("RegionList") )
|
|
||||||
continue;
|
|
||||||
if (parts[0] == _("ProcessorMenu") )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if ((r = nodes.find (parts[0])) == nodes.end()) {
|
|
||||||
|
|
||||||
/* top level is missing */
|
|
||||||
|
|
||||||
TreeIter rowp;
|
|
||||||
TreeModel::Row parent;
|
|
||||||
rowp = available_action_model->append();
|
|
||||||
nodes[parts[0]] = rowp;
|
|
||||||
parent = *(rowp);
|
|
||||||
parent[action_columns.name] = parts[0];
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
row[action_columns.path] = *p;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
FPGUI::action_changed (Gtk::ComboBox* cb, FaderPort::ButtonID id, FaderPort::ButtonState bs)
|
FPGUI::action_changed (Gtk::ComboBox* cb, FaderPort::ButtonID id, FaderPort::ButtonState bs)
|
||||||
{
|
{
|
||||||
TreeModel::const_iterator row = cb->get_active ();
|
TreeModel::const_iterator row = cb->get_active ();
|
||||||
string action_path = (*row)[action_columns.path];
|
string action_path = (*row)[action_model.path()];
|
||||||
|
|
||||||
/* release binding */
|
/* release binding */
|
||||||
fp.set_action (id, action_path, false, bs);
|
fp.set_action (id, action_path, false, bs);
|
||||||
|
|
@ -470,7 +358,7 @@ FPGUI::action_changed (Gtk::ComboBox* cb, FaderPort::ButtonID id, FaderPort::But
|
||||||
void
|
void
|
||||||
FPGUI::build_action_combo (Gtk::ComboBox& cb, vector<pair<string,string> > const & actions, FaderPort::ButtonID id, FaderPort::ButtonState bs)
|
FPGUI::build_action_combo (Gtk::ComboBox& cb, vector<pair<string,string> > const & actions, FaderPort::ButtonID id, FaderPort::ButtonState bs)
|
||||||
{
|
{
|
||||||
Glib::RefPtr<Gtk::ListStore> model (Gtk::ListStore::create (action_columns));
|
Glib::RefPtr<Gtk::ListStore> model (Gtk::ListStore::create (action_model.columns()));
|
||||||
TreeIter rowp;
|
TreeIter rowp;
|
||||||
TreeModel::Row row;
|
TreeModel::Row row;
|
||||||
string current_action = fp.get_action (id, false, bs); /* lookup release action */
|
string current_action = fp.get_action (id, false, bs); /* lookup release action */
|
||||||
|
|
@ -480,8 +368,8 @@ FPGUI::build_action_combo (Gtk::ComboBox& cb, vector<pair<string,string> > const
|
||||||
|
|
||||||
rowp = model->append();
|
rowp = model->append();
|
||||||
row = *(rowp);
|
row = *(rowp);
|
||||||
row[action_columns.name] = _("Disabled");
|
row[action_model.name()] = _("Disabled");
|
||||||
row[action_columns.path] = string();
|
row[action_model.path()] = string();
|
||||||
|
|
||||||
if (current_action.empty()) {
|
if (current_action.empty()) {
|
||||||
active_row = 0;
|
active_row = 0;
|
||||||
|
|
@ -490,15 +378,15 @@ FPGUI::build_action_combo (Gtk::ComboBox& cb, vector<pair<string,string> > const
|
||||||
for (i = actions.begin(), n = 0; i != actions.end(); ++i, ++n) {
|
for (i = actions.begin(), n = 0; i != actions.end(); ++i, ++n) {
|
||||||
rowp = model->append();
|
rowp = model->append();
|
||||||
row = *(rowp);
|
row = *(rowp);
|
||||||
row[action_columns.name] = i->first;
|
row[action_model.name()] = i->first;
|
||||||
row[action_columns.path] = i->second;
|
row[action_model.path()] = i->second;
|
||||||
if (current_action == i->second) {
|
if (current_action == i->second) {
|
||||||
active_row = n+1;
|
active_row = n+1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cb.set_model (model);
|
cb.set_model (model);
|
||||||
cb.pack_start (action_columns.name);
|
cb.pack_start (action_model.name());
|
||||||
|
|
||||||
if (active_row >= 0) {
|
if (active_row >= 0) {
|
||||||
cb.set_active (active_row);
|
cb.set_active (active_row);
|
||||||
|
|
@ -576,7 +464,7 @@ bool
|
||||||
FPGUI::find_action_in_model (const TreeModel::iterator& iter, std::string const & action_path, TreeModel::iterator* found)
|
FPGUI::find_action_in_model (const TreeModel::iterator& iter, std::string const & action_path, TreeModel::iterator* found)
|
||||||
{
|
{
|
||||||
TreeModel::Row row = *iter;
|
TreeModel::Row row = *iter;
|
||||||
string path = row[action_columns.path];
|
string path = row[action_model.path()];
|
||||||
|
|
||||||
if (path == action_path) {
|
if (path == action_path) {
|
||||||
*found = iter;
|
*found = iter;
|
||||||
|
|
@ -592,8 +480,8 @@ FPGUI::build_user_action_combo (Gtk::ComboBox& cb, FaderPort::ButtonState bs)
|
||||||
#ifndef MIXBUS
|
#ifndef MIXBUS
|
||||||
bs = FaderPort::ButtonState (bs|FaderPort::UserDown);
|
bs = FaderPort::ButtonState (bs|FaderPort::UserDown);
|
||||||
#endif
|
#endif
|
||||||
cb.set_model (available_action_model);
|
cb.set_model (action_model.model());
|
||||||
cb.pack_start (action_columns.name);
|
cb.pack_start (action_model.name());
|
||||||
cb.signal_changed().connect (sigc::bind (sigc::mem_fun (*this, &FPGUI::action_changed), &cb, FaderPort::User, bs));
|
cb.signal_changed().connect (sigc::bind (sigc::mem_fun (*this, &FPGUI::action_changed), &cb, FaderPort::User, bs));
|
||||||
|
|
||||||
/* set the active "row" to the right value for the current button binding */
|
/* set the active "row" to the right value for the current button binding */
|
||||||
|
|
@ -605,11 +493,11 @@ FPGUI::build_user_action_combo (Gtk::ComboBox& cb, FaderPort::ButtonState bs)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TreeModel::iterator iter = available_action_model->children().end();
|
TreeModel::iterator iter = action_model.model()->children().end();
|
||||||
|
|
||||||
available_action_model->foreach_iter (sigc::bind (sigc::mem_fun (*this, &FPGUI::find_action_in_model), current_action, &iter));
|
action_model.model()->foreach_iter (sigc::bind (sigc::mem_fun (*this, &FPGUI::find_action_in_model), current_action, &iter));
|
||||||
|
|
||||||
if (iter != available_action_model->children().end()) {
|
if (iter != action_model.model()->children().end()) {
|
||||||
cb.set_active (iter);
|
cb.set_active (iter);
|
||||||
} else {
|
} else {
|
||||||
cb.set_active (0);
|
cb.set_active (0);
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,10 @@ namespace Gtk {
|
||||||
|
|
||||||
#include "faderport.h"
|
#include "faderport.h"
|
||||||
|
|
||||||
|
namespace ActionManager {
|
||||||
|
class ActionModel;
|
||||||
|
}
|
||||||
|
|
||||||
namespace ArdourSurface {
|
namespace ArdourSurface {
|
||||||
|
|
||||||
class FPGUI : public Gtk::VBox
|
class FPGUI : public Gtk::VBox
|
||||||
|
|
@ -83,17 +87,8 @@ private:
|
||||||
Glib::RefPtr<Gtk::ListStore> build_midi_port_list (std::vector<std::string> const & ports, bool for_input);
|
Glib::RefPtr<Gtk::ListStore> build_midi_port_list (std::vector<std::string> const & ports, bool for_input);
|
||||||
void active_port_changed (Gtk::ComboBox*,bool for_input);
|
void active_port_changed (Gtk::ComboBox*,bool for_input);
|
||||||
|
|
||||||
struct ActionColumns : public Gtk::TreeModel::ColumnRecord {
|
const ActionManager::ActionModel& action_model;
|
||||||
ActionColumns() {
|
|
||||||
add (name);
|
|
||||||
add (path);
|
|
||||||
}
|
|
||||||
Gtk::TreeModelColumn<std::string> name;
|
|
||||||
Gtk::TreeModelColumn<std::string> path;
|
|
||||||
};
|
|
||||||
|
|
||||||
ActionColumns action_columns;
|
|
||||||
Glib::RefPtr<Gtk::TreeStore> available_action_model;
|
|
||||||
std::map<std::string,std::string> action_map; // map from action names to paths
|
std::map<std::string,std::string> action_map; // map from action names to paths
|
||||||
|
|
||||||
void build_action_combo (Gtk::ComboBox& cb, std::vector<std::pair<std::string,std::string> > const & actions, FaderPort::ButtonID, FaderPort::ButtonState);
|
void build_action_combo (Gtk::ComboBox& cb, std::vector<std::pair<std::string,std::string> > const & actions, FaderPort::ButtonID, FaderPort::ButtonState);
|
||||||
|
|
@ -103,7 +98,6 @@ private:
|
||||||
void build_user_action_combo (Gtk::ComboBox&, FaderPort::ButtonState);
|
void build_user_action_combo (Gtk::ComboBox&, FaderPort::ButtonState);
|
||||||
void build_foot_action_combo (Gtk::ComboBox&, FaderPort::ButtonState);
|
void build_foot_action_combo (Gtk::ComboBox&, FaderPort::ButtonState);
|
||||||
|
|
||||||
void build_available_action_menu ();
|
|
||||||
void action_changed (Gtk::ComboBox*, FaderPort::ButtonID, FaderPort::ButtonState);
|
void action_changed (Gtk::ComboBox*, FaderPort::ButtonID, FaderPort::ButtonState);
|
||||||
|
|
||||||
bool find_action_in_model (const Gtk::TreeModel::iterator& iter, std::string const & action_path, Gtk::TreeModel::iterator* found);
|
bool find_action_in_model (const Gtk::TreeModel::iterator& iter, std::string const & action_path, Gtk::TreeModel::iterator* found);
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@
|
||||||
#include "pbd/file_utils.h"
|
#include "pbd/file_utils.h"
|
||||||
|
|
||||||
#include "gtkmm2ext/actions.h"
|
#include "gtkmm2ext/actions.h"
|
||||||
|
#include "gtkmm2ext/action_model.h"
|
||||||
#include "gtkmm2ext/bindings.h"
|
#include "gtkmm2ext/bindings.h"
|
||||||
#include "gtkmm2ext/gtk_ui.h"
|
#include "gtkmm2ext/gtk_ui.h"
|
||||||
#include "gtkmm2ext/gui_thread.h"
|
#include "gtkmm2ext/gui_thread.h"
|
||||||
|
|
@ -85,6 +86,7 @@ FP8GUI::FP8GUI (FaderPort8& p)
|
||||||
, ignore_active_change (false)
|
, ignore_active_change (false)
|
||||||
, two_line_text_cb (_("Two Line Trackname"))
|
, two_line_text_cb (_("Two Line Trackname"))
|
||||||
, auto_pluginui_cb (_("Auto Show/Hide Plugin GUIs"))
|
, auto_pluginui_cb (_("Auto Show/Hide Plugin GUIs"))
|
||||||
|
, action_model (ActionManager::ActionModel::instance ())
|
||||||
{
|
{
|
||||||
set_border_width (12);
|
set_border_width (12);
|
||||||
|
|
||||||
|
|
@ -148,7 +150,6 @@ FP8GUI::FP8GUI (FaderPort8& p)
|
||||||
pack_start (hpacker, false, false);
|
pack_start (hpacker, false, false);
|
||||||
|
|
||||||
/* actions */
|
/* actions */
|
||||||
build_available_action_menu ();
|
|
||||||
|
|
||||||
int action_row = 0;
|
int action_row = 0;
|
||||||
int action_col = 0;
|
int action_col = 0;
|
||||||
|
|
@ -340,107 +341,11 @@ FP8GUI::active_port_changed (Gtk::ComboBox* combo, bool for_input)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
FP8GUI::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<string> paths;
|
|
||||||
vector<string> labels;
|
|
||||||
vector<string> tooltips;
|
|
||||||
vector<string> keys;
|
|
||||||
vector<Glib::RefPtr<Gtk::Action> > actions;
|
|
||||||
|
|
||||||
ActionManager::get_all_actions (paths, labels, tooltips, keys, actions);
|
|
||||||
|
|
||||||
typedef std::map<string,TreeIter> NodeMap;
|
|
||||||
NodeMap nodes;
|
|
||||||
NodeMap::iterator r;
|
|
||||||
|
|
||||||
|
|
||||||
vector<string>::iterator k;
|
|
||||||
vector<string>::iterator p;
|
|
||||||
vector<string>::iterator t;
|
|
||||||
vector<string>::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");
|
|
||||||
|
|
||||||
for (l = labels.begin(), k = keys.begin(), p = paths.begin(), t = tooltips.begin(); l != labels.end(); ++k, ++p, ++t, ++l) {
|
|
||||||
|
|
||||||
TreeModel::Row row;
|
|
||||||
vector<string> parts;
|
|
||||||
|
|
||||||
parts.clear ();
|
|
||||||
|
|
||||||
split (*p, parts, '/');
|
|
||||||
|
|
||||||
if (parts.empty()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//kinda kludgy way to avoid displaying menu items as mappable
|
|
||||||
if (parts[0] == _("Main Menu") )
|
|
||||||
continue;
|
|
||||||
if (parts[0] == _("JACK") )
|
|
||||||
continue;
|
|
||||||
if (parts[0] == _("redirectmenu") )
|
|
||||||
continue;
|
|
||||||
if (parts[0] == _("RegionList") )
|
|
||||||
continue;
|
|
||||||
if (parts[0] == _("ProcessorMenu") )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if ((r = nodes.find (parts[0])) == nodes.end()) {
|
|
||||||
|
|
||||||
/* top level is missing */
|
|
||||||
|
|
||||||
TreeIter rowp;
|
|
||||||
TreeModel::Row parent;
|
|
||||||
rowp = available_action_model->append();
|
|
||||||
nodes[parts[0]] = rowp;
|
|
||||||
parent = *(rowp);
|
|
||||||
parent[action_columns.name] = parts[0];
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
row[action_columns.path] = *p;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
FP8GUI::find_action_in_model (const TreeModel::iterator& iter, std::string const& action_path, TreeModel::iterator* found)
|
FP8GUI::find_action_in_model (const TreeModel::iterator& iter, std::string const& action_path, TreeModel::iterator* found)
|
||||||
{
|
{
|
||||||
TreeModel::Row row = *iter;
|
TreeModel::Row row = *iter;
|
||||||
string path = row[action_columns.path];
|
string path = row[action_model.path()];
|
||||||
|
|
||||||
if (path == action_path) {
|
if (path == action_path) {
|
||||||
*found = iter;
|
*found = iter;
|
||||||
|
|
@ -453,8 +358,8 @@ FP8GUI::find_action_in_model (const TreeModel::iterator& iter, std::string const
|
||||||
void
|
void
|
||||||
FP8GUI::build_action_combo (Gtk::ComboBox& cb, FP8Controls::ButtonId id)
|
FP8GUI::build_action_combo (Gtk::ComboBox& cb, FP8Controls::ButtonId id)
|
||||||
{
|
{
|
||||||
cb.set_model (available_action_model);
|
cb.set_model (action_model.model());
|
||||||
cb.pack_start (action_columns.name);
|
cb.pack_start (action_model.name());
|
||||||
|
|
||||||
/* set the active "row" to the right value for the current button binding */
|
/* set the active "row" to the right value for the current button binding */
|
||||||
string current_action = fp.get_button_action (id, false); /* lookup release action */
|
string current_action = fp.get_button_action (id, false); /* lookup release action */
|
||||||
|
|
@ -462,11 +367,11 @@ FP8GUI::build_action_combo (Gtk::ComboBox& cb, FP8Controls::ButtonId id)
|
||||||
if (current_action.empty()) {
|
if (current_action.empty()) {
|
||||||
cb.set_active (0); /* "disabled" */
|
cb.set_active (0); /* "disabled" */
|
||||||
} else {
|
} else {
|
||||||
TreeModel::iterator iter = available_action_model->children().end();
|
TreeModel::iterator iter = action_model.model()->children().end();
|
||||||
|
|
||||||
available_action_model->foreach_iter (sigc::bind (sigc::mem_fun (*this, &FP8GUI::find_action_in_model), current_action, &iter));
|
action_model.model()->foreach_iter (sigc::bind (sigc::mem_fun (*this, &FP8GUI::find_action_in_model), current_action, &iter));
|
||||||
|
|
||||||
if (iter != available_action_model->children().end()) {
|
if (iter != action_model.model()->children().end()) {
|
||||||
cb.set_active (iter);
|
cb.set_active (iter);
|
||||||
} else {
|
} else {
|
||||||
cb.set_active (0);
|
cb.set_active (0);
|
||||||
|
|
@ -480,7 +385,7 @@ void
|
||||||
FP8GUI::action_changed (Gtk::ComboBox* cb, FP8Controls::ButtonId id)
|
FP8GUI::action_changed (Gtk::ComboBox* cb, FP8Controls::ButtonId id)
|
||||||
{
|
{
|
||||||
TreeModel::const_iterator row = cb->get_active ();
|
TreeModel::const_iterator row = cb->get_active ();
|
||||||
string action_path = (*row)[action_columns.path];
|
string action_path = (*row)[action_model.path()];
|
||||||
fp.set_button_action (id, false, action_path);
|
fp.set_button_action (id, false, action_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,10 @@ namespace Gtk {
|
||||||
|
|
||||||
#include "faderport8.h"
|
#include "faderport8.h"
|
||||||
|
|
||||||
|
namespace ActionManager {
|
||||||
|
class ActionModel;
|
||||||
|
}
|
||||||
|
|
||||||
namespace ArdourSurface { namespace FP_NAMESPACE {
|
namespace ArdourSurface { namespace FP_NAMESPACE {
|
||||||
|
|
||||||
class FP8GUI : public Gtk::VBox
|
class FP8GUI : public Gtk::VBox
|
||||||
|
|
@ -88,21 +92,11 @@ private:
|
||||||
void auto_pluginui_toggled ();
|
void auto_pluginui_toggled ();
|
||||||
|
|
||||||
/* user actions */
|
/* user actions */
|
||||||
void build_available_action_menu ();
|
|
||||||
void build_action_combo (Gtk::ComboBox& cb, FP8Controls::ButtonId id);
|
void build_action_combo (Gtk::ComboBox& cb, FP8Controls::ButtonId id);
|
||||||
void action_changed (Gtk::ComboBox* cb, FP8Controls::ButtonId id);
|
void action_changed (Gtk::ComboBox* cb, FP8Controls::ButtonId id);
|
||||||
|
|
||||||
struct ActionColumns : public Gtk::TreeModel::ColumnRecord {
|
const ActionManager::ActionModel& action_model;
|
||||||
ActionColumns() {
|
|
||||||
add (name);
|
|
||||||
add (path);
|
|
||||||
}
|
|
||||||
Gtk::TreeModelColumn<std::string> name;
|
|
||||||
Gtk::TreeModelColumn<std::string> path;
|
|
||||||
};
|
|
||||||
|
|
||||||
ActionColumns action_columns;
|
|
||||||
Glib::RefPtr<Gtk::TreeStore> available_action_model;
|
|
||||||
std::map<std::string,std::string> action_map; // map from action names to paths
|
std::map<std::string,std::string> action_map; // map from action names to paths
|
||||||
|
|
||||||
bool find_action_in_model (const Gtk::TreeModel::iterator& iter, std::string const & action_path, Gtk::TreeModel::iterator* found);
|
bool find_action_in_model (const Gtk::TreeModel::iterator& iter, std::string const & action_path, Gtk::TreeModel::iterator* found);
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@
|
||||||
#include "pbd/stacktrace.h"
|
#include "pbd/stacktrace.h"
|
||||||
|
|
||||||
#include "gtkmm2ext/actions.h"
|
#include "gtkmm2ext/actions.h"
|
||||||
|
#include "gtkmm2ext/action_model.h"
|
||||||
#include "gtkmm2ext/bindings.h"
|
#include "gtkmm2ext/bindings.h"
|
||||||
#include "gtkmm2ext/gui_thread.h"
|
#include "gtkmm2ext/gui_thread.h"
|
||||||
#include "gtkmm2ext/utils.h"
|
#include "gtkmm2ext/utils.h"
|
||||||
|
|
@ -88,6 +89,7 @@ MackieControlProtocol::build_gui ()
|
||||||
MackieControlProtocolGUI::MackieControlProtocolGUI (MackieControlProtocol& p)
|
MackieControlProtocolGUI::MackieControlProtocolGUI (MackieControlProtocol& p)
|
||||||
: _cp (p)
|
: _cp (p)
|
||||||
, table (2, 9)
|
, table (2, 9)
|
||||||
|
, action_model (ActionManager::ActionModel::instance ())
|
||||||
, touch_sensitivity_adjustment (0, 0, 9, 1, 4)
|
, touch_sensitivity_adjustment (0, 0, 9, 1, 4)
|
||||||
, touch_sensitivity_scale (touch_sensitivity_adjustment)
|
, touch_sensitivity_scale (touch_sensitivity_adjustment)
|
||||||
, recalibrate_fader_button (_("Recalibrate Faders"))
|
, recalibrate_fader_button (_("Recalibrate Faders"))
|
||||||
|
|
@ -239,7 +241,6 @@ MackieControlProtocolGUI::MackieControlProtocolGUI (MackieControlProtocol& p)
|
||||||
function_key_scroller.add (function_key_editor);
|
function_key_scroller.add (function_key_editor);
|
||||||
append_page (*fkey_packer, _("Function Keys"));
|
append_page (*fkey_packer, _("Function Keys"));
|
||||||
|
|
||||||
build_available_action_menu ();
|
|
||||||
build_function_key_editor ();
|
build_function_key_editor ();
|
||||||
refresh_function_key_editor ();
|
refresh_function_key_editor ();
|
||||||
fkey_packer->show_all();
|
fkey_packer->show_all();
|
||||||
|
|
@ -441,117 +442,6 @@ MackieControlProtocolGUI::make_action_renderer (Glib::RefPtr<TreeStore> model, G
|
||||||
return renderer;
|
return renderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
MackieControlProtocolGUI::build_available_action_menu ()
|
|
||||||
{
|
|
||||||
/* build a model of all available actions (needs to be tree structured
|
|
||||||
* more)
|
|
||||||
*/
|
|
||||||
|
|
||||||
available_action_model = TreeStore::create (available_action_columns);
|
|
||||||
|
|
||||||
vector<string> paths;
|
|
||||||
vector<string> labels;
|
|
||||||
vector<string> tooltips;
|
|
||||||
vector<string> keys;
|
|
||||||
vector<Glib::RefPtr<Gtk::Action> > actions;
|
|
||||||
|
|
||||||
typedef std::map<string,TreeIter> NodeMap;
|
|
||||||
NodeMap nodes;
|
|
||||||
NodeMap::iterator r;
|
|
||||||
|
|
||||||
ActionManager::get_all_actions (paths, labels, tooltips, keys, actions);
|
|
||||||
|
|
||||||
vector<string>::iterator k;
|
|
||||||
vector<string>::iterator p;
|
|
||||||
vector<string>::iterator t;
|
|
||||||
vector<string>::iterator l;
|
|
||||||
|
|
||||||
available_action_model->clear ();
|
|
||||||
|
|
||||||
/* Because there are button bindings built in that are not
|
|
||||||
in the key binding map, there needs to be a way to undo
|
|
||||||
a profile edit.
|
|
||||||
*/
|
|
||||||
TreeIter rowp;
|
|
||||||
TreeModel::Row parent;
|
|
||||||
rowp = available_action_model->append();
|
|
||||||
parent = *(rowp);
|
|
||||||
parent[available_action_columns.name] = _("Remove Binding");
|
|
||||||
|
|
||||||
/* Key aliasing */
|
|
||||||
|
|
||||||
rowp = available_action_model->append();
|
|
||||||
parent = *(rowp);
|
|
||||||
parent[available_action_columns.name] = _("Shift");
|
|
||||||
rowp = available_action_model->append();
|
|
||||||
parent = *(rowp);
|
|
||||||
parent[available_action_columns.name] = _("Control");
|
|
||||||
rowp = available_action_model->append();
|
|
||||||
parent = *(rowp);
|
|
||||||
parent[available_action_columns.name] = _("Option");
|
|
||||||
rowp = available_action_model->append();
|
|
||||||
parent = *(rowp);
|
|
||||||
parent[available_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<string> parts;
|
|
||||||
|
|
||||||
parts.clear ();
|
|
||||||
|
|
||||||
split (*p, parts, '/');
|
|
||||||
|
|
||||||
if (parts.empty()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//kinda kludgy way to avoid displaying menu items as mappable
|
|
||||||
if (parts[0] == _("Main Menu") )
|
|
||||||
continue;
|
|
||||||
if (parts[0] == _("JACK") )
|
|
||||||
continue;
|
|
||||||
if (parts[0] == _("redirectmenu") )
|
|
||||||
continue;
|
|
||||||
if (parts[0] == _("RegionList") )
|
|
||||||
continue;
|
|
||||||
if (parts[0] == _("ProcessorMenu") )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if ((r = nodes.find (parts[0])) == nodes.end()) {
|
|
||||||
|
|
||||||
/* top level is missing */
|
|
||||||
|
|
||||||
TreeIter rowp;
|
|
||||||
TreeModel::Row parent;
|
|
||||||
rowp = available_action_model->append();
|
|
||||||
nodes[parts[0]] = rowp;
|
|
||||||
parent = *(rowp);
|
|
||||||
parent[available_action_columns.name] = parts[0];
|
|
||||||
|
|
||||||
row = *(available_action_model->append (parent.children()));
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
row = *(available_action_model->append ((*r->second)->children()));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* add this action */
|
|
||||||
|
|
||||||
if (l->empty ()) {
|
|
||||||
row[available_action_columns.name] = *t;
|
|
||||||
action_map[*t] = *p;
|
|
||||||
} else {
|
|
||||||
row[available_action_columns.name] = *l;
|
|
||||||
action_map[*l] = *p;
|
|
||||||
}
|
|
||||||
|
|
||||||
row[available_action_columns.path] = *p;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MackieControlProtocolGUI::build_function_key_editor ()
|
MackieControlProtocolGUI::build_function_key_editor ()
|
||||||
{
|
{
|
||||||
|
|
@ -560,32 +450,32 @@ MackieControlProtocolGUI::build_function_key_editor ()
|
||||||
TreeViewColumn* col;
|
TreeViewColumn* col;
|
||||||
CellRendererCombo* renderer;
|
CellRendererCombo* renderer;
|
||||||
|
|
||||||
renderer = make_action_renderer (available_action_model, function_key_columns.plain);
|
renderer = make_action_renderer (action_model.model(), function_key_columns.plain);
|
||||||
col = manage (new TreeViewColumn (_("Plain"), *renderer));
|
col = manage (new TreeViewColumn (_("Plain"), *renderer));
|
||||||
col->add_attribute (renderer->property_text(), function_key_columns.plain);
|
col->add_attribute (renderer->property_text(), function_key_columns.plain);
|
||||||
function_key_editor.append_column (*col);
|
function_key_editor.append_column (*col);
|
||||||
|
|
||||||
renderer = make_action_renderer (available_action_model, function_key_columns.shift);
|
renderer = make_action_renderer (action_model.model(), function_key_columns.shift);
|
||||||
col = manage (new TreeViewColumn (_("Shift"), *renderer));
|
col = manage (new TreeViewColumn (_("Shift"), *renderer));
|
||||||
col->add_attribute (renderer->property_text(), function_key_columns.shift);
|
col->add_attribute (renderer->property_text(), function_key_columns.shift);
|
||||||
function_key_editor.append_column (*col);
|
function_key_editor.append_column (*col);
|
||||||
|
|
||||||
renderer = make_action_renderer (available_action_model, function_key_columns.control);
|
renderer = make_action_renderer (action_model.model(), function_key_columns.control);
|
||||||
col = manage (new TreeViewColumn (_("Control"), *renderer));
|
col = manage (new TreeViewColumn (_("Control"), *renderer));
|
||||||
col->add_attribute (renderer->property_text(), function_key_columns.control);
|
col->add_attribute (renderer->property_text(), function_key_columns.control);
|
||||||
function_key_editor.append_column (*col);
|
function_key_editor.append_column (*col);
|
||||||
|
|
||||||
renderer = make_action_renderer (available_action_model, function_key_columns.option);
|
renderer = make_action_renderer (action_model.model(), function_key_columns.option);
|
||||||
col = manage (new TreeViewColumn (_("Option"), *renderer));
|
col = manage (new TreeViewColumn (_("Option"), *renderer));
|
||||||
col->add_attribute (renderer->property_text(), function_key_columns.option);
|
col->add_attribute (renderer->property_text(), function_key_columns.option);
|
||||||
function_key_editor.append_column (*col);
|
function_key_editor.append_column (*col);
|
||||||
|
|
||||||
renderer = make_action_renderer (available_action_model, function_key_columns.cmdalt);
|
renderer = make_action_renderer (action_model.model(), function_key_columns.cmdalt);
|
||||||
col = manage (new TreeViewColumn (_("Cmd/Alt"), *renderer));
|
col = manage (new TreeViewColumn (_("Cmd/Alt"), *renderer));
|
||||||
col->add_attribute (renderer->property_text(), function_key_columns.cmdalt);
|
col->add_attribute (renderer->property_text(), function_key_columns.cmdalt);
|
||||||
function_key_editor.append_column (*col);
|
function_key_editor.append_column (*col);
|
||||||
|
|
||||||
renderer = make_action_renderer (available_action_model, function_key_columns.shiftcontrol);
|
renderer = make_action_renderer (action_model.model(), function_key_columns.shiftcontrol);
|
||||||
col = manage (new TreeViewColumn (_("Shift+Control"), *renderer));
|
col = manage (new TreeViewColumn (_("Shift+Control"), *renderer));
|
||||||
col->add_attribute (renderer->property_text(), function_key_columns.shiftcontrol);
|
col->add_attribute (renderer->property_text(), function_key_columns.shiftcontrol);
|
||||||
function_key_editor.append_column (*col);
|
function_key_editor.append_column (*col);
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,10 @@ namespace Gtk {
|
||||||
|
|
||||||
#include "pbd/i18n.h"
|
#include "pbd/i18n.h"
|
||||||
|
|
||||||
|
namespace ActionManager {
|
||||||
|
class ActionModel;
|
||||||
|
}
|
||||||
|
|
||||||
namespace ArdourSurface {
|
namespace ArdourSurface {
|
||||||
|
|
||||||
class MackieControlProtocol;
|
class MackieControlProtocol;
|
||||||
|
|
@ -67,15 +71,6 @@ class MackieControlProtocolGUI : public Gtk::Notebook
|
||||||
Gtk::TreeModelColumn<std::string> full_name;
|
Gtk::TreeModelColumn<std::string> full_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AvailableActionColumns : public Gtk::TreeModel::ColumnRecord {
|
|
||||||
AvailableActionColumns() {
|
|
||||||
add (name);
|
|
||||||
add (path);
|
|
||||||
}
|
|
||||||
Gtk::TreeModelColumn<std::string> name;
|
|
||||||
Gtk::TreeModelColumn<std::string> path;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct FunctionKeyColumns : public Gtk::TreeModel::ColumnRecord {
|
struct FunctionKeyColumns : public Gtk::TreeModel::ColumnRecord {
|
||||||
FunctionKeyColumns() {
|
FunctionKeyColumns() {
|
||||||
add (name);
|
add (name);
|
||||||
|
|
@ -97,18 +92,17 @@ class MackieControlProtocolGUI : public Gtk::Notebook
|
||||||
Gtk::TreeModelColumn<std::string> shiftcontrol;
|
Gtk::TreeModelColumn<std::string> shiftcontrol;
|
||||||
};
|
};
|
||||||
|
|
||||||
AvailableActionColumns available_action_columns;
|
|
||||||
FunctionKeyColumns function_key_columns;
|
FunctionKeyColumns function_key_columns;
|
||||||
MidiPortColumns midi_port_columns;
|
MidiPortColumns midi_port_columns;
|
||||||
|
|
||||||
Gtk::ScrolledWindow function_key_scroller;
|
Gtk::ScrolledWindow function_key_scroller;
|
||||||
Gtk::TreeView function_key_editor;
|
Gtk::TreeView function_key_editor;
|
||||||
Glib::RefPtr<Gtk::ListStore> function_key_model;
|
Glib::RefPtr<Gtk::ListStore> function_key_model;
|
||||||
Glib::RefPtr<Gtk::TreeStore> available_action_model;
|
|
||||||
|
const ActionManager::ActionModel& action_model;
|
||||||
|
|
||||||
Glib::RefPtr<Gtk::ListStore> build_midi_port_list (bool for_input);
|
Glib::RefPtr<Gtk::ListStore> build_midi_port_list (bool for_input);
|
||||||
|
|
||||||
void build_available_action_menu ();
|
|
||||||
void refresh_function_key_editor ();
|
void refresh_function_key_editor ();
|
||||||
void build_function_key_editor ();
|
void build_function_key_editor ();
|
||||||
void action_changed (const Glib::ustring &sPath, const Glib::ustring &text, Gtk::TreeModelColumnBase);
|
void action_changed (const Glib::ustring &sPath, const Glib::ustring &text, Gtk::TreeModelColumnBase);
|
||||||
|
|
@ -157,4 +151,3 @@ class MackieControlProtocolGUI : public Gtk::Notebook
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@
|
||||||
#include "pbd/stacktrace.h"
|
#include "pbd/stacktrace.h"
|
||||||
|
|
||||||
#include "gtkmm2ext/actions.h"
|
#include "gtkmm2ext/actions.h"
|
||||||
|
#include "gtkmm2ext/action_model.h"
|
||||||
#include "gtkmm2ext/bindings.h"
|
#include "gtkmm2ext/bindings.h"
|
||||||
#include "gtkmm2ext/gui_thread.h"
|
#include "gtkmm2ext/gui_thread.h"
|
||||||
#include "gtkmm2ext/utils.h"
|
#include "gtkmm2ext/utils.h"
|
||||||
|
|
@ -89,6 +90,7 @@ US2400Protocol::build_gui ()
|
||||||
US2400ProtocolGUI::US2400ProtocolGUI (US2400Protocol& p)
|
US2400ProtocolGUI::US2400ProtocolGUI (US2400Protocol& p)
|
||||||
: _cp (p)
|
: _cp (p)
|
||||||
, table (2, 9)
|
, table (2, 9)
|
||||||
|
, action_model (ActionManager::ActionModel::instance ())
|
||||||
, _device_dependent_widget (0)
|
, _device_dependent_widget (0)
|
||||||
, _ignore_profile_changed (false)
|
, _ignore_profile_changed (false)
|
||||||
, ignore_active_change (false)
|
, ignore_active_change (false)
|
||||||
|
|
@ -155,7 +157,6 @@ US2400ProtocolGUI::US2400ProtocolGUI (US2400Protocol& p)
|
||||||
function_key_scroller.add (function_key_editor);
|
function_key_scroller.add (function_key_editor);
|
||||||
append_page (*fkey_packer, _("Function Keys"));
|
append_page (*fkey_packer, _("Function Keys"));
|
||||||
|
|
||||||
build_available_action_menu ();
|
|
||||||
build_function_key_editor ();
|
build_function_key_editor ();
|
||||||
refresh_function_key_editor ();
|
refresh_function_key_editor ();
|
||||||
fkey_packer->show_all();
|
fkey_packer->show_all();
|
||||||
|
|
@ -356,116 +357,6 @@ US2400ProtocolGUI::make_action_renderer (Glib::RefPtr<TreeStore> model, Gtk::Tre
|
||||||
return renderer;
|
return renderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
US2400ProtocolGUI::build_available_action_menu ()
|
|
||||||
{
|
|
||||||
/* build a model of all available actions (needs to be tree structured
|
|
||||||
* more)
|
|
||||||
*/
|
|
||||||
|
|
||||||
available_action_model = TreeStore::create (available_action_columns);
|
|
||||||
|
|
||||||
vector<string> paths;
|
|
||||||
vector<string> labels;
|
|
||||||
vector<string> tooltips;
|
|
||||||
vector<string> keys;
|
|
||||||
vector<Glib::RefPtr<Gtk::Action> > actions;
|
|
||||||
|
|
||||||
typedef std::map<string,TreeIter> NodeMap;
|
|
||||||
NodeMap nodes;
|
|
||||||
NodeMap::iterator r;
|
|
||||||
|
|
||||||
ActionManager::get_all_actions (paths, labels, tooltips, keys, actions);
|
|
||||||
|
|
||||||
vector<string>::iterator k;
|
|
||||||
vector<string>::iterator p;
|
|
||||||
vector<string>::iterator t;
|
|
||||||
vector<string>::iterator l;
|
|
||||||
|
|
||||||
available_action_model->clear ();
|
|
||||||
|
|
||||||
/* Because there are button bindings built in that are not
|
|
||||||
* in the key binding map, there needs to be a way to undo
|
|
||||||
* a profile edit. */
|
|
||||||
TreeIter rowp;
|
|
||||||
TreeModel::Row parent;
|
|
||||||
rowp = available_action_model->append();
|
|
||||||
parent = *(rowp);
|
|
||||||
parent[available_action_columns.name] = _("Remove Binding");
|
|
||||||
|
|
||||||
/* Key aliasing */
|
|
||||||
|
|
||||||
rowp = available_action_model->append();
|
|
||||||
parent = *(rowp);
|
|
||||||
parent[available_action_columns.name] = _("Shift");
|
|
||||||
rowp = available_action_model->append();
|
|
||||||
parent = *(rowp);
|
|
||||||
parent[available_action_columns.name] = _("Control");
|
|
||||||
rowp = available_action_model->append();
|
|
||||||
parent = *(rowp);
|
|
||||||
parent[available_action_columns.name] = _("Option");
|
|
||||||
rowp = available_action_model->append();
|
|
||||||
parent = *(rowp);
|
|
||||||
parent[available_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<string> parts;
|
|
||||||
|
|
||||||
parts.clear ();
|
|
||||||
|
|
||||||
split (*p, parts, '/');
|
|
||||||
|
|
||||||
if (parts.empty()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* kinda kludgy way to avoid displaying menu items as mappable */
|
|
||||||
if (parts[0] == _("Main Menu"))
|
|
||||||
continue;
|
|
||||||
if (parts[0] == _("JACK"))
|
|
||||||
continue;
|
|
||||||
if (parts[0] == _("redirectmenu"))
|
|
||||||
continue;
|
|
||||||
if (parts[0] == _("RegionList"))
|
|
||||||
continue;
|
|
||||||
if (parts[0] == _("ProcessorMenu"))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if ((r = nodes.find (parts[0])) == nodes.end()) {
|
|
||||||
|
|
||||||
/* top level is missing */
|
|
||||||
|
|
||||||
TreeIter rowp;
|
|
||||||
TreeModel::Row parent;
|
|
||||||
rowp = available_action_model->append();
|
|
||||||
nodes[parts[0]] = rowp;
|
|
||||||
parent = *(rowp);
|
|
||||||
parent[available_action_columns.name] = parts[0];
|
|
||||||
|
|
||||||
row = *(available_action_model->append (parent.children()));
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
row = *(available_action_model->append ((*r->second)->children()));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* add this action */
|
|
||||||
|
|
||||||
if (l->empty ()) {
|
|
||||||
row[available_action_columns.name] = *t;
|
|
||||||
action_map[*t] = *p;
|
|
||||||
} else {
|
|
||||||
row[available_action_columns.name] = *l;
|
|
||||||
action_map[*l] = *p;
|
|
||||||
}
|
|
||||||
|
|
||||||
row[available_action_columns.path] = (*p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
US2400ProtocolGUI::build_function_key_editor ()
|
US2400ProtocolGUI::build_function_key_editor ()
|
||||||
{
|
{
|
||||||
|
|
@ -474,12 +365,12 @@ US2400ProtocolGUI::build_function_key_editor ()
|
||||||
TreeViewColumn* col;
|
TreeViewColumn* col;
|
||||||
CellRendererCombo* renderer;
|
CellRendererCombo* renderer;
|
||||||
|
|
||||||
renderer = make_action_renderer (available_action_model, function_key_columns.plain);
|
renderer = make_action_renderer (action_model.model(), function_key_columns.plain);
|
||||||
col = manage (new TreeViewColumn (_("Plain"), *renderer));
|
col = manage (new TreeViewColumn (_("Plain"), *renderer));
|
||||||
col->add_attribute (renderer->property_text(), function_key_columns.plain);
|
col->add_attribute (renderer->property_text(), function_key_columns.plain);
|
||||||
function_key_editor.append_column (*col);
|
function_key_editor.append_column (*col);
|
||||||
|
|
||||||
renderer = make_action_renderer (available_action_model, function_key_columns.shift);
|
renderer = make_action_renderer (action_model.model(), function_key_columns.shift);
|
||||||
col = manage (new TreeViewColumn (_("Shift"), *renderer));
|
col = manage (new TreeViewColumn (_("Shift"), *renderer));
|
||||||
col->add_attribute (renderer->property_text(), function_key_columns.shift);
|
col->add_attribute (renderer->property_text(), function_key_columns.shift);
|
||||||
function_key_editor.append_column (*col);
|
function_key_editor.append_column (*col);
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,10 @@ namespace Gtk {
|
||||||
|
|
||||||
#include "pbd/i18n.h"
|
#include "pbd/i18n.h"
|
||||||
|
|
||||||
|
namespace ActionManager {
|
||||||
|
class ActionModel;
|
||||||
|
}
|
||||||
|
|
||||||
namespace ArdourSurface {
|
namespace ArdourSurface {
|
||||||
|
|
||||||
class US2400Protocol;
|
class US2400Protocol;
|
||||||
|
|
@ -66,15 +70,6 @@ class US2400ProtocolGUI : public Gtk::Notebook
|
||||||
Gtk::TreeModelColumn<std::string> full_name;
|
Gtk::TreeModelColumn<std::string> full_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AvailableActionColumns : public Gtk::TreeModel::ColumnRecord {
|
|
||||||
AvailableActionColumns() {
|
|
||||||
add (name);
|
|
||||||
add (path);
|
|
||||||
}
|
|
||||||
Gtk::TreeModelColumn<std::string> name;
|
|
||||||
Gtk::TreeModelColumn<std::string> path;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct FunctionKeyColumns : public Gtk::TreeModel::ColumnRecord {
|
struct FunctionKeyColumns : public Gtk::TreeModel::ColumnRecord {
|
||||||
FunctionKeyColumns() {
|
FunctionKeyColumns() {
|
||||||
add (name);
|
add (name);
|
||||||
|
|
@ -96,7 +91,6 @@ class US2400ProtocolGUI : public Gtk::Notebook
|
||||||
Gtk::TreeModelColumn<std::string> shiftcontrol;
|
Gtk::TreeModelColumn<std::string> shiftcontrol;
|
||||||
};
|
};
|
||||||
|
|
||||||
AvailableActionColumns available_action_columns;
|
|
||||||
FunctionKeyColumns function_key_columns;
|
FunctionKeyColumns function_key_columns;
|
||||||
MidiPortColumns midi_port_columns;
|
MidiPortColumns midi_port_columns;
|
||||||
|
|
||||||
|
|
@ -107,7 +101,8 @@ class US2400ProtocolGUI : public Gtk::Notebook
|
||||||
|
|
||||||
Glib::RefPtr<Gtk::ListStore> build_midi_port_list (bool for_input);
|
Glib::RefPtr<Gtk::ListStore> build_midi_port_list (bool for_input);
|
||||||
|
|
||||||
void build_available_action_menu ();
|
const ActionManager::ActionModel& action_model;
|
||||||
|
|
||||||
void refresh_function_key_editor ();
|
void refresh_function_key_editor ();
|
||||||
void build_function_key_editor ();
|
void build_function_key_editor ();
|
||||||
void action_changed (const Glib::ustring &sPath, const Glib::ustring &text, Gtk::TreeModelColumnBase);
|
void action_changed (const Glib::ustring &sPath, const Glib::ustring &text, Gtk::TreeModelColumnBase);
|
||||||
|
|
@ -139,4 +134,3 @@ class US2400ProtocolGUI : public Gtk::Notebook
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue