Major UI progress
This commit is contained in:
@@ -6,7 +6,7 @@ LDFLAGS += `pkg-config lv2core pugl-0 --libs`
|
||||
|
||||
PTAPSRC := ptap.cpp
|
||||
PTAPSRC += ptapui.cpp
|
||||
PTAPOBJ := $(PTAPSRC:.cpp=.o)
|
||||
PTAPOBJ := $(PTAPSRC:.cpp=.o) ../pui/*.o
|
||||
PTAPO := ptap.so
|
||||
|
||||
CPP := g++
|
||||
@@ -20,7 +20,7 @@ depend:
|
||||
makedepend $(PTAPSRC)
|
||||
|
||||
$(PTAPO): $(PTAPOBJ)
|
||||
$(CC) $(LDFLAGS) -shared -fPIC -Wl,-soname,$(PTAPO) $(PTAPOBJ) -o $@
|
||||
$(CPP) $(LDFLAGS) -shared -fPIC -Wl,-soname,$(PTAPO) $(PTAPOBJ) -o $@
|
||||
|
||||
.cpp.o:
|
||||
$(CPP) -c -fPIC $(CFLAGS) $< -o $@
|
||||
|
212
ptap/ptapui.cpp
212
ptap/ptapui.cpp
@@ -9,8 +9,12 @@
|
||||
#include <lv2.h>
|
||||
#include <lv2/lv2plug.in/ns/extensions/ui/ui.h>
|
||||
#include <pugl/pugl.h>
|
||||
#include <limits.h>
|
||||
#include "../pui/pui.h"
|
||||
|
||||
struct PTapUI {
|
||||
#define TAPS 6
|
||||
|
||||
/*struct PTapUI : PTextures {
|
||||
PuglView *view;
|
||||
pthread_t thread;
|
||||
LV2UI_Write_Function write;
|
||||
@@ -18,8 +22,143 @@ struct PTapUI {
|
||||
int width;
|
||||
int height;
|
||||
bool exit;
|
||||
|
||||
int mx;
|
||||
int my;
|
||||
int mb;
|
||||
int mm;
|
||||
Widget *active;
|
||||
|
||||
Container *widget;
|
||||
|
||||
void InitWidgets();
|
||||
};*/
|
||||
|
||||
struct PTapUI : PUi {
|
||||
pthread_t thread;
|
||||
LV2UI_Write_Function write;
|
||||
LV2UI_Controller controller;
|
||||
int width;
|
||||
int height;
|
||||
bool exit;
|
||||
|
||||
virtual ~PTapUI() {}
|
||||
|
||||
void InitWidgets();
|
||||
|
||||
/* virtual */ void ParameterChanged(const Widget *w);
|
||||
};
|
||||
|
||||
void PTapUI::InitWidgets()
|
||||
{
|
||||
widget = new Container();
|
||||
widget->colour = Colour(0.6, 0.6, 0.6, 1.0);
|
||||
widget->w = this->width;
|
||||
widget->h = this->height;
|
||||
|
||||
int padding = 3;
|
||||
|
||||
int c_w = (this->width * 0.5f);
|
||||
int c_h = (this->height * 0.25f);
|
||||
|
||||
int slide_w = 25 + padding;
|
||||
int slide_h = c_h - padding - padding;
|
||||
|
||||
for (int i = 0; i < TAPS + 2; i++) {
|
||||
Container *c = new Container();
|
||||
c->x = (i & 1) * c_w;
|
||||
c->y = (i >> 1) * c_h;
|
||||
c->w = c_w;
|
||||
c->h = c_h;
|
||||
|
||||
Container *c2 = new Container();
|
||||
c2->x = c->x;
|
||||
c2->y = c->y;
|
||||
c2->w = slide_w * TAPS + padding * 2;
|
||||
c2->h = c->h;
|
||||
c2->Pad(padding, padding);
|
||||
|
||||
Container *c3 = new Container();
|
||||
c3->colour = Colour(0, 0, 0, 0.2f);
|
||||
c3->x = c2->x + c2->w;
|
||||
c3->y = c->y;
|
||||
c3->w = slide_w * 2 + padding * 2;
|
||||
c3->h = c->h;
|
||||
c3->Pad(padding, padding);
|
||||
|
||||
Container *c4 = new Container();
|
||||
c4->x = c3->x + c3->w;
|
||||
c4->y = c->y;
|
||||
c4->w = c->w - (c4->x - c->x) + padding * 2;
|
||||
c4->h = c->h;
|
||||
c4->Pad(padding, padding);
|
||||
|
||||
for (int j = 0; j < TAPS; j++) {
|
||||
Slider *slider = new VSlider();
|
||||
slider->tex = this;
|
||||
slider->big = false;
|
||||
slider->x = c2->x + j * slide_w;//(j & 1) * slide_w;
|
||||
slider->y = c2->y + 10;// + (j >> 1) * slide_h;
|
||||
slider->w = slide_w;
|
||||
slider->h = slide_h - 10;
|
||||
slider->min = -1.f;
|
||||
slider->max = 1.f;
|
||||
slider->port = (i * 10) + 4 + j;
|
||||
slider->Pad(padding, padding);
|
||||
c2->children.push_back(slider);
|
||||
}
|
||||
|
||||
for (int j = 0; j < 2; j++) {
|
||||
Slider *slider = new VSlider();
|
||||
slider->tex = this;
|
||||
slider->big = false;
|
||||
slider->x = c3->x + j * slide_w;//(j & 1) * slide_w;
|
||||
slider->y = c3->y + 10;// + (j >> 1) * slide_h;
|
||||
slider->w = slide_w;
|
||||
slider->h = slide_h - 10;
|
||||
slider->min = -1.f;
|
||||
slider->max = 1.f;
|
||||
slider->port = (i * 10) + 4 + TAPS + j;
|
||||
slider->Pad(padding, padding);
|
||||
c3->children.push_back(slider);
|
||||
}
|
||||
|
||||
for (int j = 0; j < 1; j++) {
|
||||
Slider *slider = new VSlider();
|
||||
slider->tex = this;
|
||||
slider->big = true;
|
||||
slider->x = c4->x + j * slide_w;//(j & 1) * slide_w;
|
||||
slider->y = c4->y + 10;// + (j >> 1) * slide_h;
|
||||
slider->w = slide_w;
|
||||
slider->h = slide_h - 10;
|
||||
slider->min = -1.f;
|
||||
slider->max = 1.f;
|
||||
slider->port = (i * 10) + 4 + TAPS + 2 + j;
|
||||
slider->Pad(padding, padding);
|
||||
c4->children.push_back(slider);
|
||||
}
|
||||
|
||||
if (i < TAPS) {
|
||||
Knob *k = new Knob();
|
||||
k->tex = this;
|
||||
k->x = c->x + (TAPS + 3) * slide_w;
|
||||
k->y = c->y + 10;
|
||||
k->w = c->w - (k->x - c->x);
|
||||
k->h = c->h - 10;
|
||||
k->min = 0.f;
|
||||
k->max = 10.f;
|
||||
k->port = (i * 10) + 4 + 9;
|
||||
k->Pad(padding, padding);
|
||||
c4->children.push_back(k);
|
||||
}
|
||||
|
||||
c->children.push_back(c2);
|
||||
c->children.push_back(c3);
|
||||
c->children.push_back(c4);
|
||||
this->widget->children.push_back(c);
|
||||
}
|
||||
}
|
||||
|
||||
static void *ui_thread(void *ptr)
|
||||
{
|
||||
PTapUI *pui = (PTapUI *)ptr;
|
||||
@@ -30,56 +169,11 @@ static void *ui_thread(void *ptr)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void parameterChanged(PTapUI *pui, uint32_t index, float value)
|
||||
void PTapUI::ParameterChanged(const Widget *w)
|
||||
{
|
||||
pui->write(pui->controller, index, sizeof value, 0, &value);
|
||||
}
|
||||
if (w->port == UINT_MAX) return;
|
||||
|
||||
static void onReshape(PuglView *view, int width, int height)
|
||||
{
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glViewport(0, 0, width, height);
|
||||
glOrtho(0, width, height, 0, 0, 1);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glLoadIdentity();
|
||||
}
|
||||
|
||||
static void onDisplay(PuglView *view)
|
||||
{
|
||||
PTapUI *pui = (PTapUI *)puglGetHandle(view);
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
GLdouble x2 = 2.0;
|
||||
GLdouble y2 = 2.0;
|
||||
GLdouble x1 = pui->width - 2.0;
|
||||
GLdouble y1 = pui->height - 2.0;
|
||||
glColor3f(1.0f, 0.2f, 0.0f);
|
||||
glVertex2f(x1, y1);
|
||||
glVertex2f(x1, y2);
|
||||
glColor3f(0.0f, 1.0f, 0.0f);
|
||||
glVertex2f(x2, x2);
|
||||
glVertex2f(x2, y1);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
static void onKeyboard(PuglView *view, bool press, uint32_t key)
|
||||
{
|
||||
}
|
||||
|
||||
static void onMotion(PuglView *view, int x, int y)
|
||||
{
|
||||
}
|
||||
|
||||
static void onMouse(PuglView *view, int button, bool press, int x, int y)
|
||||
{
|
||||
}
|
||||
|
||||
static void onScroll(PuglView *view, float dx, float dy)
|
||||
{
|
||||
this->write(this->controller, w->port, sizeof w->value, 0, &w->value);
|
||||
}
|
||||
|
||||
static LV2UI_Handle ptapui_instantiate(
|
||||
@@ -109,18 +203,16 @@ static LV2UI_Handle ptapui_instantiate(
|
||||
PTapUI *pui = new PTapUI();
|
||||
pui->write = write_function;
|
||||
pui->controller = controller;
|
||||
pui->width = 320;
|
||||
pui->height = 240;
|
||||
pui->width = 750;
|
||||
pui->height = 500;
|
||||
pui->exit = false;
|
||||
|
||||
pui->InitWidgets();
|
||||
|
||||
pui->view = puglCreate(parent, "PTap", pui->width, pui->height, true);
|
||||
puglSetHandle(pui->view, pui);
|
||||
puglSetDisplayFunc(pui->view, onDisplay);
|
||||
puglSetReshapeFunc(pui->view, onReshape);
|
||||
puglSetKeyboardFunc(pui->view, onKeyboard);
|
||||
puglSetMotionFunc(pui->view, onMotion);
|
||||
puglSetMouseFunc(pui->view, onMouse);
|
||||
puglSetScrollFunc(pui->view, onScroll);
|
||||
|
||||
pui->SetFunc();
|
||||
|
||||
if (resize) {
|
||||
resize->ui_resize(resize->handle, pui->width, pui->height);
|
||||
@@ -148,6 +240,12 @@ static void ptapui_port_event(
|
||||
uint32_t format,
|
||||
const void *buffer)
|
||||
{
|
||||
PUi *pui = (PUi *)ui;
|
||||
Widget *w = pui->widget->GetWidget(port_index);
|
||||
if (!w) return;
|
||||
|
||||
w->SetValue(*((float *)buffer));
|
||||
pui->Repaint();
|
||||
}
|
||||
|
||||
static const void *ptapui_extension_data(const char *uri)
|
||||
|
Reference in New Issue
Block a user