- begin_reversible_command ( _("move marker") );
- XMLNode &before = session->locations()->get_state();
-
- Location * location = find_location_from_marker (marker, is_start);
-
- if (location) {
- if (location->is_mark()) {
- location->set_start (drag_info.copied_location->start());
- } else {
- location->set (drag_info.copied_location->start(), drag_info.copied_location->end());
- }
- }
-
- XMLNode &after = session->locations()->get_state();
- session->add_command(new MementoCommand<Locations>(*(session->locations()), &before, &after));
- commit_reversible_command ();
-
- marker_drag_line->hide();
- range_marker_drag_rect->hide();
-}
-
-void
-Editor::start_meter_marker_grab (ArdourCanvas::Item* item, GdkEvent* event)
-{
- Marker* marker;
- MeterMarker* meter_marker;
-
- if ((marker = reinterpret_cast<Marker *> (item->get_data ("marker"))) == 0) {
- fatal << _("programming error: meter marker canvas item has no marker object pointer!") << endmsg;
- /*NOTREACHED*/
- }
-
- meter_marker = dynamic_cast<MeterMarker*> (marker);
-
- MetricSection& section (meter_marker->meter());
-
- if (!section.movable()) {
- return;
- }
-
- drag_info.item = item;
- drag_info.data = marker;
- drag_info.motion_callback = &Editor::meter_marker_drag_motion_callback;
- drag_info.finished_callback = &Editor::meter_marker_drag_finished_callback;
-
- start_grab (event);
-
- drag_info.pointer_frame_offset = drag_info.grab_frame - meter_marker->meter().frame();
-
- show_verbose_time_cursor (drag_info.current_pointer_frame, 10);
-}
-
-void
-Editor::start_meter_marker_copy_grab (ArdourCanvas::Item* item, GdkEvent* event)
-{
- Marker* marker;
- MeterMarker* meter_marker;
-
- if ((marker = reinterpret_cast<Marker *> (item->get_data ("marker"))) == 0) {
- fatal << _("programming error: meter marker canvas item has no marker object pointer!") << endmsg;
- /*NOTREACHED*/
- }
-
- meter_marker = dynamic_cast<MeterMarker*> (marker);
-
- // create a dummy marker for visual representation of moving the copy.
- // The actual copying is not done before we reach the finish callback.
- char name[64];
- snprintf (name, sizeof(name), "%g/%g", meter_marker->meter().beats_per_bar(), meter_marker->meter().note_divisor ());
- MeterMarker* new_marker = new MeterMarker(*this, *meter_group, color_map[cMeterMarker], name,
- *new MeterSection(meter_marker->meter()));
-
- drag_info.item = &new_marker->the_item();
- drag_info.copy = true;
- drag_info.data = new_marker;
- drag_info.motion_callback = &Editor::meter_marker_drag_motion_callback;
- drag_info.finished_callback = &Editor::meter_marker_drag_finished_callback;
-
- start_grab (event);
-
- drag_info.pointer_frame_offset = drag_info.grab_frame - meter_marker->meter().frame();
-
- show_verbose_time_cursor (drag_info.current_pointer_frame, 10);
-}
-
-void
-Editor::meter_marker_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
-{
- MeterMarker* marker = (MeterMarker *) drag_info.data;
- nframes_t adjusted_frame;
-
- if (drag_info.current_pointer_frame > drag_info.pointer_frame_offset) {
- adjusted_frame = drag_info.current_pointer_frame - drag_info.pointer_frame_offset;
- }
- else {
- adjusted_frame = 0;
- }
-
- if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) {
- snap_to (adjusted_frame);
- }
-
- if (adjusted_frame == drag_info.last_pointer_frame) return;
-
- marker->set_position (adjusted_frame);
-
-
- drag_info.last_pointer_frame = adjusted_frame;
- drag_info.first_move = false;
-
- show_verbose_time_cursor (adjusted_frame, 10);
-}
-
-void
-Editor::meter_marker_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event)
-{
- if (drag_info.first_move) return;
-
- meter_marker_drag_motion_callback (drag_info.item, event);
-
- MeterMarker* marker = (MeterMarker *) drag_info.data;
- BBT_Time when;
-
- TempoMap& map (session->tempo_map());
- map.bbt_time (drag_info.last_pointer_frame, when);
-
- if (drag_info.copy == true) {
- begin_reversible_command (_("copy meter mark"));
- XMLNode &before = map.get_state();
- map.add_meter (marker->meter(), when);
- XMLNode &after = map.get_state();
- session->add_command(new MementoCommand<TempoMap>(map, &before, &after));
- commit_reversible_command ();
-
- // delete the dummy marker we used for visual representation of copying.
- // a new visual marker will show up automatically.
- delete marker;
- } else {
- begin_reversible_command (_("move meter mark"));
- XMLNode &before = map.get_state();
- map.move_meter (marker->meter(), when);
- XMLNode &after = map.get_state();
- session->add_command(new MementoCommand<TempoMap>(map, &before, &after));
- commit_reversible_command ();
- }
-}
-
-void
-Editor::start_tempo_marker_grab (ArdourCanvas::Item* item, GdkEvent* event)
-{
- Marker* marker;
- TempoMarker* tempo_marker;
-
- if ((marker = reinterpret_cast<Marker *> (item->get_data ("marker"))) == 0) {
- fatal << _("programming error: tempo marker canvas item has no marker object pointer!") << endmsg;
- /*NOTREACHED*/
- }
-
- if ((tempo_marker = dynamic_cast<TempoMarker *> (marker)) == 0) {
- fatal << _("programming error: marker for tempo is not a tempo marker!") << endmsg;
- /*NOTREACHED*/
- }
-
- MetricSection& section (tempo_marker->tempo());
-
- if (!section.movable()) {
- return;
- }
-
- drag_info.item = item;
- drag_info.data = marker;
- drag_info.motion_callback = &Editor::tempo_marker_drag_motion_callback;
- drag_info.finished_callback = &Editor::tempo_marker_drag_finished_callback;
-
- start_grab (event);
-
- drag_info.pointer_frame_offset = drag_info.grab_frame - tempo_marker->tempo().frame();
- show_verbose_time_cursor (drag_info.current_pointer_frame, 10);
-}
-
-void
-Editor::start_tempo_marker_copy_grab (ArdourCanvas::Item* item, GdkEvent* event)
-{
- Marker* marker;
- TempoMarker* tempo_marker;
-
- if ((marker = reinterpret_cast<Marker *> (item->get_data ("marker"))) == 0) {
- fatal << _("programming error: tempo marker canvas item has no marker object pointer!") << endmsg;
- /*NOTREACHED*/
- }
-
- if ((tempo_marker = dynamic_cast<TempoMarker *> (marker)) == 0) {
- fatal << _("programming error: marker for tempo is not a tempo marker!") << endmsg;
- /*NOTREACHED*/
- }
-
- // create a dummy marker for visual representation of moving the copy.
- // The actual copying is not done before we reach the finish callback.
- char name[64];
- snprintf (name, sizeof (name), "%.2f", tempo_marker->tempo().beats_per_minute());
- TempoMarker* new_marker = new TempoMarker(*this, *tempo_group, color_map[cTempoMarker], name,
- *new TempoSection(tempo_marker->tempo()));
-
- drag_info.item = &new_marker->the_item();
- drag_info.copy = true;
- drag_info.data = new_marker;
- drag_info.motion_callback = &Editor::tempo_marker_drag_motion_callback;
- drag_info.finished_callback = &Editor::tempo_marker_drag_finished_callback;
-
- start_grab (event);
-
- drag_info.pointer_frame_offset = drag_info.grab_frame - tempo_marker->tempo().frame();
-
- show_verbose_time_cursor (drag_info.current_pointer_frame, 10);
-}
-
-void
-Editor::tempo_marker_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
-{
- TempoMarker* marker = (TempoMarker *) drag_info.data;
- nframes_t adjusted_frame;
-
- if (drag_info.current_pointer_frame > drag_info.pointer_frame_offset) {
- adjusted_frame = drag_info.current_pointer_frame - drag_info.pointer_frame_offset;
- }
- else {
- adjusted_frame = 0;
- }
-
- if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) {
- snap_to (adjusted_frame);
- }
-
- if (adjusted_frame == drag_info.last_pointer_frame) return;
-
- /* OK, we've moved far enough to make it worth actually move the thing. */
-
- marker->set_position (adjusted_frame);
-
- show_verbose_time_cursor (adjusted_frame, 10);
-
- drag_info.last_pointer_frame = adjusted_frame;
- drag_info.first_move = false;
-}
-
-void
-Editor::tempo_marker_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event)
-{
- if (drag_info.first_move) return;
-
- tempo_marker_drag_motion_callback (drag_info.item, event);
-
- TempoMarker* marker = (TempoMarker *) drag_info.data;
- BBT_Time when;
-
- TempoMap& map (session->tempo_map());
- map.bbt_time (drag_info.last_pointer_frame, when);
-
- if (drag_info.copy == true) {
- begin_reversible_command (_("copy tempo mark"));
- XMLNode &before = map.get_state();
- map.add_tempo (marker->tempo(), when);
- XMLNode &after = map.get_state();
- session->add_command (new MementoCommand<TempoMap>(map, &before, &after));
- commit_reversible_command ();
-
- // delete the dummy marker we used for visual representation of copying.
- // a new visual marker will show up automatically.
- delete marker;
- } else {
- begin_reversible_command (_("move tempo mark"));
- XMLNode &before = map.get_state();
- map.move_tempo (marker->tempo(), when);
- XMLNode &after = map.get_state();
- session->add_command (new MementoCommand<TempoMap>(map, &before, &after));
- commit_reversible_command ();
- }
-}
-
-void
-Editor::remove_gain_control_point (ArdourCanvas::Item*item, GdkEvent* event)
-{
- ControlPoint* control_point;
-
- if ((control_point = reinterpret_cast<ControlPoint *> (item->get_data ("control_point"))) == 0) {
- fatal << _("programming error: control point canvas item has no control point object pointer!") << endmsg;
- /*NOTREACHED*/
- }
-
- // We shouldn't remove the first or last gain point
- if (control_point->line.is_last_point(*control_point) ||
- control_point->line.is_first_point(*control_point)) {
- return;
- }
-
- control_point->line.remove_point (*control_point);
-}
-
-void
-Editor::remove_control_point (ArdourCanvas::Item*item, GdkEvent* event)
-{
- ControlPoint* control_point;
-
- if ((control_point = reinterpret_cast<ControlPoint *> (item->get_data ("control_point"))) == 0) {
- fatal << _("programming error: control point canvas item has no control point object pointer!") << endmsg;
- /*NOTREACHED*/
- }
-
- control_point->line.remove_point (*control_point);
-}
-
-void
-Editor::start_control_point_grab (ArdourCanvas::Item* item, GdkEvent* event)
-{
- ControlPoint* control_point;
-
- if ((control_point = reinterpret_cast<ControlPoint *> (item->get_data ("control_point"))) == 0) {
- fatal << _("programming error: control point canvas item has no control point object pointer!") << endmsg;
- /*NOTREACHED*/
- }
-
- drag_info.item = item;
- drag_info.data = control_point;
- drag_info.motion_callback = &Editor::control_point_drag_motion_callback;
- drag_info.finished_callback = &Editor::control_point_drag_finished_callback;
-
- start_grab (event, fader_cursor);
-
- control_point->line.start_drag (control_point, drag_info.grab_frame, 0);
-
- 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);
-
- show_verbose_canvas_cursor ();
-}
-
-void
-Editor::control_point_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
-{
- ControlPoint* cp = reinterpret_cast<ControlPoint *> (drag_info.data);
-
- double cx = drag_info.current_pointer_x;
- double cy = drag_info.current_pointer_y;
-
- drag_info.cumulative_x_drag = cx - drag_info.grab_x ;
- drag_info.cumulative_y_drag = cy - drag_info.grab_y ;
-
- if (drag_info.x_constrained) {
- cx = drag_info.grab_x;
- }
- if (drag_info.y_constrained) {
- cy = drag_info.grab_y;
- }
-
- cp->line.parent_group().w2i (cx, cy);
-
- cx = max (0.0, cx);
- cy = max (0.0, cy);
- cy = min ((double) (cp->line.y_position() + cp->line.height()), cy);
-
- //translate cx to frames
- nframes_t cx_frames = unit_to_frame (cx);
-
- if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier()) && !drag_info.x_constrained) {
- snap_to (cx_frames);
- }
-
- 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)) {
- push = true;
- } else {
- push = false;
- }
-
- cp->line.point_drag (*cp, cx_frames , fraction, push);
-
- set_verbose_canvas_cursor_text (cp->line.get_verbose_cursor_string (fraction));
-
- drag_info.first_move = false;
-}
-
-void
-Editor::control_point_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event)
-{
- ControlPoint* cp = reinterpret_cast<ControlPoint *> (drag_info.data);
-
- if (drag_info.first_move) {
-
- /* just a click */
-
- if ((event->type == GDK_BUTTON_RELEASE) && (event->button.button == 1) && Keyboard::modifier_state_equals (event->button.state, Keyboard::Shift)) {
- reset_point_selection ();
- }
-
- } else {
- control_point_drag_motion_callback (item, event);
- }
- cp->line.end_drag (cp);
-}
-
-void
-Editor::start_line_grab_from_regionview (ArdourCanvas::Item* item, GdkEvent* event)
-{
- switch (mouse_mode) {
- case MouseGain:
- assert(dynamic_cast<AudioRegionView*>(clicked_regionview));
- start_line_grab (dynamic_cast<AudioRegionView*>(clicked_regionview)->get_gain_line(), event);
- break;
- default:
- break;
- }
-}
-
-void
-Editor::start_line_grab_from_line (ArdourCanvas::Item* item, GdkEvent* event)
-{
- AutomationLine* al;
-
- if ((al = reinterpret_cast<AutomationLine*> (item->get_data ("line"))) == 0) {
- fatal << _("programming error: line canvas item has no line pointer!") << endmsg;
- /*NOTREACHED*/
- }
-
- start_line_grab (al, event);
-}
-
-void
-Editor::start_line_grab (AutomationLine* line, GdkEvent* event)
-{
- double cx;
- double cy;
- nframes_t frame_within_region;
-
- /* need to get x coordinate in terms of parent (TimeAxisItemView)
- origin.
- */
-
- cx = event->button.x;
- cy = event->button.y;
- line->parent_group().w2i (cx, cy);
- frame_within_region = (nframes_t) floor (cx * frames_per_unit);
-
- if (!line->control_points_adjacent (frame_within_region, current_line_drag_info.before,
- current_line_drag_info.after)) {
- /* no adjacent points */
- return;
- }
-
- drag_info.item = &line->grab_item();
- drag_info.data = line;
- drag_info.motion_callback = &Editor::line_drag_motion_callback;
- drag_info.finished_callback = &Editor::line_drag_finished_callback;
-
- start_grab (event, fader_cursor);
-
- double const fraction = 1.0 - ((cy - line->y_position()) / line->height());
-
- line->start_drag (0, drag_info.grab_frame, fraction);
-
- set_verbose_canvas_cursor (line->get_verbose_cursor_string (fraction),
- drag_info.current_pointer_x + 20, drag_info.current_pointer_y + 20);
- show_verbose_canvas_cursor ();
-}
-
-void
-Editor::line_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
-{
- AutomationLine* line = reinterpret_cast<AutomationLine *> (drag_info.data);
- double cx = drag_info.current_pointer_x;
- double cy = drag_info.current_pointer_y;
-
- line->parent_group().w2i (cx, cy);
-
- double const fraction = 1.0 - ((cy - line->y_position()) / line->height());
-
- bool push;
-
- if (Keyboard::modifier_state_contains (event->button.state, Keyboard::Control)) {
- push = false;
- } else {
- push = true;
- }
-
- line->line_drag (current_line_drag_info.before, current_line_drag_info.after, fraction, push);
-
- set_verbose_canvas_cursor_text (line->get_verbose_cursor_string (fraction));
-}
-
-void
-Editor::line_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event)
-{
- AutomationLine* line = reinterpret_cast<AutomationLine *> (drag_info.data);
- line_drag_motion_callback (item, event);
- line->end_drag (0);
-}
-
-void
-Editor::start_region_grab (ArdourCanvas::Item* item, GdkEvent* event)
-{
- if (selection->regions.empty() || clicked_regionview == 0) {
- return;
- }
-
- drag_info.copy = false;
- drag_info.item = item;
- drag_info.data = clicked_regionview;
- drag_info.motion_callback = &Editor::region_drag_motion_callback;
- drag_info.finished_callback = &Editor::region_drag_finished_callback;
-
- start_grab (event);
-
- double speed = 1.0;
- TimeAxisView* tvp = clicked_axisview;
- RouteTimeAxisView* tv = dynamic_cast<RouteTimeAxisView*>(tvp);
-
- if (tv && tv->is_track()) {
- speed = tv->get_diskstream()->speed();
- }
-
- drag_info.last_frame_position = (nframes_t) (clicked_regionview->region()->position() / speed);
- drag_info.pointer_frame_offset = drag_info.grab_frame - drag_info.last_frame_position;
- drag_info.last_trackview = &clicked_regionview->get_time_axis_view();
- // we want a move threshold
- drag_info.want_move_threshold = true;
-
- show_verbose_time_cursor (drag_info.last_frame_position, 10);
-
- begin_reversible_command (_("move region(s)"));
-}
-
-void
-Editor::start_region_copy_grab (ArdourCanvas::Item* item, GdkEvent* event)
-{
- if (selection->regions.empty() || clicked_regionview == 0) {
- return;
- }
-
- drag_info.copy = true;
- drag_info.item = item;
- drag_info.data = clicked_regionview;
-
- start_grab(event);
-
- TimeAxisView* tv = &clicked_regionview->get_time_axis_view();
- RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(tv);
- double speed = 1.0;
-
- if (rtv && rtv->is_track()) {
- speed = rtv->get_diskstream()->speed();
- }
-
- drag_info.last_trackview = &clicked_regionview->get_time_axis_view();
- drag_info.last_frame_position = (nframes_t) (clicked_regionview->region()->position() / speed);
- drag_info.pointer_frame_offset = drag_info.grab_frame - drag_info.last_frame_position;
- // we want a move threshold
- drag_info.want_move_threshold = true;
- drag_info.motion_callback = &Editor::region_drag_motion_callback;
- drag_info.finished_callback = &Editor::region_drag_finished_callback;
- show_verbose_time_cursor (drag_info.last_frame_position, 10);
-}
-
-void
-Editor::start_region_brush_grab (ArdourCanvas::Item* item, GdkEvent* event)
-{
- if (selection->regions.empty() || clicked_regionview == 0) {
- return;
- }
-
- drag_info.copy = false;
- drag_info.item = item;
- drag_info.data = clicked_regionview;
- drag_info.motion_callback = &Editor::region_drag_motion_callback;
- drag_info.finished_callback = &Editor::region_drag_finished_callback;
-
- start_grab (event);
-
- double speed = 1.0;
- TimeAxisView* tvp = clicked_axisview;
- RouteTimeAxisView* tv = dynamic_cast<RouteTimeAxisView*>(tvp);
-
- if (tv && tv->is_track()) {
- speed = tv->get_diskstream()->speed();
- }
-
- drag_info.last_frame_position = (nframes_t) (clicked_regionview->region()->position() / speed);
- drag_info.pointer_frame_offset = drag_info.grab_frame - drag_info.last_frame_position;
- drag_info.last_trackview = &clicked_regionview->get_time_axis_view();
- // we want a move threshold
- drag_info.want_move_threshold = true;
- drag_info.brushing = true;
-
- begin_reversible_command (_("Drag region brush"));
-}
-
-void
-Editor::region_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
-{
- double x_delta;
- double y_delta = 0;
- RegionView* rv = reinterpret_cast<RegionView*> (drag_info.data);
- nframes_t pending_region_position = 0;
- int32_t pointer_y_span = 0, canvas_pointer_y_span = 0, original_pointer_order;
- int32_t visible_y_high = 0, visible_y_low = 512; //high meaning higher numbered.. not the height on the screen
- bool clamp_y_axis = false;
- vector<int32_t> height_list(512) ;
- vector<int32_t>::iterator j;
-
- if (drag_info.copy && drag_info.move_threshold_passed && drag_info.want_move_threshold) {
-
- drag_info.want_move_threshold = false; // don't copy again
-
- /* duplicate the region(s) */
-
- vector<RegionView*> new_regionviews;
-
- for (list<RegionView*>::const_iterator i = selection->regions.by_layer().begin(); i != selection->regions.by_layer().end(); ++i) {
- RegionView* rv;
- RegionView* nrv;
-
- rv = (*i);
-
- AudioRegionView* arv = dynamic_cast<AudioRegionView*>(rv);
- MidiRegionView* mrv = dynamic_cast<MidiRegionView*>(rv);
-
- if (arv) {
- nrv = new AudioRegionView (*arv);
- } else if (mrv) {
- nrv = new MidiRegionView (*mrv);
- } else {
- continue;