Work on timeline menu actions.
This commit is contained in:
parent
8a3a38b2a0
commit
43e561982b
|
@ -291,10 +291,10 @@ Sequence::snap ( Sequence_Widget *r )
|
|||
}
|
||||
}
|
||||
|
||||
nframes_t f;
|
||||
nframes_t f = r->start();
|
||||
|
||||
/* snap to beat/bar lines */
|
||||
if ( timeline->nearest_line( r->start(), &f ) )
|
||||
if ( timeline->nearest_line( &f ) )
|
||||
r->start( f );
|
||||
}
|
||||
|
||||
|
|
|
@ -92,9 +92,10 @@ Sequence_Region::trim ( enum trim_e t, int X )
|
|||
|
||||
_r->trim_left( 0 - td );
|
||||
|
||||
nframes_t f;
|
||||
nframes_t f = _r->start;
|
||||
|
||||
/* snap to beat/bar lines */
|
||||
if ( timeline->nearest_line( _r->start, &f ) )
|
||||
if ( timeline->nearest_line( &f ) )
|
||||
_r->set_left( f );
|
||||
|
||||
break;
|
||||
|
@ -114,9 +115,10 @@ Sequence_Region::trim ( enum trim_e t, int X )
|
|||
|
||||
_r->trim_right( 0 - td );
|
||||
|
||||
nframes_t f;
|
||||
nframes_t f = _r->start + _r->length;
|
||||
|
||||
/* snap to beat/bar lines */
|
||||
if ( timeline->nearest_line( _r->start + _r->length, &f ) )
|
||||
if ( timeline->nearest_line( &f ) )
|
||||
_r->set_right( f );
|
||||
|
||||
break;
|
||||
|
|
|
@ -239,6 +239,24 @@ Timeline::menu_cb ( Fl_Widget *w )
|
|||
/* FIXME: only needs to damage the location of the old cursor! */
|
||||
redraw();
|
||||
}
|
||||
else if ( ! strcmp( picked, "Playhead left" ) )
|
||||
{
|
||||
#warning unimplemented
|
||||
}
|
||||
else if ( ! strcmp( picked, "Playhead right" ) )
|
||||
{
|
||||
#warning unimplemented
|
||||
}
|
||||
else if ( ! strcmp( picked, "Swap P1 and playhead" ) )
|
||||
{
|
||||
nframes_t t = transport->frame;
|
||||
|
||||
transport->locate( p1 );
|
||||
|
||||
p1 = t;
|
||||
|
||||
redraw();
|
||||
}
|
||||
else
|
||||
WARNING( "programming error: Unknown menu item" );
|
||||
}
|
||||
|
@ -267,6 +285,9 @@ Timeline::Timeline ( int X, int Y, int W, int H, const char* L ) : Fl_Overlay_Wi
|
|||
menu->add( "Playhead to mouse", 'p', &Timeline::menu_cb, this );
|
||||
menu->add( "P1 to mouse", '[', &Timeline::menu_cb, this );
|
||||
menu->add( "P2 to mouse", ']', &Timeline::menu_cb, this );
|
||||
menu->add( "Playhead left", FL_CTRL + FL_Up, &Timeline::menu_cb, this );
|
||||
menu->add( "Playhead right", FL_CTRL + FL_Down, &Timeline::menu_cb, this );
|
||||
menu->add( "Swap P1 and playhead", FL_CTRL + '[', &Timeline::menu_cb, this );
|
||||
|
||||
{
|
||||
Scalebar *o = new Scalebar( X, Y + H - 18, W - 18, 18 );
|
||||
|
@ -441,17 +462,24 @@ nearest_line_cb ( nframes_t frame, const BBT &bbt, void *arg )
|
|||
the nearest measure line to /when/. Returns true if the new value of
|
||||
*frame is valid, false otherwise. */
|
||||
bool
|
||||
Timeline::nearest_line ( nframes_t when, nframes_t *frame ) const
|
||||
Timeline::nearest_line ( nframes_t *frame ) const
|
||||
{
|
||||
if ( snap_to == None )
|
||||
return false;
|
||||
|
||||
nframes_t when = *frame;
|
||||
|
||||
nearest_line_arg n = { when, -1 };
|
||||
|
||||
render_tempomap( when - x_to_ts( w() >> 1 ), x_to_ts( w() ), nearest_line_cb, &n );
|
||||
|
||||
if ( n.closest == (nframes_t)-1 )
|
||||
return false;
|
||||
else
|
||||
{
|
||||
*frame = n.closest;
|
||||
return *frame != (nframes_t)-1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -154,7 +154,7 @@ public:
|
|||
int beats_per_bar ( nframes_t when ) const;
|
||||
void beats_per_minute ( nframes_t when, float bpm );
|
||||
void time ( nframes_t when, int bpb, int beat_type );
|
||||
bool nearest_line ( nframes_t when, nframes_t *f ) const;
|
||||
bool nearest_line ( nframes_t *f ) const;
|
||||
|
||||
typedef void (measure_line_callback)( nframes_t frame, const BBT & bbt, void *arg );
|
||||
|
||||
|
|
Loading…
Reference in New Issue