13
0

Save last route type

This commit is contained in:
itmuckel 2022-05-11 21:22:24 +02:00 committed by Robin Gareus
parent 9178ca635a
commit 2a4ebd17d6
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
3 changed files with 74 additions and 20 deletions

View File

@ -361,6 +361,10 @@ AddRouteDialog::on_response (int r)
UIConfiguration::instance().set_show_on_cue_page (show_on_cue_page());
UIConfiguration::instance().set_insert_at_position ((int) insert_at());
/* save last route type */
auto* node = _session->extra_xml ("AddRouteDialog", true);
node->set_property (X_("LastRouteType"), enum_2_string (type_wanted ()));
reset_name_edited ();
/* Don't call ArdourDialog::on_response() because that will
automatically hide the dialog.
@ -567,7 +571,7 @@ AddRouteDialog::get_template_path ()
AddRouteDialog::TypeWanted
AddRouteDialog::type_wanted()
{
if (trk_template_chooser.get_selection()->count_selected_rows() != 1) {
if (trk_template_chooser.get_selection ()->count_selected_rows () != 1) {
return AudioTrack;
}
TreeIter iter = trk_template_chooser.get_selection ()->get_selected ();
@ -576,9 +580,9 @@ AddRouteDialog::type_wanted()
const string str = (*iter)[track_template_columns.name];
if (str == _("Audio Busses")) {
return AudioBus;
} else if (str == _("MIDI Busses")){
} else if (str == _("MIDI Busses")) {
return MidiBus;
} else if (str == _("MIDI Tracks")){
} else if (str == _("MIDI Tracks")) {
return MidiTrack;
} else if (str == _("Audio Tracks")) {
return AudioTrack;
@ -587,11 +591,31 @@ AddRouteDialog::type_wanted()
} else if (str == _("Foldback Busses")) {
return FoldbackBus;
} else {
assert (0);
return AudioTrack;
}
}
std::string
AddRouteDialog::type_wanted_to_localized_string (AddRouteDialog::TypeWanted type_wanted) {
switch(type_wanted) {
case AudioBus:
return _("Audio Busses");
case MidiBus:
return _("MIDI Busses");
case MidiTrack:
return _("MIDI Tracks");
case AudioTrack:
return _("Audio Tracks");
case VCAMaster:
return _("VCA Masters");
case FoldbackBus:
return _("Foldback Busses");
default:
return _("Audio Tracks");
break;
}
}
void
AddRouteDialog::maybe_update_name_template_entry ()
{
@ -990,6 +1014,26 @@ AddRouteDialog::refill_channel_setups ()
row[track_template_columns.modified_with] = x->modified_with;
}
/* load and select last route type */
if (_session) {
auto node = _session->extra_xml (X_("AddRouteDialog"), false);
std::string last_route{};
if (node && node->get_property (X_ ("LastRouteType"), last_route)) {
auto type_wanted = static_cast<TypeWanted> (string_2_enum (last_route, TypeWanted));
for (const auto& row : trk_template_chooser.get_model ()->children ()) {
std::string node_value{};
row.get_value (0, node_value);
if (node_value == type_wanted_to_localized_string (type_wanted)) {
trk_template_chooser.get_selection ()->select (row);
break;
}
}
}
}
set_popdown_strings (channel_combo, channel_combo_strings);
if (!channel_current_choice.empty()) {

View File

@ -47,6 +47,7 @@
#include "ardour/plugin.h"
#include "ardour/types.h"
#include "ardour/template_utils.h"
#include "ardour/route_group.h"
#include "ardour_dialog.h"
#include "instrument_selector.h"
@ -117,17 +118,18 @@ private:
Gtk::ComboBoxText strict_io_combo;
Gtk::CheckButton show_on_cue_chkbox;
void track_type_chosen ();
void refill_channel_setups ();
void refill_route_groups ();
void refill_track_modes ();
void add_route_group (ARDOUR::RouteGroup*);
void group_changed ();
void channel_combo_changed ();
bool channel_separator (const Glib::RefPtr<Gtk::TreeModel>& m, const Gtk::TreeModel::iterator& i);
bool route_separator (const Glib::RefPtr<Gtk::TreeModel>& m, const Gtk::TreeModel::iterator& i);
void maybe_update_name_template_entry ();
void instrument_changed ();
void track_type_chosen ();
std::string type_wanted_to_localized_string (TypeWanted type_wanted);
void refill_channel_setups ();
void refill_route_groups ();
void refill_track_modes ();
void add_route_group (ARDOUR::RouteGroup*);
void group_changed ();
void channel_combo_changed ();
bool channel_separator (const Glib::RefPtr<Gtk::TreeModel>& m, const Gtk::TreeModel::iterator& i);
bool route_separator (const Glib::RefPtr<Gtk::TreeModel>& m, const Gtk::TreeModel::iterator& i);
void maybe_update_name_template_entry ();
void instrument_changed ();
struct TrackTemplateColumns : public Gtk::TreeModel::ColumnRecord {
TrackTemplateColumns ()

View File

@ -24,12 +24,11 @@
#include "pbd/enumwriter.h"
#include "widgets/ardour_icon.h"
#include "add_route_dialog.h"
#include "audio_clock.h"
#include "editing.h"
#include "enums.h"
#include "editor_items.h"
#include "enums.h"
#include "startup_fsm.h"
using namespace std;
@ -60,11 +59,12 @@ setup_gtk_ardour_enums ()
StartupFSM::MainState startup_state;
StartupFSM::DialogID startup_dialog;
Gtk::ResponseType dialog_response;
AddRouteDialog::TypeWanted type_wanted;
#define REGISTER(e) enum_writer.register_distinct (typeid(e).name(), i, s); i.clear(); s.clear()
#define REGISTER_BITS(e) enum_writer.register_bits (typeid(e).name(), i, s); i.clear(); s.clear()
#define REGISTER_ENUM(e) i.push_back (e); s.push_back (#e)
#define REGISTER_CLASS_ENUM(t,e) i.push_back (t::e); s.push_back (#e)
#define REGISTER_ENUM(e) i.emplace_back (e); s.emplace_back (#e)
#define REGISTER_CLASS_ENUM(t,e) i.emplace_back (t::e); s.emplace_back (#e)
REGISTER_CLASS_ENUM (AudioClock, Timecode);
REGISTER_CLASS_ENUM (AudioClock, BBT);
@ -217,4 +217,12 @@ setup_gtk_ardour_enums ()
REGISTER_ENUM (RESPONSE_APPLY);
REGISTER_ENUM (RESPONSE_HELP);
REGISTER (dialog_response);
REGISTER_CLASS_ENUM (AddRouteDialog, AudioTrack);
REGISTER_CLASS_ENUM (AddRouteDialog, MidiTrack);
REGISTER_CLASS_ENUM (AddRouteDialog, AudioBus);
REGISTER_CLASS_ENUM (AddRouteDialog, MidiBus);
REGISTER_CLASS_ENUM (AddRouteDialog, VCAMaster);
REGISTER_CLASS_ENUM (AddRouteDialog, FoldbackBus);
REGISTER (type_wanted);
}