_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());
framecnt_t pos = grab_frame();
- const Meter& m = map.meter_at (pos);
/* not that the frame rate used here can be affected by pull up/down which
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);
+ framecnt_t len = map.frame_at_beat (map.beat_at_frame (pos) + 1.0) - pos;
+ 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"));
DEBUG_TRACE (DEBUG::Drags, "New TempoMarkerDrag\n");
_marker = reinterpret_cast<TempoMarker*> (_item->get_data ("marker"));
+ _real_section = &_marker->tempo();
assert (_marker);
}
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();
/* remove the section while we drag it */
- map.remove_tempo (section, true);
+ //map.remove_tempo (section, true);
}
}
- framepos_t const pf = adjusted_current_frame (event);
+ framepos_t const pf = adjusted_current_frame (event, false);
+ TempoMap& map (_editor->session()->tempo_map());
_marker->set_position (pf);
+ map.gui_set_tempo_frame (*_real_section, pf);
+
show_verbose_cursor_time (pf);
}
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);
if (_copy == true) {
_editor->begin_reversible_command (_("copy tempo mark"));
XMLNode &before = map.get_state();
- map.add_tempo (_marker->tempo(), when);
+ map.add_tempo (_marker->tempo(), when, _marker->tempo().type());
XMLNode &after = map.get_state();
_editor->session()->add_command (new MementoCommand<TempoMap>(map, &before, &after));
_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);
+ map.replace_tempo (*_real_section, _marker->tempo().beats_per_minute() , when, _marker->tempo().type());
XMLNode &after = map.get_state();
_editor->session()->add_command (new MementoCommand<TempoMap>(map, before_state, &after));
_editor->commit_reversible_command ();
if (moved) {
TempoMap& map (_editor->session()->tempo_map());
/* we removed it before, so add it back now */
- map.add_tempo (_marker->tempo(), _marker->tempo().start());
+ map.add_tempo (_marker->tempo(), _marker->tempo().start(), _marker->tempo().type());
// delete the dummy marker we used for visual representation while moving.
// a new visual marker will show up automatically.
delete _marker;
, _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;
}
}
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 ();
/* 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 ();
}
}
* 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);
}
}