From 3067fa56eecb660a2f9a2d3db0c2026a083acd71 Mon Sep 17 00:00:00 2001 From: falkTX Date: Sat, 3 Jan 2026 18:41:21 +0100 Subject: [PATCH] Mark auto-scaling as deprecated, to remove future confusion Signed-off-by: falkTX --- dgl/StandaloneWindow.hpp | 33 ++++++++++++-- dgl/TopLevelWidget.hpp | 18 ++++++-- dgl/Widget.hpp | 2 +- dgl/Window.hpp | 20 ++++++--- dgl/src/Cairo.cpp | 34 ++++++++++++-- dgl/src/ImageBaseWidgets.cpp | 17 ++++--- dgl/src/OpenGL.cpp | 29 ++++++++++-- dgl/src/Stub.cpp | 8 +++- dgl/src/SubWidgetPrivateData.hpp | 6 ++- dgl/src/TopLevelWidget.cpp | 28 +++++++++++- dgl/src/TopLevelWidgetPrivateData.cpp | 8 +++- dgl/src/Vulkan.cpp | 20 ++++++--- dgl/src/WidgetPrivateData.cpp | 15 +++++-- dgl/src/WidgetPrivateData.hpp | 9 +++- dgl/src/Window.cpp | 24 +++++++++- dgl/src/WindowPrivateData.cpp | 37 ++++++++++++--- dgl/src/WindowPrivateData.hpp | 4 +- distrho/DistrhoUI.hpp | 42 ++++++++++------- distrho/src/DistrhoUI.cpp | 50 ++++++++++++++++++++- examples/CairoUI/CairoExampleUI.cpp | 6 ++- examples/Parameters/DistrhoPluginInfo.h | 2 +- examples/Parameters/ExampleUIParameters.cpp | 9 ++-- examples/Parameters/Makefile | 1 + examples/SendNote/DistrhoPluginInfo.h | 4 +- examples/SendNote/Makefile | 4 +- examples/SendNote/SendNoteExampleUI.cpp | 8 +++- examples/States/DistrhoPluginInfo.h | 4 +- examples/States/ExampleUIStates.cpp | 9 ++-- examples/States/Makefile | 1 + 29 files changed, 367 insertions(+), 85 deletions(-) diff --git a/dgl/StandaloneWindow.hpp b/dgl/StandaloneWindow.hpp index 5b77e58b..cf8604b8 100644 --- a/dgl/StandaloneWindow.hpp +++ b/dgl/StandaloneWindow.hpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2022 Filipe Coelho + * Copyright (C) 2012-2026 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -84,9 +84,34 @@ public: Application& getApp() const noexcept { return Window::getApp(); } const GraphicsContext& getGraphicsContext() const noexcept { return Window::getGraphicsContext(); } double getScaleFactor() const noexcept { return Window::getScaleFactor(); } - void setGeometryConstraints(uint minimumWidth, uint minimumHeight, - bool keepAspectRatio = false, bool automaticallyScale = false) - { Window::setGeometryConstraints(minimumWidth, minimumHeight, keepAspectRatio, automaticallyScale); } + + void setGeometryConstraints(uint minimumWidth, uint minimumHeight, bool keepAspectRatio = false) + { Window::setGeometryConstraints(minimumWidth, minimumHeight, keepAspectRatio); } + + #if DGL_ALLOW_DEPRECATED_METHODS + DISTRHO_DEPRECATED_BY("setGeometryConstraints(uint, uint, bool)") + void setGeometryConstraints(uint minimumWidth, uint minimumHeight, bool keepAspectRatio, bool automaticallyScale) + { + #if defined(_MSC_VER) + #pragma warning(push) + #pragma warning(disable:4996) + #elif defined(__clang__) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wdeprecated-declarations" + #elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 460 + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" + #endif + Window::setGeometryConstraints(minimumWidth, minimumHeight, keepAspectRatio, automaticallyScale, false); + #if defined(_MSC_VER) + #pragma warning(pop) + #elif defined(__clang__) + #pragma clang diagnostic pop + #elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 460 + #pragma GCC diagnostic pop + #endif + } + #endif private: ScopedGraphicsContext sgc; diff --git a/dgl/TopLevelWidget.hpp b/dgl/TopLevelWidget.hpp index 47015a62..74959a28 100644 --- a/dgl/TopLevelWidget.hpp +++ b/dgl/TopLevelWidget.hpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2021 Filipe Coelho + * Copyright (C) 2012-2026 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -107,17 +107,27 @@ public: bool addIdleCallback(IdleCallback* callback, uint timerFrequencyInMs = 0); bool removeIdleCallback(IdleCallback* callback); double getScaleFactor() const noexcept; + + void setGeometryConstraints(uint minimumWidth, uint minimumHeight, bool keepAspectRatio = false); + + #if DGL_ALLOW_DEPRECATED_METHODS + /** DEPRECATED DO NOT USE. + * The old deprecated constructor allowed for an optional `bool automaticallyScaleAndSetAsMinimumSize`. + * This turned out to be not be a good idea; now the scaling is done automatically while minimum size is not. + */ + DISTRHO_DEPRECATED_BY("setGeometryConstraints(uint, uint, bool)") void setGeometryConstraints(uint minimumWidth, uint minimumHeight, - bool keepAspectRatio = false, - bool automaticallyScale = false, - bool resizeNowIfAutoScaling = true); + bool keepAspectRatio, + bool automaticallyScale, + bool resizeNowIfAutoScaling); DISTRHO_DEPRECATED_BY("getApp()") Application& getParentApp() const noexcept { return getApp(); } DISTRHO_DEPRECATED_BY("getWindow()") Window& getParentWindow() const noexcept { return getWindow(); } + #endif protected: bool onKeyboard(const KeyboardEvent&) override; diff --git a/dgl/Widget.hpp b/dgl/Widget.hpp index 7766f483..f70257be 100644 --- a/dgl/Widget.hpp +++ b/dgl/Widget.hpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2024 Filipe Coelho + * Copyright (C) 2012-2026 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this diff --git a/dgl/Window.hpp b/dgl/Window.hpp index 2a811b00..675ae64f 100644 --- a/dgl/Window.hpp +++ b/dgl/Window.hpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2025 Filipe Coelho + * Copyright (C) 2012-2026 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -463,13 +463,23 @@ public: Size getGeometryConstraints(bool& keepAspectRatio); /** - Set geometry constraints for the Window when resized by the user, and optionally scale contents automatically. + Set geometry constraints for the Window when resized by the user. + Also whether to keep aspect ratio based on this size. */ + void setGeometryConstraints(uint minimumWidth, uint minimumHeight, bool keepAspectRatio = false); + + #if DGL_ALLOW_DEPRECATED_METHODS + /** DEPRECATED DO NOT USE. + * The old deprecated function allowed for optional `bool automaticallyScale` and `bool resizeNowIfAutoScaling`. + * This turned out to be not be a good idea; now the scaling on constraints is never done automatically. + */ + DISTRHO_DEPRECATED_BY("setGeometryConstraints(uint, uint, bool)") void setGeometryConstraints(uint minimumWidth, uint minimumHeight, - bool keepAspectRatio = false, - bool automaticallyScale = false, - bool resizeNowIfAutoScaling = true); + bool keepAspectRatio, + bool automaticallyScale, + bool resizeNowIfAutoScaling); + #endif /** Set the transient parent of the window. diff --git a/dgl/src/Cairo.cpp b/dgl/src/Cairo.cpp index f0a5b307..ca760a78 100644 --- a/dgl/src/Cairo.cpp +++ b/dgl/src/Cairo.cpp @@ -1,7 +1,7 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2025 Filipe Coelho * Copyright (C) 2019-2021 Jean Pierre Cimalando + * Copyright (C) 2012-2026 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -736,7 +736,11 @@ template class ImageBaseSwitch; // ----------------------------------------------------------------------- -void SubWidget::PrivateData::display(const uint width, const uint height, const double autoScaleFactor) +void SubWidget::PrivateData::display(const uint width, const uint height + #if DGL_ALLOW_DEPRECATED_METHODS + , const double autoScaleFactor + #endif + ) { cairo_t* const handle = static_cast(self->getGraphicsContext()).handle; @@ -754,10 +758,13 @@ void SubWidget::PrivateData::display(const uint width, const uint height, const { // full viewport size cairo_translate(handle, 0, 0); + #if DGL_ALLOW_DEPRECATED_METHODS cairo_scale(handle, autoScaleFactor, autoScaleFactor); + #endif } else { + #if DGL_ALLOW_DEPRECATED_METHODS // set viewport pos cairo_translate(handle, absolutePos.getX() * autoScaleFactor, absolutePos.getY() * autoScaleFactor); @@ -767,12 +774,21 @@ void SubWidget::PrivateData::display(const uint width, const uint height, const 0, std::round(self->getWidth() * autoScaleFactor), std::round(self->getHeight() * autoScaleFactor)); + #else + // set viewport pos + cairo_translate(handle, absolutePos.getX(), absolutePos.getY()); + + // then cut the outer bounds + cairo_rectangle(handle, 0, 0, self->getWidth(), self->getHeight()); + #endif cairo_clip(handle); needsResetClip = true; + #if DGL_ALLOW_DEPRECATED_METHODS // set viewport scaling cairo_scale(handle, autoScaleFactor, autoScaleFactor); + #endif } // display widget @@ -783,7 +799,11 @@ void SubWidget::PrivateData::display(const uint width, const uint height, const cairo_set_matrix(handle, &matrix); + #if DGL_ALLOW_DEPRECATED_METHODS selfw->pData->displaySubWidgets(width, height, autoScaleFactor); + #else + selfw->pData->displaySubWidgets(width, height); + #endif } // ----------------------------------------------------------------------- @@ -799,7 +819,9 @@ void TopLevelWidget::PrivateData::display() const uint width = size.getWidth(); const uint height = size.getHeight(); + #if DGL_ALLOW_DEPRECATED_METHODS const double autoScaleFactor = window.pData->autoScaleFactor; + #endif cairo_matrix_t matrix; cairo_get_matrix(handle, &matrix); @@ -807,10 +829,12 @@ void TopLevelWidget::PrivateData::display() // full viewport size cairo_translate(handle, 0, 0); + #if DGL_ALLOW_DEPRECATED_METHODS if (window.pData->autoScaling) cairo_scale(handle, autoScaleFactor, autoScaleFactor); else cairo_scale(handle, 1.0, 1.0); + #endif // main widget drawing self->onDisplay(); @@ -818,7 +842,11 @@ void TopLevelWidget::PrivateData::display() cairo_set_matrix(handle, &matrix); // now draw subwidgets if there are any - selfw->pData->displaySubWidgets(width, height, autoScaleFactor); + selfw->pData->displaySubWidgets(width, height + #if DGL_ALLOW_DEPRECATED_METHODS + , autoScaleFactor + #endif + ); } // ----------------------------------------------------------------------- diff --git a/dgl/src/ImageBaseWidgets.cpp b/dgl/src/ImageBaseWidgets.cpp index 24cc0e60..8cdbc9d7 100644 --- a/dgl/src/ImageBaseWidgets.cpp +++ b/dgl/src/ImageBaseWidgets.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2022 Filipe Coelho + * Copyright (C) 2012-2026 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -31,8 +31,9 @@ ImageBaseAboutWindow::ImageBaseAboutWindow(Window& transientParentWin if (image.isValid()) { - setSize(image.getSize()); - setGeometryConstraints(image.getWidth(), image.getHeight(), true, true); + const double scaleFactor = getScaleFactor(); + setSize(image.getSize() * scaleFactor); + setGeometryConstraints(image.getWidth() * scaleFactor, image.getHeight() * scaleFactor, true); } done(); @@ -48,8 +49,9 @@ ImageBaseAboutWindow::ImageBaseAboutWindow(TopLevelWidget* const topL if (image.isValid()) { - setSize(image.getSize()); - setGeometryConstraints(image.getWidth(), image.getHeight(), true, true); + const double scaleFactor = getScaleFactor(); + setSize(image.getSize() * scaleFactor); + setGeometryConstraints(image.getWidth(), image.getHeight(), true); } done(); @@ -71,8 +73,9 @@ void ImageBaseAboutWindow::setImage(const ImageType& image) img = image; - setSize(image.getSize()); - setGeometryConstraints(image.getWidth(), image.getHeight(), true, true); + const double scaleFactor = getScaleFactor(); + setSize(image.getSize() * scaleFactor); + setGeometryConstraints(image.getWidth() * scaleFactor, image.getHeight() * scaleFactor, true); done(); } diff --git a/dgl/src/OpenGL.cpp b/dgl/src/OpenGL.cpp index 5eac3eb3..f9bb0454 100644 --- a/dgl/src/OpenGL.cpp +++ b/dgl/src/OpenGL.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2025 Filipe Coelho + * Copyright (C) 2012-2026 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -157,7 +157,11 @@ OpenGLImage::OpenGLImage(const char* const rdata, const Size& s, const GLe // -------------------------------------------------------------------------------------------------------------------- -void SubWidget::PrivateData::display(const uint width, const uint height, const double autoScaleFactor) +void SubWidget::PrivateData::display(const uint width, const uint height + #if DGL_ALLOW_DEPRECATED_METHODS + , const double autoScaleFactor + #endif + ) { if (skipDrawing) return; @@ -191,6 +195,7 @@ void SubWidget::PrivateData::display(const uint width, const uint height, const } else { + #if DGL_ALLOW_DEPRECATED_METHODS // set viewport pos glViewport(d_roundToIntPositive(absolutePos.getX() * autoScaleFactor), -d_roundToIntPositive(absolutePos.getY() * autoScaleFactor), @@ -202,6 +207,16 @@ void SubWidget::PrivateData::display(const uint width, const uint height, const d_roundToIntPositive(height - (static_cast(self->getHeight()) + absolutePos.getY()) * autoScaleFactor), d_roundToIntPositive(self->getWidth() * autoScaleFactor), d_roundToIntPositive(self->getHeight() * autoScaleFactor)); + #else + // set viewport pos + glViewport(absolutePos.getX(), -absolutePos.getY(), static_cast(width), static_cast(height)); + + // then cut the outer bounds + glScissor(absolutePos.getX(), + static_cast(height) - self->getHeight() + absolutePos.getY(), + static_cast(self->getWidth()), + static_cast(self->getHeight())); + #endif glEnable(GL_SCISSOR_TEST); needsDisableScissor = true; @@ -213,7 +228,11 @@ void SubWidget::PrivateData::display(const uint width, const uint height, const if (needsDisableScissor) glDisable(GL_SCISSOR_TEST); + #if DGL_ALLOW_DEPRECATED_METHODS selfw->pData->displaySubWidgets(width, height, autoScaleFactor); + #else + selfw->pData->displaySubWidgets(width, height); + #endif } // -------------------------------------------------------------------------------------------------------------------- @@ -234,7 +253,11 @@ void TopLevelWidget::PrivateData::display() self->onDisplay(); // now draw subwidgets if there are any - selfw->pData->displaySubWidgets(width, height, window.pData->autoScaleFactor); + selfw->pData->displaySubWidgets(width, height + #if DGL_ALLOW_DEPRECATED_METHODS + , window.pData->autoScaleFactor + #endif + ); } // -------------------------------------------------------------------------------------------------------------------- diff --git a/dgl/src/Stub.cpp b/dgl/src/Stub.cpp index 2fc1a166..f4bd6cb3 100644 --- a/dgl/src/Stub.cpp +++ b/dgl/src/Stub.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2025 Filipe Coelho + * Copyright (C) 2012-2026 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -172,9 +172,15 @@ void Rectangle::drawOutline() // -------------------------------------------------------------------------------------------------------------------- +#if DGL_ALLOW_DEPRECATED_METHODS void SubWidget::PrivateData::display(uint, uint, double) { } +#else +void SubWidget::PrivateData::display(uint, uint) +{ +} +#endif // -------------------------------------------------------------------------------------------------------------------- diff --git a/dgl/src/SubWidgetPrivateData.hpp b/dgl/src/SubWidgetPrivateData.hpp index a06f59d1..60626049 100644 --- a/dgl/src/SubWidgetPrivateData.hpp +++ b/dgl/src/SubWidgetPrivateData.hpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2021 Filipe Coelho + * Copyright (C) 2012-2026 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -38,7 +38,11 @@ struct SubWidget::PrivateData { ~PrivateData(); // NOTE display function is different depending on build type, must call displaySubWidgets at the end + #if DGL_ALLOW_DEPRECATED_METHODS void display(uint width, uint height, double autoScaleFactor); + #else + void display(uint width, uint height); + #endif DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PrivateData) }; diff --git a/dgl/src/TopLevelWidget.cpp b/dgl/src/TopLevelWidget.cpp index ab1fa4bf..61dd5e3b 100644 --- a/dgl/src/TopLevelWidget.cpp +++ b/dgl/src/TopLevelWidget.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2021 Filipe Coelho + * Copyright (C) 2012-2026 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -100,18 +100,42 @@ void TopLevelWidget::repaint(const Rectangle& rect) noexcept pData->window.repaint(rect); } +void TopLevelWidget::setGeometryConstraints(const uint minimumWidth, const uint minimumHeight, const bool keepAspectRatio) +{ + pData->window.setGeometryConstraints(minimumWidth, minimumHeight, keepAspectRatio); +} + +#if DGL_ALLOW_DEPRECATED_METHODS void TopLevelWidget::setGeometryConstraints(const uint minimumWidth, const uint minimumHeight, const bool keepAspectRatio, const bool automaticallyScale, const bool resizeNowIfAutoScaling) { + #if defined(_MSC_VER) + #pragma warning(push) + #pragma warning(disable:4996) + #elif defined(__clang__) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wdeprecated-declarations" + #elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 460 + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" + #endif pData->window.setGeometryConstraints(minimumWidth, minimumHeight, keepAspectRatio, automaticallyScale, resizeNowIfAutoScaling); -} + #if defined(_MSC_VER) + #pragma warning(pop) + #elif defined(__clang__) + #pragma clang diagnostic pop + #elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 460 + #pragma GCC diagnostic pop + #endif +} +#endif // -------------------------------------------------------------------------------------------------------------------- diff --git a/dgl/src/TopLevelWidgetPrivateData.cpp b/dgl/src/TopLevelWidgetPrivateData.cpp index adcd71bc..d3aab894 100644 --- a/dgl/src/TopLevelWidgetPrivateData.cpp +++ b/dgl/src/TopLevelWidgetPrivateData.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2021 Filipe Coelho + * Copyright (C) 2012-2026 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -75,6 +75,7 @@ bool TopLevelWidget::PrivateData::mouseEvent(const MouseEvent& ev) MouseEvent rev = ev; + #if DGL_ALLOW_DEPRECATED_METHODS if (window.pData->autoScaling) { const double autoScaleFactor = window.pData->autoScaleFactor; @@ -84,6 +85,7 @@ bool TopLevelWidget::PrivateData::mouseEvent(const MouseEvent& ev) rev.absolutePos.setX(ev.absolutePos.getX() / autoScaleFactor); rev.absolutePos.setY(ev.absolutePos.getY() / autoScaleFactor); } + #endif // propagate event to all subwidgets recursively return selfw->pData->giveMouseEventForSubWidgets(rev); @@ -97,6 +99,7 @@ bool TopLevelWidget::PrivateData::motionEvent(const MotionEvent& ev) MotionEvent rev = ev; + #if DGL_ALLOW_DEPRECATED_METHODS if (window.pData->autoScaling) { const double autoScaleFactor = window.pData->autoScaleFactor; @@ -106,6 +109,7 @@ bool TopLevelWidget::PrivateData::motionEvent(const MotionEvent& ev) rev.absolutePos.setX(ev.absolutePos.getX() / autoScaleFactor); rev.absolutePos.setY(ev.absolutePos.getY() / autoScaleFactor); } + #endif // propagate event to all subwidgets recursively return selfw->pData->giveMotionEventForSubWidgets(rev); @@ -119,6 +123,7 @@ bool TopLevelWidget::PrivateData::scrollEvent(const ScrollEvent& ev) ScrollEvent rev = ev; + #if DGL_ALLOW_DEPRECATED_METHODS if (window.pData->autoScaling) { const double autoScaleFactor = window.pData->autoScaleFactor; @@ -130,6 +135,7 @@ bool TopLevelWidget::PrivateData::scrollEvent(const ScrollEvent& ev) rev.delta.setX(ev.delta.getX() / autoScaleFactor); rev.delta.setY(ev.delta.getY() / autoScaleFactor); } + #endif // propagate event to all subwidgets recursively return selfw->pData->giveScrollEventForSubWidgets(rev); diff --git a/dgl/src/Vulkan.cpp b/dgl/src/Vulkan.cpp index 7c07d9c5..446a6d4c 100644 --- a/dgl/src/Vulkan.cpp +++ b/dgl/src/Vulkan.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2025 Filipe Coelho + * Copyright (C) 2012-2026 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -235,11 +235,19 @@ VulkanImage& VulkanImage::operator=(const VulkanImage& image) noexcept // ----------------------------------------------------------------------- -void SubWidget::PrivateData::display(const uint width, const uint height, const double autoScaleFactor) +void SubWidget::PrivateData::display(const uint width, const uint height + #if DGL_ALLOW_DEPRECATED_METHODS + , const double autoScaleFactor + #endif + ) { // TODO + #if DGL_ALLOW_DEPRECATED_METHODS selfw->pData->displaySubWidgets(width, height, autoScaleFactor); + #else + selfw->pData->displaySubWidgets(width, height); + #endif } // ----------------------------------------------------------------------- @@ -253,15 +261,17 @@ void TopLevelWidget::PrivateData::display() const uint width = size.getWidth(); const uint height = size.getHeight(); - const double autoScaleFactor = window.pData->autoScaleFactor; - // TODO // main widget drawing self->onDisplay(); // now draw subwidgets if there are any - selfw->pData->displaySubWidgets(width, height, autoScaleFactor); + selfw->pData->displaySubWidgets(width, height + #if DGL_ALLOW_DEPRECATED_METHODS + , window.pData->autoScaleFactor + #endif + ); } // ----------------------------------------------------------------------- diff --git a/dgl/src/WidgetPrivateData.cpp b/dgl/src/WidgetPrivateData.cpp index e05073cc..27821e09 100644 --- a/dgl/src/WidgetPrivateData.cpp +++ b/dgl/src/WidgetPrivateData.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2022 Filipe Coelho + * Copyright (C) 2012-2026 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -56,7 +56,12 @@ Widget::PrivateData::~PrivateData() std::free(name); } -void Widget::PrivateData::displaySubWidgets(const uint width, const uint height, const double autoScaleFactor) +void Widget::PrivateData::displaySubWidgets(const uint width, + const uint height + #if DGL_ALLOW_DEPRECATED_METHODS + , const double autoScaleFactor + #endif + ) { if (subWidgets.size() == 0) return; @@ -66,7 +71,11 @@ void Widget::PrivateData::displaySubWidgets(const uint width, const uint height, SubWidget* const subwidget(*it); if (subwidget->isVisible()) - subwidget->pData->display(width, height, autoScaleFactor); + subwidget->pData->display(width, height + #if DGL_ALLOW_DEPRECATED_METHODS + , autoScaleFactor + #endif + ); } } diff --git a/dgl/src/WidgetPrivateData.hpp b/dgl/src/WidgetPrivateData.hpp index 9cc157fd..94161245 100644 --- a/dgl/src/WidgetPrivateData.hpp +++ b/dgl/src/WidgetPrivateData.hpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2022 Filipe Coelho + * Copyright (C) 2012-2026 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -42,7 +42,12 @@ struct Widget::PrivateData { explicit PrivateData(Widget* const s, Widget* const pw); ~PrivateData(); - void displaySubWidgets(uint width, uint height, double autoScaleFactor); + void displaySubWidgets(uint width, + uint height + #if DGL_ALLOW_DEPRECATED_METHODS + , double autoScaleFactor + #endif + ); bool giveKeyboardEventForSubWidgets(const KeyboardEvent& ev); bool giveCharacterInputEventForSubWidgets(const CharacterInputEvent& ev); diff --git a/dgl/src/Window.cpp b/dgl/src/Window.cpp index 01c285e0..f5ce0bb9 100644 --- a/dgl/src/Window.cpp +++ b/dgl/src/Window.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2025 Filipe Coelho + * Copyright (C) 2012-2026 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -272,15 +272,18 @@ void Window::setSize(uint width, uint height) if (pData->isEmbed) { - const double scaleFactor = pData->scaleFactor; uint minWidth = pData->minWidth; uint minHeight = pData->minHeight; + #if DGL_ALLOW_DEPRECATED_METHODS + const double scaleFactor = pData->scaleFactor; + if (pData->autoScaling && d_isNotEqual(scaleFactor, 1.0)) { minWidth = d_roundToUnsignedInt(minWidth * scaleFactor); minHeight = d_roundToUnsignedInt(minHeight * scaleFactor); } + #endif // handle geometry constraints here if (width < minWidth) @@ -462,6 +465,7 @@ void Window::repaint(const Rectangle& rect) noexcept uint width = rect.getWidth(); uint height = rect.getHeight(); + #if DGL_ALLOW_DEPRECATED_METHODS if (pData->autoScaling) { const double autoScaleFactor = pData->autoScaleFactor; @@ -471,6 +475,7 @@ void Window::repaint(const Rectangle& rect) noexcept width = d_roundToUnsignedInt(width * autoScaleFactor); height = d_roundToUnsignedInt(height * autoScaleFactor); } + #endif puglObscureRegion(pData->view, x, y, width, height); } @@ -491,6 +496,20 @@ Size Window::getGeometryConstraints(bool& keepAspectRatio) return Size(pData->minWidth, pData->minHeight); } +void Window::setGeometryConstraints(const uint minimumWidth, const uint minimumHeight, const bool keepAspectRatio) +{ + DISTRHO_SAFE_ASSERT_RETURN(minimumWidth > 0,); + DISTRHO_SAFE_ASSERT_RETURN(minimumHeight > 0,); + + pData->minWidth = minimumWidth; + pData->minHeight = minimumHeight; + pData->keepAspectRatio = keepAspectRatio; + + if (pData->view != nullptr) + puglSetGeometryConstraints(pData->view, minimumWidth, minimumHeight, keepAspectRatio); +} + +#if DGL_ALLOW_DEPRECATED_METHODS void Window::setGeometryConstraints(uint minimumWidth, uint minimumHeight, const bool keepAspectRatio, @@ -530,6 +549,7 @@ void Window::setGeometryConstraints(uint minimumWidth, d_roundToUnsignedInt(size.getHeight() * scaleFactor)); } } +#endif void Window::setTransientParent(const uintptr_t transientParentWindowHandle) { diff --git a/dgl/src/WindowPrivateData.cpp b/dgl/src/WindowPrivateData.cpp index 563d2b44..3f555512 100644 --- a/dgl/src/WindowPrivateData.cpp +++ b/dgl/src/WindowPrivateData.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2025 Filipe Coelho + * Copyright (C) 2012-2026 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -116,8 +116,10 @@ Window::PrivateData::PrivateData(Application& a, Window* const s) usesScheduledRepaints(false), usesSizeRequest(false), scaleFactor(DGL_NAMESPACE::getScaleFactor(view)), + #if DGL_ALLOW_DEPRECATED_METHODS autoScaling(false), autoScaleFactor(1.0), + #endif minWidth(0), minHeight(0), keepAspectRatio(false), @@ -149,8 +151,10 @@ Window::PrivateData::PrivateData(Application& a, Window* const s, PrivateData* c usesScheduledRepaints(false), usesSizeRequest(false), scaleFactor(ppData->scaleFactor), + #if DGL_ALLOW_DEPRECATED_METHODS autoScaling(false), autoScaleFactor(1.0), + #endif minWidth(0), minHeight(0), keepAspectRatio(false), @@ -184,8 +188,10 @@ Window::PrivateData::PrivateData(Application& a, Window* const s, usesScheduledRepaints(false), usesSizeRequest(false), scaleFactor(scale != 0.0 ? scale : DGL_NAMESPACE::getScaleFactor(view)), + #if DGL_ALLOW_DEPRECATED_METHODS autoScaling(false), autoScaleFactor(1.0), + #endif minWidth(0), minHeight(0), keepAspectRatio(false), @@ -222,8 +228,10 @@ Window::PrivateData::PrivateData(Application& a, Window* const s, usesScheduledRepaints(_usesScheduledRepaints), usesSizeRequest(_usesSizeRequest), scaleFactor(scale != 0.0 ? scale : DGL_NAMESPACE::getScaleFactor(view)), + #if DGL_ALLOW_DEPRECATED_METHODS autoScaling(false), autoScaleFactor(1.0), + #endif minWidth(0), minHeight(0), keepAspectRatio(false), @@ -526,7 +534,10 @@ bool Window::PrivateData::openFileBrowser(const FileBrowserOptions& options) fileBrowserHandle = fileBrowserCreate(isEmbed, puglGetNativeView(view), - autoScaling ? autoScaleFactor : scaleFactor, + #if DGL_ALLOW_DEPRECATED_METHODS + autoScaling ? autoScaleFactor : + #endif + scaleFactor, options2); return fileBrowserHandle != nullptr; @@ -552,7 +563,10 @@ bool Window::PrivateData::createWebView(const char* const url, const DGL_NAMESPA puglGetNativeView(view), initialWidth, initialHeight, - autoScaling ? autoScaleFactor : scaleFactor, + #if DGL_ALLOW_DEPRECATED_METHODS + autoScaling ? autoScaleFactor : + #endif + scaleFactor, options); return webViewHandle != nullptr; @@ -646,6 +660,7 @@ void Window::PrivateData::onPuglConfigure(const uint width, const uint height) createContextIfNeeded(); + #if DGL_ALLOW_DEPRECATED_METHODS if (autoScaling) { const double scaleHorizontal = width / static_cast(minWidth); @@ -656,16 +671,22 @@ void Window::PrivateData::onPuglConfigure(const uint width, const uint height) { autoScaleFactor = 1.0; } - const uint uwidth = d_roundToUnsignedInt(width / autoScaleFactor); const uint uheight = d_roundToUnsignedInt(height / autoScaleFactor); + #else + const uint uwidth = width; + const uint uheight = height; + #endif #ifdef DGL_USE_WEB_VIEW if (webViewHandle != nullptr) webViewResize(webViewHandle, uwidth - webViewOffset.getX(), uheight - webViewOffset.getY(), - autoScaling ? autoScaleFactor : scaleFactor); + #if DGL_ALLOW_DEPRECATED_METHODS + autoScaling ? autoScaleFactor : + #endif + scaleFactor); #endif #if DGL_ALLOW_DEPRECATED_METHODS @@ -1089,12 +1110,14 @@ PuglStatus Window::PrivateData::puglEventCallback(PuglView* const view, const Pu ev.time = d_roundToUnsignedInt(event->button.time * 1000.0); ev.button = event->button.button + 1; ev.press = event->type == PUGL_BUTTON_PRESS; + #if DGL_ALLOW_DEPRECATED_METHODS if (pData->autoScaling && 0) { const double scaleFactor = pData->autoScaleFactor; ev.pos = Point(event->button.x / scaleFactor, event->button.y / scaleFactor); } else + #endif { ev.pos = Point(event->button.x, event->button.y); } @@ -1110,12 +1133,14 @@ PuglStatus Window::PrivateData::puglEventCallback(PuglView* const view, const Pu ev.mod = event->motion.state; ev.flags = event->motion.flags; ev.time = d_roundToUnsignedInt(event->motion.time * 1000.0); + #if DGL_ALLOW_DEPRECATED_METHODS if (pData->autoScaling && 0) { const double scaleFactor = pData->autoScaleFactor; ev.pos = Point(event->motion.x / scaleFactor, event->motion.y / scaleFactor); } else + #endif { ev.pos = Point(event->motion.x, event->motion.y); } @@ -1131,6 +1156,7 @@ PuglStatus Window::PrivateData::puglEventCallback(PuglView* const view, const Pu ev.mod = event->scroll.state; ev.flags = event->scroll.flags; ev.time = d_roundToUnsignedInt(event->scroll.time * 1000.0); + #if DGL_ALLOW_DEPRECATED_METHODS if (pData->autoScaling && 0) { const double scaleFactor = pData->autoScaleFactor; @@ -1138,6 +1164,7 @@ PuglStatus Window::PrivateData::puglEventCallback(PuglView* const view, const Pu ev.delta = Point(event->scroll.dx / scaleFactor, event->scroll.dy / scaleFactor); } else + #endif { ev.pos = Point(event->scroll.x, event->scroll.y); ev.delta = Point(event->scroll.dx, event->scroll.dy); diff --git a/dgl/src/WindowPrivateData.hpp b/dgl/src/WindowPrivateData.hpp index 38831848..2717a7af 100644 --- a/dgl/src/WindowPrivateData.hpp +++ b/dgl/src/WindowPrivateData.hpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2025 Filipe Coelho + * Copyright (C) 2012-2026 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -73,9 +73,11 @@ struct Window::PrivateData : IdleCallback { /** Scale factor to report to widgets on request, purely informational. */ double scaleFactor; + #if DGL_ALLOW_DEPRECATED_METHODS /** Automatic scaling to apply on widgets, implemented internally. */ bool autoScaling; double autoScaleFactor; + #endif /** Pugl geometry constraints access. */ uint minWidth, minHeight; diff --git a/distrho/DistrhoUI.hpp b/distrho/DistrhoUI.hpp index 2401197d..a84c54de 100644 --- a/distrho/DistrhoUI.hpp +++ b/distrho/DistrhoUI.hpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2025 Filipe Coelho + * Copyright (C) 2012-2026 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -55,7 +55,7 @@ START_NAMESPACE_DISTRHO class PluginWindow; -/* ------------------------------------------------------------------------------------------------------------ +/* -------------------------------------------------------------------------------------------------------------------- * DPF UI */ /** @@ -76,19 +76,29 @@ public: UI class constructor. The UI should be initialized to a default state that matches the plugin side. - When @a automaticallyScale is set to true, DPF will automatically scale up the UI - to fit the host/desktop scale factor.@n - It assumes aspect ratio is meant to be kept. - Manually call setGeometryConstraints instead if keeping UI aspect ratio is not required. + The @p width and @p height arguments are meant to be used without any OS-level UI scaling. + Scaling will be automatically done internally if needed, matching the OS and host. + + @see getScaleFactor + @see setGeometryConstraints */ - UI(uint width = 0, uint height = 0, bool automaticallyScaleAndSetAsMinimumSize = false); + UI(uint width = 0, uint height = 0); + + #if DGL_ALLOW_DEPRECATED_METHODS + /** DEPRECATED DO NOT USE. + * The old deprecated constructor allowed for an optional `bool automaticallyScaleAndSetAsMinimumSize`. + * This turned out to be not be a good idea; now the scaling is done automatically while minimum size is not. + */ + DISTRHO_DEPRECATED_BY("UI(width, height)") + UI(uint width, uint height, bool automaticallyScaleAndSetAsMinimumSize); + #endif /** Destructor. */ ~UI() override; - /* -------------------------------------------------------------------------------------------------------- + /* ----------------------------------------------------------------------------------------------------------------- * Host state */ /** @@ -201,7 +211,7 @@ public: #endif #if DISTRHO_PLUGIN_WANT_DIRECT_ACCESS - /* -------------------------------------------------------------------------------------------------------- + /* ----------------------------------------------------------------------------------------------------------------- * Direct DSP access - DO NOT USE THIS UNLESS STRICTLY NECESSARY!! */ /** @@ -212,7 +222,7 @@ public: #endif protected: - /* -------------------------------------------------------------------------------------------------------- + /* ----------------------------------------------------------------------------------------------------------------- * DSP/Plugin Callbacks */ /** @@ -237,7 +247,7 @@ protected: virtual void stateChanged(const char* key, const char* value); #endif - /* -------------------------------------------------------------------------------------------------------- + /* ----------------------------------------------------------------------------------------------------------------- * DSP/Plugin Callbacks (optional) */ /** @@ -246,7 +256,7 @@ protected: */ virtual void sampleRateChanged(double newSampleRate); - /* -------------------------------------------------------------------------------------------------------- + /* ----------------------------------------------------------------------------------------------------------------- * UI Callbacks (optional) */ /** @@ -310,7 +320,7 @@ protected: virtual void uiFileBrowserSelected(const char* filename); #endif - /* -------------------------------------------------------------------------------------------------------- + /* ----------------------------------------------------------------------------------------------------------------- * UI Resize Handling, internal */ /** @@ -320,7 +330,7 @@ protected: */ void onResize(const ResizeEvent& ev) override; - // ------------------------------------------------------------------------------------------------------- + // ---------------------------------------------------------------------------------------------------------------- private: struct PrivateData; @@ -335,7 +345,7 @@ private: /** @} */ -/* ------------------------------------------------------------------------------------------------------------ +/* -------------------------------------------------------------------------------------------------------------------- * Create UI, entry point */ /** @@ -351,7 +361,7 @@ extern UI* createUI(); /** @} */ -// ----------------------------------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------------------------------------- END_NAMESPACE_DISTRHO diff --git a/distrho/src/DistrhoUI.cpp b/distrho/src/DistrhoUI.cpp index 09b4a4d0..e2ccf46c 100644 --- a/distrho/src/DistrhoUI.cpp +++ b/distrho/src/DistrhoUI.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2024 Filipe Coelho + * Copyright (C) 2012-2026 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -322,6 +322,34 @@ void UI::PrivateData::webViewMessageCallback(void* const arg, char* const msg) /* ------------------------------------------------------------------------------------------------------------ * UI */ +UI::UI(const uint width, const uint height) + : UIWidget(UI::PrivateData::createNextWindow(this, + // width + #ifdef DISTRHO_UI_DEFAULT_WIDTH + width == 0 ? DISTRHO_UI_DEFAULT_WIDTH : + #endif + width, + // height + #ifdef DISTRHO_UI_DEFAULT_HEIGHT + height == 0 ? DISTRHO_UI_DEFAULT_HEIGHT : + #endif + height + )), + uiData(UI::PrivateData::s_nextPrivateData) +{ + if (width != 0 && height != 0) + { + Widget::setSize(width, height); + } + #ifdef DISTRHO_UI_DEFAULT_WIDTH + else + { + Widget::setSize(DISTRHO_UI_DEFAULT_WIDTH, DISTRHO_UI_DEFAULT_HEIGHT); + } + #endif +} + +#if DGL_ALLOW_DEPRECATED_METHODS UI::UI(const uint width, const uint height, const bool automaticallyScaleAndSetAsMinimumSize) : UIWidget(UI::PrivateData::createNextWindow(this, // width @@ -342,7 +370,26 @@ UI::UI(const uint width, const uint height, const bool automaticallyScaleAndSetA Widget::setSize(width, height); if (automaticallyScaleAndSetAsMinimumSize) + { + #if defined(_MSC_VER) + #pragma warning(push) + #pragma warning(disable:4996) + #elif defined(__clang__) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wdeprecated-declarations" + #elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 460 + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" + #endif setGeometryConstraints(width, height, true, true, true); + #if defined(_MSC_VER) + #pragma warning(pop) + #elif defined(__clang__) + #pragma clang diagnostic pop + #elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 460 + #pragma GCC diagnostic pop + #endif + } } #ifdef DISTRHO_UI_DEFAULT_WIDTH else @@ -351,6 +398,7 @@ UI::UI(const uint width, const uint height, const bool automaticallyScaleAndSetA } #endif } +#endif UI::~UI() { diff --git a/examples/CairoUI/CairoExampleUI.cpp b/examples/CairoUI/CairoExampleUI.cpp index 343feb1f..ee5126b0 100644 --- a/examples/CairoUI/CairoExampleUI.cpp +++ b/examples/CairoUI/CairoExampleUI.cpp @@ -1,7 +1,7 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2021 Filipe Coelho * Copyright (C) 2019-2021 Jean Pierre Cimalando + * Copyright (C) 2012-2026 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -74,7 +74,9 @@ public: fButton->setCallback(this); fButton->setId(kParameterButton); - setGeometryConstraints(DISTRHO_UI_DEFAULT_WIDTH, DISTRHO_UI_DEFAULT_HEIGHT, true, true); + // set minimum UI size + const double scaleFactor = getScaleFactor(); + setGeometryConstraints(DISTRHO_UI_DEFAULT_WIDTH * scaleFactor, DISTRHO_UI_DEFAULT_HEIGHT * scaleFactor, true); } protected: diff --git a/examples/Parameters/DistrhoPluginInfo.h b/examples/Parameters/DistrhoPluginInfo.h index ba8766a2..42831a7a 100644 --- a/examples/Parameters/DistrhoPluginInfo.h +++ b/examples/Parameters/DistrhoPluginInfo.h @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2024 Filipe Coelho + * Copyright (C) 2012-2026 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this diff --git a/examples/Parameters/ExampleUIParameters.cpp b/examples/Parameters/ExampleUIParameters.cpp index 5b465a20..8bb3efa7 100644 --- a/examples/Parameters/ExampleUIParameters.cpp +++ b/examples/Parameters/ExampleUIParameters.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2021 Filipe Coelho + * Copyright (C) 2012-2026 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -33,7 +33,7 @@ class ExampleUIParameters : public UI public: /* constructor */ ExampleUIParameters() - : UI(DISTRHO_UI_DEFAULT_WIDTH, DISTRHO_UI_DEFAULT_HEIGHT) + : UI() { /** Initialize all our parameters to their defaults. @@ -41,8 +41,9 @@ public: */ std::memset(fParamGrid, 0, sizeof(bool)*9); - // TODO explain why this is here - setGeometryConstraints(128, 128, true, false); + // set minimum UI size + const double scaleFactor = getScaleFactor(); + setGeometryConstraints(DISTRHO_UI_DEFAULT_WIDTH * scaleFactor, DISTRHO_UI_DEFAULT_HEIGHT * scaleFactor, true); } protected: diff --git a/examples/Parameters/Makefile b/examples/Parameters/Makefile index be8706c9..aaf63c89 100644 --- a/examples/Parameters/Makefile +++ b/examples/Parameters/Makefile @@ -21,6 +21,7 @@ FILES_UI = \ # -------------------------------------------------------------- # Do some magic +UI_TYPE = generic include ../../Makefile.plugins.mk # -------------------------------------------------------------- diff --git a/examples/SendNote/DistrhoPluginInfo.h b/examples/SendNote/DistrhoPluginInfo.h index 5726b5ff..a90855c9 100644 --- a/examples/SendNote/DistrhoPluginInfo.h +++ b/examples/SendNote/DistrhoPluginInfo.h @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2024 Filipe Coelho + * Copyright (C) 2012-2026 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -33,5 +33,7 @@ #define DISTRHO_PLUGIN_WANT_MIDI_INPUT 1 #define DISTRHO_PLUGIN_WANT_MIDI_OUTPUT 0 #define DISTRHO_UI_FILE_BROWSER 0 +#define DISTRHO_UI_DEFAULT_WIDTH (64 * 12 + 8) +#define DISTRHO_UI_DEFAULT_HEIGHT (64 + 8) #endif // DISTRHO_PLUGIN_INFO_H_INCLUDED diff --git a/examples/SendNote/Makefile b/examples/SendNote/Makefile index c242387b..71a39a82 100644 --- a/examples/SendNote/Makefile +++ b/examples/SendNote/Makefile @@ -22,15 +22,13 @@ FILES_UI = \ # -------------------------------------------------------------- # Do some magic +UI_TYPE = generic include ../../Makefile.plugins.mk # -------------------------------------------------------------- # Enable all possible plugin types -ifeq ($(HAVE_OPENGL),true) TARGETS += jack -endif - TARGETS += lv2_sep TARGETS += vst2 TARGETS += vst3 diff --git a/examples/SendNote/SendNoteExampleUI.cpp b/examples/SendNote/SendNoteExampleUI.cpp index 75a28ea2..ba2020b4 100644 --- a/examples/SendNote/SendNoteExampleUI.cpp +++ b/examples/SendNote/SendNoteExampleUI.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2021 Filipe Coelho + * Copyright (C) 2012-2026 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -35,10 +35,14 @@ class SendNoteExampleUI : public UI { public: SendNoteExampleUI() - : UI(64*12+8, 64+8), + : UI(), fLastKey(-1) { std::memset(fKeyState, 0, sizeof(fKeyState)); + + // set minimum UI size + const double scaleFactor = getScaleFactor(); + setGeometryConstraints(DISTRHO_UI_DEFAULT_WIDTH * scaleFactor, DISTRHO_UI_DEFAULT_HEIGHT * scaleFactor, true); } protected: diff --git a/examples/States/DistrhoPluginInfo.h b/examples/States/DistrhoPluginInfo.h index 87c17851..6b6717af 100644 --- a/examples/States/DistrhoPluginInfo.h +++ b/examples/States/DistrhoPluginInfo.h @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2024 Filipe Coelho + * Copyright (C) 2012-2026 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -33,6 +33,8 @@ #define DISTRHO_PLUGIN_WANT_STATE 1 #define DISTRHO_UI_FILE_BROWSER 0 #define DISTRHO_UI_USER_RESIZABLE 1 +#define DISTRHO_UI_DEFAULT_WIDTH 512 +#define DISTRHO_UI_DEFAULT_HEIGHT 512 // states and presets together require this in order to function #define DISTRHO_PLUGIN_WANT_FULL_STATE 1 diff --git a/examples/States/ExampleUIStates.cpp b/examples/States/ExampleUIStates.cpp index 3e2d0770..a6bfd30f 100644 --- a/examples/States/ExampleUIStates.cpp +++ b/examples/States/ExampleUIStates.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2021 Filipe Coelho + * Copyright (C) 2012-2026 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -54,15 +54,16 @@ public: /* constructor */ ExampleUIParameters() - : UI(512, 512) + : UI() { /** Initialize the grid to all off per default. */ std::memset(fParamGrid, 0, sizeof(bool)*9); - // TODO explain why this is here - setGeometryConstraints(128, 128, true); + // set minimum UI size + const double scaleFactor = getScaleFactor(); + setGeometryConstraints(DISTRHO_UI_DEFAULT_WIDTH * scaleFactor, DISTRHO_UI_DEFAULT_HEIGHT * scaleFactor, true); } protected: diff --git a/examples/States/Makefile b/examples/States/Makefile index 8016c3e2..de96e095 100644 --- a/examples/States/Makefile +++ b/examples/States/Makefile @@ -21,6 +21,7 @@ FILES_UI = \ # -------------------------------------------------------------- # Do some magic +UI_TYPE = generic include ../../Makefile.plugins.mk # --------------------------------------------------------------