info window

This commit is contained in:
Eduardo Bart
2011-04-16 21:36:58 -03:00
parent c5da620d59
commit 9dfb33f2ed
26 changed files with 267 additions and 97 deletions

View File

@@ -80,18 +80,16 @@ void BorderedImage::setTexCoords(const Rect& left,
void BorderedImage::draw(const Rect& screenCoords)
{
// check minumim size
if(screenCoords.size() <= m_cornersSize)
return;
Rect rectCoords;
Size centerSize = screenCoords.size() - m_cornersSize;
// first the center
rectCoords = Rect(screenCoords.left() + m_leftBorderTexCoords.width(),
screenCoords.top() + m_topBorderTexCoords.height(),
centerSize);
g_graphics.drawRepeatedTexturedRect(rectCoords, m_texture, m_centerTexCoords);
if(centerSize.area() > 0) {
rectCoords = Rect(screenCoords.left() + m_leftBorderTexCoords.width(),
screenCoords.top() + m_topBorderTexCoords.height(),
centerSize);
g_graphics.drawRepeatedTexturedRect(rectCoords, m_texture, m_centerTexCoords);
}
// top left corner
rectCoords = Rect(screenCoords.topLeft(),

View File

@@ -223,7 +223,7 @@ const std::vector<Point>& Font::calculateGlyphsPositions(const std::string& text
return glyphsPositions;
}
// resize glyphsPositions vector, if needed
// resize glyphsPositions vector when needed
if(textLength > (int)glyphsPositions.size())
glyphsPositions.resize(textLength);
@@ -250,9 +250,6 @@ const std::vector<Point>& Font::calculateGlyphsPositions(const std::string& text
for(i = 0; i < textLength; ++i) {
glyph = (uchar)text[i];
// store current glyph topLeft
glyphsPositions[i] = virtualPos;
// new line or first glyph
if(glyph == (uchar)'\n' || i == 0) {
if(glyph == (uchar)'\n') {
@@ -270,6 +267,9 @@ const std::vector<Point>& Font::calculateGlyphsPositions(const std::string& text
}
}
// store current glyph topLeft
glyphsPositions[i] = virtualPos;
// render only if the glyph is valid
if(glyph >= 32 && glyph != (uchar)'\n') {
virtualPos.x += m_glyphsSize[glyph].width() + m_glyphSpacing.width();
@@ -278,7 +278,7 @@ const std::vector<Point>& Font::calculateGlyphsPositions(const std::string& text
if(textBoxSize) {
textBoxSize->setWidth(maxLineWidth);
textBoxSize->setHeight(virtualPos.y + m_glyphHeight);
textBoxSize->setHeight(virtualPos.y + m_glyphHeight + m_glyphSpacing.height());
}
return glyphsPositions;

View File

@@ -139,7 +139,7 @@ void Graphics::disableDrawing()
void Graphics::drawTexturedRect(const Rect& screenCoords, const TexturePtr& texture, const Rect& textureCoords, const Color& color)
{
if(screenCoords.isEmpty())
if(screenCoords.isEmpty() || textureCoords.isEmpty())
return;
// rect correction for opengl
@@ -170,7 +170,7 @@ void Graphics::drawTexturedRect(const Rect& screenCoords, const TexturePtr& text
void Graphics::drawRepeatedTexturedRect(const Rect& screenCoords, const TexturePtr& texture, const Rect& textureCoords, const Color& color)
{
if(screenCoords.isEmpty())
if(screenCoords.isEmpty() || textureCoords.isEmpty())
return;
// render many repeated texture rects

View File

@@ -293,7 +293,7 @@ void TextArea::appendCharacter(char c)
void TextArea::removeCharacter(bool right)
{
if(m_cursorPos >= 0) {
if(m_cursorPos >= 0 && m_text.length() > 0) {
if(right && (uint)m_cursorPos < m_text.length())
m_text.erase(m_text.begin() + m_cursorPos);
else if((uint)m_cursorPos == m_text.length()) {