2 Copyright (C) 2009 Paul Davis
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.
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.
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.
19 #ifndef __ardour_gtk2_midi_list_editor_h_
20 #define __ardour_gtk2_midi_list_editor_h_
22 #include <gtkmm/treeview.h>
23 #include <gtkmm/table.h>
24 #include <gtkmm/box.h>
25 #include <gtkmm/liststore.h>
26 #include <gtkmm/scrolledwindow.h>
28 #include "evoral/types.hpp"
30 #include "ardour/session_handle.h"
32 #include "ardour_window.h"
35 template<typename Time> class Note;
45 class MidiListEditor : public ArdourWindow
48 typedef Evoral::Note<Evoral::MusicalTime> NoteType;
50 MidiListEditor(ARDOUR::Session*, boost::shared_ptr<ARDOUR::MidiRegion>,
51 boost::shared_ptr<ARDOUR::MidiTrack>);
55 struct MidiListModelColumns : public Gtk::TreeModel::ColumnRecord {
56 MidiListModelColumns() {
66 Gtk::TreeModelColumn<uint8_t> channel;
67 Gtk::TreeModelColumn<uint8_t> note;
68 Gtk::TreeModelColumn<std::string> note_name;
69 Gtk::TreeModelColumn<uint8_t> velocity;
70 Gtk::TreeModelColumn<std::string> start;
71 Gtk::TreeModelColumn<std::string> length;
72 Gtk::TreeModelColumn<std::string> end;
73 Gtk::TreeModelColumn<boost::shared_ptr<NoteType> > _note;
76 struct NoteLengthColumns : public Gtk::TreeModel::ColumnRecord {
81 Gtk::TreeModelColumn<int> ticks;
82 Gtk::TreeModelColumn<std::string> name;
85 MidiListModelColumns columns;
86 Glib::RefPtr<Gtk::ListStore> model;
87 NoteLengthColumns note_length_columns;
88 Glib::RefPtr<Gtk::ListStore> note_length_model;
90 Gtk::ScrolledWindow scroller;
91 Gtk::TreeModel::Path edit_path;
93 Gtk::CellRendererText* editing_renderer;
94 Gtk::CellEditable* editing_editable;
97 Gtk::ToggleButton sound_notes_button;
99 boost::shared_ptr<ARDOUR::MidiRegion> region;
100 boost::shared_ptr<ARDOUR::MidiTrack> track;
102 /** connection used to connect to model's ContentChanged signal */
103 PBD::ScopedConnection content_connection;
105 void edited (const std::string&, const std::string&);
106 void editing_started (Gtk::CellEditable*, const std::string& path, int);
107 void editing_canceled ();
108 void stop_editing (bool cancelled = false);
110 void redisplay_model ();
112 bool key_press (GdkEventKey* ev);
113 bool key_release (GdkEventKey* ev);
115 void delete_selected_note ();
116 void selection_changed ();
119 #endif /* __ardour_gtk2_midi_list_editor_h_ */