summaryrefslogtreecommitdiff
path: root/src/gd_pluginWindow.cpp
blob: f9119c0edd694520ff1c3a7e20026ace00b93956 (plain)
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
/* ---------------------------------------------------------------------
 *
 * Giada - Your Hardcore Loopmachine
 *
 * gd_pluginWindow
 *
 * ---------------------------------------------------------------------
 *
 * Copyright (C) 2010-2015 Giovanni A. Zuliani | Monocasual
 *
 * This file is part of Giada - Your Hardcore Loopmachine.
 *
 * Giada - Your Hardcore Loopmachine 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 3 of the License, or (at your option) any later version.
 *
 * Giada - Your Hardcore Loopmachine 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 Giada - Your Hardcore Loopmachine. If not, see
 * <http://www.gnu.org/licenses/>.
 *
 * ------------------------------------------------------------------ */


#ifdef WITH_VST

#include <FL/Fl_Scroll.H>
#include "gd_pluginWindow.h"
#include "pluginHost.h"
#include "ge_mixed.h"
#include "gui_utils.h"


extern PluginHost G_PluginHost;


Parameter::Parameter(int id, Plugin *p, int X, int Y, int W)
	: Fl_Group(X,Y,W-24,20), id(id), pPlugin(p)
{
	begin();

		label = new gBox(x(), y(), 60, 20);
		char name[kVstMaxParamStrLen];
		pPlugin->getParamName(id, name);
		label->copy_label(name);
		label->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);

		slider = new gSlider(label->x()+label->w()+8, y(), W-200, 20);
		slider->value(pPlugin->getParam(id));
		slider->callback(cb_setValue, (void *)this);

		value = new gBox(slider->x()+slider->w()+8, y(), 100, 20);
		char disp[kVstMaxParamStrLen];
		char labl[kVstMaxParamStrLen];
		char str [256];
		pPlugin->getParamDisplay(id, disp);
		pPlugin->getParamLabel(id, labl);
		sprintf(str, "%s %s", disp, labl);
		value->copy_label(str);
		value->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
		value->box(G_BOX);

		resizable(slider);

	end();
}


/* ------------------------------------------------------------------ */


void Parameter::cb_setValue(Fl_Widget *v, void *p)  { ((Parameter*)p)->__cb_setValue(); }


/* ------------------------------------------------------------------ */


void Parameter::__cb_setValue() {

	pPlugin->setParam(id, slider->value());

	char disp[256];
	char labl[256];
	char str [256];

	pPlugin->getParamDisplay(id, disp);
	pPlugin->getParamLabel(id, labl);
	sprintf(str, "%s %s", disp, labl);

	value->copy_label(str);
	value->redraw();
}


/* ------------------------------------------------------------------ */


gdPluginWindow::gdPluginWindow(Plugin *pPlugin)
 : gWindow(400, 156), pPlugin(pPlugin) // 350
{
	set_non_modal();

	gLiquidScroll *list = new gLiquidScroll(8, 8, w()-16, h()-16);
	list->type(Fl_Scroll::VERTICAL_ALWAYS);
	list->begin();

	int numParams = pPlugin->getNumParams();
	for (int i=0; i<numParams; i++)
		new Parameter(i, pPlugin, list->x(), list->y()+(i*24), list->w());
	list->end();

	end();

	char name[256];
	pPlugin->getProduct(name);
	if (strcmp(name, " ")==0)
		pPlugin->getName(name);
	label(name);

	size_range(400, (24*1)+12);
	resizable(list);

	gu_setFavicon(this);
	show();

}


gdPluginWindow::~gdPluginWindow() {}


#endif // #ifdef WITH_VST