13
0

Fix DnD import to grouped tracks

Import via Drag/Drop previously worked by selecting a track,
and then importing to the selected track.

This approach fails when the selected track is in a track-group,
and selecting the track also selects other tracks of different type.

Now the track to drop onto is passed directly passed through to
::finish_bringing_in_material as existing_track.
This commit is contained in:
Robin Gareus 2022-09-30 21:28:01 +02:00
parent 20088062bb
commit 07dea50456
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
7 changed files with 31 additions and 26 deletions

View File

@ -471,13 +471,15 @@ public:
ARDOUR::MidiTempoMapDisposition mtd,
Temporal::timepos_t& pos,
boost::shared_ptr<ARDOUR::PluginInfo> instrument = boost::shared_ptr<ARDOUR::PluginInfo>(),
boost::shared_ptr<ARDOUR::Track> track = boost::shared_ptr<ARDOUR::Track>(),
bool with_markers = false);
void do_embed (std::vector<std::string> paths,
Editing::ImportDisposition disposition,
Editing::ImportMode mode,
Temporal::timepos_t& pos,
boost::shared_ptr<ARDOUR::PluginInfo> instrument = boost::shared_ptr<ARDOUR::PluginInfo>());
boost::shared_ptr<ARDOUR::PluginInfo> instrument = boost::shared_ptr<ARDOUR::PluginInfo>(),
boost::shared_ptr<ARDOUR::Track> track = boost::shared_ptr<ARDOUR::Track>());
void get_regionview_corresponding_to (boost::shared_ptr<ARDOUR::Region> region, std::vector<RegionView*>& regions);

View File

