Browse Source

Keep aspect ratio in example parameters UI

pull/250/head
falkTX 1 year ago
parent
commit
3f405e0b31
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
1 changed files with 13 additions and 11 deletions
  1. +13
    -11
      examples/Parameters/ExampleUIParameters.cpp

+ 13
- 11
examples/Parameters/ExampleUIParameters.cpp View File

@@ -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))
{


Loading…
Cancel
Save