Mixer: Change the appearance/layout of slider modes in parameter editor. Also, add scroll widget.

This commit is contained in:
Jonathan Moore Liles 2013-09-07 16:58:16 -07:00
parent 7da3bb325f
commit a05384a8c3
6 changed files with 159 additions and 100 deletions

View File

@ -26,9 +26,10 @@ class Fl_Flowpack : public Fl_Group
{ {
int _hspacing; int _hspacing;
int _vspacing; int _vspacing;
int _max_width;
bool _flow; bool _flow;
bool _flowdown; bool _flowdown;
int _initial_height;
int _initial_width;
public: public:
@ -36,7 +37,9 @@ public:
: Fl_Group( X, Y, W, H, L ) : Fl_Group( X, Y, W, H, L )
{ {
resizable( 0 ); resizable( 0 );
_max_width = _hspacing = _vspacing = 0; _hspacing = _vspacing = 0;
_initial_width = W;
_initial_height = H;
_flow = true; _flow = true;
_flowdown = false; _flowdown = false;
} }
@ -45,7 +48,6 @@ public:
{ {
} }
int max_width ( void ) const { return _max_width; }
void vspacing ( int v ) { _vspacing = v; } void vspacing ( int v ) { _vspacing = v; }
int vspacing ( void ) const { return _vspacing; }; int vspacing ( void ) const { return _vspacing; };
@ -76,50 +78,52 @@ public:
void void
resize ( int X, int Y, int W, int H ) resize ( int X, int Y, int W, int H )
{ {
int NW = W; _initial_width = W;
int NH = H; _initial_height = H;
layout( NW, NH ); layout();
Fl_Group::resize( X, Y, NW, NH ); Fl_Group::resize( X, Y, w(), h() );
} }
void void
draw ( void ) draw ( void )
{ {
dolayout(); layout();
Fl_Group::draw(); Fl_Group::draw();
} }
void dolayout ( void ) void dolayout ( void )
{ {
int H = h(); layout();
int W = w();
layout( W, H );
if ( H != h() || W != w() )
size( W, H );
} }
void void
layout ( int &W, int &H ) layout ( void )
{ {
resizable( 0 ); resizable( 0 );
int W;
int H;
int X = 0; int X = 0;
int Y = 0; int Y = 0;
H = 0;
/* int H = 0; */
_max_width = 0;
int LW = 0; int LW = 0;
int LH = 0; int LH = 0;
int LX = 0; int LX = 0;
int LY = 0; int LY = 0;
int RH = 0; int RH = 0;
int RY = 0;
if ( _flow )
{
H = 0;
W = 0;
}
else
{
H = _initial_height;
W = _initial_width;
}
for ( int i = 0; i < children(); ++i ) for ( int i = 0; i < children(); ++i )
{ {
@ -130,16 +134,25 @@ public:
if ( _flow ) if ( _flow )
{ {
if ( _flowdown && Y + o->h() < RH ) if ( _flowdown )
{ {
/* if it'll fit in this column, put it below the previous widget */ if ( (Y - RY) + o->h() < RH )
X = LX; {
/* if it'll fit in this column, put it below the previous widget */
X = LX;
}
else
Y = 0;
} }
else if ( X + o->w() >= W ) else if ( X + o->w() >= _initial_width )
{ {
/* maybe wrap to the next row */ /* maybe wrap to the next row */
H += RH + _vspacing; H += RH + _vspacing;
RY = Y;
RH = 0; RH = 0;
if ( X > W )
W = X;
X = 0; X = 0;
} }
else else
@ -155,15 +168,9 @@ public:
LW = o->w(); LW = o->w();
LH = o->h(); LH = o->h();
/* avoid bothering the control with lots of resize() calls */
LX = X; LX = X;
LY = Y; LY = Y;
if ( ! ( o->x() == x() + LX &&
o->y() == y() + LY ) )
o->position( x() + LX, y() + LY );
if ( _flow ) if ( _flow )
{ {
if ( _flowdown ) if ( _flowdown )
@ -178,20 +185,35 @@ public:
if ( type() == Fl_Pack::HORIZONTAL ) if ( type() == Fl_Pack::HORIZONTAL )
{ {
X += LW + _hspacing; X += LW + _hspacing;
LH = _initial_height;
W = X;
} }
else else
{ {
Y += LH + _vspacing; Y += LH + _vspacing;
LW = _initial_width;
H = Y;
} }
} }
if ( X > _max_width )
_max_width = X; if ( ! ( o->x() == x() + LX &&
o->y() == y() + LY &&
o->w() == LW &&
o->h() == LH ) )
o->resize( x() + LX,
y() + LY,
LW,
LH);
} }
H += RH; if ( _flow )
{
H += RH;
if ( X > W )
W = X;
}
if ( ! _flow ) Fl_Group::resize( x(), y(), W, H );
W = X;
} }
}; };

View File

@ -49,13 +49,20 @@ public:
measure_label( o, W, H ); measure_label( o, W, H );
// set size to contain widget // set size to contain widget
size( W > o->w() ? W : o->w(), o->h() + H ); if ( o->align() & ( FL_ALIGN_TOP | FL_ALIGN_BOTTOM ) )
size( W > o->w() ? W : o->w(), o->h() + H );
if ( o->align() & ( FL_ALIGN_LEFT | FL_ALIGN_RIGHT ) )
size( o->w() + W, H > o->h() ? H : o->h() );
// center widget in group // center widget in group
if ( o->align() & FL_ALIGN_TOP ) if ( o->align() & FL_ALIGN_TOP )
o->position( x() + w() / 2 - (o->w() / 2 ), y() + H ); o->position( x() + w() / 2 - (o->w() / 2 ), y() + H );
else if ( o->align() & FL_ALIGN_BOTTOM ) else if ( o->align() & FL_ALIGN_BOTTOM )
o->position( x() + w() / 2 - (o->w() / 2 ), y() ); o->position( x() + w() / 2 - (o->w() / 2 ), y() );
else if ( o->align() & FL_ALIGN_RIGHT )
o->position( x(), y() );
else if ( o->align() & FL_ALIGN_LEFT )
o->position( x() + W, y() );
else else
{ {
/* TODO: other alignments */ /* TODO: other alignments */

View File

@ -582,7 +582,7 @@ Mixer::Mixer ( int X, int Y, int W, int H, const char *L ) :
} }
end(); end();
resize( X,Y,W,H ); resize( X,Y,W,H );
update_frequency( 15 ); update_frequency( 15 );
@ -737,10 +737,10 @@ void Mixer::resize ( int X, int Y, int W, int H )
{ {
Fl_Group::resize( X, Y, W, H ); Fl_Group::resize( X, Y, W, H );
mixer_strips->resize( X, Y + 24, W, H - (18*2) - 24 );
scroll->resize( X, Y + 24, W, H - 24 - 18 ); scroll->resize( X, Y + 24, W, H - 24 - 18 );
mixer_strips->resize( X, Y + 24, W, H - (18*2) - 24 );
rows( _rows ); rows( _rows );
} }
@ -867,8 +867,6 @@ Mixer::rows ( int ideal_rows )
{ {
sh = (scroll->h() - 18); sh = (scroll->h() - 18);
mixer_strips->flow( false ); mixer_strips->flow( false );
actual_rows = 1;
} }
int tw = 0; int tw = 0;
@ -885,12 +883,13 @@ Mixer::rows ( int ideal_rows )
if ( actual_rows > 1 ) if ( actual_rows > 1 )
mixer_strips->size( scroll->w() - 18, mixer_strips->h() ); mixer_strips->size( scroll->w() - 18, mixer_strips->h() );
else else
mixer_strips->size( tw, mixer_strips->h() ); mixer_strips->size( tw, sh );
_rows = ideal_rows; _rows = ideal_rows;
if ( _strip_height != sh ); if ( _strip_height != sh );
{ {
mixer_strips->redraw();
scroll->redraw(); scroll->redraw();
_strip_height = sh; _strip_height = sh;
} }

View File

@ -33,7 +33,7 @@
#include "FL/Fl_Labelpad_Group.H" #include "FL/Fl_Labelpad_Group.H"
#include "FL/Fl_Value_SliderX.H" #include "FL/Fl_Value_SliderX.H"
#include "FL/Fl_DialX.H" #include "FL/Fl_DialX.H"
#include <FL/Fl_Scroll.H>
#include "Module.H" #include "Module.H"
#include "Module_Parameter_Editor.H" #include "Module_Parameter_Editor.H"
#include "Controller_Module.H" #include "Controller_Module.H"
@ -46,7 +46,7 @@
Module_Parameter_Editor::Module_Parameter_Editor ( Module *module ) : Fl_Double_Window( 800, 600 ) Module_Parameter_Editor::Module_Parameter_Editor ( Module *module ) : Fl_Double_Window( 900,900 )
{ {
_module = module; _module = module;
_resized = false; _resized = false;
@ -65,52 +65,37 @@ Module_Parameter_Editor::Module_Parameter_Editor ( Module *module ) : Fl_Double_
copy_label( title ); copy_label( title );
fl_font( FL_HELVETICA, 14 ); // fl_font( FL_HELVETICA, 14 );
_min_width = 30 + fl_width( module->label() ); _min_width = 30 + fl_width( module->label() );
{ Fl_Pack *o = main_pack = new Fl_Pack( 0, 0, w(), h() - 10 ); { Fl_Group *o = new Fl_Group( 0, 0, w(), 25 );
o->type( FL_VERTICAL );
o->label( module->label() ); o->label( module->label() );
o->labelfont( 2 ); o->labelfont( 2 );
o->labeltype( FL_SHADOW_LABEL ); o->labeltype( FL_SHADOW_LABEL );
o->labelsize( 14 ); o->labelsize( 14 );
o->align( FL_ALIGN_TOP | FL_ALIGN_RIGHT | FL_ALIGN_INSIDE ); o->align( FL_ALIGN_TOP | FL_ALIGN_RIGHT | FL_ALIGN_INSIDE );
{ Fl_Menu_Button *o = mode_choice = new Fl_Menu_Button( 0, 0, 25, 25 );
{ Fl_Pack *o = new Fl_Pack( 0, 0, 50, 25 ); o->add( "Knobs" );
o->type( FL_HORIZONTAL ); o->add( "Horizontal Sliders" );
o->spacing( 20 ); o->add( "Vertical Sliders" );
o->label( NULL );
{ Fl_Menu_Button *o = mode_choice = new Fl_Menu_Button( 0, 0, 25, 25 ); o->value( 0 );
o->add( "Knobs" ); o->when( FL_WHEN_CHANGED );
o->add( "Horizontal Sliders" ); o->callback( cb_mode_handle, this );
o->add( "Vertical Sliders" );
o->label( NULL );
o->value( 0 );
o->when( FL_WHEN_CHANGED );
o->callback( cb_mode_handle, this );
}
/* { Fl_Box *o = new Fl_Box( 0, 0, 300, 25 ); */
/* o->box( FL_ROUNDED_BOX ); */
/* o->color( FL_YELLOW ); */
/* o->label( strdup( lab ) ); */
/* o->labeltype( FL_SHADOW_LABEL ); */
/* o->labelsize( 18 ); */
/* o->align( (Fl_Align)(FL_ALIGN_TOP | FL_ALIGN_RIGHT | FL_ALIGN_INSIDE ) ); */
/* // Fl_Group::current()->resizable( o ); */
/* } */
o->end();
} }
{ Fl_Group *o = new Fl_Group( 0, 0, w(), h() ); o->resizable(0);
{ Fl_Flowpack *o = control_pack = new Fl_Flowpack( 50, 0, w() - 100, h() ); o->end();
/* o->box( FL_ROUNDED_BOX ); */ }
/* o->color( FL_GRAY ); */
{ 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 );
o->type( FL_HORIZONTAL ); o->type( FL_HORIZONTAL );
o->flow( true ); o->flow( true );
o->vspacing( 10 ); o->vspacing( 5 );
o->hspacing( 10 ); o->hspacing( 5 );
o->end(); o->end();
} }
o->resizable( 0 ); o->resizable( 0 );
@ -118,11 +103,10 @@ Module_Parameter_Editor::Module_Parameter_Editor ( Module *module ) : Fl_Double_
} }
o->end(); o->end();
} }
resizable(control_scroll);
end(); end();
// draw();
make_controls(); make_controls();
} }
@ -154,7 +138,27 @@ Module_Parameter_Editor::make_controls ( void )
Fl_Color bc = FL_BACKGROUND2_COLOR; Fl_Color bc = FL_BACKGROUND2_COLOR;
controls_by_port.resize( module->control_input.size() ); controls_by_port.resize( module->control_input.size() );
if ( mode_choice->value() == 1 )
{
control_pack->flow(false);
control_pack->type( FL_VERTICAL );
control_pack->size( 450, 24 );
}
else if ( mode_choice->value() == 2 )
{
control_pack->flow(false);
control_pack->type( FL_HORIZONTAL );
control_pack->size( 24, 350 );
}
else if ( mode_choice->value() == 0 )
{
control_pack->flow(true);
control_pack->type( FL_HORIZONTAL );
control_pack->size( 700, 50 );
}
for ( unsigned int i = 0; i < module->control_input.size(); ++i ) for ( unsigned int i = 0; i < module->control_input.size(); ++i )
{ {
Fl_Widget *w; Fl_Widget *w;
@ -165,16 +169,16 @@ Module_Parameter_Editor::make_controls ( void )
/* continue; */ /* continue; */
if ( !strcasecmp( "Azimuth", p->name() ) && if ( !strcasecmp( "Azimuth", p->name() ) &&
180.0f == p->hints.maximum && 180.0f == p->hints.maximum &&
-180.0f == p->hints.minimum ) -180.0f == p->hints.minimum )
{ {
azimuth_port_number = i; azimuth_port_number = i;
azimuth_value = p->control_value(); azimuth_value = p->control_value();
continue; continue;
} }
else if ( !strcasecmp( "Elevation", p->name() ) && else if ( !strcasecmp( "Elevation", p->name() ) &&
90.0f == p->hints.maximum && 90.0f == p->hints.maximum &&
-90.0f == p->hints.minimum ) -90.0f == p->hints.minimum )
{ {
elevation_port_number = i; elevation_port_number = i;
elevation_value = p->control_value(); elevation_value = p->control_value();
@ -194,15 +198,17 @@ Module_Parameter_Editor::make_controls ( void )
o->selection_color( fc ); o->selection_color( fc );
o->type( FL_TOGGLE_BUTTON ); o->type( FL_TOGGLE_BUTTON );
o->value( p->control_value() ); o->value( p->control_value() );
o->align(FL_ALIGN_TOP);
} }
else if ( p->hints.type == Module::Port::Hints::INTEGER ) else if ( p->hints.type == Module::Port::Hints::INTEGER )
{ {
Fl_Counter *o = new Fl_Counter(0, 0, 58, 24, p->name() ); Fl_Counter *o = new Fl_Counter(0, 0, 58, 24, p->name() );
w = o; w = o;
o->type(1); o->type(1);
o->step(1); o->step(1);
o->align(FL_ALIGN_TOP);
if ( p->hints.ranged ) if ( p->hints.ranged )
{ {
@ -230,6 +236,7 @@ Module_Parameter_Editor::make_controls ( void )
o->color( bc ); o->color( bc );
o->selection_color( fc ); o->selection_color( fc );
o->value( p->control_value() ); o->value( p->control_value() );
o->align(FL_ALIGN_TOP);
o->precision( 2 ); o->precision( 2 );
/* a couple of plugins have ridiculously small units */ /* a couple of plugins have ridiculously small units */
@ -247,7 +254,8 @@ Module_Parameter_Editor::make_controls ( void )
{ {
o->type( FL_HORIZONTAL ); o->type( FL_HORIZONTAL );
o->size( 120, 24 ); o->align( FL_ALIGN_RIGHT );
o->size( 300, 24 );
if ( p->hints.ranged ) if ( p->hints.ranged )
{ {
o->minimum( p->hints.minimum ); o->minimum( p->hints.minimum );
@ -257,8 +265,9 @@ Module_Parameter_Editor::make_controls ( void )
else else
{ {
o->type( FL_VERTICAL ); o->type( FL_VERTICAL );
o->align(FL_ALIGN_TOP);
o->size( 24, 120 ); o->size( 24, 300 );
/* 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 );
@ -279,6 +288,8 @@ Module_Parameter_Editor::make_controls ( void )
} }
} }
// w->align(FL_ALIGN_TOP);
w->labelsize( 10 );
controls_by_port[i] = w; controls_by_port[i] = w;
@ -286,8 +297,6 @@ Module_Parameter_Editor::make_controls ( void )
Fl_Button *bound; Fl_Button *bound;
w->align(FL_ALIGN_TOP);
w->labelsize( 10 );
_callback_data.push_back( callback_data( this, i ) ); _callback_data.push_back( callback_data( this, i ) );
@ -310,6 +319,7 @@ Module_Parameter_Editor::make_controls ( void )
o->callback( cb_bound_handle, &_callback_data.back() ); o->callback( cb_bound_handle, &_callback_data.back() );
} }
// flg->resizable(w);
o->resizable( 0 ); o->resizable( 0 );
o->end(); o->end();
@ -317,9 +327,19 @@ Module_Parameter_Editor::make_controls ( void )
flg->set_visible_focus(); flg->set_visible_focus();
flg->position( o->x(), o->y() ); flg->position( o->x(), o->y() );
bound->position( o->x(), flg->y() + flg->h() );
o->size( flg->w(), flg->h() + bound->h() ); 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->init_sizes();
// o->resizable(flg);
} }
if (! p->hints.visible ) if (! p->hints.visible )
@ -367,13 +387,18 @@ Module_Parameter_Editor::make_controls ( void )
update_control_visibility(); update_control_visibility();
int width = control_pack->max_width() + 100; control_pack->dolayout();
int height = control_pack->h() + 50;
int width = control_pack->w() + 100;
int height = control_pack->h() + 60;
if ( width < _min_width ) if ( width < _min_width )
width = _min_width; width = _min_width;
main_pack->size( width, height ); control_pack->parent()->size( control_pack->w() + 100, control_pack->h() );
control_scroll->scroll_to(0, 0 );
size( width, height ); size( width, height );
size_range( width, height, width, height ); size_range( width, height, width, height );
} }

View File

@ -26,6 +26,7 @@ class Fl_Flowpack;
class Module; class Module;
class Fl_Menu_Button; class Fl_Menu_Button;
class Panner; class Panner;
class Fl_Scroll;
#include <vector> #include <vector>
#include <list> #include <list>
@ -75,8 +76,8 @@ class Module_Parameter_Editor : public Fl_Double_Window
void set_value (int i, float value ); void set_value (int i, float value );
void bind_control ( int i ); void bind_control ( int i );
void make_controls ( void ); void make_controls ( void );
Fl_Pack *main_pack; 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;

View File

@ -124,7 +124,12 @@ Transport::Transport ( int X, int Y, int W, int H, const char *L )
o->color2( fl_color_average( FL_GRAY, FL_BLUE, 0.50 ) ); o->color2( fl_color_average( FL_GRAY, FL_BLUE, 0.50 ) );
o->tooltip( "When active, the next playback will be done in freewheeling mode" ); o->tooltip( "When active, the next playback will be done in freewheeling mode" );
type( Fl_Pack::HORIZONTAL );
flowdown( true ); flowdown( true );
vspacing( 1 );
hspacing( 1 );
dolayout();
} }