aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2012-04-09 18:09:28 +0200
committerAlexander Sulfrian <alexander@sulfrian.net>2013-01-13 22:40:52 +0100
commit3ec8616aa76390280c7b51696b731a85e070de0f (patch)
treea1f399d1022a39bc2cc03d735b0450756928b0e3 /src
parent2435e76db6611d9797f607daff321bb6d2bd2322 (diff)
downloadusdx-3ec8616aa76390280c7b51696b731a85e070de0f.tar.gz
usdx-3ec8616aa76390280c7b51696b731a85e070de0f.tar.xz
usdx-3ec8616aa76390280c7b51696b731a85e070de0f.zip
utils/rectangle: removed external constructors and added helper
constructors that generate a rectangle from GLint[4] or FTBBox are now helper functions to remove the external dependencies from the helper class
Diffstat (limited to '')
-rw-r--r--src/menu/clipping_helper.cpp8
-rw-r--r--src/menu/clipping_helper.hpp6
-rw-r--r--src/menu/text.cpp9
-rw-r--r--src/menu/text.hpp7
-rw-r--r--src/utils/rectangle.hpp14
5 files changed, 28 insertions, 16 deletions
diff --git a/src/menu/clipping_helper.cpp b/src/menu/clipping_helper.cpp
index e12823cc..3f6bc4cd 100644
--- a/src/menu/clipping_helper.cpp
+++ b/src/menu/clipping_helper.cpp
@@ -31,6 +31,12 @@ namespace usdx
log4cpp::Category& ClippingHelper::log =
log4cpp::Category::getInstance("usdx.menu.clipping_helper");
+ Rectangle<int> ClippingHelper::makeRect(GLint box[4])
+ {
+ return Rectangle<int>(Point<int>(box[0], box[1]),
+ Point<int>(box[0] + box[2], box[1] + box[3]));
+ }
+
ClippingHelper::ClippingHelper(const Rectangle<int> &rect)
{
was_enabled = glIsEnabled(GL_SCISSOR_TEST);
@@ -40,7 +46,7 @@ namespace usdx
if (was_enabled) {
glGetIntegerv(GL_SCISSOR_BOX, scissor_box);
- new_scissor_box = rect.intersect(Rectangle<int>(scissor_box));
+ new_scissor_box = new_scissor_box.intersect(makeRect(scissor_box));
}
log << log4cpp::Priority::DEBUG << "Clipping ("
diff --git a/src/menu/clipping_helper.hpp b/src/menu/clipping_helper.hpp
index 119cc3c2..0435f01f 100644
--- a/src/menu/clipping_helper.hpp
+++ b/src/menu/clipping_helper.hpp
@@ -42,6 +42,12 @@ namespace usdx
GLboolean was_enabled;
GLint scissor_box[4];
+ /**
+ * Helper to create a Rectangle<int> object out of an GLint array. This
+ * array is returned by glGetIntegerv with GL_SCISSOR_BOX. The helper is
+ * used for converting the OpenGL array to the common internal format.
+ */
+ static Rectangle<int> makeRect(GLint box[4]);
public:
ClippingHelper(const Rectangle<int>&);
virtual ~ClippingHelper();
diff --git a/src/menu/text.cpp b/src/menu/text.cpp
index 39df2e06..884809c9 100644
--- a/src/menu/text.cpp
+++ b/src/menu/text.cpp
@@ -62,9 +62,16 @@ namespace usdx
}
}
+ Rectangle<int> Text::makeRect(const FTBBox& bbox)
+ {
+ return Rectangle<int>(Point<int>(bbox.Upper().X(), bbox.Upper().Y()),
+ Point<int>(bbox.Lower().X(), bbox.Lower().Y()));
+ }
+
+
void Text::realign(void)
{
- Rectangle<int> bbox(font->BBox(text.c_str()));
+ Rectangle<int> bbox = makeRect(font->BBox(text.c_str()));
bbox.get_point1().set_y(font->Ascender());
bbox.get_point2().set_y(font->Descender());
valign->align(offset, bbox, get_size());
diff --git a/src/menu/text.hpp b/src/menu/text.hpp
index b172b2c3..cb8e8dc4 100644
--- a/src/menu/text.hpp
+++ b/src/menu/text.hpp
@@ -83,6 +83,13 @@ namespace usdx
*/
void realign(void);
+ /**
+ * Helper to create a Rectangle<int> object out of an FTBBox. This is
+ * used for converting the BBox from ftgl to the common internal format.
+ */
+ static Rectangle<int> makeRect(const FTBBox& bbox);
+
+
protected:
virtual void draw(void);
diff --git a/src/utils/rectangle.hpp b/src/utils/rectangle.hpp
index f3f4477d..b1e67ba8 100644
--- a/src/utils/rectangle.hpp
+++ b/src/utils/rectangle.hpp
@@ -27,8 +27,6 @@
#ifndef RECTANGLE_HPP
#define RECTANGLE_HPP
-#include <ftgl.h>
-
#include "point.hpp"
#include "dimension.hpp"
#include "math.hpp"
@@ -66,18 +64,6 @@ namespace usdx
{
}
- Rectangle(const T rectangle[]) :
- point1(rectangle[0], rectangle[1]),
- point2(rectangle[0] + rectangle[2], rectangle[1] + rectangle[3])
- {
- }
-
- Rectangle(const FTBBox& bbox) :
- point1((T)bbox.Upper().X(), (T)bbox.Upper().Y()),
- point2((T)bbox.Lower().X(), (T)bbox.Lower().Y())
- {
- }
-
Rectangle(const Rectangle<T>& rectangle) :
point1(rectangle.point1), point2(rectangle.point2)
{