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_show_on_cue_page (show_on_cue_page());
UIConfiguration::instance().set_insert_at_position ((int) insert_at()); 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 (); reset_name_edited ();
/* Don't call ArdourDialog::on_response() because that will /* Don't call ArdourDialog::on_response() because that will
automatically hide the dialog. automatically hide the dialog.
@ -587,11 +591,31 @@ AddRouteDialog::type_wanted()
} else if (str == _("Foldback Busses")) { } else if (str == _("Foldback Busses")) {
return FoldbackBus; return FoldbackBus;
} else { } else {
assert (0);
return AudioTrack; 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 void
AddRouteDialog::maybe_update_name_template_entry () AddRouteDialog::maybe_update_name_template_entry ()
{ {
@ -990,6 +1014,26 @@ AddRouteDialog::refill_channel_setups ()
row[track_template_columns.modified_with] = x->modified_with; 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); set_popdown_strings (channel_combo, channel_combo_strings);
if (!channel_current_choice.empty()) { if (!channel_current_choice.empty()) {

View File

@ -47,6 +47,7 @@
#include "ardour/plugin.h" #include "ardour/plugin.h"
#include "ardour/types.h" #include "ardour/types.h"
#include "ardour/template_utils.h" #include "ardour/template_utils.h"
#include "ardour/route_group.h"
#include "ardour_dialog.h" #include "ardour_dialog.h"
#include "instrument_selector.h" #include "instrument_selector.h"
@ -118,6 +119,7 @@ private:
Gtk::CheckButton show_on_cue_chkbox; Gtk::CheckButton show_on_cue_chkbox;
void track_type_chosen (); void track_type_chosen ();
std::string type_wanted_to_localized_string (TypeWanted type_wanted);
void refill_channel_setups (); void refill_channel_setups ();
void refill_route_groups (); void refill_route_groups ();
void refill_track_modes (); void refill_track_modes ();

View File

@ -24,12 +24,11 @@
#include "pbd/enumwriter.h" #include "pbd/enumwriter.h"
#include "widgets/ardour_icon.h" #include "add_route_dialog.h"
#include "audio_clock.h" #include "audio_clock.h"
#include "editing.h" #include "editing.h"
#include "enums.h"
#include "editor_items.h" #include "editor_items.h"
#include "enums.h"
#include "startup_fsm.h" #include "startup_fsm.h"
using namespace std; using namespace std;
@ -60,11 +59,12 @@ setup_gtk_ardour_enums ()
StartupFSM::MainState startup_state; StartupFSM::MainState startup_state;
StartupFSM::DialogID startup_dialog; StartupFSM::DialogID startup_dialog;
Gtk::ResponseType dialog_response; 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(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_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_ENUM(e) i.emplace_back (e); s.emplace_back (#e)
#define REGISTER_CLASS_ENUM(t,e) i.push_back (t::e); s.push_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, Timecode);
REGISTER_CLASS_ENUM (AudioClock, BBT); REGISTER_CLASS_ENUM (AudioClock, BBT);
@ -217,4 +217,12 @@ setup_gtk_ardour_enums ()
REGISTER_ENUM (RESPONSE_APPLY); REGISTER_ENUM (RESPONSE_APPLY);
REGISTER_ENUM (RESPONSE_HELP); REGISTER_ENUM (RESPONSE_HELP);
REGISTER (dialog_response); 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);
} }