diff --git a/source/panel/curve_panel/background_panel/grid_panel.cpp b/source/panel/curve_panel/background_panel/grid_panel.cpp index 0dd3272e..d94542c6 100644 --- a/source/panel/curve_panel/background_panel/grid_panel.cpp +++ b/source/panel/curve_panel/background_panel/grid_panel.cpp @@ -19,19 +19,13 @@ namespace zlPanel { void GridPanel::paint(juce::Graphics &g) { g.fillAll(uiBase.getBackgroundColor()); - const auto bound = getLocalBounds().toFloat(); - g.setFont(uiBase.getFontSize() * zlInterface::FontLarge); if (uiBase.getColourByIdx(zlInterface::gridColour).getFloatAlpha() <= 0.01f) { return; } g.setColour(uiBase.getTextInactiveColor()); for (size_t i = 0; i < backgroundFreqs.size(); ++i) { - const auto x = backgroundFreqs[i] * bound.getWidth() + bound.getX(); - const auto textBound = juce::Rectangle(x - uiBase.getFontSize() * 3 - uiBase.getFontSize() * 0.125f, - bound.getBottom() - uiBase.getFontSize() * 2, - uiBase.getFontSize() * 3, uiBase.getFontSize() * 2); - g.drawText(backgroundFreqsNames[i], textBound, juce::Justification::bottomRight); + g.drawText(backgroundFreqsNames[i], textBounds[i], juce::Justification::bottomRight); } g.setColour(uiBase.getColourByIdx(zlInterface::gridColour)); g.fillRectList(rectList); @@ -43,12 +37,15 @@ namespace zlPanel { const auto thickness = uiBase.getFontSize() * 0.1f; for (size_t i = 0; i < backgroundFreqs.size(); ++i) { const auto x = backgroundFreqs[i] * bound.getWidth() + bound.getX(); - rectList.add({x - thickness * .5f, bound.getY(),thickness, bound.getHeight()}); + rectList.add({x - thickness * .5f, bound.getY(), thickness, bound.getHeight()}); + textBounds[i] = juce::Rectangle(x - uiBase.getFontSize() * 3 - uiBase.getFontSize() * 0.125f, + bound.getBottom() - uiBase.getFontSize() * 2, + uiBase.getFontSize() * 3, uiBase.getFontSize() * 2); } bound = bound.withSizeKeepingCentre(bound.getWidth(), bound.getHeight() - 2 * uiBase.getFontSize()); - for (auto &d:backgroundDBs) { + for (auto &d: backgroundDBs) { const auto y = d * bound.getHeight() + bound.getY(); rectList.add({bound.getX(), y - thickness * .5f, bound.getWidth(), thickness}); } diff --git a/source/panel/curve_panel/background_panel/grid_panel.hpp b/source/panel/curve_panel/background_panel/grid_panel.hpp index f166a682..f578fbab 100644 --- a/source/panel/curve_panel/background_panel/grid_panel.hpp +++ b/source/panel/curve_panel/background_panel/grid_panel.hpp @@ -24,7 +24,7 @@ namespace zlPanel { 0.59836837f, 0.68843178f, 0.80748914f, 0.89755255f, 0.98761596f }; - inline static const std::array backgroundFreqsNames = { + static constexpr std::array backgroundFreqsNames = { "20", "50", "100", "200", "500", "1k", "2k", "5k", "10k", "20k" }; @@ -43,6 +43,7 @@ namespace zlPanel { private: zlInterface::UIBase &uiBase; juce::RectangleList rectList; + std::array, 10> textBounds; }; }