mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-06 13:45:34 +00:00
Merge branch 'autosize_singleline_edit' into 'master'
Lua UI: Enable autoSize for single line text edit See merge request OpenMW/openmw!2002
This commit is contained in:
commit
f47e64b0f8
4 changed files with 9 additions and 6 deletions
|
@ -29,12 +29,13 @@ namespace LuaUi
|
||||||
Alignment vertical(propertyValue("textAlignV", Alignment::Start));
|
Alignment vertical(propertyValue("textAlignV", Alignment::Start));
|
||||||
mEditBox->setTextAlign(alignmentToMyGui(horizontal, vertical));
|
mEditBox->setTextAlign(alignmentToMyGui(horizontal, vertical));
|
||||||
|
|
||||||
mEditBox->setEditMultiLine(propertyValue("multiline", false));
|
mMultiline = propertyValue("multiline", false);
|
||||||
|
mEditBox->setEditMultiLine(mMultiline);
|
||||||
|
|
||||||
bool readOnly = propertyValue("readOnly", false);
|
bool readOnly = propertyValue("readOnly", false);
|
||||||
mEditBox->setEditStatic(readOnly);
|
mEditBox->setEditStatic(readOnly);
|
||||||
|
|
||||||
mAutoSize = readOnly && propertyValue("autoSize", false);
|
mAutoSize = (readOnly || !mMultiline) && propertyValue("autoSize", false);
|
||||||
|
|
||||||
// change caption last, for multiline and wordwrap to apply
|
// change caption last, for multiline and wordwrap to apply
|
||||||
mEditBox->setCaption(propertyValue("text", std::string()));
|
mEditBox->setCaption(propertyValue("text", std::string()));
|
||||||
|
@ -67,8 +68,8 @@ namespace LuaUi
|
||||||
if (mAutoSize)
|
if (mAutoSize)
|
||||||
{
|
{
|
||||||
mEditBox->setSize(normalSize);
|
mEditBox->setSize(normalSize);
|
||||||
MyGUI::IntSize textSize = mEditBox->getTextSize();
|
int targetHeight = mMultiline ? mEditBox->getTextSize().height : mEditBox->getFontHeight();
|
||||||
normalSize.height = std::max(normalSize.height, textSize.height);
|
normalSize.height = std::max(normalSize.height, targetHeight);
|
||||||
}
|
}
|
||||||
return normalSize;
|
return normalSize;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ namespace LuaUi
|
||||||
void textChange(MyGUI::EditBox*);
|
void textChange(MyGUI::EditBox*);
|
||||||
|
|
||||||
MyGUI::EditBox* mEditBox = nullptr;
|
MyGUI::EditBox* mEditBox = nullptr;
|
||||||
|
bool mMultiline;
|
||||||
bool mAutoSize;
|
bool mAutoSize;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ Properties
|
||||||
* - autoSize
|
* - autoSize
|
||||||
- boolean (false)
|
- boolean (false)
|
||||||
- | Automatically changes widget height to fix all the text.
|
- | Automatically changes widget height to fix all the text.
|
||||||
| Only applies for readOnly = true.
|
| Only applies when readOnly = true or multiline = false.
|
||||||
|
|
||||||
Events
|
Events
|
||||||
------
|
------
|
||||||
|
|
|
@ -7,7 +7,8 @@ return function(templates)
|
||||||
templates.textEditLine = {
|
templates.textEditLine = {
|
||||||
type = ui.TYPE.TextEdit,
|
type = ui.TYPE.TextEdit,
|
||||||
props = {
|
props = {
|
||||||
size = util.vector2(150, constants.textNormalSize),
|
size = util.vector2(150, 0),
|
||||||
|
autoSize = true,
|
||||||
textSize = constants.textNormalSize,
|
textSize = constants.textNormalSize,
|
||||||
textColor = constants.normalColor,
|
textColor = constants.normalColor,
|
||||||
multiline = false,
|
multiline = false,
|
||||||
|
|
Loading…
Reference in a new issue