2008-02-21 11:39:13 +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. */
|
|
|
|
|
/*******************************************************************************/
|
|
|
|
|
|
2008-06-21 06:38:29 +02:00
|
|
|
|
/* This is the Timeline widget, which contains all the tracks and
|
|
|
|
|
* provides cursor overlays, scrolling, zooming, measure lines, tempo
|
|
|
|
|
* map and just about everything else. */
|
2008-05-18 07:09:18 +02:00
|
|
|
|
|
2012-04-27 19:14:53 +02:00
|
|
|
|
#include <FL/Fl.H>
|
2008-05-18 07:09:18 +02:00
|
|
|
|
#include <FL/Fl_Scroll.H>
|
|
|
|
|
#include <FL/Fl_Pack.H>
|
|
|
|
|
#include <FL/Fl_Scrollbar.H>
|
|
|
|
|
#include <FL/Fl_Widget.H>
|
|
|
|
|
#include <FL/fl_draw.H>
|
2008-05-25 22:48:37 +02:00
|
|
|
|
#include <FL/Fl_Menu_Button.H>
|
2012-11-01 11:35:04 +01:00
|
|
|
|
#include <FL/Fl_Panzoomer.H>
|
2012-11-02 01:39:34 +01:00
|
|
|
|
#include <FL/Fl_Tile.H>
|
2008-05-25 22:48:37 +02:00
|
|
|
|
|
2008-02-21 11:39:13 +01:00
|
|
|
|
#include "Timeline.H"
|
2008-04-19 06:16:21 +02:00
|
|
|
|
#include "Tempo_Sequence.H"
|
|
|
|
|
#include "Time_Sequence.H"
|
2012-10-24 07:44:19 +02:00
|
|
|
|
#include "Cursor_Sequence.H"
|
2008-04-19 06:16:21 +02:00
|
|
|
|
#include "Audio_Sequence.H"
|
|
|
|
|
#include "Control_Sequence.H"
|
2008-05-18 07:09:18 +02:00
|
|
|
|
#include "Sequence.H"
|
2008-05-05 00:32:08 +02:00
|
|
|
|
#include "Annotation_Sequence.H"
|
2008-04-19 06:16:21 +02:00
|
|
|
|
#include "Track.H"
|
2008-05-22 05:05:10 +02:00
|
|
|
|
#include "Transport.H"
|
2008-05-26 06:08:25 +02:00
|
|
|
|
|
2008-05-31 01:48:44 +02:00
|
|
|
|
#include "FL/menu_popup.H"
|
|
|
|
|
|
2008-07-30 04:30:45 +02:00
|
|
|
|
#include "const.h"
|
2010-02-01 07:25:16 +01:00
|
|
|
|
#include "debug.h"
|
2008-07-30 04:30:45 +02:00
|
|
|
|
|
2010-01-21 01:33:02 +01:00
|
|
|
|
/* these headers are just for the NSM support */
|
|
|
|
|
#include "Project.H"
|
|
|
|
|
#include "TLE.H"
|
|
|
|
|
/* */
|
|
|
|
|
|
2012-02-24 10:59:26 +01:00
|
|
|
|
#include "OSC_Thread.H"
|
2012-02-26 03:01:46 +01:00
|
|
|
|
#include "OSC/Endpoint.H"
|
2012-02-24 10:59:26 +01:00
|
|
|
|
|
2012-10-24 07:44:19 +02:00
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
2012-05-22 07:04:09 +02:00
|
|
|
|
#include <nsm.h>
|
|
|
|
|
extern nsm_client_t *nsm;
|
2010-01-21 01:33:02 +01:00
|
|
|
|
|
2010-01-08 07:04:28 +01:00
|
|
|
|
#define BASE Fl_Group
|
2012-05-21 05:28:09 +02:00
|
|
|
|
#define BX this->x()
|
|
|
|
|
#define BY this->y()
|
2010-01-08 06:35:50 +01:00
|
|
|
|
|
2008-05-22 05:05:10 +02:00
|
|
|
|
|
2008-02-29 03:02:40 +01:00
|
|
|
|
|
2008-04-25 04:48:44 +02:00
|
|
|
|
bool Timeline::draw_with_measure_lines = true;
|
2012-10-24 07:44:19 +02:00
|
|
|
|
bool Timeline::draw_with_cursor_overlay = true;
|
2008-04-26 18:07:43 +02:00
|
|
|
|
Timeline::snap_e Timeline::snap_to = Bars;
|
2010-01-26 15:31:04 +01:00
|
|
|
|
bool Timeline::snapping_on_hold = false;
|
2008-04-27 20:56:20 +02:00
|
|
|
|
bool Timeline::snap_magnetic = true;
|
2008-04-30 03:08:49 +02:00
|
|
|
|
bool Timeline::follow_playhead = true;
|
2008-05-01 08:47:49 +02:00
|
|
|
|
bool Timeline::center_playhead = true;
|
2013-09-10 03:46:28 +02:00
|
|
|
|
bool Timeline::playback_latency_compensation = false;
|
2008-04-25 04:48:44 +02:00
|
|
|
|
|
2013-06-06 01:26:36 +02:00
|
|
|
|
const float UPDATE_FREQ = 1.0f / 18.0f;
|
2008-04-12 21:50:36 +02:00
|
|
|
|
|
2010-01-21 01:33:02 +01:00
|
|
|
|
extern const char *instance_name;
|
|
|
|
|
extern TLE *tle;
|
|
|
|
|
|
2008-05-22 05:05:10 +02:00
|
|
|
|
|
2008-04-12 21:50:36 +02:00
|
|
|
|
|
2008-04-28 07:11:47 +02:00
|
|
|
|
/** return the combined height of all visible children of (veritcal)
|
2008-05-13 06:38:05 +02:00
|
|
|
|
pack, /p/. This is necessary because pack sizes are adjusted only
|
|
|
|
|
when the relevant areas are exposes. */
|
2008-04-28 07:11:47 +02:00
|
|
|
|
static int
|
|
|
|
|
pack_visible_height ( const Fl_Pack *p )
|
|
|
|
|
{
|
|
|
|
|
int th = 0;
|
|
|
|
|
|
2008-04-28 18:48:35 +02:00
|
|
|
|
const Fl_Widget* const *w = p->array();
|
|
|
|
|
for ( int i = p->children(); i--; ++w )
|
2008-04-28 07:11:47 +02:00
|
|
|
|
if ( (*w)->visible() )
|
|
|
|
|
th += (*w)->h() + p->spacing();
|
|
|
|
|
|
|
|
|
|
return th;
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-22 04:29:06 +02:00
|
|
|
|
#define BP fl_begin_polygon()
|
|
|
|
|
#define EP fl_end_polygon()
|
|
|
|
|
#define vv(x,y) fl_vertex( x, y )
|
|
|
|
|
#define BL fl_begin_line()
|
|
|
|
|
#define EL fl_end_line()
|
|
|
|
|
|
2012-03-02 09:53:10 +01:00
|
|
|
|
void
|
2008-05-22 04:29:06 +02:00
|
|
|
|
draw_full_arrow_symbol ( Fl_Color color )
|
|
|
|
|
{
|
|
|
|
|
/* draw cap */
|
|
|
|
|
fl_color( color );
|
|
|
|
|
|
|
|
|
|
BP;
|
|
|
|
|
vv( -1, -1 );
|
|
|
|
|
vv( 0, 1 );
|
|
|
|
|
vv( 1, -1 );
|
|
|
|
|
EP;
|
|
|
|
|
|
|
|
|
|
/* draw cap outline */
|
|
|
|
|
fl_color( FL_BLACK );
|
|
|
|
|
|
|
|
|
|
BL;
|
|
|
|
|
vv( -1, -1 );
|
|
|
|
|
vv( 0, 1 );
|
|
|
|
|
vv( 1, -1 );
|
|
|
|
|
EL;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-02 01:41:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Timeline::Timeline_Panzoomer : public Fl_Panzoomer
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
Timeline_Panzoomer ( int X,int Y,int W,int H, const char *L=0)
|
|
|
|
|
: Fl_Panzoomer(X,Y,W,H)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
protected:
|
|
|
|
|
void
|
|
|
|
|
draw_background ( int X, int Y,int W, int H )
|
|
|
|
|
{
|
2012-11-16 10:28:09 +01:00
|
|
|
|
nframes_t ef = timeline->x_to_ts( _xmax );
|
2012-11-02 01:41:08 +01:00
|
|
|
|
|
|
|
|
|
double ty = Y;
|
|
|
|
|
|
|
|
|
|
for ( int i = 0; i < timeline->tracks->children(); i++ )
|
|
|
|
|
{
|
|
|
|
|
Track *t = (Track*)timeline->tracks->child( i );
|
|
|
|
|
|
|
|
|
|
Sequence *s = t->sequence();
|
|
|
|
|
|
|
|
|
|
if ( !s )
|
|
|
|
|
continue;
|
|
|
|
|
|
2013-04-27 06:25:00 +02:00
|
|
|
|
fl_color( FL_DARK1 );
|
2012-11-02 01:41:08 +01:00
|
|
|
|
|
|
|
|
|
const double scale = (double)H / ( pack_visible_height( timeline->tracks ) );
|
|
|
|
|
|
|
|
|
|
// double th = (double)H / timeline->tracks->children();
|
|
|
|
|
const double th = t->h() * scale;
|
|
|
|
|
|
|
|
|
|
fl_line( X, ty,
|
|
|
|
|
X + W, ty );
|
|
|
|
|
|
|
|
|
|
for ( list <Sequence_Widget *>::const_iterator r = s->_widgets.begin();
|
|
|
|
|
r != s->_widgets.end(); ++r )
|
|
|
|
|
{
|
|
|
|
|
fl_rectf(
|
|
|
|
|
X + ( W * ( (double)(*r)->start() / ef ) ),
|
|
|
|
|
ty,
|
|
|
|
|
W * ( (double)(*r)->length() / ef ),
|
|
|
|
|
th,
|
|
|
|
|
(*r)->actual_box_color());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fl_font( FL_HELVETICA, th );
|
|
|
|
|
fl_color( FL_FOREGROUND_COLOR );
|
|
|
|
|
fl_draw( t->name(), X, ty, W, th, (Fl_Align)(FL_ALIGN_LEFT | FL_ALIGN_INSIDE ));
|
|
|
|
|
|
|
|
|
|
ty += th;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2008-05-22 05:05:10 +02:00
|
|
|
|
|
|
|
|
|
|
2013-05-29 06:03:59 +02:00
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Timeline::redraw_overlay ( void )
|
|
|
|
|
{
|
|
|
|
|
((Fl_Overlay_Window*)window())->redraw_overlay();
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-24 07:44:19 +02:00
|
|
|
|
nframes_t
|
|
|
|
|
Timeline::range_start ( void ) const
|
|
|
|
|
{
|
|
|
|
|
if ( edit_cursor_track->active_cursor() )
|
|
|
|
|
return edit_cursor_track->active_cursor()->start();
|
|
|
|
|
else
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nframes_t
|
|
|
|
|
Timeline::range_end ( void ) const
|
|
|
|
|
{
|
|
|
|
|
if ( edit_cursor_track->active_cursor() )
|
|
|
|
|
return edit_cursor_track->active_cursor()->start() + edit_cursor_track->active_cursor()->length();
|
|
|
|
|
else
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Timeline::range_start ( nframes_t n )
|
|
|
|
|
{
|
|
|
|
|
if ( ! edit_cursor_track->active_cursor() )
|
|
|
|
|
new Cursor_Region( 0, 0, "Edit", NULL );
|
|
|
|
|
|
|
|
|
|
Logger log( edit_cursor_track->active_cursor() );
|
|
|
|
|
|
|
|
|
|
edit_cursor_track->active_cursor()->set_left( n );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Timeline::range_end ( nframes_t n )
|
|
|
|
|
{
|
|
|
|
|
if ( ! edit_cursor_track->active_cursor() )
|
|
|
|
|
new Cursor_Region( 0, 0, "Edit", NULL );
|
|
|
|
|
|
|
|
|
|
Logger log( edit_cursor_track->active_cursor() );
|
|
|
|
|
|
|
|
|
|
edit_cursor_track->active_cursor()->set_right( n );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** return first frame of playback (might not be 0) */
|
|
|
|
|
nframes_t
|
|
|
|
|
Timeline::playback_home ( void ) const
|
|
|
|
|
{
|
|
|
|
|
if ( play_cursor_track->active_cursor() )
|
|
|
|
|
return play_cursor_track->active_cursor()->start();
|
|
|
|
|
else
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** return last frame of playback */
|
|
|
|
|
nframes_t
|
|
|
|
|
Timeline::playback_end ( void ) const
|
|
|
|
|
{
|
|
|
|
|
if ( play_cursor_track->active_cursor() )
|
|
|
|
|
return play_cursor_track->active_cursor()->start() + play_cursor_track->active_cursor()->length();
|
|
|
|
|
else
|
|
|
|
|
return length();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Timeline::reset_range ( void )
|
|
|
|
|
{
|
|
|
|
|
delete edit_cursor_track->active_cursor();
|
|
|
|
|
}
|
|
|
|
|
|
2008-08-04 05:54:22 +02:00
|
|
|
|
/** callback used by Loggable class to create a snapshot of system
|
|
|
|
|
* state. */
|
|
|
|
|
void
|
|
|
|
|
Timeline::snapshot ( void )
|
|
|
|
|
{
|
|
|
|
|
tempo_track->log_children();
|
|
|
|
|
time_track->log_children();
|
2012-10-24 07:44:19 +02:00
|
|
|
|
edit_cursor_track->log_children();
|
|
|
|
|
punch_cursor_track->log_children();
|
|
|
|
|
play_cursor_track->log_children();
|
2008-08-04 05:54:22 +02:00
|
|
|
|
|
2013-03-14 02:02:35 +01:00
|
|
|
|
update_track_order();
|
|
|
|
|
|
2008-08-04 05:54:22 +02:00
|
|
|
|
for ( int i = 0; i < tracks->children(); ++i )
|
|
|
|
|
{
|
|
|
|
|
((Track*)tracks->child( i ))->log_children();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-28 07:11:47 +02:00
|
|
|
|
|
2008-06-19 06:14:14 +02:00
|
|
|
|
/** recalculate the size of horizontal scrolling area and inform scrollbar */
|
2008-05-28 01:47:47 +02:00
|
|
|
|
void
|
2012-11-02 01:39:21 +01:00
|
|
|
|
Timeline::adjust_panzoomer ( void )
|
2008-05-28 01:47:47 +02:00
|
|
|
|
{
|
2012-11-02 01:39:21 +01:00
|
|
|
|
panzoomer->y_value( panzoomer->y_value(), h() - rulers->h() - panzoomer->h(), 0, pack_visible_height( tracks ));
|
2012-11-16 10:28:09 +01:00
|
|
|
|
panzoomer->x_value( ts_to_x( xoffset ), /* pos */
|
|
|
|
|
tracks->w() - Track::width(), /* window size */
|
|
|
|
|
0, /* min */
|
|
|
|
|
max( ts_to_x( length() ), tracks->w() - Track::width() )/* max */
|
|
|
|
|
);
|
2008-05-28 01:47:47 +02:00
|
|
|
|
}
|
|
|
|
|
|
2008-02-26 05:58:15 +01:00
|
|
|
|
void
|
2008-03-06 23:45:23 +01:00
|
|
|
|
Timeline::cb_scroll ( Fl_Widget *w, void *v )
|
2008-02-26 05:58:15 +01:00
|
|
|
|
{
|
2008-03-06 23:45:23 +01:00
|
|
|
|
((Timeline*)v)->cb_scroll( w );
|
|
|
|
|
}
|
2008-02-26 05:58:15 +01:00
|
|
|
|
|
2008-03-06 23:45:23 +01:00
|
|
|
|
void
|
|
|
|
|
Timeline::cb_scroll ( Fl_Widget *w )
|
|
|
|
|
{
|
2012-11-02 01:39:21 +01:00
|
|
|
|
//adjust_panzoomer();
|
2008-02-26 05:58:15 +01:00
|
|
|
|
|
2012-11-02 01:39:21 +01:00
|
|
|
|
if ( panzoomer->zoom_changed() )
|
2008-02-26 05:58:15 +01:00
|
|
|
|
{
|
2012-11-01 11:35:04 +01:00
|
|
|
|
nframes_t under_mouse = x_to_offset( Fl::event_x() );
|
2008-05-03 04:17:34 +02:00
|
|
|
|
|
2012-11-02 01:39:21 +01:00
|
|
|
|
_fpp = panzoomer->zoom();
|
2008-05-03 04:17:34 +02:00
|
|
|
|
|
2012-11-02 01:39:21 +01:00
|
|
|
|
panzoomer->x_value( ts_to_x( under_mouse ) );
|
2008-05-28 01:47:47 +02:00
|
|
|
|
|
2012-11-01 11:35:04 +01:00
|
|
|
|
redraw();
|
|
|
|
|
}
|
2008-02-26 05:58:15 +01:00
|
|
|
|
|
2012-11-02 01:39:21 +01:00
|
|
|
|
if ( _old_yposition != panzoomer->y_value() )
|
2012-11-01 11:35:04 +01:00
|
|
|
|
{
|
2012-12-11 06:47:44 +01:00
|
|
|
|
tracks->position( tracks->x(), track_window->y() - (int)panzoomer->y_value() );
|
2012-11-01 11:35:04 +01:00
|
|
|
|
damage( FL_DAMAGE_SCROLL );
|
|
|
|
|
}
|
2008-04-27 15:37:50 +02:00
|
|
|
|
|
2012-11-02 01:39:21 +01:00
|
|
|
|
if ( _old_xposition != x_to_ts( panzoomer->x_value() ))
|
2012-11-01 11:35:04 +01:00
|
|
|
|
{
|
|
|
|
|
damage( FL_DAMAGE_SCROLL );
|
2012-11-02 01:39:21 +01:00
|
|
|
|
xposition( panzoomer->x_value() );
|
2008-03-06 23:45:23 +01:00
|
|
|
|
}
|
2008-02-26 05:58:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
2008-05-25 08:14:17 +02:00
|
|
|
|
void
|
|
|
|
|
Timeline::menu_cb ( Fl_Widget *w, void *v )
|
|
|
|
|
{
|
2008-05-29 08:11:35 +02:00
|
|
|
|
((Timeline*)v)->menu_cb( (Fl_Menu_*)w );
|
2008-05-25 08:14:17 +02:00
|
|
|
|
}
|
|
|
|
|
|
2012-10-24 07:44:19 +02:00
|
|
|
|
/** ensure that p1 is less than range_end() */
|
2008-06-01 03:54:01 +02:00
|
|
|
|
void
|
|
|
|
|
Timeline::fix_range ( void )
|
|
|
|
|
{
|
2012-10-24 07:44:19 +02:00
|
|
|
|
if ( range_start() > range_end() )
|
2008-06-01 03:54:01 +02:00
|
|
|
|
{
|
2012-10-24 07:44:19 +02:00
|
|
|
|
nframes_t t = range_end();
|
|
|
|
|
range_end( range_start() );
|
|
|
|
|
range_start( t );
|
2008-06-01 03:54:01 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-07-22 05:20:38 +02:00
|
|
|
|
/** set the range to /start/ + /length/ */
|
|
|
|
|
void
|
|
|
|
|
Timeline::range ( nframes_t start, nframes_t length )
|
|
|
|
|
{
|
2012-10-24 07:44:19 +02:00
|
|
|
|
range_start( start );
|
|
|
|
|
range_end( start + length );
|
2008-07-22 05:20:38 +02:00
|
|
|
|
|
|
|
|
|
redraw();
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-24 07:44:19 +02:00
|
|
|
|
/** create a new take for every armed track */
|
|
|
|
|
void
|
|
|
|
|
Timeline::add_take_for_armed_tracks ( void )
|
|
|
|
|
{
|
2013-02-23 02:18:52 +01:00
|
|
|
|
THREAD_ASSERT( UI );
|
|
|
|
|
|
|
|
|
|
wrlock();
|
|
|
|
|
|
2012-10-24 07:44:19 +02:00
|
|
|
|
for ( int i = tracks->children(); i-- ; )
|
|
|
|
|
{
|
|
|
|
|
Track *t = (Track*)tracks->child( i );
|
|
|
|
|
|
|
|
|
|
if ( t->armed() && t->sequence()->_widgets.size() )
|
|
|
|
|
t->sequence( new Audio_Sequence( t ) );
|
|
|
|
|
}
|
2013-02-23 02:18:52 +01:00
|
|
|
|
|
|
|
|
|
unlock();
|
2012-10-24 07:44:19 +02:00
|
|
|
|
}
|
|
|
|
|
|
2008-05-25 08:14:17 +02:00
|
|
|
|
void
|
2008-05-29 08:11:35 +02:00
|
|
|
|
Timeline::menu_cb ( Fl_Menu_ *m )
|
2008-05-25 08:14:17 +02:00
|
|
|
|
{
|
2008-06-06 05:07:56 +02:00
|
|
|
|
if ( ! active_r() )
|
|
|
|
|
return;
|
|
|
|
|
|
2008-05-25 08:14:17 +02:00
|
|
|
|
const char *picked = m->mvalue()->label();
|
|
|
|
|
|
|
|
|
|
/* m->item_pathname( picked, sizeof( picked ) ); */
|
|
|
|
|
|
|
|
|
|
DMESSAGE( "%s", picked );
|
|
|
|
|
|
2012-10-24 07:44:19 +02:00
|
|
|
|
if ( ! strcmp( picked, "Add audio track" ) )
|
2008-05-25 08:14:17 +02:00
|
|
|
|
{
|
|
|
|
|
/* FIXME: prompt for I/O config? */
|
|
|
|
|
|
|
|
|
|
Loggable::block_start();
|
|
|
|
|
|
|
|
|
|
/* add audio track */
|
|
|
|
|
char *name = get_unique_track_name( "Audio" );
|
|
|
|
|
|
|
|
|
|
Track *t = new Track( name );
|
|
|
|
|
|
2013-07-31 06:36:35 +02:00
|
|
|
|
free( name );
|
|
|
|
|
|
2008-05-25 08:14:17 +02:00
|
|
|
|
Audio_Sequence *o = new Audio_Sequence( t );
|
|
|
|
|
|
|
|
|
|
add_track( t );
|
|
|
|
|
|
|
|
|
|
t->sequence( o );
|
|
|
|
|
|
2009-01-20 05:34:33 +01:00
|
|
|
|
t->take_focus();
|
|
|
|
|
|
2008-05-25 08:14:17 +02:00
|
|
|
|
Loggable::block_end();
|
|
|
|
|
}
|
2012-10-24 07:44:19 +02:00
|
|
|
|
else if ( ! strcmp( picked, "Tempo from edit (beat)" ) )
|
2008-05-25 08:14:17 +02:00
|
|
|
|
{
|
2012-10-24 07:44:19 +02:00
|
|
|
|
if ( range_start() != range_end() )
|
2008-05-25 08:14:17 +02:00
|
|
|
|
{
|
2008-06-01 03:54:01 +02:00
|
|
|
|
fix_range();
|
2008-05-25 08:14:17 +02:00
|
|
|
|
|
2012-10-24 07:44:19 +02:00
|
|
|
|
beats_per_minute( range_start(), sample_rate() * 60 / (float)( range_end() - range_start() ) );
|
2008-05-25 08:14:17 +02:00
|
|
|
|
|
2012-10-24 07:44:19 +02:00
|
|
|
|
range_end( range_start() );
|
2008-05-25 08:14:17 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2012-10-24 07:44:19 +02:00
|
|
|
|
else if ( ! strcmp( picked, "Tempo from edit (bar)" ) )
|
2008-06-01 03:54:01 +02:00
|
|
|
|
{
|
2012-10-24 07:44:19 +02:00
|
|
|
|
if ( range_start() != range_end() )
|
2008-06-01 03:54:01 +02:00
|
|
|
|
{
|
|
|
|
|
fix_range();
|
|
|
|
|
|
2012-10-24 07:44:19 +02:00
|
|
|
|
position_info pi = solve_tempomap( range_start() );
|
2008-06-01 03:54:01 +02:00
|
|
|
|
|
2012-10-24 07:44:19 +02:00
|
|
|
|
beats_per_minute( range_start(), sample_rate() * 60 / (float)( ( range_end() - range_start() ) / pi.beats_per_bar ) );
|
2008-06-01 03:54:01 +02:00
|
|
|
|
|
2012-10-24 07:44:19 +02:00
|
|
|
|
range_end( range_start() );
|
2008-06-01 03:54:01 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2008-05-25 08:18:30 +02:00
|
|
|
|
else if ( ! strcmp( picked, "Playhead to mouse" ) )
|
|
|
|
|
{
|
2008-05-29 03:31:06 +02:00
|
|
|
|
int X = Fl::event_x() - Track::width();
|
2008-05-25 08:18:30 +02:00
|
|
|
|
|
2008-05-29 03:31:06 +02:00
|
|
|
|
if ( X > 0 )
|
|
|
|
|
{
|
|
|
|
|
transport->locate( xoffset + x_to_ts( X ) );
|
|
|
|
|
}
|
2008-05-25 08:18:30 +02:00
|
|
|
|
}
|
2012-10-24 07:44:19 +02:00
|
|
|
|
else if ( ! strcmp( picked, "Edit start to mouse" ) )
|
2008-05-25 08:18:30 +02:00
|
|
|
|
{
|
|
|
|
|
int X = Fl::event_x() - Track::width();
|
|
|
|
|
|
|
|
|
|
if ( X > 0 )
|
|
|
|
|
{
|
2012-10-24 07:44:19 +02:00
|
|
|
|
range_start( xoffset + x_to_ts( X ) );
|
2008-05-29 03:31:06 +02:00
|
|
|
|
}
|
2008-05-25 08:18:30 +02:00
|
|
|
|
|
2012-03-18 21:21:57 +01:00
|
|
|
|
fix_range();
|
|
|
|
|
|
2008-05-25 08:18:30 +02:00
|
|
|
|
/* FIXME: only needs to damage the location of the old cursor! */
|
|
|
|
|
redraw();
|
|
|
|
|
}
|
2012-10-24 07:44:19 +02:00
|
|
|
|
else if ( ! strcmp( picked, "Edit end to mouse" ) )
|
2008-05-25 08:18:30 +02:00
|
|
|
|
{
|
|
|
|
|
int X = Fl::event_x() - Track::width();
|
|
|
|
|
|
|
|
|
|
if ( X > 0 )
|
|
|
|
|
{
|
2012-10-24 07:44:19 +02:00
|
|
|
|
range_end( xoffset + x_to_ts( X ) );
|
2008-05-25 08:18:30 +02:00
|
|
|
|
}
|
|
|
|
|
|
2012-03-18 21:21:57 +01:00
|
|
|
|
fix_range();
|
|
|
|
|
|
2008-05-25 08:18:30 +02:00
|
|
|
|
/* FIXME: only needs to damage the location of the old cursor! */
|
|
|
|
|
redraw();
|
|
|
|
|
}
|
2008-05-30 04:28:26 +02:00
|
|
|
|
else if ( ! strcmp( picked, "Playhead left beat" ) )
|
2008-05-29 03:31:06 +02:00
|
|
|
|
{
|
2008-05-30 00:45:04 +02:00
|
|
|
|
nframes_t f = transport->frame;
|
|
|
|
|
|
|
|
|
|
if ( prev_line( &f ) )
|
|
|
|
|
transport->locate( f );
|
2008-05-29 03:31:06 +02:00
|
|
|
|
}
|
2008-05-30 04:28:26 +02:00
|
|
|
|
else if ( ! strcmp( picked, "Playhead right beat" ) )
|
2008-05-29 03:31:06 +02:00
|
|
|
|
{
|
2008-05-30 00:45:04 +02:00
|
|
|
|
nframes_t f = transport->frame;
|
|
|
|
|
|
|
|
|
|
if ( next_line( &f ) )
|
|
|
|
|
transport->locate( f );
|
2008-05-29 03:31:06 +02:00
|
|
|
|
}
|
2008-05-30 04:28:26 +02:00
|
|
|
|
else if ( ! strcmp( picked, "Playhead left bar" ) )
|
|
|
|
|
{
|
|
|
|
|
nframes_t f = transport->frame;
|
|
|
|
|
|
|
|
|
|
if ( prev_line( &f, true ) )
|
|
|
|
|
transport->locate( f );
|
|
|
|
|
}
|
|
|
|
|
else if ( ! strcmp( picked, "Playhead right bar" ) )
|
|
|
|
|
{
|
|
|
|
|
nframes_t f = transport->frame;
|
|
|
|
|
|
|
|
|
|
if ( next_line( &f, true ) )
|
|
|
|
|
transport->locate( f );
|
|
|
|
|
}
|
2012-10-24 07:44:19 +02:00
|
|
|
|
else if ( ! strcmp( picked, "Swap edit start and playhead" ) )
|
2008-05-29 03:31:06 +02:00
|
|
|
|
{
|
|
|
|
|
nframes_t t = transport->frame;
|
|
|
|
|
|
2012-10-24 07:44:19 +02:00
|
|
|
|
transport->locate( range_start() );
|
2008-05-29 03:31:06 +02:00
|
|
|
|
|
2012-10-24 07:44:19 +02:00
|
|
|
|
range_start( t );
|
2008-05-29 03:31:06 +02:00
|
|
|
|
|
|
|
|
|
redraw();
|
|
|
|
|
}
|
2012-10-24 07:44:19 +02:00
|
|
|
|
else if ( ! strcmp( picked, "Swap edit end and playhead" ) )
|
2008-05-30 04:28:26 +02:00
|
|
|
|
{
|
|
|
|
|
nframes_t t = transport->frame;
|
|
|
|
|
|
2012-10-24 07:44:19 +02:00
|
|
|
|
transport->locate( range_end() );
|
|
|
|
|
|
|
|
|
|
range_end( t );
|
|
|
|
|
|
|
|
|
|
redraw();
|
|
|
|
|
}
|
|
|
|
|
else if ( ! strcmp( picked, "Edit start to playhead" ) )
|
|
|
|
|
{
|
|
|
|
|
range_start( transport->frame );
|
2008-05-30 04:28:26 +02:00
|
|
|
|
|
2012-10-24 07:44:19 +02:00
|
|
|
|
redraw();
|
|
|
|
|
}
|
|
|
|
|
else if ( ! strcmp( picked, "Edit end to playhead" ) )
|
|
|
|
|
{
|
|
|
|
|
range_end( transport->frame );
|
2008-05-30 04:28:26 +02:00
|
|
|
|
|
|
|
|
|
redraw();
|
|
|
|
|
}
|
2012-10-24 07:44:19 +02:00
|
|
|
|
else if ( ! strcmp( picked, "Punch from edit" ) )
|
2008-05-30 04:28:26 +02:00
|
|
|
|
{
|
2012-10-24 07:44:19 +02:00
|
|
|
|
if ( range_start() != range_end() )
|
|
|
|
|
{
|
|
|
|
|
Loggable::block_start();
|
|
|
|
|
|
2012-11-06 08:50:28 +01:00
|
|
|
|
new Cursor_Region( range_start(), range_end() - range_start(), "Punch", NULL );
|
2012-10-24 07:44:19 +02:00
|
|
|
|
reset_range();
|
|
|
|
|
|
|
|
|
|
Loggable::block_end();
|
|
|
|
|
}
|
2008-05-30 04:28:26 +02:00
|
|
|
|
|
|
|
|
|
redraw();
|
|
|
|
|
}
|
2012-10-24 07:44:19 +02:00
|
|
|
|
else if ( ! strcmp( picked, "Playback from edit" ) )
|
2008-05-30 04:28:26 +02:00
|
|
|
|
{
|
2012-10-24 07:44:19 +02:00
|
|
|
|
if ( range_start() != range_end() )
|
|
|
|
|
{
|
|
|
|
|
Loggable::block_start();
|
|
|
|
|
|
|
|
|
|
if ( play_cursor_track->active_cursor() )
|
|
|
|
|
{
|
|
|
|
|
play_cursor_track->active_cursor()->start( range_start() );
|
|
|
|
|
play_cursor_track->active_cursor()->set_right( range_end() );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2012-11-06 08:50:28 +01:00
|
|
|
|
new Cursor_Region( range_start(), range_end() - range_start(), "Playback", NULL );
|
2012-10-24 07:44:19 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
reset_range();
|
|
|
|
|
|
|
|
|
|
Loggable::block_end();
|
|
|
|
|
}
|
2008-05-30 04:28:26 +02:00
|
|
|
|
|
|
|
|
|
redraw();
|
|
|
|
|
}
|
2012-06-14 06:04:31 +02:00
|
|
|
|
else if ( ! strcmp( picked, "Redraw" ) )
|
|
|
|
|
{
|
|
|
|
|
redraw();
|
|
|
|
|
}
|
2008-05-25 08:14:17 +02:00
|
|
|
|
else
|
|
|
|
|
WARNING( "programming error: Unknown menu item" );
|
|
|
|
|
}
|
2008-02-26 05:58:15 +01:00
|
|
|
|
|
2008-06-12 05:52:34 +02:00
|
|
|
|
int
|
|
|
|
|
Timeline::ntracks ( void ) const
|
|
|
|
|
{
|
|
|
|
|
return tracks->children();
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-25 22:48:37 +02:00
|
|
|
|
|
2012-06-10 20:56:22 +02:00
|
|
|
|
Timeline::~Timeline ( )
|
|
|
|
|
{
|
|
|
|
|
delete osc_thread;
|
|
|
|
|
osc_thread = 0;
|
2013-07-31 06:36:35 +02:00
|
|
|
|
delete osc;
|
|
|
|
|
osc = 0;
|
2012-06-10 20:56:22 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-01-08 07:04:28 +01:00
|
|
|
|
Timeline::Timeline ( int X, int Y, int W, int H, const char* L ) : BASE( X, Y, W, H, L )
|
2008-02-21 17:20:36 +01:00
|
|
|
|
{
|
2008-08-04 05:54:22 +02:00
|
|
|
|
Loggable::snapshot_callback( &Timeline::snapshot, this );
|
|
|
|
|
|
2012-10-24 07:44:19 +02:00
|
|
|
|
edit_cursor_track = NULL;
|
|
|
|
|
punch_cursor_track = NULL;
|
|
|
|
|
play_cursor_track = NULL;
|
|
|
|
|
|
|
|
|
|
_created_new_takes = 0;
|
|
|
|
|
_punched_in = 0;
|
|
|
|
|
_punch_in_frame = 0;
|
|
|
|
|
_punch_out_frame = 0;
|
2012-02-24 10:59:26 +01:00
|
|
|
|
osc_thread = 0;
|
2012-02-24 11:43:44 +01:00
|
|
|
|
_sample_rate = 44100;
|
2008-02-23 07:59:10 +01:00
|
|
|
|
|
2008-02-29 03:47:29 +01:00
|
|
|
|
box( FL_FLAT_BOX );
|
2008-02-23 07:59:10 +01:00
|
|
|
|
xoffset = 0;
|
2008-04-28 18:48:35 +02:00
|
|
|
|
_old_yposition = 0;
|
|
|
|
|
_old_xposition = 0;
|
2008-02-23 07:59:10 +01:00
|
|
|
|
|
2012-10-24 07:44:19 +02:00
|
|
|
|
// range_start( range_end( 0 ) );
|
2008-04-26 10:42:44 +02:00
|
|
|
|
|
2008-05-25 22:48:37 +02:00
|
|
|
|
menu = new Fl_Menu_Button( 0, 0, 0, 0, "Timeline" );
|
2008-05-25 08:14:17 +02:00
|
|
|
|
|
|
|
|
|
/* menu->add( "Add Track", 0, 0, 0 ); */
|
|
|
|
|
|
2012-12-11 06:47:44 +01:00
|
|
|
|
int ruler_height = 0;
|
|
|
|
|
|
2012-10-24 07:44:19 +02:00
|
|
|
|
menu->add( "Add audio track", 'a', 0, 0 );
|
|
|
|
|
menu->add( "Tempo from edit (beat)", 't', 0, 0 );
|
|
|
|
|
menu->add( "Tempo from edit (bar)", FL_CTRL + 't', 0, 0 );
|
2008-05-31 01:48:44 +02:00
|
|
|
|
menu->add( "Playhead to mouse", 'p', 0, 0 );
|
2012-10-24 07:44:19 +02:00
|
|
|
|
menu->add( "Edit start to mouse", '[', 0, 0 );
|
|
|
|
|
menu->add( "Edit end to mouse", ']', 0, 0 );
|
2008-05-31 01:48:44 +02:00
|
|
|
|
menu->add( "Playhead left beat", FL_SHIFT + FL_Left, 0, 0 );
|
|
|
|
|
menu->add( "Playhead right beat", FL_SHIFT + FL_Right, 0, 0 );
|
|
|
|
|
menu->add( "Playhead left bar", FL_CTRL + FL_SHIFT + FL_Left, 0, 0 );
|
|
|
|
|
menu->add( "Playhead right bar", FL_CTRL + FL_SHIFT + FL_Right, 0, 0 );
|
2012-10-24 07:44:19 +02:00
|
|
|
|
menu->add( "Swap edit start and playhead", FL_CTRL + FL_SHIFT + '[', 0, 0 );
|
|
|
|
|
menu->add( "Swap edit end and playhead", FL_CTRL + FL_SHIFT + ']', 0, 0 );
|
|
|
|
|
menu->add( "Edit start to playhead", FL_CTRL + '[', 0, 0 );
|
|
|
|
|
menu->add( "Edit end to playhead", FL_CTRL + ']', 0, 0 );
|
|
|
|
|
menu->add( "Punch from edit", FL_CTRL + FL_SHIFT + 'p', 0, 0 );
|
|
|
|
|
menu->add( "Playback from edit", FL_CTRL + FL_SHIFT + 'l', 0, 0 );
|
2012-06-14 06:04:31 +02:00
|
|
|
|
menu->add( "Redraw", FL_CTRL + 'l', 0, 0 );
|
2008-05-31 01:48:44 +02:00
|
|
|
|
|
|
|
|
|
menu_set_callback( const_cast<Fl_Menu_Item*>(menu->menu()), &Timeline::menu_cb, (void*)this );
|
2008-05-25 08:14:17 +02:00
|
|
|
|
|
2008-02-26 05:58:15 +01:00
|
|
|
|
|
|
|
|
|
{
|
2012-12-11 06:47:44 +01:00
|
|
|
|
Fl_Pack *o = new Fl_Pack( X, Y, W, 1, "rulers" );
|
2008-02-21 17:20:36 +01:00
|
|
|
|
o->type( Fl_Pack::VERTICAL );
|
|
|
|
|
|
|
|
|
|
{
|
2012-10-24 07:44:19 +02:00
|
|
|
|
Tempo_Sequence *o = new Tempo_Sequence( 0, 0, 800, 18 );
|
2008-02-21 17:20:36 +01:00
|
|
|
|
|
2012-12-11 06:47:44 +01:00
|
|
|
|
o->color( FL_DARK1 );
|
2008-02-21 17:20:36 +01:00
|
|
|
|
|
2012-12-11 06:47:44 +01:00
|
|
|
|
/* o->label( "Tempo" ); */
|
2008-02-21 17:20:36 +01:00
|
|
|
|
|
|
|
|
|
tempo_track = o;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
2012-10-24 07:44:19 +02:00
|
|
|
|
Time_Sequence *o = new Time_Sequence( 0, 24, 800, 18 );
|
2008-02-21 17:20:36 +01:00
|
|
|
|
|
2012-12-11 06:47:44 +01:00
|
|
|
|
o->color( FL_DARK2 );
|
2008-02-21 17:20:36 +01:00
|
|
|
|
|
2012-12-11 06:47:44 +01:00
|
|
|
|
/* o->name( "Time" ); */
|
2008-02-29 03:47:29 +01:00
|
|
|
|
|
2008-02-21 17:20:36 +01:00
|
|
|
|
time_track = o;
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-24 07:44:19 +02:00
|
|
|
|
{
|
|
|
|
|
Cursor_Sequence *o = new Cursor_Sequence( 0, 24, 800, 18 );
|
|
|
|
|
|
2012-12-11 06:47:44 +01:00
|
|
|
|
o->color( FL_DARK1 );
|
2012-10-24 07:44:19 +02:00
|
|
|
|
|
|
|
|
|
o->label( "Edit" );
|
|
|
|
|
o->cursor_color( FL_YELLOW );
|
|
|
|
|
|
|
|
|
|
edit_cursor_track = o;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
Cursor_Sequence *o = new Cursor_Sequence( 0, 24, 800, 18 );
|
|
|
|
|
|
2012-12-11 06:47:44 +01:00
|
|
|
|
o->color( FL_DARK2 );
|
2012-10-24 07:44:19 +02:00
|
|
|
|
|
|
|
|
|
o->label( "Punch" );
|
|
|
|
|
o->cursor_color( FL_RED );
|
|
|
|
|
|
|
|
|
|
punch_cursor_track = o;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
Cursor_Sequence *o = new Cursor_Sequence( 0, 24, 800, 18 );
|
|
|
|
|
|
2012-12-11 06:47:44 +01:00
|
|
|
|
o->color( FL_DARK1 );
|
2012-10-24 07:44:19 +02:00
|
|
|
|
|
|
|
|
|
o->label( "Playback" );
|
|
|
|
|
o->cursor_color( FL_GREEN );
|
|
|
|
|
|
|
|
|
|
play_cursor_track = o;
|
|
|
|
|
}
|
2008-04-18 22:18:07 +02:00
|
|
|
|
|
2008-05-05 01:06:36 +02:00
|
|
|
|
/* { */
|
|
|
|
|
/* Annotation_Sequence *o = new Annotation_Sequence( 0, 24, 800, 24 ); */
|
2008-04-18 22:18:07 +02:00
|
|
|
|
|
2008-05-05 01:06:36 +02:00
|
|
|
|
/* o->color( fl_gray_ramp( 'F' ) ); */
|
2008-04-18 22:18:07 +02:00
|
|
|
|
|
2008-05-05 01:06:36 +02:00
|
|
|
|
/* o->label( "Ruler" ); */
|
|
|
|
|
/* o->align( FL_ALIGN_LEFT ); */
|
|
|
|
|
|
|
|
|
|
/* ruler_track = o; */
|
|
|
|
|
/* } */
|
2008-04-18 22:18:07 +02:00
|
|
|
|
|
2008-02-21 17:20:36 +01:00
|
|
|
|
rulers = o;
|
|
|
|
|
o->end();
|
2012-12-11 06:47:44 +01:00
|
|
|
|
|
|
|
|
|
ruler_height = o->child( 0 )->h() * o->children();
|
|
|
|
|
|
|
|
|
|
DMESSAGE( "Ruler height: %i", ruler_height );
|
|
|
|
|
|
|
|
|
|
o->size( o->w(), ruler_height );
|
2008-02-21 17:20:36 +01:00
|
|
|
|
}
|
|
|
|
|
|
2012-11-02 01:39:34 +01:00
|
|
|
|
{
|
2012-12-11 06:47:44 +01:00
|
|
|
|
Fl_Tile *o = new Fl_Tile( X, rulers->y() + ruler_height, W, H - rulers->h() );
|
2012-11-02 01:39:34 +01:00
|
|
|
|
o->box(FL_FLAT_BOX);
|
|
|
|
|
o->when( FL_WHEN_RELEASE );
|
|
|
|
|
{
|
|
|
|
|
Fl_Group *o = new Fl_Group( X, rulers->y() + rulers->h(), W, ( H - rulers->h() ) - 50 );
|
2012-12-11 06:47:44 +01:00
|
|
|
|
o->box(FL_FLAT_BOX);
|
2012-11-02 01:39:34 +01:00
|
|
|
|
{
|
|
|
|
|
_fpp = 8;
|
|
|
|
|
Fl_Pack *o = new Fl_Pack( X, rulers->y() + rulers->h(), W, 1 );
|
|
|
|
|
o->type( Fl_Pack::VERTICAL );
|
|
|
|
|
o->spacing( 1 );
|
|
|
|
|
|
|
|
|
|
tracks = o;
|
|
|
|
|
o->end();
|
2012-12-11 06:47:44 +01:00
|
|
|
|
/* Fl_Group::current()->resizable( o ); */
|
2012-11-02 01:39:34 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
o->end();
|
|
|
|
|
track_window = o;
|
|
|
|
|
}
|
|
|
|
|
{
|
2012-11-02 01:41:08 +01:00
|
|
|
|
Fl_Panzoomer *o = new Timeline_Panzoomer( X,
|
2012-11-02 01:39:34 +01:00
|
|
|
|
track_window->y() + track_window->h(),
|
|
|
|
|
W,
|
|
|
|
|
50 );
|
|
|
|
|
|
|
|
|
|
o->zoom_range( 1, 20 );
|
|
|
|
|
o->zoom( 8 );
|
|
|
|
|
|
|
|
|
|
o->box( FL_FLAT_BOX );
|
2012-11-16 10:28:09 +01:00
|
|
|
|
o->color( FL_DARK1 );
|
2012-11-02 01:39:34 +01:00
|
|
|
|
o->type( FL_HORIZONTAL );
|
|
|
|
|
o->callback( cb_scroll, this );
|
|
|
|
|
|
|
|
|
|
panzoomer = o;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Fl_Box *spacebox = new Fl_Box( 0,0,1,1 );
|
2008-02-26 05:58:15 +01:00
|
|
|
|
|
2012-11-02 01:39:34 +01:00
|
|
|
|
o->end();
|
2012-12-11 06:47:44 +01:00
|
|
|
|
o->resizable( spacebox );
|
2008-05-28 01:47:47 +02:00
|
|
|
|
|
2012-11-02 01:39:34 +01:00
|
|
|
|
spacebox->resize( X, rulers->y() + ( ( H - rulers->h() ) - 50 ),
|
|
|
|
|
W, 125 );
|
2008-02-21 17:20:36 +01:00
|
|
|
|
|
2012-11-02 01:39:34 +01:00
|
|
|
|
o->position( panzoomer->x(), panzoomer->y(),
|
|
|
|
|
panzoomer->x(), track_window->y() + track_window->h() );
|
2008-02-21 17:20:36 +01:00
|
|
|
|
|
2012-11-02 01:39:34 +01:00
|
|
|
|
tile = o;
|
2012-12-11 06:47:44 +01:00
|
|
|
|
resizable(o);
|
2008-02-21 17:20:36 +01:00
|
|
|
|
}
|
|
|
|
|
|
2008-04-26 14:37:25 +02:00
|
|
|
|
/* rulers go above tracks... */
|
|
|
|
|
add( rulers );
|
2008-04-12 21:50:36 +02:00
|
|
|
|
|
2012-12-11 06:47:44 +01:00
|
|
|
|
/* redraw(); */
|
2008-02-23 07:59:10 +01:00
|
|
|
|
|
2008-02-21 17:20:36 +01:00
|
|
|
|
end();
|
2008-04-12 21:50:36 +02:00
|
|
|
|
|
|
|
|
|
Fl::add_timeout( UPDATE_FREQ, update_cb, this );
|
2008-02-21 17:20:36 +01:00
|
|
|
|
}
|
2008-02-21 11:39:13 +01:00
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Timeline::beats_per_minute ( nframes_t when, float bpm )
|
|
|
|
|
{
|
|
|
|
|
tempo_track->add( new Tempo_Point( when, bpm ) );
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-08 00:55:01 +02:00
|
|
|
|
void
|
|
|
|
|
Timeline::time ( nframes_t when, int bpb, int note_type )
|
|
|
|
|
{
|
|
|
|
|
time_track->add( new Time_Point( when, bpb, note_type ) );
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-14 20:31:11 +02:00
|
|
|
|
/************/
|
|
|
|
|
/* Snapping */
|
|
|
|
|
/************/
|
|
|
|
|
|
2008-05-13 06:38:05 +02:00
|
|
|
|
struct nearest_line_arg
|
|
|
|
|
{
|
|
|
|
|
nframes_t original;
|
|
|
|
|
nframes_t closest;
|
2008-05-30 04:28:26 +02:00
|
|
|
|
bool bar;
|
2008-05-13 06:38:05 +02:00
|
|
|
|
};
|
2008-04-18 22:18:07 +02:00
|
|
|
|
|
2008-05-13 06:38:05 +02:00
|
|
|
|
const int snap_pixel = 10;
|
2008-04-18 22:18:07 +02:00
|
|
|
|
|
2008-05-13 06:38:05 +02:00
|
|
|
|
static nframes_t
|
|
|
|
|
abs_diff ( nframes_t n1, nframes_t n2 )
|
|
|
|
|
{
|
|
|
|
|
return n1 > n2 ? n1 - n2 : n2 - n1;
|
|
|
|
|
}
|
2008-05-03 03:48:16 +02:00
|
|
|
|
|
2008-05-30 00:45:04 +02:00
|
|
|
|
static void
|
2008-07-02 05:19:31 +02:00
|
|
|
|
nearest_line_snap_cb ( nframes_t frame, const BBT &bbt, void *arg )
|
2008-05-03 03:48:16 +02:00
|
|
|
|
{
|
2008-05-13 06:38:05 +02:00
|
|
|
|
nearest_line_arg *n = (nearest_line_arg *)arg;
|
|
|
|
|
|
2008-05-30 04:28:26 +02:00
|
|
|
|
if ( n->bar && bbt.beat )
|
2008-05-14 20:31:11 +02:00
|
|
|
|
return;
|
|
|
|
|
|
2008-05-13 06:38:05 +02:00
|
|
|
|
if ( Timeline::snap_magnetic &&
|
|
|
|
|
abs_diff( frame, n->original ) > timeline->x_to_ts( snap_pixel ) )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if ( abs_diff( frame, n->original ) < abs_diff( n->original, n->closest ) )
|
|
|
|
|
n->closest = frame;
|
2008-05-03 03:48:16 +02:00
|
|
|
|
}
|
|
|
|
|
|
2008-07-02 05:19:31 +02:00
|
|
|
|
static void
|
|
|
|
|
nearest_line_cb ( nframes_t frame, const BBT &bbt, void *arg )
|
|
|
|
|
{
|
|
|
|
|
nearest_line_arg *n = (nearest_line_arg *)arg;
|
|
|
|
|
|
|
|
|
|
if ( n->bar && bbt.beat )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if ( abs_diff( frame, n->original ) < abs_diff( n->original, n->closest ) )
|
|
|
|
|
n->closest = frame;
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-30 00:45:04 +02:00
|
|
|
|
static void
|
2008-05-30 04:28:26 +02:00
|
|
|
|
prev_next_line_cb ( nframes_t frame, const BBT &bbt, void *arg )
|
2008-05-30 00:45:04 +02:00
|
|
|
|
{
|
|
|
|
|
nearest_line_arg *n = (nearest_line_arg *)arg;
|
|
|
|
|
|
2008-05-30 04:28:26 +02:00
|
|
|
|
if ( n->bar && bbt.beat )
|
|
|
|
|
return;
|
|
|
|
|
|
2008-05-30 00:45:04 +02:00
|
|
|
|
if ( abs_diff( frame, n->original ) < abs_diff( n->original, n->closest ) )
|
|
|
|
|
n->closest = frame;
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-14 20:31:11 +02:00
|
|
|
|
/** Set the value pointed to by /frame/ to the frame number of the of
|
2008-05-25 08:14:17 +02:00
|
|
|
|
the nearest measure line to /when/. Returns true if the new value of
|
|
|
|
|
*frame is valid, false otherwise. */
|
2008-05-03 03:48:16 +02:00
|
|
|
|
bool
|
2008-07-02 05:19:31 +02:00
|
|
|
|
Timeline::nearest_line ( nframes_t *frame, bool snap ) const
|
2008-02-28 21:36:46 +01:00
|
|
|
|
{
|
2010-01-26 15:31:04 +01:00
|
|
|
|
if ( snap && ( snapping_on_hold || None == Timeline::snap_to ) )
|
2008-05-03 03:48:16 +02:00
|
|
|
|
return false;
|
2008-04-26 18:07:43 +02:00
|
|
|
|
|
2008-05-29 03:31:06 +02:00
|
|
|
|
nframes_t when = *frame;
|
|
|
|
|
|
2013-03-13 01:55:28 +01:00
|
|
|
|
nearest_line_arg n = { when, JACK_MAX_FRAMES, snap && Timeline::Bars == Timeline::snap_to };
|
2008-04-27 18:01:55 +02:00
|
|
|
|
|
2008-06-01 03:13:18 +02:00
|
|
|
|
render_tempomap( when > x_to_ts( w() >> 1 ) ? when - x_to_ts( w() >> 1 ) : 0,
|
2008-07-02 05:19:31 +02:00
|
|
|
|
when + x_to_ts( w() >> 1 ), snap ? nearest_line_snap_cb : nearest_line_cb, &n );
|
2008-05-13 06:38:05 +02:00
|
|
|
|
|
2013-03-13 01:55:28 +01:00
|
|
|
|
if ( n.closest == JACK_MAX_FRAMES )
|
2008-05-29 03:31:06 +02:00
|
|
|
|
return false;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
*frame = n.closest;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2008-05-03 03:48:16 +02:00
|
|
|
|
}
|
2008-04-27 15:37:50 +02:00
|
|
|
|
|
2008-05-30 00:45:04 +02:00
|
|
|
|
/** Set the value pointed to by /frame/ to the frame number of the of
|
|
|
|
|
the nearest measure line to *greater than* /when/. Returns true if
|
|
|
|
|
the new value of *frame is valid, false otherwise. */
|
|
|
|
|
bool
|
2008-05-30 04:28:26 +02:00
|
|
|
|
Timeline::next_line ( nframes_t *frame, bool bar ) const
|
2008-05-30 00:45:04 +02:00
|
|
|
|
{
|
2013-03-31 03:48:41 +02:00
|
|
|
|
const nframes_t when = *frame + 1;
|
2008-05-30 00:45:04 +02:00
|
|
|
|
|
2013-03-13 01:55:28 +01:00
|
|
|
|
nearest_line_arg n = { when, JACK_MAX_FRAMES, bar };
|
2008-05-30 00:45:04 +02:00
|
|
|
|
|
2013-03-31 03:48:41 +02:00
|
|
|
|
const nframes_t window = sample_rate() * 60;
|
|
|
|
|
nframes_t length = window;
|
2008-05-30 00:45:04 +02:00
|
|
|
|
|
2013-03-31 03:48:41 +02:00
|
|
|
|
if ( when > JACK_MAX_FRAMES - length )
|
|
|
|
|
length = JACK_MAX_FRAMES - when;
|
|
|
|
|
|
|
|
|
|
render_tempomap( when, length, prev_next_line_cb, &n );
|
|
|
|
|
|
|
|
|
|
*frame = n.closest;
|
|
|
|
|
|
|
|
|
|
return true;
|
2008-05-30 00:45:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Set the value pointed to by /frame/ to the frame number of the of
|
|
|
|
|
the nearest measure line to *less than* /when/. Returns true if
|
|
|
|
|
the new value of *frame is valid, false otherwise. */
|
|
|
|
|
bool
|
2008-05-30 04:28:26 +02:00
|
|
|
|
Timeline::prev_line ( nframes_t *frame, bool bar ) const
|
2008-05-30 00:45:04 +02:00
|
|
|
|
{
|
2013-03-31 03:48:41 +02:00
|
|
|
|
if ( ! *frame )
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
const nframes_t when = *frame - 1;
|
2008-05-30 00:45:04 +02:00
|
|
|
|
|
2013-03-13 01:55:28 +01:00
|
|
|
|
nearest_line_arg n = { when, 0, bar };
|
2008-05-30 00:45:04 +02:00
|
|
|
|
|
2013-03-31 03:48:41 +02:00
|
|
|
|
const nframes_t window = sample_rate() * 60;
|
|
|
|
|
nframes_t start = 0;
|
2013-04-15 22:40:33 +02:00
|
|
|
|
nframes_t length = when;
|
2008-05-30 00:45:04 +02:00
|
|
|
|
|
2013-03-31 03:48:41 +02:00
|
|
|
|
if ( when > window )
|
2013-04-15 22:40:33 +02:00
|
|
|
|
{
|
2013-03-31 03:48:41 +02:00
|
|
|
|
start = when - window;
|
2013-04-15 22:40:33 +02:00
|
|
|
|
length = window;
|
|
|
|
|
}
|
2013-03-31 03:48:41 +02:00
|
|
|
|
|
2013-04-15 22:40:33 +02:00
|
|
|
|
render_tempomap( start, length, prev_next_line_cb, &n );
|
2013-03-31 03:48:41 +02:00
|
|
|
|
|
|
|
|
|
*frame = n.closest;
|
|
|
|
|
|
|
|
|
|
return true;
|
2008-05-30 00:45:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
2008-05-14 20:31:11 +02:00
|
|
|
|
|
|
|
|
|
|
2008-06-19 06:14:14 +02:00
|
|
|
|
/** given screen pixel coordinate /x/ return frame offset into
|
|
|
|
|
* timeline, taking into account the current scroll position, widget
|
|
|
|
|
* layout, etc. */
|
2008-05-03 03:48:16 +02:00
|
|
|
|
nframes_t
|
|
|
|
|
Timeline::x_to_offset ( int x ) const
|
|
|
|
|
{
|
|
|
|
|
return x_to_ts( max( 0, x - Track::width() ) ) + xoffset;
|
|
|
|
|
}
|
2008-04-26 18:07:43 +02:00
|
|
|
|
|
2013-04-06 02:13:51 +02:00
|
|
|
|
int
|
|
|
|
|
Timeline::offset_to_x ( nframes_t frame ) const
|
|
|
|
|
{
|
|
|
|
|
return ts_to_x( frame - xoffset ) + Track::width();
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-14 20:31:11 +02:00
|
|
|
|
/** draws a single measure line */
|
2012-12-12 07:13:18 +01:00
|
|
|
|
void
|
|
|
|
|
Timeline::draw_measure_cb ( nframes_t frame, const BBT &bbt, void *v )
|
2008-04-30 23:03:58 +02:00
|
|
|
|
{
|
2012-12-12 07:13:18 +01:00
|
|
|
|
Timeline *o = (Timeline*)v;
|
|
|
|
|
|
2012-05-28 04:53:02 +02:00
|
|
|
|
Fl_Color c = FL_LIGHT3;
|
2008-05-14 19:22:34 +02:00
|
|
|
|
|
2012-12-12 07:13:18 +01:00
|
|
|
|
if ( o->panzoomer->zoom() >= 15 )
|
|
|
|
|
return;
|
|
|
|
|
|
2008-05-14 19:22:34 +02:00
|
|
|
|
if ( bbt.beat )
|
2013-02-23 02:18:52 +01:00
|
|
|
|
{
|
2012-12-12 07:13:18 +01:00
|
|
|
|
if ( o->panzoomer->zoom() > 12 )
|
|
|
|
|
return;
|
|
|
|
|
else
|
|
|
|
|
c = FL_DARK1;
|
2013-02-23 02:18:52 +01:00
|
|
|
|
}
|
2008-05-14 19:22:34 +02:00
|
|
|
|
|
2012-05-28 04:53:02 +02:00
|
|
|
|
fl_color( fl_color_add_alpha( c, 64 ) );
|
2012-04-27 19:14:53 +02:00
|
|
|
|
|
2008-05-14 19:22:34 +02:00
|
|
|
|
const int x = timeline->ts_to_x( frame - timeline->xoffset ) + Track::width();
|
|
|
|
|
|
2012-05-21 05:28:09 +02:00
|
|
|
|
fl_line( x, 0, x, 2000 );
|
2008-04-30 23:03:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
2008-05-14 20:31:11 +02:00
|
|
|
|
/* FIXME: wrong place for this */
|
2008-05-13 23:38:13 +02:00
|
|
|
|
const float ticks_per_beat = 1920.0;
|
|
|
|
|
|
2008-06-19 06:14:14 +02:00
|
|
|
|
/** re-render the unified tempomap based on the current contents of the Time and Tempo sequences */
|
2008-05-14 23:50:31 +02:00
|
|
|
|
void
|
|
|
|
|
Timeline::update_tempomap ( void )
|
|
|
|
|
{
|
2008-05-15 01:47:28 +02:00
|
|
|
|
/* FIXME: we need some type of locking! */
|
2008-05-14 23:50:31 +02:00
|
|
|
|
_tempomap.clear();
|
|
|
|
|
|
|
|
|
|
for ( list <Sequence_Widget *>::const_iterator i = time_track->_widgets.begin();
|
|
|
|
|
i != time_track->_widgets.end(); ++i )
|
|
|
|
|
_tempomap.push_back( *i );
|
|
|
|
|
|
|
|
|
|
for ( list <Sequence_Widget *>::const_iterator i = tempo_track->_widgets.begin();
|
|
|
|
|
i != tempo_track->_widgets.end(); ++i )
|
|
|
|
|
_tempomap.push_back( *i );
|
|
|
|
|
|
2008-05-15 00:36:23 +02:00
|
|
|
|
_tempomap.sort( Sequence_Widget::sort_func );
|
2008-05-14 23:50:31 +02:00
|
|
|
|
}
|
|
|
|
|
|
2008-06-19 06:14:14 +02:00
|
|
|
|
/** return a stucture containing the BBT info which applies at /frame/ */
|
2008-05-14 22:00:56 +02:00
|
|
|
|
position_info
|
2008-05-14 20:31:11 +02:00
|
|
|
|
Timeline::solve_tempomap ( nframes_t frame ) const
|
2008-05-13 07:39:29 +02:00
|
|
|
|
{
|
2008-05-14 22:20:04 +02:00
|
|
|
|
return render_tempomap( frame, 0, 0, 0 );
|
2008-05-13 07:39:29 +02:00
|
|
|
|
}
|
|
|
|
|
|
2008-05-15 01:47:28 +02:00
|
|
|
|
/* THREAD: UI and RT */
|
2008-03-01 06:42:03 +01:00
|
|
|
|
/** draw appropriate measure lines inside the given bounding box */
|
2008-05-14 20:31:11 +02:00
|
|
|
|
position_info
|
|
|
|
|
Timeline::render_tempomap( nframes_t start, nframes_t length, measure_line_callback * cb, void *arg ) const
|
2008-02-21 11:39:13 +01:00
|
|
|
|
{
|
2008-05-14 19:22:34 +02:00
|
|
|
|
const nframes_t end = start + length;
|
2008-02-28 17:37:02 +01:00
|
|
|
|
|
2008-05-14 20:31:11 +02:00
|
|
|
|
position_info pos;
|
|
|
|
|
memset( &pos, 0, sizeof( pos ) );
|
|
|
|
|
|
|
|
|
|
BBT &bbt = pos.bbt;
|
2008-02-21 11:39:13 +01:00
|
|
|
|
|
2008-06-14 06:51:15 +02:00
|
|
|
|
/* default values */
|
|
|
|
|
pos.beat_type = 4;
|
|
|
|
|
pos.beats_per_bar = 4;
|
|
|
|
|
pos.tempo = 120.0;
|
|
|
|
|
|
2008-04-27 18:01:55 +02:00
|
|
|
|
const nframes_t samples_per_minute = sample_rate() * 60;
|
2008-02-21 11:39:13 +01:00
|
|
|
|
|
2008-05-14 19:22:34 +02:00
|
|
|
|
float bpm = 120.0f;
|
2008-05-13 07:39:29 +02:00
|
|
|
|
|
2008-05-14 19:22:34 +02:00
|
|
|
|
time_sig sig;
|
2008-04-30 23:03:58 +02:00
|
|
|
|
|
2008-05-14 19:22:34 +02:00
|
|
|
|
sig.beats_per_bar = 4;
|
|
|
|
|
sig.beat_type = 4;
|
2008-04-30 23:03:58 +02:00
|
|
|
|
|
2008-05-13 07:39:29 +02:00
|
|
|
|
nframes_t f = 0;
|
2008-05-14 20:43:12 +02:00
|
|
|
|
nframes_t next = 0;
|
2008-04-30 23:03:58 +02:00
|
|
|
|
|
2008-05-14 19:22:34 +02:00
|
|
|
|
nframes_t frames_per_beat = samples_per_minute / bpm;
|
2008-04-30 23:03:58 +02:00
|
|
|
|
|
2008-05-17 01:44:08 +02:00
|
|
|
|
if ( ! _tempomap.size() )
|
|
|
|
|
return pos;
|
|
|
|
|
|
2008-05-14 23:50:31 +02:00
|
|
|
|
for ( list <const Sequence_Widget *>::const_iterator i = _tempomap.begin();
|
|
|
|
|
i != _tempomap.end(); ++i )
|
2008-05-14 19:22:34 +02:00
|
|
|
|
{
|
2008-04-30 23:03:58 +02:00
|
|
|
|
|
2008-05-14 19:22:34 +02:00
|
|
|
|
if ( ! strcmp( (*i)->class_name(), "Tempo_Point" ) )
|
|
|
|
|
{
|
|
|
|
|
const Tempo_Point *p = (Tempo_Point*)(*i);
|
2008-04-30 23:03:58 +02:00
|
|
|
|
|
2008-05-14 19:22:34 +02:00
|
|
|
|
bpm = p->tempo();
|
|
|
|
|
frames_per_beat = samples_per_minute / bpm;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
const Time_Point *p = (Time_Point*)(*i);
|
2008-04-30 23:03:58 +02:00
|
|
|
|
|
2008-05-14 19:22:34 +02:00
|
|
|
|
sig = p->time();
|
2008-05-15 01:47:28 +02:00
|
|
|
|
|
|
|
|
|
/* Time point resets beat */
|
|
|
|
|
bbt.beat = 0;
|
2008-05-14 19:22:34 +02:00
|
|
|
|
}
|
2008-05-13 06:38:36 +02:00
|
|
|
|
|
2008-04-30 23:03:58 +02:00
|
|
|
|
{
|
2008-05-14 23:50:31 +02:00
|
|
|
|
list <const Sequence_Widget *>::const_iterator n = i;
|
2008-05-14 19:22:34 +02:00
|
|
|
|
++n;
|
2008-05-14 23:50:31 +02:00
|
|
|
|
if ( n == _tempomap.end() )
|
2008-05-14 19:22:34 +02:00
|
|
|
|
next = end;
|
|
|
|
|
else
|
2008-05-14 20:43:12 +02:00
|
|
|
|
// next = min( (*n)->start(), end );
|
|
|
|
|
/* points may not always be aligned with beat boundaries, so we must align here */
|
|
|
|
|
next = (*n)->start() - ( ( (*n)->start() - (*i)->start() ) % frames_per_beat );
|
2008-05-14 19:22:34 +02:00
|
|
|
|
}
|
2008-05-13 07:39:29 +02:00
|
|
|
|
|
2008-05-14 21:17:58 +02:00
|
|
|
|
for ( ; f < next; ++bbt.beat, f += frames_per_beat )
|
2008-05-14 19:22:34 +02:00
|
|
|
|
{
|
2008-05-14 21:17:58 +02:00
|
|
|
|
|
|
|
|
|
if ( bbt.beat == sig.beats_per_bar )
|
2008-05-14 19:22:34 +02:00
|
|
|
|
{
|
|
|
|
|
bbt.beat = 0;
|
|
|
|
|
++bbt.bar;
|
|
|
|
|
}
|
2008-05-13 07:39:29 +02:00
|
|
|
|
|
2008-05-14 21:20:11 +02:00
|
|
|
|
if ( f >= start )
|
2008-05-14 19:22:34 +02:00
|
|
|
|
{
|
|
|
|
|
/* in the zone */
|
2008-05-14 20:31:11 +02:00
|
|
|
|
if ( cb )
|
|
|
|
|
cb( f, bbt, arg );
|
2008-05-14 19:22:34 +02:00
|
|
|
|
}
|
2008-05-14 21:20:11 +02:00
|
|
|
|
|
2008-05-17 01:44:08 +02:00
|
|
|
|
/* ugliness to avoid failing out at -1 */
|
|
|
|
|
if ( end >= frames_per_beat )
|
|
|
|
|
{
|
|
|
|
|
if ( f >= end - frames_per_beat )
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
else if ( f + frames_per_beat >= end )
|
2008-05-14 21:20:11 +02:00
|
|
|
|
goto done;
|
2008-02-28 19:34:10 +01:00
|
|
|
|
}
|
2008-02-21 11:39:13 +01:00
|
|
|
|
}
|
2008-04-27 15:37:50 +02:00
|
|
|
|
|
2008-05-14 20:31:11 +02:00
|
|
|
|
done:
|
|
|
|
|
|
|
|
|
|
pos.frame = f;
|
|
|
|
|
pos.tempo = bpm;
|
|
|
|
|
pos.beats_per_bar = sig.beats_per_bar;
|
|
|
|
|
pos.beat_type = sig.beat_type;
|
2008-05-14 19:22:34 +02:00
|
|
|
|
|
2008-05-14 22:20:04 +02:00
|
|
|
|
assert( f <= end );
|
|
|
|
|
|
|
|
|
|
assert( end - f <= frames_per_beat );
|
2008-05-14 20:31:11 +02:00
|
|
|
|
|
|
|
|
|
/* FIXME: this this right? */
|
2008-05-14 19:22:34 +02:00
|
|
|
|
|
2008-05-17 01:44:18 +02:00
|
|
|
|
const double frames_per_tick = frames_per_beat / ticks_per_beat;
|
2008-05-14 22:20:04 +02:00
|
|
|
|
bbt.tick = ( end - f ) / frames_per_tick;
|
2008-05-14 20:31:11 +02:00
|
|
|
|
|
|
|
|
|
return pos;
|
2008-02-21 11:39:13 +01:00
|
|
|
|
}
|
2008-02-28 19:34:10 +01:00
|
|
|
|
|
2008-06-19 06:14:14 +02:00
|
|
|
|
/** maybe draw appropriate measure lines in rectangle defined by X, Y, W, and H, using color /color/ as a base */
|
2008-04-18 22:18:07 +02:00
|
|
|
|
void
|
2012-04-27 19:14:53 +02:00
|
|
|
|
Timeline::draw_measure_lines ( int X, int Y, int W, int H )
|
2008-04-18 22:18:07 +02:00
|
|
|
|
{
|
2008-05-14 20:31:11 +02:00
|
|
|
|
if ( ! draw_with_measure_lines )
|
|
|
|
|
return;
|
|
|
|
|
|
2012-04-27 19:14:53 +02:00
|
|
|
|
fl_line_style( FL_SOLID, 0 );
|
2008-05-14 19:22:34 +02:00
|
|
|
|
|
|
|
|
|
const nframes_t start = x_to_offset( X );
|
|
|
|
|
const nframes_t length = x_to_ts( W );
|
|
|
|
|
|
|
|
|
|
fl_push_clip( X, Y, W, H );
|
|
|
|
|
|
2012-12-12 07:13:18 +01:00
|
|
|
|
render_tempomap( start, length, draw_measure_cb, this );
|
2008-05-14 19:22:34 +02:00
|
|
|
|
|
|
|
|
|
fl_pop_clip();
|
2008-04-18 22:18:07 +02:00
|
|
|
|
}
|
|
|
|
|
|
2008-02-28 19:34:10 +01:00
|
|
|
|
void
|
2012-12-11 06:47:44 +01:00
|
|
|
|
Timeline::draw_clip_rulers ( void * v, int X, int Y, int W, int H )
|
|
|
|
|
{
|
|
|
|
|
Timeline *tl = (Timeline *)v;
|
|
|
|
|
|
|
|
|
|
fl_push_clip( X, Y, W, H );
|
|
|
|
|
|
|
|
|
|
tl->draw_box();
|
|
|
|
|
|
|
|
|
|
tl->draw_child( *tl->rulers );
|
|
|
|
|
|
|
|
|
|
fl_pop_clip();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Timeline::draw_clip_tracks ( void * v, int X, int Y, int W, int H )
|
2008-02-28 19:34:10 +01:00
|
|
|
|
{
|
|
|
|
|
Timeline *tl = (Timeline *)v;
|
|
|
|
|
|
|
|
|
|
fl_push_clip( X, Y, W, H );
|
|
|
|
|
|
2008-04-28 06:42:05 +02:00
|
|
|
|
tl->draw_box();
|
2008-02-29 03:47:29 +01:00
|
|
|
|
|
2012-12-11 06:47:44 +01:00
|
|
|
|
fl_damage_t pzd = tl->panzoomer->damage();
|
|
|
|
|
|
2012-11-02 01:39:34 +01:00
|
|
|
|
tl->draw_child( *tl->tile );
|
2008-02-28 19:34:10 +01:00
|
|
|
|
|
2012-12-11 06:47:44 +01:00
|
|
|
|
tl->panzoomer->damage( pzd );
|
2012-04-27 19:14:53 +02:00
|
|
|
|
|
2008-04-28 07:11:47 +02:00
|
|
|
|
fl_pop_clip();
|
2008-02-28 19:34:10 +01:00
|
|
|
|
}
|
|
|
|
|
|
2008-06-19 06:14:14 +02:00
|
|
|
|
/** handle resize event */
|
2008-04-23 04:22:46 +02:00
|
|
|
|
void
|
|
|
|
|
Timeline::resize ( int X, int Y, int W, int H )
|
|
|
|
|
{
|
2010-01-08 07:04:28 +01:00
|
|
|
|
BASE::resize( X, Y, W, H );
|
2008-03-09 18:38:50 +01:00
|
|
|
|
|
2012-11-02 01:39:34 +01:00
|
|
|
|
tile->resizable()->resize( X,
|
|
|
|
|
tile->y() + tile->h() - 150,
|
2012-12-11 06:47:44 +01:00
|
|
|
|
W, 125 );
|
|
|
|
|
|
2008-04-26 12:17:47 +02:00
|
|
|
|
/* why is THIS necessary? */
|
2012-12-11 06:47:44 +01:00
|
|
|
|
panzoomer->resize( X,
|
2012-11-02 01:39:34 +01:00
|
|
|
|
tile->y() + tile->h() - 50,
|
|
|
|
|
W,
|
|
|
|
|
50 );
|
|
|
|
|
|
2012-12-11 06:47:44 +01:00
|
|
|
|
track_window->resize( X,
|
2012-11-02 01:39:34 +01:00
|
|
|
|
tile->y(),
|
|
|
|
|
W,
|
|
|
|
|
tile->h() - 50);
|
|
|
|
|
|
2012-12-11 06:47:44 +01:00
|
|
|
|
/* /\* rulers->resize( X, *\/ */
|
|
|
|
|
/* /\* rulers->y(), *\/ */
|
|
|
|
|
/* /\* W, *\/ */
|
|
|
|
|
/* /\* rulers->h() ); *\/ */
|
2012-11-02 01:39:34 +01:00
|
|
|
|
|
2012-12-11 06:47:44 +01:00
|
|
|
|
/* tile->redraw(); */
|
2008-04-23 04:22:46 +02:00
|
|
|
|
}
|
2008-03-09 18:38:50 +01:00
|
|
|
|
|
2012-10-24 07:44:19 +02:00
|
|
|
|
|
2008-05-29 22:54:05 +02:00
|
|
|
|
void
|
2012-10-24 07:44:19 +02:00
|
|
|
|
Timeline::add_cursor ( Cursor_Region *o )
|
|
|
|
|
{
|
|
|
|
|
if ( !strcmp( o->type(), "Edit" ) )
|
|
|
|
|
{
|
|
|
|
|
DMESSAGE( "Adding cursor to edit track" );
|
|
|
|
|
edit_cursor_track->add( o );
|
|
|
|
|
}
|
|
|
|
|
else if ( !strcmp( o->type(), "Punch" ) )
|
|
|
|
|
{
|
|
|
|
|
DMESSAGE( "Adding cursor to punch track" );
|
|
|
|
|
punch_cursor_track->add( o );
|
|
|
|
|
}
|
|
|
|
|
else if ( !strcmp( o->type(), "Playback" ) )
|
|
|
|
|
{
|
|
|
|
|
DMESSAGE( "Adding cursor to punch track" );
|
|
|
|
|
play_cursor_track->add( o );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Timeline::add_cursor ( Cursor_Point *o )
|
2008-05-29 22:54:05 +02:00
|
|
|
|
{
|
2012-10-24 07:44:19 +02:00
|
|
|
|
if ( !strcmp( o->type(), "Edit" ) )
|
|
|
|
|
edit_cursor_track->add( o );
|
|
|
|
|
else if ( !strcmp( o->type(), "Punch" ) )
|
|
|
|
|
punch_cursor_track->add( o );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Timeline::draw_cursors ( Cursor_Sequence *o ) const
|
|
|
|
|
{
|
2012-11-02 01:39:21 +01:00
|
|
|
|
fl_push_clip( tracks->x() + Track::width(), rulers->y() + rulers->h(), tracks->w() - Track::width(), h() - rulers->h() - panzoomer->h() );
|
2012-10-24 07:44:19 +02:00
|
|
|
|
|
|
|
|
|
if ( o && o->_widgets.size() > 0 )
|
2008-05-29 22:54:05 +02:00
|
|
|
|
{
|
2012-10-24 07:44:19 +02:00
|
|
|
|
for ( std::list<Sequence_Widget*>::const_iterator i = o->_widgets.begin();
|
|
|
|
|
i != o->_widgets.end();
|
|
|
|
|
i++ )
|
|
|
|
|
{
|
|
|
|
|
if ( Timeline::draw_with_cursor_overlay )
|
|
|
|
|
{
|
2013-08-31 07:23:55 +02:00
|
|
|
|
fl_color( fl_color_add_alpha( (*i)->box_color(), 25 ) );
|
2012-10-24 07:44:19 +02:00
|
|
|
|
|
|
|
|
|
fl_rectf( (*i)->line_x(), tracks->y(), (*i)->abs_w(), tracks->h() );
|
|
|
|
|
}
|
2013-05-20 03:24:59 +02:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
fl_color( fl_color_add_alpha( (*i)->box_color(), 127 ));
|
|
|
|
|
|
|
|
|
|
fl_line( (*i)->line_x(), tracks->y(), (*i)->line_x(), tracks->y() + tracks->h() );
|
|
|
|
|
|
|
|
|
|
fl_line( (*i)->line_x() + (*i)->abs_w(), tracks->y(), (*i)->line_x() + (*i)->abs_w(), tracks->y() + tracks->h() );
|
|
|
|
|
}
|
2012-10-24 07:44:19 +02:00
|
|
|
|
}
|
2008-05-29 22:54:05 +02:00
|
|
|
|
}
|
2012-10-24 07:44:19 +02:00
|
|
|
|
|
|
|
|
|
fl_pop_clip();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** draw ancillary cursors (not necessarily in the overlay plane) */
|
|
|
|
|
void
|
|
|
|
|
Timeline::draw_cursors ( void ) const
|
|
|
|
|
{
|
|
|
|
|
draw_cursors( edit_cursor_track );
|
|
|
|
|
|
|
|
|
|
if ( transport->punch_enabled() )
|
|
|
|
|
draw_cursors( punch_cursor_track );
|
2008-05-29 22:54:05 +02:00
|
|
|
|
}
|
2012-10-24 07:44:19 +02:00
|
|
|
|
|
2008-05-29 22:54:05 +02:00
|
|
|
|
|
2008-02-28 19:34:10 +01:00
|
|
|
|
void
|
|
|
|
|
Timeline::draw ( void )
|
|
|
|
|
{
|
2013-03-02 02:05:42 +01:00
|
|
|
|
/* Any code that might affect the structures used for drawing from
|
|
|
|
|
* another thread must use Fl::lock()/unlock()! */
|
2013-02-23 02:18:52 +01:00
|
|
|
|
THREAD_ASSERT( UI );
|
|
|
|
|
|
2008-02-28 19:34:10 +01:00
|
|
|
|
int X, Y, W, H;
|
|
|
|
|
|
2008-04-19 03:05:57 +02:00
|
|
|
|
int bdx = 0;
|
|
|
|
|
int bdw = 0;
|
2008-02-28 19:34:10 +01:00
|
|
|
|
|
2008-04-19 03:05:57 +02:00
|
|
|
|
X = tracks->x() + bdx + 1;
|
|
|
|
|
Y = tracks->y();
|
|
|
|
|
W = tracks->w() - bdw - 1;
|
|
|
|
|
H = tracks->h();
|
2008-03-09 18:38:50 +01:00
|
|
|
|
|
2012-11-02 01:39:21 +01:00
|
|
|
|
adjust_panzoomer();
|
2008-04-28 07:11:47 +02:00
|
|
|
|
|
2012-11-01 11:35:04 +01:00
|
|
|
|
int dx = ts_to_x( _old_xposition ) - ts_to_x( xoffset );
|
2012-12-11 06:47:44 +01:00
|
|
|
|
int dy = _old_yposition - (int)panzoomer->y_value();
|
2012-11-01 11:35:04 +01:00
|
|
|
|
|
|
|
|
|
int c = damage();
|
|
|
|
|
|
2012-11-02 01:39:34 +01:00
|
|
|
|
// c = FL_DAMAGE_ALL;
|
|
|
|
|
|
2012-11-01 11:35:04 +01:00
|
|
|
|
if ( c & FL_DAMAGE_SCROLL )
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
/* draw_child( *rulers ); */
|
|
|
|
|
|
2012-11-02 01:39:34 +01:00
|
|
|
|
Y = track_window->y();
|
|
|
|
|
H = track_window->h();
|
2012-11-01 11:35:04 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( dx )
|
2012-12-11 06:47:44 +01:00
|
|
|
|
/* when scrolling horizontally, scroll rulers */
|
|
|
|
|
fl_scroll( rulers->x() + Track::width(),
|
|
|
|
|
rulers->y(),
|
|
|
|
|
rulers->w(),
|
|
|
|
|
rulers->h(), dx, 0, draw_clip_rulers, this );
|
|
|
|
|
|
|
|
|
|
if ( dy )
|
|
|
|
|
/* when scrolling vertically, also scroll track headers */
|
|
|
|
|
fl_scroll(
|
|
|
|
|
X,
|
|
|
|
|
Y,
|
|
|
|
|
Track::width(),
|
|
|
|
|
H, 0, dy, draw_clip_tracks, this );
|
|
|
|
|
|
|
|
|
|
/* scroll sequences */
|
|
|
|
|
fl_scroll( X + Track::width(),
|
|
|
|
|
Y,
|
|
|
|
|
W - Track::width(),
|
|
|
|
|
H, dx, dy, draw_clip_tracks, this );
|
2012-11-01 11:35:04 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2012-11-02 01:39:34 +01:00
|
|
|
|
|
2012-12-11 06:47:44 +01:00
|
|
|
|
// panzoomer->redraw();
|
2012-11-01 11:35:04 +01:00
|
|
|
|
|
|
|
|
|
if ( c & FL_DAMAGE_ALL )
|
2008-02-28 19:34:10 +01:00
|
|
|
|
{
|
2008-05-04 01:44:28 +02:00
|
|
|
|
DMESSAGE( "complete redraw" );
|
2008-04-27 20:44:20 +02:00
|
|
|
|
|
2010-01-08 07:04:28 +01:00
|
|
|
|
draw_box( box(), BX, BY, w(), h(), color() );
|
2008-02-28 19:34:10 +01:00
|
|
|
|
|
|
|
|
|
draw_child( *rulers );
|
|
|
|
|
|
2012-11-02 01:39:34 +01:00
|
|
|
|
fl_push_clip( tile->x(),
|
|
|
|
|
tile->y(),
|
|
|
|
|
tile->w(),
|
|
|
|
|
tile->h() );
|
2012-04-27 19:14:53 +02:00
|
|
|
|
|
2012-11-02 01:39:34 +01:00
|
|
|
|
draw_child(*tile);
|
|
|
|
|
|
2008-02-28 19:34:10 +01:00
|
|
|
|
fl_pop_clip();
|
2012-11-02 01:39:34 +01:00
|
|
|
|
|
2008-03-05 20:06:41 +01:00
|
|
|
|
redraw_overlay();
|
2012-11-02 01:39:34 +01:00
|
|
|
|
|
2008-05-06 01:49:18 +02:00
|
|
|
|
goto done;
|
2008-02-28 19:34:10 +01:00
|
|
|
|
}
|
|
|
|
|
|
2012-11-01 11:35:04 +01:00
|
|
|
|
if ( c & FL_DAMAGE_CHILD )
|
2008-04-27 09:18:03 +02:00
|
|
|
|
{
|
2012-11-02 01:39:34 +01:00
|
|
|
|
update_child(*rulers);
|
2008-04-27 09:18:03 +02:00
|
|
|
|
|
2012-11-02 01:39:34 +01:00
|
|
|
|
fl_push_clip( tile->x(),
|
|
|
|
|
tile->y(),
|
|
|
|
|
tile->w(),
|
|
|
|
|
tile->h() );
|
2012-10-24 07:44:19 +02:00
|
|
|
|
|
2012-12-11 06:47:44 +01:00
|
|
|
|
/* redraw the panzoomer preview whenever tracks change */
|
|
|
|
|
/* if ( tracks->damage() ) */
|
|
|
|
|
/* panzoomer->redraw(); */
|
|
|
|
|
|
2012-11-02 01:39:34 +01:00
|
|
|
|
update_child(*tile);
|
|
|
|
|
|
|
|
|
|
fl_pop_clip();
|
|
|
|
|
|
|
|
|
|
redraw_overlay();
|
2008-04-27 09:18:03 +02:00
|
|
|
|
}
|
|
|
|
|
|
2008-05-06 01:49:18 +02:00
|
|
|
|
done:
|
|
|
|
|
|
2012-11-02 01:39:21 +01:00
|
|
|
|
/* panzoomer->redraw(); */
|
2012-11-02 01:39:34 +01:00
|
|
|
|
// update_child( *panzoomer );
|
2012-04-27 19:14:53 +02:00
|
|
|
|
|
2012-11-01 11:35:04 +01:00
|
|
|
|
_old_xposition = xoffset;
|
2012-11-02 01:39:21 +01:00
|
|
|
|
_old_yposition = panzoomer->y_value();
|
2008-02-28 19:34:10 +01:00
|
|
|
|
}
|
|
|
|
|
|
2012-12-11 06:47:44 +01:00
|
|
|
|
void
|
|
|
|
|
Timeline::damage_sequence ( void )
|
|
|
|
|
{
|
|
|
|
|
panzoomer->redraw();
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-19 06:14:14 +02:00
|
|
|
|
/** draw a single cursor line at /frame/ with color /color/ using symbol routine /symbol/ for the cap */
|
2008-04-12 21:50:36 +02:00
|
|
|
|
void
|
2008-05-29 22:54:05 +02:00
|
|
|
|
Timeline::draw_cursor ( nframes_t frame, Fl_Color color, void (*symbol)(Fl_Color) ) const
|
2008-04-12 21:50:36 +02:00
|
|
|
|
{
|
2008-05-06 01:49:18 +02:00
|
|
|
|
// int x = ( ts_to_x( frame ) - ts_to_x( xoffset ) ) + tracks->x() + Track::width();
|
|
|
|
|
|
|
|
|
|
if ( frame < xoffset )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
const int x = ts_to_x( frame - xoffset ) + tracks->x() + Track::width();
|
2008-04-12 21:50:36 +02:00
|
|
|
|
|
2008-05-06 01:49:18 +02:00
|
|
|
|
if ( x > tracks->x() + tracks->w() )
|
2008-04-12 21:50:36 +02:00
|
|
|
|
return;
|
|
|
|
|
|
2008-05-06 01:49:18 +02:00
|
|
|
|
const int y = rulers->y() + rulers->h();
|
2012-11-02 01:39:21 +01:00
|
|
|
|
const int h = this->h() - rulers->h() - panzoomer->h();
|
2008-04-12 23:47:33 +02:00
|
|
|
|
|
2008-05-19 05:45:37 +02:00
|
|
|
|
fl_push_clip( tracks->x() + Track::width(), y, tracks->w(), h );
|
2008-04-23 08:01:32 +02:00
|
|
|
|
|
2012-05-21 05:28:09 +02:00
|
|
|
|
fl_line_style( FL_SOLID, 0 );
|
|
|
|
|
fl_color( color );
|
|
|
|
|
fl_line( x, y, x, y + h );
|
2008-04-19 07:30:41 +02:00
|
|
|
|
|
2008-05-22 04:29:06 +02:00
|
|
|
|
fl_push_matrix();
|
2012-05-21 05:28:09 +02:00
|
|
|
|
|
2008-05-22 04:29:06 +02:00
|
|
|
|
fl_translate( x, y );
|
2012-05-21 05:28:09 +02:00
|
|
|
|
fl_scale( 8, 4 );
|
|
|
|
|
|
2008-05-22 04:29:06 +02:00
|
|
|
|
symbol( color );
|
2012-05-21 05:28:09 +02:00
|
|
|
|
|
2008-05-22 04:29:06 +02:00
|
|
|
|
fl_pop_matrix();
|
2012-05-21 05:28:09 +02:00
|
|
|
|
|
2008-04-23 08:01:32 +02:00
|
|
|
|
fl_pop_clip();
|
2008-04-24 04:23:29 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Timeline::draw_playhead ( void )
|
|
|
|
|
{
|
2008-05-22 04:29:06 +02:00
|
|
|
|
draw_cursor( transport->frame, FL_RED, draw_full_arrow_symbol );
|
2008-06-13 04:21:24 +02:00
|
|
|
|
// draw_cursor( length(), FL_BLACK, draw_full_arrow_symbol );
|
2008-04-12 21:50:36 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Timeline::redraw_playhead ( void )
|
|
|
|
|
{
|
2012-11-06 08:50:28 +01:00
|
|
|
|
// static nframes_t last_playhead = -1;
|
2012-03-14 02:44:26 +01:00
|
|
|
|
static int last_playhead_x = -1;
|
2008-04-13 02:02:58 +02:00
|
|
|
|
|
2012-10-24 07:44:19 +02:00
|
|
|
|
/* FIXME: kind of a hackish way to invoke punch / looping stuff from the UI thread... */
|
2012-06-14 03:28:49 +02:00
|
|
|
|
|
|
|
|
|
if ( transport->rolling &&
|
|
|
|
|
transport->rec_enabled() &&
|
2012-10-24 07:44:19 +02:00
|
|
|
|
transport->punch_enabled() )
|
|
|
|
|
{
|
|
|
|
|
if ( _punched_in &&
|
|
|
|
|
transport->frame > _punch_in_frame &&
|
|
|
|
|
transport->frame > _punch_out_frame )
|
|
|
|
|
{
|
|
|
|
|
punch_out( _punch_out_frame );
|
|
|
|
|
}
|
|
|
|
|
else if ( ! _punched_in )
|
|
|
|
|
{
|
|
|
|
|
/* we've passed one or more punch regions... punch in for the next, if available. */
|
|
|
|
|
const Sequence_Widget *w = punch_cursor_track->next( transport->frame );
|
|
|
|
|
|
2013-03-02 02:05:42 +01:00
|
|
|
|
DMESSAGE( "Delayed punch in" );
|
2012-10-24 07:44:19 +02:00
|
|
|
|
if ( w &&
|
|
|
|
|
w->start() > transport->frame )
|
|
|
|
|
{
|
|
|
|
|
_punch_in_frame = w->start();
|
|
|
|
|
_punch_out_frame = w->start() + w->length();
|
|
|
|
|
|
|
|
|
|
punch_in( w->start() );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( transport->rolling )
|
|
|
|
|
{
|
|
|
|
|
if ( play_cursor_track->active_cursor() )
|
|
|
|
|
{
|
2013-02-13 01:50:19 +01:00
|
|
|
|
if ( transport->loop_enabled() )
|
2012-10-24 07:44:19 +02:00
|
|
|
|
{
|
|
|
|
|
if ( transport->frame > playback_end() )
|
|
|
|
|
{
|
|
|
|
|
if ( ! seek_pending() )
|
|
|
|
|
{
|
|
|
|
|
if ( transport->recording )
|
|
|
|
|
{
|
|
|
|
|
stop();
|
|
|
|
|
transport->locate( playback_home() );
|
|
|
|
|
record();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
transport->locate( playback_home() );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if ( transport->frame > playback_end() )
|
|
|
|
|
transport->stop();
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-06-14 03:28:49 +02:00
|
|
|
|
|
2012-03-14 02:44:26 +01:00
|
|
|
|
int playhead_x = ts_to_x( transport->frame );
|
|
|
|
|
|
|
|
|
|
if ( last_playhead_x != playhead_x )
|
2008-04-13 02:02:58 +02:00
|
|
|
|
{
|
|
|
|
|
redraw_overlay();
|
2012-11-06 08:50:28 +01:00
|
|
|
|
// last_playhead = transport->frame;
|
2012-03-14 02:44:26 +01:00
|
|
|
|
last_playhead_x = playhead_x;
|
2008-04-30 03:08:49 +02:00
|
|
|
|
|
|
|
|
|
if ( follow_playhead )
|
2008-05-01 08:47:49 +02:00
|
|
|
|
{
|
|
|
|
|
if ( center_playhead && active() )
|
2012-03-14 02:44:26 +01:00
|
|
|
|
xposition( max( 0, playhead_x - ( ( tracks->w() - Track::width() ) >> 1 ) ) );
|
|
|
|
|
else if ( playhead_x > ts_to_x( xoffset ) + ( tracks->w() - Track::width() ) )
|
|
|
|
|
xposition( playhead_x );
|
2012-11-02 01:39:21 +01:00
|
|
|
|
adjust_panzoomer();
|
2008-05-01 08:47:49 +02:00
|
|
|
|
}
|
2008-04-13 02:02:58 +02:00
|
|
|
|
}
|
2008-04-12 21:50:36 +02:00
|
|
|
|
}
|
|
|
|
|
|
2008-06-19 06:14:14 +02:00
|
|
|
|
/** called so many times a second to redraw the playhead etc. */
|
2008-04-12 21:50:36 +02:00
|
|
|
|
void
|
|
|
|
|
Timeline::update_cb ( void *arg )
|
|
|
|
|
{
|
|
|
|
|
Fl::repeat_timeout( UPDATE_FREQ, update_cb, arg );
|
|
|
|
|
|
|
|
|
|
Timeline *tl = (Timeline *)arg;
|
|
|
|
|
|
|
|
|
|
tl->redraw_playhead();
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-19 06:14:14 +02:00
|
|
|
|
/** draw cursors in overlay plane */
|
2008-03-01 05:57:53 +01:00
|
|
|
|
void
|
|
|
|
|
Timeline::draw_overlay ( void )
|
|
|
|
|
{
|
2008-04-12 21:50:36 +02:00
|
|
|
|
draw_playhead();
|
|
|
|
|
|
2013-05-20 03:24:59 +02:00
|
|
|
|
draw_cursors();
|
|
|
|
|
|
2008-03-09 06:06:37 +01:00
|
|
|
|
if ( ! ( _selection.w && _selection.h ) )
|
|
|
|
|
return;
|
2008-03-01 05:57:53 +01:00
|
|
|
|
|
2012-11-02 01:39:21 +01:00
|
|
|
|
fl_push_clip( tracks->x() + Track::width(), rulers->y() + rulers->h(), tracks->w() - Track::width(), h() - rulers->h() - panzoomer->h() );
|
2008-03-06 00:15:44 +01:00
|
|
|
|
|
|
|
|
|
const Rectangle &r = _selection;
|
|
|
|
|
|
|
|
|
|
fl_color( FL_MAGENTA );
|
2008-03-05 20:06:41 +01:00
|
|
|
|
fl_line_style( FL_SOLID, 0 );
|
2012-05-21 05:28:09 +02:00
|
|
|
|
fl_rect( r.x, r.y, r.w, r.h );
|
2008-03-01 05:57:53 +01:00
|
|
|
|
|
2008-03-09 06:06:37 +01:00
|
|
|
|
fl_pop_clip();
|
2008-03-05 20:06:41 +01:00
|
|
|
|
}
|
2008-03-01 05:57:53 +01:00
|
|
|
|
|
2008-06-19 06:14:14 +02:00
|
|
|
|
/** select sequence widgets within rectangle /r/ */
|
2008-03-05 20:06:41 +01:00
|
|
|
|
void
|
2008-04-29 23:16:09 +02:00
|
|
|
|
Timeline::select ( const Rectangle &r )
|
2008-03-05 20:06:41 +01:00
|
|
|
|
{
|
2008-03-06 00:15:44 +01:00
|
|
|
|
const int Y = r.y;
|
2008-03-05 20:32:39 +01:00
|
|
|
|
|
2008-03-05 20:06:41 +01:00
|
|
|
|
for ( int i = tracks->children(); i-- ; )
|
|
|
|
|
{
|
2008-04-19 06:16:21 +02:00
|
|
|
|
Track *t = (Track*)tracks->child( i );
|
2008-03-01 05:57:53 +01:00
|
|
|
|
|
2008-03-06 00:15:44 +01:00
|
|
|
|
if ( ! ( t->y() > Y + r.h || t->y() + t->h() < Y ) )
|
2008-04-29 22:47:03 +02:00
|
|
|
|
t->select( r.x, r.y, r.w, r.h, true, true );
|
2008-03-05 20:06:41 +01:00
|
|
|
|
}
|
2008-03-01 05:57:53 +01:00
|
|
|
|
}
|
2008-02-28 19:34:10 +01:00
|
|
|
|
|
2008-06-19 06:14:14 +02:00
|
|
|
|
/** delete all selected sequence widgets */
|
2008-04-29 23:16:09 +02:00
|
|
|
|
void
|
|
|
|
|
Timeline::delete_selected ( void )
|
|
|
|
|
{
|
|
|
|
|
Sequence_Widget::delete_selected();
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-19 06:14:14 +02:00
|
|
|
|
/** clear the selection of seqeunce widgets */
|
2008-04-29 23:16:09 +02:00
|
|
|
|
void
|
|
|
|
|
Timeline::select_none ( void )
|
|
|
|
|
{
|
|
|
|
|
Sequence_Widget::select_none();
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-12 09:53:00 +01:00
|
|
|
|
int
|
|
|
|
|
Timeline::nselected ( void ) const
|
|
|
|
|
{
|
|
|
|
|
return Sequence_Widget::nselected();
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-01 11:47:37 +02:00
|
|
|
|
/** An unfortunate necessity for implementing our own DND aside from
|
|
|
|
|
* the (bogus) native FLTK system */
|
|
|
|
|
Track *
|
|
|
|
|
Timeline::track_under ( int Y )
|
|
|
|
|
{
|
|
|
|
|
for ( int i = tracks->children(); i-- ; )
|
|
|
|
|
{
|
|
|
|
|
Track *t = (Track*)tracks->child( i );
|
|
|
|
|
|
|
|
|
|
if ( ! ( t->y() > Y || t->y() + t->h() < Y ) )
|
|
|
|
|
return t;
|
|
|
|
|
}
|
2008-05-04 01:44:28 +02:00
|
|
|
|
|
|
|
|
|
return NULL;
|
2008-05-01 11:47:37 +02:00
|
|
|
|
}
|
|
|
|
|
|
2008-05-27 02:03:31 +02:00
|
|
|
|
#include "FL/event_name.H"
|
|
|
|
|
#include "FL/test_press.H"
|
2008-05-01 11:47:37 +02:00
|
|
|
|
|
2008-05-30 00:45:04 +02:00
|
|
|
|
/** a bit of a hack to keep FLTK's focus navigation stuff from
|
|
|
|
|
* stealing the arrow keys from us */
|
2008-05-27 05:32:35 +02:00
|
|
|
|
int
|
|
|
|
|
Timeline::handle_scroll ( int m )
|
|
|
|
|
{
|
2008-05-30 00:45:04 +02:00
|
|
|
|
if ( m == FL_KEYBOARD &&
|
|
|
|
|
Fl::event_key() != FL_Home &&
|
|
|
|
|
Fl::event_key() != FL_End )
|
2012-11-02 01:39:21 +01:00
|
|
|
|
return menu->test_shortcut() || panzoomer->handle( m );
|
2008-05-27 05:57:54 +02:00
|
|
|
|
else
|
|
|
|
|
return 0;
|
2008-05-27 05:32:35 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-05-23 08:50:10 +02:00
|
|
|
|
Track *
|
|
|
|
|
Timeline::event_inside ( void )
|
|
|
|
|
{
|
|
|
|
|
for ( int i = tracks->children(); i--; )
|
|
|
|
|
if ( Fl::event_inside( tracks->child(i) ) )
|
|
|
|
|
return (Track*)tracks->child(i);
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2008-02-28 19:34:10 +01:00
|
|
|
|
int
|
|
|
|
|
Timeline::handle ( int m )
|
|
|
|
|
{
|
2008-03-05 20:06:41 +01:00
|
|
|
|
static Drag *drag = NULL;
|
2008-05-22 04:49:14 +02:00
|
|
|
|
static bool range = false;
|
2008-03-01 15:23:59 +01:00
|
|
|
|
|
2008-05-27 02:03:31 +02:00
|
|
|
|
/* if ( m != FL_NO_EVENT ) */
|
|
|
|
|
/* DMESSAGE( "%s", event_name( m ) ); */
|
|
|
|
|
|
2010-01-08 07:04:28 +01:00
|
|
|
|
/* int r = BASE::handle( m ); */
|
2008-05-27 02:03:31 +02:00
|
|
|
|
|
2008-02-28 19:34:10 +01:00
|
|
|
|
switch ( m )
|
|
|
|
|
{
|
2008-05-26 04:22:52 +02:00
|
|
|
|
case FL_ENTER:
|
|
|
|
|
return 1;
|
|
|
|
|
case FL_LEAVE:
|
|
|
|
|
return 1;
|
2008-05-22 04:49:14 +02:00
|
|
|
|
case FL_KEYDOWN:
|
2010-01-30 07:00:24 +01:00
|
|
|
|
if ( Fl::event_state() & ( FL_ALT | FL_CTRL | FL_SHIFT ) )
|
|
|
|
|
/* we don't want any keys with modifiers... */
|
|
|
|
|
return 0;
|
|
|
|
|
|
2008-05-22 04:49:14 +02:00
|
|
|
|
if ( Fl::event_key() == 'r' )
|
|
|
|
|
{
|
|
|
|
|
range = true;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2010-01-26 15:31:04 +01:00
|
|
|
|
else if ( Fl::event_key() == 's' )
|
|
|
|
|
{
|
|
|
|
|
snapping_on_hold = true;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2008-05-22 04:49:14 +02:00
|
|
|
|
return 0;
|
|
|
|
|
case FL_KEYUP:
|
2010-01-30 07:00:24 +01:00
|
|
|
|
if ( Fl::event_state() & ( FL_ALT | FL_CTRL | FL_SHIFT ) )
|
|
|
|
|
/* we don't want any keys with modifiers... */
|
|
|
|
|
return 0;
|
|
|
|
|
|
2008-05-22 04:49:14 +02:00
|
|
|
|
if ( Fl::event_key() == 'r' )
|
|
|
|
|
{
|
|
|
|
|
range = false;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2010-01-26 15:31:04 +01:00
|
|
|
|
else if ( Fl::event_key() == 's' )
|
|
|
|
|
{
|
|
|
|
|
snapping_on_hold = false;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2008-05-22 04:49:14 +02:00
|
|
|
|
return 0;
|
|
|
|
|
// case FL_KEYBOARD:
|
2008-04-27 05:50:58 +02:00
|
|
|
|
case FL_SHORTCUT:
|
2008-03-03 19:59:05 +01:00
|
|
|
|
{
|
2008-05-07 01:38:55 +02:00
|
|
|
|
if ( Fl::event_state() & ( FL_ALT | FL_CTRL | FL_SHIFT ) )
|
2008-04-27 05:50:58 +02:00
|
|
|
|
/* we don't want any keys with modifiers... */
|
|
|
|
|
return 0;
|
|
|
|
|
|
2008-03-03 19:59:05 +01:00
|
|
|
|
switch ( Fl::event_key() )
|
|
|
|
|
{
|
|
|
|
|
case FL_Delete:
|
2008-04-27 05:50:58 +02:00
|
|
|
|
case FL_Home:
|
|
|
|
|
case FL_End:
|
|
|
|
|
/* keep scrollbar from eating these. */
|
|
|
|
|
return 0;
|
2008-04-15 09:13:22 +02:00
|
|
|
|
default:
|
2010-01-08 07:04:28 +01:00
|
|
|
|
return BASE::handle( m );
|
2008-03-03 19:59:05 +01:00
|
|
|
|
}
|
2008-03-01 15:23:59 +01:00
|
|
|
|
|
2008-03-05 20:06:41 +01:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
{
|
2010-01-08 07:04:28 +01:00
|
|
|
|
int r = BASE::handle( m );
|
2008-03-01 15:23:59 +01:00
|
|
|
|
|
2008-03-06 00:15:44 +01:00
|
|
|
|
if ( m != FL_RELEASE && r )
|
2008-03-05 20:06:41 +01:00
|
|
|
|
return r;
|
2008-03-01 15:23:59 +01:00
|
|
|
|
|
2008-03-05 20:06:41 +01:00
|
|
|
|
const int X = Fl::event_x();
|
|
|
|
|
const int Y = Fl::event_y();
|
2008-03-01 15:23:59 +01:00
|
|
|
|
|
2008-03-05 20:06:41 +01:00
|
|
|
|
switch ( m )
|
|
|
|
|
{
|
|
|
|
|
case FL_PUSH:
|
|
|
|
|
{
|
2012-12-11 07:58:18 +01:00
|
|
|
|
if (
|
|
|
|
|
Fl::event_x() >= Track::width() &&
|
|
|
|
|
( test_press( FL_BUTTON1 ) || test_press( FL_BUTTON1 + FL_CTRL ) ))
|
2008-04-19 04:26:27 +02:00
|
|
|
|
{
|
|
|
|
|
assert( ! drag );
|
2012-12-11 07:58:18 +01:00
|
|
|
|
|
2008-07-20 23:38:11 +02:00
|
|
|
|
drag = new Drag( X, Y );
|
|
|
|
|
_selection.x = X;
|
|
|
|
|
_selection.y = Y;
|
2012-12-11 07:58:18 +01:00
|
|
|
|
|
2008-07-15 07:41:05 +02:00
|
|
|
|
if ( ! Fl::event_ctrl() )
|
|
|
|
|
select_none();
|
2012-12-11 07:58:18 +01:00
|
|
|
|
|
2008-05-26 04:22:52 +02:00
|
|
|
|
return 1;
|
2008-04-19 04:26:27 +02:00
|
|
|
|
}
|
2008-05-27 02:03:31 +02:00
|
|
|
|
else if ( test_press( FL_BUTTON3 ) )
|
2008-04-19 04:26:27 +02:00
|
|
|
|
{
|
2008-05-31 01:48:44 +02:00
|
|
|
|
menu_popup( menu );
|
2012-12-11 07:58:18 +01:00
|
|
|
|
|
2008-05-26 04:22:52 +02:00
|
|
|
|
return 1;
|
2008-04-19 04:26:27 +02:00
|
|
|
|
}
|
2008-03-05 20:06:41 +01:00
|
|
|
|
}
|
2012-12-11 07:58:18 +01:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
case FL_DRAG:
|
|
|
|
|
{
|
|
|
|
|
int ox = X - drag->x;
|
|
|
|
|
int oy = Y - drag->y;
|
2008-05-22 04:49:14 +02:00
|
|
|
|
|
2012-12-11 07:58:18 +01:00
|
|
|
|
if ( ox < 0 )
|
|
|
|
|
_selection.x = X;
|
|
|
|
|
if ( oy < 0 )
|
|
|
|
|
_selection.y = Y;
|
2008-05-22 04:49:14 +02:00
|
|
|
|
|
2012-12-11 07:58:18 +01:00
|
|
|
|
_selection.w = abs( ox );
|
|
|
|
|
_selection.h = abs( oy );
|
2008-05-26 04:22:52 +02:00
|
|
|
|
|
2012-12-11 07:58:18 +01:00
|
|
|
|
if ( range )
|
2008-03-05 20:06:41 +01:00
|
|
|
|
{
|
2012-12-11 07:58:18 +01:00
|
|
|
|
range_start( x_to_offset( _selection.x ) );
|
|
|
|
|
range_end( x_to_offset( _selection.x + _selection.w ) );
|
|
|
|
|
redraw();
|
|
|
|
|
}
|
2008-03-01 15:23:59 +01:00
|
|
|
|
|
2012-12-11 07:58:18 +01:00
|
|
|
|
redraw_overlay();
|
|
|
|
|
return 1;
|
2008-03-01 15:23:59 +01:00
|
|
|
|
|
2012-12-11 07:58:18 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case FL_RELEASE:
|
|
|
|
|
{
|
|
|
|
|
delete drag;
|
|
|
|
|
drag = NULL;
|
2008-05-26 04:22:52 +02:00
|
|
|
|
|
2012-12-11 07:58:18 +01:00
|
|
|
|
if ( range )
|
|
|
|
|
{
|
|
|
|
|
range_start( x_to_offset( _selection.x ) );
|
|
|
|
|
range_end( x_to_offset( _selection.x + _selection.w ) );
|
|
|
|
|
redraw();
|
2008-03-05 20:06:41 +01:00
|
|
|
|
}
|
2012-12-11 07:58:18 +01:00
|
|
|
|
else
|
|
|
|
|
select( _selection );
|
2008-03-01 15:23:59 +01:00
|
|
|
|
|
2012-12-11 07:58:18 +01:00
|
|
|
|
_selection.x = _selection.y =_selection.w = _selection.h = 0;
|
|
|
|
|
|
|
|
|
|
redraw_overlay();
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
return 0;
|
|
|
|
|
break;
|
2008-03-05 20:06:41 +01:00
|
|
|
|
}
|
2012-12-11 07:58:18 +01:00
|
|
|
|
|
|
|
|
|
return 0;
|
2008-02-28 19:34:10 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2012-12-11 07:58:18 +01:00
|
|
|
|
}
|
2008-04-08 22:06:38 +02:00
|
|
|
|
|
2008-06-19 06:14:14 +02:00
|
|
|
|
/** retrun a pointer to the track named /name/, or NULL if no track is named /name/ */
|
|
|
|
|
Track *
|
|
|
|
|
Timeline::track_by_name ( const char *name )
|
|
|
|
|
{
|
|
|
|
|
for ( int i = tracks->children(); i-- ; )
|
|
|
|
|
{
|
|
|
|
|
Track *t = (Track*)tracks->child( i );
|
|
|
|
|
|
2012-12-11 06:47:44 +01:00
|
|
|
|
if ( name && t->name() && ! strcmp( name, t->name() ) )
|
2008-06-19 06:14:14 +02:00
|
|
|
|
return t;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** return a malloc'd string representing a unique name for a new track */
|
|
|
|
|
char *
|
|
|
|
|
Timeline::get_unique_track_name ( const char *name )
|
|
|
|
|
{
|
|
|
|
|
char pat[256];
|
|
|
|
|
|
|
|
|
|
strcpy( pat, name );
|
|
|
|
|
|
|
|
|
|
for ( int i = 1; track_by_name( pat ); ++i )
|
|
|
|
|
snprintf( pat, sizeof( pat ), "%s.%d", name, i );
|
|
|
|
|
|
|
|
|
|
return strdup( pat );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**********/
|
|
|
|
|
/* Public */
|
|
|
|
|
/**********/
|
|
|
|
|
|
|
|
|
|
/** return the current length of the timeline, which is arrived at by
|
|
|
|
|
* calculating the end frame of the rightmost audio region on an
|
|
|
|
|
* active audio sequence. Control_Points, etc. do not factor into this
|
|
|
|
|
* calcaulation. */
|
|
|
|
|
nframes_t
|
|
|
|
|
Timeline::length ( void ) const
|
|
|
|
|
{
|
|
|
|
|
nframes_t l = 0;
|
|
|
|
|
|
|
|
|
|
for ( int i = tracks->children(); i--; )
|
2012-12-02 01:14:01 +01:00
|
|
|
|
{
|
|
|
|
|
Sequence *t = ((Track*)tracks->child( i ))->sequence();
|
|
|
|
|
|
|
|
|
|
if ( t )
|
|
|
|
|
l = max( l, ((Track*)tracks->child( i ))->sequence()->length() );
|
|
|
|
|
}
|
2008-06-19 06:14:14 +02:00
|
|
|
|
|
|
|
|
|
return l;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** set horizontal scroll postion to absolute pixel coordinate /X/ */
|
|
|
|
|
void
|
|
|
|
|
Timeline::xposition ( int X )
|
|
|
|
|
{
|
|
|
|
|
xoffset = x_to_ts( X );
|
|
|
|
|
|
2012-04-02 03:28:02 +02:00
|
|
|
|
int dx = ts_to_x( _old_xposition ) - ts_to_x( xoffset );
|
|
|
|
|
|
|
|
|
|
if ( dx )
|
|
|
|
|
damage( FL_DAMAGE_SCROLL );
|
2008-06-19 06:14:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** zoom in by one zoom step */
|
2008-04-23 22:43:17 +02:00
|
|
|
|
void
|
|
|
|
|
Timeline::zoom_in ( void )
|
|
|
|
|
{
|
2012-11-02 01:39:21 +01:00
|
|
|
|
panzoomer->zoom_in();
|
2008-04-23 22:43:17 +02:00
|
|
|
|
}
|
|
|
|
|
|
2008-06-19 06:14:14 +02:00
|
|
|
|
/** zoom out by one zoom step */
|
2008-04-23 22:43:17 +02:00
|
|
|
|
void
|
|
|
|
|
Timeline::zoom_out ( void )
|
|
|
|
|
{
|
2012-11-02 01:39:21 +01:00
|
|
|
|
panzoomer->zoom_out();
|
2008-04-23 22:43:17 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** zoom the display to show /secs/ seconds per screen */
|
|
|
|
|
void
|
|
|
|
|
Timeline::zoom ( float secs )
|
|
|
|
|
{
|
2008-05-03 00:34:43 +02:00
|
|
|
|
const int sw = tracks->w() - Track::width();
|
2008-04-23 22:43:17 +02:00
|
|
|
|
|
2008-05-03 00:34:43 +02:00
|
|
|
|
int fpp = (int)((secs * sample_rate()) / sw);
|
|
|
|
|
|
|
|
|
|
int p = 0;
|
|
|
|
|
while ( 1 << p < fpp ) p++;
|
|
|
|
|
|
2012-11-02 01:39:21 +01:00
|
|
|
|
panzoomer->zoom( p );
|
2008-04-23 22:43:17 +02:00
|
|
|
|
|
|
|
|
|
redraw();
|
|
|
|
|
}
|
2008-04-19 07:09:42 +02:00
|
|
|
|
|
2008-06-19 06:14:14 +02:00
|
|
|
|
/** fit the zoom to the current length of the timeline (subject to nearest power of two) */
|
2008-05-03 01:03:44 +02:00
|
|
|
|
void
|
|
|
|
|
Timeline::zoom_fit ( void )
|
|
|
|
|
{
|
2008-06-01 02:42:51 +02:00
|
|
|
|
xposition( 0 );
|
2008-06-22 05:57:14 +02:00
|
|
|
|
|
|
|
|
|
if ( length() )
|
|
|
|
|
zoom( length() / (float)sample_rate() );
|
|
|
|
|
else
|
|
|
|
|
zoom( 60 );
|
2008-05-03 01:03:44 +02:00
|
|
|
|
}
|
|
|
|
|
|
2008-06-19 06:14:14 +02:00
|
|
|
|
/** add /track/ to the timeline */
|
2008-04-19 04:26:27 +02:00
|
|
|
|
void
|
2008-04-19 06:16:21 +02:00
|
|
|
|
Timeline::add_track ( Track *track )
|
2008-04-19 04:26:27 +02:00
|
|
|
|
{
|
2008-05-04 01:44:28 +02:00
|
|
|
|
DMESSAGE( "added new track to the timeline" );
|
|
|
|
|
|
2008-04-19 04:26:27 +02:00
|
|
|
|
tracks->add( track );
|
|
|
|
|
|
|
|
|
|
/* FIXME: why is this necessary? doesn't the above add do DAMAGE_CHILD? */
|
|
|
|
|
redraw();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-23 08:50:10 +02:00
|
|
|
|
void
|
|
|
|
|
Timeline::insert_track ( Track *track, Track *before )
|
|
|
|
|
{
|
|
|
|
|
tracks->insert( *track, before );
|
|
|
|
|
|
|
|
|
|
tracks->redraw();
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-17 07:08:49 +02:00
|
|
|
|
void
|
|
|
|
|
Timeline::insert_track ( Track *track, int n )
|
|
|
|
|
{
|
|
|
|
|
if ( n > tracks->children() || n < 0 )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
tracks->insert( *track, n );
|
|
|
|
|
|
|
|
|
|
tracks->redraw();
|
|
|
|
|
|
|
|
|
|
/* FIXME: why is this necessary? doesn't the above add do DAMAGE_CHILD? */
|
|
|
|
|
// redraw();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
|
bool
|
|
|
|
|
compare_tracks ( Track *a, Track *b )
|
|
|
|
|
{
|
|
|
|
|
return *a < *b;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Timeline::apply_track_order ( void )
|
|
|
|
|
{
|
2013-02-23 02:18:52 +01:00
|
|
|
|
/* wrlock(); */
|
2012-06-17 07:08:49 +02:00
|
|
|
|
|
|
|
|
|
std::list<Track*> tl;
|
|
|
|
|
|
|
|
|
|
for ( int i = 0; i < tracks->children(); i++ )
|
|
|
|
|
tl.push_back( (Track*)tracks->child( i ) );
|
|
|
|
|
|
|
|
|
|
tl.sort(compare_tracks);
|
|
|
|
|
|
|
|
|
|
Fl_Widget **a = const_cast<Fl_Widget**>(tracks->array());
|
|
|
|
|
|
|
|
|
|
int j = 0;
|
|
|
|
|
for ( std::list<Track*>::const_iterator i = tl.begin();
|
|
|
|
|
i != tl.end();
|
|
|
|
|
i++, j++ )
|
|
|
|
|
a[j] = *i;
|
|
|
|
|
|
|
|
|
|
update_track_order();
|
|
|
|
|
|
2013-02-23 02:18:52 +01:00
|
|
|
|
/* unlock(); */
|
2012-06-17 07:08:49 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Timeline::update_track_order ( void )
|
|
|
|
|
{
|
|
|
|
|
for ( int i = 0; i < tracks->children(); i++ )
|
|
|
|
|
((Track*)tracks->child( i ))->row( i );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
Timeline::find_track ( const Track *track ) const
|
|
|
|
|
{
|
|
|
|
|
return tracks->find( *track );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-06-19 06:14:14 +02:00
|
|
|
|
/** remove /track/ from the timeline */
|
2008-04-19 04:26:27 +02:00
|
|
|
|
void
|
2008-04-19 06:16:21 +02:00
|
|
|
|
Timeline::remove_track ( Track *track )
|
2008-04-19 04:26:27 +02:00
|
|
|
|
{
|
2008-05-04 01:44:28 +02:00
|
|
|
|
DMESSAGE( "removed track from the timeline" );
|
2008-04-19 04:26:27 +02:00
|
|
|
|
|
|
|
|
|
/* FIXME: what to do about track contents? */
|
|
|
|
|
tracks->remove( track );
|
|
|
|
|
|
|
|
|
|
/* FIXME: why is this necessary? doesn't the above add do DAMAGE_CHILD? */
|
|
|
|
|
redraw();
|
|
|
|
|
}
|
2010-01-21 01:33:02 +01:00
|
|
|
|
|
|
|
|
|
/************/
|
|
|
|
|
/* Commands */
|
|
|
|
|
/************/
|
|
|
|
|
|
2013-02-23 02:18:52 +01:00
|
|
|
|
void
|
|
|
|
|
Timeline::command_move_track_up ( Track *track )
|
|
|
|
|
{
|
|
|
|
|
wrlock();
|
|
|
|
|
insert_track( track, find_track( track ) - 1 );
|
|
|
|
|
unlock();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Timeline::command_move_track_down ( Track *track )
|
|
|
|
|
{
|
|
|
|
|
wrlock();
|
|
|
|
|
insert_track( track, find_track( track ) + 2 );
|
|
|
|
|
unlock();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Timeline::command_remove_track ( Track *track )
|
|
|
|
|
{
|
|
|
|
|
wrlock();
|
|
|
|
|
remove_track(track);
|
|
|
|
|
unlock();
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-21 01:33:02 +01:00
|
|
|
|
void
|
2013-03-02 02:05:42 +01:00
|
|
|
|
Timeline::command_quit ( void )
|
2010-01-21 01:33:02 +01:00
|
|
|
|
{
|
2013-03-02 02:05:42 +01:00
|
|
|
|
timeline->wrlock();
|
|
|
|
|
|
2012-10-24 07:44:19 +02:00
|
|
|
|
Project::close();
|
2013-03-02 02:05:42 +01:00
|
|
|
|
|
|
|
|
|
timeline->unlock();
|
2010-01-21 01:33:02 +01:00
|
|
|
|
|
2012-10-24 07:44:19 +02:00
|
|
|
|
command_save();
|
2010-01-21 01:33:02 +01:00
|
|
|
|
|
2012-10-24 07:44:19 +02:00
|
|
|
|
while ( Fl::first_window() ) Fl::first_window()->hide();
|
2010-01-21 01:33:02 +01:00
|
|
|
|
}
|
|
|
|
|
|
2013-03-02 02:05:42 +01:00
|
|
|
|
void
|
|
|
|
|
Timeline::command_undo ( void )
|
|
|
|
|
{
|
|
|
|
|
wrlock();
|
|
|
|
|
Project::undo();
|
|
|
|
|
unlock();
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-21 01:33:02 +01:00
|
|
|
|
bool
|
|
|
|
|
Timeline::command_load ( const char *name, const char *display_name )
|
|
|
|
|
{
|
2012-10-24 07:44:19 +02:00
|
|
|
|
if ( ! name )
|
|
|
|
|
return false;
|
2010-01-21 01:33:02 +01:00
|
|
|
|
|
2013-02-23 02:18:52 +01:00
|
|
|
|
wrlock();
|
2012-10-24 07:44:19 +02:00
|
|
|
|
int r = Project::open( name );
|
2013-02-23 02:18:52 +01:00
|
|
|
|
unlock();
|
|
|
|
|
|
2012-10-24 07:44:19 +02:00
|
|
|
|
if ( r < 0 )
|
|
|
|
|
{
|
2010-01-21 01:33:02 +01:00
|
|
|
|
const char *s = Project::errstr( r );
|
|
|
|
|
|
|
|
|
|
fl_alert( "Could not open project \"%s\":\n\n\t%s", name, s );
|
|
|
|
|
|
|
|
|
|
return false;
|
2012-10-24 07:44:19 +02:00
|
|
|
|
}
|
2010-01-21 01:33:02 +01:00
|
|
|
|
|
2012-10-24 07:44:19 +02:00
|
|
|
|
Project::set_name ( display_name ? display_name : name );
|
2010-01-21 01:33:02 +01:00
|
|
|
|
|
2012-10-24 07:44:19 +02:00
|
|
|
|
apply_track_order();
|
2012-06-17 07:08:49 +02:00
|
|
|
|
|
2012-10-24 07:44:19 +02:00
|
|
|
|
return true;
|
2010-01-21 01:33:02 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
Timeline::command_save ( )
|
|
|
|
|
{
|
|
|
|
|
tle->save_options();
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
Timeline::command_new ( const char *name, const char *display_name )
|
|
|
|
|
{
|
2012-02-24 11:43:44 +01:00
|
|
|
|
bool b = Project::create( name, NULL );
|
2010-01-21 01:33:02 +01:00
|
|
|
|
|
|
|
|
|
Project::set_name ( display_name );
|
|
|
|
|
|
|
|
|
|
/* FIXME: there's other stuff that needs to be done here! */
|
|
|
|
|
/* tle->update_menu(); */
|
|
|
|
|
|
|
|
|
|
/* tle->main_window->redraw(); */
|
2012-02-24 11:43:44 +01:00
|
|
|
|
|
2012-10-24 07:44:19 +02:00
|
|
|
|
return b;
|
2010-01-21 01:33:02 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char *
|
|
|
|
|
Timeline::session_manager_name ( void )
|
|
|
|
|
{
|
2012-05-22 07:04:09 +02:00
|
|
|
|
return nsm_get_session_manager_name( nsm );
|
2010-01-21 01:33:02 +01:00
|
|
|
|
}
|
2012-02-20 10:58:46 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*******/
|
|
|
|
|
/* OSC */
|
|
|
|
|
/*******/
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
Timeline::init_osc ( const char *osc_port )
|
|
|
|
|
{
|
|
|
|
|
osc = new OSC::Endpoint();
|
|
|
|
|
|
2012-02-24 05:34:07 +01:00
|
|
|
|
if ( int r = osc->init( LO_UDP, osc_port ) )
|
2012-02-20 10:58:46 +01:00
|
|
|
|
return r;
|
|
|
|
|
|
|
|
|
|
osc->owner = this;
|
|
|
|
|
|
2013-07-31 06:36:35 +02:00
|
|
|
|
char *url = osc->url();
|
|
|
|
|
printf( "OSC=%s\n", url );
|
|
|
|
|
free(url);
|
2012-02-20 10:58:46 +01:00
|
|
|
|
|
2012-02-21 09:48:13 +01:00
|
|
|
|
osc->add_method( "/non/hello", "ssss", &Timeline::osc_non_hello, osc, "" );
|
2012-02-20 10:58:46 +01:00
|
|
|
|
|
|
|
|
|
// osc->start();
|
|
|
|
|
|
2012-02-24 10:59:26 +01:00
|
|
|
|
if ( ! osc_thread )
|
|
|
|
|
{
|
|
|
|
|
osc_thread = new OSC_Thread();
|
|
|
|
|
|
|
|
|
|
osc_thread->start();
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-20 10:58:46 +01:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2013-04-09 05:56:33 +02:00
|
|
|
|
Timeline::osc_non_hello ( const char *, const char *, lo_arg **, int , lo_message msg, void * )
|
2012-02-20 10:58:46 +01:00
|
|
|
|
{
|
2013-04-09 05:56:33 +02:00
|
|
|
|
THREAD_ASSERT( OSC );
|
|
|
|
|
|
|
|
|
|
timeline->handle_hello(msg);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Timeline::handle_hello ( lo_message msg )
|
|
|
|
|
{
|
|
|
|
|
int argc = lo_message_get_argc( msg );
|
|
|
|
|
lo_arg **argv = lo_message_get_argv( msg );
|
2012-02-20 10:58:46 +01:00
|
|
|
|
|
2012-02-21 09:48:13 +01:00
|
|
|
|
if ( argc >= 4 )
|
2012-02-20 10:58:46 +01:00
|
|
|
|
{
|
2012-02-21 09:48:13 +01:00
|
|
|
|
const char *url = &argv[0]->s;
|
|
|
|
|
const char *name = &argv[1]->s;
|
|
|
|
|
const char *version = &argv[2]->s;
|
|
|
|
|
const char *id = &argv[3]->s;
|
2012-02-20 10:58:46 +01:00
|
|
|
|
|
2013-04-09 05:56:33 +02:00
|
|
|
|
MESSAGE( "Got hello from NON peer %s (%s) @ %s with ID \"%s\"", name, version, url, id );
|
2012-02-26 03:01:46 +01:00
|
|
|
|
|
2013-04-09 05:56:33 +02:00
|
|
|
|
osc->handle_hello( &argv[3]->s, &argv[0]->s );
|
2012-02-20 10:58:46 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2013-04-09 05:56:33 +02:00
|
|
|
|
Timeline::say_hello ( void )
|
2012-04-17 06:05:34 +02:00
|
|
|
|
{
|
2013-04-09 05:56:33 +02:00
|
|
|
|
if ( nsm_is_active( nsm ) )
|
|
|
|
|
{
|
|
|
|
|
lo_message m = lo_message_new();
|
|
|
|
|
|
|
|
|
|
lo_message_add( m, "sssss",
|
|
|
|
|
"/non/hello",
|
|
|
|
|
osc->url(),
|
|
|
|
|
APP_NAME,
|
|
|
|
|
VERSION,
|
|
|
|
|
instance_name );
|
|
|
|
|
|
|
|
|
|
nsm_send_broadcast( nsm, m );
|
|
|
|
|
}
|
2012-04-17 06:05:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
2012-02-24 12:52:57 +01:00
|
|
|
|
void
|
|
|
|
|
Timeline::connect_osc ( void )
|
|
|
|
|
{
|
2013-04-09 05:56:33 +02:00
|
|
|
|
/* reconnect OSC signals */
|
2012-02-24 12:52:57 +01:00
|
|
|
|
for ( int i = tracks->children(); i-- ; )
|
|
|
|
|
{
|
|
|
|
|
Track *t = (Track*)tracks->child( i );
|
2013-04-09 05:56:33 +02:00
|
|
|
|
|
2012-12-02 01:14:01 +01:00
|
|
|
|
t->connect_osc();
|
2012-02-24 12:52:57 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2012-02-20 10:58:46 +01:00
|
|
|
|
void
|
2013-04-09 05:56:33 +02:00
|
|
|
|
Timeline::update_osc_connection_state ( void )
|
2012-02-20 10:58:46 +01:00
|
|
|
|
{
|
2013-04-09 05:56:33 +02:00
|
|
|
|
/* reconnect OSC signals */
|
|
|
|
|
for ( int i = tracks->children(); i-- ; )
|
2012-02-26 03:01:46 +01:00
|
|
|
|
{
|
2013-04-09 05:56:33 +02:00
|
|
|
|
Track *t = (Track*)tracks->child( i );
|
2012-02-26 03:01:46 +01:00
|
|
|
|
|
2013-04-09 05:56:33 +02:00
|
|
|
|
t->update_osc_connection_state();
|
2012-02-26 03:01:46 +01:00
|
|
|
|
}
|
2012-02-21 09:48:13 +01:00
|
|
|
|
}
|
|
|
|
|
|
2012-02-24 10:59:26 +01:00
|
|
|
|
/* runs in the OSC thread... */
|
|
|
|
|
void
|
|
|
|
|
Timeline::process_osc ( void )
|
|
|
|
|
{
|
|
|
|
|
THREAD_ASSERT( OSC );
|
2012-02-21 09:48:13 +01:00
|
|
|
|
|
2013-04-09 05:56:33 +02:00
|
|
|
|
/* rdlock(); */
|
2012-03-30 07:08:45 +02:00
|
|
|
|
|
2012-02-24 10:59:26 +01:00
|
|
|
|
/* reconnect OSC signals */
|
|
|
|
|
for ( int i = tracks->children(); i-- ; )
|
|
|
|
|
{
|
|
|
|
|
Track *t = (Track*)tracks->child( i );
|
|
|
|
|
|
2012-12-02 01:14:01 +01:00
|
|
|
|
t->process_osc();
|
2012-02-24 10:59:26 +01:00
|
|
|
|
}
|
2012-12-11 06:47:44 +01:00
|
|
|
|
|
2013-04-09 05:56:33 +02:00
|
|
|
|
/* unlock(); */
|
2012-02-24 10:59:26 +01:00
|
|
|
|
}
|
2012-02-21 09:48:13 +01:00
|
|
|
|
|