add copyright comments
[ardour.git] / gtk2_ardour / midi_tracer.h
1 /*
2     Copyright (C) 2012 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_gtk_midi_tracer_h__
21 #define __ardour_gtk_midi_tracer_h__
22
23 #include <gtkmm/textview.h>
24 #include <gtkmm/scrolledwindow.h>
25 #include <gtkmm/togglebutton.h>
26 #include <gtkmm/adjustment.h>
27 #include <gtkmm/spinbutton.h>
28 #include <gtkmm/label.h>
29 #include <gtkmm/comboboxtext.h>
30 #include <gtkmm/box.h>
31
32 #include "pbd/signals.h"
33 #include "pbd/ringbuffer.h"
34 #include "pbd/pool.h"
35 #include "midi++/types.h"
36 #include "ardour_window.h"
37
38 namespace MIDI {
39         class Parser;
40 }
41
42 class MidiTracer : public ArdourWindow
43 {
44   public:
45         MidiTracer ();
46         ~MidiTracer();
47
48   private:
49         MIDI::Parser* parser;
50         Gtk::TextView text;
51         Gtk::ScrolledWindow scroller;
52         Gtk::Adjustment line_count_adjustment;
53         Gtk::SpinButton line_count_spinner;
54         Gtk::Label line_count_label;
55         Gtk::HBox line_count_box;
56         struct timeval _last_receipt;
57         
58         bool autoscroll;
59         bool show_hex;
60         bool collect;
61         bool show_delta_time;
62
63         /** Incremented when an update is requested, decremented when one is handled; hence
64          *  equal to 0 when an update is not queued.  May temporarily be negative if a
65          *  update is handled before it was noted that it had just been queued.
66          */
67         volatile gint _update_queued;
68
69         RingBuffer<char *> fifo;
70         Pool buffer_pool;
71         static const size_t buffer_size = 256;
72
73         void tracer (MIDI::Parser&, MIDI::byte*, size_t);
74         void update ();
75
76         Gtk::CheckButton autoscroll_button;
77         Gtk::CheckButton base_button;
78         Gtk::CheckButton collect_button;
79         Gtk::CheckButton delta_time_button;
80         Gtk::ComboBoxText _port_combo;
81
82         void base_toggle ();
83         void autoscroll_toggle ();
84         void collect_toggle ();
85         void delta_toggle ();
86
87         void port_changed ();
88         void ports_changed ();
89         void disconnect ();
90         PBD::ScopedConnection _parser_connection;
91         PBD::ScopedConnection _manager_connection;
92 };
93
94 #endif /* __ardour_gtk_midi_tracer_h__ */