Browse Source

ImageKnob: Only reset to default if one is set; Check timePos

gh-pages
falkTX 9 years ago
parent
commit
fe68e6ac98
4 changed files with 20 additions and 7 deletions
  1. +1
    -0
      dgl/ImageKnob.hpp
  2. +5
    -6
      dgl/src/ImageKnob.cpp
  3. +3
    -0
      distrho/src/DistrhoPlugin.cpp
  4. +11
    -1
      distrho/src/DistrhoPluginInternal.hpp

+ 1
- 0
dgl/ImageKnob.hpp View File

@@ -76,6 +76,7 @@ private:
float fValue;
float fValueDef;
float fValueTmp;
bool fUsingDefault;
bool fUsingLog;
Orientation fOrientation;



+ 5
- 6
dgl/src/ImageKnob.cpp View File

@@ -32,6 +32,7 @@ ImageKnob::ImageKnob(Window& parent, const Image& image, Orientation orientation
fValue(0.5f),
fValueDef(fValue),
fValueTmp(fValue),
fUsingDefault(false),
fUsingLog(false),
fOrientation(orientation),
fRotationAngle(0),
@@ -58,6 +59,7 @@ ImageKnob::ImageKnob(Widget* widget, const Image& image, Orientation orientation
fValue(0.5f),
fValueDef(fValue),
fValueTmp(fValue),
fUsingDefault(false),
fUsingLog(false),
fOrientation(orientation),
fRotationAngle(0),
@@ -84,6 +86,7 @@ ImageKnob::ImageKnob(const ImageKnob& imageKnob)
fValue(imageKnob.fValue),
fValueDef(imageKnob.fValueDef),
fValueTmp(fValue),
fUsingDefault(imageKnob.fUsingDefault),
fUsingLog(imageKnob.fUsingLog),
fOrientation(imageKnob.fOrientation),
fRotationAngle(imageKnob.fRotationAngle),
@@ -131,6 +134,7 @@ float ImageKnob::getValue() const noexcept
void ImageKnob::setDefault(float value) noexcept
{
fValueDef = value;
fUsingDefault = true;
}

void ImageKnob::setRange(float min, float max) noexcept
@@ -162,11 +166,6 @@ void ImageKnob::setRange(float min, float max) noexcept
}
}

if (fValueDef < min)
fValueDef = min;
else if (fValueDef > max)
fValueDef = max;

fMinimum = min;
fMaximum = max;
}
@@ -313,7 +312,7 @@ bool ImageKnob::onMouse(const MouseEvent& ev)
if (! contains(ev.pos))
return false;

if (ev.mod & MODIFIER_SHIFT)
if ((ev.mod & MODIFIER_SHIFT) != 0 && fUsingDefault)
{
setValue(fValueDef);
fValueTmp = fValue;


+ 3
- 0
distrho/src/DistrhoPlugin.cpp View File

@@ -80,6 +80,9 @@ double Plugin::d_getSampleRate() const noexcept
#if DISTRHO_PLUGIN_WANT_TIMEPOS
const TimePos& Plugin::d_getTimePos() const noexcept
{
// timePos outside run() may not be valid
DISTRHO_SAFE_ASSERT(pData->isProcessing);

return pData->timePos;
}
#endif


+ 11
- 1
distrho/src/DistrhoPluginInternal.hpp View File

@@ -36,6 +36,8 @@ extern double d_lastSampleRate;
// Plugin private data

struct Plugin::PrivateData {
bool isProcessing;

uint32_t parameterCount;
Parameter* parameters;

@@ -61,7 +63,8 @@ struct Plugin::PrivateData {
double sampleRate;

PrivateData() noexcept
: parameterCount(0),
: isProcessing(false),
parameterCount(0),
parameters(nullptr),
#if DISTRHO_PLUGIN_WANT_PROGRAMS
programCount(0),
@@ -353,18 +356,25 @@ public:
#if DISTRHO_PLUGIN_IS_SYNTH
void run(const float** const inputs, float** const outputs, const uint32_t frames, const MidiEvent* const midiEvents, const uint32_t midiEventCount)
{
DISTRHO_SAFE_ASSERT_RETURN(fData != nullptr,);
DISTRHO_SAFE_ASSERT_RETURN(fPlugin != nullptr,);

fData->isProcessing = true;
fPlugin->d_run(inputs, outputs, frames, midiEvents, midiEventCount);
fData->isProcessing = false;
}
#else
void run(const float** const inputs, float** const outputs, const uint32_t frames)
{
DISTRHO_SAFE_ASSERT_RETURN(fData != nullptr,);
DISTRHO_SAFE_ASSERT_RETURN(fPlugin != nullptr,);

fData->isProcessing = true;
fPlugin->d_run(inputs, outputs, frames);
fData->isProcessing = false;
}
#endif

// -------------------------------------------------------------------

void setBufferSize(const uint32_t bufferSize, bool doCallback = false)


Loading…
Cancel
Save