Timeline: Improve behavior of audio region gain adjustment mode.
This commit is contained in:
parent
2e49295320
commit
83fceb23dc
|
@ -153,7 +153,7 @@ Audio_Region::Audio_Region ( const Audio_Region & rhs ) : Sequence_Region( rhs )
|
|||
_box_color = rhs._box_color;
|
||||
_color = rhs._color;
|
||||
|
||||
_adjusting_gain = false;
|
||||
_adjusting_gain = 0.0f;
|
||||
|
||||
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 ) );
|
||||
|
||||
|
@ -753,9 +753,9 @@ Audio_Region::handle ( int m )
|
|||
case FL_UNFOCUS:
|
||||
return 1;
|
||||
case FL_KEYUP:
|
||||
if ( Fl::event_key() == 'g' )
|
||||
if ( _adjusting_gain > 0 )
|
||||
{
|
||||
_adjusting_gain = false;
|
||||
_adjusting_gain = 0;
|
||||
redraw();
|
||||
return 1;
|
||||
}
|
||||
|
@ -763,19 +763,30 @@ Audio_Region::handle ( int m )
|
|||
case FL_KEYBOARD:
|
||||
if ( Fl::event_key() == 'g' )
|
||||
{
|
||||
_adjusting_gain = true;
|
||||
redraw();
|
||||
if ( _adjusting_gain <= 0 )
|
||||
{
|
||||
_adjusting_gain = _scale;
|
||||
redraw();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return menu().test_shortcut() != 0;
|
||||
case FL_ENTER:
|
||||
return Sequence_Region::handle( m );
|
||||
case FL_LEAVE:
|
||||
if ( _adjusting_gain > 0 )
|
||||
{
|
||||
_adjusting_gain = 0;
|
||||
redraw();
|
||||
}
|
||||
return Sequence_Region::handle( m );
|
||||
case FL_PUSH:
|
||||
{
|
||||
if ( Fl::event_key() == 'g' )
|
||||
if ( _adjusting_gain > 0.0f )
|
||||
{
|
||||
_adjusting_gain = _scale;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* splitting */
|
||||
if ( test_press( FL_BUTTON2 | FL_SHIFT ) )
|
||||
|
@ -832,15 +843,18 @@ Audio_Region::handle ( int m )
|
|||
|
||||
if ( ! _drag )
|
||||
{
|
||||
begin_drag( Drag( x() - X, y() - Y, x_to_offset( X ) ) );
|
||||
begin_drag( Drag( X, Y, x_to_offset( X ) ) );
|
||||
_log.hold();
|
||||
}
|
||||
|
||||
if ( Fl::event_key() == 'g' )
|
||||
if ( _adjusting_gain )
|
||||
{
|
||||
float d = (float)h() / ( y() - Fl::event_y() );
|
||||
int d = _drag->y - Y;
|
||||
|
||||
_scale = -0.5f * d;
|
||||
_scale = _adjusting_gain + ( 0.01f * d );
|
||||
|
||||
if ( _scale < 0.01f )
|
||||
_scale = 0.01f;
|
||||
|
||||
redraw();
|
||||
return 1;
|
||||
|
|
|
@ -99,7 +99,7 @@ private:
|
|||
|
||||
Audio_File *_clip; /* clip this region represents */
|
||||
|
||||
bool _adjusting_gain;
|
||||
float _adjusting_gain;
|
||||
float _scale; /* amplitude adjustment */
|
||||
|
||||
Fade _fade_in;
|
||||
|
|
|
@ -154,12 +154,12 @@ Sequence_Region::handle ( int m )
|
|||
{
|
||||
case 1:
|
||||
trim( trimming = LEFT, X );
|
||||
begin_drag( Drag( x() - X, y() - Y ) );
|
||||
begin_drag( Drag( X, Y ) );
|
||||
_log.hold();
|
||||
break;
|
||||
case 3:
|
||||
trim( trimming = RIGHT, X );
|
||||
begin_drag( Drag( x() - X, y() - Y ) );
|
||||
begin_drag( Drag( X, Y) );
|
||||
_log.hold();
|
||||
break;
|
||||
default:
|
||||
|
@ -207,7 +207,7 @@ Sequence_Region::handle ( int m )
|
|||
{
|
||||
if ( ! _drag )
|
||||
{
|
||||
begin_drag( Drag( x() - X, y() - Y, x_to_offset( X ) ) );
|
||||
begin_drag( Drag( X, Y, x_to_offset( X ) ) );
|
||||
_log.hold();
|
||||
}
|
||||
|
||||
|
|
|
@ -442,7 +442,7 @@ Sequence_Widget::handle ( int m )
|
|||
|
||||
if ( ! _drag )
|
||||
{
|
||||
begin_drag ( Drag( x() - X, y() - Y, start() - x_to_offset( X ) ) );
|
||||
begin_drag ( Drag( Y, x_to_offset( X ) ) );
|
||||
_log.hold();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue