Instrument Selector: use a 3-way Disposition to disambiguate the uses of this widget

This commit is contained in:
Ben Loftis 2022-02-04 20:31:21 -06:00
parent 9eb626cc37
commit 9ad82787a1
7 changed files with 25 additions and 10 deletions

View File

@ -81,6 +81,7 @@ AddRouteDialog::AddRouteDialog ()
, mode_label (_("Record Mode:"))
, instrument_label (_("Instrument:"))
, last_route_count (1)
, instrument_combo (InstrumentSelector::ForTrackSelector)
, route_count_set_by_template (false)
, name_edited_by_user (false)
{

View File

@ -432,7 +432,7 @@ Editor::drop_paths_part_two (const vector<string>& paths, timepos_t const & p, d
/* drop onto canvas background: create new tracks */
InstrumentSelector is; // instantiation builds instrument-list and sets default.
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);
if (UIConfiguration::instance().get_only_copy_imported_files() || copy) {

View File

@ -29,10 +29,10 @@
using namespace Gtk;
using namespace ARDOUR;
InstrumentSelector::InstrumentSelector (bool allow_none)
InstrumentSelector::InstrumentSelector (InstrumentListDisposition disp)
: _reasonable_synth_id (0)
, _gmsynth_id (UINT32_MAX)
, _allow_none (allow_none)
, _disposition (disp)
{
refill ();
@ -122,17 +122,23 @@ InstrumentSelector::build_instrument_list()
_instrument_list = ListStore::create(_instrument_list_columns);
if (_allow_none) {
if (_disposition==ForTrackSelector) {
TreeModel::Row row = *(_instrument_list->append());
row[_instrument_list_columns.info_ptr] = PluginInfoPtr();
row[_instrument_list_columns.name] = _("-none-");
}
uint32_t n = _allow_none ? 1 : 0;
_longest_instrument_name = "";
uint32_t n = (_disposition==ForTrackSelector) ? 1 : 0;
std::string prev;
for (PluginInfoList::const_iterator i = all_plugs.begin(); i != all_plugs.end(); ++i, ++n) {
PluginInfoPtr p = *i;
if (p->name.length() > _longest_instrument_name.length()) {
_longest_instrument_name = p->name;
}
std::string suffix;
#ifdef MIXBUS

View File

@ -39,7 +39,13 @@ class Editor;
class InstrumentSelector : public Gtk::ComboBox
{
public:
InstrumentSelector (bool allow_none = true);
enum InstrumentListDisposition {
ForAuditioner, /* this will always return some synth, never 'None' */
ForTrackDefault, /* functionally same as ForAuditioner, but for tracks */
ForTrackSelector /* this provides the 'None' option so the user can add a synth later */
};
InstrumentSelector (InstrumentListDisposition);
ARDOUR::PluginInfoPtr selected_instrument () const;
std::string selected_instrument_name () const;
@ -57,11 +63,13 @@ private:
void build_instrument_list();
void refill();
std::string _longest_instrument_name;
Glib::RefPtr<Gtk::ListStore> _instrument_list;
InstrumentListColumns _instrument_list_columns;
uint32_t _reasonable_synth_id;
uint32_t _gmsynth_id;
bool _allow_none;
InstrumentListDisposition _disposition;
PBD::ScopedConnection _update_connection;
};

View File

@ -1094,7 +1094,7 @@ RecorderUI::new_track_for_port (DataType dt, string const& port_name)
ArdourDialog d (_("Create track for input"), true, false);
Entry track_name_entry;
InstrumentSelector instrument_combo;
InstrumentSelector instrument_combo(InstrumentSelector::ForTrackDefault);
ComboBoxText strict_io_combo;
string pn = AudioEngine::instance()->get_pretty_name_by_name (port_name);

View File

@ -1757,7 +1757,7 @@ SoundFileOmega::SoundFileOmega (string title, ARDOUR::Session* s,
bool persistent,
Editing::ImportMode mode_hint)
: SoundFileBrowser (title, s, persistent)
, instrument_combo (false)
, instrument_combo (InstrumentSelector::ForTrackSelector)
, copy_files_btn ( _("Copy files to session"))
, smf_tempo_btn (_("Use MIDI Tempo Map (if defined)"))
, smf_marker_btn (_("Import MIDI markers (if any)"))

View File

@ -742,7 +742,7 @@ TriggerPage::drop_paths_part_two (std::vector<std::string> paths)
audio_paths.push_back (*s);
}
}
InstrumentSelector is; // instantiation builds instrument-list and sets default.
InstrumentSelector is(InstrumentSelector::ForTrackDefault); // instantiation builds instrument-list and sets default.
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, is.selected_instrument (), false);