diff --git a/druid/base/back_handler.lua b/druid/base/back_handler.lua index 9afa864..4f82c86 100644 --- a/druid/base/back_handler.lua +++ b/druid/base/back_handler.lua @@ -1,11 +1,11 @@ --- Component to handle back key -- @module base.back_handler -local data = require("druid.data") +local const = require("druid.const") local M = {} M.interest = { - data.ON_INPUT + const.ON_INPUT } --- Component init function @@ -13,7 +13,7 @@ M.interest = { -- @tparam callback callback on back button -- @tparam[opt] params callback argument function M.init(self, callback, params) - self.event = data.ACTION_BACK + self.event = const.ACTION_BACK self.callback = callback self.params = params end @@ -23,7 +23,7 @@ end -- @tparam string action_id on_input action id -- @tparam table action on_input action function M.on_input(self, action_id, action) - if action[data.RELEASED] then + if action[const.RELEASED] then self.callback(self.parent.parent, self.params) end diff --git a/druid/base/button.lua b/druid/base/button.lua index 58f1821..2f87afd 100644 --- a/druid/base/button.lua +++ b/druid/base/button.lua @@ -5,7 +5,7 @@ -- Long tap -- Repeated tap -local data = require("druid.data") +local const = require("druid.const") local ui_animate = require("druid.helper.druid_animate") local settings = require("druid.settings") local helper = require("druid.helper") @@ -13,7 +13,7 @@ local b_settings = settings.button local M = {} M.interest = { - data.ON_INPUT + const.ON_INPUT } M.DEFAULT_DEACTIVATE_COLOR = vmath.vector4(0, 0, 0, 0) @@ -24,7 +24,7 @@ M.DEFAULT_ACTIVATION_TIME = 0.2 function M.init(self, node, callback, params, anim_node, event) self.node = helper.get_node(node) - self.event = data.ACTION_TOUCH + self.event = const.ACTION_TOUCH self.anim_node = anim_node and helper.get_node(anim_node) or self.node self.scale_from = gui.get_scale(self.anim_node) self.scale_to = self.scale_from + b_settings.SCALE_CHANGE diff --git a/druid/base/progress.lua b/druid/base/progress.lua index e0d2b88..d8cc122 100644 --- a/druid/base/progress.lua +++ b/druid/base/progress.lua @@ -1,7 +1,7 @@ --- Component to handle progress bars -- @module base.progress -local data = require("druid.data") +local const = require("druid.const") local helper = require("druid.helper") local settings = require("druid.settings") local p_settings = settings.progress @@ -9,7 +9,7 @@ local p_settings = settings.progress local M = {} M.interest = { - data.ON_UPDATE, + const.ON_UPDATE, } local PROP_Y = "y" diff --git a/druid/base/scroll.lua b/druid/base/scroll.lua index d561e5d..7febced 100644 --- a/druid/base/scroll.lua +++ b/druid/base/scroll.lua @@ -2,7 +2,7 @@ -- @module base.scroll local helper = require("druid.helper") -local data = require("druid.data") +local const = require("druid.const") local settings = require("druid.settings").scroll local M = {} @@ -11,8 +11,8 @@ local SIDE_X = "x" local SIDE_Y = "y" M.interest = { - data.ON_UPDATE, - data.ON_SWIPE, + const.ON_UPDATE, + const.ON_SWIPE, } -- Global on all scrolls @@ -257,7 +257,7 @@ end function M.on_input(self, action_id, action) - if action_id ~= data.ACTION_TOUCH then + if action_id ~= const.ACTION_TOUCH then return false end local inp = self.input diff --git a/druid/base/text.lua b/druid/base/text.lua index 297ddc4..fff35e5 100644 --- a/druid/base/text.lua +++ b/druid/base/text.lua @@ -2,13 +2,13 @@ -- Good working with localization system -- @module base.text -local data = require("druid.data") +local const = require("druid.const") local settings = require("druid.settings") local helper = require("druid.helper") local M = {} M.interest = { - data.ON_CHANGE_LANGUAGE, + const.ON_CHANGE_LANGUAGE, } diff --git a/druid/base/timer.lua b/druid/base/timer.lua index 801cc7e..2ab6cb7 100644 --- a/druid/base/timer.lua +++ b/druid/base/timer.lua @@ -1,13 +1,13 @@ --- Component to handle GUI timers -- @module base.timer -local data = require("druid.data") +local const = require("druid.const") local formats = require("druid.helper.formats") local helper = require("druid.helper") local M = {} M.interest = { - data.ON_UPDATE + const.ON_UPDATE } local empty = function() end diff --git a/druid/data.lua b/druid/const.lua similarity index 100% rename from druid/data.lua rename to druid/const.lua diff --git a/druid/druid.lua b/druid/druid.lua index f24a12e..f271681 100644 --- a/druid/druid.lua +++ b/druid/druid.lua @@ -4,7 +4,7 @@ -- to create your own rich components. -- @module druid -local data = require("druid.data") +local const = require("druid.const") local druid_input = require("druid.helper.druid_input") local settings = require("druid.settings") @@ -86,7 +86,7 @@ local function create(self, module) end self[v][#self[v] + 1] = instance - if data.ui_input[v] then + if const.ui_input[v] then input_init(self) end end @@ -130,7 +130,7 @@ end --- Called on_message function _fct_metatable.on_message(self, message_id, message, sender) - local specific_ui_message = data.specific_ui_messages[message_id] + local specific_ui_message = const.specific_ui_messages[message_id] if specific_ui_message then local array = self[message_id] if array then @@ -141,7 +141,7 @@ function _fct_metatable.on_message(self, message_id, message, sender) end end else - local array = self[data.ON_MESSAGE] + local array = self[const.ON_MESSAGE] if array then for i = 1, #array do array[i]:on_message(message_id, message, sender) @@ -152,10 +152,10 @@ end local function notify_input_on_swipe(self) - if self[data.ON_INPUT] then - local len = #self[data.ON_INPUT] + if self[const.ON_INPUT] then + local len = #self[const.ON_INPUT] for i = len, 1, -1 do - local comp = self[data.ON_INPUT][i] + local comp = self[const.ON_INPUT][i] if comp.on_swipe then comp:on_swipe() end @@ -179,7 +179,7 @@ end --- Called ON_INPUT function _fct_metatable.on_input(self, action_id, action) - local array = self[data.ON_SWIPE] + local array = self[const.ON_SWIPE] if array then local v, result local len = #array @@ -192,7 +192,7 @@ function _fct_metatable.on_input(self, action_id, action) return true end end - array = self[data.ON_INPUT] + array = self[const.ON_INPUT] if array then local v local len = #array @@ -210,7 +210,7 @@ end --- Called on_update function _fct_metatable.update(self, dt) - local array = self[data.ON_UPDATE] + local array = self[const.ON_UPDATE] if array then for i = 1, #array do array[i]:update(dt)