MCP: fix uninitialized variable; start work on extending MCP gui
authorPaul Davis <paul@linuxaudiosystems.com>
Fri, 13 Apr 2012 17:06:35 +0000 (17:06 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Fri, 13 Apr 2012 17:06:35 +0000 (17:06 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@11961 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/surfaces/mackie/gui.cc
libs/surfaces/mackie/gui.h [new file with mode: 0644]
libs/surfaces/mackie/mackie_control_protocol.cc

index 76715a4751f3cf40e317451b710a66489c23ed7a..b710f8076f1d9ab8ee68bfd6bea2a38f6569a68e 100644 (file)
 #include <gtkmm/box.h>
 #include <gtkmm/spinbutton.h>
 #include <gtkmm/table.h>
+#include <gtkmm/treeview.h>
+#include <gtkmm/liststore.h>
+#include <gtkmm/treestore.h>
+#include <gtkmm/notebook.h>
+#include <gtkmm/cellrenderercombo.h>
+
 #include "gtkmm2ext/utils.h"
-#include "ardour/rc_configuration.h"
+#include "gtkmm2ext/actions.h"
 
 #include "mackie_control_protocol.h"
 #include "device_info.h"
+#include "gui.h"
 
 #include "i18n.h"
 
 using namespace std;
 using namespace Mackie;
-
-class MackieControlProtocolGUI : public Gtk::VBox
-{
-public:
-       MackieControlProtocolGUI (MackieControlProtocol &);
-
-private:
-
-       void surface_combo_changed ();
-       
-       MackieControlProtocol& _cp;
-       Gtk::ComboBoxText _surface_combo;
-};
+using namespace Gtk;
 
 void*
 MackieControlProtocol::get_gui () const
@@ -69,6 +64,8 @@ MackieControlProtocol::build_gui ()
 MackieControlProtocolGUI::MackieControlProtocolGUI (MackieControlProtocol& p)
        : _cp (p)
 {
+       set_border_width (12);
+
        Gtk::Table* table = Gtk::manage (new Gtk::Table (2, 2));
        table->set_spacings (4);
        
@@ -83,14 +80,55 @@ MackieControlProtocolGUI::MackieControlProtocolGUI (MackieControlProtocol& p)
        }
        Gtkmm2ext::set_popdown_strings (_surface_combo, surfaces);
        _surface_combo.set_active_text (p.device_info().name());
+       _surface_combo.signal_changed().connect (sigc::mem_fun (*this, &MackieControlProtocolGUI::surface_combo_changed));
 
-       pack_start (*table);
+       append_page (*table, _("Device Selection"));
+       table->show_all();
 
-       set_spacing (4);
-       set_border_width (12);
-       show_all ();
+       /* function key editor */
 
-       _surface_combo.signal_changed().connect (sigc::mem_fun (*this, &MackieControlProtocolGUI::surface_combo_changed));
+       append_page (function_key_scroller, _("Function Keys"));
+       function_key_scroller.add (function_key_editor);
+       
+       rebuild_function_key_editor ();
+       function_key_scroller.show_all();
+}
+
+void
+MackieControlProtocolGUI::rebuild_function_key_editor ()
+{
+       /* build a model of all available actions (needs to be tree structured
+        * more) 
+        */
+
+       available_action_model = TreeStore::create (available_action_columns);
+
+       vector<string> a_names;
+       vector<string> a_paths;
+       vector<string> a_tooltips;
+       vector<string> a_keys;
+       vector<Gtk::AccelKey> a_bindings;
+
+       ActionManager::get_all_actions (a_names, a_paths, a_tooltips, a_keys, a_bindings);
+
+       vector<string>::iterator n = a_names.begin();
+       vector<string>::iterator p = a_paths.begin();
+       TreeModel::Row r;
+
+       for (; n != a_names.end(); ++n, ++p) {
+               r = *(available_action_model->append());
+               r[available_action_columns.name] = (*n);
+               r[available_action_columns.path] = (*p);
+       }
+
+       function_key_editor.append_column (_("Key"), function_key_columns.name);
+
+       CellRendererCombo* plain_renderer = manage (new CellRendererCombo);
+       plain_renderer->property_model() = available_action_model;
+       plain_renderer->property_editable() = true;
+       plain_renderer->property_text_column() = 1;
+       TreeViewColumn* plain_column = manage (new TreeViewColumn (_("plain"), *plain_renderer));
+       function_key_editor.append_column (*plain_column);
 }
 
 void
diff --git a/libs/surfaces/mackie/gui.h b/libs/surfaces/mackie/gui.h
new file mode 100644 (file)
index 0000000..a20429a
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+       Copyright (C) 2010 Paul Davis
+
+       This program is free software; you can redistribute it and/or modify
+       it under the terms of the GNU General Public License as published by
+       the Free Software Foundation; either version 2 of the License, or
+       (at your option) any later version.
+
+       This program is distributed in the hope that it will be useful,
+       but WITHOUT ANY WARRANTY; without even the implied warranty of
+       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+       GNU General Public License for more details.
+
+       You should have received a copy of the GNU General Public License
+       along with this program; if not, write to the Free Software
+       Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include <gtkmm/comboboxtext.h>
+#include <gtkmm/box.h>
+#include <gtkmm/spinbutton.h>
+#include <gtkmm/table.h>
+#include <gtkmm/treeview.h>
+#include <gtkmm/liststore.h>
+#include <gtkmm/notebook.h>
+#include <gtkmm/scrolledwindow.h>
+
+class MackieControlProtocol;
+
+#include "i18n.h"
+
+class MackieControlProtocolGUI : public Gtk::Notebook
+{
+  public:
+    MackieControlProtocolGUI (MackieControlProtocol &);
+    
+  private:
+    void surface_combo_changed ();
+    
+    MackieControlProtocol& _cp;
+    Gtk::ComboBoxText _surface_combo;
+
+    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 {
+       FunctionKeyColumns() {
+               add (name);
+               add (unmodified);
+               add (shift);
+               add (control);
+               add (option);
+               add (cmdalt);
+               add (shiftcontrol);
+       };
+       Gtk::TreeModelColumn<std::string> name;
+       Gtk::TreeModelColumn<std::string> unmodified;
+       Gtk::TreeModelColumn<std::string> shift;
+       Gtk::TreeModelColumn<std::string> control;
+       Gtk::TreeModelColumn<std::string> option;
+       Gtk::TreeModelColumn<std::string> cmdalt;
+       Gtk::TreeModelColumn<std::string> shiftcontrol;
+    };
+
+    AvailableActionColumns available_action_columns;
+    FunctionKeyColumns function_key_columns;
+
+    Gtk::ScrolledWindow function_key_scroller;
+    Gtk::TreeView function_key_editor;
+    Glib::RefPtr<Gtk::ListStore> function_key_model;
+    Glib::RefPtr<Gtk::TreeStore> available_action_model;
+
+    void rebuild_function_key_editor ();
+};
+
index 3a39cc35224d24871b4187e54b9f9d4a55b983ba..2b9cda74799f3df938325536dbdc9d71c4cebbfd 100644 (file)
@@ -102,6 +102,7 @@ MackieControlProtocol::MackieControlProtocol (Session& session)
        , _flip_mode (false)
        , _view_mode (Mixer)
        , _current_selected_track (-1)
+       , _modifier_state (0)
 {
        DEBUG_TRACE (DEBUG::MackieControl, "MackieControlProtocol::MackieControlProtocol\n");