Add on_style_change to every component

Empty default style is now valid. Every component have their default style values. Removed style function checks
This commit is contained in:
Insality
2020-05-09 12:45:09 +03:00
parent b1b06f9a17
commit 928a212527
12 changed files with 157 additions and 171 deletions

View File

@@ -70,6 +70,18 @@ local function set_bar_to(self, set_to, is_silent)
end
--- Change style of component.
-- This function can be called before component:init. This callback
-- only for store component style params inside self context
-- @function progress:on_style_change
-- @tparam table style The component style table
function M.on_style_change(self, style)
self.style = {}
self.style.SPEED = style.SPEED or 5
self.style.MIN_DELTA = style.MIN_DELTA or 0.005
end
--- Component init function
-- @function progress:init
-- @tparam string|node node Progress bar fill node or node name
@@ -81,7 +93,6 @@ function M.init(self, node, key, init_value)
self.prop = hash("scale."..key)
self.key = key
self.style = self:get_style()
self.node = self:get_node(node)
self.scale = gui.get_scale(self.node)
self.size = gui.get_size(self.node)