151 lines
4.1 KiB
C++
151 lines
4.1 KiB
C++
/*
|
|
Copyright 2013 Peter Nelson
|
|
|
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
purpose with or without fee is hereby granted, provided that the above
|
|
copyright notice and this permission notice appear in all copies.
|
|
|
|
THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
*/
|
|
#include <pugl/pugl.h>
|
|
#include "../pui/pui.h"
|
|
#include "../pui/lv2pui.h"
|
|
#include "ptap.h"
|
|
|
|
struct PTapUI : LV2PUi {
|
|
/* virtual */ void InitWidgets();
|
|
};
|
|
|
|
void PTapUI::InitWidgets()
|
|
{
|
|
int width = 250 + 50 * (NUM_TAPS + NUM_CHANNELS + 1);
|
|
int height = 660;
|
|
|
|
char tmp[128];
|
|
|
|
this->scale = 1.0f;
|
|
|
|
widget = new Container();
|
|
widget->back = 1;
|
|
widget->colour = Colour(1, 1, 1, 1);
|
|
widget->w = width;
|
|
widget->h = height;
|
|
|
|
int padding = 4;
|
|
|
|
int cols = 2;
|
|
int rows = (NUM_TAPS + NUM_CHANNELS + cols - 1) / cols;
|
|
|
|
int c_w = (widget->w - padding * cols - padding) / cols;
|
|
int c_h = (widget->h - 25 - padding * rows - padding) / rows;
|
|
|
|
Container *t = new Container();
|
|
t->colour = Colour(0, 0, 0, .5f);
|
|
t->x = 0;
|
|
t->y = 0;
|
|
t->w = widget->w;
|
|
t->h = 25;
|
|
this->widget->Pack(t);
|
|
|
|
for (int i = 0; i < NUM_TAPS + NUM_CHANNELS; i++) {
|
|
Container *c = new VBox();
|
|
if (i < NUM_TAPS) c->frame = Colour(0, 0, 0, .15f);
|
|
c->x = (i & 1) * (c_w + padding) + padding;
|
|
c->y = (i >> 1) * (c_h + padding) + padding + 25;
|
|
c->w = c_w;
|
|
c->h = c_h;
|
|
c->padding = padding;
|
|
|
|
Container *c1 = new Container();
|
|
c1->h = 16;
|
|
c->Pack(c1);
|
|
|
|
Container *c_strip = new HBox();
|
|
c_strip->h = -1;
|
|
c_strip->padding = padding;
|
|
c->Pack(c_strip);
|
|
|
|
Container *c_taps = new HBox();
|
|
if (i >= NUM_TAPS) c_taps->colour = Colour(1, 1, 1, 0.15f);
|
|
c_strip->Pack(c_taps);
|
|
|
|
if (i < NUM_TAPS) {
|
|
snprintf(tmp, sizeof tmp, "Tap %d", i + 1);
|
|
} else {
|
|
strncpy(tmp, i == NUM_TAPS ? "Left Out" : "Right Out", sizeof tmp);
|
|
}
|
|
|
|
for (int j = 0; j < NUM_TAPS; j++) {
|
|
Slider *slider = new VSlider();
|
|
strncpy(slider->group, tmp, sizeof slider->group);
|
|
snprintf(slider->label, sizeof slider->label, "%d", j + 1);
|
|
if (i == j) {
|
|
slider->colour = Colour(.5f, .7f, 1, 1);
|
|
} else {
|
|
slider->colour = Colour(.6f, .6f, .6f, 1);
|
|
}
|
|
slider->min = -1.f;
|
|
slider->max = 1.f;
|
|
slider->port = TAP_MATRIX + i * NUM_GAINS + j;
|
|
c_taps->Pack(slider);
|
|
}
|
|
|
|
Container *c_ins = new HBox();
|
|
if (i >= NUM_TAPS) c_ins->colour = Colour(1, 1, 1, 0.15f);
|
|
c_strip->Pack(c_ins);
|
|
|
|
for (int j = 0; j < NUM_CHANNELS; j++) {
|
|
Slider *slider = new VSlider();
|
|
strncpy(slider->group, tmp, sizeof slider->group);
|
|
strncpy(slider->label, j == 0 ? "Left" : "Right", sizeof slider->label);
|
|
slider->min = -1.f;
|
|
slider->max = 1.f;
|
|
slider->port = TAP_MATRIX + i * NUM_GAINS + NUM_TAPS + j;
|
|
c_ins->Pack(slider);
|
|
}
|
|
|
|
Slider *gain = new VSlider(i >= NUM_TAPS);
|
|
strncpy(gain->group, tmp, sizeof gain->group);
|
|
strncpy(gain->label, "Gain", sizeof gain->label);
|
|
gain->colour = Colour(1, .2f, .2f, 1);
|
|
gain->min = -1.f;
|
|
gain->max = 1.f;
|
|
gain->port = TAP_GAINS + i;
|
|
c_strip->Pack(gain);
|
|
|
|
if (i < NUM_TAPS) {
|
|
Knob *delay = new Knob();
|
|
strncpy(delay->group, tmp, sizeof delay->group);
|
|
strncpy(delay->label, "Delay", sizeof delay->label);
|
|
delay->w = -1;
|
|
delay->min = 0.f;
|
|
delay->max = 10.f;
|
|
delay->port = TAP_DELAYS + i;
|
|
c_strip->Pack(delay);
|
|
}
|
|
|
|
this->widget->Pack(c);
|
|
}
|
|
|
|
tooltip = new Label();
|
|
tooltip->x = widget->w * 0.5f;
|
|
tooltip->y = 10;
|
|
tooltip->colour = Colour(1, 1, 1, 1);
|
|
tooltip->SetLabel("INIT");
|
|
this->widget->Pack(tooltip);
|
|
}
|
|
|
|
struct FLV2PUi_PTapUI : LV2PUiFactory<FLV2PUi_PTapUI> {
|
|
/* virtual */ const char *GetUri() { return PTAP_URI; }
|
|
|
|
/* virtual */ LV2PUi *CreateInstance() { return new PTapUI(); }
|
|
};
|
|
|
|
static FLV2PUi_PTapUI iFLV2PUi_PTapUI;
|