Renamed class functions

This commit is contained in:
Insality
2020-09-29 23:09:37 +03:00
parent b9f8fc95f5
commit 0d07deb23a
19 changed files with 176 additions and 175 deletions

View File

@@ -11,14 +11,14 @@ local const = require("druid.const")
local helper = require("druid.helper")
local component = require("druid.component")
local M = component.create("hover", { const.ON_INPUT })
local Hover = component.create("hover", { const.ON_INPUT })
--- Component init function
-- @function hover:init
-- @tparam node node Gui node
-- @tparam function on_hover_callback Hover callback
function M.init(self, node, on_hover_callback)
function Hover:init(node, on_hover_callback)
self.node = self:get_node(node)
self._is_hovered = false
@@ -31,7 +31,7 @@ function M.init(self, node, on_hover_callback)
end
function M.on_input(self, action_id, action)
function Hover:on_input(action_id, action)
if action_id ~= const.ACTION_TOUCH and action_id ~= nil then
return false
end
@@ -49,7 +49,7 @@ function M.on_input(self, action_id, action)
is_pick = is_pick and gui.pick_node(self.click_zone, action.x, action.y)
end
local hover_function = action_id and M.set_hover or M.set_mouse_hover
local hover_function = action_id and self.set_hover or self.set_mouse_hover
if not is_pick then
hover_function(self, false)
@@ -64,7 +64,7 @@ function M.on_input(self, action_id, action)
end
function M.on_input_interrupt(self)
function Hover:on_input_interrupt()
self:set_hover(false)
end
@@ -72,7 +72,7 @@ end
--- Set hover state
-- @function hover:set_hover
-- @tparam bool state The hover state
function M.set_hover(self, state)
function Hover:set_hover(state)
if self._is_hovered ~= state then
self._is_hovered = state
self.on_hover:trigger(self:get_context(), state)
@@ -82,7 +82,7 @@ end
--- Set mouse hover state
-- @function hover:set_mouse_hover
-- @tparam bool state The mouse hover state
function M.set_mouse_hover(self, state)
function Hover:set_mouse_hover(state)
if self._is_mouse_hovered ~= state then
self._is_mouse_hovered = state
self.on_mouse_hover:trigger(self:get_context(), state)
@@ -94,7 +94,7 @@ end
-- no click events outside stencil node
-- @function hover:set_click_zone
-- @tparam node zone Gui node
function M.set_click_zone(self, zone)
function Hover:set_click_zone(zone)
self.click_zone = self:get_node(zone)
end
@@ -104,7 +104,7 @@ end
-- any hover events
-- @function hover:set_enabled
-- @tparam bool state The hover enabled state
function M.set_enabled(self, state)
function Hover:set_enabled(state)
self._is_enabled = state
if not state then
@@ -121,9 +121,9 @@ end
--- Return current hover enabled state
-- @function hover:is_enabled
-- @treturn bool The hover enabled state
function M.is_enabled(self)
function Hover:is_enabled()
return self._is_enabled
end
return M
return Hover