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

@@ -111,6 +111,8 @@ end
function Druid.initialize(self, context, style)
self._context = context
self._style = style or settings.default_style
self._deleted = false
self.url = msg.url()
self.components = {}
end
@@ -141,6 +143,8 @@ function Druid.final(self)
components[i]:on_remove()
end
end
self._deleted = true
end
@@ -231,6 +235,45 @@ function Druid.on_message(self, message_id, message, sender)
end
function Druid.on_focus_lost(self)
local components = self.components[const.ON_FOCUS_LOST]
if components then
for i = 1, #components do
components[i]:on_focus_lost()
end
end
end
function Druid.on_focus_gained(self)
local components = self.components[const.ON_FOCUS_GAINED]
if components then
for i = 1, #components do
components[i]:on_focus_gained()
end
end
end
function Druid.on_layout_change(self)
local components = self.components[const.ON_LAYOUT_CHANGE]
if components then
for i = 1, #components do
components[i]:on_layout_change()
end
end
end
function Druid.on_language_change(self)
local components = self.components[const.ON_LANGUAGE_CHANGE]
if components then
for i = 1, #components do
components[i]:on_language_change()
end
end
end
--- Create button basic component
-- @function druid:new_button
-- @tparam args ... button init args