modify design of configuration state saving to reflect discussions on IRC
git-svn-id: svn://localhost/ardour2/trunk@934 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
93c7aeba04
commit
7adf76bbe6
|
@ -47,6 +47,8 @@ ARDOUR_UI::toggle_config_state (const char* group, const char* action, bool (Con
|
|||
|
||||
if (tact) {
|
||||
bool x = (Config->*get)();
|
||||
|
||||
cerr << "\ttoggle config, action = " << tact->get_active() << " config = " << x << endl;
|
||||
|
||||
if (x != tact->get_active()) {
|
||||
(Config->*set) (!x);
|
||||
|
@ -382,18 +384,27 @@ ARDOUR_UI::map_some_state (const char* group, const char* action, bool (Configur
|
|||
Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
|
||||
|
||||
if (tact) {
|
||||
|
||||
bool x = (Config->*get)();
|
||||
|
||||
cerr << "\tmap state, action = " << tact->get_active() << " config = " << x << endl;
|
||||
|
||||
if (tact->get_active() != x) {
|
||||
tact->set_active (x);
|
||||
}
|
||||
} else {
|
||||
cerr << "not a toggle\n";
|
||||
}
|
||||
} else {
|
||||
cerr << group << ':' << action << " not an action\n";
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ARDOUR_UI::parameter_changed (const char* parameter_name)
|
||||
{
|
||||
cerr << "Parameter changed : " << parameter_name << endl;
|
||||
|
||||
#define PARAM_IS(x) (!strcmp (parameter_name, (x)))
|
||||
|
||||
if (PARAM_IS ("slave-source")) {
|
||||
|
@ -416,8 +427,12 @@ ARDOUR_UI::parameter_changed (const char* parameter_name)
|
|||
map_some_state ("options", "UseMIDIcontrol", &Configuration::get_midi_control);
|
||||
} else if (PARAM_IS ("do-not-record-plugins")) {
|
||||
map_some_state ("options", "DoNotRunPluginsWhileRecording", &Configuration::get_do_not_record_plugins);
|
||||
} else if (PARAM_IS ("automatic-crossfades")) {
|
||||
map_some_state ("Editor", "toggle-auto-xfades", &Configuration::get_automatic_crossfades);
|
||||
} else if (PARAM_IS ("crossfades-active")) {
|
||||
map_some_state ("options", "CrossfadesActive", &Configuration::get_crossfades_active);
|
||||
map_some_state ("Editor", "toggle-xfades-active", &Configuration::get_crossfades_active);
|
||||
} else if (PARAM_IS ("crossfades-visible")) {
|
||||
map_some_state ("Editor", "toggle-xfades-visible", &Configuration::get_crossfades_visible);
|
||||
} else if (PARAM_IS ("latched-record-enable")) {
|
||||
map_some_state ("options", "LatchedRecordEnable", &Configuration::get_latched_record_enable);
|
||||
} else if (PARAM_IS ("solo-latched")) {
|
||||
|
|
|
@ -62,7 +62,7 @@ class Configuration : public Stateful
|
|||
|
||||
int set_state (const XMLNode&);
|
||||
XMLNode& get_state (void);
|
||||
XMLNode& get_partial_state (ConfigVariableBase::Owner);
|
||||
XMLNode& get_variables (sigc::slot<bool,ConfigVariableBase::Owner>);
|
||||
void set_variables (const XMLNode&, ConfigVariableBase::Owner owner);
|
||||
|
||||
void set_current_owner (ConfigVariableBase::Owner);
|
||||
|
@ -100,7 +100,8 @@ class Configuration : public Stateful
|
|||
ConfigVariableBase::Owner current_owner;
|
||||
XMLNode* _control_protocol_state;
|
||||
|
||||
XMLNode& state (ConfigVariableBase::Owner);
|
||||
XMLNode& state (sigc::slot<bool,ConfigVariableBase::Owner>);
|
||||
bool save_config_options_predicate (ConfigVariableBase::Owner owner);
|
||||
};
|
||||
|
||||
extern Configuration *Config;
|
||||
|
|
|
@ -11,11 +11,11 @@ namespace ARDOUR {
|
|||
class ConfigVariableBase {
|
||||
public:
|
||||
enum Owner {
|
||||
Default,
|
||||
System,
|
||||
Config,
|
||||
Session,
|
||||
Interface
|
||||
Default = 0x1,
|
||||
System = 0x2,
|
||||
Config = 0x4,
|
||||
Session = 0x8,
|
||||
Interface = 0x10
|
||||
};
|
||||
|
||||
ConfigVariableBase (std::string str) : _name (str), _owner (Default) {}
|
||||
|
@ -44,7 +44,7 @@ class ConfigVariable : public ConfigVariableBase
|
|||
return false;
|
||||
}
|
||||
value = val;
|
||||
_owner = owner;
|
||||
_owner = (ConfigVariableBase::Owner)(_owner |owner);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ class ConfigVariable : public ConfigVariableBase
|
|||
std::stringstream ss;
|
||||
ss << prop->value();
|
||||
ss >> value;
|
||||
_owner = owner;
|
||||
_owner = (ConfigVariableBase::Owner)(_owner |owner);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ class ConfigVariable : public ConfigVariableBase
|
|||
std::stringstream ss;
|
||||
ss << opt_prop->value();
|
||||
ss >> value;
|
||||
_owner = owner;
|
||||
_owner = (ConfigVariableBase::Owner)(_owner |owner);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,9 +55,11 @@ CONFIG_VARIABLE (bool, send_mmc, "send-mmc", false)
|
|||
CONFIG_VARIABLE (bool, mmc_control, "mmc-control", false)
|
||||
CONFIG_VARIABLE (bool, midi_feedback, "midi-feedback", false)
|
||||
CONFIG_VARIABLE (bool, midi_control, "midi-control", false)
|
||||
CONFIG_VARIABLE (bool, automatic_crossfades, "automatic-crossfades", false)
|
||||
CONFIG_VARIABLE (bool, crossfades_active, "crossfades-active", false)
|
||||
CONFIG_VARIABLE (bool, crossfades_visible, "crossfades-visible", false)
|
||||
CONFIG_VARIABLE (bool, seamless_loop, "seamless-loop", false)
|
||||
CONFIG_VARIABLE (bool, do_not_record_plugins, "do_not_record_plugins", false)
|
||||
CONFIG_VARIABLE (bool, do_not_record_plugins, "do-not-record-plugins", false)
|
||||
CONFIG_VARIABLE (AutoConnectOption, output_auto_connect, "output-auto-connect", AutoConnectOption (0))
|
||||
CONFIG_VARIABLE (AutoConnectOption, input_auto_connect, "input-auto-connect", AutoConnectOption (0))
|
||||
CONFIG_VARIABLE (EditMode, edit_mode, "edit-mode", Slide)
|
||||
|
|
|
@ -1087,6 +1087,7 @@ class Session : public sigc::trackable, public PBD::StatefulDestructible
|
|||
int load_options (const XMLNode&);
|
||||
XMLNode& get_options () const;
|
||||
int load_state (string snapshot_name);
|
||||
bool save_config_options_predicate (ConfigVariableBase::Owner owner) const;
|
||||
|
||||
nframes_t _last_roll_location;
|
||||
nframes_t _last_record_location;
|
||||
|
|
|
@ -132,14 +132,11 @@ Configuration::save_state()
|
|||
XMLTree tree;
|
||||
string rcfile;
|
||||
|
||||
/* Note: this only writes the state not touched by Session or Interface
|
||||
*/
|
||||
|
||||
rcfile = get_user_ardour_path ();
|
||||
rcfile += "ardour.rc";
|
||||
|
||||
if (rcfile.length()) {
|
||||
tree.set_root (&state (ConfigVariableBase::Config));
|
||||
tree.set_root (&get_state());
|
||||
if (!tree.write (rcfile.c_str())){
|
||||
error << string_compose (_("Config file %1 not saved"), rcfile) << endmsg;
|
||||
return -1;
|
||||
|
@ -149,22 +146,42 @@ Configuration::save_state()
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool
|
||||
Configuration::save_config_options_predicate (ConfigVariableBase::Owner owner)
|
||||
{
|
||||
const ConfigVariableBase::Owner default_or_from_config_file = (ConfigVariableBase::Owner)
|
||||
(ConfigVariableBase::Default|ConfigVariableBase::System|ConfigVariableBase::Config);
|
||||
|
||||
return owner & default_or_from_config_file;
|
||||
}
|
||||
|
||||
XMLNode&
|
||||
Configuration::get_state ()
|
||||
{
|
||||
return state (ConfigVariableBase::Config);
|
||||
}
|
||||
|
||||
XMLNode&
|
||||
Configuration::get_partial_state (ConfigVariableBase::Owner owner)
|
||||
{
|
||||
return state (owner);
|
||||
}
|
||||
|
||||
XMLNode&
|
||||
Configuration::state (ConfigVariableBase::Owner owner)
|
||||
{
|
||||
XMLNode* root;
|
||||
LocaleGuard lg (X_("POSIX"));
|
||||
|
||||
root = new XMLNode("Ardour");
|
||||
typedef map<string, MidiPortDescriptor*>::const_iterator CI;
|
||||
for(CI m = midi_ports.begin(); m != midi_ports.end(); ++m){
|
||||
root->add_child_nocopy(m->second->get_state());
|
||||
}
|
||||
|
||||
root->add_child_nocopy (get_variables (sigc::mem_fun (*this, &Configuration::save_config_options_predicate)));
|
||||
|
||||
if (_extra_xml) {
|
||||
root->add_child_copy (*_extra_xml);
|
||||
}
|
||||
|
||||
root->add_child_nocopy (ControlProtocolManager::instance().get_state());
|
||||
root->add_child_nocopy (Library->get_state());
|
||||
|
||||
return *root;
|
||||
}
|
||||
|
||||
XMLNode&
|
||||
Configuration::get_variables (sigc::slot<bool,ConfigVariableBase::Owner> predicate)
|
||||
{
|
||||
XMLNode* node;
|
||||
LocaleGuard lg (X_("POSIX"));
|
||||
|
||||
|
@ -173,36 +190,14 @@ Configuration::state (ConfigVariableBase::Owner owner)
|
|||
#undef CONFIG_VARIABLE
|
||||
#undef CONFIG_VARIABLE_SPECIAL
|
||||
#define CONFIG_VARIABLE(type,var,name,value) \
|
||||
if (var.owner() <= owner) var.add_to_node (*node);
|
||||
if (predicate (var.owner())) { var.add_to_node (*node); }
|
||||
#define CONFIG_VARIABLE_SPECIAL(type,var,name,value,mutator) \
|
||||
if (var.owner() <= owner) var.add_to_node (*node);
|
||||
if (predicate (var.owner())) { var.add_to_node (*node); }
|
||||
#include "ardour/configuration_vars.h"
|
||||
#undef CONFIG_VARIABLE
|
||||
#undef CONFIG_VARIABLE_SPECIAL
|
||||
|
||||
if (owner == ConfigVariableBase::Config) {
|
||||
|
||||
root = new XMLNode("Ardour");
|
||||
typedef map<string, MidiPortDescriptor*>::const_iterator CI;
|
||||
for(CI m = midi_ports.begin(); m != midi_ports.end(); ++m){
|
||||
root->add_child_nocopy(m->second->get_state());
|
||||
}
|
||||
|
||||
root->add_child_nocopy (*node);
|
||||
|
||||
if (_extra_xml) {
|
||||
root->add_child_copy (*_extra_xml);
|
||||
}
|
||||
|
||||
root->add_child_nocopy (ControlProtocolManager::instance().get_state());
|
||||
root->add_child_nocopy (Library->get_state());
|
||||
|
||||
} else {
|
||||
|
||||
root = node;
|
||||
}
|
||||
|
||||
return *root;
|
||||
|
||||
return *node;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -725,13 +725,22 @@ Session::load_options (const XMLNode& node)
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool
|
||||
Session::save_config_options_predicate (ConfigVariableBase::Owner owner) const
|
||||
{
|
||||
const ConfigVariableBase::Owner modified_by_session_or_user = (ConfigVariableBase::Owner)
|
||||
(ConfigVariableBase::Session|ConfigVariableBase::Interface);
|
||||
|
||||
return owner & modified_by_session_or_user;
|
||||
}
|
||||
|
||||
XMLNode&
|
||||
Session::get_options () const
|
||||
{
|
||||
XMLNode* child;
|
||||
LocaleGuard lg (X_("POSIX"));
|
||||
|
||||
XMLNode& option_root = Config->get_partial_state (ConfigVariableBase::Interface);
|
||||
XMLNode& option_root = Config->get_variables (mem_fun (*this, &Session::save_config_options_predicate));
|
||||
|
||||
child = option_root.add_child ("end-marker-is-free");
|
||||
child->add_property ("val", _end_location_is_free ? "yes" : "no");
|
||||
|
|
Loading…
Reference in New Issue
Block a user