Mixer: GUI Cleanups. Also, permit moving of strips to the left/right.

pull/3/head
Jonathan Moore Liles 2010-01-11 23:23:40 -06:00
parent 0e33c199cf
commit 6d6672e97a
8 changed files with 205 additions and 79 deletions

View File

@ -23,6 +23,8 @@
* off label and "bar" the on. Obviously you should make sure that
* each label will fit. */
#pragma once
#include <FL/Fl_Button.H>
#include <stdlib.h>

View File

@ -74,6 +74,8 @@
#include "Mixer_Strip.H"
#include <dsp.h>
#include <FL/Fl_Flip_Button.H>
std::vector <Module::Port> Chain::port;
@ -85,6 +87,7 @@ void
Chain::get ( Log_Entry &e ) const
{
e.add( ":strip", strip() );
e.add( ":tab", tab_button->value() ? "controls" : "chain" );
}
void
@ -96,7 +99,12 @@ Chain::set ( Log_Entry &e )
e.get( i, &s, &v );
if ( ! strcmp( s, ":strip" ) )
if ( ! strcmp( s, ":tab" ) )
{
tab_button->value( strcmp( v, "controls" ) == 0 );
tab_button->do_callback();
}
else if ( ! strcmp( s, ":strip" ) )
{
int i;
sscanf( v, "%X", &i );
@ -134,30 +142,35 @@ Chain::Chain ( ) : Fl_Group( 0, 0, 100, 100, "")
labelsize( 10 );
align( FL_ALIGN_TOP );
{ Fl_Tabs *o = tabs = new Fl_Tabs( X, Y, W, H );
{ Fl_Group *o = new Fl_Group( X, Y + 24, W, H - 24, "Chain" );
o->box( FL_FLAT_BOX );
o->labelsize( 9 );
{ Fl_Pack *o = modules_pack = new Fl_Pack( X, Y + 24, W, H - 24 );
o->type( Fl_Pack::VERTICAL );
o->spacing( 10 );
o->end();
}
{ Fl_Flip_Button* o = tab_button = new Fl_Flip_Button( X, Y, W, 16, "chain/controls");
o->type(1);
o->labelsize( 12 );
o->callback( cb_handle, this );
}
Y += 18;
H -= 18;
{ Fl_Group *o = chain_tab = new Fl_Group( X, Y, W, H, "" );
o->labeltype( FL_NO_LABEL );
o->box( FL_FLAT_BOX );
{ Fl_Pack *o = modules_pack = new Fl_Pack( X, Y, W, H );
o->type( Fl_Pack::VERTICAL );
o->spacing( 10 );
o->end();
}
{ Fl_Group *o = new Fl_Group( X, Y + 24, W, H - 24, "Controls" );
o->labelsize( 9 );
o->hide();
{ Fl_Scroll *o = new Fl_Scroll( X, Y + 24, W, H - 24 );
o->type( Fl_Scroll::VERTICAL );
{ Fl_Flowpack *o = controls_pack = new Fl_Flowpack( X, Y + 24, W, H - 24 );
o->hspacing( 10 );
o->vspacing( 10 );
o->end();
}
{ Fl_Group *o = control_tab = new Fl_Group( X, Y, W, H, "" );
o->labeltype( FL_NO_LABEL );
o->hide();
{ Fl_Scroll *o = new Fl_Scroll( X, Y, W, H );
o->type( Fl_Scroll::VERTICAL );
{ Fl_Flowpack *o = controls_pack = new Fl_Flowpack( X, Y, W, H );
o->hspacing( 10 );
o->vspacing( 10 );
// o->box( FL_FLAT_BOX );
// o->color( FL_RED );
o->end();
Fl_Group::current()->resizable( o );
}
o->end();
Fl_Group::current()->resizable( o );
}
@ -165,6 +178,7 @@ Chain::Chain ( ) : Fl_Group( 0, 0, 100, 100, "")
Fl_Group::current()->resizable( o );
}
o->end();
o->hide();
Fl_Group::current()->resizable( o );
}
@ -228,6 +242,22 @@ Chain::initialize_with_default ( void )
void Chain::cb_handle(Fl_Widget* o) {
if ( o = tab_button )
{
Fl_Flip_Button *fb = (Fl_Flip_Button*)o;
if ( fb->value() == 0 )
{
control_tab->hide();
chain_tab->show();
}
else
{
chain_tab->hide();
control_tab->show();
}
}
/* if ( o == head_button ) */
/* { */
/* Module *m = Module::pick_plugin(); */
@ -602,7 +632,8 @@ Chain::draw ( void )
{
Fl_Group::draw();
if ( 0 == strcmp( "Chain", tabs->value()->label() ) )
/* if ( 0 == strcmp( "Chain", tabs->value()->label() ) ) */
if ( chain_tab->visible() )
for ( int i = 0; i < modules(); ++i )
draw_connections( module( i ) );
}

View File

@ -31,13 +31,17 @@
class Mixer_Strip;
class Fl_Flowpack;
class Fl_Tabs;
class Fl_Flip_Button;
class Chain : public Fl_Group, public Loggable {
Fl_Pack *modules_pack;
Fl_Flowpack *controls_pack;
Fl_Tabs *tabs;
Fl_Flip_Button *tab_button;
Fl_Group *chain_tab;
Fl_Group *control_tab;
void cb_handle(Fl_Widget*);
static void cb_handle(Fl_Widget*, void*);

View File

@ -164,6 +164,44 @@ void Mixer::add ( Mixer_Strip *ms )
// redraw();
}
void
Mixer::insert ( Mixer_Strip *ms, Mixer_Strip *before )
{
engine->lock();
mixer_strips->remove( ms );
mixer_strips->insert( *ms, before );
engine->unlock();
scroll->redraw();
}
void
Mixer::insert ( Mixer_Strip *ms, int i )
{
Mixer_Strip *before = (Mixer_Strip*)mixer_strips->child( i );
insert( ms, before);
}
void
Mixer::move_left ( Mixer_Strip *ms )
{
int i = mixer_strips->find( ms );
if ( i > 0 )
insert( ms, i - 1 );
}
void
Mixer::move_right ( Mixer_Strip *ms )
{
int i = mixer_strips->find( ms );
if ( i < mixer_strips->children() - 1 )
insert( ms, i + 2 );
}
void Mixer::remove ( Mixer_Strip *ms )
{
MESSAGE( "Remove mixer strip \"%s\"", ms->name() );
@ -175,6 +213,7 @@ void Mixer::remove ( Mixer_Strip *ms )
engine->unlock();
delete ms;
parent()->redraw();
}

View File

@ -57,6 +57,10 @@ public:
void process ( unsigned int nframes );
void add ( Mixer_Strip *ms );
void remove ( Mixer_Strip *ms );
void move_left ( Mixer_Strip *ms );
void move_right ( Mixer_Strip *ms );
void insert ( Mixer_Strip *ms, Mixer_Strip *before );
void insert ( Mixer_Strip *ms, int i );
bool contains ( Mixer_Strip *ms );
bool save ( void );

View File

@ -39,8 +39,8 @@
#include "debug.h"
#include <FL/Fl_Tabs.H>
#include "FL/Fl_Flowpack.H"
#include <FL/fl_ask.H>
#include "Mixer.H"
#include "Chain.H"
@ -59,6 +59,7 @@ Mixer_Strip::get ( Log_Entry &e ) const
{
e.add( ":name", name() );
e.add( ":width", prepost_button->value() ? "wide" : "narrow" );
e.add( ":tab", tab_button->value() ? "signal" : "fader" );
e.add( ":color", (unsigned long)color());
}
@ -74,7 +75,15 @@ Mixer_Strip::set ( Log_Entry &e )
if ( ! strcmp( s, ":name" ) )
name( v );
else if ( ! strcmp( s, ":width" ) )
prepost_button->value( strcmp( v, "pre" ) == 0 );
{
prepost_button->value( strcmp( v, "wide" ) == 0 );
prepost_button->do_callback();
}
else if ( ! strcmp( s, ":tab" ) )
{
tab_button->value( strcmp( v, "signal" ) == 0 );
tab_button->do_callback();
}
else if ( ! strcmp( s, ":color" ) )
{
color( (Fl_Color)atoll( v ) );
@ -104,7 +113,7 @@ Mixer_Strip::chain ( Chain *c )
c->strip( this );
Fl_Group *g = signal_group;
Fl_Group *g = signal_tab;
c->resize( g->x(), g->y(), g->w(), g->h() );
g->add( c );
@ -154,12 +163,37 @@ Mixer_Strip::~Mixer_Strip ( )
log_destroy();
}
void Mixer_Strip::cb_handle(Fl_Widget* o) {
// parent()->parent()->damage( FL_DAMAGE_ALL, x(), y(), w(), h() );
if ( o == close_button )
((Mixer*)parent())->remove( this );
if ( o == tab_button )
{
if ( tab_button->value() == 0 )
{
fader_tab->show();
signal_tab->hide();
}
else
{
signal_tab->show();
fader_tab->hide();
}
}
else if ( o == left_button )
{
mixer->move_left( this );
}
else if ( o == right_button )
{
mixer->move_right( this );
}
else if ( o == close_button )
{
if ( Fl::event_shift() || 1 == fl_choice( "Are you sure you want to remove this strip?\n\n(this action cannot be undone)", "Cancel", "Remove", NULL ) )
{
((Mixer*)parent())->remove( this );
}
}
else if ( o == name_field )
name( name_field->value() );
else if ( o == prepost_button )
@ -169,7 +203,8 @@ void Mixer_Strip::cb_handle(Fl_Widget* o) {
else
size( 120, h() );
parent()->parent()->redraw();
if ( parent() )
parent()->parent()->redraw();
}
}
@ -269,6 +304,14 @@ Mixer_Strip::init ( )
}
{ Fl_Scalepack *o = new Fl_Scalepack( 7, 143, 110, 25 );
o->type( Fl_Pack::HORIZONTAL );
{ Fl_Button* o = left_button = new Fl_Button(7, 143, 35, 25, "@<-");
o->tooltip( "Move left" );
o->type(0);
o->labelsize(10);
o->when( FL_WHEN_RELEASE );
o->callback( ((Fl_Callback*)cb_handle), this );
} // Fl_Button* o
{ Fl_Button* o = close_button = new Fl_Button(7, 143, 35, 25, "X");
o->tooltip( "Remove strip" );
o->type(0);
@ -279,22 +322,29 @@ Mixer_Strip::init ( )
o->when( FL_WHEN_RELEASE );
o->callback( ((Fl_Callback*)cb_handle), this );
} // Fl_Button* o
{ Fl_Button* o = right_button = new Fl_Button(7, 143, 35, 25, "@->");
o->tooltip( "Move right" );
o->type(0);
o->labelsize(10);
o->when( FL_WHEN_RELEASE );
o->callback( ((Fl_Callback*)cb_handle), this );
} // Fl_Button* o
o->end();
} // Fl_Group* o
{ Fl_Flip_Button* o = prepost_button = new Fl_Flip_Button(61, 183, 45, 22, "narrow/wide");
o->type(1);
// o->box(FL_ROUNDED_BOX);
o->box( FL_THIN_DOWN_BOX );
o->color((Fl_Color)106);
o->selection_color((Fl_Color)65);
o->labeltype(FL_NORMAL_LABEL);
o->labelfont(0);
o->labelsize(14);
o->labelcolor(FL_FOREGROUND_COLOR);
o->align(FL_ALIGN_CLIP);
o->callback( ((Fl_Callback*)cb_handle), this );
o->when(FL_WHEN_RELEASE);
} // Fl_Flip_Button* o
{ Fl_Flip_Button* o = tab_button = new Fl_Flip_Button(61, 183, 45, 22, "fader/signal");
o->type(1);
o->labelsize( 14 );
o->callback( cb_handle, this );
o->when(FL_WHEN_RELEASE);
}
// { Fl_Pack* o = new Fl_Pack(8, 208, 103, 471);
// { Fl_Pack* o = gain_pack = new Fl_Pack(8, 208, 103, 516 );
@ -303,48 +353,33 @@ Mixer_Strip::init ( )
Fl_Pack *fader_pack;
{ Fl_Tabs *o = new Fl_Tabs( 4, 104, 110, 330 );
o->clip_children( 1 );
o->box( FL_NO_BOX );
{ Fl_Group *o = new Fl_Group( 4, 114, 110, 330, "Fader" );
o->labelsize( 9 );
o->box( FL_NO_BOX );
{ Fl_Pack* o = fader_pack = new Fl_Pack(4, 116, 103, 330 );
o->spacing( 20 );
o->type( Fl_Pack::HORIZONTAL );
{ Controller_Module *o = gain_controller = new Controller_Module( true );
// o->chain( _chain );
o->pad( false );
// o->connect_to( &gain_module->control_input[0] );
o->size( 33, 0 );
}
{ Meter_Indicator_Module *o = meter_indicator = new Meter_Indicator_Module( true );
// o->chain( _chain );
o->pad( false );
// o->connect_to( &meter_module->control_output[0] );
o->size( 58, 0 );
o->clip_children( 0 );
Fl_Group::current()->resizable(o);
}
o->end();
{ Fl_Group *o = fader_tab = new Fl_Group( 7, 115, 105, 330, "Fader" );
o->labeltype( FL_NO_LABEL );
{ Fl_Pack* o = fader_pack = new Fl_Pack(7, 116, 103, 330 );
o->spacing( 20 );
o->type( Fl_Pack::HORIZONTAL );
{ Controller_Module *o = gain_controller = new Controller_Module( true );
o->pad( false );
o->size( 33, 0 );
}
{ Meter_Indicator_Module *o = meter_indicator = new Meter_Indicator_Module( true );
o->pad( false );
o->size( 58, 0 );
o->clip_children( 0 );
Fl_Group::current()->resizable(o);
} // Fl_Group* o
}
o->end();
Fl_Group::current()->resizable(o);
}
{ Fl_Group *o = signal_group = new Fl_Group( 4, 114, 110, 330, "Signal" );
o->labelsize( 9 );
o->hide();
o->end();
}
} // Fl_Group* o
o->end();
Fl_Group::current()->resizable(o);
}
// log_create();
{ Fl_Group *o = signal_tab = new Fl_Group( 7, 115, 105, 330 );
o->labeltype( FL_NO_LABEL );
o->hide();
o->end();
}
{ Fl_Pack *o = panner_pack = new Fl_Pack( 2, 440, 114, 40 );
o->spacing( 2 );
o->type( Fl_Pack::VERTICAL );

View File

@ -46,6 +46,7 @@ class Fl_Flowpack;
class Controller_Module;
class Meter_Indicator_Module;
class Module;
class Fl_Flip_Button;
class Mixer_Strip : public Fl_Group, public Loggable {
@ -58,11 +59,15 @@ public:
// Fl_Value_Slider *gain_slider;
Fl_Flip_Button *prepost_button;
Fl_Flip_Button *tab_button;
Fl_Button *close_button;
Fl_Button *left_button;
Fl_Button *right_button;
Fl_Input *name_field;
Fl_Flowpack *controls_pack;
Fl_Group *signal_group;
Fl_Group *signal_tab;
Fl_Group *fader_tab;
Fl_Pack *panner_pack;
Chain *_chain;
@ -84,6 +89,8 @@ private:
void cb_handle(Fl_Widget*);
static void cb_handle(Fl_Widget*, void*);
void set_tab ( void );
void update_port_names ( void );
protected:

View File

@ -44,7 +44,7 @@ Fl_Single_Window *main_window;
#include <FL/Boxtypes.H>
#include "Loggable.H"
#include <FL/Fl_Tooltip.H>
#include <FL/fl_ask.H>
/* for registration */
#include "Module.H"
@ -121,7 +121,11 @@ main ( int argc, char **argv )
/* Loggable::open( name ); */
MESSAGE( "Loading \"%s\"", argv[1] );
Project::open( argv[1] );
if ( int err = Project::open( argv[1] ) )
{
fl_alert( "Error opening project specified on commandline: %s", Project::errstr( err ) );
}
}
else
{