1e25d104f96d8a004fec96ceb05f85c3da3ba088
[ardour.git] / gtk2_ardour / midi_list_editor.h
1 /*
2    Copyright (C) 2009 Paul Davis
3
4         This program is free software; you can redistribute it and/or modify
5         it under the terms of the GNU General Public License as published by
6         the Free Software Foundation; either version 2 of the License, or
7         (at your option) any later version.
8
9         This program is distributed in the hope that it will be useful,
10         but WITHOUT ANY WARRANTY; without even the implied warranty of
11         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12         GNU General Public License for more details.
13
14         You should have received a copy of the GNU General Public License
15         along with this program; if not, write to the Free Software
16         Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef __ardour_gtk2_midi_list_editor_h_
21 #define __ardour_gtk2_midi_list_editor_h_
22
23 #include <gtkmm/treeview.h>
24 #include <gtkmm/liststore.h>
25 #include <gtkmm/scrolledwindow.h>
26
27 #include "evoral/types.hpp"
28
29 #include "ardour/session_handle.h"
30
31 #include "ardour_dialog.h"
32
33 namespace ARDOUR {
34         class MidiRegion;
35         class MidiModel;
36         class Session;
37 };
38
39 class MidiListEditor : public ArdourDialog
40 {
41   public:
42         typedef Evoral::Note<Evoral::MusicalTime> NoteType;
43
44         MidiListEditor(ARDOUR::Session*, boost::shared_ptr<ARDOUR::MidiRegion>);
45         ~MidiListEditor();
46
47   private:
48         struct MidiListModelColumns : public Gtk::TreeModel::ColumnRecord {
49                 MidiListModelColumns() {
50                         add (channel);
51                         add (note);
52                         add (note_name);
53                         add (velocity);
54                         add (start);
55                         add (length);
56                         add (end);
57                         add (_note);
58                 };
59                 Gtk::TreeModelColumn<uint8_t> channel;
60                 Gtk::TreeModelColumn<uint8_t> note;
61                 Gtk::TreeModelColumn<std::string> note_name;
62                 Gtk::TreeModelColumn<uint8_t> velocity;
63                 Gtk::TreeModelColumn<std::string> start;
64                 Gtk::TreeModelColumn<std::string> length;
65                 Gtk::TreeModelColumn<std::string> end;
66                 Gtk::TreeModelColumn<boost::shared_ptr<NoteType> > _note;
67         };
68
69         MidiListModelColumns         columns;
70         Glib::RefPtr<Gtk::ListStore> model;
71         Gtk::TreeView                view;
72         Gtk::ScrolledWindow          scroller;
73         std::string               _current_edit;
74
75         boost::shared_ptr<ARDOUR::MidiRegion> region;
76
77         void edited (const std::string&, const std::string&);
78         void editing_started (Gtk::CellEditable*, const std::string& path, int);
79         void editing_canceled ();
80
81         void redisplay_model ();
82
83         bool key_press (GdkEventKey* ev);
84         bool key_release (GdkEventKey* ev);
85
86         void delete_selected_note ();
87 };
88
89 #endif /* __ardour_gtk2_midi_list_editor_h_ */