Merge branch 'lua_ui_child_element' into 'master'

Lua Element as layout children

See merge request OpenMW/openmw!3582
This commit is contained in:
Zackhasacat 2023-11-28 21:54:55 +00:00
commit ae3f9f8dcf
12 changed files with 191 additions and 98 deletions

View file

@ -164,9 +164,9 @@
---
-- Content. An array-like container, which allows to reference elements by their name.
-- Implements [iterables#List](iterables.html#List) of #Layout and [iterables#Map](iterables.html#Map) of #string to #Layout.
-- Implements [iterables#List](iterables.html#List) of #Layout or #Element and [iterables#Map](iterables.html#Map) of #string to #Layout or #Element.
-- @type Content
-- @list <#Layout>
-- @list <#any>
-- @usage
-- local content = ui.content {
-- { name = 'input' },
@ -200,27 +200,27 @@
-- @function [parent=#Content] __index
-- @param self
-- @param #string name
-- @return #Layout
-- @return #any
---
-- Puts the layout at given index by shifting all the elements after it
-- @function [parent=#Content] insert
-- @param self
-- @param #number index
-- @param #Layout layout
-- @param #any layoutOrElement
---
-- Adds the layout at the end of the Content
-- (same as calling insert with `last index + 1`)
-- @function [parent=#Content] add
-- @param self
-- @param #Layout layout
-- @param #any layoutOrElement
---
-- Finds the index of the given layout. If it is not in the container, returns nil
-- @function [parent=#Content] indexOf
-- @param self
-- @param #Layout layout
-- @param #any layoutOrElement
-- @return #number, #nil index
---
@ -228,10 +228,35 @@
-- @type Element
---
-- Refreshes the rendered element to match the current layout state
-- Refreshes the rendered element to match the current layout state.
-- Refreshes positions and sizes, but not the layout of the child Elements.
-- @function [parent=#Element] update
-- @param self
-- @usage
-- local child = ui.create {
-- type = ui.TYPE.Text,
-- props = {
-- text = 'child 1',
-- },
-- }
-- local parent = ui.create {
-- content = ui.content {
-- child,
-- {
-- type = ui.TYPE.Text,
-- props = {
-- text = 'parent 1',
-- },
-- }
-- }
-- }
-- -- ...
-- child.layout.props.text = 'child 2'
-- parent.layout.content[2].props.text = 'parent 2'
-- parent:update() -- will show 'parent 2', but 'child 1'
---
-- Destroys the element
-- @function [parent=#Element] destroy