Browse Source

SoulForce: Make the footswitch button work like in the orig plugin

master
falkTX 10 years ago
parent
commit
7def1387bd
2 changed files with 47 additions and 20 deletions
  1. +39
    -18
      plugins/SoulForce/DistrhoUISoulForce.cpp
  2. +8
    -2
      plugins/SoulForce/DistrhoUISoulForce.hpp

+ 39
- 18
plugins/SoulForce/DistrhoUISoulForce.cpp View File

@@ -35,7 +35,8 @@ DistrhoUISoulForce::DistrhoUISoulForce()
: UI(Art::backgroundWidth, Art::backgroundHeight),
fImgBackground(Art::backgroundData, Art::backgroundWidth, Art::backgroundHeight, GL_BGR),
fImgLedOff(Art::led_offData, Art::led_offWidth, Art::led_offHeight, GL_BGR),
fImgLedOn(Art::led_onData, Art::led_onWidth, Art::led_onHeight, GL_BGR)
fImgLedOn(Art::led_onData, Art::led_onWidth, Art::led_onHeight, GL_BGR),
fFootDown(true)
{
// knobs
fKnobShape = new ImageKnob(this,
@@ -64,12 +65,14 @@ DistrhoUISoulForce::DistrhoUISoulForce()
fSwitchSource->setAbsolutePos(116, 191);
fSwitchSource->setCallback(this);

fSwitchFoot = new ImageSwitch(this,
// buttons
fButtonFoot = new ImageButton(this,
Image(Art::button_upData, Art::button_upWidth, Art::button_upHeight, GL_BGR),
Image(Art::button_upData, Art::button_upWidth, Art::button_upHeight, GL_BGR),
Image(Art::button_downData, Art::button_downWidth, Art::button_downHeight, GL_BGR));
fSwitchFoot->setId(DistrhoPluginSoulForce::kParameterFootswitch);
fSwitchFoot->setAbsolutePos(125, 282);
fSwitchFoot->setCallback(this);
fButtonFoot->setId(DistrhoPluginSoulForce::kParameterFootswitch);
fButtonFoot->setAbsolutePos(125, 282);
fButtonFoot->setCallback(this);

// set initial values
d_programChanged(0);
@@ -92,7 +95,11 @@ void DistrhoUISoulForce::d_parameterChanged(uint32_t index, float value)
fSwitchSource->setDown(value > 0.5f);
break;
case DistrhoPluginSoulForce::kParameterFootswitch:
fSwitchFoot->setDown(value > 0.5f);
if (fFootDown != (value > 0.5f))
{
fFootDown = !fFootDown;
repaint();
}
break;
}
}
@@ -105,57 +112,55 @@ void DistrhoUISoulForce::d_programChanged(uint32_t index)
fKnobShape->setValue(0.5f);
fKnobFBack->setValue(0.0f);
fSwitchSource->setDown(false);
fSwitchFoot->setDown(true);
break;
case 1:
fKnobShape->setValue(0.4f);
fKnobFBack->setValue(0.0f);
fSwitchSource->setDown(false);
fSwitchFoot->setDown(true);
break;
case 2:
fKnobShape->setValue(1.0f);
fKnobFBack->setValue(0.0f);
fSwitchSource->setDown(false);
fSwitchFoot->setDown(true);
break;
case 3:
fKnobShape->setValue(0.5f);
fKnobFBack->setValue(1.0f);
fSwitchSource->setDown(false);
fSwitchFoot->setDown(true);
break;
case 4:
fKnobShape->setValue(0.0f);
fKnobFBack->setValue(1.0f);
fSwitchSource->setDown(false);
fSwitchFoot->setDown(true);
break;
case 5:
fKnobShape->setValue(0.5f);
fKnobFBack->setValue(1.0f);
fSwitchSource->setDown(true);
fSwitchFoot->setDown(true);
break;
case 6:
fKnobShape->setValue(0.0f);
fKnobFBack->setValue(1.0f);
fSwitchSource->setDown(true);
fSwitchFoot->setDown(true);
break;
case 7:
fKnobShape->setValue(0.3f);
fKnobFBack->setValue(0.5f);
fSwitchSource->setDown(false);
fSwitchFoot->setDown(true);
break;
case 8:
fKnobShape->setValue(0.3f);
fKnobFBack->setValue(0.5f);
fSwitchSource->setDown(true);
fSwitchFoot->setDown(true);
break;
}

// always true
if (! fFootDown)
{
fFootDown = true;
repaint();
}
}

// -----------------------------------------------------------------------
@@ -176,9 +181,25 @@ void DistrhoUISoulForce::imageKnobValueChanged(ImageKnob* knob, float value)
d_setParameterValue(knob->getId(), value);
}

void DistrhoUISoulForce::imageSwitchClicked(ImageSwitch* button, bool down)
void DistrhoUISoulForce::imageButtonClicked(ImageButton* imageButton, int button)
{
const uint buttonId(imageButton->getId());

if (buttonId != DistrhoPluginSoulForce::kParameterFootswitch)
return;

fFootDown = !fFootDown;

d_editParameter(buttonId, true);
d_setParameterValue(buttonId, fFootDown ? 1.0f : 0.0f);
d_editParameter(buttonId, false);

repaint();
}

void DistrhoUISoulForce::imageSwitchClicked(ImageSwitch* imageSwitch, bool down)
{
const uint buttonId(button->getId());
const uint buttonId(imageSwitch->getId());

d_editParameter(buttonId, true);
d_setParameterValue(buttonId, down ? 1.0f : 0.0f);
@@ -189,7 +210,7 @@ void DistrhoUISoulForce::onDisplay()
{
fImgBackground.draw();

if (fSwitchFoot->isDown())
if (fFootDown)
fImgLedOn.drawAt(123, 240);
else
fImgLedOff.drawAt(123, 240);


+ 8
- 2
plugins/SoulForce/DistrhoUISoulForce.hpp View File

@@ -27,12 +27,14 @@

#include "DistrhoUI.hpp"

#include "ImageButton.hpp"
#include "ImageKnob.hpp"
#include "ImageSwitch.hpp"

#include "DistrhoArtworkSoulForce.hpp"

using DGL::Image;
using DGL::ImageButton;
using DGL::ImageKnob;
using DGL::ImageSwitch;

@@ -41,6 +43,7 @@ START_NAMESPACE_DISTRHO
// -----------------------------------------------------------------------

class DistrhoUISoulForce : public UI,
public ImageButton::Callback,
public ImageKnob::Callback,
public ImageSwitch::Callback
{
@@ -61,14 +64,17 @@ protected:
void imageKnobDragFinished(ImageKnob* knob) override;
void imageKnobValueChanged(ImageKnob* knob, float value) override;

void imageSwitchClicked(ImageSwitch* imageButton, bool down) override;
void imageButtonClicked(ImageButton* imageButton, int button) override;
void imageSwitchClicked(ImageSwitch* imageSwitch, bool down) override;

void onDisplay() override;

private:
Image fImgBackground, fImgLedOff, fImgLedOn;
ScopedPointer<ImageKnob> fKnobShape, fKnobFBack;
ScopedPointer<ImageSwitch> fSwitchSource, fSwitchFoot;
ScopedPointer<ImageSwitch> fSwitchSource;
ScopedPointer<ImageButton> fButtonFoot;
bool fFootDown;

DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(DistrhoUISoulForce)
};


Loading…
Cancel
Save