_old_follow_playhead = _editor->follow_playhead ();
_editor->set_follow_playhead (false);
- _current_pointer_frame = _editor->event_frame (e, &_current_pointer_x, &_current_pointer_y);
+ _current_pointer_frame = _editor->canvas_event_frame (e, &_current_pointer_x, &_current_pointer_y);
for (list<Drag*>::const_iterator i = _drags.begin(); i != _drags.end(); ++i) {
(*i)->start_grab (e, c);
{
bool r = false;
- _current_pointer_frame = _editor->event_frame (e, &_current_pointer_x, &_current_pointer_y);
+ _current_pointer_frame = _editor->canvas_event_frame (e, &_current_pointer_x, &_current_pointer_y);
+
+ for (list<Drag*>::iterator i = _drags.begin(); i != _drags.end(); ++i) {
+ bool const t = (*i)->motion_handler (e, from_autoscroll);
+ if (t) {
+ r = true;
+ }
+
+ }
+
+ return r;
+}
+
+bool
+DragManager::window_motion_handler (GdkEvent* e, bool from_autoscroll)
+{
+ bool r = false;
+
+ _current_pointer_frame = _editor->window_event_frame (e, &_current_pointer_x, &_current_pointer_y);
for (list<Drag*>::iterator i = _drags.begin(); i != _drags.end(); ++i) {
bool const t = (*i)->motion_handler (e, from_autoscroll);
_y_constrained = false;
}
- _raw_grab_frame = _editor->event_frame (event, &_grab_x, &_grab_y);
+ _raw_grab_frame = _editor->canvas_event_frame (event, &_grab_x, &_grab_y);
setup_pointer_frame_offset ();
_grab_frame = adjusted_frame (_raw_grab_frame, event);
_last_pointer_frame = _grab_frame;
_brushing (b),
_total_x_delta (0)
{
-
+ DEBUG_TRACE (DEBUG::Drags, "New RegionMotionDrag\n");
}
-
void
RegionMotionDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
{
if ((*pending_region_position != _last_frame_position) && x_move_allowed) {
/* x movement since last time (in pixels) */
- dx = (static_cast<double> (*pending_region_position) - _last_frame_position) / _editor->frames_per_pixel;
+ dx = (static_cast<double> (*pending_region_position) - _last_frame_position) / _editor->samples_per_pixel;
/* total x movement */
framecnt_t total_dx = *pending_region_position;
double const x_delta = compute_x_delta (event, &pending_region_position);
/* Work out the change in y */
+
int delta_time_axis_view = current_pointer_time_axis_view - _last_pointer_time_axis_view;
double delta_layer = current_pointer_layer - _last_pointer_layer;
rv->drag_start ();
- /* Absolutely no idea why this is necessary, but it is; without
- it, the region view disappears after the reparent.
- */
- _editor->update_canvas_now ();
-
/* Reparent to a non scrolling group so that we can keep the
region selection above all time axis views.
Reparenting means that we will have to move the region view
- later, as the two parent groups have different coordinates.
+ within its new parent, as the two parent groups have different coordinates.
*/
+ ArdourCanvas::Group* rvg = rv->get_canvas_group();
+ Duple rv_canvas_offset = rvg->item_to_canvas (Duple (0,0));
+
rv->get_canvas_group()->reparent (_editor->_region_motion_group);
-
+
rv->fake_set_opaque (true);
+ rvg->set_position (rv_canvas_offset);
}
/* If we have moved tracks, we'll fudge the layer delta so that the
/* Get the y coordinate of the top of the track that this region is now on */
tv->canvas_display()->item_to_canvas (x, y);
- y += _editor->get_trackview_group_vertical_offset();
-
+
/* And adjust for the layer that it should be on */
StreamView* cv = tv->view ();
switch (cv->layer_display ()) {
_views = new_regionviews;
swap_grab (new_regionviews.front().view->get_canvas_group (), 0, event ? event->motion.time : 0);
-
- /*
- 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 taking so long?
- */
- _editor->update_canvas_now();
}
}
bool const changed_tracks = (_time_axis_views[_views.front().time_axis_view] != &_views.front().view->get_time_axis_view());
framecnt_t const drag_delta = _primary->region()->position() - _last_frame_position;
- _editor->update_canvas_now ();
-
if (_copy) {
finished_copy (
rv->move (-_total_x_delta, 0);
rv->set_height (rtv->view()->child_height ());
}
-
- _editor->update_canvas_now ();
}
/** @param b true to brush, otherwise false.
void
RegionInsertDrag::finished (GdkEvent *, bool)
{
- _editor->update_canvas_now ();
-
RouteTimeAxisView* dest_rtv = dynamic_cast<RouteTimeAxisView*> (_time_axis_views[_views.front().time_axis_view]);
_primary->get_canvas_group()->reparent (dest_rtv->view()->canvas_item());
DEBUG_TRACE (DEBUG::Drags, string_compose("SHIFT REGION at %1 by %2\n", i->initial_position, dt));
if (first_move) {
rv->drag_start ();
- _editor->update_canvas_now ();
rv->fake_set_opaque (true);
rv->region()->clear_changes ();
rv->region()->suspend_property_changes();
_editor->commit_reversible_command ();
- _editor->update_canvas_now ();
}
void
TimeAxisView* tvp = &_primary->get_time_axis_view ();
RouteTimeAxisView* tv = dynamic_cast<RouteTimeAxisView*>(tvp);
pair<set<boost::shared_ptr<Playlist> >::iterator,bool> insert_result;
+ frameoffset_t frame_delta = 0;
if (tv && tv->is_track()) {
speed = tv->track()->speed();
boost::shared_ptr<AudioRegion> ar (arv->audio_region());
distance = _drags->current_pointer_x() - grab_x();
len = ar->fade_in()->back()->when;
- new_length = len - _editor->unit_to_frame (distance);
+ new_length = len - _editor->pixel_to_sample (distance);
new_length = ar->verify_xfade_bounds (new_length, true /*START*/ );
arv->reset_fade_in_shape_width (ar, new_length); //the grey shape
}
boost::shared_ptr<AudioRegion> ar (arv->audio_region());
distance = grab_x() - _drags->current_pointer_x();
len = ar->fade_out()->back()->when;
- new_length = len - _editor->unit_to_frame (distance);
+ new_length = len - _editor->pixel_to_sample (distance);
new_length = ar->verify_xfade_bounds (new_length, false /*END*/ );
arv->reset_fade_out_shape_width (ar, new_length); //the grey shape
}
case ContentsTrim:
{
- bool swap_direction = false;
-
- if (event && Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) {
- swap_direction = true;
- }
-
- framecnt_t frame_delta = 0;
-
- bool left_direction = false;
- if (last_pointer_frame() > adjusted_current_frame(event)) {
- left_direction = true;
- }
-
- if (left_direction) {
- frame_delta = (last_pointer_frame() - adjusted_current_frame(event));
- } else {
- frame_delta = (adjusted_current_frame(event) - last_pointer_frame());
- }
+ frame_delta = (adjusted_current_frame(event) - last_pointer_frame());
+ // frame_delta = (last_pointer_frame() - adjusted_current_frame(event));
for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ++i) {
- i->view->trim_contents (frame_delta, left_direction, swap_direction);
+ i->view->move_contents (frame_delta);
}
}
break;
show_verbose_cursor_time ((framepos_t) (rv->region()->last_frame() / speed));
break;
case ContentsTrim:
- show_verbose_cursor_time (adjusted_current_frame (event));
+ // show_verbose_cursor_time (frame_delta);
break;
}
}
boost::shared_ptr<AudioRegion> ar (arv->audio_region());
distance = _drags->current_pointer_x() - grab_x();
len = ar->fade_in()->back()->when;
- new_length = len - _editor->unit_to_frame (distance);
+ new_length = len - _editor->pixel_to_sample (distance);
new_length = ar->verify_xfade_bounds (new_length, true /*START*/ );
ar->set_fade_in_length(new_length);
}
boost::shared_ptr<AudioRegion> ar (arv->audio_region());
distance = _drags->current_pointer_x() - grab_x();
len = ar->fade_out()->back()->when;
- new_length = len - _editor->unit_to_frame (distance);
+ new_length = len - _editor->pixel_to_sample (distance);
new_length = ar->verify_xfade_bounds (new_length, false /*END*/ );
ar->set_fade_out_length(new_length);
}
_marker = new MeterMarker (
*_editor,
*_editor->meter_group,
- ARDOUR_UI::config()->canvasvar_MeterMarker.get(),
+ ARDOUR_UI::config()->get_canvasvar_MeterMarker(),
name,
*new MeterSection (_marker->meter())
);
_marker = new TempoMarker (
*_editor,
*_editor->tempo_group,
- ARDOUR_UI::config()->canvasvar_TempoMarker.get(),
+ ARDOUR_UI::config()->get_canvasvar_TempoMarker(),
name,
*new TempoSection (_marker->tempo())
);
}
}
-CursorDrag::CursorDrag (Editor* e, ArdourCanvas::Item* i, bool s)
- : Drag (e, i),
- _stop (s)
+CursorDrag::CursorDrag (Editor* e, EditorCursor& c, bool s)
+ : Drag (e, &c.time_bar_canvas_item())
+ , _cursor (c)
+ , _stop (s)
{
DEBUG_TRACE (DEBUG::Drags, "New CursorDrag\n");
}
{
Drag::start_grab (event, c);
- _grab_zoom = _editor->frames_per_pixel;
+ _grab_zoom = _editor->samples_per_pixel;
+
+ framepos_t where = _editor->canvas_event_frame (event, 0, 0);
- framepos_t where = _editor->event_frame (event, 0, 0);
_editor->snap_to_with_modifier (where, event);
_editor->_dragging_playhead = true;
Session* s = _editor->session ();
+ /* grab the track canvas item as well */
+
+ _cursor.track_canvas_item().grab();
+
if (s) {
if (_was_rolling && _stop) {
s->request_stop ();
framepos_t const adjusted_frame = adjusted_current_frame (event);
if (adjusted_frame != last_pointer_frame()) {
fake_locate (adjusted_frame);
-#ifdef GTKOSX
- _editor->update_canvas_now ();
-#endif
}
}
{
_editor->_dragging_playhead = false;
+ _cursor.track_canvas_item().ungrab();
+
if (!movement_occurred && _stop) {
return;
}
void
CursorDrag::aborted (bool)
{
+ _cursor.track_canvas_item().ungrab();
+
if (_editor->_dragging_playhead) {
_editor->session()->request_resume_timecode_transmission ();
_editor->_dragging_playhead = false;
assert (!_copied_locations.empty());
show_verbose_cursor_time (newframe);
-
-#ifdef GTKOSX
- _editor->update_canvas_now ();
-#endif
}
void
cy = max (0.0, cy);
cy = min ((double) _point->line().height(), cy);
- framepos_t cx_frames = _editor->unit_to_frame (cx);
+ framepos_t cx_frames = _editor->pixel_to_sample (cx);
if (!_x_constrained) {
_editor->snap_to_with_modifier (cx_frames, event);
float const fraction = 1.0 - (cy / _point->line().height());
- _point->line().drag_motion (_editor->frame_to_unit_unrounded (cx_frames), fraction, false, _pushing, _final_index);
+ _point->line().drag_motion (_editor->sample_to_pixel_unrounded (cx_frames), fraction, false, _pushing, _final_index);
_editor->verbose_cursor()->set_text (_point->line().get_verbose_cursor_string (fraction));
}
_line->parent_group().canvas_to_item (cx, cy);
- framecnt_t const frame_within_region = (framecnt_t) floor (cx * _editor->frames_per_pixel);
+ framecnt_t const frame_within_region = (framecnt_t) floor (cx * _editor->samples_per_pixel);
uint32_t before;
uint32_t after;
_arv = reinterpret_cast<AudioRegionView*> (_item->get_data ("regionview"));
- _max_x = _editor->frame_to_pixel(_arv->get_duration());
+ _max_x = _editor->sample_to_pixel(_arv->get_duration());
}
void
cx = 0;
}
- boost::optional<Rect> bbox = _line->bounding_box ();
+ boost::optional<ArdourCanvas::Rect> bbox = _line->bounding_box ();
assert (bbox);
_line->set (ArdourCanvas::Duple (cx, 2.0), ArdourCanvas::Duple (cx, bbox.get().height ()));
if (start != end || y1 != y2) {
- double x1 = _editor->frame_to_pixel (start);
- double x2 = _editor->frame_to_pixel (end);
+ double x1 = _editor->sample_to_pixel (start);
+ double x2 = _editor->sample_to_pixel (end);
_editor->rubberband_rect->set_x0 (x1);
if (_vertical_only) {
_editor->rubberband_rect->set_y0 (y1);
_editor->rubberband_rect->set_y1 (y2);
-
+
_editor->rubberband_rect->show();
_editor->rubberband_rect->raise_to_top();
physical_screen_height (_editor->get_window())));
_drag_rect->hide ();
- _drag_rect->set_fill_color (ARDOUR_UI::config()->canvasvar_RangeDragRect.get());
- _drag_rect->set_outline_color (ARDOUR_UI::config()->canvasvar_RangeDragRect.get());
+ _drag_rect->set_fill_color (ARDOUR_UI::config()->get_canvasvar_RangeDragRect());
+ _drag_rect->set_outline_color (ARDOUR_UI::config()->get_canvasvar_RangeDragRect());
}
void
if (start != end) {
_editor->temp_location->set (start, end);
- double x1 = _editor->frame_to_pixel (start);
- double x2 = _editor->frame_to_pixel (end);
+ double x1 = _editor->sample_to_pixel (start);
+ double x2 = _editor->sample_to_pixel (end);
crect->set_x0 (x1);
crect->set_x1 (x2);
void
RangeMarkerBarDrag::update_item (Location* location)
{
- double const x1 = _editor->frame_to_pixel (location->start());
- double const x2 = _editor->frame_to_pixel (location->end());
+ double const x1 = _editor->sample_to_pixel (location->start());
+ double const x2 = _editor->sample_to_pixel (location->end());
_drag_rect->set_x0 (x1);
_drag_rect->set_x1 (x2);
NoteDrag::total_dx () const
{
/* dx in frames */
- frameoffset_t const dx = _editor->unit_to_frame (_drags->current_pointer_x() - grab_x());
+ frameoffset_t const dx = _editor->pixel_to_sample (_drags->current_pointer_x() - grab_x());
/* primary note time */
frameoffset_t const n = _region->source_beats_to_absolute_frames (_primary->note()->time ());
int8_t const dy = total_dy ();
/* Now work out what we have to do to the note canvas items to set this new drag delta */
- double const tdx = _editor->frame_to_unit (dx) - _cumulative_dx;
+ double const tdx = _editor->sample_to_pixel (dx) - _cumulative_dx;
double const tdy = -dy * _note_height - _cumulative_dy;
if (tdx || tdy) {
f = min (f, r->last_frame ());
framecnt_t const dxf = f - grab_frame(); // permitted dx in frames
- double const dxu = _editor->frame_to_unit (dxf); // permitted fx in units
+ double const dxu = _editor->sample_to_pixel (dxf); // permitted fx in units
_patch_change->move (ArdourCanvas::Duple (dxu - _cumulative_dx, 0));
_cumulative_dx = dxu;
}
}
MidiRubberbandSelectDrag::MidiRubberbandSelectDrag (Editor* e, MidiRegionView* rv)
- : RubberbandSelectDrag (e, rv->get_canvas_frame ())
+ : RubberbandSelectDrag (e, rv->get_canvas_group ())
, _region_view (rv)
{
y2 = max (0.0, y2 - y);
_region_view->update_drag_selection (
- _editor->frame_to_pixel (x1),
- _editor->frame_to_pixel (x2),
+ _editor->sample_to_pixel (x1),
+ _editor->sample_to_pixel (x2),
y1,
y2,
Keyboard::modifier_state_contains (button_state, Keyboard::TertiaryModifier)
}
MidiVerticalSelectDrag::MidiVerticalSelectDrag (Editor* e, MidiRegionView* rv)
- : RubberbandSelectDrag (e, rv->get_canvas_frame ())
+ : RubberbandSelectDrag (e, rv->get_canvas_group ())
, _region_view (rv)
{
_vertical_only = true;
_note[0] = adjusted_frame (pf, event) - _region_view->region()->position ();
MidiStreamView* sv = _region_view->midi_stream_view ();
- double const x = _editor->frame_to_pixel (_note[0]);
+ double const x = _editor->sample_to_pixel (_note[0]);
double const y = sv->note_to_y (sv->y_to_note (y_to_region (event->button.y)));
_drag_rect->set (ArdourCanvas::Rect (x, y, x, y + floor (_region_view->midi_stream_view()->note_height ())));
NoteCreateDrag::motion (GdkEvent* event, bool)
{
_note[1] = max ((framepos_t)0, adjusted_current_frame (event) - _region_view->region()->position ());
- double const x = _editor->frame_to_pixel (_note[1]);
+ double const x = _editor->sample_to_pixel (_note[1]);
if (_note[1] > _note[0]) {
_drag_rect->set_x1 (x);
} else {
/* how long should it be ? */
- new_length = len + _editor->unit_to_frame (distance);
+ new_length = len + _editor->pixel_to_sample (distance);
/* now check with the region that this is legal */
new_length = ar->verify_xfade_bounds (new_length, start);
if (start) {
- arv->redraw_start_xfade_to (ar, new_length);
+ arv->reset_fade_in_shape_width (ar, new_length);
} else {
- arv->redraw_end_xfade_to (ar, new_length);
+ arv->reset_fade_out_shape_width (ar, new_length);
}
}
len = ar->fade_out()->back()->when;
}
- new_length = ar->verify_xfade_bounds (len + _editor->unit_to_frame (distance), start);
+ new_length = ar->verify_xfade_bounds (len + _editor->pixel_to_sample (distance), start);
_editor->begin_reversible_command ("xfade trim");
ar->playlist()->clear_owned_changes ();