Signed-off-by: falkTX <falktx@falktx.com>pull/517/head
| @@ -274,28 +274,27 @@ void Window::setSize(uint width, uint height) | |||||
| if (pData->isEmbed) | if (pData->isEmbed) | ||||
| { | { | ||||
| uint minWidth = pData->minWidth; | |||||
| uint minHeight = pData->minHeight; | |||||
| PuglArea area = puglGetSizeHint(pData->view, PUGL_FIXED_ASPECT); | |||||
| if (pData->autoScaling && d_isNotEqual(scaleFactor, 1.0)) | if (pData->autoScaling && d_isNotEqual(scaleFactor, 1.0)) | ||||
| { | { | ||||
| minWidth = d_roundToUnsignedInt(minWidth * scaleFactor); | |||||
| minHeight = d_roundToUnsignedInt(minHeight * scaleFactor); | |||||
| area.width = d_roundToUnsignedInt(area.width * scaleFactor); | |||||
| area.height = d_roundToUnsignedInt(area.height * scaleFactor); | |||||
| width = d_roundToUnsignedInt(width * scaleFactor); | width = d_roundToUnsignedInt(width * scaleFactor); | ||||
| height = d_roundToUnsignedInt(height * scaleFactor); | height = d_roundToUnsignedInt(height * scaleFactor); | ||||
| } | } | ||||
| // handle geometry constraints here | // handle geometry constraints here | ||||
| if (width < minWidth) | |||||
| width = minWidth; | |||||
| if (width < area.width) | |||||
| width = area.width; | |||||
| if (height < minHeight) | |||||
| height = minHeight; | |||||
| if (height < area.height) | |||||
| height = area.height; | |||||
| if (pData->keepAspectRatio) | |||||
| if (area.width != 0 && area.height != 0) | |||||
| { | { | ||||
| const double ratio = static_cast<double>(pData->minWidth) | |||||
| / static_cast<double>(pData->minHeight); | |||||
| const double ratio = static_cast<double>(area.width) | |||||
| / static_cast<double>(area.height); | |||||
| const double reqRatio = static_cast<double>(width) | const double reqRatio = static_cast<double>(width) | ||||
| / static_cast<double>(height); | / static_cast<double>(height); | ||||
| @@ -432,11 +431,10 @@ void Window::enableInternalScalingWithSize(uint baseWidth, uint baseHeight, cons | |||||
| const double scaleHorizontal = size.getWidth() / static_cast<double>(baseWidth); | const double scaleHorizontal = size.getWidth() / static_cast<double>(baseWidth); | ||||
| const double scaleVertical = size.getHeight() / static_cast<double>(baseHeight); | const double scaleVertical = size.getHeight() / static_cast<double>(baseHeight); | ||||
| pData->minWidth = baseWidth; | |||||
| pData->minHeight = baseHeight; | |||||
| pData->baseWidth = baseWidth; | |||||
| pData->baseHeight = baseHeight; | |||||
| pData->autoScaling = true; | pData->autoScaling = true; | ||||
| pData->autoScaleFactor = scaleHorizontal < scaleVertical ? scaleHorizontal : scaleVertical; | pData->autoScaleFactor = scaleHorizontal < scaleVertical ? scaleHorizontal : scaleVertical; | ||||
| pData->keepAspectRatio = keepAspectRatio; | |||||
| if (pData->view == nullptr) | if (pData->view == nullptr) | ||||
| return; | return; | ||||
| @@ -527,8 +525,9 @@ void Window::runAsModal(bool blockWait) | |||||
| Size<uint> Window::getGeometryConstraints(bool& keepAspectRatio) | Size<uint> Window::getGeometryConstraints(bool& keepAspectRatio) | ||||
| { | { | ||||
| keepAspectRatio = pData->keepAspectRatio; | |||||
| return Size<uint>(pData->minWidth, pData->minHeight); | |||||
| const PuglArea area = puglGetSizeHint(pData->view, PUGL_FIXED_ASPECT); | |||||
| keepAspectRatio = area.width != 0 && area.height != 0; | |||||
| return Size<uint>(area.width, area.height); | |||||
| } | } | ||||
| void Window::setGeometryConstraints(const uint minimumWidth, const uint minimumHeight, const bool keepAspectRatio) | void Window::setGeometryConstraints(const uint minimumWidth, const uint minimumHeight, const bool keepAspectRatio) | ||||
| @@ -536,10 +535,6 @@ void Window::setGeometryConstraints(const uint minimumWidth, const uint minimumH | |||||
| DISTRHO_SAFE_ASSERT_RETURN(minimumWidth > 0,); | DISTRHO_SAFE_ASSERT_RETURN(minimumWidth > 0,); | ||||
| DISTRHO_SAFE_ASSERT_RETURN(minimumHeight > 0,); | DISTRHO_SAFE_ASSERT_RETURN(minimumHeight > 0,); | ||||
| pData->minWidth = minimumWidth; | |||||
| pData->minHeight = minimumHeight; | |||||
| pData->keepAspectRatio = keepAspectRatio; | |||||
| if (pData->view != nullptr) | if (pData->view != nullptr) | ||||
| puglSetGeometryConstraints(pData->view, minimumWidth, minimumHeight, keepAspectRatio); | puglSetGeometryConstraints(pData->view, minimumWidth, minimumHeight, keepAspectRatio); | ||||
| } | } | ||||
| @@ -558,10 +553,18 @@ void Window::setGeometryConstraints(uint minimumWidth, | |||||
| if (resizeNowIfAutoScaling && automaticallyScale && pData->autoScaling == automaticallyScale) | if (resizeNowIfAutoScaling && automaticallyScale && pData->autoScaling == automaticallyScale) | ||||
| resizeNowIfAutoScaling = false; | resizeNowIfAutoScaling = false; | ||||
| pData->minWidth = minimumWidth; | |||||
| pData->minHeight = minimumHeight; | |||||
| pData->autoScaling = automaticallyScale; | |||||
| pData->keepAspectRatio = keepAspectRatio; | |||||
| if (automaticallyScale) | |||||
| { | |||||
| pData->autoScaling = true; | |||||
| pData->baseWidth = minimumWidth; | |||||
| pData->baseHeight = minimumHeight; | |||||
| } | |||||
| else | |||||
| { | |||||
| pData->autoScaling = false; | |||||
| pData->baseWidth = 0; | |||||
| pData->baseHeight = 0; | |||||
| } | |||||
| if (pData->view == nullptr) | if (pData->view == nullptr) | ||||
| return; | return; | ||||
| @@ -118,9 +118,8 @@ Window::PrivateData::PrivateData(Application& a, Window* const s) | |||||
| scaleFactor(DGL_NAMESPACE::getScaleFactor(view)), | scaleFactor(DGL_NAMESPACE::getScaleFactor(view)), | ||||
| autoScaling(false), | autoScaling(false), | ||||
| autoScaleFactor(1.0), | autoScaleFactor(1.0), | ||||
| minWidth(0), | |||||
| minHeight(0), | |||||
| keepAspectRatio(false), | |||||
| baseWidth(0), | |||||
| baseHeight(0), | |||||
| ignoreIdleCallbacks(false), | ignoreIdleCallbacks(false), | ||||
| waitingForClipboardData(false), | waitingForClipboardData(false), | ||||
| waitingForClipboardEvents(false), | waitingForClipboardEvents(false), | ||||
| @@ -151,9 +150,8 @@ Window::PrivateData::PrivateData(Application& a, Window* const s, PrivateData* c | |||||
| scaleFactor(ppData->scaleFactor), | scaleFactor(ppData->scaleFactor), | ||||
| autoScaling(false), | autoScaling(false), | ||||
| autoScaleFactor(1.0), | autoScaleFactor(1.0), | ||||
| minWidth(0), | |||||
| minHeight(0), | |||||
| keepAspectRatio(false), | |||||
| baseWidth(0), | |||||
| baseHeight(0), | |||||
| ignoreIdleCallbacks(false), | ignoreIdleCallbacks(false), | ||||
| waitingForClipboardData(false), | waitingForClipboardData(false), | ||||
| waitingForClipboardEvents(false), | waitingForClipboardEvents(false), | ||||
| @@ -186,9 +184,8 @@ Window::PrivateData::PrivateData(Application& a, Window* const s, | |||||
| scaleFactor(scale != 0.0 ? scale : DGL_NAMESPACE::getScaleFactor(view)), | scaleFactor(scale != 0.0 ? scale : DGL_NAMESPACE::getScaleFactor(view)), | ||||
| autoScaling(false), | autoScaling(false), | ||||
| autoScaleFactor(1.0), | autoScaleFactor(1.0), | ||||
| minWidth(0), | |||||
| minHeight(0), | |||||
| keepAspectRatio(false), | |||||
| baseWidth(0), | |||||
| baseHeight(0), | |||||
| ignoreIdleCallbacks(false), | ignoreIdleCallbacks(false), | ||||
| waitingForClipboardData(false), | waitingForClipboardData(false), | ||||
| waitingForClipboardEvents(false), | waitingForClipboardEvents(false), | ||||
| @@ -224,9 +221,8 @@ Window::PrivateData::PrivateData(Application& a, Window* const s, | |||||
| scaleFactor(scale != 0.0 ? scale : DGL_NAMESPACE::getScaleFactor(view)), | scaleFactor(scale != 0.0 ? scale : DGL_NAMESPACE::getScaleFactor(view)), | ||||
| autoScaling(false), | autoScaling(false), | ||||
| autoScaleFactor(1.0), | autoScaleFactor(1.0), | ||||
| minWidth(0), | |||||
| minHeight(0), | |||||
| keepAspectRatio(false), | |||||
| baseWidth(0), | |||||
| baseHeight(0), | |||||
| ignoreIdleCallbacks(false), | ignoreIdleCallbacks(false), | ||||
| waitingForClipboardData(false), | waitingForClipboardData(false), | ||||
| waitingForClipboardEvents(false), | waitingForClipboardEvents(false), | ||||
| @@ -654,8 +650,8 @@ void Window::PrivateData::onPuglConfigure(const uint width, const uint height) | |||||
| if (autoScaling) | if (autoScaling) | ||||
| { | { | ||||
| const double scaleHorizontal = width / static_cast<double>(minWidth); | |||||
| const double scaleVertical = height / static_cast<double>(minHeight); | |||||
| const double scaleHorizontal = width / static_cast<double>(baseWidth); | |||||
| const double scaleVertical = height / static_cast<double>(baseHeight); | |||||
| autoScaleFactor = scaleHorizontal < scaleVertical ? scaleHorizontal : scaleVertical; | autoScaleFactor = scaleHorizontal < scaleVertical ? scaleHorizontal : scaleVertical; | ||||
| } | } | ||||
| else | else | ||||
| @@ -76,10 +76,7 @@ struct Window::PrivateData : IdleCallback { | |||||
| /** Automatic scaling to apply on widgets, implemented internally. */ | /** Automatic scaling to apply on widgets, implemented internally. */ | ||||
| bool autoScaling; | bool autoScaling; | ||||
| double autoScaleFactor; | double autoScaleFactor; | ||||
| /** Pugl geometry constraints access. */ | |||||
| uint minWidth, minHeight; | |||||
| bool keepAspectRatio; | |||||
| uint baseWidth, baseHeight; | |||||
| /** Whether to ignore idle callback requests, useful for temporary windows. */ | /** Whether to ignore idle callback requests, useful for temporary windows. */ | ||||
| bool ignoreIdleCallbacks; | bool ignoreIdleCallbacks; | ||||
| @@ -308,6 +308,11 @@ PuglStatus puglSetGeometryConstraints(PuglView* const view, const uint width, co | |||||
| view->sizeHints[PUGL_FIXED_ASPECT].width = static_cast<PuglSpan>(width); | view->sizeHints[PUGL_FIXED_ASPECT].width = static_cast<PuglSpan>(width); | ||||
| view->sizeHints[PUGL_FIXED_ASPECT].height = static_cast<PuglSpan>(height); | view->sizeHints[PUGL_FIXED_ASPECT].height = static_cast<PuglSpan>(height); | ||||
| } | } | ||||
| else | |||||
| { | |||||
| view->sizeHints[PUGL_FIXED_ASPECT].width = 0; | |||||
| view->sizeHints[PUGL_FIXED_ASPECT].height = 0; | |||||
| } | |||||
| #if defined(DISTRHO_OS_HAIKU) | #if defined(DISTRHO_OS_HAIKU) | ||||
| #elif defined(DISTRHO_OS_MAC) | #elif defined(DISTRHO_OS_MAC) | ||||
| @@ -382,7 +382,7 @@ UI::UI(const uint width, const uint height, const bool automaticallyScaleAndSetA | |||||
| #pragma GCC diagnostic push | #pragma GCC diagnostic push | ||||
| #pragma GCC diagnostic ignored "-Wdeprecated-declarations" | #pragma GCC diagnostic ignored "-Wdeprecated-declarations" | ||||
| #endif | #endif | ||||
| setGeometryConstraints(width, height, true, true, true); | |||||
| setGeometryConstraints(width, height, true, true, false); | |||||
| #if defined(_MSC_VER) | #if defined(_MSC_VER) | ||||
| #pragma warning(pop) | #pragma warning(pop) | ||||
| #elif defined(__clang__) | #elif defined(__clang__) | ||||