Files
android_vendor_pawlet/recovery_ui/gui/textbox.cpp
T
oxmc f6176009b1 Add recovery_ui and recovery_toolkit scaffolding (first draft, not build-tested)
Stages TWRP's GUI engine and standalone tooling as PawletOS-owned modules
instead of a bootable/recovery fork, per the plugin-architecture finding in
NOTES-ota-recovery-ab.md: stock recovery_main.cpp already dlopen()s
librecovery_ui_ext.so and dlsym()s make_device() from it at runtime, so the
UI layer doesn't require touching stock bootable/recovery at all. Confirmed
via source grep that recovery.cpp/install.cpp have zero references into the
partition manager/backup engine/GUI code and vice versa.

recovery_ui/: TWRP's gui/, minuitwrp/, libpixelflinger/ (copied verbatim,
GPL-3.0), plus a new device/ providing PawletTwrpUI (a ScreenRecoveryUI
subclass) and make_device() — written from scratch against stock's
RecoveryUI/ScreenRecoveryUI virtual-method contract, since TWRP's own fork
never ships a make_device() (every real TWRP device provides its own, and
no reference device tree was available to copy from). Top-level Android.bp
defines librecovery_ui_pawlet_twrp, the module TARGET_RECOVERY_UI_LIB should
point at. gui/Android.bp and minuitwrp/Android.bp had their include_dirs
rewritten for the new paths.

recovery_toolkit/: partition manager, backup engine (tar/digest/adbbu/apex),
filesystem/format support (exfat/dosfstools/gpt/fuse/mtp/crypto), scripting
(openrecoveryscript/orscmd/twrpinstall), shared helpers. Source only, no
Android.bp yet for any of it.

Known gap blocking recovery_ui from actually linking: gui/'s libguitwrp
depends on libaosprecovery, built from recovery_toolkit/helpers/twrp.cpp via
a Go Soong plugin (libaosprecovery_defaults.go) not yet ported. Neither repo
has been build-tested — no local AOSP build environment available in this
workspace. See each directory's README.md for a precise done/not-done
breakdown.
2026-07-11 16:34:35 -07:00

124 lines
3.3 KiB
C++

/*
Copyright 2015 bigbiff/Dees_Troy/_that 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/>.
*/
// textbox.cpp - GUITextBox object
#include <string>
extern "C" {
#include "../twcommon.h"
}
#include "minuitwrp/minui.h"
#include "rapidxml.hpp"
#include "objects.hpp"
GUITextBox::GUITextBox(xml_node<>* node) : GUIScrollList(node)
{
xml_node<>* child;
mLastCount = 0;
mIsStatic = true;
allowSelection = false; // textbox doesn't support list item selections
child = FindNode(node, "color");
if (child)
{
mFontColor = LoadAttrColor(child, "foreground", mFontColor);
mBackgroundColor = LoadAttrColor(child, "background", mBackgroundColor);
//mScrollColor = LoadAttrColor(child, "scroll", mScrollColor);
}
child = FindNode(node, "text");
while (child) {
string txt = child->value();
mText.push_back(txt);
string lookup = gui_parse_text(txt);
if (lookup != txt)
mIsStatic = false;
mLastValue.push_back(lookup);
child = child->next_sibling("text");
}
}
int GUITextBox::Update(void)
{
if (AddLines(&mLastValue, NULL, &mLastCount, &rText, NULL)) {
// someone added new text
// at least the scrollbar must be updated, even if the new lines are currently not visible
mUpdate = 1;
}
GUIScrollList::Update();
if (mUpdate) {
mUpdate = 0;
if (Render() == 0)
return 2;
}
return 0;
}
size_t GUITextBox::GetItemCount()
{
return rText.size();
}
void GUITextBox::RenderItem(size_t itemindex, int yPos, bool selected __unused)
{
if (!mFont || !mFont->GetResource())
return;
// Set the color for the font
gr_color(mFontColor.red, mFontColor.green, mFontColor.blue, mFontColor.alpha);
// render text
const char* text = rText[itemindex].c_str();
gr_textEx_scaleW(mRenderX, yPos, text, mFont->GetResource(), mRenderW, TOP_LEFT, 0);
}
void GUITextBox::NotifySelect(size_t item_selected __unused)
{
// do nothing - textbox ignores selections
}
int GUITextBox::NotifyVarChange(const std::string& varName, const std::string& value)
{
GUIScrollList::NotifyVarChange(varName, value);
if (!isConditionTrue() || mIsStatic)
return 0;
// Check to see if the variable exists in mText
for (size_t i = 0; i < mText.size(); i++) {
string lookup = gui_parse_text(mText.at(i));
if (lookup != mText.at(i)) {
mLastValue.at(i) = lookup;
mUpdate = 1;
// There are ways to improve efficiency here, but I am not
// sure if we will even use this feature in the stock theme
// at all except for language translation. If we start using
// variables in textboxes in the stock theme, we can circle
// back and make improvements here.
mLastCount = 0;
rText.clear();
}
}
return 0;
}