2013-01-16 13:37:48 -05:00
|
|
|
/*
|
2015-10-04 14:51:05 -04:00
|
|
|
Copyright (C) 2012 Paul Davis
|
2013-01-16 13:37:48 -05:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
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>
|
2007-10-11 21:54:35 -04:00
|
|
|
#include <gtkmm/treeview.h>
|
|
|
|
#include <gtkmm/treestore.h>
|
2016-03-07 17:56:03 -05:00
|
|
|
#include "gtkmm2ext/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
|
|
|
{
|
|
|
|
public:
|
|
|
|
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-03-07 17:56:03 -05:00
|
|
|
private:
|
2015-08-04 13:59:32 -04:00
|
|
|
class Tab : public Gtk::VBox
|
|
|
|
{
|
2016-03-07 17:56:03 -05: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
|
|
|
|
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;
|
|
|
|
|
|
|
|
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;
|
2016-03-07 17:56:03 -05:00
|
|
|
Gtkmm2ext::SearchBar filter_entry;
|
|
|
|
std::string filter_string;
|
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 ();
|
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&);
|
2007-10-11 21:54:35 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* __ardour_gtk_key_editor_h__ */
|