commit af09cb0a1284337a2592d237caa9ac5a274ce059
parent d4e5a958c0f4f86980420ddcb8b5406a46b7d42a
Author: falkTX <falktx@gmail.com>
Date: Sat, 24 May 2014 01:46:25 +0100
Use Rectangle in NanoWidget::textBounds
Diffstat:
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/dgl/NanoWidget.hpp b/dgl/NanoWidget.hpp
@@ -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],
diff --git a/dgl/src/NanoWidget.cpp b/dgl/src/NanoWidget.cpp
@@ -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)