1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

FormSpec : Add an auto vertical scrollbar to the textarea

This commit is contained in:
adelcoding1 2017-02-18 11:40:37 -08:00 committed by Loic Blot
parent c830347a57
commit 9b8fa99fe3
No known key found for this signature in database
GPG key ID: EFAA458E8C153987
8 changed files with 1856 additions and 34 deletions

View file

@ -53,6 +53,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "util/string.h" // for parseColorString()
#include "irrlicht_changes/static_text.h"
#include "guiscalingfilter.h"
#include "guiEditBoxWithScrollbar.h"
#if USE_FREETYPE && IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR < 9
#include "intlGUIEditBox.h"
@ -1072,6 +1073,7 @@ void GUIFormSpecMenu::parseTextArea(parserData* data, std::vector<std::string>&
std::string name = parts[2];
std::string label = parts[3];
std::string default_val = parts[4];
bool has_vscrollbar = parts.size() > 5 ? is_yes(parts[5]) : false;
MY_CHECKPOS(type,0);
MY_CHECKGEOM(type,1);
@ -1114,29 +1116,31 @@ void GUIFormSpecMenu::parseTextArea(parserData* data, std::vector<std::string>&
258+m_fields.size()
);
if (name.empty()) {
// spec field id to 0, this stops submit searching for a value that isn't there
addStaticText(Environment, spec.flabel.c_str(), rect, false, true, this, spec.fid);
} else {
spec.send = true;
bool is_editable = !name.empty();
if (is_editable) {
spec.send = true;
}
gui::IGUIEditBox *e;
#if USE_FREETYPE && IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR < 9
if (g_settings->getBool("freetype")) {
e = (gui::IGUIEditBox *) new gui::intlGUIEditBox(spec.fdefault.c_str(),
true, Environment, this, spec.fid, rect);
e->drop();
} else {
if (g_settings->getBool("freetype")) {
e = (gui::IGUIEditBox *) new gui::intlGUIEditBox(spec.flabel.c_str(),
true, Environment, this, spec.fid, rect, is_editable, has_vscrollbar);
e->drop();
} else {
#else
{
{
#endif
e = Environment->addEditBox(spec.fdefault.c_str(), rect, true, this, spec.fid);
}
e = new GUIEditBoxWithScrollBar(spec.flabel.c_str(), true,
Environment, this, spec.fid, rect, is_editable, has_vscrollbar);
}
if (spec.fname == data->focused_fieldname) {
Environment->setFocus(e);
}
if (is_editable && spec.fname == data->focused_fieldname) {
Environment->setFocus(e);
}
if (e) {
if (type == "textarea")
{
e->setMultiLine(true);
@ -1152,9 +1156,9 @@ void GUIFormSpecMenu::parseTextArea(parserData* data, std::vector<std::string>&
evt.KeyInput.PressedDown = true;
e->OnEvent(evt);
}
if (label.length() >= 1)
{
}
if (is_editable) {
if (label.length() >= 1) {
int font_height = g_fontengine->getTextHeight();
rect.UpperLeftCorner.Y -= font_height;
rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + font_height;