2009-12-25 01:59:39 +01:00
|
|
|
|
|
|
|
|
|
/*******************************************************************************/
|
|
|
|
|
/* Copyright (C) 2009 Jonathan Moore Liles */
|
|
|
|
|
/* */
|
|
|
|
|
/* 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; see the file COPYING. If not,write to the Free Software */
|
|
|
|
|
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
|
|
|
|
/*******************************************************************************/
|
|
|
|
|
|
2012-04-27 19:14:53 +02:00
|
|
|
|
#include <FL/Fl.H>
|
|
|
|
|
|
2010-01-25 03:12:10 +01:00
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <math.h>
|
|
|
|
|
|
2009-12-25 01:59:39 +01:00
|
|
|
|
#include <FL/fl_draw.H>
|
|
|
|
|
#include <FL/Fl_Pack.H>
|
|
|
|
|
#include <FL/Fl_Box.H>
|
2010-01-25 03:12:10 +01:00
|
|
|
|
#include <FL/Fl_Menu_Button.H>
|
2009-12-25 01:59:39 +01:00
|
|
|
|
#include <FL/Fl_Counter.H>
|
|
|
|
|
#include "FL/Fl_Flowpack.H"
|
|
|
|
|
#include "FL/Fl_Labelpad_Group.H"
|
2010-01-25 03:12:10 +01:00
|
|
|
|
#include "FL/Fl_Value_SliderX.H"
|
2013-05-29 07:11:07 +02:00
|
|
|
|
#include "FL/Fl_DialX.H"
|
2013-09-08 01:58:16 +02:00
|
|
|
|
#include <FL/Fl_Scroll.H>
|
2009-12-25 01:59:39 +01:00
|
|
|
|
#include "Module.H"
|
|
|
|
|
#include "Module_Parameter_Editor.H"
|
|
|
|
|
#include "Controller_Module.H"
|
|
|
|
|
#include "Chain.H"
|
2010-02-12 11:22:53 +01:00
|
|
|
|
#include "Panner.H"
|
2013-09-15 06:05:41 +02:00
|
|
|
|
#include <FL/fl_ask.H>
|
2010-02-01 07:25:16 +01:00
|
|
|
|
#include "debug.h"
|
2013-09-15 06:05:41 +02:00
|
|
|
|
#include <FL/Fl_Menu_Button.H>
|
2009-12-25 01:59:39 +01:00
|
|
|
|
|
2013-09-15 06:05:41 +02:00
|
|
|
|
#include "FL/test_press.H"
|
|
|
|
|
#include "FL/menu_popup.H"
|
2009-12-25 01:59:39 +01:00
|
|
|
|
|
|
|
|
|
|
2013-09-15 06:05:41 +02:00
|
|
|
|
Module_Parameter_Editor::Module_Parameter_Editor ( Module *module ) : Fl_Double_Window( 900,240)
|
2009-12-25 01:59:39 +01:00
|
|
|
|
{
|
|
|
|
|
_module = module;
|
|
|
|
|
_resized = false;
|
2012-03-03 22:21:18 +01:00
|
|
|
|
_min_width = 100;
|
2009-12-25 01:59:39 +01:00
|
|
|
|
|
|
|
|
|
char lab[256];
|
|
|
|
|
if ( strcmp( module->name(), module->label() ) )
|
|
|
|
|
{
|
|
|
|
|
snprintf( lab, sizeof( lab ), "%s : %s", module->name(), module->label() );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
strcpy( lab, module->label() );
|
|
|
|
|
|
|
|
|
|
char title[512];
|
|
|
|
|
snprintf( title, sizeof( title ), "%s - %s - %s", "Mixer", module->chain()->name(), lab );
|
|
|
|
|
|
2010-02-25 01:40:34 +01:00
|
|
|
|
copy_label( title );
|
2009-12-25 01:59:39 +01:00
|
|
|
|
|
2013-09-08 01:58:16 +02:00
|
|
|
|
// fl_font( FL_HELVETICA, 14 );
|
2012-03-03 22:21:18 +01:00
|
|
|
|
|
|
|
|
|
_min_width = 30 + fl_width( module->label() );
|
2013-09-08 01:58:16 +02:00
|
|
|
|
|
|
|
|
|
{ Fl_Group *o = new Fl_Group( 0, 0, w(), 25 );
|
2012-03-03 22:21:18 +01:00
|
|
|
|
o->label( module->label() );
|
|
|
|
|
o->labelfont( 2 );
|
|
|
|
|
o->labeltype( FL_SHADOW_LABEL );
|
|
|
|
|
o->labelsize( 14 );
|
|
|
|
|
o->align( FL_ALIGN_TOP | FL_ALIGN_RIGHT | FL_ALIGN_INSIDE );
|
2010-01-14 06:01:15 +01:00
|
|
|
|
|
2013-09-08 01:58:16 +02:00
|
|
|
|
{ Fl_Menu_Button *o = mode_choice = new Fl_Menu_Button( 0, 0, 25, 25 );
|
|
|
|
|
o->add( "Knobs" );
|
|
|
|
|
o->add( "Horizontal Sliders" );
|
|
|
|
|
o->add( "Vertical Sliders" );
|
|
|
|
|
o->label( NULL );
|
2013-09-15 06:05:41 +02:00
|
|
|
|
o->value( 1 );
|
2013-09-08 01:58:16 +02:00
|
|
|
|
o->when( FL_WHEN_CHANGED );
|
|
|
|
|
o->callback( cb_mode_handle, this );
|
2009-12-25 01:59:39 +01:00
|
|
|
|
}
|
2013-09-08 01:58:16 +02:00
|
|
|
|
o->resizable(0);
|
|
|
|
|
o->end();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{ Fl_Scroll *o = control_scroll = new Fl_Scroll( 0, 40, w(), h() - 40 );
|
|
|
|
|
{ Fl_Group *o = new Fl_Group( 0, 40, w(), h() - 40 );
|
|
|
|
|
{ Fl_Flowpack *o = control_pack = new Fl_Flowpack( 50, 40, w() - 100, h() - 40 );
|
2013-09-02 20:35:32 +02:00
|
|
|
|
o->type( FL_HORIZONTAL );
|
|
|
|
|
o->flow( true );
|
2013-09-08 01:58:16 +02:00
|
|
|
|
o->vspacing( 5 );
|
|
|
|
|
o->hspacing( 5 );
|
2009-12-25 01:59:39 +01:00
|
|
|
|
o->end();
|
|
|
|
|
}
|
|
|
|
|
o->resizable( 0 );
|
|
|
|
|
o->end();
|
|
|
|
|
}
|
|
|
|
|
o->end();
|
|
|
|
|
}
|
2013-09-08 01:58:16 +02:00
|
|
|
|
resizable(control_scroll);
|
2009-12-25 01:59:39 +01:00
|
|
|
|
|
|
|
|
|
end();
|
|
|
|
|
|
|
|
|
|
make_controls();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Module_Parameter_Editor::~Module_Parameter_Editor ( )
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Module_Parameter_Editor::make_controls ( void )
|
|
|
|
|
{
|
|
|
|
|
Module *module = _module;
|
|
|
|
|
|
|
|
|
|
control_pack->clear();
|
|
|
|
|
|
2012-02-10 13:01:02 +01:00
|
|
|
|
controls_by_port.clear();
|
2010-02-12 11:22:53 +01:00
|
|
|
|
|
|
|
|
|
/* these are for detecting related parameter groups which can be
|
|
|
|
|
better represented by a single control */
|
2012-02-10 13:01:02 +01:00
|
|
|
|
azimuth_port_number = -1;
|
2010-02-25 01:41:01 +01:00
|
|
|
|
float azimuth_value = 0.0f;
|
2012-02-10 13:01:02 +01:00
|
|
|
|
elevation_port_number = -1;
|
2010-02-25 01:41:01 +01:00
|
|
|
|
float elevation_value = 0.0f;
|
2013-06-27 08:49:29 +02:00
|
|
|
|
radius_port_number = -1;
|
|
|
|
|
float radius_value = 0.0f;
|
|
|
|
|
|
2013-05-29 07:11:07 +02:00
|
|
|
|
Fl_Color fc = fl_color_add_alpha( FL_CYAN, 200 );
|
|
|
|
|
Fl_Color bc = FL_BACKGROUND2_COLOR;
|
|
|
|
|
|
2012-02-10 13:01:02 +01:00
|
|
|
|
controls_by_port.resize( module->control_input.size() );
|
2013-09-08 01:58:16 +02:00
|
|
|
|
|
|
|
|
|
if ( mode_choice->value() == 1 )
|
|
|
|
|
{
|
2013-09-19 02:26:23 +02:00
|
|
|
|
control_pack->vspacing( 1 );
|
|
|
|
|
control_pack->hspacing( 10 );
|
2013-09-15 06:05:41 +02:00
|
|
|
|
control_pack->flow(true);
|
|
|
|
|
control_pack->flowdown(true);
|
|
|
|
|
control_pack->type( FL_HORIZONTAL );
|
|
|
|
|
control_pack->size( 900, 240 );
|
2013-09-08 01:58:16 +02:00
|
|
|
|
}
|
|
|
|
|
else if ( mode_choice->value() == 2 )
|
|
|
|
|
{
|
2013-09-19 02:26:23 +02:00
|
|
|
|
control_pack->vspacing( 10 );
|
|
|
|
|
control_pack->hspacing( 10 );
|
2013-09-15 06:05:41 +02:00
|
|
|
|
control_pack->flow(true);
|
|
|
|
|
control_pack->flowdown(false);
|
2013-09-08 01:58:16 +02:00
|
|
|
|
control_pack->type( FL_HORIZONTAL );
|
2013-09-15 06:05:41 +02:00
|
|
|
|
control_pack->size( 900, 350 );
|
2013-09-08 01:58:16 +02:00
|
|
|
|
}
|
|
|
|
|
else if ( mode_choice->value() == 0 )
|
|
|
|
|
{
|
2013-09-19 02:26:23 +02:00
|
|
|
|
control_pack->vspacing( 10 );
|
|
|
|
|
control_pack->hspacing( 10 );
|
2013-09-08 01:58:16 +02:00
|
|
|
|
control_pack->flow(true);
|
2013-09-15 06:05:41 +02:00
|
|
|
|
control_pack->flowdown(false);
|
2013-09-08 01:58:16 +02:00
|
|
|
|
control_pack->type( FL_HORIZONTAL );
|
|
|
|
|
control_pack->size( 700, 50 );
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-25 01:59:39 +01:00
|
|
|
|
for ( unsigned int i = 0; i < module->control_input.size(); ++i )
|
|
|
|
|
{
|
|
|
|
|
Fl_Widget *w;
|
|
|
|
|
|
|
|
|
|
Module::Port *p = &module->control_input[i];
|
|
|
|
|
|
2013-09-02 20:35:32 +02:00
|
|
|
|
/* if ( !p->hints.visible ) */
|
|
|
|
|
/* continue; */
|
2013-04-17 04:18:02 +02:00
|
|
|
|
|
2010-02-14 22:20:50 +01:00
|
|
|
|
if ( !strcasecmp( "Azimuth", p->name() ) &&
|
2013-09-08 01:58:16 +02:00
|
|
|
|
180.0f == p->hints.maximum &&
|
|
|
|
|
-180.0f == p->hints.minimum )
|
2010-02-12 11:22:53 +01:00
|
|
|
|
{
|
|
|
|
|
azimuth_port_number = i;
|
2010-02-14 22:20:50 +01:00
|
|
|
|
azimuth_value = p->control_value();
|
2010-02-12 11:22:53 +01:00
|
|
|
|
continue;
|
|
|
|
|
}
|
2010-02-14 22:20:50 +01:00
|
|
|
|
else if ( !strcasecmp( "Elevation", p->name() ) &&
|
2013-09-08 01:58:16 +02:00
|
|
|
|
90.0f == p->hints.maximum &&
|
|
|
|
|
-90.0f == p->hints.minimum )
|
2010-02-12 11:22:53 +01:00
|
|
|
|
{
|
|
|
|
|
elevation_port_number = i;
|
2010-02-14 22:20:50 +01:00
|
|
|
|
elevation_value = p->control_value();
|
2010-02-12 11:22:53 +01:00
|
|
|
|
continue;
|
2013-06-27 08:49:29 +02:00
|
|
|
|
}
|
|
|
|
|
else if ( !strcasecmp( "Radius", p->name() ) )
|
|
|
|
|
{
|
|
|
|
|
radius_port_number = i;
|
|
|
|
|
radius_value = p->control_value();
|
|
|
|
|
continue;
|
2010-02-12 11:22:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
2009-12-25 01:59:39 +01:00
|
|
|
|
if ( p->hints.type == Module::Port::Hints::BOOLEAN )
|
|
|
|
|
{
|
2013-09-15 06:05:41 +02:00
|
|
|
|
Fl_Button *o = new Fl_Button( 0, 0, 24, 24, p->name() );
|
2009-12-25 01:59:39 +01:00
|
|
|
|
w = o;
|
2013-05-29 07:11:07 +02:00
|
|
|
|
o->selection_color( fc );
|
2009-12-25 01:59:39 +01:00
|
|
|
|
o->type( FL_TOGGLE_BUTTON );
|
|
|
|
|
o->value( p->control_value() );
|
2013-09-08 01:58:16 +02:00
|
|
|
|
o->align(FL_ALIGN_TOP);
|
2009-12-25 01:59:39 +01:00
|
|
|
|
}
|
|
|
|
|
else if ( p->hints.type == Module::Port::Hints::INTEGER )
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
Fl_Counter *o = new Fl_Counter(0, 0, 58, 24, p->name() );
|
|
|
|
|
w = o;
|
2013-09-08 01:58:16 +02:00
|
|
|
|
|
2009-12-25 01:59:39 +01:00
|
|
|
|
o->type(1);
|
|
|
|
|
o->step(1);
|
2013-09-08 01:58:16 +02:00
|
|
|
|
o->align(FL_ALIGN_TOP);
|
2009-12-25 01:59:39 +01:00
|
|
|
|
|
|
|
|
|
if ( p->hints.ranged )
|
|
|
|
|
{
|
|
|
|
|
o->minimum( p->hints.minimum );
|
|
|
|
|
o->maximum( p->hints.maximum );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
o->value( p->control_value() );
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ( mode_choice->value() == 0 )
|
|
|
|
|
{
|
2013-05-29 07:11:07 +02:00
|
|
|
|
Fl_DialX *o = new Fl_DialX( 0, 0, 60, 60, p->name() );
|
2009-12-25 01:59:39 +01:00
|
|
|
|
w = o;
|
2012-02-09 04:03:48 +01:00
|
|
|
|
|
2009-12-25 01:59:39 +01:00
|
|
|
|
if ( p->hints.ranged )
|
|
|
|
|
{
|
2012-02-09 04:03:48 +01:00
|
|
|
|
DMESSAGE( "Min: %f, max: %f", p->hints.minimum, p->hints.maximum );
|
|
|
|
|
|
2009-12-25 01:59:39 +01:00
|
|
|
|
o->minimum( p->hints.minimum );
|
|
|
|
|
o->maximum( p->hints.maximum );
|
|
|
|
|
}
|
2013-05-29 07:11:07 +02:00
|
|
|
|
o->color( bc );
|
|
|
|
|
o->selection_color( fc );
|
2009-12-25 01:59:39 +01:00
|
|
|
|
o->value( p->control_value() );
|
2013-09-08 01:58:16 +02:00
|
|
|
|
o->align(FL_ALIGN_TOP);
|
2013-09-19 02:26:23 +02:00
|
|
|
|
o->box( FL_DOWN_BOX );
|
2009-12-25 01:59:39 +01:00
|
|
|
|
|
2013-09-07 08:08:46 +02:00
|
|
|
|
/* a couple of plugins have ridiculously small units */
|
2013-09-19 08:28:58 +02:00
|
|
|
|
float r = fabs( p->hints.maximum - p->hints.minimum );
|
|
|
|
|
|
|
|
|
|
if ( r <= 0.01f )
|
|
|
|
|
o->precision( 4 );
|
|
|
|
|
else if ( r <= 0.1f )
|
|
|
|
|
o->precision( 3 );
|
|
|
|
|
else if ( r <= 100.0f )
|
|
|
|
|
o->precision( 2 );
|
|
|
|
|
else if ( r <= 5000.0f )
|
|
|
|
|
o->precision( 1 );
|
|
|
|
|
/* else if ( r <= 10000.0f ) */
|
|
|
|
|
/* o->precision( 1 ); */
|
|
|
|
|
else
|
|
|
|
|
o->precision( 0 );
|
2013-09-07 08:08:46 +02:00
|
|
|
|
|
2009-12-25 01:59:39 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2009-12-26 07:58:28 +01:00
|
|
|
|
Fl_Value_SliderX *o = new Fl_Value_SliderX( 0, 0, 120, 24, p->name() );
|
2009-12-25 01:59:39 +01:00
|
|
|
|
w = o;
|
|
|
|
|
|
|
|
|
|
if ( mode_choice->value() == 1 )
|
|
|
|
|
{
|
2012-03-03 03:02:23 +01:00
|
|
|
|
o->type( FL_HORIZONTAL );
|
2012-03-02 06:02:06 +01:00
|
|
|
|
|
2013-09-08 01:58:16 +02:00
|
|
|
|
o->align( FL_ALIGN_RIGHT );
|
2013-09-15 06:05:41 +02:00
|
|
|
|
o->size( 200, 24 );
|
2009-12-25 20:16:27 +01:00
|
|
|
|
if ( p->hints.ranged )
|
|
|
|
|
{
|
|
|
|
|
o->minimum( p->hints.minimum );
|
|
|
|
|
o->maximum( p->hints.maximum );
|
|
|
|
|
}
|
2009-12-25 01:59:39 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2012-03-03 03:02:23 +01:00
|
|
|
|
o->type( FL_VERTICAL );
|
2013-09-08 01:58:16 +02:00
|
|
|
|
o->align(FL_ALIGN_TOP);
|
2012-03-02 06:02:06 +01:00
|
|
|
|
|
2013-09-15 06:05:41 +02:00
|
|
|
|
o->size( 24, 200 );
|
2009-12-25 20:16:27 +01:00
|
|
|
|
/* have to reverse the meaning of these to get the
|
|
|
|
|
* orientation of the slider right */
|
|
|
|
|
o->maximum( p->hints.minimum );
|
|
|
|
|
o->minimum( p->hints.maximum );
|
2009-12-25 01:59:39 +01:00
|
|
|
|
}
|
2013-09-07 08:08:46 +02:00
|
|
|
|
|
|
|
|
|
/* a couple of plugins have ridiculously small units */
|
2013-09-19 08:28:58 +02:00
|
|
|
|
float r = fabs( p->hints.maximum - p->hints.minimum );
|
|
|
|
|
|
|
|
|
|
if ( r <= 0.01f )
|
|
|
|
|
o->precision( 4 );
|
|
|
|
|
else if ( r <= 0.1f )
|
|
|
|
|
o->precision( 3 );
|
|
|
|
|
else if ( r <= 100.0f )
|
|
|
|
|
o->precision( 2 );
|
|
|
|
|
else if ( r <= 5000.0f )
|
|
|
|
|
o->precision( 1 );
|
|
|
|
|
/* else if ( r <= 10000.0f ) */
|
|
|
|
|
/* o->precision( 1 ); */
|
|
|
|
|
else
|
|
|
|
|
o->precision( 0 );
|
2009-12-25 01:59:39 +01:00
|
|
|
|
|
2013-05-29 07:11:07 +02:00
|
|
|
|
o->textsize( 8 );
|
2013-09-19 02:26:23 +02:00
|
|
|
|
// o->box( FL_NO_BOX );
|
2012-03-02 06:02:06 +01:00
|
|
|
|
o->slider( FL_UP_BOX );
|
2013-05-29 07:11:07 +02:00
|
|
|
|
o->color( bc );
|
|
|
|
|
o->selection_color( fc );
|
2009-12-25 01:59:39 +01:00
|
|
|
|
o->value( p->control_value() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2013-09-08 01:58:16 +02:00
|
|
|
|
// w->align(FL_ALIGN_TOP);
|
|
|
|
|
w->labelsize( 10 );
|
2009-12-25 01:59:39 +01:00
|
|
|
|
|
2012-02-10 13:01:02 +01:00
|
|
|
|
controls_by_port[i] = w;
|
2010-02-12 11:22:53 +01:00
|
|
|
|
|
2013-09-19 17:22:14 +02:00
|
|
|
|
w->copy_tooltip( p->osc_path() );
|
2012-02-10 10:06:35 +01:00
|
|
|
|
|
2013-06-27 08:49:29 +02:00
|
|
|
|
_callback_data.push_back( callback_data( this, i ) );
|
|
|
|
|
|
2012-02-10 10:06:35 +01:00
|
|
|
|
if ( p->hints.type == Module::Port::Hints::BOOLEAN )
|
2013-06-27 08:49:29 +02:00
|
|
|
|
w->callback( cb_button_handle, &_callback_data.back() );
|
2012-02-10 10:06:35 +01:00
|
|
|
|
else
|
2013-06-27 08:49:29 +02:00
|
|
|
|
w->callback( cb_value_handle, &_callback_data.back() );
|
2009-12-25 01:59:39 +01:00
|
|
|
|
|
2013-09-15 06:05:41 +02:00
|
|
|
|
{
|
|
|
|
|
Fl_Labelpad_Group *flg = new Fl_Labelpad_Group( w );
|
2013-09-02 20:35:32 +02:00
|
|
|
|
|
2013-09-15 06:05:41 +02:00
|
|
|
|
flg->set_visible_focus();
|
2013-09-02 20:35:32 +02:00
|
|
|
|
|
2013-09-15 06:05:41 +02:00
|
|
|
|
control_pack->add( flg );
|
2009-12-25 01:59:39 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-12 11:22:53 +01:00
|
|
|
|
if ( azimuth_port_number >= 0 && elevation_port_number >= 0 )
|
|
|
|
|
{
|
2013-06-27 08:49:29 +02:00
|
|
|
|
Panner *o = new Panner( 0,0, 502,502 );
|
2013-06-22 02:23:17 +02:00
|
|
|
|
o->box(FL_FLAT_BOX);
|
2010-02-12 11:22:53 +01:00
|
|
|
|
o->color(FL_GRAY0);
|
|
|
|
|
o->selection_color(FL_BACKGROUND_COLOR);
|
|
|
|
|
o->labeltype(FL_NORMAL_LABEL);
|
|
|
|
|
o->labelfont(0);
|
|
|
|
|
o->labelcolor(FL_FOREGROUND_COLOR);
|
|
|
|
|
o->align(FL_ALIGN_TOP);
|
2010-02-24 16:05:46 +01:00
|
|
|
|
o->when(FL_WHEN_CHANGED);
|
2010-02-12 11:22:53 +01:00
|
|
|
|
o->label( "Spatialization" );
|
|
|
|
|
o->labelsize( 10 );
|
2013-06-27 08:49:29 +02:00
|
|
|
|
|
|
|
|
|
_callback_data.push_back( callback_data( this, azimuth_port_number, elevation_port_number, radius_port_number ) );
|
|
|
|
|
o->callback( cb_panner_value_handle, &_callback_data.back() );
|
2010-02-12 11:22:53 +01:00
|
|
|
|
|
2010-02-14 22:20:50 +01:00
|
|
|
|
o->point( 0 )->azimuth( azimuth_value );
|
|
|
|
|
o->point( 0 )->elevation( elevation_value );
|
2013-07-18 04:13:33 +02:00
|
|
|
|
if ( radius_port_number >= 0 )
|
|
|
|
|
{
|
|
|
|
|
o->point( 0 )->radius_enabled = true;
|
|
|
|
|
o->point( 0 )->radius( radius_value );
|
|
|
|
|
}
|
2010-02-14 22:20:50 +01:00
|
|
|
|
|
|
|
|
|
Fl_Labelpad_Group *flg = new Fl_Labelpad_Group( o );
|
|
|
|
|
|
2013-09-09 05:00:40 +02:00
|
|
|
|
flg->resizable(o);
|
2010-02-14 22:20:50 +01:00
|
|
|
|
control_pack->add( flg );
|
2012-02-10 13:01:02 +01:00
|
|
|
|
|
|
|
|
|
controls_by_port[azimuth_port_number] = o;
|
|
|
|
|
controls_by_port[elevation_port_number] = o;
|
2013-07-18 04:13:33 +02:00
|
|
|
|
if ( radius_port_number >= 0 )
|
|
|
|
|
controls_by_port[radius_port_number] = o;
|
2010-02-12 11:22:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
2013-09-02 20:35:32 +02:00
|
|
|
|
update_control_visibility();
|
2010-02-12 11:22:53 +01:00
|
|
|
|
|
2013-09-08 01:58:16 +02:00
|
|
|
|
control_pack->dolayout();
|
|
|
|
|
|
|
|
|
|
int width = control_pack->w() + 100;
|
|
|
|
|
int height = control_pack->h() + 60;
|
2010-01-14 06:01:15 +01:00
|
|
|
|
|
2012-03-03 22:21:18 +01:00
|
|
|
|
if ( width < _min_width )
|
|
|
|
|
width = _min_width;
|
|
|
|
|
|
2013-09-08 01:58:16 +02:00
|
|
|
|
control_pack->parent()->size( control_pack->w() + 100, control_pack->h() );
|
|
|
|
|
|
|
|
|
|
control_scroll->scroll_to(0, 0 );
|
|
|
|
|
|
2010-01-14 06:01:15 +01:00
|
|
|
|
size( width, height );
|
2012-03-03 22:21:18 +01:00
|
|
|
|
size_range( width, height, width, height );
|
2009-12-25 01:59:39 +01:00
|
|
|
|
}
|
|
|
|
|
|
2013-09-02 20:35:32 +02:00
|
|
|
|
void
|
|
|
|
|
Module_Parameter_Editor::update_control_visibility ( void )
|
|
|
|
|
{
|
|
|
|
|
for ( unsigned int i = 0; i < _module->control_input.size(); ++i )
|
|
|
|
|
{
|
|
|
|
|
const Module::Port *p = &_module->control_input[i];
|
|
|
|
|
|
|
|
|
|
if ( p->hints.visible )
|
2013-09-15 06:05:41 +02:00
|
|
|
|
controls_by_port[i]->parent()->show();
|
2013-09-02 20:35:32 +02:00
|
|
|
|
else
|
2013-09-15 06:05:41 +02:00
|
|
|
|
controls_by_port[i]->parent()->hide();
|
2013-09-02 20:35:32 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-25 01:59:39 +01:00
|
|
|
|
void
|
|
|
|
|
Module_Parameter_Editor::cb_value_handle ( Fl_Widget *w, void *v )
|
|
|
|
|
{
|
|
|
|
|
callback_data *cd = (callback_data*)v;
|
|
|
|
|
|
2010-02-12 11:22:53 +01:00
|
|
|
|
cd->base_widget->set_value( cd->port_number[0], ((Fl_Valuator*)w)->value() );
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-10 10:06:35 +01:00
|
|
|
|
void
|
|
|
|
|
Module_Parameter_Editor::cb_button_handle ( Fl_Widget *w, void *v )
|
|
|
|
|
{
|
|
|
|
|
callback_data *cd = (callback_data*)v;
|
|
|
|
|
|
|
|
|
|
cd->base_widget->set_value( cd->port_number[0], ((Fl_Button*)w)->value() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2010-02-12 11:22:53 +01:00
|
|
|
|
void
|
|
|
|
|
Module_Parameter_Editor::cb_panner_value_handle ( Fl_Widget *w, void *v )
|
|
|
|
|
{
|
|
|
|
|
callback_data *cd = (callback_data*)v;
|
|
|
|
|
|
2010-02-14 22:20:50 +01:00
|
|
|
|
cd->base_widget->set_value( cd->port_number[0], ((Panner*)w)->point( 0 )->azimuth() );
|
|
|
|
|
cd->base_widget->set_value( cd->port_number[1], ((Panner*)w)->point( 0 )->elevation() );
|
2013-06-27 08:49:29 +02:00
|
|
|
|
cd->base_widget->set_value( cd->port_number[2], ((Panner*)w)->point( 0 )->radius() );
|
|
|
|
|
|
2009-12-25 01:59:39 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2010-02-01 07:23:01 +01:00
|
|
|
|
Module_Parameter_Editor::cb_mode_handle ( Fl_Widget *, void *v )
|
2009-12-25 01:59:39 +01:00
|
|
|
|
{
|
|
|
|
|
((Module_Parameter_Editor*)v)->make_controls();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Module_Parameter_Editor::bind_control ( int i )
|
|
|
|
|
{
|
|
|
|
|
Module::Port *p = &_module->control_input[i];
|
|
|
|
|
|
|
|
|
|
if ( p->connected() )
|
|
|
|
|
/* can only bind once */
|
|
|
|
|
return;
|
|
|
|
|
|
2009-12-28 06:25:28 +01:00
|
|
|
|
Controller_Module *o = new Controller_Module();
|
|
|
|
|
o->label( p->name() );
|
2009-12-25 01:59:39 +01:00
|
|
|
|
o->chain( _module->chain() );
|
2013-09-19 02:10:23 +02:00
|
|
|
|
o->horizontal( true );
|
2009-12-25 01:59:39 +01:00
|
|
|
|
o->connect_to( p );
|
|
|
|
|
|
|
|
|
|
_module->chain()->add_control( o );
|
|
|
|
|
_module->redraw();
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-10 09:28:37 +01:00
|
|
|
|
/* Display changes initiated via automation or from other parts of the GUI */
|
|
|
|
|
void
|
|
|
|
|
Module_Parameter_Editor::handle_control_changed ( Module::Port *p )
|
|
|
|
|
{
|
|
|
|
|
int i = _module->control_input_port_index( p );
|
2012-02-10 13:01:02 +01:00
|
|
|
|
|
|
|
|
|
Fl_Widget *w = controls_by_port[i];
|
|
|
|
|
|
|
|
|
|
if ( i == azimuth_port_number ||
|
2013-06-27 08:49:29 +02:00
|
|
|
|
i == elevation_port_number ||
|
|
|
|
|
i == radius_port_number )
|
2012-02-10 13:01:02 +01:00
|
|
|
|
{
|
|
|
|
|
Panner *_panner = (Panner*)w;
|
2012-02-10 09:28:37 +01:00
|
|
|
|
|
2012-02-10 13:01:02 +01:00
|
|
|
|
if ( i == azimuth_port_number )
|
|
|
|
|
_panner->point(0)->azimuth( p->control_value() );
|
|
|
|
|
else if ( i == elevation_port_number )
|
|
|
|
|
_panner->point(0)->elevation( p->control_value() );
|
2013-06-27 08:49:29 +02:00
|
|
|
|
else if ( i == radius_port_number )
|
|
|
|
|
_panner->point(0)->radius( p->control_value() );
|
2012-02-10 13:01:02 +01:00
|
|
|
|
|
|
|
|
|
_panner->redraw();
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
2012-02-10 09:28:37 +01:00
|
|
|
|
|
2012-02-10 10:06:35 +01:00
|
|
|
|
|
|
|
|
|
if ( p->hints.type == Module::Port::Hints::BOOLEAN )
|
|
|
|
|
{
|
2012-02-10 13:01:02 +01:00
|
|
|
|
Fl_Button *v = (Fl_Button*)w;
|
2012-02-10 10:06:35 +01:00
|
|
|
|
|
|
|
|
|
v->value( p->control_value() );
|
2012-02-10 13:01:02 +01:00
|
|
|
|
}
|
2012-02-10 10:06:35 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
2012-02-10 13:01:02 +01:00
|
|
|
|
Fl_Valuator *v = (Fl_Valuator*)w;
|
2012-02-10 10:06:35 +01:00
|
|
|
|
|
|
|
|
|
v->value( p->control_value() );
|
|
|
|
|
}
|
2012-02-10 09:28:37 +01:00
|
|
|
|
}
|
|
|
|
|
|
2013-09-15 06:05:41 +02:00
|
|
|
|
|
2013-09-02 06:37:28 +02:00
|
|
|
|
void
|
|
|
|
|
Module_Parameter_Editor::reload ( void )
|
|
|
|
|
{
|
2013-09-02 20:35:32 +02:00
|
|
|
|
// make_controls();
|
|
|
|
|
update_control_visibility();
|
2013-09-02 06:37:28 +02:00
|
|
|
|
redraw();
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-25 01:59:39 +01:00
|
|
|
|
void
|
|
|
|
|
Module_Parameter_Editor::set_value (int i, float value )
|
|
|
|
|
{
|
2013-07-18 04:13:33 +02:00
|
|
|
|
if ( i >= 0 )
|
|
|
|
|
{
|
|
|
|
|
_module->control_input[i].control_value( value );
|
|
|
|
|
if ( _module->control_input[i].connected() )
|
|
|
|
|
_module->control_input[i].connected_port()->module()->handle_control_changed( _module->control_input[i].connected_port() );
|
|
|
|
|
}
|
2010-02-24 16:05:46 +01:00
|
|
|
|
// _module->handle_control_changed( &_module->control_input[i] );
|
2009-12-25 01:59:39 +01:00
|
|
|
|
}
|
2013-09-15 06:05:41 +02:00
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Module_Parameter_Editor::menu_cb ( Fl_Widget *w, void *v )
|
|
|
|
|
{
|
|
|
|
|
((Module_Parameter_Editor*)v)->menu_cb((Fl_Menu_*)w);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Module_Parameter_Editor::menu_cb ( Fl_Menu_* m )
|
|
|
|
|
{
|
|
|
|
|
char picked[256];
|
|
|
|
|
|
|
|
|
|
if ( ! m->mvalue() || m->mvalue()->flags & FL_SUBMENU_POINTER || m->mvalue()->flags & FL_SUBMENU )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
strncpy( picked, m->mvalue()->label(), sizeof( picked ) );
|
|
|
|
|
|
|
|
|
|
// m->item_pathname( picked, sizeof( picked ) );
|
|
|
|
|
|
|
|
|
|
DMESSAGE( "%s", picked );
|
|
|
|
|
|
|
|
|
|
if ( ! strcmp( picked, "Bind" ) )
|
|
|
|
|
{
|
|
|
|
|
bind_control( _selected_control );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Fl_Menu_Button &
|
|
|
|
|
Module_Parameter_Editor::menu ( void ) const
|
|
|
|
|
{
|
|
|
|
|
static Fl_Menu_Button m( 0, 0, 0, 0, "Control" );
|
|
|
|
|
|
|
|
|
|
m.clear();
|
|
|
|
|
|
|
|
|
|
m.add( "Bind", 0, 0, 0, FL_MENU_RADIO | (_module->control_input[_selected_control].connected() ? FL_MENU_VALUE : 0 ));
|
|
|
|
|
// m.add( "Unbind", 0, &Module::menu_cb, this, 0, FL_MENU_RADIO );
|
|
|
|
|
|
|
|
|
|
m.callback( menu_cb, (void*)this );
|
|
|
|
|
|
|
|
|
|
return m;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
Module_Parameter_Editor::handle ( int m )
|
|
|
|
|
{
|
|
|
|
|
switch ( m )
|
|
|
|
|
{
|
|
|
|
|
case FL_PUSH:
|
|
|
|
|
if ( test_press( FL_BUTTON3 ) )
|
|
|
|
|
{
|
|
|
|
|
for ( unsigned int i = 0; i < controls_by_port.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
if ( Fl::event_inside( controls_by_port[i] ) )
|
|
|
|
|
{
|
|
|
|
|
_selected_control = i;
|
|
|
|
|
|
|
|
|
|
Fl_Menu_Button &m = menu();
|
|
|
|
|
|
|
|
|
|
menu_popup(&m,Fl::event_x(), Fl::event_y());
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Fl_Group::handle(m);
|
|
|
|
|
}
|