Improve input box text handling
Change-Id: I79cfaac1adf85d1ee5514bf5266930823c1a15ff
This commit is contained in:
+24
-11
@@ -1,3 +1,21 @@
|
||||
/*
|
||||
Copyright 2012 to 2016 bigbiff/Dees_Troy TeamWin
|
||||
This file is part of TWRP/TeamWin Recovery Project.
|
||||
|
||||
TWRP is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
TWRP is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with TWRP. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// text.cpp - GUIText object
|
||||
|
||||
#include <stdarg.h>
|
||||
@@ -33,7 +51,6 @@ GUIText::GUIText(xml_node<>* node)
|
||||
mVarChanged = 0;
|
||||
mFontHeight = 0;
|
||||
maxWidth = 0;
|
||||
charSkip = 0;
|
||||
scaleWidth = true;
|
||||
isHighlighted = false;
|
||||
mText = "";
|
||||
@@ -94,22 +111,18 @@ int GUIText::Render(void)
|
||||
return -1;
|
||||
|
||||
mLastValue = gui_parse_text(mText);
|
||||
string displayValue = mLastValue;
|
||||
|
||||
if (charSkip)
|
||||
displayValue.erase(0, charSkip);
|
||||
|
||||
mVarChanged = 0;
|
||||
|
||||
int x = mRenderX, y = mRenderY;
|
||||
int width = gr_ttf_measureEx(displayValue.c_str(), fontResource);
|
||||
int width = gr_ttf_measureEx(mLastValue.c_str(), fontResource);
|
||||
|
||||
if (isHighlighted)
|
||||
gr_color(mHighlightColor.red, mHighlightColor.green, mHighlightColor.blue, mHighlightColor.alpha);
|
||||
else
|
||||
gr_color(mColor.red, mColor.green, mColor.blue, mColor.alpha);
|
||||
|
||||
gr_textEx_scaleW(mRenderX, mRenderY, displayValue.c_str(), fontResource, maxWidth, mPlacement, scaleWidth);
|
||||
gr_textEx_scaleW(mRenderX, mRenderY, mLastValue.c_str(), fontResource, maxWidth, mPlacement, scaleWidth);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -164,13 +177,13 @@ int GUIText::NotifyVarChange(const std::string& varName, const std::string& valu
|
||||
int GUIText::SetMaxWidth(unsigned width)
|
||||
{
|
||||
maxWidth = width;
|
||||
if (!maxWidth)
|
||||
scaleWidth = false;
|
||||
mVarChanged = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int GUIText::SkipCharCount(unsigned skip)
|
||||
void GUIText::SetText(string newtext)
|
||||
{
|
||||
charSkip = skip;
|
||||
mVarChanged = 1;
|
||||
return 0;
|
||||
mText = newtext;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user