From 191c533ad2124cf9d9e0849fe5b588f20b7b67aa Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Thu, 16 May 2013 14:24:18 -0700 Subject: [PATCH] Provide a gray background for the chat entry, so that we can see what we're typing. --- interface/src/ui/ChatEntry.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/interface/src/ui/ChatEntry.cpp b/interface/src/ui/ChatEntry.cpp index ad4cf70ab0..588c394eb1 100644 --- a/interface/src/ui/ChatEntry.cpp +++ b/interface/src/ui/ChatEntry.cpp @@ -13,7 +13,7 @@ using namespace std; -const int MAX_CONTENT_LENGTH = 140; +const int MAX_CONTENT_LENGTH = 80; ChatEntry::ChatEntry() : _cursorPos(0) { } @@ -65,7 +65,7 @@ bool ChatEntry::keyPressEvent(QKeyEvent* event) { event->ignore(); return true; } - if (_contents.size() != MAX_CONTENT_LENGTH) { + if (_contents.size() < MAX_CONTENT_LENGTH) { _contents.insert(_cursorPos, 1, text.at(0).toAscii()); _cursorPos++; } @@ -74,7 +74,19 @@ bool ChatEntry::keyPressEvent(QKeyEvent* event) { } void ChatEntry::render(int screenWidth, int screenHeight) { - drawtext(20, screenHeight - 150, 0.10, 0, 1.0, 0, _contents.c_str(), 1, 1, 1); + // draw a gray background so that we can actually see what we're typing + int bottom = screenHeight - 150, top = screenHeight - 165; + int left = 20, right = left + 600; + + glColor3f(0.2f, 0.2f, 0.2f); + glBegin(GL_QUADS); + glVertex2f(left - 5, bottom + 7); + glVertex2f(right + 5, bottom + 7); + glVertex2f(right + 5, top - 3); + glVertex2f(left - 5, top - 3); + glEnd(); + + drawtext(left, bottom, 0.10, 0, 1.0, 0, _contents.c_str(), 1, 1, 1); float width = 0; for (string::iterator it = _contents.begin(), end = it + _cursorPos; it != end; it++) { @@ -82,7 +94,7 @@ void ChatEntry::render(int screenWidth, int screenHeight) { } glDisable(GL_LINE_SMOOTH); glBegin(GL_LINE_STRIP); - glVertex2f(20 + width, screenHeight - 165); - glVertex2f(20 + width, screenHeight - 150); + glVertex2f(left + width, top + 2); + glVertex2f(left + width, bottom + 2); glEnd(); }