Clean up a bit. Fix non-relative note dragging mode to fit my understanding of its correct behaviour. Fixes #3189.
git-svn-id: svn://localhost/ardour2/branches/3.0@7246 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
@@ -1592,15 +1592,15 @@ NoteResizeDrag::NoteResizeDrag (Editor* e, ArdourCanvas::Item* i)
|
||||
void
|
||||
NoteResizeDrag::start_grab (GdkEvent* event, Gdk::Cursor *)
|
||||
{
|
||||
Gdk::Cursor cursor;
|
||||
ArdourCanvas::CanvasNote* cnote = dynamic_cast<ArdourCanvas::CanvasNote*>(_item);
|
||||
Gdk::Cursor cursor;
|
||||
ArdourCanvas::CanvasNote* cnote = dynamic_cast<ArdourCanvas::CanvasNote*>(_item);
|
||||
|
||||
Drag::start_grab (event);
|
||||
|
||||
region = &cnote->region_view();
|
||||
|
||||
double region_start = region->get_position_pixels();
|
||||
double middle_point = region_start + cnote->x1() + (cnote->x2() - cnote->x1()) / 2.0L;
|
||||
double const region_start = region->get_position_pixels();
|
||||
double const middle_point = region_start + cnote->x1() + (cnote->x2() - cnote->x1()) / 2.0L;
|
||||
|
||||
if (grab_x() <= middle_point) {
|
||||
cursor = Gdk::Cursor(Gdk::LEFT_SIDE);
|
||||
@@ -1644,7 +1644,7 @@ NoteResizeDrag::motion (GdkEvent* /*event*/, bool /*first_move*/)
|
||||
{
|
||||
MidiRegionSelection& ms (_editor->get_selection().midi_regions);
|
||||
for (MidiRegionSelection::iterator r = ms.begin(); r != ms.end(); ++r) {
|
||||
(*r)->update_resizing (at_front, _drags->current_pointer_x() - grab_x(), relative);
|
||||
(*r)->update_resizing (dynamic_cast<ArdourCanvas::CanvasNote*>(_item), at_front, _drags->current_pointer_x() - grab_x(), relative);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1653,7 +1653,7 @@ NoteResizeDrag::finished (GdkEvent*, bool /*movement_occurred*/)
|
||||
{
|
||||
MidiRegionSelection& ms (_editor->get_selection().midi_regions);
|
||||
for (MidiRegionSelection::iterator r = ms.begin(); r != ms.end(); ++r) {
|
||||
(*r)->commit_resizing (at_front, _drags->current_pointer_x() - grab_x(), relative);
|
||||
(*r)->commit_resizing (dynamic_cast<ArdourCanvas::CanvasNote*>(_item), at_front, _drags->current_pointer_x() - grab_x(), relative);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2107,8 +2107,17 @@ MidiRegionView::begin_resizing (bool /*at_front*/)
|
||||
}
|
||||
}
|
||||
|
||||
/** Update resizing notes while user drags.
|
||||
* @param primary `primary' note for the drag; ie the one that is used as the reference in non-relative mode.
|
||||
* @param at_front which end of the note (true == note on, false == note off)
|
||||
* @param delta_x change in mouse position since the start of the drag
|
||||
* @param relative true if relative resizing is taking place, false if absolute resizing. This only makes
|
||||
* a difference when multiple notes are being resized; in relative mode, each note's length is changed by the
|
||||
* amount of the drag. In non-relative mode, all selected notes are set to have the same start or end point
|
||||
* as the \a primary note.
|
||||
*/
|
||||
void
|
||||
MidiRegionView::update_resizing (bool at_front, double delta_x, bool relative)
|
||||
MidiRegionView::update_resizing (ArdourCanvas::CanvasNote* primary, bool at_front, double delta_x, bool relative)
|
||||
{
|
||||
for (std::vector<NoteResizeData *>::iterator i = _resize_data.begin(); i != _resize_data.end(); ++i) {
|
||||
SimpleRect* resize_rect = (*i)->resize_rect;
|
||||
@@ -2119,15 +2128,13 @@ MidiRegionView::update_resizing (bool at_front, double delta_x, bool relative)
|
||||
if (relative) {
|
||||
current_x = canvas_note->x1() + delta_x;
|
||||
} else {
|
||||
// x is in track relative, transform it to region relative
|
||||
current_x = delta_x - get_position_pixels();
|
||||
current_x = primary->x1() + delta_x;
|
||||
}
|
||||
} else {
|
||||
if (relative) {
|
||||
current_x = canvas_note->x2() + delta_x;
|
||||
} else {
|
||||
// x is in track relative, transform it to region relative
|
||||
current_x = delta_x - get_end_position_pixels ();
|
||||
current_x = primary->x2() + delta_x;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2141,30 +2148,33 @@ MidiRegionView::update_resizing (bool at_front, double delta_x, bool relative)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Finish resizing notes when the user releases the mouse button.
|
||||
* Parameters the same as for \a update_resizing().
|
||||
*/
|
||||
void
|
||||
MidiRegionView::commit_resizing (bool at_front, double delta_x, bool relative)
|
||||
MidiRegionView::commit_resizing (ArdourCanvas::CanvasNote* primary, bool at_front, double delta_x, bool relative)
|
||||
{
|
||||
start_diff_command(_("resize notes"));
|
||||
|
||||
CanvasNote* first = _resize_data.empty() ? 0 : _resize_data.front()->canvas_note;
|
||||
|
||||
for (std::vector<NoteResizeData *>::iterator i = _resize_data.begin(); i != _resize_data.end(); ++i) {
|
||||
CanvasNote* canvas_note = (*i)->canvas_note;
|
||||
SimpleRect* resize_rect = (*i)->resize_rect;
|
||||
const double region_start = get_position_pixels();
|
||||
double current_x;
|
||||
|
||||
if (at_front) {
|
||||
if (relative) {
|
||||
current_x = canvas_note->x1() + delta_x;
|
||||
} else {
|
||||
// x is in track relative, transform it to region relative
|
||||
current_x = region_start + delta_x;
|
||||
current_x = primary->x1() + delta_x;
|
||||
}
|
||||
} else {
|
||||
if (relative) {
|
||||
current_x = canvas_note->x2() + delta_x;
|
||||
} else {
|
||||
// x is in track relative, transform it to region relative
|
||||
current_x = region_start + delta_x;
|
||||
current_x = primary->x2() + delta_x;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -219,20 +219,8 @@ class MidiRegionView : public RegionView
|
||||
*/
|
||||
void begin_resizing(bool at_front);
|
||||
|
||||
/** Update resizing notes while user drags.
|
||||
* @param at_front which end of the note (true == note on, false == note off)
|
||||
* @param x the difference in mouse motion, ie the motion difference if relative=true
|
||||
* or the absolute mouse position (track-relative) if relative is false
|
||||
* @param relative true if relative resizing is taking place, false if absolute resizing
|
||||
*/
|
||||
void update_resizing(bool at_front, double x, bool relative);
|
||||
|
||||
/** Finish resizing notes when the user releases the mouse button.
|
||||
* @param at_front which end of the note (true == note on, false == note off)
|
||||
* @param event_x the absolute mouse position (track-relative)
|
||||
* @param relative true if relative resizing is taking place, false if absolute resizing
|
||||
*/
|
||||
void commit_resizing(bool at_front, double event_x, bool relative);
|
||||
void update_resizing (ArdourCanvas::CanvasNote *, bool, double, bool);
|
||||
void commit_resizing (ArdourCanvas::CanvasNote *, bool, double, bool);
|
||||
|
||||
/** Adjust the velocity on a note, and the selection if applicable.
|
||||
* @param velocity the relative or absolute velocity
|
||||
|
||||
Reference in New Issue
Block a user