X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Feditor_mouse.cc;h=e8a50686b324d3f447241d7dfb19f7c5cadb7f9d;hb=b0685f4336f0496d58c16c516dfd0eabfb7f0456;hp=fc76c6a43c18c158c0858970ce50e95c525705ee;hpb=532f6aad4ac79ca15d69deccd18fca90e444c437;p=ardour.git diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc index fc76c6a43c..e8a50686b3 100644 --- a/gtk2_ardour/editor_mouse.cc +++ b/gtk2_ardour/editor_mouse.cc @@ -15,7 +15,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id$ */ #include @@ -35,6 +34,7 @@ #include "time_axis_view.h" #include "audio_time_axis.h" #include "audio_region_view.h" +#include "midi_region_view.h" #include "marker.h" #include "streamview.h" #include "region_gain_line.h" @@ -47,6 +47,7 @@ #include "rgb_macros.h" #include +#include #include #include #include @@ -291,8 +292,6 @@ void Editor::button_selection (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type) { bool commit = false; - bool c1; - bool c2; /* in object/audition/timefx mode, any button press sets the selection if the object can be selected. this is a @@ -304,84 +303,84 @@ Editor::button_selection (ArdourCanvas::Item* item, GdkEvent* event, ItemType it if (((mouse_mode != MouseObject) && (mouse_mode != MouseAudition || item_type != RegionItem) && - (mouse_mode != MouseTimeFX || item_type != RegionItem)) || + (mouse_mode != MouseTimeFX || item_type != RegionItem) && + (mouse_mode != MouseRange)) || + (event->type != GDK_BUTTON_PRESS && event->type != GDK_BUTTON_RELEASE || event->button.button > 3)) { return; } + + if (event->type == GDK_BUTTON_PRESS || event->type == GDK_BUTTON_RELEASE) { + + if ((event->button.state & Keyboard::RelevantModifierKeyMask) && event->button.button != 1) { + + /* almost no selection action on modified button-2 or button-3 events */ + + if (item_type != RegionItem && event->button.button != 2) { + return; + } + } + } Selection::Operation op = Keyboard::selection_type (event->button.state); bool press = (event->type == GDK_BUTTON_PRESS); - begin_reversible_command (_("select on click")); - + // begin_reversible_command (_("select on click")); + switch (item_type) { case RegionItem: - /* XXX make tying track/region selection optional */ - c1 = set_selected_track_from_click (op, true); - c2 = set_selected_regionview_from_click (press, op, true); - commit = (c1 || c2); - break; - case RegionViewNameHighlight: case RegionViewName: - /* XXX make tying track/region selection optional */ - c1 = set_selected_track_from_click (op, true); - c2 = set_selected_regionview_from_click (press, op, true); - commit = (c1 || c2); + case FadeInHandleItem: + case FadeInItem: + case FadeOutHandleItem: + case FadeOutItem: + if (mouse_mode != MouseRange) { + commit = set_selected_regionview_from_click (press, op, true); + } else if (event->type == GDK_BUTTON_PRESS) { + commit = set_selected_track_from_click (press, op, false); + } break; - + + case CrossfadeViewItem: + commit = set_selected_track_from_click (press, op, false); + break; + case GainAutomationControlPointItem: case PanAutomationControlPointItem: case RedirectAutomationControlPointItem: - /* XXX make tying track/region selection optional */ - c1 = set_selected_track_from_click (op, true); - c2 = set_selected_control_point_from_click (op, false); - commit = (c1 || c2); + commit = set_selected_track_from_click (press, op, true); + if (mouse_mode != MouseRange) { + commit |= set_selected_control_point_from_click (op, false); + } break; case StreamItem: - commit = set_selected_track_from_click (op, true); + /* for context click or range selection, select track */ + if (event->button.button == 3) { + commit = set_selected_track_from_click (press, op, true); + } else if (event->type == GDK_BUTTON_PRESS && mouse_mode == MouseRange) { + commit = set_selected_track_from_click (press, op, false); + } break; case AutomationTrackItem: - commit = set_selected_track_from_click (op, true); + commit = set_selected_track_from_click (press, op, true); break; default: break; } -#define SELECT_TRACK_FROM_CANVAS_IN_RANGE_MODE -#ifdef SELECT_TRACK_FROM_CANVAS_IN_RANGE_MODE - /* in range mode, button 1/2/3 press potentially selects a track */ - - if (mouse_mode == MouseRange && - event->type == GDK_BUTTON_PRESS && - event->button.button <= 3) { - - switch (item_type) { - case StreamItem: - case RegionItem: - case AutomationTrackItem: - commit = set_selected_track_from_click (op, true); - break; - - default: - break; - } - } -#endif - if (commit) { - commit_reversible_command (); - } +// if (commit) { +// commit_reversible_command (); +// } } bool Editor::button_press_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type) { - nframes_t where = event_frame (event, 0, 0); - track_canvas.grab_focus(); if (session && session->actively_recording()) { @@ -500,10 +499,9 @@ Editor::button_press_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemTyp break; case MouseObject: - if (Keyboard::modifier_state_contains (event->button.state, - Keyboard::ModifierMask(Keyboard::Control|Keyboard::Alt)) - && event->type == GDK_BUTTON_PRESS) { - + if (Keyboard::modifier_state_contains (event->button.state, Keyboard::ModifierMask(Keyboard::Control|Keyboard::Alt)) && + event->type == GDK_BUTTON_PRESS) { + start_rubberband_select (item, event); } else if (event->type == GDK_BUTTON_PRESS) { @@ -557,7 +555,7 @@ Editor::button_press_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemTyp start_rubberband_select (item, event); break; - /* */ +#ifdef WITH_CMT case ImageFrameHandleStartItem: imageframe_start_handle_op(item, event) ; return(true) ; @@ -574,16 +572,13 @@ Editor::button_press_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemTyp markerview_item_end_handle_op(item, event) ; return(true) ; break ; - /* */ - - /* */ case MarkerViewItem: start_markerview_grab(item, event) ; break ; case ImageFrameItem: start_imageframe_grab(item, event) ; break ; - /* */ +#endif case MarkerBarItem: @@ -740,79 +735,6 @@ Editor::button_press_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemTyp case 3: break; - case 4: - switch (mouse_mode) { - case MouseZoom: - //temporal_zoom_to_frame (true, where); - if (Keyboard::modifier_state_equals (event->button.state, Keyboard::Control)) { - temporal_zoom_to_frame (true, where); - } - else { - temporal_zoom_step (true); - } - break; - default: - - if (Keyboard::modifier_state_contains (event->button.state, Keyboard::ModifierMask(Keyboard::Alt))) { - scroll_backward (0.6f); - return true; - } - else if (Keyboard::no_modifier_keys_pressed (&event->button)) { - scroll_tracks_up_line (); - } else { - if (Keyboard::modifier_state_equals (event->button.state, Keyboard::Shift)) { - if (clicked_axisview) { - if (!current_stepping_trackview) { - step_timeout = Glib::signal_timeout().connect (mem_fun(*this, &Editor::track_height_step_timeout), 500); - current_stepping_trackview = clicked_axisview; - } - gettimeofday (&last_track_height_step_timestamp, 0); - current_stepping_trackview->step_height (true); - } - } - else if (Keyboard::modifier_state_equals (event->button.state, Keyboard::Control)) { - temporal_zoom_to_frame (true, where); - } - } - } - break; - - case 5: - switch (mouse_mode) { - case MouseZoom: - // temporal_zoom_to_frame (false, where); - if (Keyboard::modifier_state_equals (event->button.state, Keyboard::Control)) { - temporal_zoom_to_frame (false, where); - } - else { - temporal_zoom_step (false); - } - break; - default: - - if (Keyboard::modifier_state_contains (event->button.state, Keyboard::ModifierMask(Keyboard::Alt))) { - scroll_forward (0.6f); - return true; - } - else if (Keyboard::no_modifier_keys_pressed (&event->button)) { - scroll_tracks_down_line (); - } else { - if (Keyboard::modifier_state_equals (event->button.state, Keyboard::Shift)) { - if (clicked_axisview) { - if (!current_stepping_trackview) { - step_timeout = Glib::signal_timeout().connect (mem_fun(*this, &Editor::track_height_step_timeout), 500); - current_stepping_trackview = clicked_axisview; - } - gettimeofday (&last_track_height_step_timestamp, 0); - current_stepping_trackview->step_height (false); - } - } else if (Keyboard::modifier_state_equals (event->button.state, Keyboard::Control)) { - temporal_zoom_to_frame (false, where); - } - } - } - break; - default: break; @@ -890,21 +812,13 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT break; case StreamItem: - popup_track_context_menu (1, event->button.time, item_type, false, where); - break; - case RegionItem: case RegionViewNameHighlight: case RegionViewName: - popup_track_context_menu (1, event->button.time, item_type, false, where); - break; - case SelectionItem: - popup_track_context_menu (1, event->button.time, item_type, true, where); - break; - case AutomationTrackItem: - popup_track_context_menu (1, event->button.time, item_type, false, where); + case CrossfadeViewItem: + popup_track_context_menu (1, event->button.time, where); break; case MarkerBarItem: @@ -927,11 +841,7 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT tm_marker_context_menu (&event->button, item); break; - case CrossfadeViewItem: - popup_track_context_menu (1, event->button.time, item_type, false, where); - break; - - /* */ +#ifdef WITH_CMT case ImageFrameItem: popup_imageframe_edit_menu(1, event->button.time, item, true) ; break ; @@ -944,8 +854,7 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT case MarkerTimeAxisItem: popup_marker_time_axis_edit_menu(1, event->button.time, item, false) ; break ; - /* */ - +#endif default: break; @@ -1054,8 +963,10 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT case MouseGain: // Gain only makes sense for audio regions - if ( ! dynamic_cast(clicked_regionview)) + + if (!dynamic_cast(clicked_regionview)) { break; + } switch (item_type) { case RegionItem: @@ -1095,25 +1006,6 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT case 2: switch (mouse_mode) { - case MouseObject: - switch (item_type) { - case RegionItem: - if (Keyboard::modifier_state_equals (event->button.state, Keyboard::Shift)) { - raise_region (); - } else if (Keyboard::modifier_state_equals (event->button.state, Keyboard::ModifierMask (Keyboard::Shift|Keyboard::Alt))) { - lower_region (); - } else { - // Button2 click is unused - } - return true; - - break; - - default: - break; - } - break; - case MouseRange: // x_style_paste (where, 1.0); @@ -1155,7 +1047,7 @@ Editor::enter_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_ at_x += 20.0; at_y += 20.0; - fraction = 1.0 - (cp->get_y() / cp->line.height()); + fraction = 1.0 - ((cp->get_y() - cp->line.y_position()) / cp->line.height()); set_verbose_canvas_cursor (cp->line.get_verbose_cursor_string (fraction), at_x, at_y); show_verbose_canvas_cursor (); @@ -1169,23 +1061,25 @@ Editor::enter_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_ case GainAutomationControlPointItem: case PanAutomationControlPointItem: case RedirectAutomationControlPointItem: - cp = static_cast(item->get_data ("control_point")); - cp->set_visible (true); - - double at_x, at_y; - at_x = cp->get_x(); - at_y = cp->get_y (); - cp->item->i2w (at_x, at_y); - at_x += 20.0; - at_y += 20.0; - - fraction = 1.0 - (cp->get_y() / cp->line.height()); - - set_verbose_canvas_cursor (cp->line.get_verbose_cursor_string (fraction), at_x, at_y); - show_verbose_canvas_cursor (); - - if (is_drawable()) { - track_canvas.get_window()->set_cursor (*fader_cursor); + if (mouse_mode == MouseGain || mouse_mode == MouseObject) { + cp = static_cast(item->get_data ("control_point")); + cp->set_visible (true); + + double at_x, at_y; + at_x = cp->get_x(); + at_y = cp->get_y (); + cp->item->i2w (at_x, at_y); + at_x += 20.0; + at_y += 20.0; + + fraction = 1.0 - (cp->get_y() / cp->line.height()); + + set_verbose_canvas_cursor (cp->line.get_verbose_cursor_string (fraction), at_x, at_y); + show_verbose_canvas_cursor (); + + if (is_drawable()) { + track_canvas.get_window()->set_cursor (*fader_cursor); + } } break; @@ -1203,13 +1097,15 @@ Editor::enter_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_ case GainAutomationLineItem: case RedirectAutomationLineItem: case PanAutomationLineItem: - { - ArdourCanvas::Line *line = dynamic_cast (item); - if (line) - line->property_fill_color_rgba() = color_map[cEnteredAutomationLine]; - } - if (is_drawable()) { - track_canvas.get_window()->set_cursor (*fader_cursor); + if (mouse_mode == MouseGain || mouse_mode == MouseObject) { + { + ArdourCanvas::Line *line = dynamic_cast (item); + if (line) + line->property_fill_color_rgba() = color_map[cEnteredAutomationLine]; + } + if (is_drawable()) { + track_canvas.get_window()->set_cursor (*fader_cursor); + } } break; @@ -1221,12 +1117,13 @@ Editor::enter_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_ case StartSelectionTrimItem: case EndSelectionTrimItem: - /* */ + +#ifdef WITH_CMT case ImageFrameHandleStartItem: case ImageFrameHandleEndItem: case MarkerViewHandleStartItem: case MarkerViewHandleEndItem: - /* */ +#endif if (is_drawable()) { track_canvas.get_window()->set_cursor (*trimmer_cursor); @@ -1376,12 +1273,14 @@ Editor::leave_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_ case EndSelectionTrimItem: case EditCursorItem: case PlayheadCursorItem: - /* */ + +#ifdef WITH_CMT case ImageFrameHandleStartItem: case ImageFrameHandleEndItem: case MarkerViewHandleStartItem: case MarkerViewHandleEndItem: - /* */ +#endif + if (is_drawable()) { track_canvas.get_window()->set_cursor (*current_canvas_cursor); } @@ -1510,7 +1409,10 @@ Editor::motion_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item */ if (!drag_info.move_threshold_passed) { - drag_info.move_threshold_passed = (abs ((int) (drag_info.current_pointer_x - drag_info.grab_x)) > 4); + bool x_threshold_passed = (abs ((nframes64_t) (drag_info.current_pointer_x - drag_info.grab_x)) > 4LL); + bool y_threshold_passed = (abs ((nframes64_t) (drag_info.current_pointer_y - drag_info.grab_y)) > 4LL); + + drag_info.move_threshold_passed = (x_threshold_passed || y_threshold_passed); // and change the initial grab loc/frame if this drag info wants us to @@ -1544,12 +1446,14 @@ Editor::motion_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item case PanAutomationLineItem: case FadeInHandleItem: case FadeOutHandleItem: - /* */ + +#ifdef WITH_CMT case ImageFrameHandleStartItem: case ImageFrameHandleEndItem: case MarkerViewHandleStartItem: case MarkerViewHandleEndItem: - /* */ +#endif + if (drag_info.item && (event->motion.state & Gdk::BUTTON1_MASK || (event->motion.state & Gdk::BUTTON2_MASK))) { if (!from_autoscroll) { @@ -1621,7 +1525,7 @@ Editor::start_grab (GdkEvent* event, Gdk::Cursor *cursor) drag_info.y_constrained = false; } - drag_info.grab_frame = event_frame(event, &drag_info.grab_x, &drag_info.grab_y); + drag_info.grab_frame = event_frame (event, &drag_info.grab_x, &drag_info.grab_y); drag_info.last_pointer_frame = drag_info.grab_frame; drag_info.current_pointer_frame = drag_info.grab_frame; drag_info.current_pointer_x = drag_info.grab_x; @@ -1765,7 +1669,7 @@ Editor::fade_in_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event) nframes_t pos; nframes_t fade_length; - if ((long)drag_info.current_pointer_frame > drag_info.pointer_frame_offset) { + if (drag_info.current_pointer_frame > drag_info.pointer_frame_offset) { pos = drag_info.current_pointer_frame - drag_info.pointer_frame_offset; } else { @@ -1775,16 +1679,26 @@ Editor::fade_in_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event) if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) { snap_to (pos); } - + if (pos < (arv->region()->position() + 64)) { fade_length = 64; // this should be a minimum defined somewhere } else if (pos > arv->region()->last_frame()) { fade_length = arv->region()->length(); } else { fade_length = pos - arv->region()->position(); - } + } + /* mapover the region selection */ + + for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) { + + AudioRegionView* tmp = dynamic_cast (*i); + + if (!tmp) { + continue; + } - arv->reset_fade_in_shape_width (fade_length); + tmp->reset_fade_in_shape_width (fade_length); + } show_verbose_duration_cursor (arv->region()->position(), arv->region()->position() + fade_length, 10); @@ -1794,43 +1708,46 @@ Editor::fade_in_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event) void Editor::fade_in_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event) { - if (drag_info.first_move) return; - AudioRegionView* arv = static_cast(drag_info.data); nframes_t pos; nframes_t fade_length; - if ((long)drag_info.current_pointer_frame > drag_info.pointer_frame_offset) { + if (drag_info.first_move) return; + + if (drag_info.current_pointer_frame > drag_info.pointer_frame_offset) { pos = drag_info.current_pointer_frame - drag_info.pointer_frame_offset; - } - else { + } else { pos = 0; } - if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) { - snap_to (pos); - } - if (pos < (arv->region()->position() + 64)) { fade_length = 64; // this should be a minimum defined somewhere - } - else if (pos > arv->region()->last_frame()) { + } else if (pos > arv->region()->last_frame()) { fade_length = arv->region()->length(); - } - else { + } else { fade_length = pos - arv->region()->position(); } - + begin_reversible_command (_("change fade in length")); - AutomationList& alist = arv->audio_region()->fade_in(); - XMLNode &before = alist.get_state(); - arv->audio_region()->set_fade_in_length (fade_length); + for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) { + + AudioRegionView* tmp = dynamic_cast (*i); + + if (!tmp) { + continue; + } + + AutomationList& alist = tmp->audio_region()->fade_in(); + XMLNode &before = alist.get_state(); + + tmp->audio_region()->set_fade_in_length (fade_length); + + XMLNode &after = alist.get_state(); + session->add_command(new MementoCommand(alist, &before, &after)); + } - XMLNode &after = alist.get_state(); - session->add_command(new MementoCommand(alist, &before, &after)); commit_reversible_command (); - fade_in_drag_motion_callback (item, event); } void @@ -1859,17 +1776,16 @@ Editor::fade_out_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event nframes_t pos; nframes_t fade_length; - if ((long)drag_info.current_pointer_frame > drag_info.pointer_frame_offset) { + if (drag_info.current_pointer_frame > drag_info.pointer_frame_offset) { pos = drag_info.current_pointer_frame - drag_info.pointer_frame_offset; - } - else { + } else { pos = 0; } if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) { snap_to (pos); } - + if (pos > (arv->region()->last_frame() - 64)) { fade_length = 64; // this should really be a minimum fade defined somewhere } @@ -1879,8 +1795,19 @@ Editor::fade_out_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event else { fade_length = arv->region()->last_frame() - pos; } + + /* mapover the region selection */ + + for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) { + + AudioRegionView* tmp = dynamic_cast (*i); + + if (!tmp) { + continue; + } - arv->reset_fade_out_shape_width (fade_length); + tmp->reset_fade_out_shape_width (fade_length); + } show_verbose_duration_cursor (arv->region()->last_frame() - fade_length, arv->region()->last_frame(), 10); @@ -1896,7 +1823,7 @@ Editor::fade_out_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* eve nframes_t pos; nframes_t fade_length; - if ((long)drag_info.current_pointer_frame > drag_info.pointer_frame_offset) { + if (drag_info.current_pointer_frame > drag_info.pointer_frame_offset) { pos = drag_info.current_pointer_frame - drag_info.pointer_frame_offset; } else { @@ -1918,16 +1845,25 @@ Editor::fade_out_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* eve } begin_reversible_command (_("change fade out length")); - AutomationList& alist = arv->audio_region()->fade_out(); - XMLNode &before = alist.get_state(); - arv->audio_region()->set_fade_out_length (fade_length); + for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) { - XMLNode &after = alist.get_state(); - session->add_command(new MementoCommand(alist, &before, &after)); - commit_reversible_command (); + AudioRegionView* tmp = dynamic_cast (*i); + + if (!tmp) { + continue; + } + + AutomationList& alist = tmp->audio_region()->fade_out(); + XMLNode &before = alist.get_state(); + + tmp->audio_region()->set_fade_out_length (fade_length); + + XMLNode &after = alist.get_state(); + session->add_command(new MementoCommand(alist, &before, &after)); + } - fade_out_drag_motion_callback (item, event); + commit_reversible_command (); } void @@ -1951,7 +1887,11 @@ Editor::start_cursor_grab (ArdourCanvas::Item* item, GdkEvent* event) if (session && drag_info.was_rolling) { session->request_stop (); - } + } + + if (session && session->is_auditioning()) { + session->cancel_audition (); + } } drag_info.pointer_frame_offset = drag_info.grab_frame - cursor->current_frame; @@ -1965,7 +1905,7 @@ Editor::cursor_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event) Cursor* cursor = (Cursor *) drag_info.data; nframes_t adjusted_frame; - if ((long)drag_info.current_pointer_frame > drag_info.pointer_frame_offset) { + if (drag_info.current_pointer_frame > drag_info.pointer_frame_offset) { adjusted_frame = drag_info.current_pointer_frame - drag_info.pointer_frame_offset; } else { @@ -2081,10 +2021,9 @@ Editor::marker_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event) nframes_t newframe; - if (drag_info.pointer_frame_offset <= (long) drag_info.current_pointer_frame) { + if (drag_info.pointer_frame_offset <= drag_info.current_pointer_frame) { newframe = drag_info.current_pointer_frame - drag_info.pointer_frame_offset; - } - else { + } else { newframe = 0; } @@ -2262,7 +2201,7 @@ Editor::meter_marker_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* e MeterMarker* marker = (MeterMarker *) drag_info.data; nframes_t adjusted_frame; - if ((long)drag_info.current_pointer_frame > drag_info.pointer_frame_offset) { + if (drag_info.current_pointer_frame > drag_info.pointer_frame_offset) { adjusted_frame = drag_info.current_pointer_frame - drag_info.pointer_frame_offset; } else { @@ -2393,7 +2332,7 @@ Editor::tempo_marker_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* e TempoMarker* marker = (TempoMarker *) drag_info.data; nframes_t adjusted_frame; - if ((long)drag_info.current_pointer_frame > drag_info.pointer_frame_offset) { + if (drag_info.current_pointer_frame > drag_info.pointer_frame_offset) { adjusted_frame = drag_info.current_pointer_frame - drag_info.pointer_frame_offset; } else { @@ -2486,7 +2425,7 @@ void Editor::start_control_point_grab (ArdourCanvas::Item* item, GdkEvent* event) { ControlPoint* control_point; - + if ((control_point = reinterpret_cast (item->get_data ("control_point"))) == 0) { fatal << _("programming error: control point canvas item has no control point object pointer!") << endmsg; /*NOTREACHED*/ @@ -2501,7 +2440,7 @@ Editor::start_control_point_grab (ArdourCanvas::Item* item, GdkEvent* event) control_point->line.start_drag (control_point, drag_info.grab_frame, 0); - float fraction = 1.0 - (control_point->get_y() / control_point->line.height()); + float fraction = 1.0 - ((control_point->get_y() - control_point->line.y_position()) / control_point->line.height()); set_verbose_canvas_cursor (control_point->line.get_verbose_cursor_string (fraction), drag_info.current_pointer_x + 20, drag_info.current_pointer_y + 20); @@ -2530,7 +2469,7 @@ Editor::control_point_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* cx = max (0.0, cx); cy = max (0.0, cy); - cy = min ((double) cp->line.height(), cy); + cy = min ((double) (cp->line.y_position() + cp->line.height()), cy); //translate cx to frames nframes_t cx_frames = unit_to_frame (cx); @@ -2539,8 +2478,8 @@ Editor::control_point_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* snap_to (cx_frames); } - float fraction = 1.0 - (cy / cp->line.height()); - + float const fraction = 1.0 - ((cy - cp->line.y_position()) / cp->line.height()); + bool push; if (Keyboard::modifier_state_contains (event->button.state, Keyboard::Control)) { @@ -2630,7 +2569,7 @@ Editor::start_line_grab (AutomationLine* line, GdkEvent* event) start_grab (event, fader_cursor); - double fraction = 1.0 - (cy / line->height()); + double const fraction = 1.0 - ((cy - line->y_position()) / line->height()); line->start_drag (0, drag_info.grab_frame, fraction); @@ -2648,8 +2587,7 @@ Editor::line_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event) line->parent_group().w2i (cx, cy); - double fraction; - fraction = 1.0 - (cy / line->height()); + double const fraction = 1.0 - ((cy - line->y_position()) / line->height()); bool push; @@ -2709,8 +2647,6 @@ Editor::start_region_grab (ArdourCanvas::Item* item, GdkEvent* event) void Editor::start_region_copy_grab (ArdourCanvas::Item* item, GdkEvent* event) { - cerr << "start region copy grab, selected regions = " << selection->regions.size() << endl; - if (selection->regions.empty() || clicked_regionview == 0) { return; } @@ -2789,61 +2725,36 @@ Editor::region_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event) drag_info.want_move_threshold = false; // don't copy again - /* this is committed in the grab finished callback. */ - - begin_reversible_command (_("Drag region copy")); - /* duplicate the region(s) */ - + vector new_regionviews; - set > affected_playlists; - pair >::iterator,bool> insert_result; - - // TODO: Crossfades need to be copied! for (list::const_iterator i = selection->regions.by_layer().begin(); i != selection->regions.by_layer().end(); ++i) { RegionView* rv; - + RegionView* nrv; + rv = (*i); - - boost::shared_ptr to_playlist = rv->region()->playlist(); - RouteTimeAxisView* rtv = dynamic_cast(&rv->get_time_axis_view()); - - insert_result = affected_playlists.insert (to_playlist); - if (insert_result.second) { - session->add_command (new MementoCommand(*to_playlist, &to_playlist->get_state(), 0)); - } - - latest_regionview = 0; - - sigc::connection c = rtv->view()->RegionViewAdded.connect (mem_fun(*this, &Editor::collect_new_region_view)); - - /* create a new region with the same name. */ - - boost::shared_ptr newregion; - newregion = RegionFactory::create (rv->region()); - assert(newregion != 0); + AudioRegionView* arv = dynamic_cast(rv); + MidiRegionView* mrv = dynamic_cast(rv); - /* if the original region was locked, we don't care */ - - newregion->set_locked (false); - - to_playlist->add_region (newregion, (nframes_t) (rv->region()->position() * rtv->get_diskstream()->speed())); - - c.disconnect (); - - if (latest_regionview) { - new_regionviews.push_back (latest_regionview); + if (arv) { + nrv = new AudioRegionView (*arv); + } else if (mrv) { + nrv = new MidiRegionView (*mrv); + } else { + continue; } + + nrv->get_canvas_group()->show (); + + new_regionviews.push_back (nrv); } - - if (new_regionviews.empty()) { return; } - + /* reset selection to new regionviews */ selection->set (new_regionviews); @@ -2851,6 +2762,7 @@ Editor::region_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event) /* reset drag_info data to reflect the fact that we are dragging the copies */ drag_info.data = new_regionviews.front(); + swap_grab (new_regionviews.front()->get_canvas_group (), 0, event->motion.time); } @@ -3038,14 +2950,14 @@ Editor::region_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event) if (drag_info.move_threshold_passed) { - if ((int32_t)drag_info.current_pointer_frame > drag_info.pointer_frame_offset) { + if (drag_info.current_pointer_frame > drag_info.pointer_frame_offset) { nframes_t sync_frame; nframes_t sync_offset; int32_t sync_dir; pending_region_position = drag_info.current_pointer_frame - drag_info.pointer_frame_offset; - + sync_offset = rv->region()->sync_offset (sync_dir); sync_frame = rv->region()->adjust_to_sync (pending_region_position); @@ -3077,13 +2989,13 @@ Editor::region_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event) /* now compute the canvas unit distance we need to move the regiondrag_info.last_trackview->order to make it appear at the new location. */ - + if (pending_region_position > drag_info.last_frame_position) { x_delta = ((double) (pending_region_position - drag_info.last_frame_position) / frames_per_unit); } else { x_delta = -((double) (drag_info.last_frame_position - pending_region_position) / frames_per_unit); } - + drag_info.last_frame_position = pending_region_position; } else { @@ -3107,6 +3019,7 @@ Editor::region_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event) return; } + if (x_delta < 0) { for (list::const_iterator i = selection->regions.by_layer().begin(); i != selection->regions.by_layer().end(); ++i) { @@ -3129,149 +3042,148 @@ Editor::region_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event) MOTION ************************************************************/ - pair >::iterator,bool> insert_result; - const list& layered_regions = selection->regions.by_layer(); + bool do_move; - for (list::const_iterator i = layered_regions.begin(); i != layered_regions.end(); ++i) { + if (drag_info.first_move) { + if (drag_info.move_threshold_passed) { + do_move = true; + } else { + do_move = false; + } + } else { + do_move = true; + } + + if (do_move) { + + pair >::iterator,bool> insert_result; + const list& layered_regions = selection->regions.by_layer(); + + for (list::const_iterator i = layered_regions.begin(); i != layered_regions.end(); ++i) { - RegionView* rv = (*i); - double ix1, ix2, iy1, iy2; - int32_t temp_pointer_y_span = pointer_y_span; + RegionView* rv = (*i); + double ix1, ix2, iy1, iy2; + int32_t temp_pointer_y_span = pointer_y_span; - /* get item BBox, which will be relative to parent. so we have - to query on a child, then convert to world coordinates using - the parent. - */ + /* get item BBox, which will be relative to parent. so we have + to query on a child, then convert to world coordinates using + the parent. + */ - rv->get_canvas_frame()->get_bounds (ix1, iy1, ix2, iy2); - rv->get_canvas_group()->i2w (ix1, iy1); - TimeAxisView* tvp2 = trackview_by_y_position (iy1); - RouteTimeAxisView* canvas_rtv = dynamic_cast(tvp2); - RouteTimeAxisView* temp_rtv; - - if ((pointer_y_span != 0) && !clamp_y_axis) { - y_delta = 0; - int32_t x = 0; - for (j = height_list.begin(); j!= height_list.end(); j++) { - if (x == canvas_rtv->order) { - /* we found the track the region is on */ - if (x != original_pointer_order) { - /*this isn't from the same track we're dragging from */ - temp_pointer_y_span = canvas_pointer_y_span; - } - while (temp_pointer_y_span > 0) { - /* we're moving up canvas-wise, - so we need to find the next track height - */ - if (j != height_list.begin()) { - j--; - } - if (x != original_pointer_order) { - /* we're not from the dragged track, so ignore hidden tracks. */ - if ((*j) == 0) { - temp_pointer_y_span++; - } - } - y_delta -= (*j); - temp_pointer_y_span--; - } - while (temp_pointer_y_span < 0) { - y_delta += (*j); - if (x != original_pointer_order) { - if ((*j) == 0) { - temp_pointer_y_span--; + rv->get_canvas_frame()->get_bounds (ix1, iy1, ix2, iy2); + rv->get_canvas_group()->i2w (ix1, iy1); + TimeAxisView* tvp2 = trackview_by_y_position (iy1); + RouteTimeAxisView* canvas_rtv = dynamic_cast(tvp2); + RouteTimeAxisView* temp_rtv; + + if ((pointer_y_span != 0) && !clamp_y_axis) { + y_delta = 0; + int32_t x = 0; + for (j = height_list.begin(); j!= height_list.end(); j++) { + if (x == canvas_rtv->order) { + /* we found the track the region is on */ + if (x != original_pointer_order) { + /*this isn't from the same track we're dragging from */ + temp_pointer_y_span = canvas_pointer_y_span; + } + while (temp_pointer_y_span > 0) { + /* we're moving up canvas-wise, + so we need to find the next track height + */ + if (j != height_list.begin()) { + j--; } - } + if (x != original_pointer_order) { + /* we're not from the dragged track, so ignore hidden tracks. */ + if ((*j) == 0) { + temp_pointer_y_span++; + } + } + y_delta -= (*j); + temp_pointer_y_span--; + } + while (temp_pointer_y_span < 0) { + y_delta += (*j); + if (x != original_pointer_order) { + if ((*j) == 0) { + temp_pointer_y_span--; + } + } - if (j != height_list.end()) { - j++; + if (j != height_list.end()) { + j++; + } + temp_pointer_y_span++; } - temp_pointer_y_span++; - } - /* find out where we'll be when we move and set height accordingly */ + /* find out where we'll be when we move and set height accordingly */ - tvp2 = trackview_by_y_position (iy1 + y_delta); - temp_rtv = dynamic_cast(tvp2); - rv->set_height (temp_rtv->height); + tvp2 = trackview_by_y_position (iy1 + y_delta); + temp_rtv = dynamic_cast(tvp2); + rv->set_y_position_and_height (0, temp_rtv->height); - /* if you un-comment the following, the region colours will follow the track colours whilst dragging, - personally, i think this can confuse things, but never mind. - */ + /* if you un-comment the following, the region colours will follow the track colours whilst dragging, + personally, i think this can confuse things, but never mind. + */ - //const GdkColor& col (temp_rtv->view->get_region_color()); - //rv->set_color (const_cast(col)); - break; + //const GdkColor& col (temp_rtv->view->get_region_color()); + //rv->set_color (const_cast(col)); + break; + } + x++; } - x++; } - } - /* prevent the regionview from being moved to before - the zero position on the canvas. - */ - /* clamp */ + /* prevent the regionview from being moved to before + the zero position on the canvas. + */ + /* clamp */ - if (x_delta < 0) { - if (-x_delta > ix1) { - x_delta = -ix1; + if (x_delta < 0) { + if (-x_delta > ix1) { + x_delta = -ix1; + } + } else if ((x_delta > 0) && (rv->region()->last_frame() > max_frames - x_delta)) { + x_delta = max_frames - rv->region()->last_frame(); } - } else if ((x_delta > 0) &&(rv->region()->last_frame() > max_frames - x_delta)) { - x_delta = max_frames - rv->region()->last_frame(); - } - - if (drag_info.first_move) { - /* hide any dependent views */ -// rv->get_time_axis_view().hide_dependent_views (*rv); - - /* this is subtle. raising the regionview itself won't help, - because raise_to_top() just puts the item on the top of - its parent's stack. so, we need to put the trackview canvas_display group - on the top, since its parent is the whole canvas. - */ + if (drag_info.first_move) { - rv->get_canvas_group()->raise_to_top(); - rv->get_time_axis_view().canvas_display->raise_to_top(); - cursor_group->raise_to_top(); + /* hide any dependent views */ + + rv->get_time_axis_view().hide_dependent_views (*rv); + + /* this is subtle. raising the regionview itself won't help, + because raise_to_top() just puts the item on the top of + its parent's stack. so, we need to put the trackview canvas_display group + on the top, since its parent is the whole canvas. + */ + + rv->get_canvas_group()->raise_to_top(); + rv->get_time_axis_view().canvas_display->raise_to_top(); + cursor_group->raise_to_top(); - /* freeze the playlists from notifying till - the motion is done. - */ + rv->fake_set_opaque (true); + } + + if (drag_info.brushing) { + mouse_brush_insert_region (rv, pending_region_position); + } else { + rv->move (x_delta, y_delta); + } - RouteTimeAxisView* rtv = dynamic_cast (&rv->get_time_axis_view()); - if (rtv && rtv->is_audio_track()) { - boost::shared_ptr pl = boost::dynamic_pointer_cast(rtv->get_diskstream()->playlist()); - if (pl) { - /* only freeze and capture state once */ + } /* foreach region */ - insert_result = motion_frozen_playlists.insert (pl); - if (insert_result.second) { - pl->freeze(); - session->add_command(new MementoCommand(*pl, &pl->get_state(), 0)); - } - } - } - rv->region()->set_opaque(false); - } + } /* if do_move */ - if (drag_info.brushing) { - mouse_brush_insert_region (rv, pending_region_position); - } else { - rv->move (x_delta, y_delta); - } - } - - if (drag_info.first_move) { + if (drag_info.first_move && drag_info.move_threshold_passed) { cursor_group->raise_to_top(); + drag_info.first_move = false; } - - drag_info.first_move = false; - + if (x_delta != 0 && !drag_info.brushing) { show_verbose_time_cursor (drag_info.last_frame_position, 10); } - } void @@ -3282,9 +3194,10 @@ Editor::region_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event pair >::iterator,bool> insert_result; bool nocommit = true; double speed; - RouteTimeAxisView* atv; + RouteTimeAxisView* rtv; bool regionview_y_movement; bool regionview_x_movement; + vector copies; /* first_move is set to false if the regionview has been moved in the motion handler. @@ -3305,15 +3218,22 @@ Editor::region_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event if (drag_info.brushing) { /* all changes were made during motion event handlers */ + + if (drag_info.copy) { + for (list::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) { + copies.push_back (*i); + } + } + goto out; } /* adjust for track speed */ speed = 1.0; - atv = dynamic_cast (drag_info.last_trackview); - if (atv && atv->get_diskstream()) { - speed = atv->get_diskstream()->speed(); + rtv = dynamic_cast (drag_info.last_trackview); + if (rtv && rtv->get_diskstream()) { + speed = rtv->get_diskstream()->speed(); } regionview_x_movement = (drag_info.last_frame_position != (nframes_t) (rv->region()->position()/speed)); @@ -3322,119 +3242,141 @@ Editor::region_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event //printf ("last_frame: %s position is %lu %g\n", rv->get_time_axis_view().name().c_str(), drag_info.last_frame_position, speed); //printf ("last_rackview: %s \n", drag_info.last_trackview->name().c_str()); - if (regionview_y_movement) { + char* op_string; - /* motion between tracks */ + if (drag_info.copy) { + if (drag_info.x_constrained) { + op_string = _("fixed time region copy"); + } else { + op_string = _("region copy"); + } + } else { + if (drag_info.x_constrained) { + op_string = _("fixed time region drag"); + } else { + op_string = _("region drag"); + } + } - list new_selection; - - /* moved to a different audio track. */ + begin_reversible_command (op_string); - for (list::const_iterator i = selection->regions.by_layer().begin(); i != selection->regions.by_layer().end(); ) { - - RegionView* rv2 = (*i); - - /* the region that used to be in the old playlist is not - moved to the new one - we make a copy of it. as a result, - any existing editor for the region should no longer be - visible. - */ - - if (!drag_info.copy) { - rv2->hide_region_editor(); - } - new_selection.push_back (rv2); - i++; - } + if (regionview_y_movement) { - /* first, freeze the target tracks */ + /* moved to a different audio track. */ + + vector new_selection; - for (list::const_iterator i = new_selection.begin(); i != new_selection.end();i++ ) { + for (list::const_iterator i = selection->regions.by_layer().begin(); i != selection->regions.by_layer().end(); ) { + + RegionView* rv = (*i); - boost::shared_ptr from_playlist; - boost::shared_ptr to_playlist; - double ix1, ix2, iy1, iy2; - - (*i)->get_canvas_frame()->get_bounds (ix1, iy1, ix2, iy2); - (*i)->get_canvas_group()->i2w (ix1, iy1); + + rv->get_canvas_frame()->get_bounds (ix1, iy1, ix2, iy2); + rv->get_canvas_group()->i2w (ix1, iy1); TimeAxisView* tvp2 = trackview_by_y_position (iy1); - RouteTimeAxisView* atv2 = dynamic_cast(tvp2); + RouteTimeAxisView* rtv2 = dynamic_cast(tvp2); - (*i)->region()->set_opaque (true); - - from_playlist = (*i)->region()->playlist(); - to_playlist = atv2->playlist(); + boost::shared_ptr from_playlist = rv->region()->playlist(); + boost::shared_ptr to_playlist = rtv2->playlist(); - /* the from_playlist was frozen in the "first_move" case - of the motion handler. the insert can fail, - but that doesn't matter. it just means - we already have the playlist in the list. - */ - - motion_frozen_playlists.insert (from_playlist); + where = (nframes_t) (unit_to_frame (ix1) * speed); + boost::shared_ptr new_region (RegionFactory::create (rv->region())); - /* only freeze the to_playlist once */ + /* undo the previous hide_dependent_views so that xfades don't + disappear on copying regions + */ - insert_result = motion_frozen_playlists.insert(to_playlist); - if (insert_result.second) { - to_playlist->freeze(); - session->add_command(new MementoCommand(*to_playlist, &to_playlist->get_state(), 0)); - } + rv->get_time_axis_view().reveal_dependent_views (*rv); - } + if (!drag_info.copy) { + + /* the region that used to be in the old playlist is not + moved to the new one - we make a copy of it. as a result, + any existing editor for the region should no longer be + visible. + */ + + rv->hide_region_editor(); + rv->fake_set_opaque (false); - /* now do it again with the actual operations */ + session->add_command (new MementoCommand(*from_playlist, &from_playlist->get_state(), 0)); + from_playlist->remove_region ((rv->region())); + session->add_command (new MementoCommand(*from_playlist, 0, &from_playlist->get_state())); - for (list::const_iterator i = new_selection.begin(); i != new_selection.end();i++ ) { + } else { - boost::shared_ptr from_playlist; - boost::shared_ptr to_playlist; + /* the regionview we dragged around is a temporary copy, queue it for deletion */ - double ix1, ix2, iy1, iy2; - - (*i)->get_canvas_frame()->get_bounds (ix1, iy1, ix2, iy2); - (*i)->get_canvas_group()->i2w (ix1, iy1); - TimeAxisView* tvp2 = trackview_by_y_position (iy1); - RouteTimeAxisView* atv2 = dynamic_cast(tvp2); - - from_playlist = (*i)->region()->playlist(); - to_playlist = atv2->playlist(); + copies.push_back (rv); + } latest_regionview = 0; - - where = (nframes_t) (unit_to_frame (ix1) * speed); - boost::shared_ptr new_region (RegionFactory::create ((*i)->region())); - - from_playlist->remove_region (((*i)->region())); - sigc::connection c = atv2->view()->RegionViewAdded.connect (mem_fun(*this, &Editor::collect_new_region_view)); + sigc::connection c = rtv2->view()->RegionViewAdded.connect (mem_fun(*this, &Editor::collect_new_region_view)); + session->add_command (new MementoCommand(*to_playlist, &to_playlist->get_state(), 0)); to_playlist->add_region (new_region, where); + session->add_command (new MementoCommand(*to_playlist, 0, &to_playlist->get_state())); c.disconnect (); if (latest_regionview) { - selection->add (latest_regionview); + new_selection.push_back (latest_regionview); + } + + /* OK, this is where it gets tricky. If the playlist was being used by >1 tracks, and the region + was selected in all of them, then removing it from the playlist will have removed all + trace of it from the selection (i.e. there were N regions selected, we removed 1, + but since its the same playlist for N tracks, all N tracks updated themselves, removed the + corresponding regionview, and the selection is now empty). + + this could have invalidated any and all iterators into the region selection. + + the heuristic we use here is: if the region selection is empty, break out of the loop + here. if the region selection is not empty, then restart the loop because we know that + we must have removed at least the region(view) we've just been working on as well as any + that we processed on previous iterations. + + EXCEPT .... if we are doing a copy drag, then the selection hasn't been modified and + we can just iterate. + */ + + if (drag_info.copy) { + ++i; + } else { + if (selection->regions.empty()) { + break; + } else { + i = selection->regions.by_layer().begin(); + } } } + selection->set (new_selection); + } else { /* motion within a single track */ + + list regions = selection->regions.by_layer(); + + if (drag_info.copy) { + selection->clear_regions(); + } - for (list::const_iterator i = selection->regions.by_layer().begin(); i != selection->regions.by_layer().end(); ++i) { + for (list::iterator i = regions.begin(); i != regions.end(); ++i) { rv = (*i); - if (rv->region()->locked()) { + if (!rv->region()->can_move()) { continue; } - + if (regionview_x_movement) { double ownspeed = 1.0; - RouteTimeAxisView* atv = dynamic_cast (&(rv->get_time_axis_view())); + rtv = dynamic_cast (&(rv->get_time_axis_view())); - if (atv && atv->get_diskstream()) { - ownspeed = atv->get_diskstream()->speed(); + if (rtv && rtv->get_diskstream()) { + ownspeed = rtv->get_diskstream()->speed(); } /* base the new region position on the current position of the regionview.*/ @@ -3450,26 +3392,65 @@ Editor::region_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event where = rv->region()->position(); } - rv->get_time_axis_view().reveal_dependent_views (*rv); + boost::shared_ptr to_playlist = rv->region()->playlist(); - /* no need to add an undo here, we did that when we added this playlist to motion_frozen playlists */ - - rv->region()->set_position (where, (void *) this); - rv->region()->set_opaque (true); + assert (to_playlist); + + /* add the undo */ + + session->add_command (new MementoCommand(*to_playlist, &to_playlist->get_state(), 0)); + + if (drag_info.copy) { + + boost::shared_ptr newregion; + boost::shared_ptr ar; + + if ((ar = boost::dynamic_pointer_cast(rv->region())) != 0) { + newregion = RegionFactory::create (ar); + } else { + /* XXX MIDI HERE drobilla */ + continue; + } + + /* add it */ + + latest_regionview = 0; + sigc::connection c = rtv->view()->RegionViewAdded.connect (mem_fun(*this, &Editor::collect_new_region_view)); + to_playlist->add_region (newregion, (nframes_t) (where * rtv->get_diskstream()->speed())); + c.disconnect (); + + if (latest_regionview) { + rtv->reveal_dependent_views (*latest_regionview); + selection->add (latest_regionview); + } + + } else { + + /* just change the model */ + + rv->region()->set_position (where, (void*) this); + + } + + /* add the redo */ + + session->add_command (new MementoCommand(*to_playlist, 0, &to_playlist->get_state())); + + if (drag_info.copy) { + copies.push_back (rv); + } } } out: - for (set >::iterator p = motion_frozen_playlists.begin(); p != motion_frozen_playlists.end(); ++p) { - (*p)->thaw (); - session->add_command (new MementoCommand(*((*p).get()), 0, & (*p)->get_state())); - } - - motion_frozen_playlists.clear (); - + if (!nocommit) { commit_reversible_command (); } + + for (vector::iterator x = copies.begin(); x != copies.end(); ++x) { + delete *x; + } } void @@ -3481,10 +3462,10 @@ Editor::region_view_item_click (AudioRegionView& rv, GdkEventButton* event) if (Keyboard::modifier_state_contains (event->state, Keyboard::Control)) { TimeAxisView* tv = &rv.get_time_axis_view(); - RouteTimeAxisView* atv = dynamic_cast(tv); + RouteTimeAxisView* rtv = dynamic_cast(tv); double speed = 1.0; - if (atv && atv->is_track()) { - speed = atv->get_diskstream()->speed(); + if (rtv && rtv->is_track()) { + speed = rtv->get_diskstream()->speed(); } if (Keyboard::modifier_state_equals (event->state, Keyboard::ModifierMask (Keyboard::Control|Keyboard::Alt))) { @@ -3516,7 +3497,7 @@ Editor::show_verbose_time_cursor (nframes_t frame, double offset, double xpos, d return; } - switch (ARDOUR_UI::instance()->secondary_clock.mode ()) { + switch (Profile->get_small_screen() ? ARDOUR_UI::instance()->primary_clock.mode () : ARDOUR_UI::instance()->secondary_clock.mode ()) { case AudioClock::BBT: session->bbt_time (frame, bbt); snprintf (buf, sizeof (buf), "%02" PRIu32 "|%02" PRIu32 "|%02" PRIu32, bbt.bars, bbt.beats, bbt.ticks); @@ -3780,10 +3761,9 @@ Editor::drag_selection (ArdourCanvas::Item* item, GdkEvent* event) nframes_t length; nframes_t pending_position; - if ((int32_t) drag_info.current_pointer_frame > drag_info.pointer_frame_offset) { + if (drag_info.current_pointer_frame > drag_info.pointer_frame_offset) { pending_position = drag_info.current_pointer_frame - drag_info.pointer_frame_offset; - } - else { + } else { pending_position = 0; } @@ -3941,8 +3921,6 @@ Editor::start_trim (ArdourCanvas::Item* item, GdkEvent* event) nframes_t region_end = (nframes_t) (clicked_regionview->region()->last_frame() / speed); nframes_t region_length = (nframes_t) (clicked_regionview->region()->length() / speed); - motion_frozen_playlists.clear(); - //drag_info.item = clicked_regionview->get_name_highlight(); drag_info.item = item; drag_info.motion_callback = &Editor::trim_motion_callback; @@ -4031,7 +4009,7 @@ Editor::trim_motion_callback (ArdourCanvas::Item* item, GdkEvent* event) begin_reversible_command (trim_type); for (list::const_iterator i = selection->regions.by_layer().begin(); i != selection->regions.by_layer().end(); ++i) { - (*i)->region()->set_opaque(false); + (*i)->fake_set_opaque(false); (*i)->region()->freeze (); AudioRegionView* const arv = dynamic_cast(*i); @@ -4226,7 +4204,7 @@ Editor::trim_finished_callback (ArdourCanvas::Item* item, GdkEvent* event) i != selection->regions.by_layer().end(); ++i) { thaw_region_after_trim (**i); - (*i)->region()->set_opaque(true); + (*i)->fake_set_opaque (true); } } @@ -4518,8 +4496,7 @@ Editor::end_range_markerbar_op (ArdourCanvas::Item* item, GdkEvent* event) switch (mouse_mode) { case MouseObject: /* find the two markers on either side and then make the selection from it */ - cerr << "select between " << start << " .. " << end << endl; - select_all_within (start, end, 0.0f, FLT_MAX, Selection::Set); + select_all_within (start, end, 0.0f, FLT_MAX, track_views, Selection::Set); break; case MouseRange: @@ -4652,16 +4629,15 @@ Editor::drag_rubberband_select (ArdourCanvas::Item* item, GdkEvent* event) return; } -// if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) { -// snap_to (drag_info.current_pointer_frame); - -// if (drag_info.first_move) { -// snap_to (drag_info.grab_frame); -// } -// } - + if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) { + if (drag_info.first_move) { + snap_to (drag_info.grab_frame); + } + snap_to (drag_info.current_pointer_frame); + } /* base start and end on initial click position */ + if (drag_info.current_pointer_frame < drag_info.grab_frame) { start = drag_info.current_pointer_frame; end = drag_info.grab_frame; @@ -4673,8 +4649,7 @@ Editor::drag_rubberband_select (ArdourCanvas::Item* item, GdkEvent* event) if (drag_info.current_pointer_y < drag_info.grab_y) { y1 = drag_info.current_pointer_y; y2 = drag_info.grab_y; - } - else { + } else { y2 = drag_info.current_pointer_y; y1 = drag_info.grab_y; } @@ -4721,12 +4696,12 @@ Editor::end_rubberband_select (ArdourCanvas::Item* item, GdkEvent* event) Selection::Operation op = Keyboard::selection_type (event->button.state); bool commit; - begin_reversible_command (_("select regions")); + begin_reversible_command (_("rubberband selection")); if (drag_info.grab_frame < drag_info.last_pointer_frame) { - commit = select_all_within (drag_info.grab_frame, drag_info.last_pointer_frame, y1, y2, op); + commit = select_all_within (drag_info.grab_frame, drag_info.last_pointer_frame, y1, y2, track_views, op); } else { - commit = select_all_within (drag_info.last_pointer_frame, drag_info.grab_frame, y1, y2, op); + commit = select_all_within (drag_info.last_pointer_frame, drag_info.grab_frame, y1, y2, track_views, op); } if (commit) { @@ -4734,6 +4709,7 @@ Editor::end_rubberband_select (ArdourCanvas::Item* item, GdkEvent* event) } } else { + selection->clear_tracks(); selection->clear_regions(); selection->clear_points (); selection->clear_lines (); @@ -4760,7 +4736,7 @@ Editor::mouse_rename_region (ArdourCanvas::Item* item, GdkEvent* event) string str; prompter.get_result(str); if (str.length()) { - clicked_regionview->region()->set_name (str); + clicked_regionview->region()->set_name (str); } break; } @@ -4853,14 +4829,14 @@ Editor::mouse_brush_insert_region (RegionView* rv, nframes_t pos) return; } - RouteTimeAxisView* atv = dynamic_cast(&arv->get_time_axis_view()); + RouteTimeAxisView* rtv = dynamic_cast(&arv->get_time_axis_view()); - if (atv == 0 || !atv->is_track()) { + if (rtv == 0 || !rtv->is_track()) { return; } - boost::shared_ptr playlist = atv->playlist(); - double speed = atv->get_diskstream()->speed(); + boost::shared_ptr playlist = rtv->playlist(); + double speed = rtv->get_diskstream()->speed(); XMLNode &before = playlist->get_state(); playlist->add_region (boost::dynamic_pointer_cast (RegionFactory::create (arv->audio_region())), (nframes_t) (pos * speed));