2013-01-16 13:37:48 -05:00
|
|
|
/*
|
2019-08-02 17:26:43 -04:00
|
|
|
* Copyright (C) 2007-2016 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
* Copyright (C) 2008-2011 David Robillard <d@drobilla.net>
|
|
|
|
* Copyright (C) 2016-2017 Robin Gareus <robin@gareus.org>
|
|
|
|
*
|
|
|
|
* 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.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2013-01-16 13:37:48 -05:00
|
|
|
|
2007-10-11 21:54:35 -04:00
|
|
|
#ifndef __ardour_gtk_key_editor_h__
|
|
|
|
#define __ardour_gtk_key_editor_h__
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
2008-01-10 17:22:29 -05:00
|
|
|
#include <gtkmm/buttonbox.h>
|
2015-08-04 13:59:32 -04:00
|
|
|
#include <gtkmm/notebook.h>
|
|
|
|
#include <gtkmm/scrolledwindow.h>
|
2017-07-16 21:48:18 -04:00
|
|
|
#include <gtkmm/treemodelfilter.h>
|
2007-10-11 21:54:35 -04:00
|
|
|
#include <gtkmm/treestore.h>
|
2017-07-16 21:48:18 -04:00
|
|
|
#include <gtkmm/treeview.h>
|
2017-07-16 16:13:46 -04:00
|
|
|
|
|
|
|
#include "widgets/searchbar.h"
|
2007-10-11 21:54:35 -04:00
|
|
|
|
2011-11-18 19:56:35 -05:00
|
|
|
#include "ardour_window.h"
|
2007-10-11 21:54:35 -04:00
|
|
|
|
2015-08-04 13:59:32 -04:00
|
|
|
namespace Gtkmm2ext {
|
|
|
|
class Bindings;
|
|
|
|
}
|
|
|
|
|
2011-11-18 19:56:35 -05:00
|
|
|
class KeyEditor : public ArdourWindow
|
2007-10-11 21:54:35 -04:00
|
|
|
{
|
2017-07-01 15:11:14 -04:00
|
|
|
public:
|
2007-10-11 21:54:35 -04:00
|
|
|
KeyEditor ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2015-08-04 13:59:32 -04:00
|
|
|
void add_tab (std::string const &name, Gtkmm2ext::Bindings&);
|
2016-03-15 16:42:45 -04:00
|
|
|
void remove_tab (std::string const &name);
|
2015-10-26 14:35:06 -04:00
|
|
|
|
2016-04-24 16:20:44 -04:00
|
|
|
static sigc::signal<void> UpdateBindings;
|
|
|
|
|
2016-08-21 16:08:54 -04:00
|
|
|
void disconnect () {
|
|
|
|
_refresh_connection.disconnect ();
|
|
|
|
}
|
|
|
|
|
2017-07-01 15:11:14 -04:00
|
|
|
private:
|
2015-08-04 13:59:32 -04:00
|
|
|
class Tab : public Gtk::VBox
|
|
|
|
{
|
2017-07-01 15:11:14 -04:00
|
|
|
public:
|
2015-08-04 13:59:32 -04:00
|
|
|
Tab (KeyEditor&, std::string const &name, Gtkmm2ext::Bindings*);
|
2015-10-26 14:35:06 -04:00
|
|
|
|
2016-03-15 19:46:28 -04:00
|
|
|
uint32_t populate ();
|
2015-08-04 13:59:32 -04:00
|
|
|
void unbind ();
|
|
|
|
void bind (GdkEventKey* release_event, guint pressed_key);
|
|
|
|
void action_selected ();
|
2016-02-27 18:53:39 -05:00
|
|
|
void sort_column_changed ();
|
|
|
|
void tab_mapped ();
|
2016-03-07 17:56:03 -05:00
|
|
|
bool visible_func(const Gtk::TreeModel::const_iterator& iter) const;
|
2015-10-26 14:35:06 -04:00
|
|
|
|
2015-08-04 13:59:32 -04:00
|
|
|
struct KeyEditorColumns : public Gtk::TreeModel::ColumnRecord {
|
|
|
|
KeyEditorColumns () {
|
2015-08-05 10:57:00 -04:00
|
|
|
add (name);
|
2015-08-04 13:59:32 -04:00
|
|
|
add (binding);
|
|
|
|
add (path);
|
|
|
|
add (bindable);
|
2015-08-05 10:57:00 -04:00
|
|
|
add (action);
|
2015-08-04 13:59:32 -04:00
|
|
|
}
|
2015-08-05 10:57:00 -04:00
|
|
|
Gtk::TreeModelColumn<std::string> name;
|
2015-08-04 13:59:32 -04:00
|
|
|
Gtk::TreeModelColumn<std::string> binding;
|
|
|
|
Gtk::TreeModelColumn<std::string> path;
|
|
|
|
Gtk::TreeModelColumn<bool> bindable;
|
2015-08-05 10:57:00 -04:00
|
|
|
Gtk::TreeModelColumn<Glib::RefPtr<Gtk::Action> > action;
|
2015-08-04 13:59:32 -04:00
|
|
|
};
|
2015-10-26 14:35:06 -04:00
|
|
|
|
2015-08-04 13:59:32 -04:00
|
|
|
Gtk::VBox vpacker;
|
|
|
|
/* give KeyEditor full access to these. This is just a helper
|
2017-07-01 15:11:14 -04:00
|
|
|
* class with no special semantics
|
|
|
|
*/
|
2015-10-26 14:35:06 -04:00
|
|
|
|
2015-08-04 13:59:32 -04:00
|
|
|
KeyEditor& owner;
|
|
|
|
std::string name;
|
|
|
|
Gtkmm2ext::Bindings* bindings;
|
|
|
|
Gtk::ScrolledWindow scroller;
|
|
|
|
Gtk::TreeView view;
|
2016-03-07 17:56:03 -05:00
|
|
|
Glib::RefPtr<Gtk::TreeStore> data_model;
|
|
|
|
Glib::RefPtr<Gtk::TreeModelFilter> filter;
|
|
|
|
Glib::RefPtr<Gtk::TreeModelSort> sorted_filter;
|
2015-08-04 13:59:32 -04:00
|
|
|
KeyEditorColumns columns;
|
2016-03-07 17:56:03 -05:00
|
|
|
guint last_keyval;
|
|
|
|
|
2017-07-01 15:11:14 -04:00
|
|
|
protected:
|
2016-03-15 18:15:26 -04:00
|
|
|
bool key_press_event (GdkEventKey*);
|
|
|
|
bool key_release_event (GdkEventKey*);
|
2016-03-07 17:56:03 -05:00
|
|
|
Gtk::TreeModel::iterator find_action_path (Gtk::TreeModel::const_iterator begin, Gtk::TreeModel::const_iterator end, const std::string& path) const;
|
2007-10-11 21:54:35 -04:00
|
|
|
};
|
|
|
|
|
2015-08-04 13:59:32 -04:00
|
|
|
friend class Tab;
|
2015-10-26 14:35:06 -04:00
|
|
|
|
2015-08-04 13:59:32 -04:00
|
|
|
Gtk::VBox vpacker;
|
|
|
|
Gtk::Notebook notebook;
|
2008-01-10 17:22:29 -05:00
|
|
|
Gtk::Button unbind_button;
|
|
|
|
Gtk::HButtonBox unbind_box;
|
2014-07-10 11:04:24 -04:00
|
|
|
Gtk::HBox reset_box;
|
|
|
|
Gtk::Button reset_button;
|
|
|
|
Gtk::Label reset_label;
|
2017-07-16 16:13:46 -04:00
|
|
|
ArdourWidgets::SearchBar filter_entry;
|
2016-03-07 17:56:03 -05:00
|
|
|
std::string filter_string;
|
2016-05-21 09:30:24 -04:00
|
|
|
Gtk::Button print_button;
|
2017-01-05 15:31:27 -05:00
|
|
|
Gtk::Label print_label;
|
2007-10-12 18:30:25 -04:00
|
|
|
|
2015-08-04 13:59:32 -04:00
|
|
|
typedef std::vector<Tab*> Tabs;
|
2014-07-10 11:04:24 -04:00
|
|
|
|
2015-08-04 13:59:32 -04:00
|
|
|
Tabs tabs;
|
|
|
|
Tab* current_tab();
|
|
|
|
|
|
|
|
void unbind ();
|
2014-07-10 11:04:24 -04:00
|
|
|
void reset ();
|
2016-04-24 16:20:44 -04:00
|
|
|
void refresh ();
|
2015-08-04 13:59:32 -04:00
|
|
|
void page_change (GtkNotebookPage*, guint);
|
2016-02-27 18:53:39 -05:00
|
|
|
|
|
|
|
unsigned int sort_column;
|
|
|
|
Gtk::SortType sort_type;
|
|
|
|
void toggle_sort_type ();
|
2016-03-07 17:56:03 -05:00
|
|
|
void search_string_updated (const std::string&);
|
2016-05-21 09:30:24 -04:00
|
|
|
void print () const;
|
2016-08-21 16:08:54 -04:00
|
|
|
|
|
|
|
sigc::connection _refresh_connection;
|
2007-10-11 21:54:35 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* __ardour_gtk_key_editor_h__ */
|