X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fkeyeditor.h;h=9cbde979ecda6697d2f1c709c1badb3383956aeb;hb=6b1b72a247bf04c81292fc41af4f69c9b7f90379;hp=ba374c71b2c6987d696d8262f93fd5a7249c9b81;hpb=a26827d3b7348ee209347527f6f2a4a819aaed2e;p=ardour.git diff --git a/gtk2_ardour/keyeditor.h b/gtk2_ardour/keyeditor.h index ba374c71b2..9cbde979ec 100644 --- a/gtk2_ardour/keyeditor.h +++ b/gtk2_ardour/keyeditor.h @@ -1,55 +1,138 @@ +/* + Copyright (C) 2012 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. + +*/ + #ifndef __ardour_gtk_key_editor_h__ #define __ardour_gtk_key_editor_h__ #include #include -#include -#include +#include #include +#include +#include +#include + +#include "widgets/searchbar.h" #include "ardour_window.h" +namespace Gtkmm2ext { + class Bindings; +} + class KeyEditor : public ArdourWindow { - public: +public: KeyEditor (); - protected: - void on_show (); - void on_unmap (); - bool on_key_press_event (GdkEventKey*); - bool on_key_release_event (GdkEventKey*); - - private: - struct KeyEditorColumns : public Gtk::TreeModel::ColumnRecord { - KeyEditorColumns () { - add (action); - add (binding); - add (path); - add (bindable); - } - Gtk::TreeModelColumn action; - Gtk::TreeModelColumn binding; - Gtk::TreeModelColumn path; - Gtk::TreeModelColumn bindable; + void add_tab (std::string const &name, Gtkmm2ext::Bindings&); + void remove_tab (std::string const &name); + + static sigc::signal UpdateBindings; + + void disconnect () { + _refresh_connection.disconnect (); + } + +private: + class Tab : public Gtk::VBox + { + public: + Tab (KeyEditor&, std::string const &name, Gtkmm2ext::Bindings*); + + uint32_t populate (); + void unbind (); + void bind (GdkEventKey* release_event, guint pressed_key); + void action_selected (); + void sort_column_changed (); + void tab_mapped (); + bool visible_func(const Gtk::TreeModel::const_iterator& iter) const; + + struct KeyEditorColumns : public Gtk::TreeModel::ColumnRecord { + KeyEditorColumns () { + add (name); + add (binding); + add (path); + add (bindable); + add (action); + } + Gtk::TreeModelColumn name; + Gtk::TreeModelColumn binding; + Gtk::TreeModelColumn path; + Gtk::TreeModelColumn bindable; + Gtk::TreeModelColumn > action; + }; + + Gtk::VBox vpacker; + /* give KeyEditor full access to these. This is just a helper + * class with no special semantics + */ + + KeyEditor& owner; + std::string name; + Gtkmm2ext::Bindings* bindings; + Gtk::ScrolledWindow scroller; + Gtk::TreeView view; + Glib::RefPtr data_model; + Glib::RefPtr filter; + Glib::RefPtr sorted_filter; + KeyEditorColumns columns; + guint last_keyval; + + protected: + bool key_press_event (GdkEventKey*); + bool key_release_event (GdkEventKey*); + Gtk::TreeModel::iterator find_action_path (Gtk::TreeModel::const_iterator begin, Gtk::TreeModel::const_iterator end, const std::string& path) const; }; - Gtk::VBox vpacker; - Gtk::ScrolledWindow scroller; - Gtk::TreeView view; - Glib::RefPtr model; - KeyEditorColumns columns; + friend class Tab; + + Gtk::VBox vpacker; + Gtk::Notebook notebook; Gtk::Button unbind_button; Gtk::HButtonBox unbind_box; + Gtk::HBox reset_box; + Gtk::Button reset_button; + Gtk::Label reset_label; + ArdourWidgets::SearchBar filter_entry; + std::string filter_string; + Gtk::Button print_button; + Gtk::Label print_label; + + typedef std::vector Tabs; + + Tabs tabs; + Tab* current_tab(); void unbind (); + void reset (); + void refresh (); + void page_change (GtkNotebookPage*, guint); - bool can_bind; - guint last_state; + unsigned int sort_column; + Gtk::SortType sort_type; + void toggle_sort_type (); + void search_string_updated (const std::string&); + void print () const; - void action_selected (); - void populate (); + sigc::connection _refresh_connection; }; #endif /* __ardour_gtk_key_editor_h__ */