mirror of https://github.com/OpenMW/openmw.git
Update and document Lua Text and TextEdit widget types, fix some issues with Lua UI
parent
7f4d4c0d70
commit
581c3f4882
@ -0,0 +1,18 @@
|
|||||||
|
#include "alignment.hpp"
|
||||||
|
|
||||||
|
namespace LuaUi
|
||||||
|
{
|
||||||
|
MyGUI::Align alignmentToMyGui(Alignment horizontal, Alignment vertical)
|
||||||
|
{
|
||||||
|
MyGUI::Align align(MyGUI::Align::Center);
|
||||||
|
if (horizontal == Alignment::Start)
|
||||||
|
align |= MyGUI::Align::Left;
|
||||||
|
if (horizontal == Alignment::End)
|
||||||
|
align |= MyGUI::Align::Right;
|
||||||
|
if (horizontal == Alignment::Start)
|
||||||
|
align |= MyGUI::Align::Top;
|
||||||
|
if (horizontal == Alignment::End)
|
||||||
|
align |= MyGUI::Align::Bottom;
|
||||||
|
return align;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
#ifndef OPENMW_LUAUI_ALIGNMENT
|
||||||
|
#define OPENMW_LUAUI_ALIGNMENT
|
||||||
|
|
||||||
|
#include <MyGUI_Align.h>
|
||||||
|
|
||||||
|
namespace LuaUi
|
||||||
|
{
|
||||||
|
enum class Alignment
|
||||||
|
{
|
||||||
|
Start = 0,
|
||||||
|
Center = 1,
|
||||||
|
End = 2
|
||||||
|
};
|
||||||
|
|
||||||
|
MyGUI::Align alignmentToMyGui(Alignment horizontal, Alignment vertical);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // !OPENMW_LUAUI_PROPERTIES
|
@ -1,11 +1,43 @@
|
|||||||
#include "textedit.hpp"
|
#include "textedit.hpp"
|
||||||
|
|
||||||
|
#include "alignment.hpp"
|
||||||
|
|
||||||
namespace LuaUi
|
namespace LuaUi
|
||||||
{
|
{
|
||||||
|
void LuaTextEdit::initialize()
|
||||||
|
{
|
||||||
|
changeWidgetSkin("LuaTextEdit");
|
||||||
|
|
||||||
|
eventEditTextChange += MyGUI::newDelegate(this, &LuaTextEdit::textChange);
|
||||||
|
|
||||||
|
WidgetExtension::initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LuaTextEdit::deinitialize()
|
||||||
|
{
|
||||||
|
eventEditTextChange -= MyGUI::newDelegate(this, &LuaTextEdit::textChange);
|
||||||
|
WidgetExtension::deinitialize();
|
||||||
|
}
|
||||||
|
|
||||||
void LuaTextEdit::updateProperties()
|
void LuaTextEdit::updateProperties()
|
||||||
{
|
{
|
||||||
setCaption(propertyValue("caption", std::string()));
|
setCaption(propertyValue("text", std::string()));
|
||||||
|
setFontHeight(propertyValue("textSize", 10));
|
||||||
|
setTextColour(propertyValue("textColor", MyGUI::Colour(0, 0, 0, 1)));
|
||||||
|
setEditMultiLine(propertyValue("multiline", false));
|
||||||
|
setEditWordWrap(propertyValue("wordWrap", false));
|
||||||
|
|
||||||
|
Alignment horizontal(propertyValue("textAlignH", Alignment::Start));
|
||||||
|
Alignment vertical(propertyValue("textAlignV", Alignment::Start));
|
||||||
|
setTextAlign(alignmentToMyGui(horizontal, vertical));
|
||||||
|
|
||||||
|
setEditStatic(propertyValue("readOnly", false));
|
||||||
|
|
||||||
WidgetExtension::updateProperties();
|
WidgetExtension::updateProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LuaTextEdit::textChange(MyGUI::EditBox*)
|
||||||
|
{
|
||||||
|
triggerEvent("textChanged", sol::make_object(lua(), getCaption().asUTF8()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,44 @@
|
|||||||
|
Text Widget
|
||||||
|
===========
|
||||||
|
|
||||||
|
Properties
|
||||||
|
----------
|
||||||
|
|
||||||
|
.. list-table::
|
||||||
|
:header-rows: 1
|
||||||
|
:widths: 20 20 60
|
||||||
|
|
||||||
|
* - name
|
||||||
|
- type (default value)
|
||||||
|
- description
|
||||||
|
* - autoSize
|
||||||
|
- boolean (true)
|
||||||
|
- | Adjusts this widget's size to fit the text exactly.
|
||||||
|
| Ignores `size` and `relativeSize`.
|
||||||
|
* - text
|
||||||
|
- string ('')
|
||||||
|
- The text to display.
|
||||||
|
* - textSize
|
||||||
|
- number (10)
|
||||||
|
- The size of the text.
|
||||||
|
* - textColor
|
||||||
|
- util.color (0, 0, 0, 1)
|
||||||
|
- The color of the text.
|
||||||
|
* - multiline
|
||||||
|
- boolean (false)
|
||||||
|
- Whether to render text on multiple lines.
|
||||||
|
* - wordWrap
|
||||||
|
- boolean (false)
|
||||||
|
- Whether to break text into lines to fit the widget's width.
|
||||||
|
* - textAlignH
|
||||||
|
- ui.ALIGNMENT (Start)
|
||||||
|
- Horizontal alignment of the text.
|
||||||
|
* - textAlignV
|
||||||
|
- ui.ALIGNMENT (Start)
|
||||||
|
- Vertical alignment of the text.
|
||||||
|
* - textShadow
|
||||||
|
- boolean (false)
|
||||||
|
- Whether to render a shadow behind the text.
|
||||||
|
* - textShadowColor
|
||||||
|
- util.color (0, 0, 0, 1)
|
||||||
|
- The color of the text shadow.
|
@ -0,0 +1,51 @@
|
|||||||
|
TextEdit Widget
|
||||||
|
===============
|
||||||
|
|
||||||
|
Properties
|
||||||
|
----------
|
||||||
|
|
||||||
|
.. list-table::
|
||||||
|
:header-rows: 1
|
||||||
|
:widths: 20 20 60
|
||||||
|
|
||||||
|
* - name
|
||||||
|
- type (default value)
|
||||||
|
- description
|
||||||
|
* - text
|
||||||
|
- string ('')
|
||||||
|
- The text to display.
|
||||||
|
* - textSize
|
||||||
|
- number (10)
|
||||||
|
- The size of the text.
|
||||||
|
* - textColor
|
||||||
|
- util.color (0, 0, 0, 1)
|
||||||
|
- The color of the text.
|
||||||
|
* - multiline
|
||||||
|
- boolean (false)
|
||||||
|
- Whether to render text on multiple lines.
|
||||||
|
* - wordWrap
|
||||||
|
- boolean (false)
|
||||||
|
- Whether to break text into lines to fit the widget's width.
|
||||||
|
* - textAlignH
|
||||||
|
- ui.ALIGNMENT (Start)
|
||||||
|
- Horizontal alignment of the text.
|
||||||
|
* - textAlignV
|
||||||
|
- ui.ALIGNMENT (Start)
|
||||||
|
- Vertical alignment of the text.
|
||||||
|
* - readOnly
|
||||||
|
- boolean (false)
|
||||||
|
- Whether the text can be edited.
|
||||||
|
|
||||||
|
Events
|
||||||
|
------
|
||||||
|
|
||||||
|
.. list-table::
|
||||||
|
:header-rows: 1
|
||||||
|
:widths: 20 20 60
|
||||||
|
|
||||||
|
* - name
|
||||||
|
- first argument type
|
||||||
|
- description
|
||||||
|
* - textChanged
|
||||||
|
- string
|
||||||
|
- Displayed text changed (e. g. by user input)
|
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<MyGUI type="Resource" version="1.1">
|
||||||
|
<Resource type="ResourceSkin" name="LuaImage">
|
||||||
|
<BasisSkin type="LuaTileRect"/>
|
||||||
|
</Resource>
|
||||||
|
|
||||||
|
<Resource type="ResourceSkin" name="LuaTextEdit" size="512 20">
|
||||||
|
<Property key="FontName" value="Default"/>
|
||||||
|
<Property key="TextAlign" value="Left VCenter"/>
|
||||||
|
<Property key="TextColour" value="#{fontcolour=normal}"/>
|
||||||
|
|
||||||
|
<Child type="TextBox" skin="MW_TextEditClient" offset="0 0 502 20" align="Stretch" name="Client"/>
|
||||||
|
</Resource>
|
||||||
|
</MyGUI>
|
Loading…
Reference in New Issue