void ValueTree::SharedObject::setProperty (const var::identifier& name, const var& newValue, UndoManager* const undoManager)
{
    for (int i = properties.size(); --i >= 0;)
    {
        Property* const p = properties.getUnchecked(i);

        if (p->name == name)
        {
            if (p->value != newValue)
            {
                if (undoManager == 0)
                {
                    p->value = newValue;
                    sendPropertyChangeMessage (name);
                }
                else
                {
                    undoManager->perform (new ValueTreeSetPropertyAction (this, name, newValue, false, false));
                }
            }

            return;
        }
    }

    if (undoManager == 0)
    {
        properties.add (new Property (name, newValue));
        sendPropertyChangeMessage (name);
    }
    else
    {
        undoManager->perform (new ValueTreeSetPropertyAction (this, name, newValue, true, false));
    }
}
Example #2
0
void ValueTree::SharedObject::removeProperty (const Identifier& name, UndoManager* const undoManager)
{
    if (undoManager == 0)
    {
        if (properties.remove (name))
            sendPropertyChangeMessage (name);
    }
    else
    {
        if (properties.contains (name))
            undoManager->perform (new SetPropertyAction (this, name, var::null, properties [name], false, true));
    }
}
Example #3
0
 void removeProperty (const Identifier& name, UndoManager* const undoManager)
 {
     if (undoManager == nullptr)
     {
         if (properties.remove (name))
             sendPropertyChangeMessage (name);
     }
     else
     {
         if (properties.contains (name))
             undoManager->perform (new SetPropertyAction (this, name, var(), properties [name], false, true));
     }
 }
Example #4
0
void ValueTree::SharedObject::removeAllProperties (UndoManager* const undoManager)
{
    if (undoManager == 0)
    {
        while (properties.size() > 0)
        {
            const Identifier name (properties.getName (properties.size() - 1));
            properties.remove (name);
            sendPropertyChangeMessage (name);
        }
    }
    else
    {
        for (int i = properties.size(); --i >= 0;)
            undoManager->perform (new SetPropertyAction (this, properties.getName(i), var::null, properties.getValueAt(i), false, true));
    }
}
void ValueTree::SharedObject::removeAllProperties (UndoManager* const undoManager)
{
    if (undoManager == 0)
    {
        while (properties.size() > 0)
        {
            const var::identifier name (properties.getLast()->name);
            properties.removeLast();
            sendPropertyChangeMessage (name);
        }
    }
    else
    {
        for (int i = properties.size(); --i >= 0;)
            undoManager->perform (new ValueTreeSetPropertyAction (this, properties.getUnchecked(i)->name, var(), false, true));
    }
}
Example #6
0
 void removeAllProperties (UndoManager* const undoManager)
 {
     if (undoManager == nullptr)
     {
         while (properties.size() > 0)
         {
             auto name = properties.getName (properties.size() - 1);
             properties.remove (name);
             sendPropertyChangeMessage (name);
         }
     }
     else
     {
         for (int i = properties.size(); --i >= 0;)
             undoManager->perform (new SetPropertyAction (this, properties.getName(i), {},
                                                          properties.getValueAt(i), false, true));
     }
 }
Example #7
0
 void setProperty (const Identifier& name, const var& newValue, UndoManager* const undoManager)
 {
     if (undoManager == nullptr)
     {
         if (properties.set (name, newValue))
             sendPropertyChangeMessage (name);
     }
     else
     {
         if (const var* const existingValue = properties.getVarPointer (name))
         {
             if (*existingValue != newValue)
                 undoManager->perform (new SetPropertyAction (this, name, newValue, *existingValue, false, false));
         }
         else
         {
             undoManager->perform (new SetPropertyAction (this, name, newValue, var(), true, false));
         }
     }
 }
Example #8
0
 void setProperty (const Identifier& name, const var& newValue, UndoManager* const undoManager,
                   ValueTree::Listener* listenerToExclude = nullptr)
 {
     if (undoManager == nullptr)
     {
         if (properties.set (name, newValue))
             sendPropertyChangeMessage (name, listenerToExclude);
     }
     else
     {
         if (auto* existingValue = properties.getVarPointer (name))
         {
             if (*existingValue != newValue)
                 undoManager->perform (new SetPropertyAction (this, name, newValue, *existingValue, false, false, listenerToExclude));
         }
         else
         {
             undoManager->perform (new SetPropertyAction (this, name, newValue, {}, true, false, listenerToExclude));
         }
     }
 }
Example #9
0
void ValueTree::SharedObject::setProperty (const Identifier& name, const var& newValue, UndoManager* const undoManager)
{
    if (undoManager == 0)
    {
        if (properties.set (name, newValue))
            sendPropertyChangeMessage (name);
    }
    else
    {
        var* const existingValue = properties.getVarPointer (name);

        if (existingValue != 0)
        {
            if (*existingValue != newValue)
                undoManager->perform (new SetPropertyAction (this, name, newValue, properties [name], false, false));
        }
        else
        {
            undoManager->perform (new SetPropertyAction (this, name, newValue, var::null, true, false));
        }
    }
}
void ValueTree::SharedObject::removeProperty (const var::identifier& name, UndoManager* const undoManager)
{
    for (int i = properties.size(); --i >= 0;)
    {
        Property* const p = properties.getUnchecked(i);

        if (p->name == name)
        {
            if (undoManager == 0)
            {
                properties.remove (i);
                sendPropertyChangeMessage (name);
            }
            else
            {
                undoManager->perform (new ValueTreeSetPropertyAction (this, name, var(), false, true));
            }

            break;
        }
    }
}