@@ -299,36 +299,40 @@ Sequence::snap ( Sequence_Widget *r ) | |||||
{ | { | ||||
const int snap_pixels = 10; | const int snap_pixels = 10; | ||||
const int rx1 = r->x(); | |||||
const int rx2 = r->x() + r->w(); | |||||
for ( list <Sequence_Widget*>::iterator i = _widgets.begin(); i != _widgets.end(); i++ ) | |||||
if ( Timeline::snap_magnetic ) | |||||
{ | { | ||||
const Sequence_Widget *w = (*i); | |||||
if ( w == r ) | |||||
continue; | |||||
const int rx1 = r->x(); | |||||
const int rx2 = r->x() + r->w(); | |||||
const int wx1 = w->x(); | |||||
const int wx2 = w->x() + w->w(); | |||||
if ( abs( rx1 - wx2 ) < snap_pixels ) | |||||
for ( list <Sequence_Widget*>::iterator i = _widgets.begin(); i != _widgets.end(); i++ ) | |||||
{ | { | ||||
r->offset( w->offset() + w->length() + 1 ); | |||||
const Sequence_Widget *w = (*i); | |||||
if ( w == r ) | |||||
continue; | |||||
const int wx1 = w->x(); | |||||
const int wx2 = w->x() + w->w(); | |||||
if ( abs( rx1 - wx2 ) < snap_pixels ) | |||||
{ | |||||
r->offset( w->offset() + w->length() + 1 ); | |||||
// printf( "snap: %lu | %lu\n", w->offset() + w->length(), r->offset() ); | // printf( "snap: %lu | %lu\n", w->offset() + w->length(), r->offset() ); | ||||
goto done; | |||||
} | |||||
goto done; | |||||
} | |||||
if ( abs( rx2 - wx1 ) < snap_pixels ) | |||||
{ | |||||
r->offset( ( w->offset() - r->length() ) - 1 ); | |||||
if ( abs( rx2 - wx1 ) < snap_pixels ) | |||||
{ | |||||
r->offset( ( w->offset() - r->length() ) - 1 ); | |||||
// printf( "snap: %lu | %lu\n", r->offset() + r->length(), w->offset() ); | // printf( "snap: %lu | %lu\n", r->offset() + r->length(), w->offset() ); | ||||
goto done; | |||||
goto done; | |||||
} | |||||
} | } | ||||
} | } | ||||
@@ -244,7 +244,7 @@ exit( 0 );} | |||||
xywh {0 0 74 25} | xywh {0 0 74 25} | ||||
} { | } { | ||||
Submenu {} { | Submenu {} { | ||||
label {&Snap} open | |||||
label {&Snap to} open | |||||
xywh {0 0 74 25} | xywh {0 0 74 25} | ||||
} { | } { | ||||
MenuItem {} { | MenuItem {} { | ||||
@@ -263,6 +263,11 @@ exit( 0 );} | |||||
xywh {20 20 40 25} type Radio | xywh {20 20 40 25} type Radio | ||||
} | } | ||||
} | } | ||||
MenuItem {} { | |||||
label {Magnetic snap} | |||||
callback {Timeline::snap_magnetic = menu_picked_value( o );} selected | |||||
xywh {10 10 40 25} type Toggle value 1 | |||||
} | |||||
Submenu {} { | Submenu {} { | ||||
label {Capture Format} open | label {Capture Format} open | ||||
xywh {0 0 74 25} | xywh {0 0 74 25} | ||||
@@ -411,7 +416,7 @@ Fl::scheme( Fl::scheme() );} | |||||
Fl::background( 220, 220, 220 ); | Fl::background( 220, 220, 220 ); | ||||
Fl::foreground( 0, 0, 0 ); | Fl::foreground( 0, 0, 0 ); | ||||
Fl::scheme( Fl::scheme() );} selected | |||||
Fl::scheme( Fl::scheme() );} | |||||
xywh {20 20 40 25} type Radio | xywh {20 20 40 25} type Radio | ||||
} | } | ||||
} | } | ||||
@@ -33,6 +33,7 @@ | |||||
bool Timeline::draw_with_measure_lines = true; | bool Timeline::draw_with_measure_lines = true; | ||||
Timeline::snap_e Timeline::snap_to = Bars; | Timeline::snap_e Timeline::snap_to = Bars; | ||||
bool Timeline::snap_magnetic = true; | |||||
const float UPDATE_FREQ = 0.02f; | const float UPDATE_FREQ = 0.02f; | ||||
@@ -115,6 +115,7 @@ public: | |||||
static bool draw_with_measure_lines; | static bool draw_with_measure_lines; | ||||
static snap_e snap_to; | static snap_e snap_to; | ||||
static bool snap_magnetic; | |||||
Tempo_Sequence *tempo_track; | Tempo_Sequence *tempo_track; | ||||
Time_Sequence *time_track; | Time_Sequence *time_track; | ||||