Browse Source

Couple of minor tweaks, and a fix for menu bars.

tags/2021-05-28
Julian Storer 14 years ago
parent
commit
acbfe6c645
10 changed files with 82 additions and 36 deletions
  1. +34
    -18
      juce_amalgamated.cpp
  2. +7
    -0
      juce_amalgamated.h
  3. +13
    -10
      src/containers/juce_Expression.cpp
  4. +1
    -0
      src/containers/juce_Expression.h
  5. +4
    -3
      src/gui/components/menus/juce_MenuBarComponent.cpp
  6. +10
    -4
      src/gui/components/windows/juce_AlertWindow.cpp
  7. +3
    -0
      src/gui/components/windows/juce_AlertWindow.h
  8. +2
    -1
      src/gui/graphics/drawables/juce_DrawableComposite.cpp
  9. +5
    -0
      src/gui/graphics/fonts/juce_TextLayout.cpp
  10. +3
    -0
      src/gui/graphics/fonts/juce_TextLayout.h

+ 34
- 18
juce_amalgamated.cpp View File

@@ -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<int> 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 <TextEditor*> (textBoxes.getUnchecked(i))->getName() == nameOfTextEditor)
return static_cast <TextEditor*> (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<float> 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;


+ 7
- 0
juce_amalgamated.h View File

@@ -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


+ 13
- 10
src/containers/juce_Expression.cpp View File

@@ -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]);
}
}


+ 1
- 0
src/containers/juce_Expression.h View File

@@ -182,6 +182,7 @@ public:
{
public:
EvaluationError (const String& message);
EvaluationError (const String& symbolName, const String& memberName);
String description;
};


+ 4
- 3
src/gui/components/menus/juce_MenuBarComponent.cpp View File

@@ -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<int> mousePos (getMouseXYRelative());
updateItemUnderMouse (mousePos.getX(), mousePos.getY());
setOpenItem (-1);
if (currentPopupIndex == topLevelIndexClicked)
setOpenItem (-1);
if (commandId != 0 && model != 0)
model->menuItemSelected (commandId, topLevelIndexClicked);


+ 10
- 4
src/gui/components/windows/juce_AlertWindow.cpp View File

@@ -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 <TextEditor*> (textBoxes.getUnchecked(i))->getName() == nameOfTextEditor)
return static_cast <TextEditor*> (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;
}


+ 3
- 0
src/gui/components/windows/juce_AlertWindow.h View File

@@ -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.


+ 2
- 1
src/gui/graphics/drawables/juce_DrawableComposite.cpp View File

@@ -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<float> 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()));


+ 5
- 0
src/gui/graphics/fonts/juce_TextLayout.cpp View File

@@ -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;


+ 3
- 0
src/gui/graphics/fonts/juce_TextLayout.h View File

@@ -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.


Loading…
Cancel
Save