diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 824064d577..e5865f9f33 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -4830,6 +4830,7 @@ public: const TermPtr createTermToEvaluateInput (const EvaluationContext& context, const Term* input_, double overallTarget, Term* topLevelTerm) const { + (void) input_; jassert (input_ == input); const Term* const dest = findDestinationFor (topLevelTerm, this); @@ -5596,7 +5597,13 @@ Expression::ParseError::ParseError (const String& message) Expression::EvaluationError::EvaluationError (const String& message) : description (message) { - DBG ("Expression::EvaluationError: " + message); + DBG ("Expression::EvaluationError: " + description); +} + +Expression::EvaluationError::EvaluationError (const String& symbol, const String& member) + : description ("Unknown symbol: \"" + symbol + (member.isEmpty() ? "\"" : ("." + member + "\""))) +{ + DBG ("Expression::EvaluationError: " + description); } Expression::EvaluationContext::EvaluationContext() {} @@ -5604,7 +5611,7 @@ Expression::EvaluationContext::~EvaluationContext() {} const Expression Expression::EvaluationContext::getSymbolValue (const String& symbol, const String& member) const { - throw EvaluationError ("Unknown symbol: \"" + symbol + (member.isEmpty() ? "\"" : ("." + member + "\""))); + throw EvaluationError (symbol, member); } double Expression::EvaluationContext::evaluateFunction (const String& functionName, const double* parameters, int numParams) const @@ -5629,14 +5636,10 @@ double Expression::EvaluationContext::evaluateFunction (const String& functionNa } else if (numParams == 1) { - if (functionName == "sin") - return sin (parameters[0]); - else if (functionName == "cos") - return cos (parameters[0]); - else if (functionName == "tan") - return tan (parameters[0]); - else if (functionName == "abs") - return std::abs (parameters[0]); + if (functionName == "sin") return sin (parameters[0]); + else if (functionName == "cos") return cos (parameters[0]); + else if (functionName == "tan") return tan (parameters[0]); + else if (functionName == "abs") return std::abs (parameters[0]); } } @@ -68677,13 +68680,12 @@ void MenuBarComponent::paint (Graphics& g) void MenuBarComponent::resized() { xPositions.clear(); - int x = 2; + int x = 0; xPositions.add (x); for (int i = 0; i < menuNames.size(); ++i) { x += getLookAndFeel().getMenuBarItemWidth (*this, i, menuNames[i]); - xPositions.add (x); } } @@ -68799,7 +68801,9 @@ void MenuBarComponent::handleCommandMessage (int commandId) { const Point mousePos (getMouseXYRelative()); updateItemUnderMouse (mousePos.getX(), mousePos.getY()); - setOpenItem (-1); + + if (currentPopupIndex == topLevelIndexClicked) + setOpenItem (-1); if (commandId != 0 && model != 0) model->menuItemSelected (commandId, topLevelIndexClicked); @@ -77065,13 +77069,19 @@ void AlertWindow::addTextEditor (const String& name, updateLayout (false); } -const String AlertWindow::getTextEditorContents (const String& nameOfTextEditor) const +TextEditor* AlertWindow::getTextEditor (const String& nameOfTextEditor) const { for (int i = textBoxes.size(); --i >= 0;) - if (((TextEditor*)textBoxes[i])->getName() == nameOfTextEditor) - return ((TextEditor*)textBoxes[i])->getText(); + if (static_cast (textBoxes.getUnchecked(i))->getName() == nameOfTextEditor) + return static_cast (textBoxes.getUnchecked(i)); - return String::empty; + return 0; +} + +const String AlertWindow::getTextEditorContents (const String& nameOfTextEditor) const +{ + TextEditor* const t = getTextEditor (nameOfTextEditor); + return t != 0 ? t->getText() : String::empty; } void AlertWindow::addComboBox (const String& name, @@ -86404,7 +86414,7 @@ const Expression DrawableComposite::getSymbolValue (const String& symbol, const return m->position.getExpression(); } - return Expression::EvaluationContext::getSymbolValue (symbol, member); + throw Expression::EvaluationError (symbol, member); } const Rectangle DrawableComposite::getUntransformedBounds (const bool includeMarkers) const @@ -86662,6 +86672,7 @@ bool DrawableComposite::ValueTreeWrapper::containsMarker (bool xAxis, const Valu const DrawableComposite::Marker DrawableComposite::ValueTreeWrapper::getMarker (bool xAxis, const ValueTree& state) const { + (void) xAxis; jassert (containsMarker (xAxis, state)); return Marker (state [nameProperty], RelativeCoordinate (state [posProperty].toString())); @@ -90744,6 +90755,11 @@ void TextLayout::clear() totalLines = 0; } +bool TextLayout::isEmpty() const +{ + return tokens.size() == 0; +} + void TextLayout::appendText (const String& text, const Font& font) { const juce_wchar* t = text; diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 948a5116b1..b9fb1527c6 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -6923,6 +6923,7 @@ public: { public: EvaluationError (const String& message); + EvaluationError (const String& symbolName, const String& memberName); String description; }; @@ -54408,6 +54409,9 @@ public: void setText (const String& newText, const Font& fontToUse); + /** Returns true if the layout has not had any text added yet. */ + bool isEmpty() const; + /** Breaks the text up to form a paragraph with the given width. @param maximumWidth any text wider than this will be split @@ -54568,6 +54572,9 @@ public: */ const String getTextEditorContents (const String& nameOfTextEditor) const; + /** Returns a pointer to a textbox that was added with addTextEditor(). */ + TextEditor* getTextEditor (const String& nameOfTextEditor) const; + /** Adds a drop-down list of choices to the box. After the box has been shown, the getComboBoxComponent() method can diff --git a/src/containers/juce_Expression.cpp b/src/containers/juce_Expression.cpp index 09a994fe08..15eee94d72 100644 --- a/src/containers/juce_Expression.cpp +++ b/src/containers/juce_Expression.cpp @@ -210,6 +210,7 @@ public: const TermPtr createTermToEvaluateInput (const EvaluationContext& context, const Term* input_, double overallTarget, Term* topLevelTerm) const { + (void) input_; jassert (input_ == input); const Term* const dest = findDestinationFor (topLevelTerm, this); @@ -987,7 +988,13 @@ Expression::ParseError::ParseError (const String& message) Expression::EvaluationError::EvaluationError (const String& message) : description (message) { - DBG ("Expression::EvaluationError: " + message); + DBG ("Expression::EvaluationError: " + description); +} + +Expression::EvaluationError::EvaluationError (const String& symbol, const String& member) + : description ("Unknown symbol: \"" + symbol + (member.isEmpty() ? "\"" : ("." + member + "\""))) +{ + DBG ("Expression::EvaluationError: " + description); } //============================================================================== @@ -996,7 +1003,7 @@ Expression::EvaluationContext::~EvaluationContext() {} const Expression Expression::EvaluationContext::getSymbolValue (const String& symbol, const String& member) const { - throw EvaluationError ("Unknown symbol: \"" + symbol + (member.isEmpty() ? "\"" : ("." + member + "\""))); + throw EvaluationError (symbol, member); } double Expression::EvaluationContext::evaluateFunction (const String& functionName, const double* parameters, int numParams) const @@ -1021,14 +1028,10 @@ double Expression::EvaluationContext::evaluateFunction (const String& functionNa } else if (numParams == 1) { - if (functionName == "sin") - return sin (parameters[0]); - else if (functionName == "cos") - return cos (parameters[0]); - else if (functionName == "tan") - return tan (parameters[0]); - else if (functionName == "abs") - return std::abs (parameters[0]); + if (functionName == "sin") return sin (parameters[0]); + else if (functionName == "cos") return cos (parameters[0]); + else if (functionName == "tan") return tan (parameters[0]); + else if (functionName == "abs") return std::abs (parameters[0]); } } diff --git a/src/containers/juce_Expression.h b/src/containers/juce_Expression.h index 07f50127b0..9085e53c92 100644 --- a/src/containers/juce_Expression.h +++ b/src/containers/juce_Expression.h @@ -182,6 +182,7 @@ public: { public: EvaluationError (const String& message); + EvaluationError (const String& symbolName, const String& memberName); String description; }; diff --git a/src/gui/components/menus/juce_MenuBarComponent.cpp b/src/gui/components/menus/juce_MenuBarComponent.cpp index c216926788..e461751b30 100644 --- a/src/gui/components/menus/juce_MenuBarComponent.cpp +++ b/src/gui/components/menus/juce_MenuBarComponent.cpp @@ -113,13 +113,12 @@ void MenuBarComponent::paint (Graphics& g) void MenuBarComponent::resized() { xPositions.clear(); - int x = 2; + int x = 0; xPositions.add (x); for (int i = 0; i < menuNames.size(); ++i) { x += getLookAndFeel().getMenuBarItemWidth (*this, i, menuNames[i]); - xPositions.add (x); } } @@ -235,7 +234,9 @@ void MenuBarComponent::handleCommandMessage (int commandId) { const Point mousePos (getMouseXYRelative()); updateItemUnderMouse (mousePos.getX(), mousePos.getY()); - setOpenItem (-1); + + if (currentPopupIndex == topLevelIndexClicked) + setOpenItem (-1); if (commandId != 0 && model != 0) model->menuItemSelected (commandId, topLevelIndexClicked); diff --git a/src/gui/components/windows/juce_AlertWindow.cpp b/src/gui/components/windows/juce_AlertWindow.cpp index 2d4acf90a6..b49f064088 100644 --- a/src/gui/components/windows/juce_AlertWindow.cpp +++ b/src/gui/components/windows/juce_AlertWindow.cpp @@ -226,13 +226,19 @@ void AlertWindow::addTextEditor (const String& name, updateLayout (false); } -const String AlertWindow::getTextEditorContents (const String& nameOfTextEditor) const +TextEditor* AlertWindow::getTextEditor (const String& nameOfTextEditor) const { for (int i = textBoxes.size(); --i >= 0;) - if (((TextEditor*)textBoxes[i])->getName() == nameOfTextEditor) - return ((TextEditor*)textBoxes[i])->getText(); + if (static_cast (textBoxes.getUnchecked(i))->getName() == nameOfTextEditor) + return static_cast (textBoxes.getUnchecked(i)); + + return 0; +} - return String::empty; +const String AlertWindow::getTextEditorContents (const String& nameOfTextEditor) const +{ + TextEditor* const t = getTextEditor (nameOfTextEditor); + return t != 0 ? t->getText() : String::empty; } diff --git a/src/gui/components/windows/juce_AlertWindow.h b/src/gui/components/windows/juce_AlertWindow.h index fa87942710..b694308dec 100644 --- a/src/gui/components/windows/juce_AlertWindow.h +++ b/src/gui/components/windows/juce_AlertWindow.h @@ -142,6 +142,9 @@ public: */ const String getTextEditorContents (const String& nameOfTextEditor) const; + /** Returns a pointer to a textbox that was added with addTextEditor(). */ + TextEditor* getTextEditor (const String& nameOfTextEditor) const; + //============================================================================== /** Adds a drop-down list of choices to the box. diff --git a/src/gui/graphics/drawables/juce_DrawableComposite.cpp b/src/gui/graphics/drawables/juce_DrawableComposite.cpp index 685dca052e..7ed409d3d2 100644 --- a/src/gui/graphics/drawables/juce_DrawableComposite.cpp +++ b/src/gui/graphics/drawables/juce_DrawableComposite.cpp @@ -266,7 +266,7 @@ const Expression DrawableComposite::getSymbolValue (const String& symbol, const return m->position.getExpression(); } - return Expression::EvaluationContext::getSymbolValue (symbol, member); + throw Expression::EvaluationError (symbol, member); } const Rectangle DrawableComposite::getUntransformedBounds (const bool includeMarkers) const @@ -526,6 +526,7 @@ bool DrawableComposite::ValueTreeWrapper::containsMarker (bool xAxis, const Valu const DrawableComposite::Marker DrawableComposite::ValueTreeWrapper::getMarker (bool xAxis, const ValueTree& state) const { + (void) xAxis; jassert (containsMarker (xAxis, state)); return Marker (state [nameProperty], RelativeCoordinate (state [posProperty].toString())); diff --git a/src/gui/graphics/fonts/juce_TextLayout.cpp b/src/gui/graphics/fonts/juce_TextLayout.cpp index 95e910bf0c..17e481a3b1 100644 --- a/src/gui/graphics/fonts/juce_TextLayout.cpp +++ b/src/gui/graphics/fonts/juce_TextLayout.cpp @@ -136,6 +136,11 @@ void TextLayout::clear() totalLines = 0; } +bool TextLayout::isEmpty() const +{ + return tokens.size() == 0; +} + void TextLayout::appendText (const String& text, const Font& font) { const juce_wchar* t = text; diff --git a/src/gui/graphics/fonts/juce_TextLayout.h b/src/gui/graphics/fonts/juce_TextLayout.h index c887a66d6f..f2c84dc4cf 100644 --- a/src/gui/graphics/fonts/juce_TextLayout.h +++ b/src/gui/graphics/fonts/juce_TextLayout.h @@ -88,6 +88,9 @@ public: void setText (const String& newText, const Font& fontToUse); + /** Returns true if the layout has not had any text added yet. */ + bool isEmpty() const; + //============================================================================== /** Breaks the text up to form a paragraph with the given width.