a-EQ: Transfer function curves improvement
[ardour.git] / libs / plugins / a-comp.lv2 / ui.cc
1 /* a-comp UI -- test/example
2  *
3  * Copyright (C) 2016 Robin Gareus <robin@gareus.org>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2, or (at your option)
8  * any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18
19 #define ACOMP_URI "urn:ardour:a-comp"
20
21 #include <stdlib.h>
22
23 #include <gtkmm.h>
24
25 #include "lv2/lv2plug.in/ns/extensions/ui/ui.h"
26
27 using namespace Gtk;
28
29 typedef struct {
30         LV2UI_Write_Function write;
31         LV2UI_Controller     controller;
32
33         Box* box;
34         Label*  label;
35 } ACompUI;
36
37
38 /******************************************************************************
39  * GUI
40  */
41
42 static void* setup_ui (ACompUI* ui) {
43         ui->box = manage (new HBox);
44
45         ui->label = manage (new Label ("Hello World"));
46         ui->box->pack_start (*ui->label, false, false, 4);
47
48         return ui->box->gobj ();
49 }
50
51
52 /******************************************************************************
53  * LV2 callbacks
54  */
55
56 static LV2UI_Handle
57 instantiate (const LV2UI_Descriptor*   descriptor,
58              const char*               plugin_uri,
59              const char*               bundle_path,
60              LV2UI_Write_Function      write_function,
61              LV2UI_Controller          controller,
62              LV2UI_Widget*             widget,
63              const LV2_Feature* const* features)
64 {
65         ACompUI* ui = (ACompUI*)calloc (1, sizeof (ACompUI));
66         ui->write      = write_function;
67         ui->controller = controller;
68         ui->box        = NULL;
69
70         *widget = setup_ui (ui);
71         return ui;
72 }
73
74 static void
75 cleanup (LV2UI_Handle handle)
76 {
77         ACompUI* ui = (ACompUI*)handle;
78         free (ui);
79 }
80
81 static void
82 port_event (LV2UI_Handle handle,
83             uint32_t     port_index,
84             uint32_t     buffer_size,
85             uint32_t     format,
86             const void*  buffer)
87 {
88         ACompUI* ui = (ACompUI*)handle;
89 }
90
91 /******************************************************************************
92  * LV2 setup
93  */
94
95 static const void*
96 extension_data (const char* uri)
97 {
98         return NULL;
99 }
100
101 static const LV2UI_Descriptor descriptor = {
102         ACOMP_URI "#ui",
103         instantiate,
104         cleanup,
105         port_event,
106         extension_data
107 };
108
109 LV2_SYMBOL_EXPORT
110 const LV2UI_Descriptor*
111 lv2ui_descriptor (uint32_t index)
112 {
113         switch (index) {
114         case 0:
115                 return &descriptor;
116         default:
117                 return NULL;
118         }
119 }