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());
+ framecnt_t len = map.frame_at_beat (map.beat_at_frame (pos) + 1.0) - pos;
return view->add_region (grab_frame(), len, commit);
}
DEBUG_TRACE (DEBUG::Drags, "New MeterMarkerDrag\n");
_marker = reinterpret_cast<MeterMarker*> (_item->get_data ("marker"));
assert (_marker);
+ _real_section = &_marker->meter();
+
}
void
// leave or lose the original marker (leave if its a copy; lose if its
// not, because we'll remove it from the map).
+ char name[64];
+ snprintf (name, sizeof(name), "%g/%g", _marker->meter().divisions_per_bar(), _marker->meter().note_divisor ());
+
MeterSection section (_marker->meter());
if (!section.movable()) {
return;
}
- char name[64];
- snprintf (name, sizeof(name), "%g/%g", _marker->meter().divisions_per_bar(), _marker->meter().note_divisor ());
-
_marker = new MeterMarker (
*_editor,
*_editor->meter_group,
swap_grab (&_marker->the_item(), 0, GDK_CURRENT_TIME);
if (!_copy) {
+ _editor->begin_reversible_command (_("move meter mark"));
TempoMap& map (_editor->session()->tempo_map());
/* get current state */
before_state = &map.get_state();
/* remove the section while we drag it */
- map.remove_meter (section, true);
+ //map.remove_meter (section, true);
}
+ _marker->hide();
}
framepos_t const pf = adjusted_current_frame (event);
_marker->set_position (pf);
+ _editor->session()->tempo_map().gui_move_meter (_real_section, _marker->meter(), pf);
+
show_verbose_cursor_time (pf);
}
if (_copy == true) {
_editor->begin_reversible_command (_("copy meter mark"));
XMLNode &before = map.get_state();
- map.add_meter (_marker->meter(), when);
+
+ if (_marker->meter().position_lock_style() == AudioTime) {
+ map.add_meter (_marker->meter(), _marker->position());
+ } else {
+ map.add_meter (_marker->meter(), map.bbt_to_beats (when), when);
+ }
+
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 meter mark"));
-
/* we removed it before, so add it back now */
+ if (_marker->meter().position_lock_style() == AudioTime) {
+ map.add_meter (_marker->meter(), _marker->position());
+ } else {
+ map.add_meter (_marker->meter(), map.beat_at_frame (_marker->position()), when);
+ }
- map.add_meter (_marker->meter(), when);
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_meter (_marker->meter(), _marker->meter().frame());
+ map.add_meter (_marker->meter(), map.beat_at_frame (_marker->meter().frame()), _marker->meter().bbt());
// delete the dummy marker we used for visual representation while moving.
// a new visual marker will show up automatically.
delete _marker;
DEBUG_TRACE (DEBUG::Drags, "New TempoMarkerDrag\n");
_marker = reinterpret_cast<TempoMarker*> (_item->get_data ("marker"));
+ _real_section = &_marker->tempo();
assert (_marker);
}
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);
}
+ _marker->hide();
}
- framepos_t const pf = adjusted_current_frame (event);
+ framepos_t const pf = adjusted_current_frame (event, false);
+ Tempo const tp = _marker->tempo();
_marker->set_position (pf);
+ _editor->session()->tempo_map().gui_move_tempo (_real_section, tp, pf);
+
show_verbose_cursor_time (pf);
}
return;
}
- motion (event, false);
+ //motion (event, false);
TempoMap& map (_editor->session()->tempo_map());
- 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);
+
+ if (_marker->tempo().position_lock_style() == MusicTime) {
+ map.add_tempo (_marker->tempo(), _real_section->beat(), _marker->tempo().type());
+ } else {
+ map.add_tempo (_marker->tempo(), _real_section->frame(), _marker->tempo().type());
+ }
+
XMLNode &after = map.get_state();
_editor->session()->add_command (new MementoCommand<TempoMap>(map, &before, &after));
_editor->commit_reversible_command ();
} else {
/* we removed it before, so add it back now */
- map.add_tempo (_marker->tempo(), when);
+ if (_marker->tempo().position_lock_style() == MusicTime) {
+ map.replace_tempo (*_real_section, _marker->tempo().beats_per_minute() , _real_section->beat(), _marker->tempo().type());
+ } else {
+ map.replace_tempo (*_real_section, _marker->tempo().beats_per_minute() , _real_section->frame(), _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());
+ if (_marker->tempo().position_lock_style() == MusicTime) {
+ map.add_tempo (_marker->tempo(), _marker->tempo().beat(), _marker->tempo().type());
+ } else {
+ map.add_tempo (_marker->tempo(), _marker->tempo().frame(), _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 ();
void
TimeFXDrag::finished (GdkEvent* event, bool movement_occurred)
{
- if (!movement_occurred) {
- return;
- }
+ /* 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.
+ */
- motion (event, false);
+ float fraction = 1.0;
- _primary->get_time_axis_view().hide_timestretch ();
+ if (movement_occurred) {
- framepos_t adjusted_frame_pos = adjusted_current_frame (event);
+ motion (event, false);
- if (adjusted_frame_pos < _primary->region()->position()) {
- /* backwards drag of the left edge - not usable */
- return;
- }
+ _primary->get_time_axis_view().hide_timestretch ();
- framecnt_t newlen = adjusted_frame_pos - _primary->region()->position();
+ framepos_t adjusted_frame_pos = adjusted_current_frame (event);
- float percentage = (double) newlen / (double) _primary->region()->length();
+ if (adjusted_frame_pos < _primary->region()->position()) {
+ /* backwards drag of the left edge - not usable */
+ return;
+ }
+
+ framecnt_t newlen = adjusted_frame_pos - _primary->region()->position();
+
+ 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 ();
}
}