Skip to content

Commit

Permalink
chore: clean up code
Browse files Browse the repository at this point in the history
  • Loading branch information
zsliu98 committed Jun 2, 2024
1 parent fcc9c58 commit 0e6259b
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 32 deletions.
1 change: 0 additions & 1 deletion source/gui/button/click_button/click_button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ namespace zlInterface {
ClickButton::ClickButton(juce::Drawable *image, UIBase &base)
: button("", juce::DrawableButton::ButtonStyle::ImageFitted), lookAndFeel(image, base) {
button.setLookAndFeel(&lookAndFeel);
// setBufferedToImage(true);
addAndMakeVisible(button);
}

Expand Down
2 changes: 1 addition & 1 deletion source/gui/button/compact_button/compact_button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace zlInterface {
CompactButton::CompactButton(const juce::String &labelText, UIBase &base) : uiBase(base), lookAndFeel(uiBase),
animator{} {
// setBufferedToImage(true);
button.setClickingTogglesState(true);
button.setButtonText(labelText);
button.setLookAndFeel(&lookAndFeel);
Expand All @@ -23,6 +22,7 @@ namespace zlInterface {
}

CompactButton::~CompactButton() {
animator.cancelAllAnimations(false);
button.setLookAndFeel(nullptr);
}

Expand Down
1 change: 1 addition & 0 deletions source/gui/combobox/compact_combobox/compact_combobox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace zlInterface {


CompactCombobox::~CompactCombobox() {
animator.cancelAllAnimations(false);
comboBox.setLookAndFeel(nullptr);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
#include "compact_linear_slider.hpp"

namespace zlInterface {
CompactLinearSlider::CompactLinearSlider(const juce::String &labelText, UIBase &base) : uiBase(base),
sliderLookAndFeel(base), nameLookAndFeel(base), textLookAndFeel(base),
slider(base),
animator{} {
CompactLinearSlider::CompactLinearSlider(const juce::String &labelText, UIBase &base)
: uiBase(base),
sliderLookAndFeel(base), nameLookAndFeel(base), textLookAndFeel(base),
slider(base) {
juce::ignoreUnused(uiBase);

slider.setSliderStyle(juce::Slider::LinearHorizontal);
Expand All @@ -23,7 +23,6 @@ namespace zlInterface {
slider.setDoubleClickReturnValue(true, 0.0);
slider.setScrollWheelEnabled(true);
slider.setInterceptsMouseClicks(false, false);
// slider.setBufferedToImage(true);
slider.setLookAndFeel(&sliderLookAndFeel);
addAndMakeVisible(slider);

Expand All @@ -45,9 +44,7 @@ namespace zlInterface {
}

CompactLinearSlider::~CompactLinearSlider() {
slider.setLookAndFeel(nullptr);
label.setLookAndFeel(nullptr);
text.setLookAndFeel(nullptr);
animator.cancelAllAnimations(false);
}

void CompactLinearSlider::resized() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ namespace zlInterface {
SnappingSlider slider;
juce::Label label, text;

std::atomic<float> lrPad = 0, ubPad = 0;

friz::Animator animator;
friz::Animator animator{};
static constexpr int animationId = 1;

std::atomic<float> lrPad = 0, ubPad = 0;

juce::String getDisplayValue(juce::Slider &s);
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
namespace zlInterface {
TwoValueRotarySlider::TwoValueRotarySlider(const juce::String &labelText, UIBase &base)
: uiBase(base),
slider1(base), slider2(base),
slider1LAF(base), slider2LAF(base),
slider1(base), slider2(base),
labelLookAndFeel(base), labelLookAndFeel1(base), labelLookAndFeel2(base), textBoxLAF(base),
animator{} {
for (auto const s: {&slider1, &slider2}) {
Expand Down Expand Up @@ -69,15 +69,11 @@ namespace zlInterface {
}

TwoValueRotarySlider::~TwoValueRotarySlider() {
animator.cancelAllAnimations(false);
slider1.removeListener(this);
slider2.removeListener(this);
label1.removeListener(this);
label2.removeListener(this);
slider1.setLookAndFeel(nullptr);
slider2.setLookAndFeel(nullptr);
for (auto &l: {&label, &label1, &label2}) {
l->setLookAndFeel(nullptr);
}
}

juce::String TwoValueRotarySlider::getDisplayValue(juce::Slider &s) {
Expand Down Expand Up @@ -133,30 +129,24 @@ namespace zlInterface {
void TwoValueRotarySlider::mouseUp(const juce::MouseEvent &event) {
if (!showSlider2.load() || event.mods.isLeftButtonDown()) {
slider1.mouseUp(event);
// label1.setText(getDisplayValue(slider1), juce::dontSendNotification);
} else {
slider2.mouseUp(event);
// label2.setText(getDisplayValue(slider2), juce::dontSendNotification);
}
}

void TwoValueRotarySlider::mouseDown(const juce::MouseEvent &event) {
if (!showSlider2.load() || event.mods.isLeftButtonDown()) {
slider1.mouseDown(event);
// label1.setText(getDisplayValue(slider1), juce::dontSendNotification);
} else {
slider2.mouseDown(event);
// label2.setText(getDisplayValue(slider2), juce::dontSendNotification);
}
}

void TwoValueRotarySlider::mouseDrag(const juce::MouseEvent &event) {
if (!showSlider2.load() || event.mods.isLeftButtonDown()) {
slider1.mouseDrag(event);
// label1.setText(getDisplayValue(slider1), juce::dontSendNotification);
} else {
slider2.mouseDrag(event);
// label2.setText(getDisplayValue(slider2), juce::dontSendNotification);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ namespace zlInterface {

~TwoValueRotarySlider() override;

// void paintOverChildren(juce::Graphics &g) override;

void mouseUp(const juce::MouseEvent &event) override;

void mouseDown(const juce::MouseEvent &event) override;
Expand Down Expand Up @@ -71,15 +69,16 @@ namespace zlInterface {
private:
UIBase &uiBase;

SnappingSlider slider1, slider2;
FirstRotarySliderLookAndFeel slider1LAF;
SecondRotarySliderLookAndFeel slider2LAF;

juce::Label label, label1, label2;
NameLookAndFeel labelLookAndFeel, labelLookAndFeel1, labelLookAndFeel2;
SnappingSlider slider1, slider2;

NameLookAndFeel labelLookAndFeel, labelLookAndFeel1, labelLookAndFeel2;
NameLookAndFeel textBoxLAF;

juce::Label label, label1, label2;

std::atomic<bool> showSlider2 = true, mouseOver, editable;
std::atomic<float> lrPad = 0, ubPad = 0;

Expand Down
3 changes: 1 addition & 2 deletions source/panel/curve_panel/sum_panel/sum_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ namespace zlPanel {
}

for (size_t j = 0; j < useLRMS.size(); ++j) {
paths[j].clear();
if (!useLRMS[j]) {
paths[j].clear();
continue;
}

Expand All @@ -94,7 +94,6 @@ namespace zlPanel {

const auto maxDB = maximumDB.load();
auto y0 = 0.f;
paths[j].clear();
for (size_t i = 0; i < zlIIR::frequencies.size(); ++i) {
const auto x = static_cast<float>(i) / static_cast<float>(zlIIR::frequencies.size() - 1) * bound.
getWidth();
Expand Down

0 comments on commit 0e6259b

Please sign in to comment.