mirror of
https://github.com/Insality/druid
synced 2025-06-27 10:27:48 +02:00
Add generics annotations to component set_style/nodes/template
This commit is contained in:
parent
aff4412677
commit
62384f36b3
@ -145,18 +145,6 @@ return AwesomeComponent
|
|||||||
<td class="name" nowrap><a href="#set_input_priority">set_input_priority(self, value, is_temporary)</a></td>
|
<td class="name" nowrap><a href="#set_input_priority">set_input_priority(self, value, is_temporary)</a></td>
|
||||||
<td class="summary">Set component input priority</td>
|
<td class="summary">Set component input priority</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td class="name" nowrap><a href="#set_nodes">set_nodes(self, nodes)</a></td>
|
|
||||||
<td class="summary">Set current component nodes.</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="name" nowrap><a href="#set_style">set_style(self, druid_style)</a></td>
|
|
||||||
<td class="summary">Set current component style table.</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="name" nowrap><a href="#set_template">set_template(self, template)</a></td>
|
|
||||||
<td class="summary">Set component template name.</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
@ -546,110 +534,6 @@ return AwesomeComponent
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "set_nodes"></a>
|
|
||||||
<strong>set_nodes(self, nodes)</strong>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Set current component nodes.
|
|
||||||
Use if your component nodes was cloned with `gui.clone_tree` and you got the node tree.
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Parameters:</h3>
|
|
||||||
<ul>
|
|
||||||
<li><span class="parameter">self</span>
|
|
||||||
<span class="types"><span class="type">BaseComponent</span></span>
|
|
||||||
<a href="../modules/BaseComponent.html#">BaseComponent</a>
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">nodes</span>
|
|
||||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
|
|
||||||
BaseComponent nodes table
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Returns:</h3>
|
|
||||||
<ol>
|
|
||||||
|
|
||||||
<span class="types"><span class="type">BaseComponent</span></span>
|
|
||||||
<a href="../modules/BaseComponent.html#">BaseComponent</a>
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Usage:</h3>
|
|
||||||
<ul>
|
|
||||||
<pre class="example"><span class="keyword">local</span> nodes = gui.clone_tree(self.prefab)
|
|
||||||
... In your component:
|
|
||||||
self:set_nodes(nodes)</pre>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "set_style"></a>
|
|
||||||
<strong>set_style(self, druid_style)</strong>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Set current component style table.
|
|
||||||
<p> Invoke `on_style_change` on component, if exist. Component should handle
|
|
||||||
their style changing and store all style params
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Parameters:</h3>
|
|
||||||
<ul>
|
|
||||||
<li><span class="parameter">self</span>
|
|
||||||
<span class="types"><span class="type">BaseComponent</span></span>
|
|
||||||
<a href="../modules/BaseComponent.html#">BaseComponent</a>
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">druid_style</span>
|
|
||||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a> or <span class="type">nil</span></span>
|
|
||||||
Druid style module
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Returns:</h3>
|
|
||||||
<ol>
|
|
||||||
|
|
||||||
<span class="types"><span class="type">BaseComponent</span></span>
|
|
||||||
<a href="../modules/BaseComponent.html#">BaseComponent</a>
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
|
||||||
<dt>
|
|
||||||
<a name = "set_template"></a>
|
|
||||||
<strong>set_template(self, template)</strong>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
Set component template name.
|
|
||||||
<p> Use on all your custom components with GUI layouts used as templates.
|
|
||||||
It will check parent template name to build full template name in self:get_node()
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Parameters:</h3>
|
|
||||||
<ul>
|
|
||||||
<li><span class="parameter">self</span>
|
|
||||||
<span class="types"><span class="type">BaseComponent</span></span>
|
|
||||||
<a href="../modules/BaseComponent.html#">BaseComponent</a>
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">template</span>
|
|
||||||
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
|
|
||||||
BaseComponent template name
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Returns:</h3>
|
|
||||||
<ol>
|
|
||||||
|
|
||||||
<span class="types"><span class="type">BaseComponent</span></span>
|
|
||||||
<a href="../modules/BaseComponent.html#">BaseComponent</a>
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
|
@ -126,27 +126,6 @@ function druid__base_component.set_input_enabled(self, state) end
|
|||||||
---@return number The component input priority
|
---@return number The component input priority
|
||||||
function druid__base_component.set_input_priority(self, value, is_temporary) end
|
function druid__base_component.set_input_priority(self, value, is_temporary) end
|
||||||
|
|
||||||
--- Set current component nodes.
|
|
||||||
--- Use if your component nodes was cloned with `gui.clone_tree` and you got the node tree.
|
|
||||||
---@param self druid.base_component @{BaseComponent}
|
|
||||||
---@param nodes table BaseComponent nodes table
|
|
||||||
---@return druid.base_component @{BaseComponent}
|
|
||||||
function druid__base_component.set_nodes(self, nodes) end
|
|
||||||
|
|
||||||
--- Set current component style table.
|
|
||||||
--- Invoke `on_style_change` on component, if exist. Component should handle their style changing and store all style params
|
|
||||||
---@param self druid.base_component @{BaseComponent}
|
|
||||||
---@param druid_style table|nil Druid style module
|
|
||||||
---@return druid.base_component @{BaseComponent}
|
|
||||||
function druid__base_component.set_style(self, druid_style) end
|
|
||||||
|
|
||||||
--- Set component template name.
|
|
||||||
--- Use on all your custom components with GUI layouts used as templates. It will check parent template name to build full template name in self:get_node()
|
|
||||||
---@param self druid.base_component @{BaseComponent}
|
|
||||||
---@param template string BaseComponent template name
|
|
||||||
---@return druid.base_component @{BaseComponent}
|
|
||||||
function druid__base_component.set_template(self, template) end
|
|
||||||
|
|
||||||
|
|
||||||
---@class druid.blocker : druid.base_component
|
---@class druid.blocker : druid.base_component
|
||||||
---@field node node Blocker node
|
---@field node node Blocker node
|
||||||
@ -1897,3 +1876,27 @@ function helper.table_to_string(t) end
|
|||||||
---@param ... any Other component params to pass it to component:init function
|
---@param ... any Other component params to pass it to component:init function
|
||||||
---@return T Component instance
|
---@return T Component instance
|
||||||
function druid_instance.new(self, component, ...) end
|
function druid_instance.new(self, component, ...) end
|
||||||
|
|
||||||
|
--- Set current component style table.
|
||||||
|
--- Invoke `on_style_change` on component, if exist. Component should handle their style changing and store all style params
|
||||||
|
---@generic T: druid.base_component
|
||||||
|
---@param self T @{BaseComponent}
|
||||||
|
---@param druid_style table|nil Druid style module
|
||||||
|
---@return T @{BaseComponent}
|
||||||
|
function druid__base_component.set_style(self, druid_style) end
|
||||||
|
|
||||||
|
--- Set component template name.
|
||||||
|
--- Use on all your custom components with GUI layouts used as templates. It will check parent template name to build full template name in self:get_node()
|
||||||
|
---@generic T: druid.base_component
|
||||||
|
---@param self T @{BaseComponent}
|
||||||
|
---@param template string BaseComponent template name
|
||||||
|
---@return T @{BaseComponent}
|
||||||
|
function druid__base_component.set_template(self, template) end
|
||||||
|
|
||||||
|
--- Set current component nodes.
|
||||||
|
--- Use if your component nodes was cloned with `gui.clone_tree` and you got the node tree.
|
||||||
|
---@generic T: druid.base_component
|
||||||
|
---@param self T @{BaseComponent}
|
||||||
|
---@param nodes table BaseComponent nodes table
|
||||||
|
---@return T @{BaseComponent}
|
||||||
|
function druid__base_component.set_nodes(self, nodes) end
|
||||||
|
@ -76,6 +76,7 @@ end
|
|||||||
-- @tparam BaseComponent self @{BaseComponent}
|
-- @tparam BaseComponent self @{BaseComponent}
|
||||||
-- @tparam table|nil druid_style Druid style module
|
-- @tparam table|nil druid_style Druid style module
|
||||||
-- @treturn BaseComponent @{BaseComponent}
|
-- @treturn BaseComponent @{BaseComponent}
|
||||||
|
-- @local
|
||||||
function BaseComponent.set_style(self, druid_style)
|
function BaseComponent.set_style(self, druid_style)
|
||||||
self._meta.style = druid_style or {}
|
self._meta.style = druid_style or {}
|
||||||
local component_style = self._meta.style[self._component.name] or {}
|
local component_style = self._meta.style[self._component.name] or {}
|
||||||
@ -95,6 +96,7 @@ end
|
|||||||
-- @tparam BaseComponent self @{BaseComponent}
|
-- @tparam BaseComponent self @{BaseComponent}
|
||||||
-- @tparam string template BaseComponent template name
|
-- @tparam string template BaseComponent template name
|
||||||
-- @treturn BaseComponent @{BaseComponent}
|
-- @treturn BaseComponent @{BaseComponent}
|
||||||
|
-- @local
|
||||||
function BaseComponent.set_template(self, template)
|
function BaseComponent.set_template(self, template)
|
||||||
template = template or ""
|
template = template or ""
|
||||||
|
|
||||||
@ -131,6 +133,7 @@ end
|
|||||||
-- local nodes = gui.clone_tree(self.prefab)
|
-- local nodes = gui.clone_tree(self.prefab)
|
||||||
-- ... In your component:
|
-- ... In your component:
|
||||||
-- self:set_nodes(nodes)
|
-- self:set_nodes(nodes)
|
||||||
|
-- @local
|
||||||
function BaseComponent.set_nodes(self, nodes)
|
function BaseComponent.set_nodes(self, nodes)
|
||||||
self._meta.nodes = nodes
|
self._meta.nodes = nodes
|
||||||
|
|
||||||
|
@ -100,3 +100,27 @@
|
|||||||
---@param ... any Other component params to pass it to component:init function
|
---@param ... any Other component params to pass it to component:init function
|
||||||
---@return T Component instance
|
---@return T Component instance
|
||||||
function druid_instance.new(self, component, ...) end
|
function druid_instance.new(self, component, ...) end
|
||||||
|
|
||||||
|
--- Set current component style table.
|
||||||
|
--- Invoke `on_style_change` on component, if exist. Component should handle their style changing and store all style params
|
||||||
|
---@generic T: druid.base_component
|
||||||
|
---@param self T @{BaseComponent}
|
||||||
|
---@param druid_style table|nil Druid style module
|
||||||
|
---@return T @{BaseComponent}
|
||||||
|
function druid__base_component.set_style(self, druid_style) end
|
||||||
|
|
||||||
|
--- Set component template name.
|
||||||
|
--- Use on all your custom components with GUI layouts used as templates. It will check parent template name to build full template name in self:get_node()
|
||||||
|
---@generic T: druid.base_component
|
||||||
|
---@param self T @{BaseComponent}
|
||||||
|
---@param template string BaseComponent template name
|
||||||
|
---@return T @{BaseComponent}
|
||||||
|
function druid__base_component.set_template(self, template) end
|
||||||
|
|
||||||
|
--- Set current component nodes.
|
||||||
|
--- Use if your component nodes was cloned with `gui.clone_tree` and you got the node tree.
|
||||||
|
---@generic T: druid.base_component
|
||||||
|
---@param self T @{BaseComponent}
|
||||||
|
---@param nodes table BaseComponent nodes table
|
||||||
|
---@return T @{BaseComponent}
|
||||||
|
function druid__base_component.set_nodes(self, nodes) end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user