@ -369,9 +369,9 @@ Editor::do_import (vector<string> paths,
MidiTempoMapDisposition smf_tempo_disposition,
timepos_t& pos,
ARDOUR::PluginInfoPtr instrument,
boost::shared_ptr<Track> track,
bool with_markers)
{
boost::shared_ptr<Track> track;
vector<string> to_import;
int nth = 0;
bool use_timestamp = (pos == timepos_t::max (pos.time_domain()));
@ -522,9 +522,13 @@ Editor::do_import (vector<string> paths,
}
void
Editor::do_embed (vector<string> paths, ImportDisposition import_as, ImportMode mode, timepos_t& pos, ARDOUR::PluginInfoPtr instrument)
Editor::do_embed (vector<string> paths,
ImportDisposition import_as,
ImportMode mode,
timepos_t& pos,
ARDOUR::PluginInfoPtr instrument,
boost::shared_ptr<Track> track)
{
boost::shared_ptr<Track> track;
bool check_sample_rate = true;
vector<string> to_embed;
bool multi = paths.size() > 1;

View File

@ -440,7 +440,7 @@ Editor::drop_paths_part_two (const vector<string>& paths, timepos_t const & p, d
/* drop onto canvas background: create new tracks */
InstrumentSelector is(InstrumentSelector::ForTrackDefault); // instantiation builds instrument-list and sets default.
do_import (midi_paths, Editing::ImportDistinctFiles, ImportAsTrack, SrcBest, SMFTrackNumber, SMFTempoIgnore, pos, is.selected_instrument(), false);
do_import (midi_paths, Editing::ImportDistinctFiles, ImportAsTrack, SrcBest, SMFTrackNumber, SMFTempoIgnore, pos, is.selected_instrument());
if (UIConfiguration::instance().get_only_copy_imported_files() || copy) {
do_import (audio_paths, Editing::ImportDistinctFiles, Editing::ImportAsTrack,
@ -454,17 +454,14 @@ Editor::drop_paths_part_two (const vector<string>& paths, timepos_t const & p, d
/* check that its a track, not a bus */
if (tv->track()) {
/* select the track, then embed/import */
selection->set (tv);
do_import (midi_paths, Editing::ImportSerializeFiles, ImportToTrack,
SrcBest, SMFTrackNumber, SMFTempoIgnore, pos);
SrcBest, SMFTrackNumber, SMFTempoIgnore, pos, boost::shared_ptr<ARDOUR::PluginInfo>(), tv->track ());
if (UIConfiguration::instance().get_only_copy_imported_files() || copy) {
do_import (audio_paths, Editing::ImportSerializeFiles, Editing::ImportToTrack,
SrcBest, SMFTrackName, SMFTempoIgnore, pos, boost::shared_ptr<PluginInfo>(), false);
SrcBest, SMFTrackName, SMFTempoIgnore, pos, boost::shared_ptr<PluginInfo>());
} else {
do_embed (audio_paths, Editing::ImportSerializeFiles, ImportToTrack, pos);
do_embed (audio_paths, Editing::ImportSerializeFiles, ImportToTrack, pos, boost::shared_ptr<ARDOUR::PluginInfo>(), tv->track ());
}
}
}

View File

@ -282,9 +282,11 @@ public:
virtual void do_import (std::vector<std::string> paths, Editing::ImportDisposition, Editing::ImportMode mode, ARDOUR::SrcQuality,
ARDOUR::MidiTrackNameSource, ARDOUR::MidiTempoMapDisposition, Temporal::timepos_t&,
boost::shared_ptr<ARDOUR::PluginInfo> instrument = boost::shared_ptr<ARDOUR::PluginInfo>(),
boost::shared_ptr<ARDOUR::Track> track = boost::shared_ptr<ARDOUR::Track>(),
bool with_markers = false) = 0;
virtual void do_embed (std::vector<std::string> paths, Editing::ImportDisposition, Editing::ImportMode mode, Temporal::timepos_t&,
boost::shared_ptr<ARDOUR::PluginInfo> instrument = boost::shared_ptr<ARDOUR::PluginInfo>()) = 0;
boost::shared_ptr<ARDOUR::PluginInfo> instrument = boost::shared_ptr<ARDOUR::PluginInfo>(),
boost::shared_ptr<ARDOUR::Track> track = boost::shared_ptr<ARDOUR::Track>()) = 0;
/** Open main export dialog */
virtual void export_audio () = 0;

View File

@ -2208,7 +2208,7 @@ SoundFileOmega::do_something (int action)
_import_active = true;
if (copy_files_btn.get_active()) {
PublicEditor::instance().do_import (paths, chns, mode, quality, mts, mtd, where, instrument, with_midi_markers);
PublicEditor::instance().do_import (paths, chns, mode, quality, mts, mtd, where, instrument, boost::shared_ptr<Track>(), with_midi_markers);
} else {
PublicEditor::instance().do_embed (paths, chns, mode, where, instrument);
}

View File

@ -724,7 +724,7 @@ TriggerPage::drop_paths_part_two (std::vector<std::string> paths)
}
timepos_t pos (0);
Editing::ImportDisposition disposition = Editing::ImportSerializeFiles; // or Editing::ImportDistinctFiles // TODO use drop modifier? config?
PublicEditor::instance().do_import (midi_paths, disposition, Editing::ImportAsTrigger, SrcBest, SMFTrackNumber, SMFTempoIgnore, pos, _trigger_clip_picker.instrument_plugin (), false);
PublicEditor::instance().do_import (midi_paths, disposition, Editing::ImportAsTrigger, SrcBest, SMFTrackNumber, SMFTempoIgnore, pos, _trigger_clip_picker.instrument_plugin ());
PublicEditor::instance().do_import (audio_paths, disposition, Editing::ImportAsTrigger, SrcBest, SMFTrackNumber, SMFTempoIgnore, pos);
}

View File

@ -5,10 +5,10 @@ function factory (params) return function ()
files:push_back("/tmp/test.wav")
local pos = -1
local pos = Temporal.timepos_t(0)
Editor:do_import (files,
Editing.ImportDistinctFiles, Editing.ImportAsTrack, ARDOUR.SrcQuality.SrcBest,
ARDOUR.MidiTrackNameSource.SMFTrackName, ARDOUR.MidiTempoMapDisposition.SMFTempoIgnore,
pos, ARDOUR.PluginInfo(), false)
pos, ARDOUR.PluginInfo(), ARDOUR.Track(), false)
end end