summaryrefslogtreecommitdiffstats
path: root/gui/text.cpp
diff options
context:
space:
mode:
authorthat <github@that.at>2015-02-14 20:23:16 +0100
committerthat <github@that.at>2015-02-15 20:36:40 +0100
commitf6ed8fc1f51e368bb76905d9f1d2d3735e70a644 (patch)
treeba66418d418869274d259ce35cca8d4021d8ce4e /gui/text.cpp
parentRetain and display previous selection for image flashing (diff)
downloadandroid_bootable_recovery-f6ed8fc1f51e368bb76905d9f1d2d3735e70a644.tar
android_bootable_recovery-f6ed8fc1f51e368bb76905d9f1d2d3735e70a644.tar.gz
android_bootable_recovery-f6ed8fc1f51e368bb76905d9f1d2d3735e70a644.tar.bz2
android_bootable_recovery-f6ed8fc1f51e368bb76905d9f1d2d3735e70a644.tar.lz
android_bootable_recovery-f6ed8fc1f51e368bb76905d9f1d2d3735e70a644.tar.xz
android_bootable_recovery-f6ed8fc1f51e368bb76905d9f1d2d3735e70a644.tar.zst
android_bootable_recovery-f6ed8fc1f51e368bb76905d9f1d2d3735e70a644.zip
Diffstat (limited to 'gui/text.cpp')
-rw-r--r--gui/text.cpp58
1 files changed, 10 insertions, 48 deletions
diff --git a/gui/text.cpp b/gui/text.cpp
index 29d7ad948..cc18b170f 100644
--- a/gui/text.cpp
+++ b/gui/text.cpp
@@ -28,9 +28,6 @@ extern "C" {
GUIText::GUIText(xml_node<>* node)
: GUIObject(node)
{
- xml_attribute<>* attr;
- xml_node<>* child;
-
mFont = NULL;
mIsStatic = 1;
mVarChanged = 0;
@@ -38,53 +35,21 @@ GUIText::GUIText(xml_node<>* node)
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)
- {
- 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 colors
+ mColor = LoadAttrColor(node, "color", COLOR(0,0,0,255));
+ mHighlightColor = LoadAttrColor(node, "highlightcolor", mColor);
// Load the font, and possibly override the color
- child = node->first_node("font");
+ xml_node<>* child = node->first_node("font");
if (child)
{
- attr = child->first_attribute("resource");
- if (attr)
- mFont = PageManager::FindResource(attr->value());
-
- attr = child->first_attribute("color");
- if (attr)
- {
- 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;
- }
+ mFont = LoadAttrFont(child, "resource");
+ mColor = LoadAttrColor(child, "color", mColor);
+ mHighlightColor = LoadAttrColor(child, "highlightcolor", mColor);
}
// Load the placement
@@ -97,8 +62,7 @@ GUIText::GUIText(xml_node<>* node)
mLastValue = parseText();
if (mLastValue != mText) mIsStatic = 0;
- mFontHeight = gr_getMaxFontHeight(mFont ? mFont->GetResource() : NULL);
- return;
+ mFontHeight = mFont->GetHeight();
}
int GUIText::Render(void)
@@ -107,13 +71,11 @@ int GUIText::Render(void)
return 0;
void* fontResource = NULL;
- string displayValue;
-
if (mFont)
fontResource = mFont->GetResource();
mLastValue = parseText();
- displayValue = mLastValue;
+ string displayValue = mLastValue;
if (charSkip)
displayValue.erase(0, charSkip);
@@ -138,7 +100,7 @@ int GUIText::Render(void)
y -= mFontHeight;
}
- if (hasHighlightColor && isHighlighted)
+ if (isHighlighted)
gr_color(mHighlightColor.red, mHighlightColor.green, mHighlightColor.blue, mHighlightColor.alpha);
else
gr_color(mColor.red, mColor.green, mColor.blue, mColor.alpha);