Skip to content

Commit

Permalink
feat(match label): add dark background
Browse files Browse the repository at this point in the history
zsliu98 committed Jan 24, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 0f17b86 commit 98300a5
Showing 4 changed files with 72 additions and 12 deletions.
15 changes: 5 additions & 10 deletions source/panel/curve_panel/match_panel/match_analyzer_panel.cpp
Original file line number Diff line number Diff line change
@@ -15,16 +15,11 @@ namespace zlPanel {
zlInterface::UIBase &base)
: analyzerRef(analyzer), parametersNARef(parametersNA), uiBase(base),
lowDragger(base), highDragger(base), shiftDragger(base),
labelLAF(uiBase) {
matchLabel(base) {
parametersNARef.addParameterListener(zlState::maximumDB::ID, this);
parameterChanged(zlState::maximumDB::ID, parametersNARef.getRawParameterValue(zlState::maximumDB::ID)->load());
setInterceptsMouseClicks(true, true);
uiBase.getValueTree().addListener(this);
runningLabel.setText("Running", juce::dontSendNotification);
runningLabel.setJustificationType(juce::Justification::centred);
labelLAF.setFontScale(5.f);
runningLabel.setLookAndFeel(&labelLAF);
addChildComponent(runningLabel); {
uiBase.getValueTree().addListener(this); {
lowDragger.getLAF().setDraggerShape(zlInterface::DraggerLookAndFeel::DraggerShape::rightArrow);
lowDragger.setYPortion(.5f);
lowDragger.setXYEnabled(true, false);
@@ -46,6 +41,7 @@ namespace zlPanel {
d->addListener(this);
addAndMakeVisible(d);
}
addChildComponent(matchLabel);
lookAndFeelChanged();
visibilityChanged();
}
@@ -99,8 +95,7 @@ namespace zlPanel {
rightCorner.store({bound.getRight() * 1.1f, bound.getBottom() * 1.1f});
atomicBound.store(bound);
dBScale.store((1.f + uiBase.getFontSize() * 2.f / bound.getHeight()) * 2.f);
runningLabel.setBounds(bound.withSizeKeepingCentre(
bound.getWidth() * .5f, uiBase.getFontSize() * 5.f).toNearestInt());
matchLabel.setBounds(getLocalBounds());
lowDragger.setBounds(getLocalBounds());
highDragger.setBounds(getLocalBounds());
shiftDragger.setBounds(getLocalBounds());
@@ -138,7 +133,7 @@ namespace zlPanel {
backgroundAlpha = f ? .2f : .5f;
showAverage = !f;
} else if (zlInterface::UIBase::isProperty(zlInterface::settingIdx::matchFitRunning, property)) {
runningLabel.setVisible(static_cast<bool>(uiBase.getProperty(zlInterface::settingIdx::matchFitRunning)));
matchLabel.setVisible(static_cast<bool>(uiBase.getProperty(zlInterface::settingIdx::matchFitRunning)));
}
}

4 changes: 2 additions & 2 deletions source/panel/curve_panel/match_panel/match_analyzer_panel.hpp
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@
#include "../../../dsp/dsp.hpp"
#include "../../../gui/gui.hpp"
#include "../helpers.hpp"
#include "match_label.hpp"

namespace zlPanel {
class MatchAnalyzerPanel final : public juce::Component,
@@ -57,8 +58,7 @@ namespace zlPanel {
float currentMaximumDB{zlState::maximumDB::dBs[static_cast<size_t>(zlState::maximumDB::defaultI)]};
std::atomic<float> maximumDB{zlState::maximumDB::dBs[static_cast<size_t>(zlState::maximumDB::defaultI)]};
zlInterface::Dragger lowDragger, highDragger, shiftDragger;
zlInterface::NameLookAndFeel labelLAF;
juce::Label runningLabel;
MatchLabel matchLabel;
static constexpr auto scale = 1.5f;
size_t preDrawIdx{0};
float preDrawDB{0.f};
32 changes: 32 additions & 0 deletions source/panel/curve_panel/match_panel/match_label.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (C) 2025 - zsliu98
// This file is part of ZLEqualizer
//
// ZLEqualizer is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License Version 3 as published by the Free Software Foundation.
//
// ZLEqualizer is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License along with ZLEqualizer. If not, see <https://www.gnu.org/licenses/>.

#include "match_label.hpp"

namespace zlPanel {
MatchLabel::MatchLabel(zlInterface::UIBase &base)
: uiBase(base), labelLAF(base) {
runningLabel.setText("Running", juce::dontSendNotification);
runningLabel.setJustificationType(juce::Justification::centred);
labelLAF.setFontScale(5.f);
runningLabel.setLookAndFeel(&labelLAF);
addAndMakeVisible(runningLabel);
setBufferedToImage(true);
}

void MatchLabel::paint(juce::Graphics &g) {
g.fillAll(uiBase.getColourByIdx(zlInterface::backgroundColour).withAlpha(.75f));
}

void MatchLabel::resized() {
const auto bound = getLocalBounds().toFloat();
runningLabel.setBounds(bound.withSizeKeepingCentre(
bound.getWidth() * .5f, uiBase.getFontSize() * 5.f).toNearestInt());
}
} // zlPanel
33 changes: 33 additions & 0 deletions source/panel/curve_panel/match_panel/match_label.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (C) 2025 - zsliu98
// This file is part of ZLEqualizer
//
// ZLEqualizer is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License Version 3 as published by the Free Software Foundation.
//
// ZLEqualizer is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License along with ZLEqualizer. If not, see <https://www.gnu.org/licenses/>.

#ifndef ZLPANEL_MATCH_LABEL_HPP
#define ZLPANEL_MATCH_LABEL_HPP

#include "../../../gui/gui.hpp"

namespace zlPanel {

class MatchLabel : public juce::Component {
public:
explicit MatchLabel(zlInterface::UIBase &base);

void paint(juce::Graphics &g) override;

void resized() override;

private:
zlInterface::UIBase &uiBase;
zlInterface::NameLookAndFeel labelLAF;
juce::Label runningLabel;
};

} // zlPanel

#endif //ZLPANEL_MATCH_LABEL_HPP

0 comments on commit 98300a5

Please sign in to comment.