Update ldoc code comments

This commit is contained in:
Insality 2020-02-05 02:44:09 +03:00
parent 92098052e3
commit 544fd8d736
18 changed files with 98 additions and 20 deletions

View File

@ -1,5 +1,5 @@
--- Component to handle back key (android, backspace)
-- @module base.back_handler
-- @module druid.back_handler
local const = require("druid.const")
local component = require("druid.system.component")

View File

@ -1,5 +1,5 @@
--- Component to block input on specify zone (node)
-- @module base.blocker
-- @module druid.blocker
local const = require("druid.const")
local helper = require("druid.helper")

View File

@ -1,5 +1,5 @@
--- Component to handle basic GUI button
-- @module base.button
-- @module druid.button
-- TODO: Add button mode:
-- Long tap
@ -26,8 +26,10 @@ function M.init(self, node, callback, params, anim_node, event)
self.style = self:get_style()
self.node = helper.get_node(node)
-- TODO: match event inside on_input?
self.event = const.ACTION_TOUCH
self.anim_node = anim_node and helper.get_node(anim_node) or self.node
-- TODO: rename to start_scale
self.scale_from = gui.get_scale(self.anim_node)
self.pos = gui.get_position(self.anim_node)
self.callback = callback

View File

@ -1,5 +1,5 @@
--- Druid checkbox component
-- @module base.checkbox
-- @module druid.checkbox
local helper = require("druid.helper")
local component = require("druid.system.component")

View File

@ -1,5 +1,5 @@
--- Checkboux group module
-- @module base.checkbox_group
-- @module druid.checkbox_group
local component = require("druid.system.component")

View File

@ -1,6 +1,6 @@
--- Component to handle placing components by row and columns.
-- Grid can anchor your elements, get content size and other
-- @module base.grid
-- @module druid.grid
local helper = require("druid.helper")
local component = require("druid.system.component")

View File

@ -1,6 +1,6 @@
--- Component to handle all GUI texts
-- Good working with localization system
-- @module base.text
-- @module druid.locale
local const = require("druid.const")
local settings = require("druid.system.settings")

View File

@ -1,5 +1,5 @@
--- Basic progress bar component
-- @module base.progress
-- @module druid.progress
local const = require("druid.const")
local helper = require("druid.helper")

View File

@ -1,5 +1,5 @@
--- Radio group module
-- @module base.checkbox_group
-- @module druid.radio_group
local component = require("druid.system.component")

View File

@ -1,5 +1,5 @@
--- Component to handle scroll content
-- @module base.scroll
-- @module druid.scroll
local helper = require("druid.helper")
local const = require("druid.const")

View File

@ -1,5 +1,5 @@
--- Druid slider component
-- @module base.slider
-- @module druid.slider
local helper = require("druid.helper")
local const = require("druid.const")

View File

@ -1,6 +1,6 @@
--- Component to handle all GUI texts
-- Good working with localization system
-- @module base.text
-- @module druid.text
local const = require("druid.const")
local helper = require("druid.helper")

View File

@ -1,5 +1,5 @@
--- Component to handle GUI timers
-- @module base.timer
-- @module druid.timer
local const = require("druid.const")
local formats = require("druid.helper.formats")

View File

