From 4d12f969b8fa40497b60a6e15873b1b3af924dda Mon Sep 17 00:00:00 2001 From: Dees_Troy Date: Fri, 19 Oct 2012 13:13:15 -0400 Subject: Add ability for buttons to have highlights on touch --- gui/text.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'gui/text.cpp') diff --git a/gui/text.cpp b/gui/text.cpp index 90482fef3..dc7a2d119 100644 --- a/gui/text.cpp +++ b/gui/text.cpp @@ -38,12 +38,16 @@ GUIText::GUIText(xml_node<>* node) mFontHeight = 0; maxWidth = 0; charSkip = 0; + isHighlighted = false; + hasHighlightColor = false; if (!node) return; // Initialize color to solid black memset(&mColor, 0, sizeof(COLOR)); mColor.alpha = 255; + memset(&mHighlightColor, 0, sizeof(COLOR)); + mHighlightColor.alpha = 255; attr = node->first_attribute("color"); if (attr) @@ -51,6 +55,13 @@ GUIText::GUIText(xml_node<>* node) std::string color = attr->value(); ConvertStrToColor(color, &mColor); } + attr = node->first_attribute("highlightcolor"); + if (attr) + { + std::string color = attr->value(); + ConvertStrToColor(color, &mHighlightColor); + hasHighlightColor = true; + } // Load the font, and possibly override the color child = node->first_node("font"); @@ -65,6 +76,14 @@ GUIText::GUIText(xml_node<>* node) { std::string color = attr->value(); ConvertStrToColor(color, &mColor); + } + + attr = child->first_attribute("highlightcolor"); + if (attr) + { + std::string color = attr->value(); + ConvertStrToColor(color, &mHighlightColor); + hasHighlightColor = true; } } @@ -117,7 +136,10 @@ int GUIText::Render(void) y -= mFontHeight; } - gr_color(mColor.red, mColor.green, mColor.blue, mColor.alpha); + if (hasHighlightColor && isHighlighted) + gr_color(mHighlightColor.red, mHighlightColor.green, mHighlightColor.blue, mHighlightColor.alpha); + else + gr_color(mColor.red, mColor.green, mColor.blue, mColor.alpha); if (maxWidth) gr_textExW(x, y, displayValue.c_str(), fontResource, maxWidth + x); -- cgit v1.2.3