Skip to content

Commit

Permalink
resize bug fixed
Browse files Browse the repository at this point in the history
First resize event is now fired after display has been added to stage.
  • Loading branch information
blancoberg committed Sep 26, 2024
1 parent c5e0dcb commit 6775590
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/surge-xt/gui/widgets/OscillatorWaveformDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1295,14 +1295,16 @@ struct WaveTable3DEditor : public juce::Component,
float samplesCached[128][128];
float morphValue = 0.0;

int currentBreakingPoint = -1;

union ParamCached
{
int i;
float f;
};

ParamCached paramCached[7];
float zoomFactor = 1.0;
float zoomFactor = -1.0;
bool hasResized = false;

/* Values exported from
Expand Down Expand Up @@ -1332,7 +1334,6 @@ struct WaveTable3DEditor : public juce::Component,
: parent(pD), storage(s), oscdata(osc), sge(ed)
{
clearSampleCache();
resized();
}

void cacheParams()
Expand Down Expand Up @@ -1384,12 +1385,12 @@ struct WaveTable3DEditor : public juce::Component,
w = getWidth();
h = getHeight();

wf = (float)w * 2.f;
hf = (float)h * 2.f;
wf = (float)w * zoomFactor * 2;
hf = (float)h * zoomFactor * 2;

backingImage = nullptr;
backingImage = std::make_unique<juce::Image>(
juce::Image::PixelFormat::ARGB, (int)wf * zoomFactor, (int)(hf)*zoomFactor, true);
backingImage = std::make_unique<juce::Image>(juce::Image::PixelFormat::ARGB, (int)wf,
(int)(hf), true);
}
}

Expand Down Expand Up @@ -1527,8 +1528,8 @@ struct WaveTable3DEditor : public juce::Component,

osc->processSamplesForDisplay(samples, rendered_samples, processForReal);

float xScaled = wf * scale * zoomFactor;
float YScaled = hf * scale * zoomFactor;
float xScaled = wf * scale;
float YScaled = hf * scale;

float skewCalc = skew;

Expand Down Expand Up @@ -1982,6 +1983,8 @@ void OscillatorWaveformDisplay::showCustomEditor()
auto b = getLocalBounds().withTrimmedBottom(wtbheight);
customEditor->setBounds(b);
addAndMakeVisible(*customEditor);
customEditor->resized(); // Resize needs to happen after it has been added to the scene.
// Otherwise bounds will return 0
repaint();

customEditorAccOverlay->setTitle("Close Custom Editor");
Expand Down

0 comments on commit 6775590

Please sign in to comment.