+
/*
Copyright (C) 2000-2001 Paul Davis
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
{
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)) {
}
}
}
-
+
Selection::Operation op = Keyboard::selection_type (event->button.state);
bool press = (event->type == GDK_BUTTON_PRESS);
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;
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 {
}
button_selection (item, event, item_type);
-
+
+ //ctrl-drag or right-click-drag on a "range" ruler should start a range drag
+ if (event->type == GDK_BUTTON_PRESS) {
+ if (event->button.button == 3 || ( (event->button.button == 1) && (Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier) ))) {
+ if (item_type == TransportMarkerBarItem) {
+ start_range_markerbar_op (item, event, CreateTransportMarker);
+ return true;
+ }
+ if (item_type == RangeMarkerBarItem) {
+ start_range_markerbar_op (item, event, CreateRangeMarker);
+ return true;
+ }
+ if (item_type == CdMarkerBarItem) {
+ start_range_markerbar_op (item, event, CreateCDMarker);
+ return true;
+ }
+ }
+ }
+
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:
- return true;
-
+ case TransportMarkerBarItem:
case RangeMarkerBarItem:
- start_range_markerbar_op (item, event, CreateRangeMarker);
- return true;
- break;
-
case CdMarkerBarItem:
- 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);
+ }
return true;
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 GainAutomationControlPointItem:
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 GainControlPointItem:
{
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:
case CdMarkerBarItem:
case TempoBarItem:
case MeterBarItem:
- popup_ruler_menu (pixel_to_frame(event->button.x), item_type);
+ popup_ruler_menu (where, item_type);
break;
case MarkerItem:
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());
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;
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);
}
switch (item_type) {
case PlayheadCursorItem:
case MarkerItem:
+ case MarkerBarItem:
+ case TempoBarItem:
+ case MeterBarItem:
+ case RangeMarkerBarItem:
+ case TransportMarkerBarItem:
+ case CdMarkerBarItem:
case GainControlPointItem:
case RedirectAutomationControlPointItem:
case GainAutomationControlPointItem:
case MarkerViewHandleEndItem:
/* </CMT Additions> */
if (drag_info.item && (event->motion.state & Gdk::BUTTON1_MASK ||
+ (event->motion.state & Gdk::BUTTON3_MASK) ||
(event->motion.state & Gdk::BUTTON2_MASK))) {
if (!from_autoscroll) {
- maybe_autoscroll (&event->motion);
+ 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 (!from_autoscroll) {
maybe_autoscroll (&event->motion);
}
- (this->*(drag_info.motion_callback)) (item, event);
+ if (drag_info.motion_callback) {
+ (this->*(drag_info.motion_callback)) (item, event);
+ }
goto handled;
}
goto not_handled;
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;
- }
+ range_marker_drag_rect->hide();
+ drag_info.clear_copied_locations ();
}
void
// 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;
return false;
}
- drag_info.item->ungrab (event->button.time);
+ drag_info.item->ungrab (event ? event->button.time : 0);
- if (drag_info.finished_callback) {
+ if (drag_info.finished_callback && event) {
drag_info.last_pointer_x = drag_info.current_pointer_x;
drag_info.last_pointer_y = drag_info.current_pointer_y;
(this->*(drag_info.finished_callback)) (item, event);
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)
{
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)
{
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;
}
_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)
{
- nframes64_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;
- nframes64_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 {
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();
+ }
+ if (Profile->get_sae()) {
+ edit_point_clock.set (drag_info.copied_locations.front()->start());
+ }
show_verbose_time_cursor (newframe, 10);
+
+#ifdef GTKOSX
+ track_canvas->update_now ();
+#endif
}
void
Editor::marker_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event)
{
if (drag_info.first_move) {
- /* just a click, do nothing but whatever selection occured */
+
+ /* 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());
+ }
}
}
drag_info.grab_x = control_point->get_x();
drag_info.grab_y = control_point->get_y();
control_point->line.parent_group().i2w(drag_info.grab_x, drag_info.grab_y);
- track_canvas->w2c(drag_info.grab_x, drag_info.grab_y,
- drag_info.grab_x, drag_info.grab_y);
+ track_canvas->w2c(drag_info.grab_x, drag_info.grab_y, drag_info.grab_x, drag_info.grab_y);
drag_info.grab_frame = pixel_to_frame(drag_info.grab_x);
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 ();
}
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 = (nframes64_t) floor (cx * frames_per_unit);
if (!line->control_points_adjacent (frame_within_region, current_line_drag_info.before,
start_grab (event, fader_cursor);
+ /* 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);
-
- // make sure we hit zero when passing through
- if ((cy < zero_gain_y and (cy - dy) > zero_gain_y)
- or (cy > zero_gain_y and (cy - dy) < zero_gain_y)) {
- cy = 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);
- double fraction;
- fraction = 1.0 - (cy / line->height());
+ double fraction = 1.0 - (cy / line->height());
bool push;
show_verbose_time_cursor (drag_info.last_frame_position, 10);
begin_reversible_command (_("move region(s)"));
+
+ _region_motion_group->raise_to_top ();
+
+ /* sync the canvas to what we think is its current state */
+ track_canvas->update_now();
}
void
drag_info.motion_callback = &Editor::region_drag_motion_callback;
drag_info.finished_callback = &Editor::region_drag_finished_callback;
show_verbose_time_cursor (drag_info.last_frame_position, 10);
+ _region_motion_group->raise_to_top ();
}
void
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;
AudioRegionView* arv;
- rv = (*i);
-
-
- if ((arv = dynamic_cast<AudioRegionView*>(rv)) == 0) {
+ if ((arv = dynamic_cast<AudioRegionView*>(*i)) == 0) {
/* XXX handle MIDI here */
continue;
}
-
+
const boost::shared_ptr<const Region> original = arv->region();
boost::shared_ptr<Region> region_copy = RegionFactory::create (original);
boost::shared_ptr<AudioRegion> ar = boost::dynamic_pointer_cast<AudioRegion> (region_copy);
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();
}
}
{
double x_delta;
double y_delta = 0;
- RegionView* rv = reinterpret_cast<RegionView*> (drag_info.data);
nframes64_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
}
original_pointer_order = drag_info.dest_trackview->order;
-
+
/************************************************************
Y-Delta Computation
************************************************************/
int32_t children = 0, numtracks = 0;
// XXX hard coding track limit, oh my, so very very bad
- bitset <1024> tracks (0x00);
+ bitset <1024> tracks (0x00ul);
/* get a bitmask representing the visible tracks */
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
rv2->get_canvas_frame()->get_bounds (ix1, iy1, ix2, iy2);
rv2->get_canvas_group()->i2w (ix1, iy1);
+ iy1 += vertical_adjustment.get_value() - canvas_timebars_vsize;
+
TimeAxisView* tvp2 = trackview_by_y_position (iy1);
RouteTimeAxisView* atv2 = dynamic_cast<RouteTimeAxisView*>(tvp2);
/* 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) {
nframes64_t sync_frame;
nframes64_t sync_offset;
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;
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;
- }
+ 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 ) {
+ 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* 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 (-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;
}
trackviews. 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) {
rv->get_canvas_frame()->get_bounds (ix1, iy1, ix2, iy2);
rv->get_canvas_group()->i2w (ix1, iy1);
+
+ /* for evaluation of the track position of iy1, we have to adjust
+ to allow for the vertical scrolling adjustment and the height of the timebars.
+ */
+
+ 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);
+ }
+
TimeAxisView* tvp2 = trackview_by_y_position (iy1);
AudioTimeAxisView* canvas_atv = dynamic_cast<AudioTimeAxisView*>(tvp2);
AudioTimeAxisView* temp_atv;
}
}
-
- /* 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();
- }
-
-
- if (drag_info.first_move) {
-
- /* hide any dependent views */
-
- rv->get_time_axis_view().hide_dependent_views (*rv);
-
- /* this is subtle. raising the regionview itself won't help,
- because raise_to_top() just puts the item on the top of
- its parent's stack. so, we need to put the trackview canvas_display group
- on the top, since its parent is the whole canvas.
- */
-
- rv->get_canvas_group()->raise_to_top();
- rv->get_time_axis_view().canvas_display->raise_to_top();
- cursor_group->raise_to_top();
- rv->fake_set_opaque (true);
- }
-
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 */
vector<RegionView*> new_selection;
typedef set<boost::shared_ptr<Playlist> > PlaylistSet;
PlaylistSet modified_playlists;
- pair<PlaylistSet::iterator,bool> insert_result;
+ 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;
/* 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 ();
the drag.
*/
- if (Config->get_edit_mode() == Lock && !drag_info.copy) {
+ if (Config->get_edit_mode() == Lock) {
drag_info.x_constrained = !drag_info.x_constrained;
}
}
begin_reversible_command (op_string);
+ changed_position = (drag_info.last_frame_position != (nframes64_t) (clicked_regionview->region()->position()));
+ changed_tracks = (trackview_by_y_position (drag_info.current_pointer_y) != &clicked_regionview->get_time_axis_view());
+
+ drag_delta = clicked_regionview->region()->position() - drag_info.last_frame_position;
+
+ track_canvas->update_now ();
for (list<RegionView*>::const_iterator i = selection->regions.by_layer().begin(); i != selection->regions.by_layer().end(); ) {
double ix1, ix2, iy1, iy2;
rv->get_canvas_frame()->get_bounds (ix1, iy1, ix2, iy2);
rv->get_canvas_group()->i2w (ix1, iy1);
+ iy1 += vertical_adjustment.get_value() - canvas_timebars_vsize;
+
TimeAxisView* dest_tv = trackview_by_y_position (iy1);
AudioTimeAxisView* dest_atv = dynamic_cast<AudioTimeAxisView*>(dest_tv);
- double speed;
- bool changed_tracks;
- bool changed_position;
nframes64_t where;
if (rv->region()->locked()) {
continue;
}
- /* adjust for track speed */
-
- speed = 1.0;
-
- if (dest_atv && dest_atv->get_diskstream()) {
- speed = dest_atv->get_diskstream()->speed();
- }
-
- changed_position = (drag_info.last_frame_position != (nframes64_t) (rv->region()->position()/speed));
- changed_tracks = (dest_tv != &rv->get_time_axis_view());
-
if (changed_position && !drag_info.x_constrained) {
- where = (nframes64_t) (unit_to_frame (ix1) * speed);
+ where = rv->region()->position() - drag_delta;
} else {
where = rv->region()->position();
}
- /* undo the previous hide_dependent_views so that xfades don't
- disappear on copying regions
- */
-
- rv->get_time_axis_view().reveal_dependent_views (*rv);
-
boost::shared_ptr<Region> new_region;
if (drag_info.copy) {
/* we already made a copy */
new_region = rv->region();
- } else {
+
+ /* 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) {
new_region = RegionFactory::create (rv->region());
}
insert_result = modified_playlists.insert (to_playlist);
if (insert_result.second) {
- session->add_command (new MementoCommand<Playlist>(*to_playlist, &to_playlist->get_state(), 0));
+ session->add_command (new MementoCommand<Playlist>(*to_playlist, &to_playlist->get_state(), 0));
}
to_playlist->add_region (new_region, where);
if (!latest_regionviews.empty()) {
// XXX why just the first one ? we only expect one
- dest_atv->reveal_dependent_views (*latest_regionviews.front());
+ //dest_atv->reveal_dependent_views (*latest_regionviews.front());
new_selection.push_back (latest_regionviews.front());
}
} 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.
+ */
+
+ RouteTimeAxisView* dest_rtv = dynamic_cast<RouteTimeAxisView*> (dest_atv);
+ 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_atv->playlist();
insert_result = modified_playlists.insert (playlist);
if (insert_result.second) {
- session->add_command (new MementoCommand<Playlist>(*playlist, &playlist->get_state(), 0));
+ session->add_command (new MementoCommand<Playlist>(*playlist, &playlist->get_state(), 0));
+ }
+ /* 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();
}
rv->region()->set_position (where, (void*) this);
insert_result = modified_playlists.insert (from_playlist);
if (insert_result.second) {
- session->add_command (new MementoCommand<Playlist>(*from_playlist, &from_playlist->get_state(), 0));
+ session->add_command (new MementoCommand<Playlist>(*from_playlist, &from_playlist->get_state(), 0));
}
from_playlist->remove_region ((rv->region()));
copies.push_back (rv);
}
}
-
if (new_selection.empty()) {
if (drag_info.copy) {
*/
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 (vector<RegionView*>::iterator x = copies.begin(); x != copies.end(); ++x) {
delete *x;
}
+
}
void
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 ();
}
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 (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 ();