diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index ecc47ba043..00f6d02b4f 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -4702,9 +4702,9 @@ Array* var::convertToArray() return array; } -void var::append (const var& value) +void var::append (const var& n) { - convertToArray()->add (value); + convertToArray()->add (n); } void var::remove (const int index) @@ -4715,9 +4715,9 @@ void var::remove (const int index) array->remove (index); } -void var::insert (const int index, const var& value) +void var::insert (const int index, const var& n) { - convertToArray()->insert (index, value); + convertToArray()->insert (index, n); } void var::resize (const int numArrayElementsWanted) @@ -4725,10 +4725,10 @@ void var::resize (const int numArrayElementsWanted) convertToArray()->resize (numArrayElementsWanted); } -int var::indexOf (const var& value) const +int var::indexOf (const var& n) const { const Array* const array = getArray(); - return array != nullptr ? array->indexOf (value) : -1; + return array != nullptr ? array->indexOf (n) : -1; } void var::writeToStream (OutputStream& output) const @@ -6046,9 +6046,9 @@ Expression Expression::withRenamedSymbol (const Expression::Symbol& oldSymbol, c return e; } -bool Expression::referencesSymbol (const Expression::Symbol& symbol, const Scope& scope) const +bool Expression::referencesSymbol (const Expression::Symbol& symbolToCheck, const Scope& scope) const { - Helpers::SymbolCheckVisitor visitor (symbol); + Helpers::SymbolCheckVisitor visitor (symbolToCheck); try { @@ -16553,6 +16553,7 @@ private: { DynamicObject* const resultObject = new DynamicObject(); result = resultObject; + NamedValueSet& resultProperties = resultObject->getProperties(); for (;;) { @@ -16582,17 +16583,17 @@ private: t = t.findEndOfWhitespace(); oldT = t; - const juce_wchar c = t.getAndAdvance(); - if (c != ':') + const juce_wchar c2 = t.getAndAdvance(); + if (c2 != ':') return createFail ("Expected ':', but found", &oldT); - var propertyValue; - Result r (parseAny (t, propertyValue)); + resultProperties.set (propertyName, var::null); + var* propertyValue = resultProperties.getVarPointer (propertyName); - if (r.failed()) - return r; + Result r2 (parseAny (t, *propertyValue)); - resultObject->setProperty (propertyName, propertyValue); + if (r2.failed()) + return r2; t = t.findEndOfWhitespace(); oldT = t; @@ -16923,6 +16924,119 @@ void JSON::writeToStream (OutputStream& output, const var& data, const bool allO JSONFormatter::write (output, data, 0, allOnOneLine); } +#if JUCE_UNIT_TESTS + +class JSONTests : public UnitTest +{ +public: + JSONTests() : UnitTest ("JSON") {} + + static String createRandomWideCharString (Random& r) + { + juce_wchar buffer[40] = { 0 }; + + for (int i = 0; i < numElementsInArray (buffer) - 1; ++i) + { + if (r.nextBool()) + { + do + { + buffer[i] = (juce_wchar) (1 + r.nextInt (0x10ffff - 1)); + } + while (! CharPointer_UTF16::canRepresent (buffer[i])); + } + else + buffer[i] = (juce_wchar) (1 + r.nextInt (0xff)); + } + + return CharPointer_UTF32 (buffer); + } + + static String createRandomIdentifier (Random& r) + { + char buffer[30] = { 0 }; + + for (int i = 0; i < numElementsInArray (buffer) - 1; ++i) + { + static const char chars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-:"; + buffer[i] = chars [r.nextInt (sizeof (chars) - 1)]; + } + + return CharPointer_ASCII (buffer); + } + + static var createRandomVar (Random& r, int depth) + { + switch (r.nextInt (depth > 3 ? 6 : 8)) + { + case 0: return var::null; + case 1: return r.nextInt(); + case 2: return r.nextInt64(); + case 3: return r.nextBool(); + case 4: return r.nextDouble(); + case 5: return createRandomWideCharString (r); + + case 6: + { + var v (createRandomVar (r, depth + 1)); + + for (int i = 1 + r.nextInt (30); --i >= 0;) + v.append (createRandomVar (r, depth + 1)); + + return v; + } + + case 7: + { + DynamicObject* o = new DynamicObject(); + + for (int i = r.nextInt (30); --i >= 0;) + o->setProperty (createRandomIdentifier (r), createRandomVar (r, depth + 1)); + + return o; + } + + default: + return var::null; + } + } + + void runTest() + { + beginTest ("JSON"); + Random r; + r.setSeedRandomly(); + + expect (JSON::parse (String::empty) == var::null); + expect (JSON::parse ("{}").isObject()); + expect (JSON::parse ("[]").isArray()); + expect (JSON::parse ("1234").isInt()); + expect (JSON::parse ("12345678901234").isInt64()); + expect (JSON::parse ("1.123e3").isDouble()); + expect (JSON::parse ("-1234").isInt()); + expect (JSON::parse ("-12345678901234").isInt64()); + expect (JSON::parse ("-1.123e3").isDouble()); + + for (int i = 100; --i >= 0;) + { + var v; + + if (i > 0) + v = createRandomVar (r, 0); + + const bool oneLine = r.nextBool(); + String asString (JSON::toString (v, oneLine)); + var parsed = JSON::parse (asString); + String parsedString (JSON::toString (parsed, oneLine)); + expect (asString.isNotEmpty() && parsedString == asString); + } + } +}; + +static JSONTests JSONUnitTests; + +#endif + END_JUCE_NAMESPACE /*** End of inlined file: juce_JSON.cpp ***/ @@ -21213,8 +21327,6 @@ namespace MarkChunk for (int i = 0; i < numCues; ++i) { const String prefixCue ("Cue" + String (i)); - const String prefixLabel ("CueLabel" + String (i)); - const int identifier = idOffset + values.getValue (prefixCue + "Identifier", "1").getIntValue(); #if JUCE_DEBUG @@ -21223,8 +21335,7 @@ namespace MarkChunk #endif const int offset = values.getValue (prefixCue + "Offset", "0").getIntValue(); - - String label (prefixLabel); + String label ("CueLabel" + String (i)); for (int labelIndex = 0; labelIndex < numCueLabels; ++labelIndex) { @@ -26089,12 +26200,12 @@ void ReverbAudioSource::setParameters (const Reverb::Parameters& newParams) reverb.setParameters (newParams); } -void ReverbAudioSource::setBypassed (bool isBypassed) noexcept +void ReverbAudioSource::setBypassed (bool b) noexcept { - if (bypass != isBypassed) + if (bypass != b) { const ScopedLock sl (lock); - bypass = isBypassed; + bypass = b; reverb.reset(); } } @@ -27287,11 +27398,11 @@ void AudioDeviceManager::addMidiInputCallback (const String& name, } } -void AudioDeviceManager::removeMidiInputCallback (const String& name, MidiInputCallback* callback) +void AudioDeviceManager::removeMidiInputCallback (const String& name, MidiInputCallback* callbackToRemove) { for (int i = midiCallbacks.size(); --i >= 0;) { - if (midiCallbackDevices[i] == name && midiCallbacks.getUnchecked(i) == callback) + if (midiCallbackDevices[i] == name && midiCallbacks.getUnchecked(i) == callbackToRemove) { const ScopedLock sl (midiCallbackLock); midiCallbacks.remove (i); @@ -39443,9 +39554,9 @@ void Synthesiser::noteOn (const int midiChannel, { // If hitting a note that's still ringing, stop it first (it could be // still playing because of the sustain or sostenuto pedal). - for (int i = voices.size(); --i >= 0;) + for (int j = voices.size(); --j >= 0;) { - SynthesiserVoice* const voice = voices.getUnchecked (i); + SynthesiserVoice* const voice = voices.getUnchecked (j); if (voice->getCurrentlyPlayingNote() == midiNoteNumber && voice->isPlayingChannel (midiChannel)) @@ -40769,7 +40880,7 @@ public: void run() { uint32 lastTime = Time::getMillisecondCounter(); - Message::Ptr message (new Message()); + Message::Ptr messageToSend (new Message()); while (! threadShouldExit()) { @@ -40796,7 +40907,7 @@ public: */ if (callbackNeeded.compareAndSetBool (1, 0)) { - postMessage (message); + postMessage (messageToSend); /* Sometimes our message can get discarded by the OS (e.g. when running as an RTAS when the app has a modal loop), so this is how long to wait before assuming the @@ -44654,7 +44765,7 @@ void ModalComponentManager::handleAsyncUpdate() if (! item->isActive) { - ScopedPointer item (stack.removeAndReturn (i)); + ScopedPointer deleter (stack.removeAndReturn (i)); for (int j = item->callbacks.size(); --j >= 0;) item->callbacks.getUnchecked(j)->modalStateFinished (item->returnValue); @@ -46016,15 +46127,15 @@ void ShapeButton::setShape (const Path& newShape, if (resizeNowToFitThisShape) { - Rectangle bounds (shape.getBounds()); + Rectangle newBounds (shape.getBounds()); if (hasShadow) - bounds.expand (4.0f, 4.0f); + newBounds.expand (4.0f, 4.0f); - shape.applyTransform (AffineTransform::translation (-bounds.getX(), -bounds.getY())); + shape.applyTransform (AffineTransform::translation (-newBounds.getX(), -newBounds.getY())); - setSize (1 + (int) (bounds.getWidth() + outlineWidth), - 1 + (int) (bounds.getHeight() + outlineWidth)); + setSize (1 + (int) (newBounds.getWidth() + outlineWidth), + 1 + (int) (newBounds.getHeight() + outlineWidth)); } } @@ -49499,8 +49610,8 @@ END_JUCE_NAMESPACE /*** Start of inlined file: juce_ImageComponent.cpp ***/ BEGIN_JUCE_NAMESPACE -ImageComponent::ImageComponent (const String& componentName) - : Component (componentName), +ImageComponent::ImageComponent (const String& name) + : Component (name), placement (RectanglePlacement::centred) { } @@ -49561,9 +49672,9 @@ END_JUCE_NAMESPACE /*** Start of inlined file: juce_Label.cpp ***/ BEGIN_JUCE_NAMESPACE -Label::Label (const String& componentName, +Label::Label (const String& name, const String& labelText) - : Component (componentName), + : Component (name), textValue (labelText), lastTextValue (labelText), font (15.0f), @@ -55432,9 +55543,9 @@ void TextEditor::drawContent (Graphics& g) } } - for (int i = underlinedSections.size(); --i >= 0;) + for (int j = underlinedSections.size(); --j >= 0;) { - const Range& underlinedSection = underlinedSections.getReference (i); + const Range& underlinedSection = underlinedSections.getReference (j); Iterator i2 (sections, wordWrapWidth, passwordCharacter); @@ -57897,8 +58008,8 @@ private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TreeViewport); }; -TreeView::TreeView (const String& componentName) - : Component (componentName), +TreeView::TreeView (const String& name) + : Component (name), rootItem (nullptr), indentSize (24), defaultOpenness (false), @@ -62083,7 +62194,7 @@ public: void changeListenerCallback (ChangeBroadcaster*) { - const OpennessRestorer openness (*this); + const OpennessRestorer opennessRestorer (*this); clearSubItems(); const StringArray categories (owner.getMappings().getCommandManager()->getCommandCategories()); @@ -63966,9 +64077,9 @@ END_JUCE_NAMESPACE /*** Start of inlined file: juce_GroupComponent.cpp ***/ BEGIN_JUCE_NAMESPACE -GroupComponent::GroupComponent (const String& componentName, +GroupComponent::GroupComponent (const String& name, const String& labelText) - : Component (componentName), + : Component (name), text (labelText), justification (Justification::left) { @@ -64650,11 +64761,11 @@ void ResizableBorderComponent::mouseDrag (const MouseEvent& e) return; } - const Rectangle bounds (mouseZone.resizeRectangleBy (originalBounds, e.getOffsetFromDragStart())); + const Rectangle newBounds (mouseZone.resizeRectangleBy (originalBounds, e.getOffsetFromDragStart())); if (constrainer != nullptr) { - constrainer->setBoundsForComponent (component, bounds, + constrainer->setBoundsForComponent (component, newBounds, mouseZone.isDraggingTopEdge(), mouseZone.isDraggingLeftEdge(), mouseZone.isDraggingBottomEdge(), @@ -64662,12 +64773,12 @@ void ResizableBorderComponent::mouseDrag (const MouseEvent& e) } else { - Component::Positioner* const positioner = component->getPositioner(); + Component::Positioner* const pos = component->getPositioner(); - if (positioner != nullptr) - positioner->applyNewBounds (bounds); + if (pos != nullptr) + pos->applyNewBounds (newBounds); else - component->setBounds (bounds); + component->setBounds (newBounds); } } @@ -64770,10 +64881,10 @@ void ResizableCornerComponent::mouseDrag (const MouseEvent& e) } else { - Component::Positioner* const positioner = component->getPositioner(); + Component::Positioner* const pos = component->getPositioner(); - if (positioner != nullptr) - positioner->applyNewBounds (r); + if (pos != nullptr) + pos->applyNewBounds (r); else component->setBounds (r); } @@ -64852,20 +64963,20 @@ void ResizableEdgeComponent::mouseDrag (const MouseEvent& e) return; } - Rectangle bounds (originalBounds); + Rectangle newBounds (originalBounds); switch (edge) { - case leftEdge: bounds.setLeft (jmin (bounds.getRight(), bounds.getX() + e.getDistanceFromDragStartX())); break; - case rightEdge: bounds.setWidth (jmax (0, bounds.getWidth() + e.getDistanceFromDragStartX())); break; - case topEdge: bounds.setTop (jmin (bounds.getBottom(), bounds.getY() + e.getDistanceFromDragStartY())); break; - case bottomEdge: bounds.setHeight (jmax (0, bounds.getHeight() + e.getDistanceFromDragStartY())); break; + case leftEdge: newBounds.setLeft (jmin (newBounds.getRight(), newBounds.getX() + e.getDistanceFromDragStartX())); break; + case rightEdge: newBounds.setWidth (jmax (0, newBounds.getWidth() + e.getDistanceFromDragStartX())); break; + case topEdge: newBounds.setTop (jmin (newBounds.getBottom(), newBounds.getY() + e.getDistanceFromDragStartY())); break; + case bottomEdge: newBounds.setHeight (jmax (0, newBounds.getHeight() + e.getDistanceFromDragStartY())); break; default: jassertfalse; break; } if (constrainer != nullptr) { - constrainer->setBoundsForComponent (component, bounds, + constrainer->setBoundsForComponent (component, newBounds, edge == topEdge, edge == leftEdge, edge == bottomEdge, @@ -64873,12 +64984,12 @@ void ResizableEdgeComponent::mouseDrag (const MouseEvent& e) } else { - Component::Positioner* const positioner = component->getPositioner(); + Component::Positioner* const pos = component->getPositioner(); - if (positioner != nullptr) - positioner->applyNewBounds (bounds); + if (pos != nullptr) + pos->applyNewBounds (newBounds); else - component->setBounds (bounds); + component->setBounds (newBounds); } } @@ -66564,8 +66675,8 @@ END_JUCE_NAMESPACE /*** Start of inlined file: juce_Viewport.cpp ***/ BEGIN_JUCE_NAMESPACE -Viewport::Viewport (const String& componentName) - : Component (componentName), +Viewport::Viewport (const String& name) + : Component (name), scrollBarThickness (0), singleStepX (16), singleStepY (16), @@ -79029,17 +79140,17 @@ BEGIN_JUCE_NAMESPACE CallOutBox::CallOutBox (Component& contentComponent, Component& componentToPointTo, - Component* const parentComponent) + Component* const parent) : borderSpace (20), arrowSize (16.0f), content (contentComponent) { addAndMakeVisible (&content); - if (parentComponent != nullptr) + if (parent != nullptr) { - parentComponent->addChildComponent (this); + parent->addChildComponent (this); - updatePosition (parentComponent->getLocalArea (&componentToPointTo, componentToPointTo.getLocalBounds()), - parentComponent->getLocalBounds()); + updatePosition (parent->getLocalArea (&componentToPointTo, componentToPointTo.getLocalBounds()), + parent->getLocalBounds()); setVisible (true); } @@ -79147,12 +79258,12 @@ void CallOutBox::updatePosition (const Rectangle& newAreaToPointTo, const R targetArea = newAreaToPointTo; availableArea = newAreaToFitIn; - Rectangle bounds (0, 0, - content.getWidth() + borderSpace * 2, - content.getHeight() + borderSpace * 2); + Rectangle newBounds (0, 0, + content.getWidth() + borderSpace * 2, + content.getHeight() + borderSpace * 2); - const int hw = bounds.getWidth() / 2; - const int hh = bounds.getHeight() / 2; + const int hw = newBounds.getWidth() / 2; + const int hh = newBounds.getHeight() / 2; const float hwReduced = (float) (hw - borderSpace * 3); const float hhReduced = (float) (hh - borderSpace * 3); const float arrowIndent = borderSpace - arrowSize; @@ -79187,12 +79298,12 @@ void CallOutBox::updatePosition (const Rectangle& newAreaToPointTo, const R nearest = distanceFromCentre; targetPoint = targets[i]; - bounds.setPosition ((int) (centre.getX() - hw), - (int) (centre.getY() - hh)); + newBounds.setPosition ((int) (centre.getX() - hw), + (int) (centre.getY() - hh)); } } - setBounds (bounds); + setBounds (newBounds); } void CallOutBox::refreshPath() @@ -79828,18 +79939,18 @@ class TempDialogWindow : public DialogWindow { public: TempDialogWindow (const String& title, - Component* contentComponent, + Component* contentComponent_, Component* componentToCentreAround, const Colour& colour, - const bool escapeKeyTriggersCloseButton, + const bool escapeKeyTriggersCloseButton_, const bool shouldBeResizable, const bool useBottomRightCornerResizer) - : DialogWindow (title, colour, escapeKeyTriggersCloseButton, true) + : DialogWindow (title, colour, escapeKeyTriggersCloseButton_, true) { if (! JUCEApplication::isStandaloneApp()) setAlwaysOnTop (true); // for a plugin, make it always-on-top because the host windows are often top-level - setContentNonOwned (contentComponent, true); + setContentNonOwned (contentComponent_, true); centreAroundComponent (componentToCentreAround, getWidth(), getHeight()); setResizable (shouldBeResizable, useBottomRightCornerResizer); } @@ -80302,13 +80413,13 @@ ResizableWindow::~ResizableWindow() jassert (getNumChildComponents() == 0); } -void ResizableWindow::initialise (const bool addToDesktop) +void ResizableWindow::initialise (const bool shouldAddToDesktop) { defaultConstrainer.setMinimumOnscreenAmounts (0x10000, 16, 24, 16); lastNonFullScreenPos.setBounds (50, 50, 256, 256); - if (addToDesktop) + if (shouldAddToDesktop) Component::addToDesktop (ResizableWindow::getDesktopWindowStyleFlags()); } @@ -80564,12 +80675,12 @@ void ResizableWindow::setConstrainer (ComponentBoundsConstrainer* newConstrainer } } -void ResizableWindow::setBoundsConstrained (const Rectangle& bounds) +void ResizableWindow::setBoundsConstrained (const Rectangle& newBounds) { if (constrainer != nullptr) - constrainer->setBoundsForComponent (this, bounds, false, false, false, false); + constrainer->setBoundsForComponent (this, newBounds, false, false, false, false); else - setBounds (bounds); + setBounds (newBounds); } void ResizableWindow::paint (Graphics& g) @@ -81000,7 +81111,7 @@ END_JUCE_NAMESPACE /*** Start of inlined file: juce_TooltipWindow.cpp ***/ BEGIN_JUCE_NAMESPACE -TooltipWindow::TooltipWindow (Component* const parentComponent, +TooltipWindow::TooltipWindow (Component* const parent_, const int millisecondsBeforeTipAppears_) : Component ("tooltip"), millisecondsBeforeTipAppears (millisecondsBeforeTipAppears_), @@ -81015,8 +81126,8 @@ TooltipWindow::TooltipWindow (Component* const parentComponent, setAlwaysOnTop (true); setOpaque (true); - if (parentComponent != nullptr) - parentComponent->addChildComponent (this); + if (parent_ != nullptr) + parent_->addChildComponent (this); } TooltipWindow::~TooltipWindow() @@ -82087,8 +82198,8 @@ const Rectangle RelativeRectangle::resolve (const Expression::Scope* scop { if (scope == nullptr) { - RelativeRectangleLocalScope scope (*this); - return resolve (&scope); + RelativeRectangleLocalScope defaultScope (*this); + return resolve (&defaultScope); } else { @@ -82793,10 +82904,10 @@ void RelativeCoordinatePositionerBase::componentChildrenChanged (Component& chan apply(); } -void RelativeCoordinatePositionerBase::componentBeingDeleted (Component& component) +void RelativeCoordinatePositionerBase::componentBeingDeleted (Component& comp) { - jassert (sourceComponents.contains (&component)); - sourceComponents.removeValue (&component); + jassert (sourceComponents.contains (&comp)); + sourceComponents.removeValue (&comp); registeredOk = false; } @@ -88790,17 +88901,17 @@ void DrawableShape::setStrokeFill (const FillType& newFill) } void DrawableShape::setFillInternal (RelativeFillType& fill, const RelativeFillType& newFill, - ScopedPointer& positioner) + ScopedPointer& pos) { if (fill != newFill) { fill = newFill; - positioner = nullptr; + pos = nullptr; if (fill.isDynamic()) { - positioner = new RelativePositioner (*this, fill, true); - positioner->apply(); + pos = new RelativePositioner (*this, fill, true); + pos->apply(); } else { @@ -89269,11 +89380,11 @@ void DrawableComposite::resetContentAreaAndBoundingBoxToFitChildren() resetBoundingBoxToContentArea(); } -bool DrawableComposite::registerCoordinates (RelativeCoordinatePositionerBase& positioner) +bool DrawableComposite::registerCoordinates (RelativeCoordinatePositionerBase& pos) { - bool ok = positioner.addPoint (bounds.topLeft); - ok = positioner.addPoint (bounds.topRight) && ok; - return positioner.addPoint (bounds.bottomLeft) && ok; + bool ok = pos.addPoint (bounds.topLeft); + ok = pos.addPoint (bounds.topRight) && ok; + return pos.addPoint (bounds.bottomLeft) && ok; } void DrawableComposite::recalculateCoordinates (Expression::Scope* scope) @@ -89537,11 +89648,11 @@ void DrawableImage::setBoundingBox (const RelativeParallelogram& newBounds) } } -bool DrawableImage::registerCoordinates (RelativeCoordinatePositionerBase& positioner) +bool DrawableImage::registerCoordinates (RelativeCoordinatePositionerBase& pos) { - bool ok = positioner.addPoint (bounds.topLeft); - ok = positioner.addPoint (bounds.topRight) && ok; - return positioner.addPoint (bounds.bottomLeft) && ok; + bool ok = pos.addPoint (bounds.topLeft); + ok = pos.addPoint (bounds.topRight) && ok; + return pos.addPoint (bounds.bottomLeft) && ok; } void DrawableImage::recalculateCoordinates (Expression::Scope* scope) @@ -89912,16 +90023,15 @@ void DrawablePath::ValueTreeWrapper::writeTo (RelativePointPath& relativePath) c for (int j = 0; j < numCps; ++j) points[j] = e.getControlPoint (j); - const Identifier type (e.getType()); - RelativePointPath::ElementBase* newElement = 0; + const Identifier t (e.getType()); - if (type == Element::startSubPathElement) newElement = new RelativePointPath::StartSubPath (points[0]); - else if (type == Element::closeSubPathElement) newElement = new RelativePointPath::CloseSubPath(); - else if (type == Element::lineToElement) newElement = new RelativePointPath::LineTo (points[0]); - else if (type == Element::quadraticToElement) newElement = new RelativePointPath::QuadraticTo (points[0], points[1]); - else if (type == Element::cubicToElement) newElement = new RelativePointPath::CubicTo (points[0], points[1], points[2]); - else jassertfalse; + if (t == Element::startSubPathElement) newElement = new RelativePointPath::StartSubPath (points[0]); + else if (t == Element::closeSubPathElement) newElement = new RelativePointPath::CloseSubPath(); + else if (t == Element::lineToElement) newElement = new RelativePointPath::LineTo (points[0]); + else if (t == Element::quadraticToElement) newElement = new RelativePointPath::QuadraticTo (points[0], points[1]); + else if (t == Element::cubicToElement) newElement = new RelativePointPath::CubicTo (points[0], points[1], points[2]); + else jassertfalse; relativePath.addElement (newElement); } @@ -90342,12 +90452,12 @@ void DrawableRectangle::rebuildPath() } } -bool DrawableRectangle::registerCoordinates (RelativeCoordinatePositionerBase& positioner) +bool DrawableRectangle::registerCoordinates (RelativeCoordinatePositionerBase& pos) { - bool ok = positioner.addPoint (bounds.topLeft); - ok = positioner.addPoint (bounds.topRight) && ok; - ok = positioner.addPoint (bounds.bottomLeft) && ok; - return positioner.addPoint (cornerSize) && ok; + bool ok = pos.addPoint (bounds.topLeft); + ok = pos.addPoint (bounds.topRight) && ok; + ok = pos.addPoint (bounds.bottomLeft) && ok; + return pos.addPoint (cornerSize) && ok; } void DrawableRectangle::recalculateCoordinates (Expression::Scope* scope) @@ -90549,12 +90659,12 @@ void DrawableText::refreshBounds() } } -bool DrawableText::registerCoordinates (RelativeCoordinatePositionerBase& positioner) +bool DrawableText::registerCoordinates (RelativeCoordinatePositionerBase& pos) { - bool ok = positioner.addPoint (bounds.topLeft); - ok = positioner.addPoint (bounds.topRight) && ok; - ok = positioner.addPoint (bounds.bottomLeft) && ok; - return positioner.addPoint (fontSizeControlPoint) && ok; + bool ok = pos.addPoint (bounds.topLeft); + ok = pos.addPoint (bounds.topRight) && ok; + ok = pos.addPoint (bounds.bottomLeft) && ok; + return pos.addPoint (fontSizeControlPoint) && ok; } void DrawableText::recalculateCoordinates (Expression::Scope* scope) @@ -98745,9 +98855,9 @@ private: return code; } - int getCode (const int codeSize_, const bool initialise) + int getCode (const int codeSize_, const bool shouldInitialise) { - if (initialise) + if (shouldInitialise) { currentBit = 0; lastBit = 0; @@ -194509,18 +194619,18 @@ class OggWriter : public AudioFormatWriter public: OggWriter (OutputStream* const out, - const double sampleRate, - const int numChannels, - const int bitsPerSample, + const double sampleRate_, + const int numChannels_, + const int bitsPerSample_, const int qualityIndex) - : AudioFormatWriter (out, TRANS (oggFormatName), sampleRate, numChannels, bitsPerSample), + : AudioFormatWriter (out, TRANS (oggFormatName), sampleRate_, numChannels_, bitsPerSample_), ok (false) { using namespace OggVorbisNamespace; vorbis_info_init (&vi); - if (vorbis_encode_init_vbr (&vi, numChannels, (int) sampleRate, + if (vorbis_encode_init_vbr (&vi, numChannels_, (int) sampleRate_, jlimit (0.0f, 1.0f, qualityIndex * 0.1f)) == 0) { vorbis_comment_init (&vc); @@ -272859,9 +272969,9 @@ public: unitsToHeightScaleFactor (0.0f) { JUCE_AUTORELEASEPOOL - CFStringRef name = PlatformUtilities::juceStringToCFString (font.getTypefaceName()); - ctFontRef = CTFontCreateWithName (name, 1024, nullptr); - CFRelease (name); + CFStringRef cfName = PlatformUtilities::juceStringToCFString (font.getTypefaceName()); + ctFontRef = CTFontCreateWithName (cfName, 1024, nullptr); + CFRelease (cfName); if (ctFontRef != nullptr) { @@ -272869,7 +272979,7 @@ public: if (font.isItalic()) { - CTFontRef newFont = CTFontCreateCopyWithSymbolicTraits (ctFontRef, 0.0, nullptr, + CTFontRef newFont = CTFontCreateCopyWithSymbolicTraits (ctFontRef, 0.0f, nullptr, kCTFontItalicTrait, kCTFontItalicTrait); if (newFont != nullptr) @@ -272885,7 +272995,7 @@ public: if (font.isBold()) { - CTFontRef newFont = CTFontCreateCopyWithSymbolicTraits (ctFontRef, 0.0, nullptr, + CTFontRef newFont = CTFontCreateCopyWithSymbolicTraits (ctFontRef, 0.0f, nullptr, kCTFontBoldTrait, kCTFontBoldTrait); if (newFont != nullptr) { @@ -277899,9 +278009,9 @@ public: unitsToHeightScaleFactor (0.0f) { JUCE_AUTORELEASEPOOL - CFStringRef name = PlatformUtilities::juceStringToCFString (font.getTypefaceName()); - ctFontRef = CTFontCreateWithName (name, 1024, nullptr); - CFRelease (name); + CFStringRef cfName = PlatformUtilities::juceStringToCFString (font.getTypefaceName()); + ctFontRef = CTFontCreateWithName (cfName, 1024, nullptr); + CFRelease (cfName); if (ctFontRef != nullptr) { @@ -277909,7 +278019,7 @@ public: if (font.isItalic()) { - CTFontRef newFont = CTFontCreateCopyWithSymbolicTraits (ctFontRef, 0.0, nullptr, + CTFontRef newFont = CTFontCreateCopyWithSymbolicTraits (ctFontRef, 0.0f, nullptr, kCTFontItalicTrait, kCTFontItalicTrait); if (newFont != nullptr) @@ -277925,7 +278035,7 @@ public: if (font.isBold()) { - CTFontRef newFont = CTFontCreateCopyWithSymbolicTraits (ctFontRef, 0.0, nullptr, + CTFontRef newFont = CTFontCreateCopyWithSymbolicTraits (ctFontRef, 0.0f, nullptr, kCTFontBoldTrait, kCTFontBoldTrait); if (newFont != nullptr) { @@ -279627,7 +279737,9 @@ public: bool isMinimised() const; void setFullScreen (bool shouldBeFullScreen); bool isFullScreen() const; + void updateFullscreenStatus(); bool contains (const Point& position, bool trueIfInAChildWindow) const; + bool hasNativeTitleBar() const { return (getStyleFlags() & windowHasTitleBar) != 0; } const BorderSize getFrameSize() const; bool setAlwaysOnTop (bool alwaysOnTop); void toFront (bool makeActiveWindow); @@ -279731,6 +279843,17 @@ public: : (num == 2 ? ModifierKeys::middleButtonModifier : 0)); } + static unsigned int getNSWindowStyleMask (const int flags) noexcept + { + unsigned int style = (flags & windowHasTitleBar) != 0 ? NSTitledWindowMask + : NSBorderlessWindowMask; + + if ((flags & windowHasMinimiseButton) != 0) style |= NSMiniaturizableWindowMask; + if ((flags & windowHasCloseButton) != 0) style |= NSClosableWindowMask; + if ((flags & windowIsResizable) != 0) style |= NSResizableWindowMask; + return style; + } + virtual void viewFocusGain(); virtual void viewFocusLoss(); bool isFocused() const; @@ -280152,7 +280275,7 @@ END_JUCE_NAMESPACE if (JUCE_NAMESPACE::Component::getCurrentlyModalComponent() != nullptr && owner->getComponent()->isCurrentlyBlockedByAnotherModalComponent() - && (owner->getStyleFlags() & JUCE_NAMESPACE::ComponentPeer::windowHasTitleBar) != 0) + && owner->hasNativeTitleBar()) JUCE_NAMESPACE::Component::getCurrentlyModalComponent()->inputAttemptWhenModal(); return frameRect.size; @@ -280163,6 +280286,8 @@ END_JUCE_NAMESPACE isZooming = true; [super zoom: sender]; isZooming = false; + + owner->redirectMovedOrResized(); } - (void) windowWillMove: (NSNotification*) notification @@ -280171,7 +280296,7 @@ END_JUCE_NAMESPACE if (JUCE_NAMESPACE::Component::getCurrentlyModalComponent() != nullptr && owner->getComponent()->isCurrentlyBlockedByAnotherModalComponent() - && (owner->getStyleFlags() & JUCE_NAMESPACE::ComponentPeer::windowHasTitleBar) != 0) + && owner->hasNativeTitleBar()) JUCE_NAMESPACE::Component::getCurrentlyModalComponent()->inputAttemptWhenModal(); } @@ -280251,7 +280376,7 @@ NSViewComponentPeer::NSViewComponentPeer (Component* const component_, #endif recursiveToFrontCall (false) { - NSRect r = NSMakeRect (0, 0, (float) component->getWidth(), (float) component->getHeight()); + NSRect r = NSMakeRect (0, 0, (CGFloat) component->getWidth(), (CGFloat) component->getHeight()); view = [[JuceNSView alloc] initWithOwner: this withFrame: r]; [view setPostsFrameChangedNotifications: YES]; @@ -280263,27 +280388,12 @@ NSViewComponentPeer::NSViewComponentPeer (Component* const component_, } else { - r.origin.x = (float) component->getX(); - r.origin.y = (float) component->getY(); + r.origin.x = (CGFloat) component->getX(); + r.origin.y = (CGFloat) component->getY(); r.origin.y = [[[NSScreen screens] objectAtIndex: 0] frame].size.height - (r.origin.y + r.size.height); - unsigned int style = 0; - if ((windowStyleFlags & windowHasTitleBar) == 0) - style = NSBorderlessWindowMask; - else - style = NSTitledWindowMask; - - if ((windowStyleFlags & windowHasMinimiseButton) != 0) - style |= NSMiniaturizableWindowMask; - - if ((windowStyleFlags & windowHasCloseButton) != 0) - style |= NSClosableWindowMask; - - if ((windowStyleFlags & windowIsResizable) != 0) - style |= NSResizableWindowMask; - window = [[JuceNSWindow alloc] initWithContentRect: r - styleMask: style + styleMask: getNSWindowStyleMask (windowStyleFlags) backing: NSBackingStoreBuffered defer: YES]; @@ -280377,7 +280487,7 @@ void NSViewComponentPeer::setBounds (int x, int y, int w, int h, bool isNowFullS { fullScreen = isNowFullScreen; - NSRect r = NSMakeRect ((float) x, (float) y, (float) jmax (0, w), (float) jmax (0, h)); + NSRect r = NSMakeRect ((CGFloat) x, (CGFloat) y, (CGFloat) jmax (0, w), (CGFloat) jmax (0, h)); if (isSharedWindow) { @@ -280518,7 +280628,7 @@ void NSViewComponentPeer::setMinimised (bool shouldBeMinimised) bool NSViewComponentPeer::isMinimised() const { - return window != nil && [window isMiniaturized]; + return [window isMiniaturized]; } void NSViewComponentPeer::setFullScreen (bool shouldBeFullScreen) @@ -280527,11 +280637,12 @@ void NSViewComponentPeer::setFullScreen (bool shouldBeFullScreen) { Rectangle r (lastNonFullscreenBounds); - setMinimised (false); + if (isMinimised()) + setMinimised (false); if (fullScreen != shouldBeFullScreen) { - if (shouldBeFullScreen && (getStyleFlags() & windowHasTitleBar) != 0) + if (shouldBeFullScreen && hasNativeTitleBar()) { fullScreen = true; [window performZoom: nil]; @@ -280539,7 +280650,7 @@ void NSViewComponentPeer::setFullScreen (bool shouldBeFullScreen) else { if (shouldBeFullScreen) - r = Desktop::getInstance().getMainMonitorArea(); + r = component->getParentMonitorArea(); // (can't call the component's setBounds method because that'll reset our fullscreen flag) if (r != getComponent()->getBounds() && ! r.isEmpty()) @@ -280637,8 +280748,7 @@ void NSViewComponentPeer::toBehind (ComponentPeer* other) else { [window orderWindow: NSWindowBelow - relativeTo: otherPeer->window != nil ? [otherPeer->window windowNumber] - : 0 ]; + relativeTo: [otherPeer->window windowNumber]]; } } } @@ -280694,7 +280804,7 @@ void juce_HandleProcessFocusChange() bool NSViewComponentPeer::isFocused() const { return isSharedWindow ? this == currentlyFocusedPeer - : (window != nil && [window isKeyWindow]); + : [window isKeyWindow]; } void NSViewComponentPeer::grabFocus() @@ -281052,8 +281162,23 @@ bool NSViewComponentPeer::windowShouldClose() return NO; } +void NSViewComponentPeer::updateFullscreenStatus() +{ + if (hasNativeTitleBar()) + { + const Rectangle screen (getFrameSize().subtractedFrom (component->getParentMonitorArea())); + const Rectangle window (component->getScreenBounds()); + + fullScreen = std::abs (screen.getX() - window.getX()) <= 2 + && std::abs (screen.getY() - window.getY()) <= 2 + && std::abs (screen.getRight() - window.getRight()) <= 2 + && std::abs (screen.getBottom() - window.getBottom()) <= 2; + } +} + void NSViewComponentPeer::redirectMovedOrResized() { + updateFullscreenStatus(); handleMovedOrResized(); } @@ -281121,8 +281246,8 @@ void NSViewComponentPeer::repaint (const Rectangle& area) } else { - [view setNeedsDisplayInRect: NSMakeRect ((float) area.getX(), [view frame].size.height - (float) area.getBottom(), - (float) area.getWidth(), (float) area.getHeight())]; + [view setNeedsDisplayInRect: NSMakeRect ((CGFloat) area.getX(), [view frame].size.height - (CGFloat) area.getBottom(), + (CGFloat) area.getWidth(), (CGFloat) area.getHeight())]; } } diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 386f8e5871..b30c2a3083 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -73,7 +73,7 @@ namespace JuceDummyNamespace {} */ #define JUCE_MAJOR_VERSION 1 #define JUCE_MINOR_VERSION 53 -#define JUCE_BUILDNUMBER 98 +#define JUCE_BUILDNUMBER 99 /** Current Juce version number. @@ -7134,9 +7134,9 @@ public: { const ScopedLockType lock (getLock()); const ElementType* e = data.elements.getData(); - const ElementType* const end = e + numUsed; + const ElementType* const end_ = e + numUsed; - for (; e != end; ++e) + for (; e != end_; ++e) if (elementToLookFor == *e) return static_cast (e - data.elements.getData()); @@ -7152,9 +7152,9 @@ public: { const ScopedLockType lock (getLock()); const ElementType* e = data.elements.getData(); - const ElementType* const end = e + numUsed; + const ElementType* const end_ = e + numUsed; - for (; e != end; ++e) + for (; e != end_; ++e) if (elementToLookFor == *e) return true; @@ -7486,11 +7486,11 @@ public: const ScopedLockType lock (getLock()); int start = 0; - int end = numUsed; + int end_ = numUsed; for (;;) { - if (start >= end) + if (start >= end_) { return -1; } @@ -7500,14 +7500,14 @@ public: } else { - const int halfway = (start + end) >> 1; + const int halfway = (start + end_) >> 1; if (halfway == start) return -1; else if (comparator.compareElements (elementToLookFor, data.elements [halfway]) >= 0) start = halfway; else - end = halfway; + end_ = halfway; } } } @@ -8470,7 +8470,10 @@ private: any kind of ReferenceCountedObject. The var class is intended to act like the kind of values used in dynamic scripting languages. - @see DynamicObject + You can save/load var objects either in a small, proprietary binary format + using writeToStream()/readFromStream(), or as JSON by using the JSON class. + + @see JSON, DynamicObject */ class JUCE_API var { @@ -8630,12 +8633,14 @@ public: /** Writes a binary representation of this value to a stream. The data can be read back later using readFromStream(). + @see JSON */ void writeToStream (OutputStream& output) const; /** Reads back a stored binary representation of a value. The data in the stream must have been written using writeToStream(), or this will have unpredictable results. + @see JSON */ static var readFromStream (InputStream& input); @@ -9692,9 +9697,9 @@ public: { const ScopedLockType lock (getLock()); ObjectClass* const* e = data.elements.getData(); - ObjectClass* const* const end = e + numUsed; + ObjectClass* const* const end_ = e + numUsed; - for (; e != end; ++e) + for (; e != end_; ++e) if (objectToLookFor == *e) return static_cast (e - data.elements.getData()); @@ -9710,9 +9715,9 @@ public: { const ScopedLockType lock (getLock()); ObjectClass* const* e = data.elements.getData(); - ObjectClass* const* const end = e + numUsed; + ObjectClass* const* const end_ = e + numUsed; - for (; e != end; ++e) + for (; e != end_; ++e) if (objectToLookFor == *e) return true; @@ -9969,11 +9974,11 @@ public: const ScopedLockType lock (getLock()); int start = 0; - int end = numUsed; + int end_ = numUsed; for (;;) { - if (start >= end) + if (start >= end_) { return -1; } @@ -9983,14 +9988,14 @@ public: } else { - const int halfway = (start + end) >> 1; + const int halfway = (start + end_) >> 1; if (halfway == start) return -1; else if (comparator.compareElements (objectToLookFor, data.elements [halfway]) >= 0) start = halfway; else - end = halfway; + end_ = halfway; } } } @@ -10570,7 +10575,7 @@ public: will be the "upperLimit" parameter that is passed to your generateHash() function. The number of hash slots will grow automatically if necessary, or it can be remapped manually using remapTable(). */ - HashMap (const int numberOfSlots = defaultHashTableSize) + explicit HashMap (const int numberOfSlots = defaultHashTableSize) : totalNumItems (0) { slots.insertMultiple (0, nullptr, numberOfSlots); @@ -14088,9 +14093,9 @@ public: { const ScopedLockType lock (getLock()); ObjectClass** e = data.elements.getData(); - ObjectClass** const end = e + numUsed; + ObjectClass** const end_ = e + numUsed; - while (e != end) + while (e != end_) { if (objectToLookFor == *e) return static_cast (e - data.elements.getData()); @@ -14110,9 +14115,9 @@ public: { const ScopedLockType lock (getLock()); ObjectClass** e = data.elements.getData(); - ObjectClass** const end = e + numUsed; + ObjectClass** const end_ = e + numUsed; - while (e != end) + while (e != end_) { if (objectToLookFor == *e) return true; @@ -14418,12 +14423,12 @@ public: const ScopedLockType lock (getLock()); const int start = jlimit (0, numUsed, startIndex); - const int end = jlimit (0, numUsed, startIndex + numberToRemove); + const int end_ = jlimit (0, numUsed, startIndex + numberToRemove); - if (end > start) + if (end_ > start) { int i; - for (i = start; i < end; ++i) + for (i = start; i < end_; ++i) { if (data.elements[i] != nullptr) { @@ -14432,9 +14437,9 @@ public: } } - const int rangeSize = end - start; + const int rangeSize = end_ - start; ObjectClass** e = data.elements + start; - i = numUsed - end; + i = numUsed - end_; numUsed -= rangeSize; while (--i >= 0) @@ -14959,11 +14964,11 @@ public: const ScopedLockType lock (getLock()); int start = 0; - int end = numUsed; + int end_ = numUsed; for (;;) { - if (start >= end) + if (start >= end_) { return -1; } @@ -14973,12 +14978,12 @@ public: } else { - const int halfway = (start + end) >> 1; + const int halfway = (start + end_) >> 1; if (halfway == start) return -1; else if (elementToLookFor < data.elements [halfway]) - end = halfway; + end_ = halfway; else start = halfway; } @@ -14995,11 +15000,11 @@ public: const ScopedLockType lock (getLock()); int start = 0; - int end = numUsed; + int end_ = numUsed; for (;;) { - if (start >= end) + if (start >= end_) { return false; } @@ -15009,12 +15014,12 @@ public: } else { - const int halfway = (start + end) >> 1; + const int halfway = (start + end_) >> 1; if (halfway == start) return false; else if (elementToLookFor < data.elements [halfway]) - end = halfway; + end_ = halfway; else start = halfway; } @@ -15031,13 +15036,13 @@ public: const ScopedLockType lock (getLock()); int start = 0; - int end = numUsed; + int end_ = numUsed; for (;;) { - if (start >= end) + if (start >= end_) { - jassert (start <= end); + jassert (start <= end_); insertInternal (start, newElement); break; } @@ -15047,7 +15052,7 @@ public: } else { - const int halfway = (start + end) >> 1; + const int halfway = (start + end_) >> 1; if (halfway == start) { @@ -15059,7 +15064,7 @@ public: break; } else if (newElement < data.elements [halfway]) - end = halfway; + end_ = halfway; else start = halfway; } diff --git a/src/core/juce_StandardHeader.h b/src/core/juce_StandardHeader.h index 5d8afb71af..83fdf0d9da 100644 --- a/src/core/juce_StandardHeader.h +++ b/src/core/juce_StandardHeader.h @@ -33,7 +33,7 @@ */ #define JUCE_MAJOR_VERSION 1 #define JUCE_MINOR_VERSION 53 -#define JUCE_BUILDNUMBER 98 +#define JUCE_BUILDNUMBER 99 /** Current Juce version number. diff --git a/src/native/mac/juce_mac_NSViewComponentPeer.mm b/src/native/mac/juce_mac_NSViewComponentPeer.mm index 908888ede7..2024286690 100644 --- a/src/native/mac/juce_mac_NSViewComponentPeer.mm +++ b/src/native/mac/juce_mac_NSViewComponentPeer.mm @@ -165,7 +165,9 @@ public: bool isMinimised() const; void setFullScreen (bool shouldBeFullScreen); bool isFullScreen() const; + void updateFullscreenStatus(); bool contains (const Point& position, bool trueIfInAChildWindow) const; + bool hasNativeTitleBar() const { return (getStyleFlags() & windowHasTitleBar) != 0; } const BorderSize getFrameSize() const; bool setAlwaysOnTop (bool alwaysOnTop); void toFront (bool makeActiveWindow); @@ -269,6 +271,17 @@ public: : (num == 2 ? ModifierKeys::middleButtonModifier : 0)); } + static unsigned int getNSWindowStyleMask (const int flags) noexcept + { + unsigned int style = (flags & windowHasTitleBar) != 0 ? NSTitledWindowMask + : NSBorderlessWindowMask; + + if ((flags & windowHasMinimiseButton) != 0) style |= NSMiniaturizableWindowMask; + if ((flags & windowHasCloseButton) != 0) style |= NSClosableWindowMask; + if ((flags & windowIsResizable) != 0) style |= NSResizableWindowMask; + return style; + } + //============================================================================== virtual void viewFocusGain(); virtual void viewFocusLoss(); @@ -701,7 +714,7 @@ END_JUCE_NAMESPACE if (JUCE_NAMESPACE::Component::getCurrentlyModalComponent() != nullptr && owner->getComponent()->isCurrentlyBlockedByAnotherModalComponent() - && (owner->getStyleFlags() & JUCE_NAMESPACE::ComponentPeer::windowHasTitleBar) != 0) + && owner->hasNativeTitleBar()) JUCE_NAMESPACE::Component::getCurrentlyModalComponent()->inputAttemptWhenModal(); return frameRect.size; @@ -712,6 +725,8 @@ END_JUCE_NAMESPACE isZooming = true; [super zoom: sender]; isZooming = false; + + owner->redirectMovedOrResized(); } - (void) windowWillMove: (NSNotification*) notification @@ -720,7 +735,7 @@ END_JUCE_NAMESPACE if (JUCE_NAMESPACE::Component::getCurrentlyModalComponent() != nullptr && owner->getComponent()->isCurrentlyBlockedByAnotherModalComponent() - && (owner->getStyleFlags() & JUCE_NAMESPACE::ComponentPeer::windowHasTitleBar) != 0) + && owner->hasNativeTitleBar()) JUCE_NAMESPACE::Component::getCurrentlyModalComponent()->inputAttemptWhenModal(); } @@ -805,7 +820,7 @@ NSViewComponentPeer::NSViewComponentPeer (Component* const component_, #endif recursiveToFrontCall (false) { - NSRect r = NSMakeRect (0, 0, (float) component->getWidth(), (float) component->getHeight()); + NSRect r = NSMakeRect (0, 0, (CGFloat) component->getWidth(), (CGFloat) component->getHeight()); view = [[JuceNSView alloc] initWithOwner: this withFrame: r]; [view setPostsFrameChangedNotifications: YES]; @@ -817,27 +832,12 @@ NSViewComponentPeer::NSViewComponentPeer (Component* const component_, } else { - r.origin.x = (float) component->getX(); - r.origin.y = (float) component->getY(); + r.origin.x = (CGFloat) component->getX(); + r.origin.y = (CGFloat) component->getY(); r.origin.y = [[[NSScreen screens] objectAtIndex: 0] frame].size.height - (r.origin.y + r.size.height); - unsigned int style = 0; - if ((windowStyleFlags & windowHasTitleBar) == 0) - style = NSBorderlessWindowMask; - else - style = NSTitledWindowMask; - - if ((windowStyleFlags & windowHasMinimiseButton) != 0) - style |= NSMiniaturizableWindowMask; - - if ((windowStyleFlags & windowHasCloseButton) != 0) - style |= NSClosableWindowMask; - - if ((windowStyleFlags & windowIsResizable) != 0) - style |= NSResizableWindowMask; - window = [[JuceNSWindow alloc] initWithContentRect: r - styleMask: style + styleMask: getNSWindowStyleMask (windowStyleFlags) backing: NSBackingStoreBuffered defer: YES]; @@ -932,7 +932,7 @@ void NSViewComponentPeer::setBounds (int x, int y, int w, int h, bool isNowFullS { fullScreen = isNowFullScreen; - NSRect r = NSMakeRect ((float) x, (float) y, (float) jmax (0, w), (float) jmax (0, h)); + NSRect r = NSMakeRect ((CGFloat) x, (CGFloat) y, (CGFloat) jmax (0, w), (CGFloat) jmax (0, h)); if (isSharedWindow) { @@ -1073,7 +1073,7 @@ void NSViewComponentPeer::setMinimised (bool shouldBeMinimised) bool NSViewComponentPeer::isMinimised() const { - return window != nil && [window isMiniaturized]; + return [window isMiniaturized]; } void NSViewComponentPeer::setFullScreen (bool shouldBeFullScreen) @@ -1082,11 +1082,12 @@ void NSViewComponentPeer::setFullScreen (bool shouldBeFullScreen) { Rectangle r (lastNonFullscreenBounds); - setMinimised (false); + if (isMinimised()) + setMinimised (false); if (fullScreen != shouldBeFullScreen) { - if (shouldBeFullScreen && (getStyleFlags() & windowHasTitleBar) != 0) + if (shouldBeFullScreen && hasNativeTitleBar()) { fullScreen = true; [window performZoom: nil]; @@ -1094,7 +1095,7 @@ void NSViewComponentPeer::setFullScreen (bool shouldBeFullScreen) else { if (shouldBeFullScreen) - r = Desktop::getInstance().getMainMonitorArea(); + r = component->getParentMonitorArea(); // (can't call the component's setBounds method because that'll reset our fullscreen flag) if (r != getComponent()->getBounds() && ! r.isEmpty()) @@ -1192,8 +1193,7 @@ void NSViewComponentPeer::toBehind (ComponentPeer* other) else { [window orderWindow: NSWindowBelow - relativeTo: otherPeer->window != nil ? [otherPeer->window windowNumber] - : 0 ]; + relativeTo: [otherPeer->window windowNumber]]; } } } @@ -1250,7 +1250,7 @@ void juce_HandleProcessFocusChange() bool NSViewComponentPeer::isFocused() const { return isSharedWindow ? this == currentlyFocusedPeer - : (window != nil && [window isKeyWindow]); + : [window isKeyWindow]; } void NSViewComponentPeer::grabFocus() @@ -1610,8 +1610,23 @@ bool NSViewComponentPeer::windowShouldClose() return NO; } +void NSViewComponentPeer::updateFullscreenStatus() +{ + if (hasNativeTitleBar()) + { + const Rectangle screen (getFrameSize().subtractedFrom (component->getParentMonitorArea())); + const Rectangle window (component->getScreenBounds()); + + fullScreen = std::abs (screen.getX() - window.getX()) <= 2 + && std::abs (screen.getY() - window.getY()) <= 2 + && std::abs (screen.getRight() - window.getRight()) <= 2 + && std::abs (screen.getBottom() - window.getBottom()) <= 2; + } +} + void NSViewComponentPeer::redirectMovedOrResized() { + updateFullscreenStatus(); handleMovedOrResized(); } @@ -1682,8 +1697,8 @@ void NSViewComponentPeer::repaint (const Rectangle& area) } else { - [view setNeedsDisplayInRect: NSMakeRect ((float) area.getX(), [view frame].size.height - (float) area.getBottom(), - (float) area.getWidth(), (float) area.getHeight())]; + [view setNeedsDisplayInRect: NSMakeRect ((CGFloat) area.getX(), [view frame].size.height - (CGFloat) area.getBottom(), + (CGFloat) area.getWidth(), (CGFloat) area.getHeight())]; } }