Add self:get_node assert, add no_auto_template flag, fix idents

This commit is contained in:
Insality 2022-03-09 18:14:40 +02:00
parent a3e5ff1116
commit 669b525c15
7 changed files with 14 additions and 11 deletions

View File

@ -262,7 +262,6 @@ function StaticGrid.get_size(self)
end end
function StaticGrid.get_size_for(self, count) function StaticGrid.get_size_for(self, count)
if not count or count == 0 then if not count or count == 0 then
return vmath.vector3(0) return vmath.vector3(0)
@ -475,5 +474,4 @@ function StaticGrid:_get_zero_offset_x(row_index)
end end
return StaticGrid return StaticGrid

View File

@ -12,6 +12,8 @@ local helper = require("druid.helper")
local BaseComponent = class("druid.component") local BaseComponent = class("druid.component")
local IS_AUTO_TEMPLATE = not (sys.get_config("druid.no_auto_template") == "1")
--- Component Interests --- Component Interests
BaseComponent.ON_INPUT = const.ON_INPUT BaseComponent.ON_INPUT = const.ON_INPUT
@ -79,7 +81,7 @@ function BaseComponent.set_template(self, template)
template = template or const.EMPTY_STRING template = template or const.EMPTY_STRING
local parent = self:get_parent_component() local parent = self:get_parent_component()
if parent then if parent and IS_AUTO_TEMPLATE then
local parent_template = parent:get_template() local parent_template = parent:get_template()
if #parent_template > 0 then if #parent_template > 0 then
if #template > 0 then if #template > 0 then
@ -138,7 +140,6 @@ function BaseComponent.increase_input_priority(self)
end end
--- Get node for component by name. --- Get node for component by name.
-- If component has nodes, node_or_name should be string -- If component has nodes, node_or_name should be string
-- It auto pick node by template name or from nodes by clone_tree -- It auto pick node by template name or from nodes by clone_tree
@ -154,18 +155,25 @@ function BaseComponent.get_node(self, node_or_name)
template_name = template_name .. "/" template_name = template_name .. "/"
end end
local node
local node_type = type(node_or_name) local node_type = type(node_or_name)
if nodes then if nodes then
assert(node_type == const.STRING, "You should pass node name instead of node") assert(node_type == const.STRING, "You should pass node name instead of node")
return nodes[template_name .. node_or_name] node = nodes[template_name .. node_or_name]
else else
if node_type == const.STRING then if node_type == const.STRING then
return gui.get_node(template_name .. node_or_name) node = gui.get_node(template_name .. node_or_name)
else else
-- Assume it's already node from gui.get_node -- Assume it's already node from gui.get_node
return node_or_name node = node_or_name
end end
end end
if not node then
assert(node, "No component with name: " .. template_name .. node_or_name)
end
return node
end end

View File

@ -312,7 +312,6 @@ function DataList._check_elements_from(self, index, step)
end end
--- Update actual data params --- Update actual data params
-- @tparam DataList self @{DataList} -- @tparam DataList self @{DataList}
-- @local -- @local

View File

@ -410,7 +410,6 @@ function DynamicGrid._get_next_node_pos(self, origin_node_index, new_node, place
end end
function DynamicGrid._get_node_size(self, node) function DynamicGrid._get_node_size(self, node)
return vmath.mul_per_elem(gui.get_size(node), gui.get_scale(node)) return vmath.mul_per_elem(gui.get_size(node), gui.get_scale(node))
end end

View File

@ -173,7 +173,6 @@ function M.is_enabled(node)
end end
--- Return closest non inverted clipping parent node for node --- Return closest non inverted clipping parent node for node
-- @function helper.get_closest_stencil_node -- @function helper.get_closest_stencil_node
-- @tparam node node Gui node -- @tparam node node Gui node

View File

@ -140,7 +140,6 @@ local function check_sort_input_stack(self, components)
end end
--- Check whitelists and blacklists for input components --- Check whitelists and blacklists for input components
local function can_use_input_component(self, component) local function can_use_input_component(self, component)
local can_by_whitelist = true local can_by_whitelist = true

View File

@ -28,6 +28,7 @@ use_accelerometer = 0
[druid] [druid]
no_auto_input = 0 no_auto_input = 0
stencil_check = 0 stencil_check = 0
no_auto_template = 0
input_text = text input_text = text
input_touch = touch input_touch = touch
input_marked_text = marked_text input_marked_text = marked_text