Skip to content

Commit

Permalink
Remove CEffectLabel; Introduce Surge::Widgets::EffectLabel (surge-syn…
Browse files Browse the repository at this point in the history
  • Loading branch information
baconpaul authored May 23, 2021
1 parent 8998baf commit 3df7337
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 53 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,6 @@ set(SURGE_GENERATED_SOURCES

set(SURGE_GUI_SOURCES
src/gui/CAboutBox.cpp
src/gui/CEffectLabel.h
src/gui/CEffectSettings.cpp
src/gui/CHSwitch2.cpp
src/gui/CLFOGui.cpp
Expand Down
2 changes: 2 additions & 0 deletions libs/escape-from-vstgui/include/efvg/escape_from_vstgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,8 @@ struct CColor
return red == that.red && green == that.green && blue == that.blue && alpha == that.alpha;
}
juce::Colour asJuceColour() const { return juce::Colour(red, green, blue, alpha); }

operator juce::Colour() const { return asJuceColour(); }
uint8_t red, green, blue, alpha;
};

Expand Down
47 changes: 0 additions & 47 deletions src/gui/CEffectLabel.h

This file was deleted.

18 changes: 13 additions & 5 deletions src/gui/SurgeGUIEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include "CEffectSettings.h"
#include "CSurgeVuMeter.h"
#include "CMenuAsSlider.h"
#include "CEffectLabel.h"
#include "CTextButtonWithHover.h"
#include "CAboutBox.h"
#include "SurgeBitmaps.h"
Expand All @@ -43,6 +42,7 @@
#include "ModulationEditor.h"
#include "LuaEditors.h"

#include "widgets/EffectLabel.h"
#include "widgets/Switch.h"
#include "widgets/VerticalLabel.h"

Expand Down Expand Up @@ -1246,10 +1246,18 @@ void SurgeGUIEditor::openOrRecreateEditor()
vr.right += 5;
vr.offset(5, -12);
vr.offset(0, yofs * synth->fx[current_fx]->group_label_ypos(i));
CEffectLabel *lb = new CEffectLabel(vr);
lb->setLabel(label);
lb->setSkin(currentSkin, bitmapStore);
frame->addView(lb);
if (!effectLabels[i])
{
effectLabels[i] = std::make_unique<Surge::Widgets::EffectLabel>();
}
effectLabels[i]->setBounds(vr.asJuceIntRect());
effectLabels[i]->setLabel(label);
effectLabels[i]->setSkin(currentSkin, bitmapStore);
frame->juceComponent()->addAndMakeVisible(*effectLabels[i]);
}
else
{
effectLabels[i].reset(nullptr);
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/gui/SurgeGUIEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ namespace Widgets
{
struct Switch;
struct VerticalLabel;
struct EffectLabel;
} // namespace Widgets
} // namespace Surge

Expand Down Expand Up @@ -478,6 +479,8 @@ class SurgeGUIEditor : public EditorType,
/*
* This is the JUCE component management
*/
std::array<std::unique_ptr<Surge::Widgets::EffectLabel>, 15> effectLabels;

std::unordered_map<Surge::GUI::Skin::Control::sessionid_t, std::unique_ptr<juce::Component>>
juceSkinComponents;
template <typename T>
Expand Down
54 changes: 54 additions & 0 deletions src/gui/widgets/EffectLabel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
** Surge Synthesizer is Free and Open Source Software
**
** Surge is made available under the Gnu General Public License, v3.0
** https://www.gnu.org/licenses/gpl-3.0.en.html
**
** Copyright 2004-2021 by various individuals as described by the Git transaction log
**
** All source at: https://github.com/surge-synthesizer/surge.git
**
** Surge was a commercial product from 2004-2018, with Copyright and ownership
** in that period held by Claes Johanson at Vember Audio. Claes made Surge
** open source in September 2018.
*/

#ifndef SURGE_XT_EFFECTLABEL_H
#define SURGE_XT_EFFECTLABEL_H

#include <JuceHeader.h>
#include "SkinSupport.h"
#include "RuntimeFont.h"
#include <string>

namespace Surge
{
namespace Widgets
{
struct EffectLabel : public juce::Component, public Surge::GUI::SkinConsumingComponent
{
EffectLabel() = default;
~EffectLabel() = default;

std::string label;
void setLabel(const std::string &l)
{
label = l;
repaint();
}

void paint(juce::Graphics &g) override
{
auto lb = getLocalBounds().withTrimmedTop(getHeight() - 2);
g.setColour(skin->getColor(Colors::Effect::Label::Separator));
g.fillRect(lb);

g.setColour(skin->getColor(Colors::Effect::Label::Text));
g.setFont(Surge::GUI::getFontManager()->displayFont);
g.drawText(label, getLocalBounds(), juce::Justification::centredLeft);
}
};
} // namespace Widgets
} // namespace Surge

#endif // SURGE_XT_EFFECTLABEL_H

0 comments on commit 3df7337

Please sign in to comment.