Browse Source

Added a getUndoManager() method to CachedValue and ValueWithDefault and made CachedValue weak referenceable

tags/2021-05-28
ed 6 years ago
parent
commit
c29eea44e3
3 changed files with 12 additions and 9 deletions
  1. +0
    -5
      modules/juce_data_structures/values/juce_CachedValue.cpp
  2. +7
    -2
      modules/juce_data_structures/values/juce_CachedValue.h
  3. +5
    -2
      modules/juce_data_structures/values/juce_ValueWithDefault.h

+ 0
- 5
modules/juce_data_structures/values/juce_CachedValue.cpp View File

@@ -144,11 +144,6 @@ public:
expect (t["testkey"] == var());
}
beginTest ("reset value");
{
}
}
};


+ 7
- 2
modules/juce_data_structures/values/juce_CachedValue.h View File

@@ -181,11 +181,14 @@ public:
/** Returns the property ID of the referenced property. */
const Identifier& getPropertyID() const noexcept { return targetProperty; }
/** Returns the UndoManager that is being used. */
UndoManager* getUndoManager() noexcept { return undoManager; }
private:
//==============================================================================
ValueTree targetTree;
Identifier targetProperty;
UndoManager* undoManager;
UndoManager* undoManager = nullptr;
Type defaultValue;
Type cachedValue;
@@ -199,13 +202,15 @@ private:
void valueTreeChildOrderChanged (ValueTree&, int, int) override {}
void valueTreeParentChanged (ValueTree&) override {}
//==============================================================================
JUCE_DECLARE_WEAK_REFERENCEABLE (CachedValue)
JUCE_DECLARE_NON_COPYABLE (CachedValue)
};
//==============================================================================
template <typename Type>
inline CachedValue<Type>::CachedValue() : undoManager (nullptr) {}
inline CachedValue<Type>::CachedValue() {}
template <typename Type>
inline CachedValue<Type>::CachedValue (ValueTree& v, const Identifier& i, UndoManager* um)


+ 5
- 2
modules/juce_data_structures/values/juce_ValueWithDefault.h View File

@@ -41,7 +41,7 @@ class ValueWithDefault
public:
//==============================================================================
/** Creates an unitialised ValueWithDefault. Initialise it using one of the referTo() methods. */
ValueWithDefault() : undoManager (nullptr) {}
ValueWithDefault() {}
/** Creates an ValueWithDefault object. The default value will be an empty var. */
ValueWithDefault (ValueTree& tree, const Identifier& propertyID, UndoManager* um)
@@ -181,6 +181,9 @@ public:
/** Returns the property ID of the referenced property. */
Identifier& getPropertyID() noexcept { return targetProperty; }
/** Returns the UndoManager that is being used. */
UndoManager* getUndoManager() noexcept { return undoManager; }
//==============================================================================
ValueWithDefault& operator= (const ValueWithDefault& other)
{
@@ -194,7 +197,7 @@ private:
//==============================================================================
ValueTree targetTree;
Identifier targetProperty;
UndoManager* undoManager;
UndoManager* undoManager = nullptr;
var defaultValue;
String delimiter;


Loading…
Cancel
Save