1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-11 23:54:18 +00:00

Added method ValueTree::getRoot()

This commit is contained in:
jules 2017-01-01 11:58:29 +00:00
parent a15d79d4fe
commit 7eb534ae88
2 changed files with 22 additions and 7 deletions

View file

@ -57,6 +57,11 @@ public:
}
}
SharedObject* getRoot() noexcept
{
return parent == nullptr ? this : parent->getRoot();
}
template <typename Method>
void callListeners (Method method, ValueTree& tree) const
{
@ -483,9 +488,8 @@ public:
}
//==============================================================================
class SetPropertyAction : public UndoableAction
struct SetPropertyAction : public UndoableAction
{
public:
SetPropertyAction (SharedObject* const so, const Identifier& propertyName,
const var& newVal, const var& oldVal, bool isAdding, bool isDeleting,
ValueTree::Listener* listenerToExclude = nullptr)
@ -547,9 +551,8 @@ public:
};
//==============================================================================
class AddOrRemoveChildAction : public UndoableAction
struct AddOrRemoveChildAction : public UndoableAction
{
public:
AddOrRemoveChildAction (SharedObject* parentObject, int index, SharedObject* newChild)
: target (parentObject),
child (newChild != nullptr ? newChild : parentObject->children.getObjectPointer (index)),
@ -600,9 +603,8 @@ public:
};
//==============================================================================
class MoveChildAction : public UndoableAction
struct MoveChildAction : public UndoableAction
{
public:
MoveChildAction (SharedObject* parentObject, int fromIndex, int toIndex) noexcept
: parent (parentObject), startIndex (fromIndex), endIndex (toIndex)
{
@ -751,6 +753,12 @@ ValueTree ValueTree::getParent() const noexcept
: static_cast<SharedObject*> (nullptr));
}
ValueTree ValueTree::getRoot() const noexcept
{
return ValueTree (object != nullptr ? object->getRoot()
: static_cast<SharedObject*> (nullptr));
}
ValueTree ValueTree::getSibling (const int delta) const noexcept
{
if (object == nullptr || object->parent == nullptr)