2017-01-23 10:15:08 +00:00
|
|
|
|
/*
|
|
|
|
|
==============================================================================
|
|
|
|
|
This file is part of Obxd synthesizer.
|
|
|
|
|
|
2020-04-19 13:43:40 +00:00
|
|
|
|
Copyright <EFBFBD> 2013-2014 Filatov Vadim
|
2017-01-23 10:15:08 +00:00
|
|
|
|
|
|
|
|
|
Contact author via email :
|
|
|
|
|
justdat_@_e1.ru
|
|
|
|
|
|
|
|
|
|
This file may be licensed under the terms of of the
|
|
|
|
|
GNU General Public License Version 2 (the ``GPL'').
|
|
|
|
|
|
|
|
|
|
Software distributed under the License is distributed
|
|
|
|
|
on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
|
|
|
|
|
express or implied. See the GPL for the specific language
|
|
|
|
|
governing rights and limitations.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GPL along with this
|
|
|
|
|
program. If not, go to http://www.gnu.org/licenses/gpl.html
|
|
|
|
|
or write to the Free Software Foundation, Inc.,
|
|
|
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
==============================================================================
|
|
|
|
|
*/
|
|
|
|
|
#pragma once
|
|
|
|
|
#include "../Source/Engine/SynthEngine.h"
|
2021-09-01 08:38:39 +00:00
|
|
|
|
#include "../Components/ScaleComponent.h"
|
|
|
|
|
class ObxdAudioProcessor;
|
2020-04-19 13:43:40 +00:00
|
|
|
|
|
2021-09-01 08:38:39 +00:00
|
|
|
|
class TooglableButton : public ImageButton, public ScalableComponent
|
2017-01-23 10:15:08 +00:00
|
|
|
|
{
|
2021-09-01 08:38:39 +00:00
|
|
|
|
juce::String img_name;
|
2017-01-23 10:15:08 +00:00
|
|
|
|
public:
|
2021-09-01 08:38:39 +00:00
|
|
|
|
TooglableButton (juce::String name, ObxdAudioProcessor *owner) : ImageButton(),ScalableComponent(owner), img_name(name)
|
2017-01-23 10:15:08 +00:00
|
|
|
|
{
|
|
|
|
|
//this->setImages
|
2021-09-01 08:38:39 +00:00
|
|
|
|
//kni = k;
|
|
|
|
|
scaleFactorChanged();
|
2020-08-10 15:38:31 +00:00
|
|
|
|
//toogled = false;
|
2017-01-23 10:15:08 +00:00
|
|
|
|
width = kni.getWidth();
|
|
|
|
|
height = kni.getHeight();
|
2020-04-19 13:43:40 +00:00
|
|
|
|
w2 = width;
|
2017-01-23 10:15:08 +00:00
|
|
|
|
h2 = height / 2;
|
2020-04-19 13:43:40 +00:00
|
|
|
|
this->setClickingTogglesState (true);
|
2017-01-23 10:15:08 +00:00
|
|
|
|
}
|
2021-09-01 08:38:39 +00:00
|
|
|
|
void scaleFactorChanged() override
|
|
|
|
|
{
|
|
|
|
|
kni = getScaledImageFromCache(img_name, getScaleFactor(), getIsHighResolutionDisplay());
|
|
|
|
|
/*
|
|
|
|
|
backgroundImage =
|
|
|
|
|
allImage.getClippedImage(Rectangle<int>(0,
|
|
|
|
|
allImage.getHeight() / 2,
|
|
|
|
|
allImage.getWidth(),
|
|
|
|
|
allImage.getHeight() / 2));
|
|
|
|
|
*/
|
|
|
|
|
repaint();
|
|
|
|
|
}
|
2020-04-21 13:08:05 +00:00
|
|
|
|
~TooglableButton() override{
|
|
|
|
|
|
|
|
|
|
};
|
2020-04-19 13:43:40 +00:00
|
|
|
|
// Source: https://git.iem.at/audioplugins/IEMPluginSuite/-/blob/master/resources/customComponents/ReverseSlider.h
|
|
|
|
|
public:
|
|
|
|
|
class ToggleAttachment : public juce::AudioProcessorValueTreeState::ButtonAttachment
|
|
|
|
|
{
|
2020-04-23 17:10:28 +00:00
|
|
|
|
RangedAudioParameter* parameter = nullptr;
|
|
|
|
|
TooglableButton* buttonToControl = nullptr;
|
2020-04-19 13:43:40 +00:00
|
|
|
|
public:
|
|
|
|
|
ToggleAttachment (juce::AudioProcessorValueTreeState& stateToControl,
|
|
|
|
|
const juce::String& parameterID,
|
2020-04-23 17:10:28 +00:00
|
|
|
|
TooglableButton& buttonToControl) : AudioProcessorValueTreeState::ButtonAttachment (stateToControl, parameterID, buttonToControl), buttonToControl(&buttonToControl)
|
2020-04-19 13:43:40 +00:00
|
|
|
|
{
|
2020-04-23 17:10:28 +00:00
|
|
|
|
parameter = stateToControl.getParameter (parameterID);
|
2020-08-10 15:38:31 +00:00
|
|
|
|
//buttonToControl.setParameter (parameter);
|
2020-04-19 13:43:40 +00:00
|
|
|
|
}
|
2020-04-23 17:10:28 +00:00
|
|
|
|
/*
|
2020-04-19 13:43:40 +00:00
|
|
|
|
ToggleAttachment (juce::AudioProcessorValueTreeState& stateToControl,
|
|
|
|
|
const juce::String& parameterID,
|
|
|
|
|
Button& buttonToControl) : AudioProcessorValueTreeState::ButtonAttachment (stateToControl, parameterID, buttonToControl)
|
|
|
|
|
{
|
2020-04-23 17:10:28 +00:00
|
|
|
|
}*/
|
|
|
|
|
void updateToSlider(){
|
|
|
|
|
float val = parameter->getValue();
|
|
|
|
|
//buttonToControl->setValue(parameter->convertFrom0to1(val0to1), NotificationType::dontSendNotification);
|
2020-08-10 15:38:31 +00:00
|
|
|
|
DBG("Toggle Parameter: " << parameter->name << " Val: " << val);
|
|
|
|
|
buttonToControl->setToggleState(val, NotificationType::dontSendNotification);
|
2020-04-19 13:43:40 +00:00
|
|
|
|
}
|
|
|
|
|
virtual ~ToggleAttachment() = default;
|
|
|
|
|
};
|
2020-08-10 15:38:31 +00:00
|
|
|
|
/*
|
2020-04-19 13:43:40 +00:00
|
|
|
|
void setParameter (const AudioProcessorParameter* p)
|
|
|
|
|
{
|
|
|
|
|
if (parameter == p)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
parameter = p;
|
|
|
|
|
repaint();
|
2020-08-10 15:38:31 +00:00
|
|
|
|
}*/
|
|
|
|
|
/*
|
2020-04-19 13:43:40 +00:00
|
|
|
|
void clicked() override
|
2017-01-23 10:15:08 +00:00
|
|
|
|
{
|
2020-04-19 13:43:40 +00:00
|
|
|
|
toogled = ! toogled;
|
2017-01-23 10:15:08 +00:00
|
|
|
|
//this->setColour(1,Colours::blue);
|
|
|
|
|
//if(toogled)
|
|
|
|
|
// this->setColour(TextButton::ColourIds::buttonColourId,Colours::lightgreen);
|
|
|
|
|
//else
|
|
|
|
|
// this->removeColour(TextButton::ColourIds::buttonColourId);
|
|
|
|
|
//this->setColour(DrawableButton::ColourIds::backgroundColourId,Colours::lightpink);
|
|
|
|
|
Button::clicked();
|
|
|
|
|
|
2020-08-10 15:38:31 +00:00
|
|
|
|
};*/
|
2020-04-19 13:43:40 +00:00
|
|
|
|
|
|
|
|
|
void paintButton (Graphics& g, bool isMouseOverButton, bool isButtonDown) override
|
2017-01-23 10:15:08 +00:00
|
|
|
|
{
|
2020-04-19 13:43:40 +00:00
|
|
|
|
int offset = 0;
|
|
|
|
|
|
2020-08-10 15:38:31 +00:00
|
|
|
|
//if (toogled)
|
|
|
|
|
if (getToggleState())
|
2017-01-23 10:15:08 +00:00
|
|
|
|
{
|
|
|
|
|
offset = 1;
|
|
|
|
|
}
|
2020-05-22 11:34:09 +00:00
|
|
|
|
|
2021-09-01 08:38:39 +00:00
|
|
|
|
g.drawImage(kni, 0, 0, getWidth(), getHeight(), 0, offset * h2 * getScaleInt() , w2 * getScaleInt(), h2 * getScaleInt());
|
2017-01-23 10:15:08 +00:00
|
|
|
|
}
|
2020-08-10 15:38:31 +00:00
|
|
|
|
/*
|
2020-04-19 13:43:40 +00:00
|
|
|
|
void setValue (float state, int notify)
|
2017-01-23 10:15:08 +00:00
|
|
|
|
{
|
2020-04-19 13:43:40 +00:00
|
|
|
|
if (state > 0.5)
|
|
|
|
|
toogled = true;
|
2017-01-23 10:15:08 +00:00
|
|
|
|
else toogled = false;
|
2020-04-19 13:43:40 +00:00
|
|
|
|
|
2017-01-23 10:15:08 +00:00
|
|
|
|
repaint();
|
2020-08-10 15:38:31 +00:00
|
|
|
|
}*/
|
2020-04-19 13:43:40 +00:00
|
|
|
|
|
2020-08-10 15:38:31 +00:00
|
|
|
|
/*float getValue()
|
2017-01-23 10:15:08 +00:00
|
|
|
|
{
|
2020-04-19 13:43:40 +00:00
|
|
|
|
if (toogled)
|
|
|
|
|
return 1;
|
2017-01-23 10:15:08 +00:00
|
|
|
|
else return 0;
|
2020-08-10 15:38:31 +00:00
|
|
|
|
}*/
|
2017-01-23 10:15:08 +00:00
|
|
|
|
//void paint(Graphics& g)
|
|
|
|
|
//{
|
|
|
|
|
// g.drawImageTransformed(kni,AffineTransform::rotation(((getValue() - getMinimum())/(getMaximum() - getMinimum()))*float_Pi - float_Pi*2));
|
|
|
|
|
//}
|
2020-04-19 13:43:40 +00:00
|
|
|
|
|
2020-08-10 15:38:31 +00:00
|
|
|
|
//bool toogled;
|
2020-04-19 13:43:40 +00:00
|
|
|
|
|
2017-01-23 10:15:08 +00:00
|
|
|
|
private:
|
|
|
|
|
Image kni;
|
2020-04-19 13:43:40 +00:00
|
|
|
|
int width, height, w2, h2;
|
2020-08-10 15:38:31 +00:00
|
|
|
|
//const AudioProcessorParameter* parameter;
|
2020-04-19 13:43:40 +00:00
|
|
|
|
};
|