#include <pbd/error.h>
#include <gtkmm2ext/utils.h>
+#include <gtkmm2ext/tearoff.h>
#include <pbd/memento_command.h>
#include <pbd/basename.h>
#include "keyboard.h"
#include "editing.h"
#include "rgb_macros.h"
+#include "control_point_dialog.h"
#include <ardour/types.h>
#include <ardour/profile.h>
Gdk::ModifierType mask;
Glib::RefPtr<Gdk::Window> canvas_window = const_cast<Editor*>(this)->track_canvas->get_window();
Glib::RefPtr<const Gdk::Window> pointer_window;
+
+ if (!canvas_window) {
+ return false;
+ }
pointer_window = canvas_window->get_pointer (x, y, mask);
if (pointer_window == track_canvas->get_bin_window()) {
-
- track_canvas->window_to_world (x, y, wx, wy);
+ wx = x;
+ wy = y;
in_track_canvas = true;
} else {
in_track_canvas = false;
-
- if (pointer_window == time_canvas->get_bin_window()) {
- time_canvas->window_to_world (x, y, wx, wy);
- } else {
return false;
- }
}
- wx += horizontal_adjustment.get_value();
- wy += vertical_adjustment.get_value();
-
GdkEvent event;
event.type = GDK_BUTTON_RELEASE;
event.button.x = wx;
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
- track_canvas->w2c(event->button.x, event->button.y, *pcx, *pcy);
+
+ *pcx = event->button.x;
+ *pcy = event->button.y;
+ _trackview_group->w2i(*pcx, *pcy);
break;
case GDK_MOTION_NOTIFY:
- track_canvas->w2c(event->motion.x, event->motion.y, *pcx, *pcy);
+
+ *pcx = event->motion.x;
+ *pcy = event->motion.y;
+ _trackview_group->w2i(*pcx, *pcy);
break;
case GDK_ENTER_NOTIFY:
case GDK_LEAVE_NOTIFY:
return grabber_edit_point_cursor;
break;
default:
- return grabber_cursor;
break;
}
+ return grabber_cursor;
}
void
break;
}
- if (mouse_mode == MouseNote)
- midi_toolbar_frame.show();
- else
- midi_toolbar_frame.hide();
-
+ if (midi_tools_tearoff) {
+ if (mouse_mode == MouseNote) {
+ midi_tools_tearoff->show();
+ } else {
+ midi_tools_tearoff->hide();
+ }
+ }
+
ignore_mouse_mode_toggle = false;
set_canvas_cursor ();
{
switch (current_mouse_mode()) {
case MouseObject:
- if (next) set_mouse_mode (MouseRange);
- else set_mouse_mode (MouseTimeFX);
+ if (next) {
+ if (Profile->get_sae()) {
+ set_mouse_mode (MouseZoom);
+ } else {
+ set_mouse_mode (MouseRange);
+ }
+ } else {
+ set_mouse_mode (MouseTimeFX);
+ }
break;
case MouseRange:
break;
case MouseZoom:
- if (next) set_mouse_mode (MouseGain);
- else set_mouse_mode (MouseRange);
+ if (next) {
+ if (Profile->get_sae()) {
+ set_mouse_mode (MouseTimeFX);
+ } else {
+ set_mouse_mode (MouseGain);
+ }
+ } else {
+ if (Profile->get_sae()) {
+ set_mouse_mode (MouseObject);
+ } else {
+ set_mouse_mode (MouseRange);
+ }
+ }
break;
case MouseGain:
break;
case MouseTimeFX:
- if (next) set_mouse_mode (MouseAudition);
- else set_mouse_mode (MouseGain);
+ if (next) {
+ set_mouse_mode (MouseAudition);
+ } else {
+ if (Profile->get_sae()) {
+ set_mouse_mode (MouseZoom);
+ } else {
+ set_mouse_mode (MouseGain);
+ }
+ }
break;
case MouseAudition:
void
Editor::button_selection (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type)
{
- /* in object/audition/timefx mode, any button press sets
- the selection if the object can be selected. this is a
- bit of hack, because we want to avoid this if the
- mouse operation is a region alignment.
+ /* in object/audition/timefx/gain-automation mode,
+ any button press sets the selection if the object
+ can be selected. this is a bit of hack, because
+ we want to avoid this if the mouse operation is a
+ region alignment.
note: not dbl-click or triple-click
*/
if (((mouse_mode != MouseObject) &&
(mouse_mode != MouseAudition || item_type != RegionItem) &&
(mouse_mode != MouseTimeFX || item_type != RegionItem) &&
+ (mouse_mode != MouseGain) &&
(mouse_mode != MouseRange)) ||
- (event->type != GDK_BUTTON_PRESS && event->type != GDK_BUTTON_RELEASE || event->button.button > 3)) {
+ ((event->type != GDK_BUTTON_PRESS && event->type != GDK_BUTTON_RELEASE) || event->button.button > 3)) {
return;
}
}
}
}
-
+
Selection::Operation op = Keyboard::selection_type (event->button.state);
bool press = (event->type == GDK_BUTTON_PRESS);
bool
Editor::button_press_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type)
{
+ Glib::RefPtr<Gdk::Window> canvas_window = const_cast<Editor*>(this)->track_canvas->get_window();
+
+ if (canvas_window) {
+ Glib::RefPtr<const Gdk::Window> pointer_window;
+ int x, y;
+ double wx, wy;
+ Gdk::ModifierType mask;
+
+ pointer_window = canvas_window->get_pointer (x, y, mask);
+
+ if (pointer_window == track_canvas->get_bin_window()) {
+ track_canvas->window_to_world (x, y, wx, wy);
+ allow_vertical_scroll = true;
+ } else {
+ allow_vertical_scroll = false;
+ }
+ }
+
track_canvas->grab_focus();
if (session && session->actively_recording()) {
}
button_selection (item, event, item_type);
-
+
if (drag_info.item == 0 &&
(Keyboard::is_delete_event (&event->button) ||
Keyboard::is_context_menu_event (&event->button) ||
}
return true;
+ case MarkerBarItem:
case TempoBarItem:
- return true;
-
case MeterBarItem:
+ if (!Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) {
+ start_cursor_grab_no_stop(&playhead_cursor->canvas_item, event);
+ }
return true;
+ break;
+
case RangeMarkerBarItem:
- start_range_markerbar_op (item, event, CreateRangeMarker);
+ if (!Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) {
+ start_cursor_grab_no_stop(&playhead_cursor->canvas_item, event);
+ } else {
+ start_range_markerbar_op (item, event, CreateRangeMarker);
+ }
return true;
break;
case CdMarkerBarItem:
- start_range_markerbar_op (item, event, CreateCDMarker);
+ if (!Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) {
+ start_cursor_grab_no_stop(&playhead_cursor->canvas_item, event);
+ } else {
+ start_range_markerbar_op (item, event, CreateCDMarker);
+ }
return true;
break;
case TransportMarkerBarItem:
- start_range_markerbar_op (item, event, CreateTransportMarker);
+ if (!Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) {
+ start_cursor_grab_no_stop(&playhead_cursor->canvas_item, event);
+ } else {
+ start_range_markerbar_op (item, event, CreateTransportMarker);
+ }
return true;
break;
-
+
default:
break;
}
case RegionViewName:
/* rename happens on edit clicks */
- start_trim (clicked_regionview->get_name_highlight(), event);
- return true;
+ start_trim (clicked_regionview->get_name_highlight(), event);
+ return true;
break;
case ControlPointItem:
case MouseGain:
switch (item_type) {
case RegionItem:
- // start_line_grab_from_regionview (item, event);
+ /* start a grab so that if we finish after moving
+ we can tell what happened.
+ */
+ drag_info.item = item;
+ drag_info.motion_callback = &Editor::region_gain_motion_callback;
+ drag_info.finished_callback = 0;
+ start_grab (event, current_canvas_cursor);
break;
case GainLineItem:
bool
Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type)
{
- nframes_t where = event_frame (event, 0, 0);
+ nframes64_t where = event_frame (event, 0, 0);
AutomationTimeAxisView* atv = 0;
-
+
/* no action if we're recording */
if (session && session->actively_recording()) {
button_selection (item, event, item_type);
/* edit events get handled here */
-
+
if (drag_info.item == 0 && Keyboard::is_edit_event (&event->button)) {
switch (item_type) {
case RegionItem:
}
break;
+ case ControlPointItem:
+ edit_control_point (item);
+ break;
+
default:
break;
}
return true;
case MarkerBarItem:
- if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) {
- snap_to (where, 0, true);
+ if (!_dragging_playhead) {
+ if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) {
+ snap_to (where, 0, true);
+ }
+ mouse_add_new_marker (where);
}
- mouse_add_new_marker (where);
return true;
case CdMarkerBarItem:
- // if we get here then a dragged range wasn't done
- if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) {
- snap_to (where, 0, true);
+ if (!_dragging_playhead) {
+ // if we get here then a dragged range wasn't done
+ if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) {
+ snap_to (where, 0, true);
+ }
+ mouse_add_new_marker (where, true);
}
- mouse_add_new_marker (where, true);
return true;
case TempoBarItem:
- if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) {
- snap_to (where);
+ if (!_dragging_playhead) {
+ if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) {
+ snap_to (where);
+ }
+ mouse_add_new_tempo_event (where);
}
- mouse_add_new_tempo_event (where);
return true;
case MeterBarItem:
- mouse_add_new_meter_event (pixel_to_frame (event->button.x));
+ if (!_dragging_playhead) {
+ mouse_add_new_meter_event (pixel_to_frame (event->button.x));
+ }
return true;
break;
default:
break;
}
-
+
switch (mouse_mode) {
case MouseObject:
switch (item_type) {
switch (item_type) {
case RegionItem:
- dynamic_cast<AudioRegionView*>(clicked_regionview)->add_gain_point_event (item, event);
+ /* check that we didn't drag before releasing, since
+ its really annoying to create new control
+ points when doing this.
+ */
+ if (drag_info.first_move) {
+ dynamic_cast<AudioRegionView*>(clicked_regionview)->add_gain_point_event (item, event);
+ }
return true;
break;
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;
+ at_x += 10.0;
+ at_y += 10.0;
fraction = 1.0 - (cp->get_y() / cp->line().height());
case MeterBarItem:
case TempoBarItem:
if (is_drawable()) {
- time_canvas->get_window()->set_cursor (*timebar_cursor);
+ track_canvas->get_window()->set_cursor (*timebar_cursor);
}
break;
case MeterMarkerItem:
case TempoMarkerItem:
if (is_drawable()) {
- time_canvas->get_window()->set_cursor (*timebar_cursor);
+ track_canvas->get_window()->set_cursor (*timebar_cursor);
}
break;
case FadeInHandleItem:
case TempoBarItem:
case MarkerBarItem:
if (is_drawable()) {
- time_canvas->get_window()->set_cursor (*timebar_cursor);
+ track_canvas->get_window()->set_cursor (*current_canvas_cursor);
}
break;
case TempoMarkerItem:
if (is_drawable()) {
- time_canvas->get_window()->set_cursor (*timebar_cursor);
+ track_canvas->get_window()->set_cursor (*timebar_cursor);
}
break;
return false;
}
+void
+Editor::scrub ()
+{
+ double delta;
+
+ if (scrubbing_direction == 0) {
+ /* first move */
+ session->request_locate (drag_info.current_pointer_frame, false);
+ session->request_transport_speed (0.1);
+ scrubbing_direction = 1;
+
+ } else {
+
+ if (last_scrub_x > drag_info.current_pointer_x) {
+
+ /* pointer moved to the left */
+
+ if (scrubbing_direction > 0) {
+
+ /* we reversed direction to go backwards */
+
+ scrub_reversals++;
+ scrub_reverse_distance += (int) (last_scrub_x - drag_info.current_pointer_x);
+
+ } else {
+
+ /* still moving to the left (backwards) */
+
+ scrub_reversals = 0;
+ scrub_reverse_distance = 0;
+
+ delta = 0.01 * (last_scrub_x - drag_info.current_pointer_x);
+ session->request_transport_speed (session->transport_speed() - delta);
+ }
+
+ } else {
+ /* pointer moved to the right */
+
+ if (scrubbing_direction < 0) {
+ /* we reversed direction to go forward */
+
+ scrub_reversals++;
+ scrub_reverse_distance += (int) (drag_info.current_pointer_x - last_scrub_x);
+
+ } else {
+ /* still moving to the right */
+
+ scrub_reversals = 0;
+ scrub_reverse_distance = 0;
+
+ delta = 0.01 * (drag_info.current_pointer_x - last_scrub_x);
+ session->request_transport_speed (session->transport_speed() + delta);
+ }
+ }
+
+ /* if there have been more than 2 opposite motion moves detected, or one that moves
+ back more than 10 pixels, reverse direction
+ */
+
+ if (scrub_reversals >= 2 || scrub_reverse_distance > 10) {
+
+ if (scrubbing_direction > 0) {
+ /* was forwards, go backwards */
+ session->request_transport_speed (-0.1);
+ scrubbing_direction = -1;
+ } else {
+ /* was backwards, go forwards */
+ session->request_transport_speed (0.1);
+ scrubbing_direction = 1;
+ }
+
+ scrub_reverse_distance = 0;
+ scrub_reversals = 0;
+ }
+ }
+
+ last_scrub_x = drag_info.current_pointer_x;
+}
+
bool
Editor::motion_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type, bool from_autoscroll)
{
where DISPLAY = :0.0, and given the cost of what the motion
event might do, its a good tradeoff.
*/
-
+
track_canvas->get_pointer (x, y);
- }
-
+ }
+
if (current_stepping_trackview) {
/* don't keep the persistent stepped trackview if the mouse moves */
current_stepping_trackview = 0;
drag_info.current_pointer_frame = event_frame (event, &drag_info.current_pointer_x,
&drag_info.current_pointer_y);
+
switch (mouse_mode) {
case MouseAudition:
if (_scrubbing) {
-
- double delta;
-
- if (scrubbing_direction == 0) {
- /* first move */
- session->request_locate (drag_info.current_pointer_frame, false);
- session->request_transport_speed (0.1);
- scrubbing_direction = 1;
-
- } else {
-
- if (last_scrub_x > drag_info.current_pointer_x) {
-
- /* pointer moved to the left */
-
- if (scrubbing_direction > 0) {
-
- /* we reversed direction to go backwards */
-
- scrub_reversals++;
- scrub_reverse_distance += (int) (last_scrub_x - drag_info.current_pointer_x);
-
- } else {
-
- /* still moving to the left (backwards) */
-
- scrub_reversals = 0;
- scrub_reverse_distance = 0;
-
- delta = 0.01 * (last_scrub_x - drag_info.current_pointer_x);
- session->request_transport_speed (session->transport_speed() - delta);
- }
-
- } else {
- /* pointer moved to the right */
-
- if (scrubbing_direction < 0) {
- /* we reversed direction to go forward */
-
- scrub_reversals++;
- scrub_reverse_distance += (int) (drag_info.current_pointer_x - last_scrub_x);
-
- } else {
- /* still moving to the right */
-
- scrub_reversals = 0;
- scrub_reverse_distance = 0;
-
- delta = 0.01 * (drag_info.current_pointer_x - last_scrub_x);
- session->request_transport_speed (session->transport_speed() + delta);
- }
- }
-
- /* if there have been more than 2 opposite motion moves detected, or one that moves
- back more than 10 pixels, reverse direction
- */
-
- if (scrub_reversals >= 2 || scrub_reverse_distance > 10) {
-
- if (scrubbing_direction > 0) {
- /* was forwards, go backwards */
- session->request_transport_speed (-0.1);
- scrubbing_direction = -1;
- } else {
- /* was backwards, go forwards */
- session->request_transport_speed (0.1);
- scrubbing_direction = 1;
- }
-
- scrub_reverse_distance = 0;
- scrub_reversals = 0;
- }
- }
-
- last_scrub_x = drag_info.current_pointer_x;
+ scrub ();
}
+ break;
default:
break;
case PlayheadCursorItem:
case MarkerItem:
case ControlPointItem:
+ case MarkerBarItem:
+ case TempoBarItem:
+ case MeterBarItem:
+ case RangeMarkerBarItem:
+ case TransportMarkerBarItem:
+ case CdMarkerBarItem:
case TempoMarkerItem:
case MeterMarkerItem:
case RegionViewNameHighlight:
if (drag_info.item && (event->motion.state & Gdk::BUTTON1_MASK ||
(event->motion.state & Gdk::BUTTON2_MASK))) {
if (!from_autoscroll) {
- maybe_autoscroll (event);
+ maybe_autoscroll_horizontally (&event->motion);
+ }
+ if (drag_info.motion_callback) {
+ (this->*(drag_info.motion_callback)) (item, event);
}
- (this->*(drag_info.motion_callback)) (item, event);
goto handled;
}
goto not_handled;
-
+ break;
default:
break;
}
switch (mouse_mode) {
+ case MouseGain:
+ if (item_type == RegionItem) {
+ if (drag_info.item && drag_info.motion_callback) {
+ (this->*(drag_info.motion_callback)) (item, event);
+ }
+ goto handled;
+ }
+ break;
+
case MouseObject:
case MouseRange:
case MouseZoom:
if (drag_info.item && (event->motion.state & GDK_BUTTON1_MASK ||
(event->motion.state & GDK_BUTTON2_MASK))) {
if (!from_autoscroll) {
- maybe_autoscroll (event);
+ maybe_autoscroll (&event->motion);
+ }
+ if (drag_info.motion_callback) {
+ (this->*(drag_info.motion_callback)) (item, event);
}
- (this->*(drag_info.motion_callback)) (item, event);
goto handled;
}
goto not_handled;
return false;
}
+void
+Editor::break_drag ()
+{
+ stop_canvas_autoscroll ();
+ hide_verbose_canvas_cursor ();
+
+ if (drag_info.item) {
+ drag_info.item->ungrab (0);
+
+ /* put it back where it came from */
+
+ double cxw, cyw;
+ cxw = 0;
+ cyw = 0;
+ drag_info.item->i2w (cxw, cyw);
+ drag_info.item->move (drag_info.original_x - cxw, drag_info.original_y - cyw);
+ }
+
+ finalize_drag ();
+}
+
+void
+Editor::finalize_drag ()
+{
+ drag_info.item = 0;
+ drag_info.copy = false;
+ drag_info.motion_callback = 0;
+ drag_info.finished_callback = 0;
+ drag_info.dest_trackview = 0;
+ drag_info.source_trackview = 0;
+ drag_info.last_frame_position = 0;
+ drag_info.grab_frame = 0;
+ drag_info.last_pointer_frame = 0;
+ drag_info.current_pointer_frame = 0;
+ drag_info.brushing = false;
+ range_marker_drag_rect->hide();
+ drag_info.clear_copied_locations ();
+}
+
void
Editor::start_grab (GdkEvent* event, Gdk::Cursor *cursor)
{
// if dragging with button2, the motion is x constrained, with Alt-button2 it is y constrained
- if (event->button.button == 2) {
+ if (Keyboard::is_button2_event (&event->button)) {
if (Keyboard::modifier_state_equals (event->button.state, Keyboard::SecondaryModifier)) {
drag_info.y_constrained = true;
drag_info.x_constrained = false;
drag_info.want_move_threshold = false;
drag_info.pointer_frame_offset = 0;
drag_info.brushing = false;
- drag_info.copied_location = 0;
+ drag_info.clear_copied_locations ();
+
+ drag_info.original_x = 0;
+ drag_info.original_y = 0;
+ drag_info.item->i2w (drag_info.original_x, drag_info.original_y);
drag_info.item->grab (Gdk::POINTER_MOTION_MASK|Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK,
*cursor,
hide_verbose_canvas_cursor();
- drag_info.item = 0;
- drag_info.copy = false;
- drag_info.motion_callback = 0;
- drag_info.finished_callback = 0;
- drag_info.last_trackview = 0;
- drag_info.last_frame_position = 0;
- drag_info.grab_frame = 0;
- drag_info.last_pointer_frame = 0;
- drag_info.current_pointer_frame = 0;
- drag_info.brushing = false;
-
- if (drag_info.copied_location) {
- delete drag_info.copied_location;
- drag_info.copied_location = 0;
- }
+ finalize_drag ();
return did_drag;
}
+void
+Editor::region_gain_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
+{
+ if (drag_info.first_move && drag_info.move_threshold_passed) {
+ drag_info.first_move = false;
+ }
+}
+
void
Editor::start_fade_in_grab (ArdourCanvas::Item* item, GdkEvent* event)
{
AudioRegionView* arv = static_cast<AudioRegionView*>(drag_info.data);
- drag_info.pointer_frame_offset = drag_info.grab_frame - ((nframes_t) arv->audio_region()->fade_in()->back()->when + arv->region()->position());
+
+ drag_info.pointer_frame_offset = drag_info.grab_frame - ((nframes64_t) arv->audio_region()->fade_in()->back()->when + arv->region()->position());
}
void
Editor::fade_in_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
{
AudioRegionView* arv = static_cast<AudioRegionView*>(drag_info.data);
- nframes_t pos;
- nframes_t fade_length;
+ nframes64_t pos;
+ nframes64_t fade_length;
if (drag_info.current_pointer_frame > drag_info.pointer_frame_offset) {
pos = drag_info.current_pointer_frame - drag_info.pointer_frame_offset;
Editor::fade_in_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event)
{
AudioRegionView* arv = static_cast<AudioRegionView*>(drag_info.data);
- nframes_t pos;
- nframes_t fade_length;
+ nframes64_t pos;
+ nframes64_t fade_length;
if (drag_info.first_move) return;
AudioRegionView* arv = static_cast<AudioRegionView*>(drag_info.data);
- drag_info.pointer_frame_offset = drag_info.grab_frame - (arv->region()->length() - (nframes_t) arv->audio_region()->fade_out()->back()->when + arv->region()->position());
+ drag_info.pointer_frame_offset = drag_info.grab_frame - (arv->region()->length() - (nframes64_t) arv->audio_region()->fade_out()->back()->when + arv->region()->position());
}
void
Editor::fade_out_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
{
AudioRegionView* arv = static_cast<AudioRegionView*>(drag_info.data);
- nframes_t pos;
- nframes_t fade_length;
+ nframes64_t pos;
+ nframes64_t fade_length;
if (drag_info.current_pointer_frame > drag_info.pointer_frame_offset) {
pos = drag_info.current_pointer_frame - drag_info.pointer_frame_offset;
if (drag_info.first_move) return;
AudioRegionView* arv = static_cast<AudioRegionView*>(drag_info.data);
- nframes_t pos;
- nframes_t fade_length;
+ nframes64_t pos;
+ nframes64_t fade_length;
if (drag_info.current_pointer_frame > drag_info.pointer_frame_offset) {
pos = drag_info.current_pointer_frame - drag_info.pointer_frame_offset;
show_verbose_time_cursor (cursor->current_frame, 10);
}
+void
+Editor::start_cursor_grab_no_stop (ArdourCanvas::Item* item, GdkEvent* event)
+{
+ drag_info.item = item;
+ drag_info.motion_callback = &Editor::cursor_drag_motion_callback;
+ drag_info.finished_callback = &Editor::cursor_drag_finished_ensure_locate_callback;
+
+ start_grab (event);
+
+ if ((drag_info.data = (item->get_data ("cursor"))) == 0) {
+ fatal << _("programming error: cursor canvas item has no cursor data pointer!") << endmsg;
+ /*NOTREACHED*/
+ }
+
+ Cursor* cursor = (Cursor *) drag_info.data;
+ nframes64_t where = event_frame (event, 0, 0);
+
+ snap_to(where);
+ playhead_cursor->set_position (where);
+
+ if (cursor == playhead_cursor) {
+ _dragging_playhead = true;
+
+ if (session && session->is_auditioning()) {
+ session->cancel_audition ();
+ }
+ }
+
+ drag_info.pointer_frame_offset = drag_info.grab_frame - cursor->current_frame;
+
+ show_verbose_time_cursor (cursor->current_frame, 10);
+}
+
void
Editor::cursor_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
{
Cursor* cursor = (Cursor *) drag_info.data;
- nframes_t adjusted_frame;
+ nframes64_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;
if (adjusted_frame == drag_info.last_pointer_frame) return;
cursor->set_position (adjusted_frame);
-
- UpdateAllTransportClocks (cursor->current_frame);
show_verbose_time_cursor (cursor->current_frame, 10);
+#ifdef GTKOSX
+ track_canvas->update_now ();
+#endif
+ UpdateAllTransportClocks (cursor->current_frame);
+
drag_info.last_pointer_frame = adjusted_frame;
drag_info.first_move = false;
}
void
Editor::cursor_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event)
{
- if (drag_info.first_move) return;
+ _dragging_playhead = false;
+
+ if (drag_info.first_move) {
+ return;
+ }
cursor_drag_motion_callback (item, event);
+
+ if (item == &playhead_cursor->canvas_item) {
+ if (session) {
+ session->request_locate (playhead_cursor->current_frame, drag_info.was_rolling);
+ }
+ }
+}
+void
+Editor::cursor_drag_finished_ensure_locate_callback (ArdourCanvas::Item* item, GdkEvent* event)
+{
_dragging_playhead = false;
+ cursor_drag_motion_callback (item, event);
+
if (item == &playhead_cursor->canvas_item) {
if (session) {
session->request_locate (playhead_cursor->current_frame, drag_info.was_rolling);
marker_drag_line_points.front().set_x(x1);
marker_drag_line_points.back().set_x(x1);
marker_drag_line->property_points() = marker_drag_line_points;
- }
- else {
+ } else {
range_marker_drag_rect->property_x1() = x1;
range_marker_drag_rect->property_x2() = x2;
}
}
+
void
Editor::start_marker_grab (ArdourCanvas::Item* item, GdkEvent* event)
{
_dragging_edit_point = true;
- drag_info.copied_location = new Location (*location);
drag_info.pointer_frame_offset = drag_info.grab_frame - (is_start ? location->start() : location->end());
update_marker_drag_item (location);
// marker_drag_line->raise_to_top();
} else {
range_marker_drag_rect->show();
- range_marker_drag_rect->raise_to_top();
+ //range_marker_drag_rect->raise_to_top();
}
if (is_start) {
selection->toggle (marker);
break;
case Selection::Set:
- selection->set (marker);
+ if (!selection->selected (marker)) {
+ selection->set (marker);
+ }
break;
case Selection::Extend:
- selection->add (marker);
+ {
+ Locations::LocationList ll;
+ list<Marker*> to_add;
+ nframes64_t s, e;
+ selection->markers.range (s, e);
+ s = min (marker->position(), s);
+ e = max (marker->position(), e);
+ s = min (s, e);
+ e = max (s, e);
+ if (e < max_frames) {
+ ++e;
+ }
+ session->locations()->find_all_between (s, e, ll, Location::Flags (0));
+ for (Locations::LocationList::iterator i = ll.begin(); i != ll.end(); ++i) {
+ LocationMarkers* lm = find_location_markers (*i);
+ if (lm) {
+ if (lm->start) {
+ to_add.push_back (lm->start);
+ }
+ if (lm->end) {
+ to_add.push_back (lm->end);
+ }
+ }
+ }
+ if (!to_add.empty()) {
+ selection->add (to_add);
+ }
break;
+ }
case Selection::Add:
selection->add (marker);
break;
}
+
+ /* set up copies for us to manipulate during the drag */
+
+ drag_info.clear_copied_locations ();
+
+ for (MarkerSelection::iterator i = selection->markers.begin(); i != selection->markers.end(); ++i) {
+ Location *l = find_location_from_marker (*i, is_start);
+ drag_info.copied_locations.push_back (new Location (*l));
+ }
}
void
Editor::marker_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
{
- nframes_t f_delta;
- Marker* marker = (Marker *) drag_info.data;
- Location *real_location;
- Location *copy_location;
+ nframes64_t f_delta = 0;
+ nframes64_t newframe;
bool is_start;
bool move_both = false;
+ Marker* dragged_marker = (Marker*) drag_info.data;
+ Marker* marker;
+ Location *real_location;
+ Location *copy_location = 0;
- nframes_t newframe;
if (drag_info.pointer_frame_offset <= drag_info.current_pointer_frame) {
newframe = drag_info.current_pointer_frame - drag_info.pointer_frame_offset;
} else {
newframe = 0;
}
- nframes_t next = newframe;
+ nframes64_t next = newframe;
if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) {
snap_to (newframe, 0, true);
return;
}
- /* call this to find out if its the start or end */
-
- if ((real_location = find_location_from_marker (marker, is_start)) == 0) {
- return;
+ if (Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) {
+ move_both = true;
}
- if (real_location->locked()) {
+ MarkerSelection::iterator i;
+ list<Location*>::iterator x;
+
+ /* find the marker we're dragging, and compute the delta */
+
+ for (i = selection->markers.begin(), x = drag_info.copied_locations.begin();
+ x != drag_info.copied_locations.end() && i != selection->markers.end();
+ ++i, ++x) {
+
+ copy_location = *x;
+ marker = *i;
+
+ if (marker == dragged_marker) {
+
+ if ((real_location = find_location_from_marker (marker, is_start)) == 0) {
+ /* que pasa ?? */
+ return;
+ }
+
+ if (real_location->is_mark()) {
+ f_delta = newframe - copy_location->start();
+ } else {
+
+
+ switch (marker->type()) {
+ case Marker::Start:
+ case Marker::LoopStart:
+ case Marker::PunchIn:
+ f_delta = newframe - copy_location->start();
+ break;
+
+ case Marker::End:
+ case Marker::LoopEnd:
+ case Marker::PunchOut:
+ f_delta = newframe - copy_location->end();
+ break;
+ default:
+ /* what kind of marker is this ? */
+ return;
+ }
+ }
+ break;
+ }
+ }
+
+ if (i == selection->markers.end()) {
+ /* hmm, impossible - we didn't find the dragged marker */
return;
}
- /* use the copy that we're "dragging" around */
-
- copy_location = drag_info.copied_location;
+ /* now move them all */
- f_delta = copy_location->end() - copy_location->start();
-
- if (Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) {
- move_both = true;
- }
+ for (i = selection->markers.begin(), x = drag_info.copied_locations.begin();
+ x != drag_info.copied_locations.end() && i != selection->markers.end();
+ ++i, ++x) {
- if (copy_location->is_mark()) {
- /* just move it */
+ copy_location = *x;
+ marker = *i;
- copy_location->set_start (newframe);
+ /* call this to find out if its the start or end */
+
+ if ((real_location = find_location_from_marker (marker, is_start)) == 0) {
+ continue;
+ }
+
+ if (real_location->locked()) {
+ continue;
+ }
- } else {
+ if (copy_location->is_mark()) {
- if (is_start) { // start-of-range marker
+ /* just move it */
- if (move_both) {
- copy_location->set_start (newframe);
- copy_location->set_end (newframe + f_delta);
- } else if (newframe < copy_location->end()) {
- copy_location->set_start (newframe);
- } else {
- snap_to (next, 1, true);
- copy_location->set_end (next);
- copy_location->set_start (newframe);
- }
+ copy_location->set_start (copy_location->start() + f_delta);
+
+ } else {
- } else { // end marker
+ nframes64_t new_start = copy_location->start() + f_delta;
+ nframes64_t new_end = copy_location->end() + f_delta;
- if (move_both) {
- copy_location->set_end (newframe);
- copy_location->set_start (newframe - f_delta);
- } else if (newframe > copy_location->start()) {
- copy_location->set_end (newframe);
+ if (is_start) { // start-of-range marker
+
+ if (move_both) {
+ copy_location->set_start (new_start);
+ copy_location->set_end (new_end);
+ } else if (new_start < copy_location->end()) {
+ copy_location->set_start (new_start);
+ } else {
+ snap_to (next, 1, true);
+ copy_location->set_end (next);
+ copy_location->set_start (newframe);
+ }
+
+ } else { // end marker
- } else if (newframe > 0) {
- snap_to (next, -1, true);
- copy_location->set_start (next);
- copy_location->set_end (newframe);
+ if (move_both) {
+ copy_location->set_end (new_end);
+ copy_location->set_start (new_start);
+ } else if (new_end > copy_location->start()) {
+ copy_location->set_end (new_end);
+ } else if (newframe > 0) {
+ snap_to (next, -1, true);
+ copy_location->set_start (next);
+ copy_location->set_end (newframe);
+ }
}
}
+ update_marker_drag_item (copy_location);
+
+ LocationMarkers* lm = find_location_markers (real_location);
+
+ if (lm) {
+ lm->set_position (copy_location->start(), copy_location->end());
+ }
}
drag_info.last_pointer_frame = drag_info.current_pointer_frame;
drag_info.first_move = false;
- update_marker_drag_item (copy_location);
-
- LocationMarkers* lm = find_location_markers (real_location);
- lm->set_position (copy_location->start(), copy_location->end());
- edit_point_clock.set (copy_location->start());
+ if (drag_info.copied_locations.empty()) {
+ abort();
+ }
+ edit_point_clock.set (drag_info.copied_locations.front()->start());
show_verbose_time_cursor (newframe, 10);
+
+#ifdef GTKOSX
+ track_canvas->update_now ();
+#endif
+ edit_point_clock.set (copy_location->start());
}
void
Editor::marker_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event)
{
if (drag_info.first_move) {
- marker_drag_motion_callback (item, event);
+ /* just a click, do nothing but finish
+ off the selection process
+ */
+
+ Selection::Operation op = Keyboard::selection_type (event->button.state);
+ Marker* marker = (Marker *) drag_info.data;
+
+ switch (op) {
+ case Selection::Set:
+ if (selection->selected (marker) && selection->markers.size() > 1) {
+ selection->set (marker);
+ }
+ break;
+
+ case Selection::Toggle:
+ case Selection::Extend:
+ case Selection::Add:
+ break;
+ }
+
+ return;
}
_dragging_edit_point = false;
- Marker* marker = (Marker *) drag_info.data;
- bool is_start;
begin_reversible_command ( _("move marker") );
XMLNode &before = session->locations()->get_state();
-
- Location * location = find_location_from_marker (marker, is_start);
- if (location) {
-
- if (location->locked()) {
- return;
- }
+ MarkerSelection::iterator i;
+ list<Location*>::iterator x;
+ bool is_start;
- 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());
+ for (i = selection->markers.begin(), x = drag_info.copied_locations.begin();
+ x != drag_info.copied_locations.end() && i != selection->markers.end();
+ ++i, ++x) {
+
+ Location * location = find_location_from_marker ((*i), is_start);
+
+ if (location) {
+
+ if (location->locked()) {
+ return;
+ }
+
+ if (location->is_mark()) {
+ location->set_start ((*x)->start());
+ } else {
+ location->set ((*x)->start(), (*x)->end());
+ }
}
}
Editor::meter_marker_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
{
MeterMarker* marker = (MeterMarker *) drag_info.data;
- nframes_t adjusted_frame;
+ nframes64_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;
Editor::tempo_marker_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
{
TempoMarker* marker = (TempoMarker *) drag_info.data;
- nframes_t adjusted_frame;
+ nframes64_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;
control_point->line().start_drag (control_point, drag_info.grab_frame, 0);
- double fraction = 1.0 - ((control_point->get_y() - control_point->line().y_position()) / (double)control_point->line().height());
+ float fraction = 1.0 - (control_point->get_y() / 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);
+ drag_info.current_pointer_x + 10, drag_info.current_pointer_y + 10);
show_verbose_canvas_cursor ();
}
cx = max (0.0, cx);
cy = max (0.0, cy);
- cy = min ((double) (cp->line().y_position() + cp->line().height()), cy);
+ cy = min ((double) cp->line().height(), cy);
//translate cx to frames
- nframes_t cx_frames = unit_to_frame (cx);
+ nframes64_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);
}
- const double fraction = 1.0 - ((cy - cp->line().y_position()) / (double)cp->line().height());
+ float fraction = 1.0 - (cy / cp->line().height());
bool push;
cp->line().end_drag (cp);
}
+void
+Editor::edit_control_point (ArdourCanvas::Item* item)
+{
+ ControlPoint* p = reinterpret_cast<ControlPoint *> (item->get_data ("control_point"));
+
+ if (p == 0) {
+ fatal << _("programming error: control point canvas item has no control point object pointer!") << endmsg;
+ /*NOTREACHED*/
+ }
+
+ ControlPointDialog d (p);
+ d.set_position (Gtk::WIN_POS_MOUSE);
+ ensure_float (d);
+
+ if (d.run () != RESPONSE_ACCEPT) {
+ return;
+ }
+
+ p->line().modify_point_y (*p, d.get_y_fraction ());
+}
+
+
void
Editor::start_line_grab_from_regionview (ArdourCanvas::Item* item, GdkEvent* event)
{
{
double cx;
double cy;
- nframes_t frame_within_region;
+ nframes64_t frame_within_region;
/* need to get x coordinate in terms of parent (TimeAxisItemView)
- origin.
+ origin, and ditto for y.
*/
cx = event->button.x;
cy = event->button.y;
+
line->parent_group().w2i (cx, cy);
- frame_within_region = (nframes_t) floor (cx * frames_per_unit);
+
+ frame_within_region = (nframes64_t) floor (cx * frames_per_unit);
if (!line->control_points_adjacent (frame_within_region, current_line_drag_info.before,
current_line_drag_info.after)) {
start_grab (event, fader_cursor);
- const double fraction = 1.0 - ((cy - line->y_position()) / (double)line->height());
+ /* store grab start in parent frame */
+
+ drag_info.grab_x = cx;
+ drag_info.grab_y = cy;
+
+ double fraction = 1.0 - (cy / 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);
+ drag_info.current_pointer_x + 10, drag_info.current_pointer_y + 10);
show_verbose_canvas_cursor ();
}
AutomationLine* line = reinterpret_cast<AutomationLine *> (drag_info.data);
double dy = drag_info.current_pointer_y - drag_info.last_pointer_y;
-
+
if (event->button.state & Keyboard::SecondaryModifier) {
dy *= 0.1;
}
- double cx = drag_info.current_pointer_x;
double cy = drag_info.grab_y + drag_info.cumulative_y_drag + dy;
// calculate zero crossing point. back off by .01 to stay on the
// positive side of zero
- double _unused = 0;
double zero_gain_y = (1.0 - ZERO_GAIN_FRACTION) * line->height() - .01;
- line->parent_group().i2w(_unused, zero_gain_y);
+
+ // line->parent_group().i2w(_unused, zero_gain_y);
// make sure we hit zero when passing through
if ((cy < zero_gain_y and (cy - dy) > zero_gain_y)
drag_info.cumulative_y_drag = cy - drag_info.grab_y;
- line->parent_group().w2i (cx, cy);
-
cy = max (0.0, cy);
cy = min ((double) line->height(), cy);
- const double fraction = 1.0 - ((cy - line->y_position()) / (double)line->height());
+
+ double fraction = 1.0 - (cy / line->height());
bool push;
if (selection->regions.empty() || clicked_regionview == 0) {
return;
}
-
+ _region_motion_group->raise_to_top ();
drag_info.copy = false;
drag_info.item = item;
drag_info.data = clicked_regionview;
speed = tv->get_diskstream()->speed();
}
- drag_info.last_frame_position = (nframes_t) (clicked_regionview->region()->position() / speed);
+ drag_info.last_frame_position = (nframes64_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();
+ drag_info.source_trackview = &clicked_regionview->get_time_axis_view();
+ drag_info.source_layer = clicked_regionview->region()->layer();
+ drag_info.dest_trackview = drag_info.source_trackview;
+ drag_info.dest_layer = drag_info.source_layer;
// 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)"));
+
+ /* sync the canvas to what we think is its current state */
+ track_canvas->update_now();
}
void
drag_info.copy = false;
drag_info.item = item;
drag_info.data = clicked_axisview;
- drag_info.last_trackview = clicked_axisview;
+ drag_info.source_trackview = clicked_axisview;
+ drag_info.dest_trackview = drag_info.source_trackview;
+ drag_info.dest_layer = drag_info.source_layer;
drag_info.motion_callback = &Editor::create_region_drag_motion_callback;
drag_info.finished_callback = &Editor::create_region_drag_finished_callback;
if (selection->regions.empty() || clicked_regionview == 0) {
return;
}
-
+ _region_motion_group->raise_to_top ();
drag_info.copy = true;
drag_info.item = item;
drag_info.data = clicked_regionview;
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.source_trackview = &clicked_regionview->get_time_axis_view();
+ drag_info.dest_trackview = drag_info.source_trackview;
+ drag_info.dest_layer = drag_info.source_layer;
+ drag_info.last_frame_position = (nframes64_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;
speed = tv->get_diskstream()->speed();
}
- drag_info.last_frame_position = (nframes_t) (clicked_regionview->region()->position() / speed);
+ drag_info.last_frame_position = (nframes64_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();
+ drag_info.source_trackview = &clicked_regionview->get_time_axis_view();
+ drag_info.dest_trackview = drag_info.source_trackview;
+ drag_info.dest_layer = drag_info.source_layer;
// we want a move threshold
drag_info.want_move_threshold = true;
drag_info.brushing = true;
drag_info.want_move_threshold = false; // don't copy again
- /* duplicate the region(s) */
+ /* duplicate the regionview(s) and 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);
+
+ const boost::shared_ptr<const Region> original = rv->region();
+ boost::shared_ptr<Region> region_copy = RegionFactory::create (original);
if (arv) {
- nrv = new AudioRegionView (*arv);
+ boost::shared_ptr<AudioRegion> audioregion_copy
+ = boost::dynamic_pointer_cast<AudioRegion>(region_copy);
+ nrv = new AudioRegionView (*arv, audioregion_copy);
} else if (mrv) {
- nrv = new MidiRegionView (*mrv);
- } else {
- continue;
- }
+ boost::shared_ptr<MidiRegion> midiregion_copy
+ = boost::dynamic_pointer_cast<MidiRegion>(region_copy);
+ nrv = new MidiRegionView (*mrv, midiregion_copy);
+ } else {
+ continue;
+ }
nrv->get_canvas_group()->show ();
-
new_regionviews.push_back (nrv);
}
return;
}
- /* reset selection to new regionviews */
+ /* reset selection to new regionviews. This will not set selection visual status for
+ these regionviews since they don't belong to a track, so do that by hand too.
+ */
selection->set (new_regionviews);
+ for (vector<RegionView*>::iterator i = new_regionviews.begin(); i != new_regionviews.end(); ++i) {
+ (*i)->set_selected (true);
+ }
+
/* 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);
+ /*
+ sync the canvas to what we think is its current state
+ without it, the canvas seems to
+ "forget" to update properly after the upcoming reparent()
+ ..only if the mouse is in rapid motion at the time of the grab.
+ something to do with regionview creation raking so long?
+ */
+ track_canvas->update_now();
}
}
bool
-Editor::check_region_drag_possible (RouteTimeAxisView** tv)
+Editor::check_region_drag_possible (RouteTimeAxisView** tv, layer_t* layer)
{
/* Which trackview is this ? */
- TimeAxisView* tvp = trackview_by_y_position (drag_info.current_pointer_y);
- (*tv) = dynamic_cast<RouteTimeAxisView*>(tvp);
+ std::pair<TimeAxisView*, int> const tvp = trackview_by_y_position (drag_info.current_pointer_y);
+ (*tv) = dynamic_cast<RouteTimeAxisView*> (tvp.first);
+ (*layer) = tvp.second;
/* The region motion is only processed if the pointer is over
an audio track.
hide_verbose_canvas_cursor ();
return false;
}
-
+
return true;
}
Editor::region_drag_splice_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
{
RouteTimeAxisView* tv;
+ layer_t layer;
- if (!check_region_drag_possible (&tv)) {
+ if (!check_region_drag_possible (&tv, &layer)) {
return;
}
{
}
+void
+Editor::visible_order_range (int* low, int* high) const
+{
+ *low = TimeAxisView::max_order ();
+ *high = 0;
+
+ for (TrackViewList::const_iterator i = track_views.begin(); i != track_views.end(); ++i) {
+
+ RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (*i);
+
+ if (!rtv->hidden()) {
+
+ if (*high < rtv->order()) {
+ *high = rtv->order ();
+ }
+
+ if (*low > rtv->order()) {
+ *low = rtv->order ();
+ }
+ }
+ }
+}
+
+/** @param new_order New track order.
+ * @param old_order Old track order.
+ * @param visible_y_low Lowest visible order.
+ * @param visible_y_high Highest visible order.
+ * @param tracks Bitset of tracks indexed by order; 0 means a audio/MIDI track, 1 means something else.
+ * @param heigh_list Heights of tracks indexed by order.
+ * @return true if y movement should not happen, otherwise false.
+ */
+bool
+Editor::y_movement_disallowed (
+ int new_order, int old_order, int y_span, int visible_y_low, int visible_y_high,
+ bitset<512> const & tracks, vector<int32_t> const & height_list
+ ) const
+{
+ if (new_order != old_order) {
+
+ /* this isn't the pointer track */
+
+ if (y_span > 0) {
+
+ /* moving up the canvas */
+ if ( (new_order - y_span) >= visible_y_low) {
+
+ int32_t n = 0;
+
+ /* work out where we'll end up with this y span, taking hidden TimeAxisViews into account */
+ int32_t visible_tracks = 0;
+ while (visible_tracks < y_span ) {
+ visible_tracks++;
+ while (height_list[new_order - (visible_tracks - n)] == 0) {
+ /* passing through a hidden track */
+ n--;
+ }
+ }
+
+ if (tracks[new_order - (y_span - n)] != 0x00) {
+ /* moving to a non-track; disallow */
+ return true;
+ }
+
+
+ } else {
+ /* moving beyond the lowest visible track; disallow */
+ return true;
+ }
+
+ } else if (y_span < 0) {
+
+ /* moving down the canvas */
+ if ((new_order - y_span) <= visible_y_high) {
+
+ int32_t visible_tracks = 0;
+ int32_t n = 0;
+ while (visible_tracks > y_span ) {
+ visible_tracks--;
+
+ while (height_list[new_order - (visible_tracks - n)] == 0) {
+ /* passing through a hidden track */
+ n++;
+ }
+ }
+
+ if (tracks[new_order - (y_span - n)] != 0x00) {
+ /* moving to a non-track; disallow */
+ return true;
+ }
+
+
+ } else {
+
+ /* moving beyond the highest visible track; disallow */
+ return true;
+ }
+ }
+
+ } else {
+
+ /* this is the pointer's track */
+
+ if ((new_order - y_span) > visible_y_high) {
+ /* we will overflow */
+ return true;
+ } else if ((new_order - y_span) < visible_y_low) {
+ /* we will overflow */
+ return true;
+ }
+ }
+
+ return false;
+}
+
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
+ nframes64_t pending_region_position = 0;
+ int32_t pointer_order_span = 0, canvas_pointer_order_span = 0;
+ int32_t pointer_layer_span = 0;
+
bool clamp_y_axis = false;
- vector<int32_t> height_list(512) ;
vector<int32_t>::iterator j;
- RouteTimeAxisView* tv;
possibly_copy_regions_during_grab (event);
- if (!check_region_drag_possible (&tv)) {
+ /* *pointer* variables reflect things about the pointer; as we may be moving
+ multiple regions, much detail must be computed per-region */
+
+ /* current_pointer_view will become the TimeAxisView that we're currently pointing at, and
+ current_pointer_layer the current layer on that TimeAxisView */
+ RouteTimeAxisView* current_pointer_view;
+ layer_t current_pointer_layer;
+ if (!check_region_drag_possible (¤t_pointer_view, ¤t_pointer_layer)) {
return;
}
- original_pointer_order = drag_info.last_trackview->order;
-
+ /* TimeAxisView that we were pointing at last time we entered this method */
+ TimeAxisView const * const last_pointer_view = drag_info.dest_trackview;
+ /* the order of the track that we were pointing at last time we entered this method */
+ int32_t const last_pointer_order = last_pointer_view->order ();
+ /* the layer that we were pointing at last time we entered this method */
+ layer_t const last_pointer_layer = drag_info.dest_layer;
+
/************************************************************
- Y-Delta Computation
+ Y DELTA COMPUTATION
************************************************************/
+ /* Height of TimeAxisViews, indexed by order */
+ /* XXX: hard-coded limit of TimeAxisViews */
+ vector<int32_t> height_list (512);
+
if (drag_info.brushing) {
clamp_y_axis = true;
- pointer_y_span = 0;
+ pointer_order_span = 0;
goto y_axis_done;
}
- if ((pointer_y_span = (drag_info.last_trackview->order - tv->order)) != 0) {
+ /* the change in track order between this callback and the last */
+ pointer_order_span = last_pointer_view->order() - current_pointer_view->order();
+ /* the change in layer between this callback and the last;
+ only meaningful if pointer_order_span == 0 (ie we've not moved tracks) */
+ pointer_layer_span = last_pointer_layer - current_pointer_layer;
- int32_t children = 0, numtracks = 0;
- // XXX hard coding track limit, oh my, so very very bad
- bitset <1024> tracks (0x00);
+ if (pointer_order_span != 0) {
+
+ int32_t children = 0;
+ /* XXX: hard-coded limit of tracks */
+ bitset <512> tracks (0x00);
+
+ int visible_y_high;
+ int visible_y_low;
+ visible_order_range (&visible_y_low, &visible_y_high);
+
/* get a bitmask representing the visible tracks */
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
- TimeAxisView *tracklist_timeview;
- tracklist_timeview = (*i);
- RouteTimeAxisView* rtv2 = dynamic_cast<RouteTimeAxisView*>(tracklist_timeview);
+ RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (*i);
TimeAxisView::Children children_list;
- /* zeroes are audio tracks. ones are other types. */
+ /* zeroes are audio/MIDI tracks. ones are other types. */
- if (!rtv2->hidden()) {
+ if (!rtv->hidden()) {
- if (visible_y_high < rtv2->order) {
- visible_y_high = rtv2->order;
- }
- if (visible_y_low > rtv2->order) {
- visible_y_low = rtv2->order;
- }
-
- if (!rtv2->is_track()) {
- tracks = tracks |= (0x01 << rtv2->order);
+ if (!rtv->is_track()) {
+ /* not an audio nor MIDI track */
+ tracks = tracks |= (0x01 << rtv->order());
}
- height_list[rtv2->order] = (*i)->height;
+ height_list[rtv->order()] = (*i)->current_height();
children = 1;
- if ((children_list = rtv2->get_child_list()).size() > 0) {
+
+ if ((children_list = rtv->get_child_list()).size() > 0) {
for (TimeAxisView::Children::iterator j = children_list.begin(); j != children_list.end(); ++j) {
- tracks = tracks |= (0x01 << (rtv2->order + children));
- height_list[rtv2->order + children] = (*j)->height;
- numtracks++;
+ tracks = tracks |= (0x01 << (rtv->order() + children));
+ height_list[rtv->order() + children] = (*j)->current_height();
children++;
}
}
- numtracks++;
}
}
- /* find the actual span according to the canvas */
-
- canvas_pointer_y_span = pointer_y_span;
- if (drag_info.last_trackview->order >= tv->order) {
- int32_t y;
- for (y = tv->order; y < drag_info.last_trackview->order; y++) {
- if (height_list[y] == 0 ) {
- canvas_pointer_y_span--;
+
+ /* find the actual pointer span, in terms of the number of visible tracks;
+ to do this, we reduce |pointer_order_span| by the number of hidden tracks
+ over the span */
+
+ canvas_pointer_order_span = pointer_order_span;
+ if (last_pointer_view->order() >= current_pointer_view->order()) {
+ for (int32_t y = current_pointer_view->order(); y < last_pointer_view->order(); y++) {
+ if (height_list[y] == 0) {
+ canvas_pointer_order_span--;
}
}
} else {
- int32_t y;
- for (y = drag_info.last_trackview->order;y <= tv->order; y++) {
- if ( height_list[y] == 0 ) {
- canvas_pointer_y_span++;
+ for (int32_t y = last_pointer_view->order(); y <= current_pointer_view->order(); y++) {
+ if (height_list[y] == 0) {
+ canvas_pointer_order_span++;
}
}
}
for (list<RegionView*>::const_iterator i = selection->regions.by_layer().begin(); i != selection->regions.by_layer().end(); ++i) {
- RegionView* rv2 = (*i);
- double ix1, ix2, iy1, iy2;
- int32_t n = 0;
-
- rv2->get_canvas_frame()->get_bounds (ix1, iy1, ix2, iy2);
- rv2->get_canvas_group()->i2w (ix1, iy1);
- TimeAxisView* tvp2 = trackview_by_y_position (iy1);
- RouteTimeAxisView* rtv2 = dynamic_cast<RouteTimeAxisView*>(tvp2);
-
- if (rtv2->order != original_pointer_order) {
- /* this isn't the pointer track */
+
+ RegionView* rv = (*i);
- if (canvas_pointer_y_span > 0) {
+ if (rv->region()->locked()) {
+ continue;
+ }
- /* moving up the canvas */
- if ((rtv2->order - canvas_pointer_y_span) >= visible_y_low) {
-
- int32_t visible_tracks = 0;
- while (visible_tracks < canvas_pointer_y_span ) {
- visible_tracks++;
-
- while (height_list[rtv2->order - (visible_tracks - n)] == 0) {
- /* we're passing through a hidden track */
- n--;
- }
- }
-
- if (tracks[rtv2->order - (canvas_pointer_y_span - n)] != 0x00) {
- clamp_y_axis = true;
- }
-
- } else {
- clamp_y_axis = true;
- }
-
- } else if (canvas_pointer_y_span < 0) {
+ double ix1, ix2, iy1, iy2;
+ rv->get_canvas_frame()->get_bounds (ix1, iy1, ix2, iy2);
+ rv->get_canvas_frame()->i2w (ix1, iy1);
+ iy1 += vertical_adjustment.get_value() - canvas_timebars_vsize;
+
+ /* get the new trackview for this particular region */
+ std::pair<TimeAxisView*, int> const tvp = trackview_by_y_position (iy1);
+ assert (tvp.first);
+ RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (tvp.first);
+
+ /* I know this method has a slightly excessive argument list, but I think
+ it's nice to separate the code out all the same, since it has such a
+ simple result, and it makes it clear that there are no other
+ side-effects.
+ */
- /*moving down the canvas*/
+ /* XXX: not sure that we should be passing canvas_pointer_order_span in here,
+ as surely this is a per-region thing... */
+
+ clamp_y_axis = y_movement_disallowed (
+ rtv->order(), last_pointer_order, canvas_pointer_order_span, visible_y_low, visible_y_high,
+ tracks, height_list
+ );
- if ((rtv2->order - (canvas_pointer_y_span - n)) <= visible_y_high) { // we will overflow
-
-
- int32_t visible_tracks = 0;
-
- while (visible_tracks > canvas_pointer_y_span ) {
- visible_tracks--;
-
- while (height_list[rtv2->order - (visible_tracks - n)] == 0) {
- n++;
- }
- }
- if ( tracks[rtv2->order - ( canvas_pointer_y_span - n)] != 0x00) {
- clamp_y_axis = true;
-
- }
- } else {
-
- clamp_y_axis = true;
- }
- }
-
- } else {
-
- /* this is the pointer's track */
- if ((rtv2->order - pointer_y_span) > visible_y_high) { // we will overflow
- clamp_y_axis = true;
- } else if ((rtv2->order - pointer_y_span) < visible_y_low) { // we will underflow
- clamp_y_axis = true;
- }
- }
if (clamp_y_axis) {
break;
}
}
- } else if (drag_info.last_trackview == tv) {
- clamp_y_axis = true;
- }
+ } else if (drag_info.dest_trackview == current_pointer_view) {
+
+ if (current_pointer_layer == last_pointer_layer) {
+ /* No movement; clamp */
+ clamp_y_axis = true;
+ }
+ }
y_axis_done:
if (!clamp_y_axis) {
- drag_info.last_trackview = tv;
+ drag_info.dest_trackview = current_pointer_view;
+ drag_info.dest_layer = current_pointer_layer;
}
/************************************************************
/* compute the amount of pointer motion in frames, and where
the region would be if we moved it by that much.
*/
-
if ( drag_info.move_threshold_passed ) {
- if (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;
+ nframes64_t sync_frame;
+ nframes64_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_offset = clicked_regionview->region()->sync_offset (sync_dir);
/* we don't handle a sync point that lies before zero.
*/
snap_to (sync_frame);
}
- pending_region_position = rv->region()->adjust_to_sync (sync_frame);
+ pending_region_position = clicked_regionview->region()->adjust_to_sync (sync_frame);
} else {
pending_region_position = drag_info.last_frame_position;
pending_region_position = 0;
}
- if (pending_region_position > max_frames - rv->region()->length()) {
+ if (pending_region_position > max_frames - clicked_regionview->region()->length()) {
pending_region_position = drag_info.last_frame_position;
}
-
- // printf ("3: pending_region_position= %lu %lu\n", pending_region_position, drag_info.last_frame_position );
-
- bool x_move_allowed = ( !drag_info.x_constrained && (Config->get_edit_mode() != Lock)) || ( drag_info.x_constrained && (Config->get_edit_mode() == Lock)) ;
- if ( pending_region_position != drag_info.last_frame_position && x_move_allowed ) {
+
+ bool x_move_allowed;
+
+ if (Config->get_edit_mode() == Lock) {
+ if (drag_info.copy) {
+ x_move_allowed = !drag_info.x_constrained;
+ } else {
+ /* in locked edit mode, reverse the usual meaning of x_constrained */
+ x_move_allowed = drag_info.x_constrained;
+ }
+ } else {
+ x_move_allowed = !drag_info.x_constrained;
+ }
+
+ if (( pending_region_position != drag_info.last_frame_position) && x_move_allowed ) {
/* now compute the canvas unit distance we need to move the regionview
to make it appear at the new location.
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);
- }
+ for (list<RegionView*>::const_iterator i = selection->regions.by_layer().begin(); i != selection->regions.by_layer().end(); ++i) {
+
+ RegionView* rv = (*i);
+
+ // If any regionview is at zero, we need to know so we can stop further leftward motion.
+
+ double ix1, ix2, iy1, iy2;
+ rv->get_canvas_frame()->get_bounds (ix1, iy1, ix2, iy2);
+ rv->get_canvas_frame()->i2w (ix1, iy1);
+
+ if (-x_delta > ix1 + horizontal_adjustment.get_value()) {
+ x_delta = 0;
+ pending_region_position = drag_info.last_frame_position;
+ break;
+ }
+ }
+ }
+
drag_info.last_frame_position = pending_region_position;
-
+
} else {
x_delta = 0;
}
PREPARE TO MOVE
************************************************************/
- if (x_delta == 0 && (pointer_y_span == 0)) {
+ if (x_delta == 0 && pointer_order_span == 0 && pointer_layer_span == 0) {
/* haven't reached next snap point, and we're not switching
- trackviews. nothing to do.
+ trackviews nor layers. nothing to do.
*/
return;
- }
-
-
- if (x_delta < 0) {
- for (list<RegionView*>::const_iterator i = selection->regions.by_layer().begin(); i != selection->regions.by_layer().end(); ++i) {
-
- RegionView* rv2 = (*i);
-
- // If any regionview is at zero, we need to know so we can stop further leftward motion.
-
- double ix1, ix2, iy1, iy2;
- rv2->get_canvas_frame()->get_bounds (ix1, iy1, ix2, iy2);
- rv2->get_canvas_group()->i2w (ix1, iy1);
-
- if (ix1 <= 1) {
- x_delta = 0;
- break;
- }
- }
}
/*************************************************************
MOTION
************************************************************/
-
- bool do_move;
-
+ bool do_move = true;
if (drag_info.first_move) {
- if (drag_info.move_threshold_passed) {
- do_move = true;
- } else {
+ if (!drag_info.move_threshold_passed) {
do_move = false;
}
- } else {
- do_move = true;
}
if (do_move) {
const list<RegionView*>& layered_regions = selection->regions.by_layer();
for (list<RegionView*>::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;
- /* 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.
- */
+ if (rv->region()->locked()) {
+ continue;
+ }
- 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<RouteTimeAxisView*>(tvp2);
- RouteTimeAxisView* temp_rtv;
+ /* here we are calculating the y distance from the
+ top of the first track view to the top of the region
+ area of the track view that we're working on */
- if ((pointer_y_span != 0) && !clamp_y_axis) {
- y_delta = 0;
+ /* this x value is just a dummy value so that we have something
+ to pass to i2w () */
+
+ double ix1 = 0;
+
+ /* distance from the top of this track view to the region area
+ of our track view is always 1 */
+
+ double iy1 = 1;
+
+ /* convert to world coordinates, ie distance from the top of
+ the ruler section */
+
+ rv->get_canvas_frame()->i2w (ix1, iy1);
+
+ /* compensate for the ruler section and the vertical scrollbar position */
+ iy1 += get_trackview_group_vertical_offset ();
+
+ if (drag_info.first_move) {
+
+ // hide any dependent views
+
+ rv->get_time_axis_view().hide_dependent_views (*rv);
+
+ /*
+ reparent to a non scrolling group so that we can keep the
+ region selection above all time axis views.
+ reparenting means we have to move the rv as the two
+ parent groups have different coordinates.
+ */
+
+ rv->get_canvas_group()->property_y() = iy1 - 1;
+ rv->get_canvas_group()->reparent(*_region_motion_group);
+
+ rv->fake_set_opaque (true);
+ }
+
+ /* current view for this particular region */
+ std::pair<TimeAxisView*, int> pos = trackview_by_y_position (iy1);
+ RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (pos.first);
+
+ if (pointer_order_span != 0 && !clamp_y_axis) {
+
+ /* INTER-TRACK MOVEMENT */
+
+ /* move through the height list to the track that the region is currently on */
+ vector<int32_t>::iterator j = height_list.begin ();
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--;
+ while (j != height_list.end () && x != rtv->order ()) {
+ ++x;
+ ++j;
+ }
+
+ y_delta = 0;
+ int32_t temp_pointer_order_span = canvas_pointer_order_span;
+
+ if (j != height_list.end ()) {
+
+ /* Account for layers in the original and
+ destination tracks. If we're moving around in layers we assume
+ that only one track is involved, so it's ok to use *pointer*
+ variables here. */
+
+ StreamView* lv = last_pointer_view->view ();
+ assert (lv);
+
+ /* move to the top of the last trackview */
+ if (lv->layer_display () == Stacked) {
+ y_delta -= (lv->layers() - last_pointer_layer - 1) * lv->child_height ();
+ }
+
+ StreamView* cv = current_pointer_view->view ();
+ assert (cv);
+
+ /* move to the right layer on the current trackview */
+ if (cv->layer_display () == Stacked) {
+ y_delta += (cv->layers() - current_pointer_layer - 1) * cv->child_height ();
+ }
+
+ /* And for being on a non-topmost layer on the new
+ track */
+
+ while (temp_pointer_order_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 != last_pointer_order) {
+ if ((*j) == 0) {
+ ++temp_pointer_order_span;
}
- 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++;
+
+ y_delta -= (*j);
+ temp_pointer_order_span--;
+ }
+
+ while (temp_pointer_order_span < 0) {
+
+ y_delta += (*j);
+
+ if (x != last_pointer_order) {
+ if ((*j) == 0) {
+ --temp_pointer_order_span;
}
- temp_pointer_y_span++;
}
- /* 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<RouteTimeAxisView*>(tvp2);
- rv->set_y_position_and_height (0, temp_rtv->height);
+
+ if (j != height_list.end()) {
+ j++;
+ }
- /* 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<GdkColor&>(col));
- break;
+ temp_pointer_order_span++;
}
- x++;
- }
- }
-
- /* 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;
- }
- } else if ((x_delta > 0) && (rv->region()->last_frame() > max_frames - x_delta)) {
- x_delta = max_frames - rv->region()->last_frame();
- }
+
+ /* find out where we'll be when we move and set height accordingly */
- if (drag_info.first_move) {
+ std::pair<TimeAxisView*, int> const pos = trackview_by_y_position (iy1 + y_delta);
+ RouteTimeAxisView const * temp_rtv = dynamic_cast<RouteTimeAxisView*> (pos.first);
+ rv->set_height (temp_rtv->view()->child_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.
+ */
+
+ //const GdkColor& col (temp_rtv->view->get_region_color());
+ //rv->set_color (const_cast<GdkColor&>(col));
+ }
+ }
- /* 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();
+ if (pointer_order_span == 0 && pointer_layer_span != 0 && !clamp_y_axis) {
- rv->fake_set_opaque (true);
+ /* INTER-LAYER MOVEMENT in the same track */
+ y_delta = rtv->view()->child_height () * pointer_layer_span;
}
+
if (drag_info.brushing) {
mouse_brush_insert_region (rv, pending_region_position);
} else {
- rv->move (x_delta, y_delta);
+ rv->move (x_delta, y_delta);
}
} /* foreach region */
void
Editor::region_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event)
{
- nframes_t where;
- RegionView* rvdi = reinterpret_cast<RegionView *> (drag_info.data);
- pair<set<boost::shared_ptr<Playlist> >::iterator,bool> insert_result;
bool nocommit = true;
- double speed;
- RouteTimeAxisView* rtv;
- bool regionview_y_movement;
- bool regionview_x_movement;
vector<RegionView*> copies;
- list <boost::shared_ptr<Playlist > > used_playlists;
- list <sigc::connection > used_connections;
- bool preserve_selection = false;
+ RouteTimeAxisView* source_tv;
+ boost::shared_ptr<Diskstream> ds;
+ boost::shared_ptr<Playlist> from_playlist;
+ vector<RegionView*> new_selection;
+ typedef set<boost::shared_ptr<Playlist> > PlaylistSet;
+ PlaylistSet modified_playlists;
+ PlaylistSet frozen_playlists;
+ list <sigc::connection> modified_playlist_connections;
+ pair<PlaylistSet::iterator,bool> insert_result, frozen_insert_result;
+ nframes64_t drag_delta;
+ bool changed_tracks, changed_position;
+ std::pair<TimeAxisView*, int> tvp;
+ std::map<RegionView*, RouteTimeAxisView*> final;
/* first_move is set to false if the regionview has been moved in the
motion handler.
nocommit = false;
- /* The regionview has been moved at some stage during the grab so we need
- to account for any mouse movement between this event and the last one.
- */
-
- region_drag_motion_callback (item, event);
-
if (Config->get_edit_mode() == Splice && !pre_drag_region_selection.empty()) {
selection->set (pre_drag_region_selection);
pre_drag_region_selection.clear ();
goto out;
}
- /* adjust for track speed */
- speed = 1.0;
-
- rtv = dynamic_cast<RouteTimeAxisView*> (drag_info.last_trackview);
- if (rtv && rtv->get_diskstream()) {
- speed = rtv->get_diskstream()->speed();
- }
-
- regionview_x_movement = (drag_info.last_frame_position != (nframes_t) (rvdi->region()->position()/speed));
- regionview_y_movement = (drag_info.last_trackview != &rvdi->get_time_axis_view());
+ char* op_string;
- //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());
+ /* reverse this here so that we have the correct logic to finalize
+ the drag.
+ */
- char* op_string;
+ if (Config->get_edit_mode() == Lock && !drag_info.copy) {
+ drag_info.x_constrained = !drag_info.x_constrained;
+ }
if (drag_info.copy) {
if (drag_info.x_constrained) {
}
begin_reversible_command (op_string);
+ changed_position = (drag_info.last_frame_position != (nframes64_t) (clicked_regionview->region()->position()));
+ tvp = trackview_by_y_position (drag_info.current_pointer_y);
+ changed_tracks = (tvp.first != &clicked_regionview->get_time_axis_view());
- if (regionview_y_movement) {
+ drag_delta = clicked_regionview->region()->position() - drag_info.last_frame_position;
- /* moved to a different track. */
-
- vector<RegionView*> new_selection;
-
- for (list<RegionView*>::const_iterator i = selection->regions.by_layer().begin(); i != selection->regions.by_layer().end(); ) {
-
- RegionView* rv = (*i);
+ track_canvas->update_now ();
- double ix1, ix2, iy1, iy2;
-
- rv->get_canvas_frame()->get_bounds (ix1, iy1, ix2, iy2);
- rv->get_canvas_group()->i2w (ix1, iy1);
+ /* make a list of where each region ended up */
+ for (list<RegionView*>::const_iterator i = selection->regions.by_layer().begin(); i != selection->regions.by_layer().end(); ++i) {
- RouteTimeAxisView* rtv2 = dynamic_cast<RouteTimeAxisView*>(trackview_by_y_position (iy1));
+ double ix1, ix2, iy1, iy2;
+ (*i)->get_canvas_frame()->get_bounds (ix1, iy1, ix2, iy2);
+ (*i)->get_canvas_frame()->i2w (ix1, iy1);
+ iy1 += vertical_adjustment.get_value() - canvas_timebars_vsize;
- boost::shared_ptr<Playlist> from_playlist = rv->region()->playlist();
- boost::shared_ptr<Playlist> to_playlist = rtv2->playlist();
-
- where = (nframes_t) (unit_to_frame (ix1) * speed);
- boost::shared_ptr<Region> new_region (RegionFactory::create (rv->region()));
+ std::pair<TimeAxisView*, int> tv = trackview_by_y_position (iy1);
+ final[*i] = dynamic_cast<RouteTimeAxisView*> (tv.first);
+ }
- if (! to_playlist->frozen()) {
- /*
- we haven't seen this playlist before.
- we want to freeze it because we don't want to relayer per-region.
- its much better to do that just once if the playlist is large.
- */
+ for (list<RegionView*>::const_iterator i = selection->regions.by_layer().begin(); i != selection->regions.by_layer().end(); ) {
- /*
- connect so the selection is changed when the new regionview finally appears (after thaw).
- keep track of it so we can disconnect later.
- */
+ RegionView* rv = (*i);
+ RouteTimeAxisView* dest_rtv = final[*i];
- sigc::connection c = rtv2->view()->RegionViewAdded.connect (mem_fun(*this, &Editor::collect_and_select_new_region_view));
- used_connections.push_back (c);
+ nframes64_t where;
- /* undo */
- session->add_command (new MementoCommand<Playlist>(*to_playlist, &to_playlist->get_state(), 0));
+ if (rv->region()->locked()) {
+ ++i;
+ continue;
+ }
- /* remember used playlists so we can thaw them later */
- used_playlists.push_back(to_playlist);
- to_playlist->freeze();
- }
+ if (changed_position && !drag_info.x_constrained) {
+ where = rv->region()->position() - drag_delta;
+ } else {
+ where = rv->region()->position();
+ }
+ boost::shared_ptr<Region> new_region;
+
+ if (drag_info.copy) {
+ /* we already made a copy */
+ new_region = rv->region();
+
/* undo the previous hide_dependent_views so that xfades don't
disappear on copying regions
*/
+
+ //rv->get_time_axis_view().reveal_dependent_views (*rv);
+
+ } else if (changed_tracks && dest_rtv->playlist()) {
+ new_region = RegionFactory::create (rv->region());
+ }
- 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);
-
- session->add_command (new MementoCommand<Playlist>(*from_playlist, &from_playlist->get_state(), 0));
- from_playlist->remove_region ((rv->region()));
- session->add_command (new MementoCommand<Playlist>(*from_playlist, 0, &from_playlist->get_state()));
-
- } else {
-
- /* the regionview we dragged around is a temporary copy, queue it for deletion */
+ if (changed_tracks || drag_info.copy) {
- copies.push_back (rv);
+ boost::shared_ptr<Playlist> to_playlist = dest_rtv->playlist();
+ if (!to_playlist) {
+ ++i;
+ continue;
}
latest_regionviews.clear ();
- sigc::connection c = rtv2->view()->RegionViewAdded.connect (mem_fun(*this, &Editor::collect_new_region_view));
- session->add_command (new MementoCommand<Playlist>(*to_playlist, &to_playlist->get_state(), 0));
+
+ sigc::connection c = dest_rtv->view()->RegionViewAdded.connect (mem_fun(*this, &Editor::collect_new_region_view));
+
+ insert_result = modified_playlists.insert (to_playlist);
+ if (insert_result.second) {
+ session->add_command (new MementoCommand<Playlist>(*to_playlist, &to_playlist->get_state(), 0));
+ }
to_playlist->add_region (new_region, where);
- session->add_command (new MementoCommand<Playlist>(*to_playlist, 0, &to_playlist->get_state()));
+
c.disconnect ();
if (!latest_regionviews.empty()) {
- new_selection.insert (new_selection.end(), latest_regionviews.begin(), latest_regionviews.end());
+ // XXX why just the first one ? we only expect one
+ // commented out in nick_m's canvas reworking. is that intended?
+ //dest_atv->reveal_dependent_views (*latest_regionviews.front());
+ new_selection.push_back (latest_regionviews.front());
}
- /* 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.
-
+ } else {
+ /*
+ motion on the same track. plonk the previously reparented region
+ back to its original canvas group (its streamview).
+ No need to do anything for copies as they are fake regions which will be deleted.
*/
- if (drag_info.copy) {
- ++i;
- } else {
- if (selection->regions.empty()) {
- break;
- } else {
- /*
- XXX see above .. but we just froze the playlists.. we have to keep iterating, right?
- */
-
- //i = selection->regions.by_layer().begin();
- ++i;
- }
- }
- }
-
- } else {
-
- /* motion within a single track */
-
- list<RegionView*> regions = selection->regions.by_layer();
-
- for (list<RegionView*>::iterator i = regions.begin(); i != regions.end(); ++i) {
-
- RegionView* rv = (*i);
- boost::shared_ptr<Playlist> to_playlist = (*i)->region()->playlist();
- RouteTimeAxisView* from_rtv = dynamic_cast<RouteTimeAxisView*> (&(rv->get_time_axis_view()));
+ rv->get_canvas_group()->reparent (*dest_rtv->view()->canvas_item());
+ rv->get_canvas_group()->property_y() = 0;
+
+ /* just change the model */
+
+ boost::shared_ptr<Playlist> playlist = dest_rtv->playlist();
- if (!rv->region()->can_move()) {
- continue;
+ insert_result = modified_playlists.insert (playlist);
+ if (insert_result.second) {
+ session->add_command (new MementoCommand<Playlist>(*playlist, &playlist->get_state(), 0));
}
-
- if (regionview_x_movement) {
- double ownspeed = 1.0;
-
- if (from_rtv && from_rtv->get_diskstream()) {
- ownspeed = from_rtv->get_diskstream()->speed();
- }
-
- /* base the new region position on the current position of the regionview.*/
-
- double ix1, ix2, iy1, iy2;
-
- rv->get_canvas_frame()->get_bounds (ix1, iy1, ix2, iy2);
- rv->get_canvas_group()->i2w (ix1, iy1);
- where = (nframes_t) (unit_to_frame (ix1) * ownspeed);
-
- } else {
-
- where = rv->region()->position();
+ /* freeze to avoid lots of relayering in the case of a multi-region drag */
+ frozen_insert_result = frozen_playlists.insert(playlist);
+ if (frozen_insert_result.second) {
+ playlist->freeze();
}
- if (! to_playlist->frozen()) {
- sigc::connection c = from_rtv->view()->RegionViewAdded.connect (mem_fun(*this, &Editor::collect_and_select_new_region_view));
- used_connections.push_back (c);
+ rv->region()->set_position (where, (void*) this);
+ }
- /* add the undo */
- session->add_command (new MementoCommand<Playlist>(*to_playlist, &to_playlist->get_state(), 0));
+ if (changed_tracks && !drag_info.copy) {
- used_playlists.push_back(to_playlist);
- to_playlist->freeze();
- }
+ /* get the playlist where this drag started. we can't use rv->region()->playlist()
+ because we may have copied the region and it has not been attached to a playlist.
+ */
- if (drag_info.copy) {
+ assert ((source_tv = dynamic_cast<RouteTimeAxisView*> (&rv->get_time_axis_view())));
+ assert ((ds = source_tv->get_diskstream()));
+ assert ((from_playlist = ds->playlist()));
- boost::shared_ptr<Region> newregion;
- boost::shared_ptr<Region> ar;
- boost::shared_ptr<Region> mr;
+ /* moved to a different audio track, without copying */
- if ((ar = boost::dynamic_pointer_cast<AudioRegion>(rv->region())) != 0) {
- newregion = RegionFactory::create (ar);
- } else if ((mr = boost::dynamic_pointer_cast<MidiRegion>(rv->region())) != 0) {
- newregion = RegionFactory::create (mr);
- }
+ /* the region that used to be in the old playlist is not
+ moved to the new one - we use 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);
+
+ /* remove the region from the old playlist */
- /* add it */
+ insert_result = modified_playlists.insert (from_playlist);
+ if (insert_result.second) {
+ session->add_command (new MementoCommand<Playlist>(*from_playlist, &from_playlist->get_state(), 0));
+ }
- latest_regionviews.clear ();
- 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 ();
+ from_playlist->remove_region ((rv->region()));
+
+ /* 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 a 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).
- if (!latest_regionviews.empty()) {
- // XXX why just the first one ? we only expect one
- rtv->reveal_dependent_views (*latest_regionviews.front());
- selection->add (latest_regionviews);
- }
-
- } else {
+ this could have invalidated any and all iterators into the region selection.
- /* just change the model */
+ 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.
- rv->region()->set_position (where, (void*) this);
- preserve_selection = true;
+ EXCEPT .... if we are doing a copy drag, then the selection hasn't been modified and
+ we can just iterate.
+ */
+ if (selection->regions.empty()) {
+ break;
+ } else {
+ i = selection->regions.by_layer().begin();
}
+ } else {
+ ++i;
+ }
+
+ if (drag_info.copy) {
+ copies.push_back (rv);
}
-
- }
- if (! preserve_selection) {
- //selection->clear_regions();
}
- while (used_playlists.size() > 0) {
-
- list <boost::shared_ptr<Playlist > >::iterator i = used_playlists.begin();
- (*i)->thaw();
-
- if (used_connections.size()) {
- sigc::connection c = used_connections.front();
- c.disconnect();
- used_connections.pop_front();
+
+ if (new_selection.empty()) {
+ if (drag_info.copy) {
+ /* the region(view)s that are selected and being dragged around
+ are copies and do not belong to any track. remove them
+ from the selection right here.
+ */
+ selection->clear_regions();
}
- /* add the redo */
-
- session->add_command (new MementoCommand<Playlist>(*(*i), 0, &(*i)->get_state()));
- used_playlists.pop_front();
+ } else {
+ /* this will clear any existing selection that would have been
+ cleared in the other clause above
+ */
+ selection->set (new_selection);
}
+ for (set<boost::shared_ptr<Playlist> >::iterator p = frozen_playlists.begin(); p != frozen_playlists.end(); ++p) {
+ (*p)->thaw();
+ }
+
out:
-
if (!nocommit) {
+ for (set<boost::shared_ptr<Playlist> >::iterator p = modified_playlists.begin(); p != modified_playlists.end(); ++p) {
+ session->add_command (new MementoCommand<Playlist>(*(*p), 0, &(*p)->get_state()));
+ }
commit_reversible_command ();
}
for (vector<RegionView*>::iterator x = copies.begin(); x != copies.end(); ++x) {
delete *x;
}
-}
+}
void
Editor::create_region_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
void
Editor::create_region_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event)
{
- MidiTimeAxisView* mtv = dynamic_cast<MidiTimeAxisView*> (drag_info.last_trackview);
+ MidiTimeAxisView* mtv = dynamic_cast<MidiTimeAxisView*> (drag_info.dest_trackview);
if (!mtv)
return;
begin_reversible_command (_("create region"));
XMLNode &before = mtv->playlist()->get_state();
- nframes_t start = drag_info.grab_frame;
+ nframes64_t start = drag_info.grab_frame;
snap_to (start, -1);
const Meter& m = session->tempo_map().meter_at(start);
const Tempo& t = session->tempo_map().tempo_at(start);
if (Keyboard::modifier_state_equals (event->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::SecondaryModifier))) {
- align_region (rv.region(), SyncPoint, (nframes_t) (where * speed));
+ align_region (rv.region(), SyncPoint, (nframes64_t) (where * speed));
} else if (Keyboard::modifier_state_equals (event->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier))) {
- align_region (rv.region(), End, (nframes_t) (where * speed));
+ align_region (rv.region(), End, (nframes64_t) (where * speed));
} else {
- align_region (rv.region(), Start, (nframes_t) (where * speed));
+ align_region (rv.region(), Start, (nframes64_t) (where * speed));
}
}
}
}
void
-Editor::show_verbose_time_cursor (nframes_t frame, double offset, double xpos, double ypos)
+Editor::show_verbose_time_cursor (nframes64_t frame, double offset, double xpos, double ypos)
{
char buf[128];
SMPTE::Time smpte;
BBT_Time bbt;
int hours, mins;
- nframes_t frame_rate;
+ nframes64_t frame_rate;
float secs;
if (session == 0) {
break;
default:
- snprintf (buf, sizeof(buf), "%u", frame);
+ snprintf (buf, sizeof(buf), "%" PRIi64, frame);
break;
}
set_verbose_canvas_cursor (buf, xpos + offset, ypos + offset);
}
else {
- set_verbose_canvas_cursor (buf, drag_info.current_pointer_x + offset, drag_info.current_pointer_y + offset);
+ set_verbose_canvas_cursor (buf, drag_info.current_pointer_x + offset - horizontal_adjustment.get_value(), drag_info.current_pointer_y + offset - vertical_adjustment.get_value() + canvas_timebars_vsize);
}
show_verbose_canvas_cursor ();
}
void
-Editor::show_verbose_duration_cursor (nframes_t start, nframes_t end, double offset, double xpos, double ypos)
+Editor::show_verbose_duration_cursor (nframes64_t start, nframes64_t end, double offset, double xpos, double ypos)
{
char buf[128];
SMPTE::Time smpte;
BBT_Time sbbt;
BBT_Time ebbt;
int hours, mins;
- nframes_t distance, frame_rate;
+ nframes64_t distance, frame_rate;
float secs;
Meter meter_at_start(session->tempo_map().meter_at(start));
break;
default:
- snprintf (buf, sizeof(buf), "%u", end - start);
+ snprintf (buf, sizeof(buf), "%" PRIi64, end - start);
break;
}
start_grab (event);
- drag_info.last_trackview = clicked_axisview;
+ drag_info.source_trackview = clicked_routeview;
+ drag_info.dest_trackview = drag_info.source_trackview;
drag_info.last_frame_position = latest_regionviews.front()->region()->position();
drag_info.pointer_frame_offset = drag_info.grab_frame - drag_info.last_frame_position;
void
Editor::start_selection_op (ArdourCanvas::Item* item, GdkEvent* event, SelectionOp op)
{
- nframes_t start = 0;
- nframes_t end = 0;
+ nframes64_t start = 0;
+ nframes64_t end = 0;
if (session == 0) {
return;
void
Editor::drag_selection (ArdourCanvas::Item* item, GdkEvent* event)
{
- nframes_t start = 0;
- nframes_t end = 0;
- nframes_t length;
- nframes_t pending_position;
+ nframes64_t start = 0;
+ nframes64_t end = 0;
+ nframes64_t length;
+ nframes64_t pending_position;
if (drag_info.current_pointer_frame > drag_info.pointer_frame_offset) {
pending_position = drag_info.current_pointer_frame - drag_info.pointer_frame_offset;
}
if (event->button.x >= horizontal_adjustment.get_value() + canvas_width) {
- start_canvas_autoscroll (1);
+ start_canvas_autoscroll (1, 0);
}
if (start != end) {
speed = tv->get_diskstream()->speed();
}
- nframes_t region_start = (nframes_t) (clicked_regionview->region()->position() / speed);
- nframes_t region_end = (nframes_t) (clicked_regionview->region()->last_frame() / speed);
- nframes_t region_length = (nframes_t) (clicked_regionview->region()->length() / speed);
+ nframes64_t region_start = (nframes64_t) (clicked_regionview->region()->position() / speed);
+ nframes64_t region_end = (nframes64_t) (clicked_regionview->region()->last_frame() / speed);
+ nframes64_t region_length = (nframes64_t) (clicked_regionview->region()->length() / speed);
//drag_info.item = clicked_regionview->get_name_highlight();
drag_info.item = item;
Editor::trim_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
{
RegionView* rv = clicked_regionview;
- nframes_t frame_delta = 0;
+ nframes64_t frame_delta = 0;
bool left_direction;
bool obey_snap = !Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier());
}
case EndTrim:
- if ((left_direction == true) && (drag_info.current_pointer_frame > (nframes_t) (rv->region()->last_frame()/speed))) {
+ if ((left_direction == true) && (drag_info.current_pointer_frame > (nframes64_t) (rv->region()->last_frame()/speed))) {
break;
} else {
for (list<RegionView*>::const_iterator i = selection->regions.by_layer().begin(); i != selection->regions.by_layer().end(); ++i) {
switch (trim_op) {
case StartTrim:
- show_verbose_time_cursor((nframes_t) (rv->region()->position()/speed), 10);
+ show_verbose_time_cursor((nframes64_t) (rv->region()->position()/speed), 10);
break;
case EndTrim:
- show_verbose_time_cursor((nframes_t) (rv->region()->last_frame()/speed), 10);
+ show_verbose_time_cursor((nframes64_t) (rv->region()->last_frame()/speed), 10);
break;
case ContentsTrim:
show_verbose_time_cursor(drag_info.current_pointer_frame, 10);
}
void
-Editor::single_contents_trim (RegionView& rv, nframes_t frame_delta, bool left_direction, bool swap_direction, bool obey_snap)
+Editor::single_contents_trim (RegionView& rv, nframes64_t frame_delta, bool left_direction, bool swap_direction, bool obey_snap)
{
boost::shared_ptr<Region> region (rv.region());
return;
}
- nframes_t new_bound;
+ nframes64_t new_bound;
double speed = 1.0;
TimeAxisView* tvp = clicked_axisview;
if (left_direction) {
if (swap_direction) {
- new_bound = (nframes_t) (region->position()/speed) + frame_delta;
+ new_bound = (nframes64_t) (region->position()/speed) + frame_delta;
} else {
- new_bound = (nframes_t) (region->position()/speed) - frame_delta;
+ new_bound = (nframes64_t) (region->position()/speed) - frame_delta;
}
} else {
if (swap_direction) {
- new_bound = (nframes_t) (region->position()/speed) - frame_delta;
+ new_bound = (nframes64_t) (region->position()/speed) - frame_delta;
} else {
- new_bound = (nframes_t) (region->position()/speed) + frame_delta;
+ new_bound = (nframes64_t) (region->position()/speed) + frame_delta;
}
}
if (obey_snap) {
snap_to (new_bound);
}
- region->trim_start ((nframes_t) (new_bound * speed), this);
+ region->trim_start ((nframes64_t) (new_bound * speed), this);
rv.region_changed (StartChanged);
}
void
-Editor::single_start_trim (RegionView& rv, nframes_t frame_delta, bool left_direction, bool obey_snap)
+Editor::single_start_trim (RegionView& rv, nframes64_t frame_delta, bool left_direction, bool obey_snap)
{
boost::shared_ptr<Region> region (rv.region());
return;
}
- nframes_t new_bound;
+ nframes64_t new_bound;
double speed = 1.0;
TimeAxisView* tvp = clicked_axisview;
}
if (left_direction) {
- new_bound = (nframes_t) (region->position()/speed) - frame_delta;
+ new_bound = (nframes64_t) (region->position()/speed) - frame_delta;
} else {
- new_bound = (nframes_t) (region->position()/speed) + frame_delta;
+ new_bound = (nframes64_t) (region->position()/speed) + frame_delta;
}
if (obey_snap) {
snap_to (new_bound, (left_direction ? 0 : 1));
}
- region->trim_front ((nframes_t) (new_bound * speed), this);
+ region->trim_front ((nframes64_t) (new_bound * speed), this);
rv.region_changed (Change (LengthChanged|PositionChanged|StartChanged));
}
void
-Editor::single_end_trim (RegionView& rv, nframes_t frame_delta, bool left_direction, bool obey_snap)
+Editor::single_end_trim (RegionView& rv, nframes64_t frame_delta, bool left_direction, bool obey_snap)
{
boost::shared_ptr<Region> region (rv.region());
return;
}
- nframes_t new_bound;
+ nframes64_t new_bound;
double speed = 1.0;
TimeAxisView* tvp = clicked_axisview;
}
if (left_direction) {
- new_bound = (nframes_t) ((region->last_frame() + 1)/speed) - frame_delta;
+ new_bound = (nframes64_t) ((region->last_frame() + 1)/speed) - frame_delta;
} else {
- new_bound = (nframes_t) ((region->last_frame() + 1)/speed) + frame_delta;
+ new_bound = (nframes64_t) ((region->last_frame() + 1)/speed) + frame_delta;
}
if (obey_snap) {
snap_to (new_bound);
}
- region->trim_end ((nframes_t) (new_bound * speed), this);
+ region->trim_end ((nframes64_t) (new_bound * speed), this);
rv.region_changed (LengthChanged);
}
Editor::point_trim (GdkEvent* event)
{
RegionView* rv = clicked_regionview;
- nframes_t new_bound = drag_info.current_pointer_frame;
+ nframes64_t new_bound = drag_info.current_pointer_frame;
if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) {
snap_to (new_bound);
void
Editor::drag_range_markerbar_op (ArdourCanvas::Item* item, GdkEvent* event)
{
- nframes_t start = 0;
- nframes_t end = 0;
+ nframes64_t start = 0;
+ nframes64_t end = 0;
ArdourCanvas::SimpleRect *crect;
switch (range_marker_op) {
update_marker_drag_item (temp_location);
range_marker_drag_rect->show();
- range_marker_drag_rect->raise_to_top();
+ //range_marker_drag_rect->raise_to_top();
}
break;
}
if (event->button.x >= horizontal_adjustment.get_value() + canvas_width) {
- start_canvas_autoscroll (1);
+ start_canvas_autoscroll (1, 0);
}
if (start != end) {
if (Keyboard::no_modifier_keys_pressed (&event->button) && range_marker_op != CreateCDMarker) {
- nframes_t start;
- nframes_t end;
+ nframes64_t start;
+ nframes64_t end;
start = session->locations()->first_mark_before (drag_info.grab_frame);
end = session->locations()->first_mark_after (drag_info.grab_frame);
void
Editor::drag_mouse_zoom (ArdourCanvas::Item* item, GdkEvent* event)
{
- nframes_t start;
- nframes_t end;
+ nframes64_t start;
+ nframes64_t end;
if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) {
snap_to (drag_info.current_pointer_frame);
}
void
-Editor::reposition_zoom_rect (nframes_t start, nframes_t end)
+Editor::reposition_zoom_rect (nframes64_t start, nframes64_t end)
{
double x1 = frame_to_pixel (start);
double x2 = frame_to_pixel (end);
void
Editor::drag_rubberband_select (ArdourCanvas::Item* item, GdkEvent* event)
{
- nframes_t start;
- nframes_t end;
+ nframes64_t start;
+ nframes64_t end;
double y1;
double y2;
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;
}
}
} else {
- selection->clear_tracks();
+ if (!getenv("ARDOUR_SAE")) {
+ selection->clear_tracks();
+ }
selection->clear_regions();
selection->clear_points ();
selection->clear_lines ();
return;
}
- nframes_t newlen = drag_info.last_pointer_frame - clicked_regionview->region()->position();
+ nframes64_t newlen = drag_info.last_pointer_frame - clicked_regionview->region()->position();
float percentage = (double) newlen / (double) clicked_regionview->region()->length();
-
+
#ifndef USE_RUBBERBAND
// Soundtouch uses percentage / 100 instead of normal (/ 1)
if (clicked_regionview->region()->data_type() == DataType::AUDIO) {
percentage = (float) ((double) newlen - (double) clicked_regionview->region()->length()) / ((double) newlen) * 100.0f;
-#endif
}
-
+#endif
+
begin_reversible_command (_("timestretch"));
-
+
// XXX how do timeFX on multiple regions ?
-
+
RegionSelection rs;
rs.add (clicked_regionview);
}
void
-Editor::mouse_brush_insert_region (RegionView* rv, nframes_t pos)
+Editor::mouse_brush_insert_region (RegionView* rv, nframes64_t pos)
{
/* no brushing without a useful snap setting */
- // FIXME
- AudioRegionView* arv = dynamic_cast<AudioRegionView*>(rv);
- assert(arv);
-
switch (snap_mode) {
case SnapMagnetic:
return; /* can't work because it allows region to be placed anywhere */
return;
}
- RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(&arv->get_time_axis_view());
+ RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(&rv->get_time_axis_view());
if (rtv == 0 || !rtv->is_track()) {
return;
double speed = rtv->get_diskstream()->speed();
XMLNode &before = playlist->get_state();
- playlist->add_region (boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (arv->audio_region())), (nframes_t) (pos * speed));
+ playlist->add_region (RegionFactory::create (rv->region()), (nframes64_t) (pos * speed));
XMLNode &after = playlist->get_state();
session->add_command(new MementoCommand<Playlist>(*playlist.get(), &before, &after));
gint
Editor::track_height_step_timeout ()
{
- struct timeval now;
- struct timeval delta;
-
- gettimeofday (&now, 0);
- timersub (&now, &last_track_height_step_timestamp, &delta);
-
- if (delta.tv_sec * 1000000 + delta.tv_usec > 250000) { /* milliseconds */
+ if (get_microseconds() - last_track_height_step_timestamp < 250000) {
current_stepping_trackview = 0;
return false;
}