From 39a70ce9e7444d842a827b11cfbe8d2fb32629ca Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 30 Apr 2013 11:06:23 -0700 Subject: [PATCH] Rather than Xs, use a "solid block" pseudo-character to draw a bar. Tweaked the colors to indicate the pressed key again. --- interface/src/Avatar.cpp | 3 ++- interface/src/main.cpp | 3 ++- interface/src/ui/TextRenderer.cpp | 17 +++++++++++------ interface/src/ui/TextRenderer.h | 3 +++ 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/interface/src/Avatar.cpp b/interface/src/Avatar.cpp index 889a158324..6ce3276553 100644 --- a/interface/src/Avatar.cpp +++ b/interface/src/Avatar.cpp @@ -736,7 +736,7 @@ void Avatar::render(bool lookingInMirror) { glTranslatef(_position.x, _position.y + chatMessageHeight, _position.z); glRotatef(atan2(-modelview[2], -modelview[10]) * 180 / PI, 0, 1, 0); - glColor3f(0, 1, 0); + glColor3f(0, 0.8, 0); glRotatef(180, 0, 0, 1); glScalef(chatMessageScale, chatMessageScale, 1.0f); @@ -752,6 +752,7 @@ void Avatar::render(bool lookingInMirror) { _chatMessage[lastIndex] = '\0'; textRenderer()->draw(-width/2, 0, _chatMessage.c_str()); _chatMessage[lastIndex] = lastChar; + glColor3f(0, 1, 0); textRenderer()->draw(width/2 - lastWidth, 0, _chatMessage.c_str() + lastIndex); } glEnable(GL_LIGHTING); diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 1b52194d8d..634b883e08 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -65,6 +65,7 @@ #include "ui/MenuRow.h" #include "ui/MenuColumn.h" #include "ui/Menu.h" +#include "ui/TextRenderer.h" #include "Camera.h" #include "Avatar.h" @@ -1333,7 +1334,7 @@ void key(unsigned char k, int x, int y) if (chatEntry.key(k)) { myAvatar.setKeyState(k == '\b' || k == 127 ? // backspace or delete DELETE_KEY_DOWN : INSERT_KEY_DOWN); - myAvatar.setChatMessage(string(chatEntry.getContents().size(), 'X')); + myAvatar.setChatMessage(string(chatEntry.getContents().size(), SOLID_BLOCK_CHAR)); } else { myAvatar.setChatMessage(chatEntry.getContents()); diff --git a/interface/src/ui/TextRenderer.cpp b/interface/src/ui/TextRenderer.cpp index 38f72aec0d..5780c59ec1 100644 --- a/interface/src/ui/TextRenderer.cpp +++ b/interface/src/ui/TextRenderer.cpp @@ -89,9 +89,11 @@ const Glyph& TextRenderer::getGlyph(char c) { if (glyph.isValid()) { return glyph; } - QRect bounds = _metrics.boundingRect(c); + // we use 'J' as a representative size for the solid block character + QChar ch = (c == SOLID_BLOCK_CHAR) ? QChar('J') : QChar(c); + QRect bounds = _metrics.boundingRect(ch); if (bounds.isEmpty()) { - glyph = Glyph(0, QPoint(), QRect(), _metrics.width(c)); + glyph = Glyph(0, QPoint(), QRect(), _metrics.width(ch)); return glyph; } @@ -116,16 +118,19 @@ const Glyph& TextRenderer::getGlyph(char c) { } // render the glyph into an image and copy it into the texture QImage image(bounds.width(), bounds.height(), QImage::Format_ARGB32); - image.fill(0); - { + if (c == SOLID_BLOCK_CHAR) { + image.fill(QColor(255, 255, 255)); + + } else { + image.fill(0); QPainter painter(&image); painter.setFont(_font); painter.setPen(QColor(255, 255, 255)); - painter.drawText(-bounds.x(), -bounds.y(), QChar(c)); + painter.drawText(-bounds.x(), -bounds.y(), ch); } glTexSubImage2D(GL_TEXTURE_2D, 0, _x, _y, bounds.width(), bounds.height(), GL_RGBA, GL_UNSIGNED_BYTE, image.constBits()); - glyph = Glyph(_currentTextureID, QPoint(_x, _y), bounds, _metrics.width(c)); + glyph = Glyph(_currentTextureID, QPoint(_x, _y), bounds, _metrics.width(ch)); _x += bounds.width(); _rowHeight = qMax(_rowHeight, bounds.height()); diff --git a/interface/src/ui/TextRenderer.h b/interface/src/ui/TextRenderer.h index 636bcd8e73..6de0c77bad 100644 --- a/interface/src/ui/TextRenderer.h +++ b/interface/src/ui/TextRenderer.h @@ -15,6 +15,9 @@ #include #include +// a special "character" that renders as a solid block +const char SOLID_BLOCK_CHAR = 127; + class Glyph; class TextRenderer {