Mixer/Module_Parameter_Editor: Change default view from knobs to horizontal sliders. Make toggle buttons smaller.

pull/116/head
Jonathan Moore Liles 2013-09-14 21:05:41 -07:00
parent f3b73381d7
commit d97a2ee7ba
5 changed files with 142 additions and 94 deletions

View File

@ -112,7 +112,8 @@ public:
int LX = 0; int LX = 0;
int LY = 0; int LY = 0;
int RH = 0; int RH = 0;
int RY = 0; // int RY = 0;
int CW = 0;
if ( _flow ) if ( _flow )
{ {
@ -136,35 +137,45 @@ public:
{ {
if ( _flowdown ) if ( _flowdown )
{ {
if ( (Y - RY) + o->h() < RH ) if ( Y + o->h() <= _initial_height )
{ {
/* if it'll fit in this column, put it below the previous widget */ /* if it'll fit in this column, put it below the previous widget */
X = LX; X = LX;
} }
else else
Y = 0; {
} Y = H;
else if ( X + o->w() >= _initial_width ) CW = 0;
{ }
/* maybe wrap to the next row */
H += RH + _vspacing;
RY = Y;
RH = 0;
if ( X > W )
W = X;
X = 0; CW = o->w() > CW ? o->w() : CW;
RH = Y + o->h() > RH ? Y + o->h() : RH;
} }
else else
{ {
/* otherwise, put it in the next column */ if ( X + o->w() >= _initial_width )
Y = H; {
} /* maybe wrap to the next row */
H += RH + _vspacing;
// RY = Y;
RH = 0;
if ( X > W )
W = X;
X = 0;
}
else
{
/* otherwise, put it in the next column */
Y = H;
}
RH = o->h() > RH ? o->h() : RH;
}
} }
RH = o->h() > RH ? o->h() : RH;
LW = o->w(); LW = o->w();
LH = o->h(); LH = o->h();
@ -174,11 +185,15 @@ public:
if ( _flow ) if ( _flow )
{ {
if ( _flowdown ) if ( _flowdown )
{
Y += LH + _vspacing; Y += LH + _vspacing;
X += CW + _hspacing;
}
else else
{
Y += RH + _vspacing; Y += RH + _vspacing;
X += LW + _hspacing;
X += LW + _hspacing; }
} }
else else
{ {
@ -212,8 +227,11 @@ public:
H += RH; H += RH;
if ( X > W ) if ( X > W )
W = X; W = X;
}
/* if ( _flowdown ) */
/* H = _initial_height; */
}
Fl_Group::resize( x(), y(), W, H ); Fl_Group::resize( x(), y(), W, H );
} }
}; };

View File