@ -1,8 +1,9 @@
--- Druid constants
-- @module constants
-- @module const
local M = {}
-- Actions
M.ACTION_TOUCH = hash("touch")
M.ACTION_TEXT = hash("text")
@ -10,22 +11,25 @@ M.ACTION_BACKSPACE = hash("backspace")
M.ACTION_ENTER = hash("enter")
M.ACTION_BACK = hash("back")
M.RELEASED = "released"
M.PRESSED = "pressed"
M.STRING = "string"
M.TABLE = "table"
M.ZERO = "0"
M.ALL = "all"
--- Interests
M.ON_MESSAGE = hash("on_message")
M.ON_UPDATE = hash("on_update")
-- Input
M.ON_SWIPE = hash("on_swipe")
M.ON_INPUT = hash("on_input")
M.PIVOTS = {
[gui.PIVOT_CENTER] = vmath.vector3(0),
[gui.PIVOT_N] = vmath.vector3(0, 0.5, 0),
@ -38,11 +42,13 @@ M.PIVOTS = {
[gui.PIVOT_NW] = vmath.vector3(-0.5, 0.5, 0),
}
M.SIDE = {
X = "x",
Y = "y"
}
M.UI_INPUT = {
[M.ON_SWIPE] = true,
[M.ON_INPUT] = true
@ -52,13 +58,34 @@ M.UI_INPUT = {
M.ON_CHANGE_LANGUAGE = hash("on_change_language")
M.ON_LAYOUT_CHANGED = hash("on_layout_changed")
M.SPECIFIC_UI_MESSAGES = {
[M.ON_CHANGE_LANGUAGE] = "on_change_language",
[M.ON_LAYOUT_CHANGED] = "on_layout_changed"
}
-- Basic druid components
M.COMPONENTS = {
BUTTON = "button",
BLOCKER = "blocker",
BACK_HANDLER = "back_handler",
TEXT = "text",
LOCALE = "locale",
TIMER = "timer",
PROGRESS = "progress",
GRID = "grid",
SCROLL = "scroll",
SLIDER = "slider",
CHECKBOX = "checkbox",
CHECKBOX_GROUP = "checkbox_group",
RADIO_GROUP = "radio_group",
}
M.EMPTY_FUNCTION = function() end
M.EMPTY_STRING = ""
M.EMPTY_TABLE = {}
return M

View File

@ -1,4 +1,4 @@
--- Druid helper module
-- Druid helper module
-- @module helper
local const = require("druid.const")

View File

@ -1,4 +1,4 @@
--- Druid helper module for animating GUI nodes
-- Druid helper module for animating GUI nodes
-- @module helper.animate
local M = {}

View File

@ -1,5 +1,5 @@
--- Component for rich progress component
-- @module rich.progress_rich
-- @module druid.progress_rich
local component = require("druid.system.component")

View File

@ -1,12 +1,19 @@
--- General component class
--@class component
--- Basic class for all Druid components.
-- To create you component, use `component.create`
-- @module component
local const = require("druid.const")
local class = require("druid.system.middleclass")
-- @classmod Component
local Component = class("druid.component")
--- Setup component context and his style table
-- @function component:setup_component
-- @tparam context table Druid context. Usually it is self of script
-- @tparam style table Druid style module
-- @treturn Component Component itself
function Component.setup_component(self, context, style)
self._meta = {
template = nil,
@ -22,6 +29,9 @@ function Component.setup_component(self, context, style)
end
--- Get current component style table
-- @function component:get_style
-- @treturn table Component style table
function Component.get_style(self)
if not self._meta.style then
return const.EMPTY_TABLE
@ -31,41 +41,65 @@ function Component.get_style(self)
end
--- Set current component style table
-- @function component:set_style
-- @tparam table style Druid style module
function Component.set_style(self, druid_style)
self._meta.style = druid_style
end
--- Get current component template name
-- @function component:get_template
-- @treturn string Component template name
function Component.get_template(self)
return self._meta.template
end
--- Set current component template name
-- @function component:set_template
-- @tparam string template Component template name
function Component.set_template(self, template)
self._meta.template = template
end
--- Get current component nodes
-- @function component:get_nodes
-- @treturn table Component nodes table
function Component.get_nodes(self)
return self._meta.nodes
end
--- Set current component nodes
-- @function component:set_nodes
-- @tparam table nodes Component nodes table
function Component.set_nodes(self, nodes)
self._meta.nodes = nodes
end
--- Get current component context
-- @function component:get_context
-- @treturn table Component context
function Component.get_context(self, context)
return self._meta.context
end
--- Set current component context
-- @function component:set_context
-- @tparam table context Druid context. Usually it is self of script
function Component.set_context(self, context)
self._meta.context = context
end
--- Get current component interests
-- @function component:get_interests
-- @treturn table List of component interests
function Component.get_interests(self)
return self._component.interest
end
@ -91,12 +125,22 @@ function Component.get_node(self, node_or_name)
end
--- Return druid with context of calling component.
-- Use it to create component inside of other components.
-- @function component:get_druid
-- @treturn Druid Druid instance with component context
function Component.get_druid(self)
local context = { _context = self }
return setmetatable(context, { __index = self:get_context().druid })
end
--- Basic constructor of component. It will call automaticaly
-- by `Component.static.create`
-- @function component:initialize
-- @tparam string name Component name
-- @tparam table interest List of component's interest
-- @local
function Component.initialize(self, name, interest)
self._component = {
name = name,
@ -105,6 +149,11 @@ function Component.initialize(self, name, interest)
end
--- Create new component. It will inheritance from basic
-- druid component.
-- @function Component.create
-- @tparam string name Component name
-- @tparam table interest List of component's interest
function Component.static.create(name, interest)
-- Yea, inheritance here
local new_class = class(name, Component)