From a90aedce50565ca14d2f02fa2fdc9e0b5c59fcdc Mon Sep 17 00:00:00 2001 From: jules Date: Fri, 20 Jan 2012 18:20:19 +0000 Subject: [PATCH] Small updates to ComponentBuilder, UnitTestRunner. --- .../Source/Utility/jucer_PresetIDs.h | 1 + .../juce_core/threads/juce_ChildProcess.cpp | 4 ++-- .../juce_core/unit_tests/juce_UnitTest.cpp | 8 +++++++ modules/juce_core/unit_tests/juce_UnitTest.h | 5 +++++ .../messages/juce_MessageManager.h | 2 +- .../drawables/juce_DrawablePath.cpp | 2 +- .../layout/juce_ComponentBuilder.cpp | 22 ++++++++++++++----- .../layout/juce_ComponentBuilder.h | 6 ++--- .../mouse/juce_MouseInputSource.cpp | 8 ++++--- .../juce_RelativeCoordinatePositioner.cpp | 8 ++++++- 10 files changed, 50 insertions(+), 16 deletions(-) diff --git a/extras/Introjucer/Source/Utility/jucer_PresetIDs.h b/extras/Introjucer/Source/Utility/jucer_PresetIDs.h index a7690eb504..4cac89305d 100644 --- a/extras/Introjucer/Source/Utility/jucer_PresetIDs.h +++ b/extras/Introjucer/Source/Utility/jucer_PresetIDs.h @@ -82,6 +82,7 @@ namespace Ids DECLARE_ID (locked); DECLARE_ID (tooltip); DECLARE_ID (memberName); + DECLARE_ID (markerName); DECLARE_ID (focusOrder); DECLARE_ID (hidden); DECLARE_ID (useStdCall); diff --git a/modules/juce_core/threads/juce_ChildProcess.cpp b/modules/juce_core/threads/juce_ChildProcess.cpp index e86855f2d9..b109e68a8e 100644 --- a/modules/juce_core/threads/juce_ChildProcess.cpp +++ b/modules/juce_core/threads/juce_ChildProcess.cpp @@ -81,8 +81,8 @@ public: expect (p.start ("ls /")); #endif - String output (p.readAllProcessOutput()); - expect (output.isNotEmpty()); + //String output (p.readAllProcessOutput()); + //expect (output.isNotEmpty()); #endif } }; diff --git a/modules/juce_core/unit_tests/juce_UnitTest.cpp b/modules/juce_core/unit_tests/juce_UnitTest.cpp index 5adeab3adb..10a0fefb06 100644 --- a/modules/juce_core/unit_tests/juce_UnitTest.cpp +++ b/modules/juce_core/unit_tests/juce_UnitTest.cpp @@ -117,6 +117,9 @@ void UnitTestRunner::runTests (const Array& tests) for (int i = 0; i < tests.size(); ++i) { + if (shouldAbortTests()) + break; + try { tests.getUnchecked(i)->performTest (this); @@ -140,6 +143,11 @@ void UnitTestRunner::logMessage (const String& message) Logger::writeToLog (message); } +bool UnitTestRunner::shouldAbortTests() +{ + return false; +} + void UnitTestRunner::beginNewTest (UnitTest* const test, const String& subCategory) { endTest(); diff --git a/modules/juce_core/unit_tests/juce_UnitTest.h b/modules/juce_core/unit_tests/juce_UnitTest.h index 942d984033..4bced4dc58 100644 --- a/modules/juce_core/unit_tests/juce_UnitTest.h +++ b/modules/juce_core/unit_tests/juce_UnitTest.h @@ -260,6 +260,11 @@ protected: */ virtual void logMessage (const String& message); + /** This can be overridden to let the runner know that it should abort the tests + as soon as possible, e.g. because the thread needs to stop. + */ + virtual bool shouldAbortTests(); + private: //============================================================================== friend class UnitTest; diff --git a/modules/juce_events/messages/juce_MessageManager.h b/modules/juce_events/messages/juce_MessageManager.h index 6a0342dd96..1cf65bf40e 100644 --- a/modules/juce_events/messages/juce_MessageManager.h +++ b/modules/juce_events/messages/juce_MessageManager.h @@ -244,7 +244,7 @@ public: successful by calling lockWasGained(). If this is false, your thread is being told to die, so you should take evasive action. - If you pass zero for the thread object, it will wait indefinitely for the lock - be + If you pass nullptr for the thread object, it will wait indefinitely for the lock - be careful when doing this, because it's very easy to deadlock if your message thread attempts to call stopThread() on a thread just as that thread attempts to get the message lock. diff --git a/modules/juce_gui_basics/drawables/juce_DrawablePath.cpp b/modules/juce_gui_basics/drawables/juce_DrawablePath.cpp index 7ea06fa0d0..af2738ec46 100644 --- a/modules/juce_gui_basics/drawables/juce_DrawablePath.cpp +++ b/modules/juce_gui_basics/drawables/juce_DrawablePath.cpp @@ -203,7 +203,7 @@ void DrawablePath::ValueTreeWrapper::writeTo (RelativePointPath& relativePath) c for (int j = 0; j < numCps; ++j) points[j] = e.getControlPoint (j); - RelativePointPath::ElementBase* newElement = 0; + RelativePointPath::ElementBase* newElement = nullptr; const Identifier t (e.getType()); if (t == Element::startSubPathElement) newElement = new RelativePointPath::StartSubPath (points[0]); diff --git a/modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp b/modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp index 914200af3c..5066548106 100644 --- a/modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp +++ b/modules/juce_gui_basics/layout/juce_ComponentBuilder.cpp @@ -359,21 +359,32 @@ void ComponentBuilder::updateChildComponents (Component& parent, const ValueTree } } -void ComponentBuilder::refreshChildrenFromValueTree (Component& parent, - const ValueTree& childList, - ImageProvider* const imageProvider) +static void updateMarkers (MarkerList* const list, const ValueTree& state) +{ + if (list != nullptr) + MarkerList::ValueTreeWrapper (state).applyTo (*list); +} + +void ComponentBuilder::initialiseFromValueTree (Component& comp, + const ValueTree& state, + ImageProvider* const imageProvider) { using namespace ComponentBuilderHelpers; ComponentBuilder builder; builder.setImageProvider (imageProvider); builder.registerStandardComponentTypes(); - builder.updateChildComponents (parent, childList); + + updateMarkers (comp.getMarkers (true), state.getChildWithName ("MARKERS_X")); + updateMarkers (comp.getMarkers (false), state.getChildWithName ("MARKERS_Y")); + + const ValueTree childList (state.getChildWithName ("COMPONENTS")); + builder.updateChildComponents (comp, childList); for (int i = 0; i < childList.getNumChildren(); ++i) { const ValueTree state (childList.getChild(i)); - Component* const c = findComponentWithID (parent, getStateId (state)); + Component* const c = findComponentWithID (comp, getStateId (state)); if (c != nullptr) { @@ -385,6 +396,7 @@ void ComponentBuilder::refreshChildrenFromValueTree (Component& parent, refreshBasicComponentProperties (*c, state); } } + } RelativeRectangle ComponentBuilder::getComponentBounds (const ValueTree& state) diff --git a/modules/juce_gui_basics/layout/juce_ComponentBuilder.h b/modules/juce_gui_basics/layout/juce_ComponentBuilder.h index ad42e1a757..46f4410ed9 100644 --- a/modules/juce_gui_basics/layout/juce_ComponentBuilder.h +++ b/modules/juce_gui_basics/layout/juce_ComponentBuilder.h @@ -229,9 +229,9 @@ public: /** */ - static void refreshChildrenFromValueTree (Component& parent, - const ValueTree& state, - ImageProvider* imageProvider); + static void initialiseFromValueTree (Component& component, + const ValueTree& state, + ImageProvider* imageProvider); //============================================================================= /** @internal */ diff --git a/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp b/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp index 595ef29be6..d6712d8b46 100644 --- a/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp +++ b/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp @@ -197,13 +197,15 @@ public: setButtons (screenPos, time, ModifierKeys()); if (safeOldComp != nullptr) - sendMouseExit (current, screenPos, time); + { + componentUnderMouse = safeNewComp; + sendMouseExit (safeOldComp, screenPos, time); + } buttonState = originalButtonState; } - componentUnderMouse = safeNewComp; - current = getComponentUnderMouse(); + current = componentUnderMouse = safeNewComp; if (current != nullptr) sendMouseEnter (current, screenPos, time); diff --git a/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp b/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp index b22eb6b5ba..4ca8139f76 100644 --- a/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp +++ b/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp @@ -50,7 +50,13 @@ Expression RelativeCoordinatePositionerBase::ComponentScope::getSymbolValue (con const MarkerList::Marker* const marker = findMarker (symbol, list); if (marker != nullptr) - return marker->position.getExpression(); + { + Component* const parent = component.getParentComponent(); + jassert (parent != nullptr); + + ComponentScope scope (*parent); + return Expression (marker->position.getExpression().evaluate (scope)); + } return Expression::Scope::getSymbolValue (symbol); }