Mixer: Allow drag and drop for moving mixer strips.

This commit is contained in:
Jonathan Moore Liles 2013-05-22 22:45:55 -07:00
parent 960dc543c3
commit 0552a9a7cf
4 changed files with 39 additions and 27 deletions

View File

@ -616,6 +616,17 @@ void Mixer::remove ( Mixer_Strip *ms )
parent()->redraw(); parent()->redraw();
} }
Mixer_Strip *
Mixer::event_inside ( void )
{
for ( int i = mixer_strips->children(); i--; )
if ( Fl::event_inside( mixer_strips->child(i) ) )
return (Mixer_Strip*)mixer_strips->child(i);
return NULL;
}
bool bool
Mixer::contains ( Mixer_Strip *ms ) Mixer::contains ( Mixer_Strip *ms )
{ {

View File

@ -91,6 +91,7 @@ public:
void insert ( Mixer_Strip *ms, Mixer_Strip *before ); void insert ( Mixer_Strip *ms, Mixer_Strip *before );
void insert ( Mixer_Strip *ms, int i ); void insert ( Mixer_Strip *ms, int i );
bool contains ( Mixer_Strip *ms ); bool contains ( Mixer_Strip *ms );
Mixer_Strip * event_inside ( void );
bool save ( void ); bool save ( void );
void quit ( void ); void quit ( void );

View File

@ -232,10 +232,6 @@ void Mixer_Strip::cb_handle(Fl_Widget* o) {
set_spatializer_visibility(); set_spatializer_visibility();
} }
else if ( o == left_button )
command_move_left();
else if ( o == right_button )
command_move_right();
else if ( o == close_button ) else if ( o == close_button )
{ {
if ( Fl::event_shift() || 1 == fl_choice( "Are you sure you want to remove this strip?\n\n(this action cannot be undone)", "Cancel", "Remove", NULL ) ) if ( Fl::event_shift() || 1 == fl_choice( "Are you sure you want to remove this strip?\n\n(this action cannot be undone)", "Cancel", "Remove", NULL ) )
@ -406,16 +402,8 @@ Mixer_Strip::init ( )
o->value( name() ); o->value( name() );
o->callback( cb_handle, (void*)this ); o->callback( cb_handle, (void*)this );
} }
{ Fl_Scalepack *o = new Fl_Scalepack( 7, 143, 110, 25 ); { Fl_Scalepack *o = new Fl_Scalepack( 7, 143, 110, 18 );
o->type( Fl_Pack::HORIZONTAL ); o->type( Fl_Pack::HORIZONTAL );
{ Fl_Button* o = left_button = new Fl_Button(7, 143, 35, 25, "@<-");
o->tooltip( "Move left" );
o->type(0);
o->labelsize(10);
o->when( FL_WHEN_RELEASE );
o->callback( ((Fl_Callback*)cb_handle), this );
} // Fl_Button* o
{ Fl_Flip_Button* o = width_button = new Fl_Flip_Button(61, 183, 45, 22, "[]/[-]"); { Fl_Flip_Button* o = width_button = new Fl_Flip_Button(61, 183, 45, 22, "[]/[-]");
o->type(1); o->type(1);
@ -436,14 +424,6 @@ Mixer_Strip::init ( )
o->callback( ((Fl_Callback*)cb_handle), this ); o->callback( ((Fl_Callback*)cb_handle), this );
} // Fl_Button* o } // Fl_Button* o
{ Fl_Button* o = right_button = new Fl_Button(7, 143, 35, 25, "@->");
o->tooltip( "Move right" );
o->type(0);
o->labelsize(10);
o->when( FL_WHEN_RELEASE );
o->callback( ((Fl_Callback*)cb_handle), this );
} // Fl_Button* o
o->end(); o->end();
} // Fl_Group* o } // Fl_Group* o
{ Fl_Flip_Button* o = tab_button = new Fl_Flip_Button(61, 183, 45, 22, "fader/signal"); { Fl_Flip_Button* o = tab_button = new Fl_Flip_Button(61, 183, 45, 22, "fader/signal");
@ -548,6 +528,7 @@ Mixer_Strip::draw ( void )
damage() & FL_DAMAGE_CHILD ) damage() & FL_DAMAGE_CHILD )
Fl_Group::draw(); Fl_Group::draw();
fl_color( Fl::focus() == this ? Fl_Group::selection_color() : FL_BLACK ); fl_color( Fl::focus() == this ? Fl_Group::selection_color() : FL_BLACK );
fl_rect( x(), y(), w(), h() ); fl_rect( x(), y(), w(), h() );
} }
@ -700,6 +681,8 @@ Mixer_Strip::handle ( int m )
Logger log( this ); Logger log( this );
static Fl_Widget *dragging = NULL;
if ( Fl_Group::handle( m ) ) if ( Fl_Group::handle( m ) )
return 1; return 1;
@ -725,15 +708,35 @@ Mixer_Strip::handle ( int m )
menu_popup( &menu(), x(), y() ); menu_popup( &menu(), x(), y() );
return 1; return 1;
} }
else else
return menu().test_shortcut() != 0; return menu().test_shortcut() != 0;
break; break;
} }
case FL_PUSH: case FL_PUSH:
if ( Fl::event_button1() && Fl::event_inside( color_box ) )
{
}
_button = Fl::event_button(); _button = Fl::event_button();
return 1;
break;
case FL_DRAG:
if ( Fl::event_is_click() )
return 1;
dragging = this;
break; break;
case FL_RELEASE: case FL_RELEASE:
{ if ( dragging == this )
{
mixer->insert( this, mixer->event_inside() );
dragging = NULL;
return 1;
}
int b = _button; int b = _button;
_button = 0; _button = 0;
@ -748,7 +751,6 @@ Mixer_Strip::handle ( int m )
return 1; return 1;
} }
break; break;
}
} }
return 0; return 0;

View File

@ -91,8 +91,6 @@ private:
Fl_Flip_Button *width_button; Fl_Flip_Button *width_button;
Fl_Flip_Button *tab_button; Fl_Flip_Button *tab_button;
Fl_Button *close_button; Fl_Button *close_button;
Fl_Button *left_button;
Fl_Button *right_button;
Fl_Input *name_field; Fl_Input *name_field;
Fl_Flowpack *controls_pack; Fl_Flowpack *controls_pack;