Skip to content

Commit 3067fa5

Browse files
committed
Mark auto-scaling as deprecated, to remove future confusion
Signed-off-by: falkTX <[email protected]>
1 parent 22c0d84 commit 3067fa5

29 files changed

+367
-85
lines changed

dgl/StandaloneWindow.hpp

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* DISTRHO Plugin Framework (DPF)
3-
* Copyright (C) 2012-2022 Filipe Coelho <[email protected]>
3+
* Copyright (C) 2012-2026 Filipe Coelho <[email protected]>
44
*
55
* Permission to use, copy, modify, and/or distribute this software for any purpose with
66
* or without fee is hereby granted, provided that the above copyright notice and this
@@ -84,9 +84,34 @@ class StandaloneWindow : public Window,
8484
Application& getApp() const noexcept { return Window::getApp(); }
8585
const GraphicsContext& getGraphicsContext() const noexcept { return Window::getGraphicsContext(); }
8686
double getScaleFactor() const noexcept { return Window::getScaleFactor(); }
87-
void setGeometryConstraints(uint minimumWidth, uint minimumHeight,
88-
bool keepAspectRatio = false, bool automaticallyScale = false)
89-
{ Window::setGeometryConstraints(minimumWidth, minimumHeight, keepAspectRatio, automaticallyScale); }
87+
88+
void setGeometryConstraints(uint minimumWidth, uint minimumHeight, bool keepAspectRatio = false)
89+
{ Window::setGeometryConstraints(minimumWidth, minimumHeight, keepAspectRatio); }
90+
91+
#if DGL_ALLOW_DEPRECATED_METHODS
92+
DISTRHO_DEPRECATED_BY("setGeometryConstraints(uint, uint, bool)")
93+
void setGeometryConstraints(uint minimumWidth, uint minimumHeight, bool keepAspectRatio, bool automaticallyScale)
94+
{
95+
#if defined(_MSC_VER)
96+
#pragma warning(push)
97+
#pragma warning(disable:4996)
98+
#elif defined(__clang__)
99+
#pragma clang diagnostic push
100+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
101+
#elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 460
102+
#pragma GCC diagnostic push
103+
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
104+
#endif
105+
Window::setGeometryConstraints(minimumWidth, minimumHeight, keepAspectRatio, automaticallyScale, false);
106+
#if defined(_MSC_VER)
107+
#pragma warning(pop)
108+
#elif defined(__clang__)
109+
#pragma clang diagnostic pop
110+
#elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 460
111+
#pragma GCC diagnostic pop
112+
#endif
113+
}
114+
#endif
90115

91116
private:
92117
ScopedGraphicsContext sgc;

dgl/TopLevelWidget.hpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* DISTRHO Plugin Framework (DPF)
3-
* Copyright (C) 2012-2021 Filipe Coelho <[email protected]>
3+
* Copyright (C) 2012-2026 Filipe Coelho <[email protected]>
44
*
55
* Permission to use, copy, modify, and/or distribute this software for any purpose with
66
* or without fee is hereby granted, provided that the above copyright notice and this
@@ -107,17 +107,27 @@ class TopLevelWidget : public Widget
107107
bool addIdleCallback(IdleCallback* callback, uint timerFrequencyInMs = 0);
108108
bool removeIdleCallback(IdleCallback* callback);
109109
double getScaleFactor() const noexcept;
110+
111+
void setGeometryConstraints(uint minimumWidth, uint minimumHeight, bool keepAspectRatio = false);
112+
113+
#if DGL_ALLOW_DEPRECATED_METHODS
114+
/** DEPRECATED DO NOT USE.
115+
* The old deprecated constructor allowed for an optional `bool automaticallyScaleAndSetAsMinimumSize`.
116+
* This turned out to be not be a good idea; now the scaling is done automatically while minimum size is not.
117+
*/
118+
DISTRHO_DEPRECATED_BY("setGeometryConstraints(uint, uint, bool)")
110119
void setGeometryConstraints(uint minimumWidth,
111120
uint minimumHeight,
112-
bool keepAspectRatio = false,
113-
bool automaticallyScale = false,
114-
bool resizeNowIfAutoScaling = true);
121+
bool keepAspectRatio,
122+
bool automaticallyScale,
123+
bool resizeNowIfAutoScaling);
115124

116125
DISTRHO_DEPRECATED_BY("getApp()")
117126
Application& getParentApp() const noexcept { return getApp(); }
118127

119128
DISTRHO_DEPRECATED_BY("getWindow()")
120129
Window& getParentWindow() const noexcept { return getWindow(); }
130+
#endif
121131

122132
protected:
123133
bool onKeyboard(const KeyboardEvent&) override;

dgl/Widget.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* DISTRHO Plugin Framework (DPF)
3-
* Copyright (C) 2012-2024 Filipe Coelho <[email protected]>
3+
* Copyright (C) 2012-2026 Filipe Coelho <[email protected]>
44
*
55
* Permission to use, copy, modify, and/or distribute this software for any purpose with
66
* or without fee is hereby granted, provided that the above copyright notice and this

dgl/Window.hpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* DISTRHO Plugin Framework (DPF)
3-
* Copyright (C) 2012-2025 Filipe Coelho <[email protected]>
3+
* Copyright (C) 2012-2026 Filipe Coelho <[email protected]>
44
*
55
* Permission to use, copy, modify, and/or distribute this software for any purpose with
66
* or without fee is hereby granted, provided that the above copyright notice and this
@@ -463,13 +463,23 @@ class DISTRHO_API Window
463463
Size<uint> getGeometryConstraints(bool& keepAspectRatio);
464464

465465
/**
466-
Set geometry constraints for the Window when resized by the user, and optionally scale contents automatically.
466+
Set geometry constraints for the Window when resized by the user.
467+
Also whether to keep aspect ratio based on this size.
467468
*/
469+
void setGeometryConstraints(uint minimumWidth, uint minimumHeight, bool keepAspectRatio = false);
470+
471+
#if DGL_ALLOW_DEPRECATED_METHODS
472+
/** DEPRECATED DO NOT USE.
473+
* The old deprecated function allowed for optional `bool automaticallyScale` and `bool resizeNowIfAutoScaling`.
474+
* This turned out to be not be a good idea; now the scaling on constraints is never done automatically.
475+
*/
476+
DISTRHO_DEPRECATED_BY("setGeometryConstraints(uint, uint, bool)")
468477
void setGeometryConstraints(uint minimumWidth,
469478
uint minimumHeight,
470-
bool keepAspectRatio = false,
471-
bool automaticallyScale = false,
472-
bool resizeNowIfAutoScaling = true);
479+
bool keepAspectRatio,
480+
bool automaticallyScale,
481+
bool resizeNowIfAutoScaling);
482+
#endif
473483

474484
/**
475485
Set the transient parent of the window.

dgl/src/Cairo.cpp

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* DISTRHO Plugin Framework (DPF)
3-
* Copyright (C) 2012-2025 Filipe Coelho <[email protected]>
43
* Copyright (C) 2019-2021 Jean Pierre Cimalando <[email protected]>
4+
* Copyright (C) 2012-2026 Filipe Coelho <[email protected]>
55
*
66
* Permission to use, copy, modify, and/or distribute this software for any purpose with
77
* or without fee is hereby granted, provided that the above copyright notice and this
@@ -736,7 +736,11 @@ template class ImageBaseSwitch<CairoImage>;
736736

737737
// -----------------------------------------------------------------------
738738

739-
void SubWidget::PrivateData::display(const uint width, const uint height, const double autoScaleFactor)
739+
void SubWidget::PrivateData::display(const uint width, const uint height
740+
#if DGL_ALLOW_DEPRECATED_METHODS
741+
, const double autoScaleFactor
742+
#endif
743+
)
740744
{
741745
cairo_t* const handle = static_cast<const CairoGraphicsContext&>(self->getGraphicsContext()).handle;
742746

@@ -754,10 +758,13 @@ void SubWidget::PrivateData::display(const uint width, const uint height, const
754758
{
755759
// full viewport size
756760
cairo_translate(handle, 0, 0);
761+
#if DGL_ALLOW_DEPRECATED_METHODS
757762
cairo_scale(handle, autoScaleFactor, autoScaleFactor);
763+
#endif
758764
}
759765
else
760766
{
767+
#if DGL_ALLOW_DEPRECATED_METHODS
761768
// set viewport pos
762769
cairo_translate(handle, absolutePos.getX() * autoScaleFactor, absolutePos.getY() * autoScaleFactor);
763770

@@ -767,12 +774,21 @@ void SubWidget::PrivateData::display(const uint width, const uint height, const
767774
0,
768775
std::round(self->getWidth() * autoScaleFactor),
769776
std::round(self->getHeight() * autoScaleFactor));
777+
#else
778+
// set viewport pos
779+
cairo_translate(handle, absolutePos.getX(), absolutePos.getY());
780+
781+
// then cut the outer bounds
782+
cairo_rectangle(handle, 0, 0, self->getWidth(), self->getHeight());
783+
#endif
770784

771785
cairo_clip(handle);
772786
needsResetClip = true;
773787

788+
#if DGL_ALLOW_DEPRECATED_METHODS
774789
// set viewport scaling
775790
cairo_scale(handle, autoScaleFactor, autoScaleFactor);
791+
#endif
776792
}
777793

778794
// display widget
@@ -783,7 +799,11 @@ void SubWidget::PrivateData::display(const uint width, const uint height, const
783799

784800
cairo_set_matrix(handle, &matrix);
785801

802+
#if DGL_ALLOW_DEPRECATED_METHODS
786803
selfw->pData->displaySubWidgets(width, height, autoScaleFactor);
804+
#else
805+
selfw->pData->displaySubWidgets(width, height);
806+
#endif
787807
}
788808

789809
// -----------------------------------------------------------------------
@@ -799,26 +819,34 @@ void TopLevelWidget::PrivateData::display()
799819
const uint width = size.getWidth();
800820
const uint height = size.getHeight();
801821

822+
#if DGL_ALLOW_DEPRECATED_METHODS
802823
const double autoScaleFactor = window.pData->autoScaleFactor;
824+
#endif
803825

804826
cairo_matrix_t matrix;
805827
cairo_get_matrix(handle, &matrix);
806828

807829
// full viewport size
808830
cairo_translate(handle, 0, 0);
809831

832+
#if DGL_ALLOW_DEPRECATED_METHODS
810833
if (window.pData->autoScaling)
811834
cairo_scale(handle, autoScaleFactor, autoScaleFactor);
812835
else
813836
cairo_scale(handle, 1.0, 1.0);
837+
#endif
814838

815839
// main widget drawing
816840
self->onDisplay();
817841

818842
cairo_set_matrix(handle, &matrix);
819843

820844
// now draw subwidgets if there are any
821-
selfw->pData->displaySubWidgets(width, height, autoScaleFactor);
845+
selfw->pData->displaySubWidgets(width, height
846+
#if DGL_ALLOW_DEPRECATED_METHODS
847+
, autoScaleFactor
848+
#endif
849+
);
822850
}
823851

824852
// -----------------------------------------------------------------------

dgl/src/ImageBaseWidgets.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* DISTRHO Plugin Framework (DPF)
3-
* Copyright (C) 2012-2022 Filipe Coelho <[email protected]>
3+
* Copyright (C) 2012-2026 Filipe Coelho <[email protected]>
44
*
55
* Permission to use, copy, modify, and/or distribute this software for any purpose with
66
* or without fee is hereby granted, provided that the above copyright notice and this
@@ -31,8 +31,9 @@ ImageBaseAboutWindow<ImageType>::ImageBaseAboutWindow(Window& transientParentWin
3131

3232
if (image.isValid())
3333
{
34-
setSize(image.getSize());
35-
setGeometryConstraints(image.getWidth(), image.getHeight(), true, true);
34+
const double scaleFactor = getScaleFactor();
35+
setSize(image.getSize() * scaleFactor);
36+
setGeometryConstraints(image.getWidth() * scaleFactor, image.getHeight() * scaleFactor, true);
3637
}
3738

3839
done();
@@ -48,8 +49,9 @@ ImageBaseAboutWindow<ImageType>::ImageBaseAboutWindow(TopLevelWidget* const topL
4849

4950
if (image.isValid())
5051
{
51-
setSize(image.getSize());
52-
setGeometryConstraints(image.getWidth(), image.getHeight(), true, true);
52+
const double scaleFactor = getScaleFactor();
53+
setSize(image.getSize() * scaleFactor);
54+
setGeometryConstraints(image.getWidth(), image.getHeight(), true);
5355
}
5456

5557
done();
@@ -71,8 +73,9 @@ void ImageBaseAboutWindow<ImageType>::setImage(const ImageType& image)
7173

7274
img = image;
7375

74-
setSize(image.getSize());
75-
setGeometryConstraints(image.getWidth(), image.getHeight(), true, true);
76+
const double scaleFactor = getScaleFactor();
77+
setSize(image.getSize() * scaleFactor);
78+
setGeometryConstraints(image.getWidth() * scaleFactor, image.getHeight() * scaleFactor, true);
7679

7780
done();
7881
}

dgl/src/OpenGL.cpp

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* DISTRHO Plugin Framework (DPF)
3-
* Copyright (C) 2012-2025 Filipe Coelho <[email protected]>
3+
* Copyright (C) 2012-2026 Filipe Coelho <[email protected]>
44
*
55
* Permission to use, copy, modify, and/or distribute this software for any purpose with
66
* 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<uint>& s, const GLe
157157

158158
// --------------------------------------------------------------------------------------------------------------------
159159

160-
void SubWidget::PrivateData::display(const uint width, const uint height, const double autoScaleFactor)
160+
void SubWidget::PrivateData::display(const uint width, const uint height
161+
#if DGL_ALLOW_DEPRECATED_METHODS
162+
, const double autoScaleFactor
163+
#endif
164+
)
161165
{
162166
if (skipDrawing)
163167
return;
@@ -191,6 +195,7 @@ void SubWidget::PrivateData::display(const uint width, const uint height, const
191195
}
192196
else
193197
{
198+
#if DGL_ALLOW_DEPRECATED_METHODS
194199
// set viewport pos
195200
glViewport(d_roundToIntPositive(absolutePos.getX() * autoScaleFactor),
196201
-d_roundToIntPositive(absolutePos.getY() * autoScaleFactor),
@@ -202,6 +207,16 @@ void SubWidget::PrivateData::display(const uint width, const uint height, const
202207
d_roundToIntPositive(height - (static_cast<int>(self->getHeight()) + absolutePos.getY()) * autoScaleFactor),
203208
d_roundToIntPositive(self->getWidth() * autoScaleFactor),
204209
d_roundToIntPositive(self->getHeight() * autoScaleFactor));
210+
#else
211+
// set viewport pos
212+
glViewport(absolutePos.getX(), -absolutePos.getY(), static_cast<int>(width), static_cast<int>(height));
213+
214+
// then cut the outer bounds
215+
glScissor(absolutePos.getX(),
216+
static_cast<int>(height) - self->getHeight() + absolutePos.getY(),
217+
static_cast<int>(self->getWidth()),
218+
static_cast<int>(self->getHeight()));
219+
#endif
205220

206221
glEnable(GL_SCISSOR_TEST);
207222
needsDisableScissor = true;
@@ -213,7 +228,11 @@ void SubWidget::PrivateData::display(const uint width, const uint height, const
213228
if (needsDisableScissor)
214229
glDisable(GL_SCISSOR_TEST);
215230

231+
#if DGL_ALLOW_DEPRECATED_METHODS
216232
selfw->pData->displaySubWidgets(width, height, autoScaleFactor);
233+
#else
234+
selfw->pData->displaySubWidgets(width, height);
235+
#endif
217236
}
218237

219238
// --------------------------------------------------------------------------------------------------------------------
@@ -234,7 +253,11 @@ void TopLevelWidget::PrivateData::display()
234253
self->onDisplay();
235254

236255
// now draw subwidgets if there are any
237-
selfw->pData->displaySubWidgets(width, height, window.pData->autoScaleFactor);
256+
selfw->pData->displaySubWidgets(width, height
257+
#if DGL_ALLOW_DEPRECATED_METHODS
258+
, window.pData->autoScaleFactor
259+
#endif
260+
);
238261
}
239262

240263
// --------------------------------------------------------------------------------------------------------------------

dgl/src/Stub.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* DISTRHO Plugin Framework (DPF)
3-
* Copyright (C) 2012-2025 Filipe Coelho <[email protected]>
3+
* Copyright (C) 2012-2026 Filipe Coelho <[email protected]>
44
*
55
* Permission to use, copy, modify, and/or distribute this software for any purpose with
66
* or without fee is hereby granted, provided that the above copyright notice and this
@@ -172,9 +172,15 @@ void Rectangle<T>::drawOutline()
172172

173173
// --------------------------------------------------------------------------------------------------------------------
174174

175+
#if DGL_ALLOW_DEPRECATED_METHODS
175176
void SubWidget::PrivateData::display(uint, uint, double)
176177
{
177178
}
179+
#else
180+
void SubWidget::PrivateData::display(uint, uint)
181+
{
182+
}
183+
#endif
178184

179185
// --------------------------------------------------------------------------------------------------------------------
180186

dgl/src/SubWidgetPrivateData.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* DISTRHO Plugin Framework (DPF)
3-
* Copyright (C) 2012-2021 Filipe Coelho <[email protected]>
3+
* Copyright (C) 2012-2026 Filipe Coelho <[email protected]>
44
*
55
* Permission to use, copy, modify, and/or distribute this software for any purpose with
66
* or without fee is hereby granted, provided that the above copyright notice and this
@@ -38,7 +38,11 @@ struct SubWidget::PrivateData {
3838
~PrivateData();
3939

4040
// NOTE display function is different depending on build type, must call displaySubWidgets at the end
41+
#if DGL_ALLOW_DEPRECATED_METHODS
4142
void display(uint width, uint height, double autoScaleFactor);
43+
#else
44+
void display(uint width, uint height);
45+
#endif
4246

4347
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PrivateData)
4448
};

0 commit comments

Comments
 (0)