Browse Source

Improve handling of standalone resizing

Signed-off-by: falkTX <falktx@falktx.com>
main
falkTX 1 year ago
parent
commit
7767a93dd8
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
4 changed files with 91 additions and 11 deletions
  1. +1
    -1
      dpf
  2. +64
    -7
      plugins/Common/IldaeilUI.cpp
  3. +25
    -3
      plugins/Common/PluginHostWindow.cpp
  4. +1
    -0
      plugins/Common/PluginHostWindow.hpp

+ 1
- 1
dpf

@@ -1 +1 @@
Subproject commit 08ef3c258695279b17d1e485e7b4577e7e8242c4
Subproject commit 11ea617b17d9daef7c4194baf997c83bf921c905

+ 64
- 7
plugins/Common/IldaeilUI.cpp View File

@@ -68,8 +68,6 @@ class IldaeilUI : public UI,
static constexpr const uint kGenericWidth = 380;
static constexpr const uint kGenericHeight = 400;
static constexpr const uint kButtonHeight = 20;
static constexpr const uint kMinWidth = 120;
static constexpr const uint kMinHeight = 120;

struct PluginInfoCache {
BinaryType btype;
@@ -188,7 +186,10 @@ class IldaeilUI : public UI,
char fPluginSearchString[0xff];

String fPopupError, fPluginFilename, fDiscoveryTool;
Size<uint> fNextSize;
Size<uint> fCurrentConstraintSize, fLastSize, fNextSize;
bool fIgnoreNextHostWindowResize;
bool fShowingHostWindow;
bool fUpdateGeometryConstraints;

struct RunnerData {
bool needsReinit;
@@ -233,6 +234,9 @@ public:
fCurrentPluginInfo(),
fPluginSearchActive(false),
fPluginSearchFirstShow(false),
fIgnoreNextHostWindowResize(false),
fShowingHostWindow(false),
fUpdateGeometryConstraints(false),
fRunnerData()
{
const double scaleFactor = getScaleFactor();
@@ -256,13 +260,13 @@ public:

if (d_isNotEqual(scaleFactor, 1.0))
{
setGeometryConstraints(kMinWidth * scaleFactor, kMinHeight * scaleFactor);
setGeometryConstraints(kInitialWidth * scaleFactor, kInitialWidth * scaleFactor);
setSize(kInitialWidth * scaleFactor, kInitialHeight * scaleFactor);
fPluginHostWindow.setOffset(0, kButtonHeight * scaleFactor + paddingY);
}
else
{
setGeometryConstraints(kMinWidth, kMinHeight);
setGeometryConstraints(kInitialWidth, kInitialWidth);
fPluginHostWindow.setOffset(0, kButtonHeight + paddingY);
}

@@ -405,6 +409,9 @@ public:
fPluginHasEmbedUI = true;
fPluginHasFileOpen = false;

fIgnoreNextHostWindowResize = false;
fShowingHostWindow = true;

carla_embed_custom_ui(handle, fPluginId, fPluginHostWindow.attachAndGetWindowHandle());
}
else
@@ -448,6 +455,8 @@ public:
const double scaleFactor = getScaleFactor();
fNextSize = Size<uint>(kGenericWidth * scaleFactor,
(kGenericHeight + ImGui::GetStyle().WindowPadding.y) * scaleFactor);
fLastSize = Size<uint>();
fUpdateGeometryConstraints = true;
#endif
}

@@ -659,10 +668,48 @@ public:
protected:
void pluginWindowResized(const uint width, const uint height) override
{
if (fIgnoreNextHostWindowResize)
{
fIgnoreNextHostWindowResize = false;
return;
}

if (fShowingHostWindow)
{
fShowingHostWindow = false;
fIgnoreNextHostWindowResize = true;
fUpdateGeometryConstraints = true;
}

const uint extraHeight = kButtonHeight * getScaleFactor() + ImGui::GetStyle().WindowPadding.y * 2;

fNextSize = Size<uint>(width, height + extraHeight);

// reduce geometry constraint if needed
if (fIgnoreNextHostWindowResize)
return;
if (width < fCurrentConstraintSize.getWidth() || height < fCurrentConstraintSize.getHeight())
fUpdateGeometryConstraints = true;
}

#if ILDAEIL_STANDALONE
void onResize(const ResizeEvent& ev) override
{
UI::onResize(ev);

if (fIgnoreNextHostWindowResize)
return;
if (fShowingHostWindow)
return;

if (fDrawingState == kDrawingPluginEmbedUI)
{
const uint extraHeight = kButtonHeight * getScaleFactor() + ImGui::GetStyle().WindowPadding.y * 2;

fPluginHostWindow.setSize(ev.size.getWidth(), ev.size.getHeight() - extraHeight);
}
}
#endif

void uiIdle() override
{
@@ -675,10 +722,18 @@ protected:
repaint();
}

if (fNextSize.isValid())
if (fNextSize.isValid() && fLastSize != fNextSize)
{
fLastSize = fNextSize;

if (fUpdateGeometryConstraints)
{
fUpdateGeometryConstraints = false;
fCurrentConstraintSize = fNextSize;
setGeometryConstraints(fNextSize.getWidth(), fNextSize.getHeight());
}

setSize(fNextSize);
fNextSize = Size<uint>();
}

switch (fIdleState)
@@ -1235,6 +1290,8 @@ protected:
fDrawingState = kDrawingPluginList;
#ifndef DISTRHO_OS_WASM
fNextSize = Size<uint>(kInitialWidth * scaleFactor, kInitialHeight * scaleFactor);
fLastSize = Size<uint>();
fUpdateGeometryConstraints = true;
#endif
}



+ 25
- 3
plugins/Common/PluginHostWindow.cpp View File

@@ -252,6 +252,9 @@ struct PluginHostWindow::PrivateData
}
}
#else
for (XEvent event; XPending(display) > 0;)
XNextEvent(display, &event);

if (pluginWindow != 0)
{
int width = 0;
@@ -304,9 +307,6 @@ struct PluginHostWindow::PrivateData
pluginWindowCallbacks->pluginWindowResized(width, height);
}
}

for (XEvent event; XPending(display) > 0;)
XNextEvent(display, &event);
#endif
}

@@ -315,6 +315,23 @@ struct PluginHostWindow::PrivateData
xOffset = x;
yOffset = y;
}

void setSize(const uint width, const uint height)
{
#if defined(DISTRHO_OS_HAIKU)
#elif defined(DISTRHO_OS_MAC)
if (pluginView != nullptr)
[pluginView setFrameSize:NSMakeSize(width, height)];
#elif defined(DISTRHO_OS_WASM)
#elif defined(DISTRHO_OS_WINDOWS)
if (pluginWindow != nullptr)
SetWindowPos(pluginWindow, 0, 0, 0, width, height,
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER);
#else
if (pluginWindow != 0)
XResizeWindow(display, pluginWindow, width, height);
#endif
}
};

PluginHostWindow::PluginHostWindow(Window& parentWindow, Callbacks* const cbs)
@@ -345,4 +362,9 @@ void PluginHostWindow::setOffset(const uint x, const uint y)
pData->setOffset(x, y);
}

void PluginHostWindow::setSize(const uint width, const uint height)
{
pData->setSize(width, height);
}

END_NAMESPACE_DGL

+ 1
- 0
plugins/Common/PluginHostWindow.hpp View File

@@ -39,6 +39,7 @@ public:
bool hide();
void idle();
void setOffset(uint x, uint y);
void setSize(uint width, uint height);
};

END_NAMESPACE_DGL

Loading…
Cancel
Save