[55026d]: / trunk / src / LV2 / gx_room_simulator.lv2 / gx_room_simulator_gui.cpp  Maximize  Restore  History

Download this file

217 lines (192 with data), 6.5 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
/*
* Copyright (C) 2012 Hermann Meyer, Andreas Degert, Pete Shorthose, Steve Poskitt
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* --------------------------------------------------------------------------
*/
#include <string>
#include <iostream>
#include <gtkmm.h>
#include "gx_room_simulator.h"
#include "widget.h"
#include <lv2.h>
#include <lv2/lv2plug.in/ns/extensions/ui/ui.h>
using namespace std;
class GxRoomSimulator
{
private:
Glib::ustring plugskin;
Glib::ustring addKnob;
Glib::ustring plug_name;
void set_knob(Glib::ustring knob);
void set_skin();
void set_plug_name(const char * plugin_uri);
GtkWidget* make_gui();
public:
Widget* widget;
static void set_plug_name_static(GxRoomSimulator *self, const char * plugin_uri)
{
self->set_plug_name(plugin_uri);
}
static GtkWidget* make_gui_static(GxRoomSimulator *self)
{
return self->make_gui();
}
GxRoomSimulator () {};
~GxRoomSimulator () {};
} ;
void GxRoomSimulator::set_knob( Glib::ustring knob)
{
addKnob = " style 'gx_";
addKnob += plug_name;
addKnob += "_dark_skin_icons'\n"
" { \n"
" stock['bigknob'] = {{'";
addKnob += knob;
addKnob += ".png'}}\n";
addKnob += " stock['button_on'] = {{'"
"sw_on.png'}}\n"
" stock['button_off'] = {{'"
"sw_off.png'}}\n"
" }\n"
"widget '*.";
addKnob += plug_name;
addKnob += "' style 'gx_";
addKnob += plug_name;
addKnob += "_dark_skin_icons' \n"
"class '*GxToggleImage' style'gx_";
addKnob += plug_name;
addKnob += "_dark_skin_icons' \n";
}
void GxRoomSimulator::set_skin()
{
Glib::ustring toparse = "pixmap_path ";
toparse += " '";
toparse += GX_LV2_STYLE_DIR;
toparse += "/'\n";
toparse += "style \"gx_";
toparse += plug_name;
toparse += "_dark-paintbox\"\n"
" { \n"
"GxPaintBox::skin-gradient = {\n"
"{ 65536, 0, 0, 13107, 52428 }, \n"
"{ 52428, 0, 0, 0, 52428 },\n"
"{ 13107, 0, 0, 13107, 13107 }}\n"
" GxPaintBox::icon-set =4\n"
" stock['amp_skin'] = {{'";
toparse += plugskin;
toparse += "'}}\n"
" }\n"
"\n"
"style 'gx_headechocat_box' \n"
" { \n"
" fg[NORMAL] = {0,0,0} \n"
"font_name = 'sans 10' \n"
" }\n";
toparse += addKnob;
toparse += " widget '*.amplabel' style:highest 'gx_headechocat_box'\n"
"widget '*.";
toparse += plug_name;
toparse += "' style 'gx_";
toparse += plug_name;
toparse += "_dark-paintbox' ";
toparse += "style 'gx_switch'\n"
"{\n"
"xthickness = 0\n"
"ythickness = 0\n"
"GtkButton::inner-border = {0, 0, 0, 0}\n"
"GtkButton::default-border = {0, 0, 0, 0}\n"
"GtkButton::focus-line-width = 0\n"
"GtkButton::focus-padding = 0\n"
"GtkButton::interior-focus = 0\n"
"GtkButton::child-displacement-x = 0\n"
"GtkButton::child-displacement-y = 0\n"
" }\n"
"widget '*.";
toparse += plug_name;
toparse += "' style:highest 'gx_switch'";
gtk_rc_parse_string (toparse.c_str());
}
void GxRoomSimulator::set_plug_name( const char * plugin_uri)
{
addKnob = "";
if (strcmp("http://guitarix.sourceforge.net/plugins/gx_room_simulator_#_room_simulator_", plugin_uri) == 0)
{
plugskin = "vertical_pedal_white.png";
plug_name = "room_simulator";
set_knob("tactile_knob_large_151f");
}
else
{
plugskin = "vertical_pedal_white.png";
plug_name = "room_simulator";
}
}
GtkWidget* GxRoomSimulator::make_gui()
{
// init the gxwmm library
Gxw::init();
set_skin();
GtkWidget* container = gtk_vbox_new(FALSE, 0);
widget = new Widget(plug_name);
GtkWidget* cWidget = GTK_WIDGET(widget->gobj());
gtk_container_add(GTK_CONTAINER(container), cWidget );
return container;
}
static LV2UI_Handle instantiate(const struct _LV2UI_Descriptor * descriptor,
const char * plugin_uri,
const char * bundle_path,
LV2UI_Write_Function write_function,
LV2UI_Controller controller,
LV2UI_Widget * widget,
const LV2_Feature * const * features)
{
GxRoomSimulator* self = new GxRoomSimulator();
if (self == NULL) return NULL;
self->set_plug_name_static(self, plugin_uri);
*widget = (LV2UI_Widget)self->make_gui_static(self);
self->widget->controller = controller;
self->widget->write_function = write_function;
return (LV2UI_Handle)self;
}
static void cleanup(LV2UI_Handle ui)
{
GxRoomSimulator *pluginGui = static_cast<GxRoomSimulator*>(ui);
delete pluginGui->widget;
delete pluginGui;
}
static void port_event(LV2UI_Handle ui,
uint32_t port_index,
uint32_t buffer_size,
uint32_t format,
const void * buffer)
{
GxRoomSimulator *self = static_cast<GxRoomSimulator*>(ui);
self->widget->set_value_static( port_index, buffer_size, format, buffer, self->widget);
return;
}
static LV2UI_Descriptor descriptors[] =
{
{GXPLUGIN_UI_URI, instantiate, cleanup, port_event, NULL}
};
const LV2UI_Descriptor * lv2ui_descriptor(uint32_t index)
{
//printf("lv2ui_descriptor(%u) called\n", (uint32_t)index);
if (index >= sizeof(descriptors) / sizeof(descriptors[0]))
{
return NULL;
}
return descriptors + index;
}