Browse Source

Use Rectangle in NanoWidget::textBounds

gh-pages
falkTX 9 years ago
parent
commit
af09cb0a12
2 changed files with 7 additions and 5 deletions
  1. +2
    -3
      dgl/NanoWidget.hpp
  2. +5
    -2
      dgl/src/NanoWidget.cpp

+ 2
- 3
dgl/NanoWidget.hpp View File

@@ -709,12 +709,11 @@ protected:
void textBox(float x, float y, float breakRowWidth, const char* string, const char* end);

/**
Measures the specified text string. Parameter bounds should be a pointer to float[4],
if the bounding box of the text should be returned. The bounds value are [xmin,ymin, xmax,ymax]
Measures the specified text string. The bounds value are [xmin,ymin, xmax,ymax].
Returns the horizontal advance of the measured text (i.e. where the next character should drawn).
Measured values are returned in local coordinate space.
*/
float textBounds(float x, float y, const char* string, const char* end, float* bounds);
float textBounds(float x, float y, const char* string, const char* end, Rectangle<float>& bounds);

/**
Measures the specified multi-text string. Parameter bounds should be a pointer to float[4],


+ 5
- 2
dgl/src/NanoWidget.cpp View File

@@ -544,9 +544,12 @@ void NanoWidget::textBox(float x, float y, float breakRowWidth, const char* stri
nvgTextBox(fContext, x, y, breakRowWidth, string, end);
}

float NanoWidget::textBounds(float x, float y, const char* string, const char* end, float* bounds)
float NanoWidget::textBounds(float x, float y, const char* string, const char* end, Rectangle<float>& bounds)
{
return nvgTextBounds(fContext, x, y, string, end, bounds);
float b[4];
const float ret = nvgTextBounds(fContext, x, y, string, end, b);
bounds = Rectangle<float>(b[0], b[1], b[2], b[3]);
return ret;
}

void NanoWidget::textBoxBounds(float x, float y, float breakRowWidth, const char* string, const char* end, float* bounds)


Loading…
Cancel
Save