2008-02-20 06:57:14 +01:00
|
|
|
|
|
|
|
/*******************************************************************************/
|
|
|
|
/* Copyright (C) 2008 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. */
|
|
|
|
/*******************************************************************************/
|
|
|
|
|
|
|
|
#include "Track.H"
|
|
|
|
|
2008-04-19 06:16:21 +02:00
|
|
|
#include "Transport.H"
|
2008-03-09 22:18:22 +01:00
|
|
|
|
2008-05-22 09:05:49 +02:00
|
|
|
/* #include "Port.H" */
|
2008-03-09 22:18:22 +01:00
|
|
|
|
2008-04-21 16:57:30 +02:00
|
|
|
#include "../FL/Fl_Sometimes_Input.H"
|
2008-04-21 22:24:08 +02:00
|
|
|
#include <FL/fl_ask.H>
|
2008-04-26 10:42:44 +02:00
|
|
|
#include <FL/Fl_Color_Chooser.H>
|
|
|
|
// #include <FL/fl_draw.H>
|
|
|
|
#include <FL/Fl.H>
|
2008-04-21 16:57:30 +02:00
|
|
|
|
2008-05-26 06:08:25 +02:00
|
|
|
#include "Engine/Engine.H" // for lock()
|
|
|
|
|
2008-05-05 01:06:36 +02:00
|
|
|
#include "Control_Sequence.H"
|
|
|
|
#include "Annotation_Sequence.H"
|
|
|
|
|
2008-04-25 07:15:08 +02:00
|
|
|
int Track::_soloing = 0;
|
|
|
|
|
2008-04-26 07:33:04 +02:00
|
|
|
const char *Track::capture_format = "Wav 24";
|
|
|
|
|
2008-02-21 04:40:20 +01:00
|
|
|
void
|
2008-05-19 05:01:09 +02:00
|
|
|
Track::cb_input_field ( Fl_Widget *, void *v )
|
2008-02-21 04:40:20 +01:00
|
|
|
{
|
2008-04-19 06:16:21 +02:00
|
|
|
((Track*)v)->cb_input_field();
|
2008-02-21 04:40:20 +01:00
|
|
|
}
|
|
|
|
|
2008-04-19 06:16:21 +02:00
|
|
|
void
|
|
|
|
Track::cb_button ( Fl_Widget *w, void *v )
|
2008-03-07 03:29:02 +01:00
|
|
|
{
|
2008-04-19 06:16:21 +02:00
|
|
|
((Track*)v)->cb_button( w );
|
2008-03-07 03:29:02 +01:00
|
|
|
}
|
|
|
|
|
2008-03-09 19:28:48 +01:00
|
|
|
|
2008-02-20 06:57:14 +01:00
|
|
|
void
|
2008-04-19 06:16:21 +02:00
|
|
|
Track::cb_input_field ( void )
|
2008-02-20 06:57:14 +01:00
|
|
|
{
|
2008-04-19 06:16:21 +02:00
|
|
|
log_start();
|
2008-02-26 05:58:15 +01:00
|
|
|
|
2008-04-21 20:01:03 +02:00
|
|
|
name( name_field->value() );
|
2008-02-20 08:53:54 +01:00
|
|
|
|
2008-04-19 06:16:21 +02:00
|
|
|
log_end();
|
|
|
|
}
|
2008-02-20 08:53:54 +01:00
|
|
|
|
2008-04-19 06:16:21 +02:00
|
|
|
void
|
|
|
|
Track::cb_button ( Fl_Widget *w )
|
|
|
|
{
|
2008-03-12 17:06:13 +01:00
|
|
|
|
2008-04-19 06:16:21 +02:00
|
|
|
if ( w == record_button )
|
2008-03-12 17:06:13 +01:00
|
|
|
{
|
2008-04-25 07:15:08 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
if ( w == mute_button )
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
if ( w == solo_button )
|
|
|
|
{
|
|
|
|
if ( solo_button->value() )
|
|
|
|
++_soloing;
|
2008-04-19 06:16:21 +02:00
|
|
|
else
|
2008-04-25 07:15:08 +02:00
|
|
|
--_soloing;
|
2008-03-12 17:06:13 +01:00
|
|
|
}
|
2008-04-19 06:16:21 +02:00
|
|
|
else
|
|
|
|
if ( w == take_menu )
|
2008-03-07 03:29:02 +01:00
|
|
|
{
|
2008-04-19 06:16:21 +02:00
|
|
|
int v = take_menu->value();
|
2008-03-07 03:29:02 +01:00
|
|
|
|
2008-04-19 06:16:21 +02:00
|
|
|
switch ( v )
|
|
|
|
{
|
|
|
|
case 0: /* show all takes */
|
|
|
|
show_all_takes( take_menu->menu()[ v ].value() );
|
|
|
|
return;
|
|
|
|
case 1: /* new */
|
2008-05-07 18:18:57 +02:00
|
|
|
sequence( (Audio_Sequence*)sequence()->clone_empty() );
|
2008-04-19 06:16:21 +02:00
|
|
|
return;
|
|
|
|
}
|
2008-03-09 19:28:48 +01:00
|
|
|
|
2008-04-19 06:16:21 +02:00
|
|
|
const char *s = take_menu->menu()[ v ].text;
|
2008-03-10 02:07:04 +01:00
|
|
|
|
2008-04-19 06:16:21 +02:00
|
|
|
for ( int i = takes->children(); i--; )
|
|
|
|
{
|
2008-05-05 07:29:39 +02:00
|
|
|
Audio_Sequence *t = (Audio_Sequence*)takes->child( i );
|
2008-04-19 06:16:21 +02:00
|
|
|
if ( ! strcmp( s, t->name() ) )
|
|
|
|
{
|
2008-05-07 18:18:57 +02:00
|
|
|
sequence( t );
|
2008-04-19 06:16:21 +02:00
|
|
|
redraw();
|
|
|
|
break;
|
|
|
|
}
|
2008-03-10 02:07:04 +01:00
|
|
|
}
|
|
|
|
}
|
2008-04-19 06:16:21 +02:00
|
|
|
}
|
2008-03-10 02:07:04 +01:00
|
|
|
|
2008-04-20 23:46:47 +02:00
|
|
|
void
|
|
|
|
Track::init ( void )
|
2008-04-19 06:16:21 +02:00
|
|
|
{
|
2008-05-07 18:18:57 +02:00
|
|
|
_sequence = NULL;
|
2008-04-19 06:16:21 +02:00
|
|
|
_name = NULL;
|
|
|
|
_selected = false;
|
|
|
|
_show_all_takes = false;
|
|
|
|
_size = 1;
|
2008-03-12 17:06:13 +01:00
|
|
|
|
2008-04-30 05:50:58 +02:00
|
|
|
record_ds = NULL;
|
|
|
|
playback_ds = NULL;
|
|
|
|
|
2008-04-19 07:09:42 +02:00
|
|
|
labeltype( FL_NO_LABEL );
|
|
|
|
|
2008-05-27 05:32:35 +02:00
|
|
|
// clear_visible_focus();
|
|
|
|
|
2008-04-20 23:46:47 +02:00
|
|
|
Fl_Group::size( timeline->w(), height() );
|
2008-03-07 03:29:02 +01:00
|
|
|
|
2008-04-19 06:16:21 +02:00
|
|
|
Track *o = this;
|
|
|
|
o->box( FL_THIN_UP_BOX );
|
|
|
|
{
|
2008-04-29 19:35:45 +02:00
|
|
|
Fl_Group *o = new Fl_Group( 0, 0, 149, 70 );
|
2008-04-19 06:16:21 +02:00
|
|
|
o->color( ( Fl_Color ) 53 );
|
2008-04-29 19:35:45 +02:00
|
|
|
|
2008-04-19 06:16:21 +02:00
|
|
|
{
|
2008-04-21 16:57:30 +02:00
|
|
|
Fl_Input *o = name_field = new Fl_Sometimes_Input( 2, 2, 144, 24 );
|
2008-04-27 05:50:58 +02:00
|
|
|
o->color( FL_BACKGROUND_COLOR );
|
2008-04-19 06:16:21 +02:00
|
|
|
o->labeltype( FL_NO_LABEL );
|
|
|
|
o->labelcolor( FL_GRAY0 );
|
2008-04-27 05:50:58 +02:00
|
|
|
o->textcolor( FL_FOREGROUND_COLOR );
|
2008-03-09 18:38:36 +01:00
|
|
|
|
2008-04-19 06:16:21 +02:00
|
|
|
o->callback( cb_input_field, (void*)this );
|
|
|
|
}
|
2008-03-07 03:29:02 +01:00
|
|
|
|
2008-04-19 06:16:21 +02:00
|
|
|
{
|
|
|
|
Fl_Group *o = controls = new Fl_Group( 2, 28, 149, 24 );
|
2008-03-07 03:29:02 +01:00
|
|
|
|
2008-04-19 06:16:21 +02:00
|
|
|
{
|
|
|
|
Fl_Button *o = record_button =
|
|
|
|
new Fl_Button( 6, 28, 26, 24, "@circle" );
|
|
|
|
o->type( 1 );
|
|
|
|
o->box( FL_THIN_UP_BOX );
|
|
|
|
o->color( FL_LIGHT1 );
|
|
|
|
o->selection_color( FL_RED );
|
|
|
|
o->labelsize( 8 );
|
|
|
|
o->callback( cb_button, this );
|
|
|
|
}
|
|
|
|
{
|
|
|
|
Fl_Button *o = mute_button =
|
|
|
|
new Fl_Button( 35, 28, 26, 24, "m" );
|
|
|
|
o->type( 1 );
|
|
|
|
o->box( FL_THIN_UP_BOX );
|
|
|
|
o->color( FL_LIGHT1 );
|
|
|
|
o->labelsize( 11 );
|
|
|
|
o->callback( cb_button, this );
|
|
|
|
}
|
|
|
|
{
|
|
|
|
Fl_Button *o = solo_button =
|
|
|
|
new Fl_Button( 66, 28, 26, 24, "s" );
|
|
|
|
o->type( 1 );
|
|
|
|
o->box( FL_THIN_UP_BOX );
|
|
|
|
o->color( FL_LIGHT1 );
|
|
|
|
o->labelsize( 11 );
|
|
|
|
o->callback( cb_button, this );
|
|
|
|
}
|
|
|
|
{
|
|
|
|
Fl_Menu_Button *o = take_menu =
|
|
|
|
new Fl_Menu_Button( 97, 28, 47, 24, "T" );
|
|
|
|
o->box( FL_THIN_UP_BOX );
|
|
|
|
o->color( FL_LIGHT1 );
|
|
|
|
o->align( FL_ALIGN_LEFT | FL_ALIGN_INSIDE );
|
|
|
|
o->callback( cb_button, this );
|
2008-03-07 03:29:02 +01:00
|
|
|
|
2008-04-19 06:16:21 +02:00
|
|
|
o->add( "Show all takes", 0, 0, 0, FL_MENU_TOGGLE );
|
|
|
|
o->add( "New", 0, 0, 0, FL_MENU_DIVIDER );
|
2008-03-07 03:29:02 +01:00
|
|
|
}
|
2008-04-19 06:16:21 +02:00
|
|
|
o->end();
|
2008-03-07 03:29:02 +01:00
|
|
|
}
|
2008-02-28 12:55:09 +01:00
|
|
|
|
2008-04-19 06:16:21 +02:00
|
|
|
{
|
2008-04-29 19:35:45 +02:00
|
|
|
Fl_Box *o = new Fl_Box( 0, 72, 149, 38 );
|
2008-04-28 06:42:05 +02:00
|
|
|
o->box( FL_NO_BOX );
|
2008-04-19 06:16:21 +02:00
|
|
|
Fl_Group::current()->resizable( o );
|
|
|
|
}
|
2008-02-20 06:57:14 +01:00
|
|
|
|
2008-04-19 06:16:21 +02:00
|
|
|
o->size( Track::width(), h() );
|
|
|
|
o->end();
|
|
|
|
}
|
|
|
|
{
|
|
|
|
Fl_Pack *o = pack = new Fl_Pack( width(), 0, 1006, 115 );
|
|
|
|
o->labeltype( FL_NO_LABEL );
|
|
|
|
o->resize( x() + width(), y(), w() - width(), h() );
|
2008-04-23 04:22:46 +02:00
|
|
|
|
|
|
|
resizable( o );
|
2008-02-20 07:35:29 +01:00
|
|
|
|
2008-05-05 01:06:36 +02:00
|
|
|
{
|
2008-05-07 04:01:03 +02:00
|
|
|
// Fl_Pack *o = annotation = new Fl_Pack( width(), 0, pack->w(), 0 );
|
|
|
|
Fl_Pack *o = annotation = new Fl_Pack( width(), 0, pack->w(), 1 );
|
2008-05-05 01:06:36 +02:00
|
|
|
o->end();
|
|
|
|
}
|
|
|
|
|
2008-04-19 06:16:21 +02:00
|
|
|
{
|
2008-05-06 04:56:26 +02:00
|
|
|
Fl_Pack *o = control = new Fl_Pack( width(), 0, pack->w(), 0 );
|
2008-04-19 06:16:21 +02:00
|
|
|
o->end();
|
|
|
|
}
|
2008-03-03 19:59:05 +01:00
|
|
|
|
|
|
|
{
|
2008-05-06 04:56:26 +02:00
|
|
|
Fl_Pack *o = takes = new Fl_Pack( width(), 0, pack->w(), 0 );
|
2008-04-19 06:16:21 +02:00
|
|
|
o->end();
|
|
|
|
o->hide();
|
2008-03-03 19:59:05 +01:00
|
|
|
}
|
|
|
|
|
2008-04-19 06:16:21 +02:00
|
|
|
o->end();
|
|
|
|
}
|
|
|
|
end();
|
2008-03-03 19:59:05 +01:00
|
|
|
|
2008-04-20 23:46:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-21 20:01:03 +02:00
|
|
|
Track::Track ( const char *L, int channels ) :
|
|
|
|
Fl_Group ( 0, 0, 0, 0, 0 )
|
2008-04-20 23:46:47 +02:00
|
|
|
{
|
|
|
|
init();
|
|
|
|
|
|
|
|
if ( L )
|
|
|
|
name( L );
|
2008-04-19 07:26:43 +02:00
|
|
|
|
2008-04-26 14:07:39 +02:00
|
|
|
color( (Fl_Color)rand() );
|
|
|
|
|
2008-04-21 20:01:03 +02:00
|
|
|
configure_inputs( channels );
|
|
|
|
configure_outputs( channels );
|
|
|
|
|
2008-04-19 06:16:21 +02:00
|
|
|
log_create();
|
|
|
|
}
|
2008-03-03 19:59:05 +01:00
|
|
|
|
2008-04-19 06:16:21 +02:00
|
|
|
Track::~Track ( )
|
2008-02-20 07:35:29 +01:00
|
|
|
{
|
2008-05-28 02:36:17 +02:00
|
|
|
log_destroy();
|
|
|
|
|
2008-05-04 00:50:32 +02:00
|
|
|
timeline->remove_track( this );
|
|
|
|
|
2008-05-06 05:24:43 +02:00
|
|
|
/* give up our ports */
|
|
|
|
configure_inputs( 0 );
|
|
|
|
configure_outputs( 0 );
|
|
|
|
|
2008-05-28 02:36:17 +02:00
|
|
|
_sequence = NULL;
|
|
|
|
takes = NULL;
|
|
|
|
control = NULL;
|
|
|
|
annotation = NULL;
|
2008-05-07 04:32:37 +02:00
|
|
|
|
|
|
|
if ( _name )
|
|
|
|
free( _name );
|
2008-02-20 07:35:29 +01:00
|
|
|
}
|
|
|
|
|
2008-04-19 06:16:21 +02:00
|
|
|
|
|
|
|
static int pack_visible( Fl_Pack *p )
|
2008-03-05 20:06:41 +01:00
|
|
|
{
|
2008-04-19 06:16:21 +02:00
|
|
|
int v = 0;
|
|
|
|
for ( int i = p->children(); i--; )
|
|
|
|
if ( p->child( i )->visible() )
|
|
|
|
v++;
|
2008-03-05 20:06:41 +01:00
|
|
|
|
2008-04-19 06:16:21 +02:00
|
|
|
return v;
|
2008-03-05 20:06:41 +01:00
|
|
|
}
|
|
|
|
|
2008-04-19 06:16:21 +02:00
|
|
|
/* adjust size of widget and children */
|
2008-02-20 06:57:14 +01:00
|
|
|
void
|
2008-04-19 06:16:21 +02:00
|
|
|
Track::resize ( void )
|
2008-02-20 06:57:14 +01:00
|
|
|
{
|
2008-04-19 06:16:21 +02:00
|
|
|
for ( int i = takes->children(); i--; )
|
|
|
|
takes->child( i )->size( w(), height() );
|
|
|
|
|
2008-05-05 01:06:36 +02:00
|
|
|
for ( int i = annotation->children(); i--; )
|
|
|
|
annotation->child( i )->size( w(), 24 );
|
|
|
|
|
2008-04-19 06:16:21 +02:00
|
|
|
for ( int i = control->children(); i--; )
|
|
|
|
control->child( i )->size( w(), height() );
|
2008-02-24 11:58:16 +01:00
|
|
|
|
2008-05-06 04:56:26 +02:00
|
|
|
/* FIXME: hack! */
|
|
|
|
if ( annotation->children() )
|
|
|
|
annotation->show();
|
|
|
|
else
|
|
|
|
annotation->hide();
|
|
|
|
|
2008-04-19 06:16:21 +02:00
|
|
|
if ( _show_all_takes )
|
|
|
|
{
|
|
|
|
takes->show();
|
|
|
|
Fl_Group::size( w(), height() * ( 1 + takes->children() + pack_visible( control ) ) );
|
|
|
|
}
|
|
|
|
else
|
2008-02-20 06:57:14 +01:00
|
|
|
{
|
2008-04-19 06:16:21 +02:00
|
|
|
takes->hide();
|
|
|
|
Fl_Group::size( w(), height() * ( 1 + pack_visible( control ) ) );
|
2008-02-20 06:57:14 +01:00
|
|
|
}
|
|
|
|
|
2008-05-05 01:06:36 +02:00
|
|
|
Fl_Group::size( w(), h() + ( ( 24 ) * pack_visible( annotation ) ) );
|
|
|
|
|
2008-05-07 18:18:57 +02:00
|
|
|
if ( sequence() )
|
|
|
|
sequence()->size( w(), height() );
|
2008-02-20 06:57:14 +01:00
|
|
|
|
2008-04-19 06:16:21 +02:00
|
|
|
|
|
|
|
if ( controls->y() + controls->h() > y() + h() )
|
|
|
|
controls->hide();
|
|
|
|
else
|
|
|
|
controls->show();
|
|
|
|
|
2008-04-28 06:42:05 +02:00
|
|
|
/* FIXME: why is this necessary? */
|
2008-04-24 09:08:23 +02:00
|
|
|
if ( parent() )
|
2008-04-28 06:42:05 +02:00
|
|
|
parent()->parent()->redraw();
|
2008-02-20 06:57:14 +01:00
|
|
|
}
|
|
|
|
|
2008-02-20 08:24:56 +01:00
|
|
|
void
|
2008-04-19 06:16:21 +02:00
|
|
|
Track::size ( int v )
|
2008-02-20 08:24:56 +01:00
|
|
|
{
|
2008-04-19 06:16:21 +02:00
|
|
|
if ( v < 0 || v > 3 )
|
|
|
|
return;
|
2008-02-20 06:57:14 +01:00
|
|
|
|
2008-04-19 06:16:21 +02:00
|
|
|
_size = v;
|
2008-02-20 06:57:14 +01:00
|
|
|
|
2008-04-19 06:16:21 +02:00
|
|
|
resize();
|
|
|
|
}
|
2008-02-28 21:36:46 +01:00
|
|
|
|
2008-04-21 02:28:59 +02:00
|
|
|
|
|
|
|
void
|
2008-05-05 07:29:39 +02:00
|
|
|
Track::add ( Audio_Sequence * t )
|
2008-04-21 02:28:59 +02:00
|
|
|
{
|
|
|
|
takes->insert( *t, 0 );
|
|
|
|
if ( ! t->name() )
|
|
|
|
{
|
|
|
|
char pat[20];
|
|
|
|
snprintf( pat, sizeof( pat ), "%d", takes->children() );
|
|
|
|
t->name( strdup( pat ) );
|
|
|
|
}
|
|
|
|
|
2008-04-23 23:00:51 +02:00
|
|
|
take_menu->add( t->name() );
|
|
|
|
|
|
|
|
t->labeltype( FL_ENGRAVED_LABEL );
|
2008-04-21 02:28:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-05-05 07:29:39 +02:00
|
|
|
Track::remove ( Audio_Sequence *t )
|
2008-04-21 02:28:59 +02:00
|
|
|
{
|
2008-05-28 02:36:17 +02:00
|
|
|
if ( ! takes )
|
|
|
|
return;
|
|
|
|
|
2008-05-26 08:20:49 +02:00
|
|
|
timeline->wrlock();
|
|
|
|
|
2008-04-21 02:28:59 +02:00
|
|
|
takes->remove( t );
|
2008-04-21 05:05:25 +02:00
|
|
|
|
2008-05-26 08:20:49 +02:00
|
|
|
timeline->unlock();
|
|
|
|
|
2008-04-21 05:05:25 +02:00
|
|
|
resize();
|
|
|
|
|
2008-04-21 02:28:59 +02:00
|
|
|
// take_menu->remove( t->name() );
|
|
|
|
}
|
|
|
|
|
2008-05-26 08:20:49 +02:00
|
|
|
void
|
|
|
|
Track::remove ( Annotation_Sequence *t )
|
|
|
|
{
|
2008-05-28 02:36:17 +02:00
|
|
|
if ( ! annotation )
|
|
|
|
return;
|
|
|
|
|
2008-05-26 08:20:49 +02:00
|
|
|
annotation->remove( t );
|
|
|
|
|
|
|
|
resize();
|
|
|
|
}
|
|
|
|
|
2008-04-21 02:28:59 +02:00
|
|
|
void
|
|
|
|
Track::remove ( Control_Sequence *t )
|
|
|
|
{
|
2008-05-28 02:36:17 +02:00
|
|
|
if ( ! control )
|
|
|
|
return;
|
|
|
|
|
2008-05-26 06:08:25 +02:00
|
|
|
engine->lock();
|
|
|
|
|
2008-04-21 02:28:59 +02:00
|
|
|
control->remove( t );
|
2008-04-21 05:05:25 +02:00
|
|
|
|
2008-05-26 06:08:25 +02:00
|
|
|
engine->unlock();
|
|
|
|
|
2008-04-21 05:05:25 +02:00
|
|
|
resize();
|
2008-04-21 02:28:59 +02:00
|
|
|
}
|
|
|
|
|
2008-04-19 06:16:21 +02:00
|
|
|
void
|
2008-05-07 18:18:57 +02:00
|
|
|
Track::sequence ( Audio_Sequence * t )
|
2008-04-19 06:16:21 +02:00
|
|
|
{
|
2008-04-20 23:46:47 +02:00
|
|
|
t->track( this );
|
|
|
|
|
2008-05-07 18:18:57 +02:00
|
|
|
if ( sequence() )
|
|
|
|
add( sequence() );
|
2008-02-20 06:57:14 +01:00
|
|
|
|
2008-05-07 18:18:57 +02:00
|
|
|
_sequence = t;
|
2008-05-05 01:06:36 +02:00
|
|
|
pack->insert( *t, 1 );
|
2008-02-20 06:57:14 +01:00
|
|
|
|
2008-04-23 23:00:51 +02:00
|
|
|
t->labeltype( FL_NO_LABEL );
|
|
|
|
|
2008-04-19 06:16:21 +02:00
|
|
|
resize();
|
|
|
|
}
|
2008-02-20 06:57:14 +01:00
|
|
|
|
2008-04-19 06:16:21 +02:00
|
|
|
void
|
2008-04-20 23:46:47 +02:00
|
|
|
Track::add ( Control_Sequence *t )
|
2008-04-19 06:16:21 +02:00
|
|
|
{
|
2008-05-06 06:37:45 +02:00
|
|
|
DMESSAGE( "adding control sequence" );
|
2008-04-21 05:05:25 +02:00
|
|
|
|
2008-05-26 06:08:25 +02:00
|
|
|
engine->lock();
|
|
|
|
|
2008-04-20 23:46:47 +02:00
|
|
|
t->track( this );
|
|
|
|
|
2008-04-19 06:16:21 +02:00
|
|
|
control->add( t );
|
2008-02-20 06:57:14 +01:00
|
|
|
|
2008-05-26 06:08:25 +02:00
|
|
|
engine->unlock();
|
|
|
|
|
2008-04-19 06:16:21 +02:00
|
|
|
resize();
|
|
|
|
}
|
2008-02-20 06:57:14 +01:00
|
|
|
|
2008-05-05 01:06:36 +02:00
|
|
|
void
|
|
|
|
Track::add ( Annotation_Sequence *t )
|
|
|
|
{
|
2008-05-06 06:37:45 +02:00
|
|
|
DMESSAGE( "adding annotation sequence" );
|
2008-05-05 01:06:36 +02:00
|
|
|
|
|
|
|
t->track( this );
|
|
|
|
|
|
|
|
annotation->add( t );
|
|
|
|
|
|
|
|
resize();
|
|
|
|
}
|
|
|
|
|
2008-04-29 22:47:03 +02:00
|
|
|
/** add all widget on this track falling within the given rectangle to
|
|
|
|
the selection. */
|
|
|
|
void
|
|
|
|
Track::select ( int X, int Y, int W, int H,
|
|
|
|
bool include_control, bool merge_control )
|
|
|
|
{
|
|
|
|
|
2008-05-07 18:18:57 +02:00
|
|
|
Sequence *t = sequence();
|
2008-04-29 22:47:03 +02:00
|
|
|
|
|
|
|
if ( ! ( t->y() > Y + H || t->y() + t->h() < Y ) )
|
|
|
|
t->select_range( X, W );
|
|
|
|
else
|
|
|
|
include_control = true;
|
|
|
|
|
|
|
|
if ( include_control )
|
|
|
|
for ( int i = control->children(); i--; )
|
|
|
|
{
|
|
|
|
Control_Sequence *c = (Control_Sequence*)control->child( i );
|
|
|
|
|
|
|
|
if ( merge_control ||
|
|
|
|
( c->y() >= Y && c->y() + c->h() <= Y + H ) )
|
|
|
|
c->select_range( X, W );
|
|
|
|
}
|
|
|
|
}
|
2008-02-20 06:57:14 +01:00
|
|
|
|
2008-04-20 23:46:47 +02:00
|
|
|
void
|
|
|
|
Track::draw ( void )
|
|
|
|
{
|
|
|
|
if ( _selected )
|
|
|
|
{
|
|
|
|
Fl_Color c = color();
|
|
|
|
|
|
|
|
color( FL_RED );
|
|
|
|
|
|
|
|
Fl_Group::draw();
|
|
|
|
|
|
|
|
color( c );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Fl_Group::draw();
|
|
|
|
}
|
|
|
|
|
2008-05-27 02:03:31 +02:00
|
|
|
#include "FL/event_name.H"
|
|
|
|
#include "FL/test_press.H"
|
|
|
|
|
2008-04-20 23:46:47 +02:00
|
|
|
int
|
|
|
|
Track::handle ( int m )
|
|
|
|
{
|
2008-05-27 02:03:31 +02:00
|
|
|
|
|
|
|
/* if ( m != FL_NO_EVENT ) */
|
|
|
|
/* DMESSAGE( "%s", event_name( m ) ); */
|
|
|
|
|
2008-04-20 23:46:47 +02:00
|
|
|
switch ( m )
|
|
|
|
{
|
|
|
|
case FL_MOUSEWHEEL:
|
|
|
|
{
|
2008-05-05 07:29:39 +02:00
|
|
|
Logger log( this );
|
|
|
|
|
2008-04-20 23:46:47 +02:00
|
|
|
if ( ! Fl::event_shift() )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
int d = Fl::event_dy();
|
|
|
|
|
|
|
|
if ( d < 0 )
|
|
|
|
size( size() - 1 );
|
|
|
|
else
|
|
|
|
size( size() + 1 );
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
2008-04-21 22:24:08 +02:00
|
|
|
case FL_PUSH:
|
|
|
|
{
|
2008-05-05 07:29:39 +02:00
|
|
|
Logger log( this );
|
2008-04-28 10:29:59 +02:00
|
|
|
|
2008-04-21 22:24:08 +02:00
|
|
|
int X = Fl::event_x();
|
|
|
|
int Y = Fl::event_y();
|
|
|
|
|
2008-05-26 04:22:52 +02:00
|
|
|
if ( Fl_Group::handle( m ) )
|
|
|
|
return 1;
|
|
|
|
|
2008-05-27 02:03:31 +02:00
|
|
|
if ( test_press( FL_BUTTON3 ) && X < Track::width() )
|
2008-04-21 22:24:08 +02:00
|
|
|
{
|
|
|
|
int c = output.size();
|
|
|
|
|
|
|
|
/* context menu */
|
|
|
|
Fl_Menu_Item menu[] =
|
|
|
|
{
|
|
|
|
{ "Type", 0, 0, 0, FL_SUBMENU },
|
|
|
|
{ "Mono", 0, 0, 0, FL_MENU_RADIO | ( c == 1 ? FL_MENU_VALUE : 0 ) },
|
|
|
|
{ "Stereo", 0, 0, 0, FL_MENU_RADIO | ( c == 2 ? FL_MENU_VALUE : 0 ) },
|
|
|
|
{ "Quad", 0, 0, 0, FL_MENU_RADIO | ( c == 4 ? FL_MENU_VALUE : 0 ) },
|
|
|
|
{ "...", 0, 0, 0, FL_MENU_RADIO | ( c == 3 || c > 4 ? FL_MENU_VALUE : 0 ) },
|
|
|
|
{ 0 },
|
2008-04-28 20:17:46 +02:00
|
|
|
{ "Add Control" },
|
2008-05-05 00:32:08 +02:00
|
|
|
{ "Add Annotation" },
|
2008-04-26 10:42:44 +02:00
|
|
|
{ "Color" },
|
2008-05-26 06:19:13 +02:00
|
|
|
{ "Remove", 0, 0, 0 }, // transport->rolling ? FL_MENU_INACTIVE : 0 },
|
2008-04-21 22:24:08 +02:00
|
|
|
{ 0 },
|
|
|
|
};
|
|
|
|
|
|
|
|
const Fl_Menu_Item *r = menu->popup( X, Y, "Track" );
|
|
|
|
|
2008-04-23 06:18:00 +02:00
|
|
|
if ( r && r > &menu[ 0 ] )
|
2008-04-21 22:24:08 +02:00
|
|
|
{
|
|
|
|
if ( r < &menu[ 4 ] )
|
|
|
|
{
|
|
|
|
int c = r - &menu[1];
|
|
|
|
int ca[] = { 1, 2, 4 };
|
|
|
|
|
|
|
|
configure_inputs( ca[ c ] );
|
|
|
|
configure_outputs( ca[ c ] );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( r == &menu[ 4 ] )
|
|
|
|
{
|
|
|
|
const char *s = fl_input( "How many channels?", "3" );
|
|
|
|
|
|
|
|
int c = atoi( s );
|
|
|
|
|
|
|
|
if ( c <= 0 || c > 10 )
|
|
|
|
fl_alert( "Invalid number of channels." );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
configure_inputs( c );
|
|
|
|
configure_outputs( c );
|
|
|
|
}
|
|
|
|
}
|
2008-04-25 23:35:51 +02:00
|
|
|
else if ( r == &menu[ 6 ] )
|
2008-04-28 20:17:46 +02:00
|
|
|
{
|
|
|
|
new Control_Sequence( this );
|
|
|
|
}
|
|
|
|
else if ( r == &menu[ 7 ] )
|
2008-04-26 10:42:44 +02:00
|
|
|
{
|
2008-05-05 01:06:36 +02:00
|
|
|
add( new Annotation_Sequence( this ) );
|
2008-05-05 00:32:08 +02:00
|
|
|
}
|
|
|
|
else if ( r == &menu[ 8 ] )
|
|
|
|
{
|
2008-04-26 10:42:44 +02:00
|
|
|
unsigned char r, g, b;
|
|
|
|
|
|
|
|
Fl::get_color( color(), r, g, b );
|
|
|
|
|
|
|
|
if ( fl_color_chooser( "Track Color", r, g, b ) )
|
|
|
|
{
|
|
|
|
color( fl_rgb_color( r, g, b ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
// color( fl_show_colormap( color() ) );
|
|
|
|
redraw();
|
|
|
|
}
|
2008-05-05 00:32:08 +02:00
|
|
|
else if ( r == &menu[ 9 ] )
|
2008-04-25 23:35:51 +02:00
|
|
|
{
|
|
|
|
int r = fl_choice( "Are you certain you want to remove track \"%s\"?", "Cancel", NULL, "Remove", name() );
|
|
|
|
|
|
|
|
if ( r == 2 )
|
|
|
|
{
|
|
|
|
timeline->remove_track( this );
|
|
|
|
Fl::delete_widget( this );
|
|
|
|
}
|
|
|
|
}
|
2008-04-21 22:24:08 +02:00
|
|
|
}
|
2008-05-26 04:22:52 +02:00
|
|
|
return 1;
|
2008-04-21 22:24:08 +02:00
|
|
|
}
|
2008-04-26 10:42:44 +02:00
|
|
|
|
|
|
|
return 1;
|
2008-04-21 22:24:08 +02:00
|
|
|
}
|
2008-05-26 04:22:52 +02:00
|
|
|
|
|
|
|
return 0;
|
2008-04-21 22:24:08 +02:00
|
|
|
}
|
2008-04-20 23:46:47 +02:00
|
|
|
default:
|
|
|
|
return Fl_Group::handle( m );
|
|
|
|
}
|
2008-04-26 10:42:44 +02:00
|
|
|
|
|
|
|
return 0;
|
2008-04-20 23:46:47 +02:00
|
|
|
}
|