Update annotations: scroll, static_grid, events, druid_instance

This commit is contained in:
Insality
2020-10-11 23:53:30 +03:00
parent 082aa454c6
commit 248b9c30f9
5 changed files with 181 additions and 158 deletions

View File

@@ -7,7 +7,8 @@
-- end
--
-- Learn Druid instance function here
-- @module druid_instance
-- @module DruidInstance
-- @alias druid_instance
-- @see Button
-- @see Blocker
-- @see BackHandler
@@ -16,7 +17,7 @@
-- @see druid.lang_text
-- @see druid.timer
-- @see druid.progress
-- @see druid.static_grid
-- @see StaticGrid
-- @see druid.dynamic_grid
-- @see Scroll
-- @see druid.slider
@@ -53,8 +54,8 @@ local radio_group = require("druid.extended.radio_group")
local slider = require("druid.extended.slider")
local timer = require("druid.extended.timer")
-- @classmod Druid
local Druid = class("druid.druid_instance")
local DruidInstance = class("druid.druid_instance")
local function input_init(self)
@@ -142,10 +143,10 @@ end
--- Druid class constructor
-- @function druid:initialize
-- @tparam context table Druid context. Usually it is self of script
-- @tparam style table Druid style module
function Druid:initialize(context, style)
-- @tparam DruidInstance self
-- @tparam table context Druid context. Usually it is self of script
-- @tparam table style Druid style module
function DruidInstance.initialize(self, context, style)
self._context = context
self._style = style or settings.default_style
self._deleted = false
@@ -161,10 +162,10 @@ end
--- Create new druid component
-- @function druid:create
-- @tparam DruidInstance self
-- @tparam Component component Component module
-- @tparam args ... Other component params to pass it to component:init function
function Druid:create(component, ...)
function DruidInstance.create(self, component, ...)
local instance = create(self, component)
if instance.init then
@@ -177,8 +178,8 @@ end
--- Call on final function on gui_script. It will call on_remove
-- on all druid components
-- @function druid:final
function Druid:final()
-- @tparam DruidInstance self
function DruidInstance.final(self)
local components = self.components[const.ALL]
for i = #components, 1, -1 do
@@ -195,9 +196,9 @@ end
--- Remove component from druid instance.
-- Component `on_remove` function will be invoked, if exist.
-- @function druid:remove
-- @tparam DruidInstance self
-- @tparam Component component Component instance
function Druid:remove(component)
function DruidInstance.remove(self, component)
if self._is_input_processing then
table.insert(self._late_remove, component)
return
@@ -238,9 +239,9 @@ end
--- Druid update function
-- @function druid:update
-- @tparam DruidInstance self
-- @tparam number dt Delta time
function Druid:update(dt)
function DruidInstance.update(self, dt)
local components = self.components[const.ON_UPDATE]
for i = 1, #components do
components[i]:update(dt)
@@ -249,10 +250,10 @@ end
--- Druid on_input function
-- @function druid:on_input
-- @tparam DruidInstance self
-- @tparam hash action_id Action_id from on_input
-- @tparam table action Action from on_input
function Druid:on_input(action_id, action)
function DruidInstance.on_input(self, action_id, action)
self._is_input_processing = true
local is_input_consumed = false
@@ -277,11 +278,11 @@ end
--- Druid on_message function
-- @function druid:on_message
-- @tparam DruidInstance self
-- @tparam hash message_id Message_id from on_message
-- @tparam table message Message from on_message
-- @tparam hash sender Sender from on_message
function Druid:on_message(message_id, message, sender)
function DruidInstance.on_message(self, message_id, message, sender)
local specific_ui_message = const.SPECIFIC_UI_MESSAGES[message_id]
if specific_ui_message then
@@ -303,8 +304,8 @@ end
--- Druid on focus lost interest function.
-- This one called by on_window_callback by global window listener
-- @function druid:on_focus_lost
function Druid:on_focus_lost()
-- @tparam DruidInstance self
function DruidInstance.on_focus_lost(self)
local components = self.components[const.ON_FOCUS_LOST]
for i = 1, #components do
components[i]:on_focus_lost()
@@ -314,8 +315,8 @@ end
--- Druid on focus gained interest function.
-- This one called by on_window_callback by global window listener
-- @function druid:on_focus_gained
function Druid:on_focus_gained()
-- @tparam DruidInstance self
function DruidInstance.on_focus_gained(self)
local components = self.components[const.ON_FOCUS_GAINED]
for i = 1, #components do
components[i]:on_focus_gained()
@@ -325,8 +326,8 @@ end
--- Druid on layout change function.
-- Called on update gui layout
-- @function druid:on_layout_change
function Druid:on_layout_change()
-- @tparam DruidInstance self
function DruidInstance.on_layout_change(self)
local components = self.components[const.ON_LAYOUT_CHANGE]
for i = 1, #components do
components[i]:on_layout_change()
@@ -338,7 +339,7 @@ end
-- This one called by global gruid.on_language_change, but can be
-- call manualy to update all translations
-- @function druid.on_language_change
function Druid:on_language_change()
function DruidInstance.on_language_change(self)
local components = self.components[const.ON_LANGUAGE_CHANGE]
for i = 1, #components do
components[i]:on_language_change()
@@ -347,185 +348,185 @@ end
--- Create button basic component
-- @function druid:new_button
-- @tparam DruidInstance self
-- @tparam args ... button init args
-- @treturn Component button component
function Druid:new_button(...)
return Druid.create(self, button, ...)
function DruidInstance.new_button(self, ...)
return DruidInstance.create(self, button, ...)
end
--- Create blocker basic component
-- @function druid:new_blocker
-- @tparam DruidInstance self
-- @tparam args ... blocker init args
-- @treturn Component blocker component
function Druid:new_blocker(...)
return Druid.create(self, blocker, ...)
function DruidInstance.new_blocker(self, ...)
return DruidInstance.create(self, blocker, ...)
end
--- Create back_handler basic component
-- @function druid:new_back_handler
-- @tparam DruidInstance self
-- @tparam args ... back_handler init args
-- @treturn Component back_handler component
function Druid:new_back_handler(...)
return Druid.create(self, back_handler, ...)
function DruidInstance.new_back_handler(self, ...)
return DruidInstance.create(self, back_handler, ...)
end
--- Create hover basic component
-- @function druid:new_hover
-- @tparam DruidInstance self
-- @tparam args ... hover init args
-- @treturn Component hover component
function Druid:new_hover(...)
return Druid.create(self, hover, ...)
function DruidInstance.new_hover(self, ...)
return DruidInstance.create(self, hover, ...)
end
--- Create text basic component
-- @function druid:new_text
-- @tparam DruidInstance self
-- @tparam args ... text init args
-- @treturn Component text component
function Druid:new_text(...)
return Druid.create(self, text, ...)
function DruidInstance.new_text(self, ...)
return DruidInstance.create(self, text, ...)
end
--- Create grid basic component
-- Deprecated
-- @function druid:new_grid
-- @tparam DruidInstance self
-- @tparam args ... grid init args
-- @treturn Component grid component
function Druid:new_grid(...)
function DruidInstance.new_grid(self, ...)
helper.deprecated("The druid:new_grid is deprecated. Please use druid:new_static_grid instead")
return Druid.create(self, static_grid, ...)
return DruidInstance.create(self, static_grid, ...)
end
--- Create static grid basic component
-- @function druid:new_static_grid
-- @tparam DruidInstance self
-- @tparam args ... grid init args
-- @treturn Component grid component
function Druid:new_static_grid(...)
return Druid.create(self, static_grid, ...)
function DruidInstance.new_static_grid(self, ...)
return DruidInstance.create(self, static_grid, ...)
end
--- Create scroll basic component
-- @function druid:new_scroll
-- @tparam DruidInstance self
-- @tparam args ... scroll init args
-- @treturn Component scroll component
function Druid:new_scroll(...)
return Druid.create(self, scroll, ...)
function DruidInstance.new_scroll(self, ...)
return DruidInstance.create(self, scroll, ...)
end
--- Create swipe basic component
-- @function druid:new_swipe
-- @tparam DruidInstance self
-- @tparam args ... swipe init args
-- @treturn Component swipe component
function Druid:new_swipe(...)
return Druid.create(self, swipe, ...)
function DruidInstance.new_swipe(self, ...)
return DruidInstance.create(self, swipe, ...)
end
--- Create drag basic component
-- @function druid:new_drag
-- @tparam DruidInstance self
-- @tparam args ... drag init args
-- @treturn Componetn drag component
function Druid:new_drag(...)
return Druid.create(self, drag, ...)
function DruidInstance.new_drag(self, ...)
return DruidInstance.create(self, drag, ...)
end
--- Create dynamic grid component
-- @function druid:new_dynamic_grid
-- @tparam DruidInstance self
-- @tparam args ... grid init args
-- @treturn Component grid component
function Druid:new_dynamic_grid(...)
function DruidInstance.new_dynamic_grid(self, ...)
-- return helper.extended_component("dynamic_grid")
return Druid.create(self, dynamic_grid, ...)
return DruidInstance.create(self, dynamic_grid, ...)
end
--- Create lang_text component
-- @function druid:new_lang_text
-- @tparam DruidInstance self
-- @tparam args ... lang_text init args
-- @treturn Component lang_text component
function Druid:new_lang_text(...)
function DruidInstance.new_lang_text(self, ...)
-- return helper.extended_component("lang_text")
return Druid.create(self, lang_text, ...)
return DruidInstance.create(self, lang_text, ...)
end
--- Create slider component
-- @function druid:new_slider
-- @tparam DruidInstance self
-- @tparam args ... slider init args
-- @treturn Component slider component
function Druid:new_slider(...)
function DruidInstance.new_slider(self, ...)
-- return helper.extended_component("slider")
return Druid.create(self, slider, ...)
return DruidInstance.create(self, slider, ...)
end
--- Create checkbox component
-- @function druid:new_checkbox
-- @tparam DruidInstance self
-- @tparam args ... checkbox init args
-- @treturn Component checkbox component
function Druid:new_checkbox(...)
function DruidInstance.new_checkbox(self, ...)
-- return helper.extended_component("checkbox")
return Druid.create(self, checkbox, ...)
return DruidInstance.create(self, checkbox, ...)
end
--- Create input component
-- @function druid:new_input
-- @tparam DruidInstance self
-- @tparam args ... input init args
-- @treturn Component input component
function Druid:new_input(...)
function DruidInstance.new_input(self, ...)
-- return helper.extended_component("input")
return Druid.create(self, input, ...)
return DruidInstance.create(self, input, ...)
end
--- Create checkbox_group component
-- @function druid:new_checkbox_group
-- @tparam DruidInstance self
-- @tparam args ... checkbox_group init args
-- @treturn Component checkbox_group component
function Druid:new_checkbox_group(...)
function DruidInstance.new_checkbox_group(self, ...)
-- return helper.extended_component("checkbox_group")
return Druid.create(self, checkbox_group, ...)
return DruidInstance.create(self, checkbox_group, ...)
end
--- Create radio_group component
-- @function druid:new_radio_group
-- @tparam DruidInstance self
-- @tparam args ... radio_group init args
-- @treturn Component radio_group component
function Druid:new_radio_group(...)
function DruidInstance.new_radio_group(self, ...)
-- return helper.extended_component("radio_group")
return Druid.create(self, radio_group, ...)
return DruidInstance.create(self, radio_group, ...)
end
--- Create timer component
-- @function druid:new_timer
-- @tparam DruidInstance self
-- @tparam args ... timer init args
-- @treturn Component timer component
function Druid:new_timer(...)
function DruidInstance.new_timer(self, ...)
-- return helper.extended_component("timer")
return Druid.create(self, timer, ...)
return DruidInstance.create(self, timer, ...)
end
--- Create progress component
-- @function druid:new_progress
-- @tparam DruidInstance self
-- @tparam args ... progress init args
-- @treturn Component progress component
function Druid:new_progress(...)
function DruidInstance.new_progress(self, ...)
-- return helper.extended_component("progress")
return Druid.create(self, progress, ...)
return DruidInstance.create(self, progress, ...)
end
return Druid
return DruidInstanceInstance