summaryrefslogtreecommitdiffstats
path: root/gui/text.cpp
diff options
context:
space:
mode:
authorEthan Yonker <dees_troy@teamw.in>2015-10-05 17:16:27 +0200
committerDees Troy <dees_troy@teamw.in>2015-10-16 22:57:35 +0200
commitb7a54a30167f211647222c0a2f90b369e0e33e32 (patch)
treefa6464e7a16456936de1cfaa087fcfc2f9564ff2 /gui/text.cpp
parentUnion sepolicy within TWRP to make SELinux permissive (diff)
downloadandroid_bootable_recovery-b7a54a30167f211647222c0a2f90b369e0e33e32.tar
android_bootable_recovery-b7a54a30167f211647222c0a2f90b369e0e33e32.tar.gz
android_bootable_recovery-b7a54a30167f211647222c0a2f90b369e0e33e32.tar.bz2
android_bootable_recovery-b7a54a30167f211647222c0a2f90b369e0e33e32.tar.lz
android_bootable_recovery-b7a54a30167f211647222c0a2f90b369e0e33e32.tar.xz
android_bootable_recovery-b7a54a30167f211647222c0a2f90b369e0e33e32.tar.zst
android_bootable_recovery-b7a54a30167f211647222c0a2f90b369e0e33e32.zip
Diffstat (limited to 'gui/text.cpp')
-rw-r--r--gui/text.cpp40
1 files changed, 21 insertions, 19 deletions
diff --git a/gui/text.cpp b/gui/text.cpp
index effb9359b..9898e2838 100644
--- a/gui/text.cpp
+++ b/gui/text.cpp
@@ -34,7 +34,9 @@ GUIText::GUIText(xml_node<>* node)
mFontHeight = 0;
maxWidth = 0;
charSkip = 0;
+ scaleWidth = true;
isHighlighted = false;
+ mText = "";
if (!node)
return;
@@ -54,6 +56,23 @@ GUIText::GUIText(xml_node<>* node)
xml_node<>* child = FindNode(node, "text");
if (child) mText = child->value();
+ child = FindNode(node, "noscaling");
+ if (child) {
+ scaleWidth = false;
+ } else {
+ if (mPlacement == TOP_LEFT || mPlacement == BOTTOM_LEFT) {
+ maxWidth = gr_fb_width() - mRenderX;
+ } else if (mPlacement == TOP_RIGHT || mPlacement == BOTTOM_RIGHT) {
+ maxWidth = mRenderX;
+ } else if (mPlacement == CENTER || mPlacement == CENTER_X_ONLY) {
+ if (mRenderX < gr_fb_width() / 2) {
+ maxWidth = mRenderX * 2;
+ } else {
+ maxWidth = (gr_fb_width() - mRenderX) * 2;
+ }
+ }
+ }
+
// Simple way to check for static state
mLastValue = gui_parse_text(mText);
if (mLastValue != mText) mIsStatic = 0;
@@ -81,30 +100,13 @@ int GUIText::Render(void)
int x = mRenderX, y = mRenderY;
int width = gr_measureEx(displayValue.c_str(), fontResource);
- if (mPlacement != TOP_LEFT && mPlacement != BOTTOM_LEFT)
- {
- if (mPlacement == CENTER || mPlacement == CENTER_X_ONLY)
- x -= (width / 2);
- else
- x -= width;
- }
- if (mPlacement != TOP_LEFT && mPlacement != TOP_RIGHT)
- {
- if (mPlacement == CENTER)
- y -= (mFontHeight / 2);
- else if (mPlacement == BOTTOM_LEFT || mPlacement == BOTTOM_RIGHT)
- y -= mFontHeight;
- }
-
if (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);
- else
- gr_textEx(x, y, displayValue.c_str(), fontResource);
+ gr_textEx_scaleW(mRenderX, mRenderY, displayValue.c_str(), fontResource, maxWidth, mPlacement, scaleWidth);
+
return 0;
}