Browse Source

Fix recursive resizing in certain DAWs

pull/83/head
falkTX 6 years ago
parent
commit
b526e381cc
2 changed files with 14 additions and 4 deletions
  1. +3
    -0
      distrho/src/DistrhoUI.cpp
  2. +11
    -4
      distrho/src/DistrhoUIInternal.hpp

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

@@ -165,6 +165,9 @@ void UI::uiReshape(uint width, uint height)

void UI::onResize(const ResizeEvent& ev)
{
if (pData->resizeInProgress)
return;

pData->setSizeCallback(ev.size.getWidth(), ev.size.getHeight());
}
#endif


+ 11
- 4
distrho/src/DistrhoUIInternal.hpp View File

@@ -63,6 +63,7 @@ struct UI::PrivateData {
// UI
const bool userResizable;
bool automaticallyScale;
bool resizeInProgress;
uint minWidth;
uint minHeight;

@@ -82,6 +83,7 @@ struct UI::PrivateData {
#endif
userResizable(resizable),
automaticallyScale(false),
resizeInProgress(false),
minWidth(0),
minHeight(0),
callbacksPtr(nullptr),
@@ -191,16 +193,21 @@ protected:
void onReshape(uint width, uint height) override
{
DISTRHO_SAFE_ASSERT_RETURN(fUI != nullptr,);
DISTRHO_SAFE_ASSERT_RETURN(fUI->pData != nullptr,);

if (fUI->pData->automaticallyScale)
UI::PrivateData* const pData = fUI->pData;
DISTRHO_SAFE_ASSERT_RETURN(pData != nullptr,);

if (pData->automaticallyScale)
{
const double scaleHorizontal = static_cast<double>(width) / static_cast<double>(fUI->pData->minWidth);
const double scaleVertical = static_cast<double>(height) / static_cast<double>(fUI->pData->minHeight);
const double scaleHorizontal = static_cast<double>(width) / static_cast<double>(pData->minWidth);
const double scaleVertical = static_cast<double>(height) / static_cast<double>(pData->minHeight);
setScaling(scaleHorizontal < scaleVertical ? scaleHorizontal : scaleVertical);
}

pData->resizeInProgress = true;
fUI->setSize(width, height);
pData->resizeInProgress = false;

fUI->uiReshape(width, height);
fIsReady = true;
}


Loading…
Cancel
Save