remove cruft
[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         Gtk::TextView text;
50         Gtk::ScrolledWindow scroller;
51         Gtk::Adjustment line_count_adjustment;
52         Gtk::SpinButton line_count_spinner;
53         Gtk::Label line_count_label;
54         Gtk::HBox line_count_box;
55         struct timeval _last_receipt;
56         
57         bool autoscroll;
58         bool show_hex;
59         bool show_delta_time;
60
61         /** Incremented when an update is requested, decremented when one is handled; hence
62          *  equal to 0 when an update is not queued.  May temporarily be negative if a
63          *  update is handled before it was noted that it had just been queued.
64          */
65         volatile gint _update_queued;
66
67         RingBuffer<char *> fifo;
68         Pool buffer_pool;
69         static const size_t buffer_size = 256;
70
71         void tracer (MIDI::Parser&, MIDI::byte*, size_t);
72         void update ();
73
74         Gtk::CheckButton autoscroll_button;
75         Gtk::CheckButton base_button;
76         Gtk::CheckButton collect_button;
77         Gtk::CheckButton delta_time_button;
78         Gtk::ComboBoxText _port_combo;
79
80         void base_toggle ();
81         void autoscroll_toggle ();
82         void collect_toggle ();
83         void delta_toggle ();
84
85         void port_changed ();
86         void ports_changed ();
87         void disconnect ();
88         PBD::ScopedConnection _parser_connection;
89         PBD::ScopedConnection _manager_connection;
90 };
91
92 #endif /* __ardour_gtk_midi_tracer_h__ */