#include <pbd/error.h>
#include <gtkmm2ext/utils.h>
+#include <gtkmm2ext/tearoff.h>
#include <pbd/memento_command.h>
#include <pbd/basename.h>
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 ();
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());
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
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;
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;
}
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);
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 if (newframe > 0) {
- snap_to (next, -1, true);
- copy_location->set_start (next);
- copy_location->set_end (newframe);
+ } else { // end marker
+
+ 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) {
- /* 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());
+ }
}
}
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
nframes64_t cx_frames = unit_to_frame (cx);
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;
start_grab (event, fader_cursor);
- const double fraction = 1.0 - ((cy - line->y_position()) / (double)line->height());
+ 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 ();
}
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
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;
drag_info.dest_trackview = drag_info.source_trackview;
// 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)"));
- /*
- the group containing moved regions may have been
- offset during autoscroll. reset its y offset
- (we should really handle this in the same way
- we do with the x axis, but a simple way of achieving that
- eludes me right now).
- */
-
- _region_motion_group->property_y() = 0;
/* sync the canvas to what we think is its current state */
track_canvas->update_now();
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;
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->property_y() = 0;
}
void
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;
- }
-
- const boost::shared_ptr<const Region> original = rv->region();
- boost::shared_ptr<Region> region_copy = RegionFactory::create (original);
+ 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);
hide_verbose_canvas_cursor ();
return false;
}
-
+
return true;
}
{
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
}
rv2->get_canvas_frame()->get_bounds (ix1, iy1, ix2, iy2);
- rv2->get_canvas_group()->i2w (ix1, iy1);
+ rv2->get_canvas_frame()->i2w (ix1, iy1);
iy1 += vertical_adjustment.get_value() - canvas_timebars_vsize;
TimeAxisView* tvp2 = trackview_by_y_position (iy1);
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;
}
double ix1, ix2, iy1, iy2;
rv2->get_canvas_frame()->get_bounds (ix1, iy1, ix2, iy2);
- rv2->get_canvas_group()->i2w (ix1, iy1);
+ rv2->get_canvas_frame()->i2w (ix1, iy1);
if (-x_delta > ix1 + horizontal_adjustment.get_value()) {
// do_move = false;
- cerr << "illegal move" << endl;
x_delta = 0;
pending_region_position = drag_info.last_frame_position;
break;
*/
rv->get_canvas_frame()->get_bounds (ix1, iy1, ix2, iy2);
- rv->get_canvas_group()->i2w (ix1, iy1);
+ rv->get_canvas_frame()->i2w (ix1, iy1);
+
+ cerr << "adjust y from " << iy1 << " using "
+ << vertical_adjustment.get_value() << " - "
+ << canvas_timebars_vsize
+ << endl;
+
+ iy1 += get_trackview_group_vertical_offset ();;
if (drag_info.first_move) {
rv->fake_set_opaque (true);
}
- /* 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 += vertical_adjustment.get_value() - canvas_timebars_vsize;
TimeAxisView* tvp2 = trackview_by_y_position (iy1);
RouteTimeAxisView* canvas_rtv = dynamic_cast<RouteTimeAxisView*>(tvp2);
tvp2 = trackview_by_y_position (iy1 + y_delta);
temp_rtv = dynamic_cast<RouteTimeAxisView*>(tvp2);
- rv->set_y_position_and_height (0, temp_rtv->current_height());
+ rv->set_height (temp_rtv->current_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.
}
}
- /* 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.brushing) {
mouse_brush_insert_region (rv, pending_region_position);
} else {
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;
- /* XXX is this true??? i can''t tell the difference.
- 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 ();
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(); ) {
RegionView* rv = (*i);
double ix1, ix2, iy1, iy2;
rv->get_canvas_frame()->get_bounds (ix1, iy1, ix2, iy2);
- rv->get_canvas_group()->i2w (ix1, iy1);
+ rv->get_canvas_frame()->i2w (ix1, iy1);
iy1 += vertical_adjustment.get_value() - canvas_timebars_vsize;
TimeAxisView* dest_tv = trackview_by_y_position (iy1);
RouteTimeAxisView* dest_rtv = dynamic_cast<RouteTimeAxisView*>(dest_tv);
- double speed;
- bool changed_tracks, changed_position;
nframes64_t where;
if (rv->region()->locked()) {
++i;
continue;
}
-
- /* adjust for track speed */
-
- speed = 1.0;
- if (dest_rtv && dest_rtv->get_diskstream()) {
- speed = dest_rtv->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) {
- _master_group->w2i(ix1, iy1);
- where = (nframes64_t) (unit_to_frame (ix1) * speed);
+ 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();