Fix thinkos in cubasish theme
[ardour.git] / gtk2_ardour / midi_tracer.h
1 /*
2  * Copyright (C) 2010-2018 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2010 Carl Hetherington <carl@carlh.net>
4  * Copyright (C) 2011 David Robillard <d@drobilla.net>
5  * Copyright (C) 2014-2017 Robin Gareus <robin@gareus.org>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21
22 #ifndef __ardour_gtk_midi_tracer_h__
23 #define __ardour_gtk_midi_tracer_h__
24
25 #include <gtkmm/textview.h>
26 #include <gtkmm/scrolledwindow.h>
27 #include <gtkmm/togglebutton.h>
28 #include <gtkmm/adjustment.h>
29 #include <gtkmm/spinbutton.h>
30 #include <gtkmm/label.h>
31 #include <gtkmm/comboboxtext.h>
32 #include <gtkmm/box.h>
33
34 #include "pbd/signals.h"
35 #include "pbd/ringbuffer.h"
36 #include "pbd/pool.h"
37 #include "midi++/types.h"
38 #include "ardour_window.h"
39
40 namespace MIDI {
41         class Parser;
42 }
43
44 namespace ARDOUR {
45         class MidiPort;
46 }
47
48 class MidiTracer : public ArdourWindow
49 {
50 public:
51         MidiTracer ();
52         ~MidiTracer();
53
54 private:
55         Gtk::TextView text;
56         Gtk::ScrolledWindow scroller;
57         Gtk::Adjustment line_count_adjustment;
58         Gtk::SpinButton line_count_spinner;
59         Gtk::Label line_count_label;
60         Gtk::HBox line_count_box;
61         MIDI::samplecnt_t _last_receipt;
62
63         bool autoscroll;
64         bool show_hex;
65         bool show_delta_time;
66
67         /** Incremented when an update is requested, decremented when one is handled; hence
68          *  equal to 0 when an update is not queued.  May temporarily be negative if a
69          *  update is handled before it was noted that it had just been queued.
70          */
71         volatile gint _update_queued;
72
73         PBD::RingBuffer<char *> fifo;
74         Pool buffer_pool;
75         static const size_t buffer_size = 256;
76
77         void tracer (MIDI::Parser&, MIDI::byte*, size_t, MIDI::samplecnt_t);
78         void update ();
79
80         Gtk::CheckButton autoscroll_button;
81         Gtk::CheckButton base_button;
82         Gtk::CheckButton collect_button;
83         Gtk::CheckButton delta_time_button;
84         Gtk::ComboBoxText _port_combo;
85
86         void base_toggle ();
87         void autoscroll_toggle ();
88         void collect_toggle ();
89         void delta_toggle ();
90
91         void port_changed ();
92         void ports_changed ();
93         void disconnect ();
94         PBD::ScopedConnection _parser_connection;
95         PBD::ScopedConnection _manager_connection;
96         MIDI::Parser my_parser;
97
98         boost::shared_ptr<ARDOUR::MidiPort> traced_port;
99 };
100
101 #endif /* __ardour_gtk_midi_tracer_h__ */