_last_pointer_x = _drags->current_pointer_x ();
_last_pointer_y = current_pointer_y ();
- _last_pointer_frame = adjusted_current_frame (event);
+ _last_pointer_frame = adjusted_current_frame (event, false);
}
return true;
}
boost::shared_ptr<Region>
-Drag::add_midi_region (MidiTimeAxisView* view)
+Drag::add_midi_region (MidiTimeAxisView* view, bool commit)
{
if (_editor->session()) {
const TempoMap& map (_editor->session()->tempo_map());
might be wrong.
*/
framecnt_t len = m.frames_per_bar (map.tempo_at (pos), _editor->session()->frame_rate());
- return view->add_region (grab_frame(), len, true);
+ return view->add_region (grab_frame(), len, commit);
}
return boost::shared_ptr<Region>();
/* compute the amount of pointer motion in frames, and where
the region would be if we moved it by that much.
*/
- *pending_region_position = adjusted_frame (_drags->current_pointer_frame () + snap_delta (event->button.state), event, true);
+ *pending_region_position = adjusted_frame (_drags->current_pointer_frame (), event, false);
framepos_t sync_frame;
framecnt_t sync_offset;
*/
if (sync_dir >= 0 || (sync_dir < 0 && *pending_region_position >= sync_offset)) {
- sync_frame = *pending_region_position + (sync_dir * sync_offset);
+ framecnt_t const sd = snap_delta (event->button.state);
+ sync_frame = *pending_region_position + (sync_dir * sync_offset) + sd;
_editor->snap_to_with_modifier (sync_frame, event);
- *pending_region_position = _primary->region()->adjust_to_sync (sync_frame) - snap_delta (event->button.state);
+ *pending_region_position = _primary->region()->adjust_to_sync (sync_frame) - sd;
} else {
*pending_region_position = _last_frame_position;
RegionCreateDrag::motion (GdkEvent* event, bool first_move)
{
if (first_move) {
- _region = add_midi_region (_view);
+ _editor->begin_reversible_command (_("create region"));
+ _region = add_midi_region (_view, false);
_view->playlist()->freeze ();
} else {
if (_region) {
framepos_t const f = adjusted_current_frame (event);
if (f < grab_frame()) {
- _region->set_position (f);
+ _region->set_initial_position (f);
}
/* Don't use a zero-length region, and subtract 1 frame from the snapped length
RegionCreateDrag::finished (GdkEvent*, bool movement_occurred)
{
if (!movement_occurred) {
- add_midi_region (_view);
+ add_midi_region (_view, true);
} else {
_view->playlist()->thaw ();
+ _editor->commit_reversible_command();
}
}
Timecode::BBT_Time when;
TempoMap& map (_editor->session()->tempo_map());
- map.bbt_time (last_pointer_frame(), when);
+ map.bbt_time (_marker->position(), when);
if (_copy == true) {
_editor->begin_reversible_command (_("copy meter mark"));
swap_grab (&_marker->the_item(), 0, GDK_CURRENT_TIME);
if (!_copy) {
+ _editor->begin_reversible_command (_("move tempo mark"));
TempoMap& map (_editor->session()->tempo_map());
/* get current state */
before_state = &map.get_state();
motion (event, false);
TempoMap& map (_editor->session()->tempo_map());
- framepos_t beat_time = map.round_to_beat (last_pointer_frame(), RoundNearest);
+ framepos_t beat_time = map.round_to_beat (_marker->position(), RoundNearest);
Timecode::BBT_Time when;
map.bbt_time (beat_time, when);
_editor->commit_reversible_command ();
} else {
- _editor->begin_reversible_command (_("move tempo mark"));
/* we removed it before, so add it back now */
map.add_tempo (_marker->tempo(), when);
XMLNode &after = map.get_state();
, _selection_changed (false)
{
DEBUG_TRACE (DEBUG::Drags, "New MarkerDrag\n");
-
+ Gtk::Window* toplevel = _editor->current_toplevel();
_marker = reinterpret_cast<ArdourMarker*> (_item->get_data ("marker"));
+
assert (_marker);
_points.push_back (ArdourCanvas::Duple (0, 0));
- _points.push_back (ArdourCanvas::Duple (0, physical_screen_height (_editor->get_window())));
+
+ _points.push_back (ArdourCanvas::Duple (0, toplevel ? physical_screen_height (toplevel->get_window()) : 900));
}
MarkerDrag::~MarkerDrag ()
if (move_both || (*x).move_both) {
copy_location->set_start (new_start);
copy_location->set_end (new_end);
- } else if (new_start < copy_location->end()) {
+ } else if (new_start < copy_location->end()) {
copy_location->set_start (new_start);
} else if (newframe > 0) {
//_editor->snap_to (next, RoundUpAlways, true);
}
void
-MarkerDrag::aborted (bool movement_occured)
+MarkerDrag::aborted (bool movement_occurred)
{
- if (!movement_occured) {
+ if (!movement_occurred) {
return;
}
double mx = event->button.x;
double my = event->button.y;
- _line->parent_group().canvas_to_item (mx, my);
+ _line->grab_item().canvas_to_item (mx, my);
framecnt_t const frame_within_region = (framecnt_t) floor (mx * _editor->samples_per_pixel);
Drag::start_grab (event, _editor->cursors()->fader);
- /* store grab start in parent frame */
+ /* store grab start in item frame */
double const bx = _line->nth (_before)->get_x();
double const ax = _line->nth (_after)->get_x();
double const click_ratio = (ax - mx) / (ax - bx);
}
void
-LineDrag::finished (GdkEvent* event, bool movement_occured)
+LineDrag::finished (GdkEvent* event, bool movement_occurred)
{
- if (movement_occured) {
+ if (movement_occurred) {
motion (event, false);
_line->end_drag (false, 0);
_editor->commit_reversible_command ();
AutomationTimeAxisView* atv;
if ((atv = dynamic_cast<AutomationTimeAxisView*>(_editor->clicked_axisview)) != 0) {
- framepos_t where = _editor->canvas_event_sample (event, 0, 0);
+ framepos_t where = grab_frame ();
+
+ double cx = 0;
+ double cy = _fixed_grab_y;
- atv->add_automation_event (event, where, event->button.y, false);
+ _line->grab_item().item_to_canvas (cx, cy);
+
+ atv->add_automation_event (event, where, cy, false);
} else if (dynamic_cast<AudioTimeAxisView*>(_editor->clicked_axisview) != 0) {
AudioRegionView* arv;
if ((arv = dynamic_cast<AudioRegionView*>(_editor->clicked_regionview)) != 0) {
- arv->add_gain_point_event (arv->get_canvas_group (), event, false);
+ arv->add_gain_point_event (&arv->get_gain_line()->grab_item(), event, false);
}
}
}
/* MIDI track */
if (_editor->selection->empty() && _editor->mouse_mode == MouseDraw) {
/* nothing selected */
- add_midi_region (mtv);
+ add_midi_region (mtv, true);
do_deselect = false;
}
}
}
void
-TimeFXDrag::finished (GdkEvent* /*event*/, bool movement_occurred)
+TimeFXDrag::finished (GdkEvent* event, bool movement_occurred)
{
- _primary->get_time_axis_view().hide_timestretch ();
+ /* this may have been a single click, no drag. We still want the dialog
+ to show up in that case, so that the user can manually edit the
+ parameters for the timestretch.
+ */
- if (!movement_occurred) {
- return;
- }
+ float fraction = 1.0;
- if (last_pointer_frame() < _primary->region()->position()) {
- /* backwards drag of the left edge - not usable */
- return;
- }
+ if (movement_occurred) {
+
+ motion (event, false);
+
+ _primary->get_time_axis_view().hide_timestretch ();
+
+ framepos_t adjusted_frame_pos = adjusted_current_frame (event);
+
+ if (adjusted_frame_pos < _primary->region()->position()) {
+ /* backwards drag of the left edge - not usable */
+ return;
+ }
- framecnt_t newlen = last_pointer_frame() - _primary->region()->position();
+ framecnt_t newlen = adjusted_frame_pos - _primary->region()->position();
- float percentage = (double) newlen / (double) _primary->region()->length();
+ fraction = (double) newlen / (double) _primary->region()->length();
#ifndef USE_RUBBERBAND
- // Soundtouch uses percentage / 100 instead of normal (/ 1)
- if (_primary->region()->data_type() == DataType::AUDIO) {
- percentage = (float) ((double) newlen - (double) _primary->region()->length()) / ((double) newlen) * 100.0f;
- }
+ // Soundtouch uses fraction / 100 instead of normal (/ 1)
+ if (_primary->region()->data_type() == DataType::AUDIO) {
+ fraction = (float) ((double) newlen - (double) _primary->region()->length()) / ((double) newlen) * 100.0f;
+ }
#endif
+ }
if (!_editor->get_selection().regions.empty()) {
/* primary will already be included in the selection, and edit
selection.
*/
- if (_editor->time_stretch (_editor->get_selection().regions, percentage) == -1) {
+ if (_editor->time_stretch (_editor->get_selection().regions, fraction) == -1) {
error << _("An error occurred while executing time stretch operation") << endmsg;
}
}
_drag_rect = new ArdourCanvas::Rectangle (_editor->time_line_group,
ArdourCanvas::Rect (0.0, 0.0, 0.0,
- physical_screen_height (_editor->get_window())));
+ physical_screen_height (_editor->current_toplevel()->get_window())));
_drag_rect->hide ();
_drag_rect->set_fill_color (UIConfiguration::instance().color ("range drag rect"));
}
void
-RangeMarkerBarDrag::aborted (bool movement_occured)
+RangeMarkerBarDrag::aborted (bool movement_occurred)
{
- if (movement_occured) {
+ if (movement_occurred) {
_drag_rect->hide ();
}
}
frameoffset_t ret;
if (snap) {
- ret = _region->snap_frame_to_frame (st - rp) + rp - n - snap_delta (state);
+ bool const ensure_snap = _editor->snap_mode () != SnapMagnetic;
+ ret = _region->snap_frame_to_frame (st - rp, ensure_snap) + rp - n - snap_delta (state);
} else {
ret = st - n - snap_delta (state);
}
* odd with them. so show the note value anyway, always.
*/
- char buf[12];
uint8_t new_note = min (max (_primary->note()->note() + note_delta, 0), 127);
- snprintf (buf, sizeof (buf), "%s (%d)", Evoral::midi_note_name (new_note).c_str(),
- (int) floor ((double)new_note));
-
- show_verbose_cursor_text (buf);
+ _region->show_verbose_cursor_for_new_note_value (_primary->note(), new_note);
}
}