ardour
midi_list_editor.h
Go to the documentation of this file.
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 #ifndef __ardour_gtk2_midi_list_editor_h_
20 #define __ardour_gtk2_midi_list_editor_h_
21 
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>
27 
28 #include "evoral/types.hpp"
29 
30 #include "ardour/session_handle.h"
31 
32 #include "ardour_window.h"
33 
34 namespace Evoral {
35  template<typename Time> class Note;
36 };
37 
38 namespace ARDOUR {
39  class MidiRegion;
40  class MidiModel;
41  class MidiTrack;
42  class Session;
43 };
44 
46 {
47  public:
49 
53 
54  private:
55  struct MidiListModelColumns : public Gtk::TreeModel::ColumnRecord {
57  add (channel);
58  add (note);
59  add (note_name);
60  add (velocity);
61  add (start);
62  add (length);
63  add (_note);
64  };
65  Gtk::TreeModelColumn<uint8_t> channel;
66  Gtk::TreeModelColumn<uint8_t> note;
67  Gtk::TreeModelColumn<std::string> note_name;
68  Gtk::TreeModelColumn<uint8_t> velocity;
69  Gtk::TreeModelColumn<std::string> start;
70  Gtk::TreeModelColumn<std::string> length;
71  Gtk::TreeModelColumn<boost::shared_ptr<NoteType> > _note;
72  };
73 
74  struct NoteLengthColumns : public Gtk::TreeModel::ColumnRecord {
76  add (ticks);
77  add (name);
78  }
79  Gtk::TreeModelColumn<int> ticks;
80  Gtk::TreeModelColumn<std::string> name;
81  };
82 
84  Glib::RefPtr<Gtk::ListStore> model;
86  Glib::RefPtr<Gtk::ListStore> note_length_model;
87  Gtk::TreeView view;
88  Gtk::ScrolledWindow scroller;
89  Gtk::TreeModel::Path edit_path;
91  Gtk::CellRendererText* editing_renderer;
92  Gtk::CellEditable* editing_editable;
93  Gtk::Table buttons;
94  Gtk::VBox vbox;
95  Gtk::ToggleButton sound_notes_button;
96 
99 
102 
103  void edited (const std::string&, const std::string&);
104  void editing_started (Gtk::CellEditable*, const std::string& path, int);
105  void editing_canceled ();
106  void stop_editing (bool cancelled = false);
107 
108  void redisplay_model ();
109 
110  bool key_press (GdkEventKey* ev);
111  bool key_release (GdkEventKey* ev);
112  bool scroll_event (GdkEventScroll*);
113 
114  void delete_selected_note ();
115  void selection_changed ();
116 };
117 
118 #endif /* __ardour_gtk2_midi_list_editor_h_ */
Gtk::TreeModelColumn< std::string > start
void edited(const std::string &, const std::string &)
Gtk::TreeModelColumn< uint8_t > channel
Gtk::TreeModelColumn< uint8_t > velocity
Gtk::TreeModel::Path edit_path
MidiListModelColumns columns
bool key_release(GdkEventKey *ev)
Gtk::TreeModelColumn< boost::shared_ptr< NoteType > > _note
Gtk::TreeModelColumn< uint8_t > note
Definition: amp.h:29
Gtk::TreeView view
Evoral::Note< Evoral::Beats > NoteType
PBD::ScopedConnection content_connection
MidiListEditor(ARDOUR::Session *, boost::shared_ptr< ARDOUR::MidiRegion >, boost::shared_ptr< ARDOUR::MidiTrack >)
Gtk::CellEditable * editing_editable
Gtk::TreeModelColumn< std::string > note_name
Gtk::TreeModelColumn< std::string > length
void stop_editing(bool cancelled=false)
Gtk::TreeModelColumn< int > ticks
Gtk::ToggleButton sound_notes_button
bool key_press(GdkEventKey *ev)
Gtk::Table buttons
boost::shared_ptr< ARDOUR::MidiTrack > track
Gtk::ScrolledWindow scroller
Glib::RefPtr< Gtk::ListStore > model
boost::shared_ptr< ARDOUR::MidiRegion > region
Glib::RefPtr< Gtk::ListStore > note_length_model
void editing_started(Gtk::CellEditable *, const std::string &path, int)
Gtk::TreeModelColumn< std::string > name
NoteLengthColumns note_length_columns
Gtk::CellRendererText * editing_renderer
bool scroll_event(GdkEventScroll *)