translatable should be in data

This commit is contained in:
Insality 2019-03-27 00:50:46 +03:00
parent da1e75fa89
commit 9af3046ca4
2 changed files with 13 additions and 12 deletions

View File

@ -6,11 +6,13 @@ M.A_BACKSPACE = hash("backspace")
M.A_ENTER = hash("enter")
M.A_ANDR_BACK = hash("back")
-- interest
M.LAYOUT_CHANGED = hash("layout_changed")
M.ON_MESSAGE = hash("on_message")
M.ON_INPUT = hash("on_input")
M.ON_SWIPE = hash("on_swipe")
M.ON_UPDATE = hash("on_update")
M.TRANSLATABLE = hash("TRANSLATABLE")
M.RELEASED = "released"
M.PRESSED = "pressed"

View File

@ -1,19 +1,11 @@
local M = {}
local druid_input = require("druid.help_modules.druid_input")
local data = require("druid.data")
local druid_input = require("druid.help_modules.druid_input")
M.input = druid_input
M.TRANSLATABLE = hash("TRANSLATABLE")
local M = {}
local STRING = "string"
--- New druid era, registering components
-- temporary make components outside
local components = {
-- base
button = require("druid.base.button"),
@ -22,6 +14,7 @@ local components = {
-- timer = require("druid.base.timer"),
}
local function register_components()
for k, v in pairs(components) do
-- TODO: Find better solution to creating elements?
@ -43,7 +36,7 @@ function M.on_message(factory, message_id, message, sender)
v:on_layout_updated(message)
end
end
elseif message_id == M.TRANSLATABLE then
elseif message_id == data.TRANSLATABLE then
M.translate(factory)
else
if factory[data.ON_MESSAGE] then
@ -54,6 +47,7 @@ function M.on_message(factory, message_id, message, sender)
end
end
--- Called ON_INPUT
function M.on_input(factory, action_id, action)
if factory[data.ON_SWIPE] then
@ -81,6 +75,7 @@ function M.on_input(factory, action_id, action)
return false
end
--- Called on_update
function M.update(factory, dt)
if factory[data.ON_UPDATE] then
@ -90,6 +85,7 @@ function M.update(factory, dt)
end
end
--- Create UI instance for ui elements
-- @return instance with all ui components
function M.new(self)
@ -98,6 +94,7 @@ function M.new(self)
return factory
end
local function input_init(factory)
if not factory.input_inited then
factory.input_inited = true
@ -136,6 +133,7 @@ local function create(meta, factory, name, ...)
return instance
end
function M.create(factory, meta, name, ...)
local instance = create(meta, factory, name)
instance.factory = factory
@ -145,4 +143,5 @@ function M.create(factory, meta, name, ...)
end
end
return M
return M