mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 23:05:04 +01:00
Rename various things in the property system.
git-svn-id: svn://localhost/ardour2/branches/3.0@7681 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
167c439002
commit
7b29752441
17 changed files with 60 additions and 66 deletions
|
|
@ -416,7 +416,7 @@ AddRouteDialog::group_changed ()
|
|||
|
||||
PropertyList plist;
|
||||
plist.add (Properties::active, true);
|
||||
g->set_properties (plist);
|
||||
g->apply_changes (plist);
|
||||
|
||||
RouteGroupDialog d (g, Gtk::Stock::NEW);
|
||||
int const r = d.do_run ();
|
||||
|
|
|
|||
|
|
@ -366,7 +366,7 @@ EditorRouteGroups::row_change (const Gtk::TreeModel::Path&, const Gtk::TreeModel
|
|||
|
||||
group->set_hidden (!(*iter)[_columns.is_visible], this);
|
||||
|
||||
group->set_properties (plist);
|
||||
group->apply_changes (plist);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -379,7 +379,7 @@ void
|
|||
GroupTabs::run_new_group_dialog (RouteList const & rl)
|
||||
{
|
||||
RouteGroup* g = new RouteGroup (*_session, "");
|
||||
g->set_properties (default_properties ());
|
||||
g->apply_changes (default_properties ());
|
||||
|
||||
RouteGroupDialog d (g, Gtk::Stock::NEW);
|
||||
int const r = d.do_run ();
|
||||
|
|
@ -402,7 +402,7 @@ GroupTabs::create_and_add_group () const
|
|||
{
|
||||
RouteGroup* g = new RouteGroup (*_session, "");
|
||||
|
||||
g->set_properties (default_properties ());
|
||||
g->apply_changes (default_properties ());
|
||||
|
||||
RouteGroupDialog d (g, Gtk::Stock::NEW);
|
||||
int const r = d.do_run ();
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ RouteGroupDialog::do_run ()
|
|||
plist.add (Properties::active, _active.get_active());
|
||||
plist.add (Properties::name, string (_name.get_text()));
|
||||
|
||||
_group->set_properties (plist);
|
||||
_group->apply_changes (plist);
|
||||
}
|
||||
|
||||
return r;
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ RouteGroupMenu::new_group ()
|
|||
}
|
||||
|
||||
RouteGroup* g = new RouteGroup (*_session, "");
|
||||
g->set_properties (*_default_properties);
|
||||
g->apply_changes (*_default_properties);
|
||||
|
||||
RouteGroupDialog d (g, Gtk::Stock::NEW);
|
||||
int const r = d.do_run ();
|
||||
|
|
|
|||
|
|
@ -2144,7 +2144,7 @@ Playlist::property_factory (const XMLNode& history_node) const
|
|||
|
||||
RegionListProperty* rlp = new RegionListProperty (*const_cast<Playlist*> (this));
|
||||
|
||||
if (rlp->load_history_state (**i)) {
|
||||
if (rlp->set_change (**i)) {
|
||||
if (!prop_list) {
|
||||
prop_list = new PropertyList();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1216,7 +1216,7 @@ Region::_set_state (const XMLNode& node, int version, PropertyChange& what_chang
|
|||
{
|
||||
const XMLProperty* prop;
|
||||
|
||||
what_changed = set_properties (node);
|
||||
what_changed = set_values (node);
|
||||
|
||||
if ((prop = node.property (X_("id")))) {
|
||||
_id = prop->value();
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ RegionFactory::create (boost::shared_ptr<Region> region, frameoffset_t offset, b
|
|||
}
|
||||
|
||||
if (ret) {
|
||||
ret->set_properties (plist);
|
||||
ret->apply_changes (plist);
|
||||
map_add (ret);
|
||||
|
||||
if (announce) {
|
||||
|
|
@ -162,7 +162,7 @@ RegionFactory::create (boost::shared_ptr<Region> region, const SourceList& srcs,
|
|||
|
||||
if (ret) {
|
||||
|
||||
ret->set_properties (plist);
|
||||
ret->apply_changes (plist);
|
||||
map_add (ret);
|
||||
|
||||
if (announce) {
|
||||
|
|
@ -207,7 +207,7 @@ RegionFactory::create (const SourceList& srcs, const PropertyList& plist, bool a
|
|||
|
||||
if (ret) {
|
||||
|
||||
ret->set_properties (plist);
|
||||
ret->apply_changes (plist);
|
||||
map_add (ret);
|
||||
|
||||
if (announce) {
|
||||
|
|
|
|||
|
|
@ -235,7 +235,7 @@ RouteGroup::set_state (const XMLNode& node, int version)
|
|||
return set_state_2X (node, version);
|
||||
}
|
||||
|
||||
set_properties (node);
|
||||
set_values (node);
|
||||
|
||||
const XMLProperty *prop;
|
||||
|
||||
|
|
@ -260,7 +260,7 @@ RouteGroup::set_state (const XMLNode& node, int version)
|
|||
int
|
||||
RouteGroup::set_state_2X (const XMLNode& node, int /*version*/)
|
||||
{
|
||||
set_properties (node);
|
||||
set_values (node);
|
||||
|
||||
if (node.name() == "MixGroup") {
|
||||
_gain = true;
|
||||
|
|
|
|||
|
|
@ -85,20 +85,16 @@ public:
|
|||
_have_old = false;
|
||||
}
|
||||
|
||||
void add_history_state (XMLNode* history_node) const {
|
||||
void get_change (XMLNode* history_node) const {
|
||||
/* We can get to the current state of a scalar property like this one simply
|
||||
by knowing what the new state is.
|
||||
*/
|
||||
history_node->add_property (property_name(), to_string (_current));
|
||||
}
|
||||
|
||||
/** Try to set state from the property of an XML node.
|
||||
* @param node XML node.
|
||||
* @return true if the value of the property is changed
|
||||
*/
|
||||
bool set_state_from_owner_state (XMLNode const& owner_state) {
|
||||
bool set_value (XMLNode const & node) {
|
||||
|
||||
XMLProperty const* p = owner_state.property (property_name());
|
||||
XMLProperty const* p = node.property (property_name());
|
||||
|
||||
if (p) {
|
||||
T const v = from_string (p->value ());
|
||||
|
|
@ -112,12 +108,13 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
void add_state_to_owner_state (XMLNode& owner_state) const {
|
||||
owner_state.add_property (property_name(), to_string (_current));
|
||||
void get_value (XMLNode & node) const {
|
||||
node.add_property (property_name(), to_string (_current));
|
||||
}
|
||||
|
||||
bool changed () const { return _have_old; }
|
||||
void set_state_from_property (PropertyBase const * p) {
|
||||
|
||||
void apply_change (PropertyBase const * p) {
|
||||
T v = dynamic_cast<const PropertyTemplate<T>* > (p)->val ();
|
||||
if (v != _current) {
|
||||
set (v);
|
||||
|
|
|
|||
|
|
@ -89,10 +89,8 @@ public:
|
|||
/** Forget about any old value for this state */
|
||||
virtual void clear_history () = 0;
|
||||
|
||||
/** Make XML that allows us to get from some previous state to the current state
|
||||
* of this property, and add it to @param history_node
|
||||
*/
|
||||
virtual void add_history_state (XMLNode* history_node) const = 0;
|
||||
/** Get any change in this property as XML and add it to a node */
|
||||
virtual void get_change (XMLNode *) const = 0;
|
||||
|
||||
/** Add information to two property lists: one that allows
|
||||
* undo of the changes in this property's state betwen now and
|
||||
|
|
@ -103,19 +101,21 @@ public:
|
|||
|
||||
virtual PropertyBase* maybe_clone_self_if_found_in_history_node (const XMLNode&) const { return 0; }
|
||||
|
||||
/** Set state from an XML node previously generated by add_history_state */
|
||||
virtual bool set_state_from_owner_state (XMLNode const&) = 0;
|
||||
/** Set our value from an XML node.
|
||||
* @return true if the value was set.
|
||||
*/
|
||||
virtual bool set_value (XMLNode const &) = 0;
|
||||
|
||||
/** Add complete current state in XML form to an existing XML node @param node */
|
||||
virtual void add_state_to_owner_state (XMLNode& node) const = 0;
|
||||
/** Get our value and put it into an XML node */
|
||||
virtual void get_value (XMLNode& node) const = 0;
|
||||
|
||||
/** @return true if this property has changed in value since construction or since
|
||||
* the last call to clear_history(), whichever was more recent.
|
||||
*/
|
||||
virtual bool changed() const = 0;
|
||||
|
||||
/** Set the value of this property from another */
|
||||
virtual void set_state_from_property (PropertyBase const *) = 0;
|
||||
/** Apply a change contained in another Property to this one */
|
||||
virtual void apply_change (PropertyBase const *) = 0;
|
||||
|
||||
const gchar*property_name () const { return g_quark_to_string (_property_id); }
|
||||
PropertyID property_id () const { return _property_id; }
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ public:
|
|||
|
||||
virtual ~PropertyList();
|
||||
|
||||
void add_history_state (XMLNode* before);
|
||||
void get_changes (XMLNode *);
|
||||
|
||||
/** Add a property (of some kind) to the list. Used when
|
||||
constructing PropertyLists that describe a change/operation.
|
||||
|
|
|
|||
|
|
@ -94,11 +94,7 @@ class SequenceProperty : public PropertyBase
|
|||
_change.removed.swap (_change.added);
|
||||
}
|
||||
|
||||
void add_history_state (XMLNode* history_node) const {
|
||||
|
||||
/* We could record the whole of the current state here, but its
|
||||
obviously more efficient just to record what has changed.
|
||||
*/
|
||||
void get_change (XMLNode* history_node) const {
|
||||
|
||||
XMLNode* child = new XMLNode (PBD::capitalize (property_name()));
|
||||
history_node->add_child_nocopy (*child);
|
||||
|
|
@ -121,14 +117,15 @@ class SequenceProperty : public PropertyBase
|
|||
}
|
||||
}
|
||||
|
||||
bool set_state_from_owner_state (XMLNode const& owner_state) {
|
||||
bool set_value (XMLNode const &) {
|
||||
/* XXX: not used, but probably should be */
|
||||
assert (false);
|
||||
return false;
|
||||
}
|
||||
|
||||
void add_state_to_owner_state (XMLNode& owner_state_node) const {
|
||||
void get_value (XMLNode & node) const {
|
||||
for (typename Container::const_iterator i = _val.begin(); i != _val.end(); ++i) {
|
||||
owner_state_node.add_child_nocopy ((*i)->get_state ());
|
||||
node.add_child_nocopy ((*i)->get_state ());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -141,7 +138,7 @@ class SequenceProperty : public PropertyBase
|
|||
_change.removed.clear ();
|
||||
}
|
||||
|
||||
void set_state_from_property (PropertyBase const * p) {
|
||||
void apply_change (PropertyBase const * p) {
|
||||
const ChangeRecord& change (dynamic_cast<const SequenceProperty*> (p)->change ());
|
||||
update (change);
|
||||
}
|
||||
|
|
@ -301,7 +298,7 @@ class SequenceProperty : public PropertyBase
|
|||
* @return true if loading succeeded, false otherwise
|
||||
*/
|
||||
|
||||
bool load_history_state (const XMLNode& history_node) {
|
||||
bool set_change (XMLNode const & history_node) {
|
||||
|
||||
const XMLNodeList& children (history_node.children());
|
||||
|
||||
|
|
|
|||
|
|
@ -48,9 +48,10 @@ class Stateful {
|
|||
|
||||
virtual XMLNode& get_state (void) = 0;
|
||||
virtual int set_state (const XMLNode&, int version) = 0;
|
||||
virtual bool set_property (const PropertyBase&);
|
||||
|
||||
PropertyChange set_properties (const PropertyList&);
|
||||
virtual bool apply_change (PropertyBase const &);
|
||||
PropertyChange apply_changes (PropertyList const &);
|
||||
|
||||
const OwnedPropertyList& properties() const { return *_properties; }
|
||||
|
||||
void add_property (PropertyBase& s);
|
||||
|
|
@ -92,10 +93,8 @@ class Stateful {
|
|||
void add_instant_xml (XMLNode&, const sys::path& directory_path);
|
||||
XMLNode *instant_xml (const std::string& str, const sys::path& directory_path);
|
||||
void add_properties (XMLNode &);
|
||||
/* derived types can call this from ::set_state() (or elsewhere)
|
||||
to get basic property setting done.
|
||||
*/
|
||||
PropertyChange set_properties (XMLNode const &);
|
||||
|
||||
PropertyChange set_values (XMLNode const &);
|
||||
|
||||
/* derived classes can implement this to do cross-checking
|
||||
of property values after either a PropertyList or XML
|
||||
|
|
|
|||
|
|
@ -39,13 +39,13 @@ PropertyList::~PropertyList ()
|
|||
}
|
||||
|
||||
void
|
||||
PropertyList::add_history_state (XMLNode* history_node)
|
||||
PropertyList::get_changes (XMLNode* history_node)
|
||||
{
|
||||
for (const_iterator i = begin(); i != end(); ++i) {
|
||||
DEBUG_TRACE (DEBUG::Properties, string_compose ("Add before/after to %1 for %2\n",
|
||||
history_node->name(),
|
||||
i->second->property_name()));
|
||||
i->second->add_history_state (history_node);
|
||||
i->second->get_change (history_node);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -174,17 +174,18 @@ Stateful::diff (PropertyList& before, PropertyList& after, Command* cmd) const
|
|||
}
|
||||
}
|
||||
|
||||
/** Set state of some/all _properties from an XML node.
|
||||
* @param owner_state Node.
|
||||
* @return PropertyChanges made.
|
||||
/** Set our property values from an XML node.
|
||||
* Derived types can call this from ::set_state() (or elsewhere)
|
||||
* to get basic property setting done.
|
||||
* @return IDs of properties that were changed.
|
||||
*/
|
||||
PropertyChange
|
||||
Stateful::set_properties (XMLNode const & owner_state)
|
||||
Stateful::set_values (XMLNode const & node)
|
||||
{
|
||||
PropertyChange c;
|
||||
|
||||
for (OwnedPropertyList::iterator i = _properties->begin(); i != _properties->end(); ++i) {
|
||||
if (i->second->set_state_from_owner_state (owner_state)) {
|
||||
if (i->second->set_value (node)) {
|
||||
c.add (i->first);
|
||||
}
|
||||
}
|
||||
|
|
@ -195,7 +196,7 @@ Stateful::set_properties (XMLNode const & owner_state)
|
|||
}
|
||||
|
||||
PropertyChange
|
||||
Stateful::set_properties (const PropertyList& property_list)
|
||||
Stateful::apply_changes (const PropertyList& property_list)
|
||||
{
|
||||
PropertyChange c;
|
||||
PropertyList::const_iterator p;
|
||||
|
|
@ -209,7 +210,7 @@ Stateful::set_properties (const PropertyList& property_list)
|
|||
for (PropertyList::const_iterator i = property_list.begin(); i != property_list.end(); ++i) {
|
||||
if ((p = _properties->find (i->first)) != _properties->end()) {
|
||||
DEBUG_TRACE (DEBUG::Stateful, string_compose ("actually setting property %1\n", p->second->property_name()));
|
||||
if (set_property (*i->second)) {
|
||||
if (apply_change (*i->second)) {
|
||||
c.add (i->first);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -232,7 +233,7 @@ void
|
|||
Stateful::add_properties (XMLNode& owner_state)
|
||||
{
|
||||
for (OwnedPropertyList::iterator i = _properties->begin(); i != _properties->end(); ++i) {
|
||||
i->second->add_state_to_owner_state (owner_state);
|
||||
i->second->get_value (owner_state);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -302,14 +303,14 @@ Stateful::changed() const
|
|||
}
|
||||
|
||||
bool
|
||||
Stateful::set_property (const PropertyBase& prop)
|
||||
Stateful::apply_change (const PropertyBase& prop)
|
||||
{
|
||||
OwnedPropertyList::iterator i = _properties->find (prop.property_id());
|
||||
if (i == _properties->end()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
i->second->set_state_from_property (&prop);
|
||||
i->second->apply_change (&prop);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ StatefulDiffCommand::operator() ()
|
|||
boost::shared_ptr<Stateful> s (_object.lock());
|
||||
|
||||
if (s) {
|
||||
s->set_properties (*_redo);
|
||||
s->apply_changes (*_redo);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -96,7 +96,7 @@ StatefulDiffCommand::undo ()
|
|||
|
||||
if (s) {
|
||||
std::cerr << "Undoing a stateful diff command\n";
|
||||
s->set_properties (*_undo);
|
||||
s->apply_changes (*_undo);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -118,8 +118,8 @@ StatefulDiffCommand::get_state ()
|
|||
XMLNode* undo = new XMLNode (X_("Undo"));
|
||||
XMLNode* redo = new XMLNode (X_("Do"));
|
||||
|
||||
_undo->add_history_state (undo);
|
||||
_redo->add_history_state (redo);
|
||||
_undo->get_changes (undo);
|
||||
_redo->get_changes (redo);
|
||||
|
||||
node->add_child_nocopy (*undo);
|
||||
node->add_child_nocopy (*redo);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue