Add more annotations, update grid_page example

This commit is contained in:
Insality
2020-11-29 22:17:51 +03:00
parent 14a4e4365e
commit 897d401142
6 changed files with 63 additions and 22 deletions

View File

@@ -267,6 +267,7 @@ end
-- It will change content gui node size
-- @tparam Scroll self
-- @tparam vector3 size The new size for content node
-- @tparam vector3 offset Offset value to set, where content is starts
-- @treturn druid.scroll Current scroll instance
function Scroll.set_size(self, size, offset)
if offset then
@@ -361,6 +362,10 @@ function Scroll.set_vertical_scroll(self, state)
end
--- Check node if it visible now on scroll
-- @tparam Scroll self
-- @tparma node node The node to check
-- @treturn boolean True, if node in visible scroll area
function Scroll.is_node_in_view(self, node)
local node_border = helper.get_border(node, gui.get_position(node))
local view_border = helper.get_border(self.view_node, -self.position)

View File

@@ -318,7 +318,9 @@ function StaticGrid.clear(self)
end
-- return vector where content borders starts
--- Return StaticGrid offset, where StaticGrid content starts.
-- @tparam StaticGrid self The StaticGrid instance
-- @treturn vector3 The StaticGrid offset
function StaticGrid:get_offset()
local borders = self:get_borders()
local size = self:get_size()

View File

@@ -224,6 +224,21 @@ function DynamicGrid.get_size(self, border)
end
--- Return DynamicGrid offset, where DynamicGrid content starts.
-- @tparam DynamicGrid self The DynamicGrid instance
-- @treturn vector3 The DynamicGrid offset
function DynamicGrid.get_offset(self)
local size = self:get_size()
local borders = self:get_borders()
local offset = vmath.vector3(
(borders.z + borders.x)/2 + size.x * self.pivot.x,
(borders.y + borders.w)/2 + size.y * self.pivot.y,
0)
return offset
end
--- Return grid content borders
-- @tparam DynamicGrid self
-- @treturn vector3 The grid content borders
@@ -391,24 +406,12 @@ function DynamicGrid._get_next_node_pos(self, origin_node_index, new_node, place
end
function DynamicGrid._get_node_size(self, node)
return vmath.mul_per_elem(gui.get_size(node), gui.get_scale(node))
end
function DynamicGrid:get_offset()
-- return vector where content borders starts
local size = self:get_size()
local borders = self:get_borders()
local offset = vmath.vector3(
(borders.z + borders.x)/2 + size.x * self.pivot.x,
(borders.y + borders.w)/2 + size.y * self.pivot.y,
0)
return offset
end
--- Return side vector to correct node shifting
function DynamicGrid._get_side_vector(self, side, is_forward)
if side == const.SIDE.X then

View File

@@ -183,9 +183,11 @@ function M.is_web()
end
--- Distance from node to size border
--- Distance from node position to his borders
-- @function helper.get_border
-- @return vector4 (left, top, right, down)
-- @tparam node node The gui node to check
-- @tparam vector3 offset The offset to add to result
-- @return vector4 Vector with distance to node border: (left, top, right, down)
function M.get_border(node, offset)
local pivot = gui.get_pivot(node)
local pivot_offset = M.get_pivot_offset(pivot)