Paste uses exact beats. rework _start_beats calculation in copy-with-offset ctor.
This commit is contained in:
parent
94e0a15325
commit
93c24e4433
|
@ -658,7 +658,7 @@ AutomationTimeAxisView::add_automation_event (GdkEvent* event, framepos_t when,
|
|||
}
|
||||
|
||||
bool
|
||||
AutomationTimeAxisView::paste (framepos_t pos, const Selection& selection, PasteContext& ctx)
|
||||
AutomationTimeAxisView::paste (framepos_t pos, const Selection& selection, PasteContext& ctx, const int32_t& sub_num)
|
||||
{
|
||||
if (_line) {
|
||||
return paste_one (pos, ctx.count, ctx.times, selection, ctx.counts, ctx.greedy);
|
||||
|
|
|
@ -97,7 +97,7 @@ class AutomationTimeAxisView : public TimeAxisView {
|
|||
/* editing operations */
|
||||
|
||||
void cut_copy_clear (Selection&, Editing::CutCopyOp);
|
||||
bool paste (ARDOUR::framepos_t, const Selection&, PasteContext&);
|
||||
bool paste (ARDOUR::framepos_t, const Selection&, PasteContext&, const int32_t& sub_num);
|
||||
|
||||
int set_state (const XMLNode&, int version);
|
||||
|
||||
|
|
|
@ -1190,7 +1190,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
|
|||
void cut_copy_midi (Editing::CutCopyOp);
|
||||
|
||||
void mouse_paste ();
|
||||
void paste_internal (framepos_t position, float times);
|
||||
void paste_internal (framepos_t position, float times, const int32_t& sub_num);
|
||||
|
||||
/* EDITING OPERATIONS */
|
||||
|
||||
|
@ -1283,7 +1283,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
|
|||
void delete_ ();
|
||||
void cut ();
|
||||
void copy ();
|
||||
void paste (float times, bool from_context_menu = false);
|
||||
void paste (float times, bool from_context_menu);
|
||||
|
||||
void place_transient ();
|
||||
void remove_transient (ArdourCanvas::Item* item);
|
||||
|
|
|
@ -1256,8 +1256,8 @@ RegionMoveDrag::motion (GdkEvent* event, bool first_move)
|
|||
MidiRegionView* mrv = dynamic_cast<MidiRegionView*>(rv);
|
||||
|
||||
const boost::shared_ptr<const Region> original = rv->region();
|
||||
boost::shared_ptr<Region> region_copy = RegionFactory::create (original, true);
|
||||
region_copy->set_position (original->position(), _editor->get_grid_music_divisions (event->button.state));
|
||||
boost::shared_ptr<Region> region_copy = RegionFactory::create (original, true
|
||||
, _editor->get_grid_music_divisions (event->button.state));
|
||||
/* need to set this so that the drop zone code can work. This doesn't
|
||||
actually put the region into the playlist, but just sets a weak pointer
|
||||
to it.
|
||||
|
@ -1478,7 +1478,9 @@ RegionMoveDrag::finished_copy (bool const changed_position, bool const /*changed
|
|||
}
|
||||
|
||||
if (dest_rtv != 0) {
|
||||
RegionView* new_view = insert_region_into_playlist (i->view->region(), dest_rtv, i->layer, where, modified_playlists);
|
||||
RegionView* new_view = insert_region_into_playlist (i->view->region(), dest_rtv, i->layer, where,
|
||||
modified_playlists, _editor->get_grid_music_divisions (ev_state));
|
||||
|
||||
if (new_view != 0) {
|
||||
new_views.push_back (new_view);
|
||||
}
|
||||
|
@ -1574,7 +1576,8 @@ RegionMoveDrag::finished_no_copy (
|
|||
/* insert into new playlist */
|
||||
|
||||
RegionView* new_view = insert_region_into_playlist (
|
||||
RegionFactory::create (rv->region (), true), dest_rtv, dest_layer, where, modified_playlists
|
||||
RegionFactory::create (rv->region (), true), dest_rtv, dest_layer, where,
|
||||
modified_playlists, _editor->get_grid_music_divisions (ev_state)
|
||||
);
|
||||
|
||||
if (new_view == 0) {
|
||||
|
@ -1737,7 +1740,8 @@ RegionMoveDrag::insert_region_into_playlist (
|
|||
RouteTimeAxisView* dest_rtv,
|
||||
layer_t dest_layer,
|
||||
framecnt_t where,
|
||||
PlaylistSet& modified_playlists
|
||||
PlaylistSet& modified_playlists,
|
||||
const int32_t& sub_num
|
||||
)
|
||||
{
|
||||
boost::shared_ptr<Playlist> dest_playlist = dest_rtv->playlist ();
|
||||
|
@ -1754,8 +1758,7 @@ RegionMoveDrag::insert_region_into_playlist (
|
|||
if (r.second) {
|
||||
dest_playlist->clear_changes ();
|
||||
}
|
||||
|
||||
dest_playlist->add_region (region, where);
|
||||
dest_playlist->add_region (region, where, 1.0, false, sub_num);
|
||||
|
||||
if (dest_rtv->view()->layer_display() == Stacked || dest_rtv->view()->layer_display() == Expanded) {
|
||||
dest_playlist->set_layer (region, dest_layer);
|
||||
|
|
|
@ -423,7 +423,8 @@ private:
|
|||
RouteTimeAxisView*,
|
||||
ARDOUR::layer_t,
|
||||
ARDOUR::framecnt_t,
|
||||
PlaylistSet&
|
||||
PlaylistSet&,
|
||||
const int32_t& sub_num
|
||||
);
|
||||
|
||||
void remove_region_from_playlist (
|
||||
|
|
|
@ -105,5 +105,5 @@ Editor::keyboard_selection_begin (Editing::EditIgnoreOption ign)
|
|||
void
|
||||
Editor::keyboard_paste ()
|
||||
{
|
||||
paste (1);
|
||||
paste (1, false);
|
||||
}
|
||||
|
|
|
@ -4635,7 +4635,7 @@ Editor::paste (float times, bool from_context)
|
|||
{
|
||||
DEBUG_TRACE (DEBUG::CutNPaste, "paste to preferred edit pos\n");
|
||||
|
||||
paste_internal (get_preferred_edit_position (EDIT_IGNORE_NONE, from_context), times);
|
||||
paste_internal (get_preferred_edit_position (EDIT_IGNORE_NONE, from_context), times, get_grid_music_divisions (0));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -4649,11 +4649,11 @@ Editor::mouse_paste ()
|
|||
}
|
||||
|
||||
snap_to (where);
|
||||
paste_internal (where, 1);
|
||||
paste_internal (where, 1, get_grid_music_divisions (0));
|
||||
}
|
||||
|
||||
void
|
||||
Editor::paste_internal (framepos_t position, float times)
|
||||
Editor::paste_internal (framepos_t position, float times, const int32_t& sub_num)
|
||||
{
|
||||
DEBUG_TRACE (DEBUG::CutNPaste, string_compose ("apparent paste position is %1\n", position));
|
||||
|
||||
|
@ -4746,7 +4746,7 @@ Editor::paste_internal (framepos_t position, float times)
|
|||
"greedy" paste from one automation type to another. */
|
||||
|
||||
PasteContext ctx(paste_count, times, ItemCounts(), true);
|
||||
ts.front()->paste (position, *cut_buffer, ctx);
|
||||
ts.front()->paste (position, *cut_buffer, ctx, sub_num);
|
||||
|
||||
} else {
|
||||
|
||||
|
@ -4754,7 +4754,7 @@ Editor::paste_internal (framepos_t position, float times)
|
|||
|
||||
PasteContext ctx(paste_count, times, ItemCounts(), false);
|
||||
for (TrackViewList::iterator i = ts.begin(); i != ts.end(); ++i) {
|
||||
(*i)->paste (position, *cut_buffer, ctx);
|
||||
(*i)->paste (position, *cut_buffer, ctx, sub_num);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3491,7 +3491,7 @@ MidiRegionView::selection_as_cut_buffer () const
|
|||
|
||||
/** This method handles undo */
|
||||
bool
|
||||
MidiRegionView::paste (framepos_t pos, const ::Selection& selection, PasteContext& ctx)
|
||||
MidiRegionView::paste (framepos_t pos, const ::Selection& selection, PasteContext& ctx, const int32_t& sub_num)
|
||||
{
|
||||
bool commit = false;
|
||||
// Paste notes, if available
|
||||
|
@ -3506,7 +3506,7 @@ MidiRegionView::paste (framepos_t pos, const ::Selection& selection, PasteContex
|
|||
typedef RouteTimeAxisView::AutomationTracks ATracks;
|
||||
const ATracks& atracks = midi_view()->automation_tracks();
|
||||
for (ATracks::const_iterator a = atracks.begin(); a != atracks.end(); ++a) {
|
||||
if (a->second->paste(pos, selection, ctx)) {
|
||||
if (a->second->paste(pos, selection, ctx, sub_num)) {
|
||||
commit = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ public:
|
|||
void resolve_note(uint8_t note_num, Evoral::Beats end_time);
|
||||
|
||||
void cut_copy_clear (Editing::CutCopyOp);
|
||||
bool paste (framepos_t pos, const ::Selection& selection, PasteContext& ctx);
|
||||
bool paste (framepos_t pos, const ::Selection& selection, PasteContext& ctx, const int32_t& sub_num);
|
||||
void paste_internal (framepos_t pos, unsigned paste_count, float times, const MidiCutBuffer&);
|
||||
|
||||
void add_canvas_patch_change (ARDOUR::MidiModel::PatchChangePtr patch, const std::string& displaytext, bool);
|
||||
|
|
|
@ -662,7 +662,7 @@ struct RegionPositionSorter {
|
|||
};
|
||||
|
||||
bool
|
||||
MidiStreamView::paste (ARDOUR::framepos_t pos, const Selection& selection, PasteContext& ctx)
|
||||
MidiStreamView::paste (ARDOUR::framepos_t pos, const Selection& selection, PasteContext& ctx, const int32_t& sub_num)
|
||||
{
|
||||
/* Paste into the first region which starts on or before pos. Only called when
|
||||
using an internal editing tool. */
|
||||
|
@ -690,5 +690,5 @@ MidiStreamView::paste (ARDOUR::framepos_t pos, const Selection& selection, Paste
|
|||
}
|
||||
|
||||
MidiRegionView* mrv = dynamic_cast<MidiRegionView*> (*prev);
|
||||
return mrv ? mrv->paste(pos, selection, ctx) : false;
|
||||
return mrv ? mrv->paste(pos, selection, ctx, sub_num) : false;
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ class MidiStreamView : public StreamView
|
|||
|
||||
RegionView* create_region_view (boost::shared_ptr<ARDOUR::Region>, bool, bool);
|
||||
|
||||
bool paste (ARDOUR::framepos_t pos, const Selection& selection, PasteContext& ctx);
|
||||
bool paste (ARDOUR::framepos_t pos, const Selection& selection, PasteContext& ctx, const int32_t& sub_num);
|
||||
|
||||
void apply_note_range(uint8_t lowest, uint8_t highest, bool to_region_views);
|
||||
|
||||
|
|
|
@ -1635,12 +1635,12 @@ MidiTimeAxisView::capture_channel_mode_changed ()
|
|||
}
|
||||
|
||||
bool
|
||||
MidiTimeAxisView::paste (framepos_t pos, const Selection& selection, PasteContext& ctx)
|
||||
MidiTimeAxisView::paste (framepos_t pos, const Selection& selection, PasteContext& ctx, const int32_t& sub_num)
|
||||
{
|
||||
if (!_editor.internal_editing()) {
|
||||
// Non-internal paste, paste regions like any other route
|
||||
return RouteTimeAxisView::paste(pos, selection, ctx);
|
||||
return RouteTimeAxisView::paste(pos, selection, ctx, sub_num);
|
||||
}
|
||||
|
||||
return midi_view()->paste(pos, selection, ctx);
|
||||
return midi_view()->paste(pos, selection, ctx, sub_num);
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ public:
|
|||
void show_existing_automation (bool apply_to_selection = false);
|
||||
void create_automation_child (const Evoral::Parameter& param, bool show);
|
||||
|
||||
bool paste (ARDOUR::framepos_t, const Selection&, PasteContext& ctx);
|
||||
bool paste (ARDOUR::framepos_t, const Selection&, PasteContext& ctx, const int32_t& sub_num);
|
||||
|
||||
ARDOUR::NoteMode note_mode() const { return _note_mode; }
|
||||
ARDOUR::ColorMode color_mode() const { return _color_mode; }
|
||||
|
|
|
@ -1585,7 +1585,7 @@ RouteTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
|
|||
}
|
||||
|
||||
bool
|
||||
RouteTimeAxisView::paste (framepos_t pos, const Selection& selection, PasteContext& ctx)
|
||||
RouteTimeAxisView::paste (framepos_t pos, const Selection& selection, PasteContext& ctx, const int32_t& sub_num)
|
||||
{
|
||||
if (!is_track()) {
|
||||
return false;
|
||||
|
@ -1619,7 +1619,7 @@ RouteTimeAxisView::paste (framepos_t pos, const Selection& selection, PasteConte
|
|||
framecnt_t amount = extent.second - extent.first;
|
||||
pl->ripple(pos, amount * ctx.times, boost::shared_ptr<Region>());
|
||||
}
|
||||
pl->paste (*p, pos, ctx.times);
|
||||
pl->paste (*p, pos, ctx.times, sub_num);
|
||||
|
||||
vector<Command*> cmds;
|
||||
pl->rdiff (cmds);
|
||||
|
|
|
@ -107,7 +107,7 @@ public:
|
|||
|
||||
/* Editing operations */
|
||||
void cut_copy_clear (Selection&, Editing::CutCopyOp);
|
||||
bool paste (ARDOUR::framepos_t, const Selection&, PasteContext& ctx);
|
||||
bool paste (ARDOUR::framepos_t, const Selection&, PasteContext& ctx, const int32_t& sub_num);
|
||||
RegionView* combine_regions ();
|
||||
void uncombine_regions ();
|
||||
void uncombine_region (RegionView*);
|
||||
|
|
|
@ -185,7 +185,8 @@ class TimeAxisView : public virtual AxisView
|
|||
*/
|
||||
virtual bool paste (ARDOUR::framepos_t pos,
|
||||
const Selection& selection,
|
||||
PasteContext& ctx) { return false; }
|
||||
PasteContext& ctx,
|
||||
const int32_t& sub_num) { return false; }
|
||||
|
||||
virtual void set_selected_regionviews (RegionSelection&) {}
|
||||
virtual void set_selected_points (PointSelection&) {}
|
||||
|
|
|
@ -128,7 +128,7 @@ public:
|
|||
|
||||
/* Editing operations */
|
||||
|
||||
void add_region (boost::shared_ptr<Region>, framepos_t position, float times = 1, bool auto_partition = false);
|
||||
void add_region (boost::shared_ptr<Region>, framepos_t position, float times = 1, bool auto_partition = false, const int32_t& sub_num = 0);
|
||||
void remove_region (boost::shared_ptr<Region>);
|
||||
void get_equivalent_regions (boost::shared_ptr<Region>, std::vector<boost::shared_ptr<Region> >&);
|
||||
void get_region_list_equivalent_regions (boost::shared_ptr<Region>, std::vector<boost::shared_ptr<Region> >&);
|
||||
|
@ -161,7 +161,7 @@ public:
|
|||
|
||||
boost::shared_ptr<Playlist> cut (std::list<AudioRange>&, bool result_is_hidden = true);
|
||||
boost::shared_ptr<Playlist> copy (std::list<AudioRange>&, bool result_is_hidden = true);
|
||||
int paste (boost::shared_ptr<Playlist>, framepos_t position, float times);
|
||||
int paste (boost::shared_ptr<Playlist>, framepos_t position, float times, const int32_t& sub_num);
|
||||
|
||||
const RegionListProperty& region_list_property () const { return regions; }
|
||||
boost::shared_ptr<RegionList> region_list();
|
||||
|
@ -362,7 +362,7 @@ public:
|
|||
|
||||
virtual XMLNode& state (bool);
|
||||
|
||||
bool add_region_internal (boost::shared_ptr<Region>, framepos_t position);
|
||||
bool add_region_internal (boost::shared_ptr<Region>, framepos_t position, const int32_t& sub_num = 0);
|
||||
|
||||
int remove_region_internal (boost::shared_ptr<Region>);
|
||||
void copy_regions (RegionList&) const;
|
||||
|
|
|
@ -171,10 +171,12 @@ class LIBARDOUR_API Region
|
|||
Trimmable::CanTrim can_trim () const;
|
||||
|
||||
PositionLockStyle position_lock_style () const { return _position_lock_style; }
|
||||
double beat () const { return _beat; }
|
||||
void set_position_lock_style (PositionLockStyle ps);
|
||||
void recompute_position_from_lock_style (const int32_t& sub_num);
|
||||
|
||||
double beat () const { return _beat; }
|
||||
void set_beat (double beat) { _beat = beat; }
|
||||
|
||||
void suspend_property_changes ();
|
||||
|
||||
bool covers (framepos_t frame) const {
|
||||
|
|
|
@ -107,8 +107,7 @@ MidiRegion::MidiRegion (boost::shared_ptr<const MidiRegion> other, frameoffset_t
|
|||
, _start_beats (Properties::start_beats, Evoral::Beats())
|
||||
, _length_beats (Properties::length_beats, other->_length_beats)
|
||||
{
|
||||
const double offset_beat = _session.tempo_map().exact_beat_at_frame (other->_position + offset, sub_num) - other->beat();
|
||||
_start_beats = Evoral::Beats (other->_start_beats.val().to_double() + offset_beat);
|
||||
_start_beats = Evoral::Beats (_session.tempo_map().exact_beat_at_frame (other->_position + offset - other->_start, sub_num) - other->beat());
|
||||
update_length_beats (sub_num);
|
||||
register_properties ();
|
||||
|
||||
|
@ -163,7 +162,10 @@ MidiRegion::clone (boost::shared_ptr<MidiSource> newsrc) const
|
|||
plist.add (Properties::length_beats, _length_beats);
|
||||
plist.add (Properties::layer, 0);
|
||||
|
||||
return boost::dynamic_pointer_cast<MidiRegion> (RegionFactory::create (newsrc, plist, true));
|
||||
boost::shared_ptr<MidiRegion> ret (boost::dynamic_pointer_cast<MidiRegion> (RegionFactory::create (newsrc, plist, true)));
|
||||
ret->set_beat (beat());
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -665,7 +665,7 @@ Playlist::flush_notifications (bool from_undo)
|
|||
|
||||
/** Note: this calls set_layer (..., DBL_MAX) so it will reset the layering index of region */
|
||||
void
|
||||
Playlist::add_region (boost::shared_ptr<Region> region, framepos_t position, float times, bool auto_partition)
|
||||
Playlist::add_region (boost::shared_ptr<Region> region, framepos_t position, float times, bool auto_partition, const int32_t& sub_num)
|
||||
{
|
||||
RegionWriteLock rlock (this);
|
||||
times = fabs (times);
|
||||
|
@ -679,7 +679,7 @@ Playlist::flush_notifications (bool from_undo)
|
|||
}
|
||||
|
||||
if (itimes >= 1) {
|
||||
add_region_internal (region, pos);
|
||||
add_region_internal (region, pos, sub_num);
|
||||
set_layer (region, DBL_MAX);
|
||||
pos += region->length();
|
||||
--itimes;
|
||||
|
@ -692,7 +692,7 @@ Playlist::flush_notifications (bool from_undo)
|
|||
|
||||
for (int i = 0; i < itimes; ++i) {
|
||||
boost::shared_ptr<Region> copy = RegionFactory::create (region, true);
|
||||
add_region_internal (copy, pos);
|
||||
add_region_internal (copy, pos, sub_num);
|
||||
set_layer (copy, DBL_MAX);
|
||||
pos += region->length();
|
||||
}
|
||||
|
@ -713,7 +713,7 @@ Playlist::flush_notifications (bool from_undo)
|
|||
plist.add (Properties::layer, region->layer());
|
||||
|
||||
boost::shared_ptr<Region> sub = RegionFactory::create (region, plist);
|
||||
add_region_internal (sub, pos);
|
||||
add_region_internal (sub, pos, sub_num);
|
||||
set_layer (sub, DBL_MAX);
|
||||
}
|
||||
}
|
||||
|
@ -734,7 +734,7 @@ Playlist::flush_notifications (bool from_undo)
|
|||
}
|
||||
|
||||
bool
|
||||
Playlist::add_region_internal (boost::shared_ptr<Region> region, framepos_t position)
|
||||
Playlist::add_region_internal (boost::shared_ptr<Region> region, framepos_t position, const int32_t& sub_num)
|
||||
{
|
||||
if (region->data_type() != _type) {
|
||||
return false;
|
||||
|
@ -747,7 +747,7 @@ Playlist::flush_notifications (bool from_undo)
|
|||
region->set_playlist (boost::weak_ptr<Playlist>(foo));
|
||||
}
|
||||
|
||||
region->set_position (position);
|
||||
region->set_position (position, sub_num);
|
||||
|
||||
regions.insert (upper_bound (regions.begin(), regions.end(), region, cmp), region);
|
||||
all_regions.insert (region);
|
||||
|
@ -1146,7 +1146,7 @@ Playlist::flush_notifications (bool from_undo)
|
|||
chopped.
|
||||
*/
|
||||
|
||||
ret->paste (pl, (*i).start - start, 1.0f);
|
||||
ret->paste (pl, (*i).start - start, 1.0f, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1208,7 +1208,7 @@ Playlist::flush_notifications (bool from_undo)
|
|||
}
|
||||
|
||||
int
|
||||
Playlist::paste (boost::shared_ptr<Playlist> other, framepos_t position, float times)
|
||||
Playlist::paste (boost::shared_ptr<Playlist> other, framepos_t position, float times, const int32_t& sub_num)
|
||||
{
|
||||
times = fabs (times);
|
||||
|
||||
|
@ -1230,7 +1230,7 @@ Playlist::flush_notifications (bool from_undo)
|
|||
the ordering they had in the original playlist.
|
||||
*/
|
||||
|
||||
add_region_internal (copy_of_region, (*i)->position() + pos);
|
||||
add_region_internal (copy_of_region, (*i)->position() + pos, sub_num);
|
||||
set_layer (copy_of_region, copy_of_region->layer() + top);
|
||||
}
|
||||
pos += shift;
|
||||
|
@ -1321,7 +1321,7 @@ Playlist::duplicate_range (AudioRange& range, float times)
|
|||
{
|
||||
boost::shared_ptr<Playlist> pl = copy (range.start, range.length(), true);
|
||||
framecnt_t offset = range.end - range.start;
|
||||
paste (pl, range.start + offset, times);
|
||||
paste (pl, range.start + offset, times, 0);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1345,7 +1345,7 @@ Playlist::duplicate_ranges (std::list<AudioRange>& ranges, float /* times */)
|
|||
|
||||
for (list<AudioRange>::iterator i = ranges.begin(); i != ranges.end(); ++i) {
|
||||
boost::shared_ptr<Playlist> pl = copy ((*i).start, (*i).length(), true);
|
||||
paste (pl, (*i).start + offset, 1.0f); // times ??
|
||||
paste (pl, (*i).start + offset, 1.0f, 0); // times ??
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue