DPF

DISTRHO Plugin Framework
Log | Files | Refs | Submodules | README | LICENSE

commit 3f405e0b312c3165d027b4e94a4c5a3fe38e85cb
parent f3a4f3f0b9a9af7cad85fe16caadad1570eababb
Author: falkTX <falktx@falktx.com>
Date:   Thu, 31 Dec 2020 09:26:08 +0000

Keep aspect ratio in example parameters UI

Diffstat:
Mexamples/Parameters/ExampleUIParameters.cpp | 24+++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/examples/Parameters/ExampleUIParameters.cpp b/examples/Parameters/ExampleUIParameters.cpp @@ -39,7 +39,7 @@ public: std::memset(fParamGrid, 0, sizeof(bool)*9); // TODO explain why this is here - setGeometryConstraints(128, 128, true); + setGeometryConstraints(128, 128, true, false); } protected: @@ -104,16 +104,17 @@ protected: { const uint width = getWidth(); const uint height = getHeight(); + const uint minwh = std::min(width, height); Rectangle<int> r; - r.setWidth(width/3 - 6); - r.setHeight(height/3 - 6); + r.setWidth(minwh/3 - 6); + r.setHeight(minwh/3 - 6); // draw left, center and right columns for (int i=0; i<3; ++i) { - r.setX(3 + i*width/3); + r.setX(3 + i*minwh/3); // top r.setY(3); @@ -126,7 +127,7 @@ protected: r.draw(); // middle - r.setY(3 + height/3); + r.setY(3 + minwh/3); if (fParamGrid[3+i]) glColor3f(0.8f, 0.5f, 0.3f); @@ -136,7 +137,7 @@ protected: r.draw(); // bottom - r.setY(3 + height*2/3); + r.setY(3 + minwh*2/3); if (fParamGrid[6+i]) glColor3f(0.8f, 0.5f, 0.3f); @@ -159,16 +160,17 @@ protected: const uint width = getWidth(); const uint height = getHeight(); + const uint minwh = std::min(width, height); Rectangle<int> r; - r.setWidth(width/3 - 6); - r.setHeight(height/3 - 6); + r.setWidth(minwh/3 - 6); + r.setHeight(minwh/3 - 6); // handle left, center and right columns for (int i=0; i<3; ++i) { - r.setX(3 + i*width/3); + r.setX(3 + i*minwh/3); // top r.setY(3); @@ -190,7 +192,7 @@ protected: } // middle - r.setY(3 + height/3); + r.setY(3 + minwh/3); if (r.contains(ev.pos)) { @@ -203,7 +205,7 @@ protected: } // bottom - r.setY(3 + height*2/3); + r.setY(3 + minwh*2/3); if (r.contains(ev.pos)) {