Put plugin inline display into a freely available class ...
[ardour.git] / gtk2_ardour / plugin_display.h
1 /*
2     Copyright (C) 2017 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_plugin_display__
21 #define __ardour_plugin_display__
22
23 #include <gtkmm/drawingarea.h>
24
25 #include "ardour/plugin.h"
26
27 class PluginDisplay : public Gtk::DrawingArea
28 {
29 public:
30         PluginDisplay(boost::shared_ptr<ARDOUR::Plugin>, uint32_t max_height = 80);
31         virtual ~PluginDisplay();
32
33 protected:
34         bool on_expose_event (GdkEventExpose *);
35         void on_size_request (Gtk::Requisition* req);
36         bool on_button_press_event (GdkEventButton *ev);
37         bool on_button_release_event (GdkEventButton *ev);
38
39         void plugin_going_away () {
40                 _qdraw_connection.disconnect ();
41         }
42
43         void update_height_alloc (uint32_t inline_height);
44         virtual uint32_t render_inline (cairo_t *, uint32_t width);
45
46         boost::shared_ptr<ARDOUR::Plugin> _plug;
47         PBD::ScopedConnection _qdraw_connection;
48         PBD::ScopedConnection _death_connection;
49         cairo_surface_t* _surf;
50         uint32_t _max_height;
51         uint32_t _cur_height;
52         bool _scroll;
53 };
54
55 #endif