summaryrefslogtreecommitdiff
path: root/libs/surfaces/faderport8
diff options
context:
space:
mode:
authorJohannes Mueller <github@johannes-mueller.org>2019-04-20 14:08:36 +0200
committerJohannes Mueller <github@johannes-mueller.org>2019-04-20 15:25:32 +0200
commit5b7bcec529c0b44cacf61298a0df5e7903e111d9 (patch)
tree6641ada41ecff828d7944fe453b841693ce5d095 /libs/surfaces/faderport8
parentb141d17274c5d778fc8847e6129b37105be858ae (diff)
Use ActionModel API in the Control Surfaces that can make use of it
Diffstat (limited to 'libs/surfaces/faderport8')
-rw-r--r--libs/surfaces/faderport8/gui.cc113
-rw-r--r--libs/surfaces/faderport8/gui.h16
2 files changed, 14 insertions, 115 deletions
diff --git a/libs/surfaces/faderport8/gui.cc b/libs/surfaces/faderport8/gui.cc
index 6eb4fabfb8..a4b0b9b172 100644
--- a/libs/surfaces/faderport8/gui.cc
+++ b/libs/surfaces/faderport8/gui.cc
@@ -27,6 +27,7 @@
#include "pbd/file_utils.h"
#include "gtkmm2ext/actions.h"
+#include "gtkmm2ext/action_model.h"
#include "gtkmm2ext/bindings.h"
#include "gtkmm2ext/gtk_ui.h"
#include "gtkmm2ext/gui_thread.h"
@@ -85,6 +86,7 @@ FP8GUI::FP8GUI (FaderPort8& p)
, ignore_active_change (false)
, two_line_text_cb (_("Two Line Trackname"))
, auto_pluginui_cb (_("Auto Show/Hide Plugin GUIs"))
+ , action_model (ActionManager::ActionModel::instance ())
{
set_border_width (12);
@@ -148,7 +150,6 @@ FP8GUI::FP8GUI (FaderPort8& p)
pack_start (hpacker, false, false);
/* actions */
- build_available_action_menu ();
int action_row = 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
FP8GUI::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];
+ string path = row[action_model.path()];
if (path == action_path) {
*found = iter;
@@ -453,8 +358,8 @@ FP8GUI::find_action_in_model (const TreeModel::iterator& iter, std::string const
void
FP8GUI::build_action_combo (Gtk::ComboBox& cb, FP8Controls::ButtonId id)
{
- cb.set_model (available_action_model);
- cb.pack_start (action_columns.name);
+ cb.set_model (action_model.model());
+ cb.pack_start (action_model.name());
/* 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 */
@@ -462,11 +367,11 @@ FP8GUI::build_action_combo (Gtk::ComboBox& cb, FP8Controls::ButtonId id)
if (current_action.empty()) {
cb.set_active (0); /* "disabled" */
} 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);
} else {
cb.set_active (0);
@@ -480,7 +385,7 @@ void
FP8GUI::action_changed (Gtk::ComboBox* cb, FP8Controls::ButtonId id)
{
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);
}
diff --git a/libs/surfaces/faderport8/gui.h b/libs/surfaces/faderport8/gui.h
index 5e9dfd6489..8b8eacd2d7 100644
--- a/libs/surfaces/faderport8/gui.h
+++ b/libs/surfaces/faderport8/gui.h
@@ -37,6 +37,10 @@ namespace Gtk {
#include "faderport8.h"
+namespace ActionManager {
+ class ActionModel;
+}
+
namespace ArdourSurface { namespace FP_NAMESPACE {
class FP8GUI : public Gtk::VBox
@@ -88,21 +92,11 @@ private:
void auto_pluginui_toggled ();
/* user actions */
- void build_available_action_menu ();
void build_action_combo (Gtk::ComboBox& cb, FP8Controls::ButtonId id);
void action_changed (Gtk::ComboBox* cb, FP8Controls::ButtonId id);
- struct ActionColumns : public Gtk::TreeModel::ColumnRecord {
- ActionColumns() {
- add (name);
- add (path);
- }
- Gtk::TreeModelColumn<std::string> name;
- Gtk::TreeModelColumn<std::string> path;
- };
+ const ActionManager::ActionModel& action_model;
- ActionColumns action_columns;
- Glib::RefPtr<Gtk::TreeStore> available_action_model;
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);