13
0

Merge branch 'ardour'

This commit is contained in:
Robin Gareus 2024-07-13 21:04:32 +02:00
commit 5327222c81
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
3 changed files with 46 additions and 2 deletions

View File

@ -67,6 +67,7 @@
#include "mergeable_line.h"
#include "region_gain_line.h"
#include "control_point.h"
#include "paste_context.h"
#include "ghostregion.h"
#include "audio_time_axis.h"
#include "rgb_macros.h"
@ -1264,6 +1265,40 @@ AudioRegionView::get_region_fx_line (PBD::ID& id, uint32_t& param_id)
return _rdx_param != UINT32_MAX && _rfx_id != 0;
}
bool
AudioRegionView::paste (Temporal::timepos_t const& pos, const Selection& selection, PasteContext& ctx)
{
if (!_fx_line || selection.lines.size() != 1) {
return false;
}
std::shared_ptr<AutomationList> alist (_fx_line->the_list());
AutomationSelection::const_iterator p = selection.lines.begin ();
Temporal::timecnt_t len = (*p)->length();
Temporal::timepos_t tpos (pos);
unsigned paste_count = ctx.count;
switch (alist->time_domain()) {
case Temporal::BeatTime:
tpos += trackview.editor().get_paste_offset (pos, paste_count > 0 ? 1 : 0, len);
break;
case Temporal::AudioTime:
tpos += trackview.editor().get_paste_offset (pos, paste_count, len);
break;
}
XMLNode &before = alist->get_state();
Temporal::timepos_t model_pos (_region->position().distance (tpos));
alist->paste (**p, model_pos);
timepos_t rlen ((samplepos_t)_region->length().samples());
alist->truncate_end (rlen);
trackview.session()->add_command (new MementoCommand<AutomationList>(*alist.get(), &before, &alist->get_state()));
return true;
}
void
AudioRegionView::update_envelope_visibility ()
{

View File

@ -54,6 +54,7 @@ class GhostRegion;
class AutomationTimeAxisView;
class RegionFxLine;
class RouteTimeAxisView;
class PasteContext;
class AudioRegionView : public RegionView, public LineMerger
{
@ -97,6 +98,7 @@ public:
bool set_region_fx_line (std::weak_ptr<PBD::Controllable>);
bool get_region_fx_line (PBD::ID&, uint32_t&);
void update_envelope_visibility ();
bool paste (Temporal::timepos_t const&, const Selection&, PasteContext&);
sigc::signal<void> region_line_changed;

View File

@ -5411,7 +5411,7 @@ Editor::paste_internal (timepos_t const & pos, float times)
* the below "do the reasonable thing" logic. */
ts = selection->tracks.filter_to_unique_playlists ();
sort_track_selection (ts);
} else {
} else if (cut_buffer->lines.empty ()) {
/* Figure out which track to base the paste at. */
TimeAxisView* base_track = NULL;
if (_edit_point == Editing::EditAtMouse && entered_track) {
@ -5465,10 +5465,17 @@ Editor::paste_internal (timepos_t const & pos, float times)
R1.A1, R1.A2, R2, R2.A1, ... */
}
bool commit = false;
begin_reversible_command (Operations::paste);
if (ts.size() == 1 && cut_buffer->lines.size() == 1 &&
if (ts.size() == 0 && cut_buffer->lines.size() == 1 && entered_regionview) {
AudioRegionView* arv = dynamic_cast<AudioRegionView*>(entered_regionview);
if (arv) {
PasteContext ctx(paste_count, times, ItemCounts(), true);
commit |= arv->paste (position, *cut_buffer, ctx);
}
} else if (ts.size() == 1 && cut_buffer->lines.size() == 1 &&
dynamic_cast<AutomationTimeAxisView*>(ts.front())) {
/* Only one line copied, and one automation track selected. Do a
"greedy" paste from one automation type to another. */