Add list of druid instances, add global events: on_window_callback, on_layout_change and on_language_change

This commit is contained in:
Insality
2020-04-18 01:41:28 +03:00
parent b9b67c55d6
commit f02c68242a
5 changed files with 115 additions and 10 deletions

View File

@@ -51,10 +51,17 @@ local function init_swipe_control(self)
end
local function on_window_callback(self, event, data)
druid.on_window_callback(event, data)
end
function init(self)
druid.set_default_style(default_style)
self.druid = druid.new(self)
window.set_listener(on_window_callback)
init_top_panel(self)
init_swipe_control(self)
self.page = 1

View File

@@ -1,5 +1,4 @@
local druid = require("druid.druid")
local const = require("druid.const")
local lang = require("example.lang")
@@ -12,9 +11,7 @@ local function setup_druid()
return lang.get_locale(lang_id)
end)
-- TODO: Call druid.finish_setup?
-- Need to update all gui, in case, when gui init was befure this init
msg.post("/gui#main", const.ON_CHANGE_LANGUAGE)
druid.on_language_change()
end

View File

@@ -1,4 +1,4 @@
local const = require("druid.const")
local druid = require("druid.druid")
local M = {}
@@ -47,7 +47,7 @@ end
function M.toggle_locale()
data = data == en and ru or en
msg.post("/gui#main", const.ON_CHANGE_LANGUAGE)
druid.on_language_change()
end
return M