Timeline: Improve behavior of audio region gain adjustment mode.

This commit is contained in:
Jonathan Moore Liles 2013-09-22 21:34:04 -07:00
parent 2e49295320
commit 83fceb23dc
4 changed files with 32 additions and 18 deletions

View File

@ -153,7 +153,7 @@ Audio_Region::Audio_Region ( const Audio_Region & rhs ) : Sequence_Region( rhs )
_box_color = rhs._box_color; _box_color = rhs._box_color;
_color = rhs._color; _color = rhs._color;
_adjusting_gain = false; _adjusting_gain = 0.0f;
log_create(); log_create();
} }
@ -661,7 +661,7 @@ Audio_Region::draw ( void )
if ( _adjusting_gain ) if ( _adjusting_gain > 0.0f )
{ {
fl_color( fl_color_add_alpha( FL_DARK1, 127 ) ); fl_color( fl_color_add_alpha( FL_DARK1, 127 ) );
@ -744,7 +744,7 @@ Audio_Region::handle ( int m )
int X = Fl::event_x(); int X = Fl::event_x();
int Y = Fl::event_y(); int Y = Fl::event_y();
Logger _log( this ); Logger _log( this );
switch ( m ) switch ( m )
@ -753,29 +753,40 @@ Audio_Region::handle ( int m )
case FL_UNFOCUS: case FL_UNFOCUS:
return 1; return 1;
case FL_KEYUP: case FL_KEYUP:
if ( Fl::event_key() == 'g' ) if ( _adjusting_gain > 0 )
{ {
_adjusting_gain = false; _adjusting_gain = 0;
redraw(); redraw();
return 1; return 1;
} }
break; break;
case FL_KEYBOARD: case FL_KEYBOARD:
if ( Fl::event_key() == 'g' ) if ( Fl::event_key() == 'g' )
{ {
_adjusting_gain = true; if ( _adjusting_gain <= 0 )
redraw(); {
_adjusting_gain = _scale;
redraw();
}
return 1; return 1;
} }
return menu().test_shortcut() != 0; return menu().test_shortcut() != 0;
case FL_ENTER: case FL_ENTER:
return Sequence_Region::handle( m ); return Sequence_Region::handle( m );
case FL_LEAVE: case FL_LEAVE:
if ( _adjusting_gain > 0 )
{
_adjusting_gain = 0;
redraw();
}
return Sequence_Region::handle( m ); return Sequence_Region::handle( m );
case FL_PUSH: case FL_PUSH:
{ {
if ( Fl::event_key() == 'g' ) if ( _adjusting_gain > 0.0f )
{
_adjusting_gain = _scale;
return 1; return 1;
}
/* splitting */ /* splitting */
if ( test_press( FL_BUTTON2 | FL_SHIFT ) ) if ( test_press( FL_BUTTON2 | FL_SHIFT ) )
@ -832,15 +843,18 @@ Audio_Region::handle ( int m )
if ( ! _drag ) if ( ! _drag )
{ {
begin_drag( Drag( x() - X, y() - Y, x_to_offset( X ) ) ); begin_drag( Drag( X, Y, x_to_offset( X ) ) );
_log.hold(); _log.hold();
} }
if ( Fl::event_key() == 'g' ) if ( _adjusting_gain )
{ {
float d = (float)h() / ( y() - Fl::event_y() ); int d = _drag->y - Y;
_scale = _adjusting_gain + ( 0.01f * d );
_scale = -0.5f * d; if ( _scale < 0.01f )
_scale = 0.01f;
redraw(); redraw();
return 1; return 1;

View File

@ -99,7 +99,7 @@ private:
Audio_File *_clip; /* clip this region represents */ Audio_File *_clip; /* clip this region represents */
bool _adjusting_gain; float _adjusting_gain;
float _scale; /* amplitude adjustment */ float _scale; /* amplitude adjustment */
Fade _fade_in; Fade _fade_in;

View File

@ -154,12 +154,12 @@ Sequence_Region::handle ( int m )
{ {
case 1: case 1:
trim( trimming = LEFT, X ); trim( trimming = LEFT, X );
begin_drag( Drag( x() - X, y() - Y ) ); begin_drag( Drag( X, Y ) );
_log.hold(); _log.hold();
break; break;
case 3: case 3:
trim( trimming = RIGHT, X ); trim( trimming = RIGHT, X );
begin_drag( Drag( x() - X, y() - Y ) ); begin_drag( Drag( X, Y) );
_log.hold(); _log.hold();
break; break;
default: default:
@ -207,7 +207,7 @@ Sequence_Region::handle ( int m )
{ {
if ( ! _drag ) if ( ! _drag )
{ {
begin_drag( Drag( x() - X, y() - Y, x_to_offset( X ) ) ); begin_drag( Drag( X, Y, x_to_offset( X ) ) );
_log.hold(); _log.hold();
} }

View File

@ -442,7 +442,7 @@ Sequence_Widget::handle ( int m )
if ( ! _drag ) if ( ! _drag )
{ {
begin_drag ( Drag( x() - X, y() - Y, start() - x_to_offset( X ) ) ); begin_drag ( Drag( Y, x_to_offset( X ) ) );
_log.hold(); _log.hold();
} }