void LLControlVariable::setValue(const LLSD& new_value, bool saved_value) { if ((*mValidateSignal)(this, new_value) == false) { // can not set new value, exit return; } LLSD storable_value = getComparableValue(new_value); bool value_changed = llsd_compare(getValue(), storable_value) == FALSE; if(saved_value) { // If we're going to save this value, return to default but don't fire resetToDefault(false); if (llsd_compare(mValues.back(), storable_value) == FALSE) { mValues.push_back(storable_value); } } else { // This is a unsaved value. Its needs to reside at // mValues[2] (or greater). It must not affect // the result of getSaveValue() if (llsd_compare(mValues.back(), storable_value) == FALSE) { while(mValues.size() > 2) { // Remove any unsaved values. mValues.pop_back(); } if(mValues.size() < 2) { // Add the default to the 'save' value. mValues.push_back(mValues[0]); } // Add the 'un-save' value. mValues.push_back(storable_value); } } if(value_changed) { if(getCOAActive() == this) (*mCommitSignal)(this,storable_value); } }
void LLControlVariable::setDefaultValue(const LLSD& value) { // Set the control variables value and make it // the default value. If the active value is changed, // send the signal. // *NOTE: Default values are not saved, only read. LLSD comparable_value = getComparableValue(value); bool value_changed = (llsd_compare(getValue(), comparable_value) == FALSE); resetToDefault(false); mValues[0] = comparable_value; if(value_changed) { firePropertyChanged(); } }