@ -39,14 +39,15 @@
#include "Controller_Module.H" #include "Controller_Module.H"
#include "Chain.H" #include "Chain.H"
#include "Panner.H" #include "Panner.H"
#include <FL/fl_ask.H>
#include "debug.h" #include "debug.h"
#include <FL/Fl_Menu_Button.H>
#include "FL/test_press.H"
#include "FL/menu_popup.H"
Module_Parameter_Editor::Module_Parameter_Editor ( Module *module ) : Fl_Double_Window( 900,900 ) Module_Parameter_Editor::Module_Parameter_Editor ( Module *module ) : Fl_Double_Window( 900,240)
{ {
_module = module; _module = module;
_resized = false; _resized = false;
@ -81,7 +82,7 @@ Module_Parameter_Editor::Module_Parameter_Editor ( Module *module ) : Fl_Double_
o->add( "Horizontal Sliders" ); o->add( "Horizontal Sliders" );
o->add( "Vertical Sliders" ); o->add( "Vertical Sliders" );
o->label( NULL ); o->label( NULL );
o->value( 0 ); o->value( 1 );
o->when( FL_WHEN_CHANGED ); o->when( FL_WHEN_CHANGED );
o->callback( cb_mode_handle, this ); o->callback( cb_mode_handle, this );
} }
@ -141,19 +142,23 @@ Module_Parameter_Editor::make_controls ( void )
if ( mode_choice->value() == 1 ) if ( mode_choice->value() == 1 )
{ {
control_pack->flow(false); control_pack->flow(true);
control_pack->type( FL_VERTICAL ); control_pack->flowdown(true);
control_pack->size( 450, 24 ); control_pack->vspacing(0);
control_pack->type( FL_HORIZONTAL );
control_pack->size( 900, 240 );
} }
else if ( mode_choice->value() == 2 ) else if ( mode_choice->value() == 2 )
{ {
control_pack->flow(false); control_pack->flow(true);
control_pack->flowdown(false);
control_pack->type( FL_HORIZONTAL ); control_pack->type( FL_HORIZONTAL );
control_pack->size( 24, 350 ); control_pack->size( 900, 350 );
} }
else if ( mode_choice->value() == 0 ) else if ( mode_choice->value() == 0 )
{ {
control_pack->flow(true); control_pack->flow(true);
control_pack->flowdown(false);
control_pack->type( FL_HORIZONTAL ); control_pack->type( FL_HORIZONTAL );
control_pack->size( 700, 50 ); control_pack->size( 700, 50 );
@ -193,7 +198,7 @@ Module_Parameter_Editor::make_controls ( void )
if ( p->hints.type == Module::Port::Hints::BOOLEAN ) if ( p->hints.type == Module::Port::Hints::BOOLEAN )
{ {
Fl_Button *o = new Fl_Button( 0, 0, 30, 30, p->name() ); Fl_Button *o = new Fl_Button( 0, 0, 24, 24, p->name() );
w = o; w = o;
o->selection_color( fc ); o->selection_color( fc );
o->type( FL_TOGGLE_BUTTON ); o->type( FL_TOGGLE_BUTTON );
@ -255,7 +260,7 @@ Module_Parameter_Editor::make_controls ( void )
o->type( FL_HORIZONTAL ); o->type( FL_HORIZONTAL );
o->align( FL_ALIGN_RIGHT ); o->align( FL_ALIGN_RIGHT );
o->size( 300, 24 ); o->size( 200, 24 );
if ( p->hints.ranged ) if ( p->hints.ranged )
{ {
o->minimum( p->hints.minimum ); o->minimum( p->hints.minimum );
@ -267,7 +272,7 @@ Module_Parameter_Editor::make_controls ( void )
o->type( FL_VERTICAL ); o->type( FL_VERTICAL );
o->align(FL_ALIGN_TOP); o->align(FL_ALIGN_TOP);
o->size( 24, 300 ); o->size( 24, 200 );
/* have to reverse the meaning of these to get the /* have to reverse the meaning of these to get the
* orientation of the slider right */ * orientation of the slider right */
o->maximum( p->hints.minimum ); o->maximum( p->hints.minimum );
@ -295,8 +300,6 @@ Module_Parameter_Editor::make_controls ( void )
w->tooltip( p->osc_path() ); w->tooltip( p->osc_path() );
Fl_Button *bound;
_callback_data.push_back( callback_data( this, i ) ); _callback_data.push_back( callback_data( this, i ) );
@ -305,47 +308,12 @@ Module_Parameter_Editor::make_controls ( void )
else else
w->callback( cb_value_handle, &_callback_data.back() ); w->callback( cb_value_handle, &_callback_data.back() );
{ Fl_Group *o = new Fl_Group( 0, 0, 50, 75 ); {
{ Fl_Labelpad_Group *flg = new Fl_Labelpad_Group( w );
Fl_Labelpad_Group *flg = new Fl_Labelpad_Group( w );
{ Fl_Button *o = bound = new Fl_Button( 0, 50, 14, 14 ); flg->set_visible_focus();
o->selection_color( FL_YELLOW );
o->type( 0 );
o->labelsize( 8 );
o->value( p->connected() ); control_pack->add( flg );
o->callback( cb_bound_handle, &_callback_data.back() );
}
// flg->resizable(w);
o->resizable( 0 );
o->end();
o->set_visible_focus();
flg->set_visible_focus();
flg->position( o->x(), o->y() );
if ( mode_choice->value() == 1 )
{
bound->position( flg->x() + 450 - bound->w(), o->y() );
o->size( flg->w() + bound->w(), flg->h() );
}
else
{
bound->position( o->x(), flg->y() + flg->h() );
o->size( flg->w(), flg->h() + bound->h() );
}
o->init_sizes();
// o->resizable(flg);
}
if (! p->hints.visible )
o->hide();
control_pack->add( o );
} }
} }
@ -412,9 +380,9 @@ Module_Parameter_Editor::update_control_visibility ( void )
const Module::Port *p = &_module->control_input[i]; const Module::Port *p = &_module->control_input[i];
if ( p->hints.visible ) if ( p->hints.visible )
controls_by_port[i]->parent()->parent()->show(); controls_by_port[i]->parent()->show();
else else
controls_by_port[i]->parent()->parent()->hide(); controls_by_port[i]->parent()->hide();
} }
} }
@ -452,18 +420,6 @@ Module_Parameter_Editor::cb_mode_handle ( Fl_Widget *, void *v )
((Module_Parameter_Editor*)v)->make_controls(); ((Module_Parameter_Editor*)v)->make_controls();
} }
void
Module_Parameter_Editor::cb_bound_handle ( Fl_Widget *w, void *v )
{
callback_data *cd = (callback_data*)v;
Fl_Button *fv = (Fl_Button*)w;
fv->value( 1 );
cd->base_widget->bind_control( cd->port_number[0] );
}
void void
Module_Parameter_Editor::bind_control ( int i ) Module_Parameter_Editor::bind_control ( int i )
{ {
@ -524,6 +480,7 @@ Module_Parameter_Editor::handle_control_changed ( Module::Port *p )
} }
} }
void void
Module_Parameter_Editor::reload ( void ) Module_Parameter_Editor::reload ( void )
{ {
@ -543,3 +500,73 @@ Module_Parameter_Editor::set_value (int i, float value )
} }
// _module->handle_control_changed( &_module->control_input[i] ); // _module->handle_control_changed( &_module->control_input[i] );
} }
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);
}

View File

@ -77,11 +77,15 @@ class Module_Parameter_Editor : public Fl_Double_Window
void bind_control ( int i ); void bind_control ( int i );
void make_controls ( void ); void make_controls ( void );
static void menu_cb ( Fl_Widget *w, void *v );
void menu_cb ( Fl_Menu_ *m );
Fl_Scroll *control_scroll; Fl_Scroll *control_scroll;
Fl_Flowpack *control_pack; Fl_Flowpack *control_pack;
Fl_Menu_Button *mode_choice; Fl_Menu_Button *mode_choice;
bool _resized; bool _resized;
int _min_width; int _min_width;
int _selected_control;
int azimuth_port_number; int azimuth_port_number;
int elevation_port_number; int elevation_port_number;
@ -90,11 +94,14 @@ class Module_Parameter_Editor : public Fl_Double_Window
std::list<callback_data> _callback_data; std::list<callback_data> _callback_data;
std::vector<Fl_Widget*> controls_by_port; std::vector<Fl_Widget*> controls_by_port;
Fl_Menu_Button &menu ( void ) const;
public: public:
void reload ( void ); void reload ( void );
void handle_control_changed ( Module::Port *p ); void handle_control_changed ( Module::Port *p );
int handle ( int m );
Module_Parameter_Editor ( Module *module ); Module_Parameter_Editor ( Module *module );
virtual ~Module_Parameter_Editor ( ); virtual ~Module_Parameter_Editor ( );
}; };

View File

@ -41,7 +41,6 @@ Panner::Panner ( int X, int Y, int W, int H, const char *L ) :
_bg_image = 0; _bg_image = 0;
_bg_image_scaled = 0; _bg_image_scaled = 0;
_bg_image_projection = 0; _bg_image_projection = 0;
_range = 15.0f;
// _projection = POLAR; // _projection = POLAR;
_points.push_back( Point( 1, 0 ) ); _points.push_back( Point( 1, 0 ) );

View File

@ -136,10 +136,7 @@ public:
}; };
private: private:
float _range;
vector <Point> _points; vector <Point> _points;
static int _configs[][12]; static int _configs[][12];