示例#1
0
void LLControlVariable::resetToDefault(bool fire_signal)
{
	//The first setting is always the default
	//Pop to it and fire off the listener
	while(mValues.size() > 1)
	{
		mValues.pop_back();
	}
	
	if(fire_signal) 
	{
		firePropertyChanged();
	}
}
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);
	LLSD original_value = getValue();
	bool value_changed = llsd_compare(original_value, 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 an 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)
    {
		firePropertyChanged(original_value);
		mSanitySignal(this,isSane());
    }
}
示例#3
0
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();
	}
}
示例#4
0
 void setString(Item* target, const wstring& newValue)
 {
   wstring* data = static_cast<wstring*>(getDataPointer(target));
   *data = newValue;
   firePropertyChanged(target);
 }