Add example docs for LDoc

This commit is contained in:
Insality
2019-09-25 20:40:41 +03:00
parent 4d424a34c2
commit b72e7451e1
14 changed files with 92 additions and 35 deletions

View File

@@ -1,3 +1,6 @@
--- Component to handle back key
-- @module base.back_handler
local data = require("druid.data")
local M = {}
@@ -5,21 +8,25 @@ M.interest = {
data.ON_INPUT
}
--- Component init function
-- @tparam table self component instance
-- @tparam callback callback on back button
-- @tparam[opt] params callback argument
function M.init(self, callback, params)
self.event = data.A_ANDR_BACK
self.event = data.ACTION_BACK
self.callback = callback
self.params = params
end
--- input handler
-- @param action_id - input action id
-- @param action - input action
--- Input handler for component
-- @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
self.callback(self.parent.parent, self.params)
end
return true
end

View File

@@ -1,3 +1,6 @@
--- Component to handle basic GUI button
-- @module base.button
local data = require("druid.data")
local ui_animate = require("druid.helper.druid_animate")
local settings = require("druid.settings")
@@ -17,7 +20,7 @@ M.DEFAUL_ACTIVATION_TIME = 0.2
function M.init(self, node, callback, params, anim_node, event)
self.node = helper.get_node(node)
self.event = data.A_TOUCH
self.event = data.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
@@ -185,4 +188,4 @@ function M.set_ext_zone(self, zone)
end
return M
return M

View File

@@ -1,11 +1,11 @@
--- Component to handle placing components by row and columns.
-- Grid can anchor your elements, get content size and other
-- @module base.grid
local helper = require("druid.helper")
local M = {}
--- Sort and placing nodes
-- Plans: placing by max width, placing with max in_row
-- Allow different node sizes, allow animation with node insert
function M.init(self, parent, element, in_row)
self.parent = helper.get_node(parent)
@@ -111,4 +111,4 @@ function M.clear(self)
end
return M
return M

View File

@@ -1,3 +1,6 @@
--- Component to handle progress bars
-- @module base.progress
local data = require("druid.data")
local helper = require("druid.helper")
local settings = require("druid.settings")
@@ -147,4 +150,4 @@ function M.update(self, dt)
end
return M
return M

View File

@@ -1,3 +1,6 @@
--- Component to handle scroll content
-- @module base.scroll
local helper = require("druid.helper")
local data = require("druid.data")
local settings = require("druid.settings").scroll
@@ -310,7 +313,11 @@ function M.on_input(self, action_id, action)
end
--- Start scroll to point (x, y, z)
--- Start scroll to target point
-- @tparam point vector3 target point
-- @tparam[opt] bool is_instant instant scroll flag
-- @usage scroll:scroll_to(vmath.vector3(0, 50, 0))
-- @usage scroll:scroll_to(vmath.vector3(0), true)
function M.scroll_to(self, point, is_instant)
local b = self.border
local target = vmath.vector3(point)

View File

@@ -1,3 +1,7 @@
--- Component to handle all GUI texts
-- Good working with localization system
-- @module base.text
local data = require("druid.data")
local settings = require("druid.settings")
local helper = require("druid.helper")
@@ -81,4 +85,4 @@ function M.set_scale(self, scale)
end
return M
return M

View File

@@ -1,3 +1,6 @@
--- Component to handle GUI timers
-- @module base.timer
local data = require("druid.data")
local formats = require("druid.helper.formats")
local helper = require("druid.helper")
@@ -9,6 +12,7 @@ M.interest = {
local empty = function() end
function M.init(self, node, seconds_from, seconds_to, callback)
self.node = helper.get_node(node)
seconds_from = math.max(seconds_from, 0)