aboutsummaryrefslogtreecommitdiffstats
path: root/src/menu
diff options
context:
space:
mode:
Diffstat (limited to 'src/menu')
-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
4 files changed, 28 insertions, 2 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);