Revision: 522
http://cadcdev.svn.sourceforge.net/cadcdev/?rev=522&view=rev
Author: atani
Date: 2007-10-29 22:05:47 -0700 (Mon, 29 Oct 2007)
Log Message:
-----------
fixed vertical centering of the menubox/items based on position.
This was originally using the position as a start point rather than a center point.
Modified Paths:
--------------
tiki/src/gl/drawables/lightbarmenu.cpp
Modified: tiki/src/gl/drawables/lightbarmenu.cpp
===================================================================
--- tiki/src/gl/drawables/lightbarmenu.cpp 2007-10-30 00:26:20 UTC (rev 521)
+++ tiki/src/gl/drawables/lightbarmenu.cpp 2007-10-30 05:05:47 UTC (rev 522)
@@ -26,7 +26,11 @@
m_height = 0.0f;
m_width = 0.0f;
- float y = 10.0f;
+ Tiki::Debug::printf("Option list size: %d\n", options.size());
+ // the 2.0f here is to give some space between the border and the first options in the menu
+ float start_y = 2.0f + (m_borderSize * 2.0f) + (-25.0f * (options.size() / 2));
+ float y = start_y;
+ Tiki::Debug::printf("Starting Y: %04.4f\n", y);
for(std::list<std::string>::const_iterator iter = options.begin(); iter != options.end(); iter++)
{
float h, w;
@@ -50,7 +54,10 @@
subAdd(tempLabel);
y += 25.0f;
}
- m_height = (y - 10.0f) + (m_borderSize * 2);
+ Tiki::Debug::printf("Ending Y: %04.4f\n", y);
+ // the 4.0f here is to give some space between the border and the last options in the menu
+ m_height = ((start_y - y) * -1) + 4.0f;
+ Tiki::Debug::printf("Y size: %04.4f\n", m_height);
m_width += (m_borderSize * 2);
m_options.front()->setTint(m_colorSelected);
@@ -202,15 +209,15 @@
glBegin(GL_QUADS);
m_borderColor.select();
glBegin(GL_QUADS);
- glVertex3f(tv.x - m_width/2, tv.y, tv.z / 1000.0f);
- glVertex3f(tv.x + m_width/2, tv.y, tv.z / 1000.0f);
- glVertex3f(tv.x + m_width/2, tv.y + m_height, tv.z / 1000.0f);
- glVertex3f(tv.x - m_width/2, tv.y + m_height, tv.z / 1000.0f);
+ glVertex3f(tv.x - m_width/2, tv.y - m_height/2, tv.z / 1000.0f);
+ glVertex3f(tv.x + m_width/2, tv.y - m_height/2, tv.z / 1000.0f);
+ glVertex3f(tv.x + m_width/2, tv.y + m_height/2, tv.z / 1000.0f);
+ glVertex3f(tv.x - m_width/2, tv.y + m_height/2, tv.z / 1000.0f);
m_boxColor.select();
- glVertex3f(tv.x - (m_width - m_borderSize)/2, tv.y + m_borderSize, tv.z / 1000.0f);
- glVertex3f(tv.x + (m_width - m_borderSize)/2, tv.y + m_borderSize, tv.z / 1000.0f);
- glVertex3f(tv.x + (m_width - m_borderSize)/2, tv.y + (m_height - m_borderSize), tv.z / 1000.0f);
- glVertex3f(tv.x - (m_width - m_borderSize)/2, tv.y + (m_height - m_borderSize), tv.z / 1000.0f);
+ glVertex3f(tv.x - (m_width - m_borderSize)/2, tv.y + (m_borderSize - m_height)/2, tv.z / 1000.0f);
+ glVertex3f(tv.x + (m_width - m_borderSize)/2, tv.y + (m_borderSize - m_height)/2, tv.z / 1000.0f);
+ glVertex3f(tv.x + (m_width - m_borderSize)/2, tv.y + (m_height - m_borderSize)/2, tv.z / 1000.0f);
+ glVertex3f(tv.x - (m_width - m_borderSize)/2, tv.y + (m_height - m_borderSize)/2, tv.z / 1000.0f);
glEnd();
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|