Mixer: Allow drag and drop for moving mixer strips.

pull/116/head
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();
}
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
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, int i );
bool contains ( Mixer_Strip *ms );
Mixer_Strip * event_inside ( void );
bool save ( void );
void quit ( void );

View File

@ -232,10 +232,6 @@ void Mixer_Strip::cb_handle(Fl_Widget* o) {
set_spatializer_visibility();
}
else if ( o == left_button )
command_move_left();
else if ( o == right_button )
command_move_right();
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 ) )
@ -406,17 +402,9 @@ Mixer_Strip::init ( )
o->value( name() );
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 );
{ 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, "[]/[-]");
o->type(1);
o->tooltip( "Switch between wide and narrow views" );
@ -436,14 +424,6 @@ Mixer_Strip::init ( )
o->callback( ((Fl_Callback*)cb_handle), this );
} // 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();
} // Fl_Group* o
{ 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 )
Fl_Group::draw();
fl_color( Fl::focus() == this ? Fl_Group::selection_color() : FL_BLACK );
fl_rect( x(), y(), w(), h() );
}
@ -699,6 +680,8 @@ Mixer_Strip::handle ( int m )
static int _button = 0;
Logger log( this );
static Fl_Widget *dragging = NULL;
if ( Fl_Group::handle( m ) )
return 1;
@ -725,15 +708,35 @@ Mixer_Strip::handle ( int m )
menu_popup( &menu(), x(), y() );
return 1;
}
else
else
return menu().test_shortcut() != 0;
break;
}
case FL_PUSH:
if ( Fl::event_button1() && Fl::event_inside( color_box ) )
{
}
_button = Fl::event_button();
return 1;
break;
case FL_DRAG:
if ( Fl::event_is_click() )
return 1;
dragging = this;
break;
case FL_RELEASE:
{
if ( dragging == this )
{
mixer->insert( this, mixer->event_inside() );
dragging = NULL;
return 1;
}
int b = _button;
_button = 0;
@ -748,7 +751,6 @@ Mixer_Strip::handle ( int m )
return 1;
}
break;
}
}
return 0;

View File

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