Browse Source

Special handling for cases where reshape is called on constructor

Signed-off-by: falkTX <falktx@falktx.com>
pull/312/head
falkTX 3 years ago
parent
commit
7ddda017a0
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
3 changed files with 48 additions and 2 deletions
  1. +9
    -0
      dgl/Window.hpp
  2. +13
    -0
      dgl/src/Window.cpp
  3. +26
    -2
      distrho/src/DistrhoUIPrivateData.hpp

+ 9
- 0
dgl/Window.hpp View File

@@ -447,6 +447,15 @@ private:
friend class PluginWindow;
friend class TopLevelWidget;

/** @internal */
explicit Window(Application& app,
uintptr_t parentWindowHandle,
uint width,
uint height,
double scaleFactor,
bool resizable,
bool doPostInit);

DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Window);
};



+ 13
- 0
dgl/src/Window.cpp View File

@@ -69,6 +69,19 @@ Window::Window(Application& app,
pData->initPost();
}

Window::Window(Application& app,
const uintptr_t parentWindowHandle,
const uint width,
const uint height,
const double scaleFactor,
const bool resizable,
const bool doPostInit)
: pData(new PrivateData(app, this, parentWindowHandle, width, height, scaleFactor, resizable))
{
if (doPostInit)
pData->initPost();
}

Window::~Window()
{
delete pData;


+ 26
- 2
distrho/src/DistrhoUIPrivateData.hpp View File

@@ -152,6 +152,8 @@ public:
class PluginWindow : public Window
{
DISTRHO_NAMESPACE::UI* const ui;
bool initializing;
bool receivedReshapeDuringInit;

public:
explicit PluginWindow(DISTRHO_NAMESPACE::UI* const uiPtr,
@@ -160,14 +162,21 @@ public:
const uint width,
const uint height,
const double scaleFactor)
: Window(app, parentWindowHandle, width, height, scaleFactor, DISTRHO_UI_USER_RESIZABLE),
ui(uiPtr)
: Window(app, parentWindowHandle, width, height, scaleFactor, DISTRHO_UI_USER_RESIZABLE, false),
ui(uiPtr),
initializing(true),
receivedReshapeDuringInit(false)
{
pData->initPost();
puglBackendEnter(pData->view);
}

void leaveContext()
{
if (receivedReshapeDuringInit)
ui->uiReshape(getWidth(), getHeight());

initializing = false;
puglBackendLeave(pData->view);
}

@@ -176,6 +185,9 @@ protected:
{
DISTRHO_SAFE_ASSERT_RETURN(ui != nullptr,);

if (initializing)
return;

ui->uiFocus(focus, mode);
}

@@ -183,6 +195,12 @@ protected:
{
DISTRHO_SAFE_ASSERT_RETURN(ui != nullptr,);

if (initializing)
{
receivedReshapeDuringInit = true;
return;
}

ui->uiReshape(width, height);
}

@@ -190,6 +208,9 @@ protected:
{
DISTRHO_SAFE_ASSERT_RETURN(ui != nullptr,);

if (initializing)
return;

ui->uiScaleFactorChanged(scaleFactor);
}

@@ -380,6 +401,9 @@ inline void PluginWindow::onFileSelected(const char* const filename)
{
DISTRHO_SAFE_ASSERT_RETURN(ui != nullptr,);

if (initializing)
return;

# if DISTRHO_PLUGIN_WANT_STATEFILES
if (char* const key = ui->uiData->uiStateFileKeyRequest)
{


Loading…
Cancel
Save