mirror of
https://github.com/Insality/druid
synced 2025-09-27 18:12:21 +02:00
Update
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
--- Container component
|
||||
---Container component
|
||||
-- Container setup in GUI
|
||||
-- parent container - container that contains this container. If not, then it's a window default container or parent node
|
||||
-- container pivot - the point of the parent container that will be used as a pivot point for positioning
|
||||
@@ -47,7 +47,7 @@ local CORNER_PIVOTS = {
|
||||
}
|
||||
|
||||
|
||||
--- The Container init
|
||||
---The Container init
|
||||
---@param node node Gui node
|
||||
---@param mode string Layout mode
|
||||
---@param callback fun(self: druid.container, size: vector3)|nil Callback on size changed
|
||||
@@ -118,7 +118,7 @@ function M:set_pivot(pivot)
|
||||
end
|
||||
|
||||
|
||||
--- Component style params.
|
||||
---Component style params.
|
||||
-- You can override this component styles params in Druid styles table
|
||||
-- or create your own style
|
||||
-- @table style
|
||||
@@ -131,7 +131,7 @@ function M:on_style_change(style)
|
||||
end
|
||||
|
||||
|
||||
--- Set new size of layout node
|
||||
---Set new size of layout node
|
||||
---@param width number|nil
|
||||
---@param height number|nil
|
||||
---@param anchor_pivot constant|nil If set will keep the corner possition relative to the new size
|
||||
@@ -207,7 +207,7 @@ function M:get_scale()
|
||||
end
|
||||
|
||||
|
||||
--- Set size for layout node to fit inside it
|
||||
---Set size for layout node to fit inside it
|
||||
---@param target_size vector3
|
||||
---@return druid.container Container
|
||||
function M:fit_into_size(target_size)
|
||||
@@ -218,7 +218,7 @@ function M:fit_into_size(target_size)
|
||||
end
|
||||
|
||||
|
||||
--- Set current size for layout node to fit inside it
|
||||
---Set current size for layout node to fit inside it
|
||||
---@return druid.container Container
|
||||
function M:fit_into_window()
|
||||
return self:fit_into_size(vmath.vector3(gui.get_width(), gui.get_height(), 0))
|
||||
@@ -388,7 +388,7 @@ function M:refresh()
|
||||
stretch_side_y = parent.size.y - (abs(self.node_offset.y) + abs(self.node_offset.w))
|
||||
end
|
||||
|
||||
---- Size Update (for stretch)
|
||||
----Size Update (for stretch)
|
||||
if self.mode == const.LAYOUT_MODE.STRETCH then
|
||||
self:set_size(
|
||||
abs(stretch_side_x * self.node_fill_x),
|
||||
@@ -522,7 +522,7 @@ function M:_on_corner_drag(x, y, corner_offset)
|
||||
end
|
||||
|
||||
|
||||
--- Set node for layout node to fit inside it. Pass nil to reset
|
||||
---Set node for layout node to fit inside it. Pass nil to reset
|
||||
---@param node string|node The node_id or gui.get_node(node_id)
|
||||
---@return druid.container Layout
|
||||
function M:fit_into_node(node)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
-- Copyright (c) 2021 Maksim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
|
||||
|
||||
--- Component to manage data for huge dataset in scroll.
|
||||
---Component to manage data for huge dataset in scroll.
|
||||
-- It requires Druid Scroll and Druid Grid (Static or Dynamic) components
|
||||
--
|
||||
-- <a href="https://insality.github.io/druid/druid/index.html?example=general_data_list" target="_blank"><b>Example Link</b></a>
|
||||
@@ -9,22 +9,22 @@
|
||||
-- @alias druid.data_list
|
||||
|
||||
|
||||
--- The Druid scroll component
|
||||
---The Druid scroll component
|
||||
-- @tfield Scroll scroll Scroll
|
||||
|
||||
--- The Druid Grid component
|
||||
---The Druid Grid component
|
||||
-- @tfield StaticGrid grid StaticGrid}, @{DynamicGrid
|
||||
|
||||
--- The current progress of scroll posititon
|
||||
---The current progress of scroll posititon
|
||||
-- @tfield number scroll_progress
|
||||
|
||||
--- The current top index of visual elements
|
||||
---The current top index of visual elements
|
||||
-- @tfield number top_index
|
||||
|
||||
--- The current last index of visual elements
|
||||
---The current last index of visual elements
|
||||
-- @tfield number last_index
|
||||
|
||||
--- Event triggered when scroll progress is changed; event(self, progress_value)
|
||||
---Event triggered when scroll progress is changed; event(self, progress_value)
|
||||
-- @tfield event on_scroll_progress_change event
|
||||
|
||||
---On DataList visual element created Event callback(self, index, node, instance)
|
||||
@@ -55,7 +55,7 @@ local event = require("event.event")
|
||||
local M = component.create("data_list")
|
||||
|
||||
|
||||
--- The DataList constructor
|
||||
---The DataList constructor
|
||||
---@param scroll druid.scroll The Scroll instance for Data List component
|
||||
---@param grid druid.grid The StaticGrid} or @{DynamicGrid instance for Data List component
|
||||
---@param create_function function The create function callback(self, data, index, data_list). Function should return (node, [component])
|
||||
@@ -85,14 +85,14 @@ function M:init(scroll, grid, create_function)
|
||||
end
|
||||
|
||||
|
||||
--- Druid System on_remove function
|
||||
---Druid System on_remove function
|
||||
function M:on_remove()
|
||||
self:clear()
|
||||
self.scroll.on_scroll:unsubscribe(self._refresh, self)
|
||||
end
|
||||
|
||||
|
||||
--- Set refresh function for DataList component
|
||||
---Set refresh function for DataList component
|
||||
---@param is_use_cache boolean Use cache version of DataList. Requires make setup of components in on_element_add callback and clean in on_element_remove
|
||||
---@return druid.data_list Current DataList instance
|
||||
function M:set_use_cache(is_use_cache)
|
||||
@@ -101,7 +101,7 @@ function M:set_use_cache(is_use_cache)
|
||||
end
|
||||
|
||||
|
||||
--- Set new data set for DataList component
|
||||
---Set new data set for DataList component
|
||||
---@param data table The new data array
|
||||
---@return druid.data_list Current DataList instance
|
||||
function M:set_data(data)
|
||||
@@ -112,14 +112,14 @@ function M:set_data(data)
|
||||
end
|
||||
|
||||
|
||||
--- Return current data from DataList component
|
||||
---Return current data from DataList component
|
||||
---@return table The current data array
|
||||
function M:get_data()
|
||||
return self._data
|
||||
end
|
||||
|
||||
|
||||
--- Add element to DataList. Currenly untested
|
||||
---Add element to DataList. Currenly untested
|
||||
---@param data table
|
||||
---@param index number|nil
|
||||
---@param shift_policy number|nil The constant from const.SHIFT.*
|
||||
@@ -132,7 +132,7 @@ function M:add(data, index, shift_policy)
|
||||
end
|
||||
|
||||
|
||||
--- Remove element from DataList. Currenly untested
|
||||
---Remove element from DataList. Currenly untested
|
||||
---@param index number|nil
|
||||
---@param shift_policy number|nil The constant from const.SHIFT.*
|
||||
function M:remove(index, shift_policy)
|
||||
@@ -141,7 +141,7 @@ function M:remove(index, shift_policy)
|
||||
end
|
||||
|
||||
|
||||
--- Remove element from DataList by data value. Currenly untested
|
||||
---Remove element from DataList by data value. Currenly untested
|
||||
---@param data table
|
||||
---@param shift_policy number|nil The constant from const.SHIFT.*
|
||||
function M:remove_by_data(data, shift_policy)
|
||||
@@ -153,14 +153,14 @@ function M:remove_by_data(data, shift_policy)
|
||||
end
|
||||
|
||||
|
||||
--- Clear the DataList and refresh visuals
|
||||
---Clear the DataList and refresh visuals
|
||||
function M:clear()
|
||||
self._data = {}
|
||||
self:_refresh()
|
||||
end
|
||||
|
||||
|
||||
--- Return index for data value
|
||||
---Return index for data value
|
||||
---@param data table
|
||||
function M:get_index(data)
|
||||
for index, value in pairs(self._data) do
|
||||
@@ -173,7 +173,7 @@ function M:get_index(data)
|
||||
end
|
||||
|
||||
|
||||
--- Return all currenly created nodes in DataList
|
||||
---Return all currenly created nodes in DataList
|
||||
---@return node[] List of created nodes
|
||||
function M:get_created_nodes()
|
||||
local nodes = {}
|
||||
@@ -186,7 +186,7 @@ function M:get_created_nodes()
|
||||
end
|
||||
|
||||
|
||||
--- Return all currenly created components in DataList
|
||||
---Return all currenly created components in DataList
|
||||
---@return druid.component[] List of created nodes
|
||||
function M:get_created_components()
|
||||
local components = {}
|
||||
@@ -199,7 +199,7 @@ function M:get_created_components()
|
||||
end
|
||||
|
||||
|
||||
--- Instant scroll to element with passed index
|
||||
---Instant scroll to element with passed index
|
||||
---@param index number
|
||||
function M:scroll_to_index(index)
|
||||
local pos = self.grid:get_pos(index)
|
||||
@@ -207,7 +207,7 @@ function M:scroll_to_index(index)
|
||||
end
|
||||
|
||||
|
||||
--- Add element at passed index using cache or create new
|
||||
---Add element at passed index using cache or create new
|
||||
---@param index number
|
||||
---@private
|
||||
function M:_add_at(index)
|
||||
@@ -240,7 +240,7 @@ function M:_add_at(index)
|
||||
end
|
||||
|
||||
|
||||
--- Remove element from passed index and add it to cache if applicable
|
||||
---Remove element from passed index and add it to cache if applicable
|
||||
---@param index number
|
||||
---@private
|
||||
function M:_remove_at(index)
|
||||
@@ -270,7 +270,7 @@ end
|
||||
|
||||
|
||||
|
||||
--- Refresh all elements in DataList
|
||||
---Refresh all elements in DataList
|
||||
---@private
|
||||
function M:_refresh()
|
||||
self.scroll:set_size(self.grid:get_size_for(#self._data))
|
||||
|
@@ -1,25 +1,25 @@
|
||||
-- Copyright (c) 2021 Maksim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
|
||||
|
||||
--- Druid hotkey component
|
||||
---Druid hotkey component
|
||||
--
|
||||
-- <a href="https://insality.github.io/druid/druid/index.html?example=general_hotkey" target="_blank"><b>Example Link</b></a>
|
||||
-- @module Hotkey
|
||||
-- @within BaseComponent
|
||||
-- @alias druid.hotkey
|
||||
|
||||
--- On hotkey released callback(self, argument)
|
||||
---On hotkey released callback(self, argument)
|
||||
-- @tfield event on_hotkey_pressed event
|
||||
|
||||
--- On hotkey released callback(self, argument)
|
||||
---On hotkey released callback(self, argument)
|
||||
-- @tfield event on_hotkey_released event
|
||||
|
||||
--- Visual node
|
||||
---Visual node
|
||||
-- @tfield node node
|
||||
|
||||
--- Button trigger node
|
||||
---Button trigger node
|
||||
-- @tfield node|nil click_node
|
||||
|
||||
--- Button component from click_node
|
||||
---Button component from click_node
|
||||
-- @tfield Button button Button
|
||||
|
||||
---
|
||||
@@ -37,7 +37,7 @@ local event = require("event.event")
|
||||
local M = component.create("hotkey")
|
||||
|
||||
|
||||
--- The Hotkey constructor
|
||||
---The Hotkey constructor
|
||||
---@param keys string[]|string The keys to be pressed for trigger callback. Should contains one key and any modificator keys
|
||||
---@param callback function The callback function
|
||||
---@param callback_argument any|nil The argument to pass into the callback function
|
||||
@@ -56,7 +56,7 @@ function M:init(keys, callback, callback_argument)
|
||||
end
|
||||
|
||||
|
||||
--- Component style params.
|
||||
---Component style params.
|
||||
-- You can override this component styles params in druid styles table
|
||||
-- or create your own style
|
||||
-- @table style
|
||||
@@ -71,7 +71,7 @@ function M:on_style_change(style)
|
||||
end
|
||||
|
||||
|
||||
--- Add hotkey for component callback
|
||||
---Add hotkey for component callback
|
||||
---@param keys string[]|hash[]|string|hash that have to be pressed before key pressed to activate
|
||||
---@param callback_argument any|nil The argument to pass into the callback function
|
||||
---@return druid.hotkey Current instance
|
||||
@@ -186,7 +186,7 @@ function M:on_input(action_id, action)
|
||||
end
|
||||
|
||||
|
||||
--- If true, the callback will be triggered on action.repeated
|
||||
---If true, the callback will be triggered on action.repeated
|
||||
---@param is_enabled_repeated bool The flag value
|
||||
---@return druid.hotkey
|
||||
function M:set_repeat(is_enabled_repeated)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
-- Copyright (c) 2021 Maksim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
|
||||
|
||||
--- Druid input text component.
|
||||
---Druid input text component.
|
||||
-- Carry on user text input
|
||||
--
|
||||
-- <a href="https://insality.github.io/druid/druid/index.html?example=general_input" target="_blank"><b>Example Link</b></a>
|
||||
@@ -9,73 +9,73 @@
|
||||
-- @within BaseComponent
|
||||
-- @alias druid.input
|
||||
|
||||
--- On input field select callback(self, input_instance)
|
||||
---On input field select callback(self, input_instance)
|
||||
-- @tfield event on_input_select event
|
||||
|
||||
--- On input field unselect callback(self, input_text, input_instance)
|
||||
---On input field unselect callback(self, input_text, input_instance)
|
||||
-- @tfield event on_input_unselect event
|
||||
|
||||
--- On input field text change callback(self, input_text)
|
||||
---On input field text change callback(self, input_text)
|
||||
-- @tfield event on_input_text event
|
||||
|
||||
--- On input field text change to empty string callback(self, input_text)
|
||||
---On input field text change to empty string callback(self, input_text)
|
||||
-- @tfield event on_input_empty event
|
||||
|
||||
--- On input field text change to max length string callback(self, input_text)
|
||||
---On input field text change to max length string callback(self, input_text)
|
||||
-- @tfield event on_input_full event
|
||||
|
||||
--- On trying user input with not allowed character callback(self, params, input_text)
|
||||
---On trying user input with not allowed character callback(self, params, input_text)
|
||||
-- @tfield event on_input_wrong event
|
||||
|
||||
--- On cursor position change callback(self, cursor_index, start_index, end_index)
|
||||
---On cursor position change callback(self, cursor_index, start_index, end_index)
|
||||
-- @tfield event on_select_cursor_change event
|
||||
|
||||
--- The cursor index. The index of letter cursor after. Leftmost cursor - 0
|
||||
---The cursor index. The index of letter cursor after. Leftmost cursor - 0
|
||||
-- @tfield number cursor_index
|
||||
|
||||
--- The selection start index. The index of letter cursor after. Leftmost selection - 0
|
||||
---The selection start index. The index of letter cursor after. Leftmost selection - 0
|
||||
-- @tfield number start_index
|
||||
|
||||
--- Theselection end index. The index of letter cursor before. Rightmost selection - #text
|
||||
---Theselection end index. The index of letter cursor before. Rightmost selection - #text
|
||||
-- @tfield number end_index
|
||||
|
||||
--- Text component
|
||||
---Text component
|
||||
-- @tfield Text text Text
|
||||
|
||||
--- Current input value
|
||||
---Current input value
|
||||
-- @tfield string value
|
||||
|
||||
--- Previous input value
|
||||
---Previous input value
|
||||
-- @tfield string previous_value
|
||||
|
||||
--- Current input value with marked text
|
||||
---Current input value with marked text
|
||||
-- @tfield string current_value
|
||||
|
||||
--- Marked text for input field. Info: https://defold.com/manuals/input-key-and-text/#marked-text
|
||||
---Marked text for input field. Info: https://defold.com/manuals/input-key-and-text/#marked-text
|
||||
-- @tfield string marked_value
|
||||
|
||||
--- Text width
|
||||
---Text width
|
||||
-- @tfield number text_width
|
||||
|
||||
--- Marked text width
|
||||
---Marked text width
|
||||
-- @tfield number marked_text_width
|
||||
|
||||
--- Button component
|
||||
---Button component
|
||||
-- @tfield Button button Button
|
||||
|
||||
--- Is current input selected now
|
||||
---Is current input selected now
|
||||
-- @tfield boolean is_selected
|
||||
|
||||
--- Is current input is empty now
|
||||
---Is current input is empty now
|
||||
-- @tfield boolean is_empty
|
||||
|
||||
--- Max length for input text
|
||||
---Max length for input text
|
||||
-- @tfield number|nil max_length
|
||||
|
||||
--- Pattern matching for user input
|
||||
---Pattern matching for user input
|
||||
-- @tfield string|nil allowerd_characters
|
||||
|
||||
--- Gui keyboard type for input field
|
||||
---Gui keyboard type for input field
|
||||
-- @tfield number keyboard_type
|
||||
|
||||
---
|
||||
@@ -108,7 +108,7 @@ M.ALLOWED_ACTIONS = {
|
||||
[const.ACTION_ESC] = true,
|
||||
}
|
||||
|
||||
--- Mask text by replacing every character with a mask character
|
||||
---Mask text by replacing every character with a mask character
|
||||
---@param text string
|
||||
---@param mask string
|
||||
---@return string Masked text
|
||||
@@ -132,7 +132,7 @@ local function clear_and_select(self)
|
||||
end
|
||||
|
||||
|
||||
--- Component style params.
|
||||
---Component style params.
|
||||
-- You can override this component styles params in druid styles table
|
||||
-- or create your own style
|
||||
-- @table style
|
||||
@@ -155,7 +155,7 @@ function M:on_style_change(style)
|
||||
end
|
||||
|
||||
|
||||
--- The Input constructor
|
||||
---The Input constructor
|
||||
---@param click_node node Node to enabled input component
|
||||
---@param text_node node|druid.text Text node what will be changed on user input. You can pass text component instead of text node name Text
|
||||
---@param keyboard_type number|nil Gui keyboard type for input field
|
||||
@@ -326,7 +326,7 @@ function M:get_text_selected()
|
||||
return utf8.sub(self.value, self.start_index + 1, self.end_index)
|
||||
end
|
||||
|
||||
--- Replace selected text with new text
|
||||
---Replace selected text with new text
|
||||
---@param text string The text to replace selected text
|
||||
---@return string New input text
|
||||
function M:get_text_selected_replaced(text)
|
||||
@@ -343,7 +343,7 @@ function M:get_text_selected_replaced(text)
|
||||
end
|
||||
|
||||
|
||||
--- Set text for input field
|
||||
---Set text for input field
|
||||
---@param input_text string The string to apply for input field
|
||||
function M:set_text(input_text)
|
||||
input_text = tostring(input_text or "")
|
||||
@@ -391,7 +391,7 @@ function M:set_text(input_text)
|
||||
end
|
||||
|
||||
|
||||
--- Select input field. It will show the keyboard and trigger on_select events
|
||||
---Select input field. It will show the keyboard and trigger on_select events
|
||||
function M:select()
|
||||
gui.reset_keyboard()
|
||||
self.marked_value = ""
|
||||
@@ -415,7 +415,7 @@ function M:select()
|
||||
end
|
||||
|
||||
|
||||
--- Remove selection from input. It will hide the keyboard and trigger on_unselect events
|
||||
---Remove selection from input. It will hide the keyboard and trigger on_unselect events
|
||||
function M:unselect()
|
||||
gui.reset_keyboard()
|
||||
self.marked_value = ""
|
||||
@@ -433,7 +433,7 @@ function M:unselect()
|
||||
end
|
||||
|
||||
|
||||
--- Return current input field text
|
||||
---Return current input field text
|
||||
---@return string The current input field text
|
||||
function M:get_text()
|
||||
if self.marked_value ~= "" then
|
||||
@@ -444,7 +444,7 @@ function M:get_text()
|
||||
end
|
||||
|
||||
|
||||
--- Set maximum length for input field.
|
||||
---Set maximum length for input field.
|
||||
-- Pass nil to make input field unliminted (by default)
|
||||
---@param max_length number Maximum length for input text field
|
||||
---@return druid.input Current input instance
|
||||
@@ -454,7 +454,7 @@ function M:set_max_length(max_length)
|
||||
end
|
||||
|
||||
|
||||
--- Set allowed charaters for input field.
|
||||
---Set allowed charaters for input field.
|
||||
-- See: https://defold.com/ref/stable/string/
|
||||
-- ex: [%a%d] for alpha and numeric
|
||||
---@param characters string Regulax exp. for validate user input
|
||||
@@ -465,7 +465,7 @@ function M:set_allowed_characters(characters)
|
||||
end
|
||||
|
||||
|
||||
--- Reset current input selection and return previous value
|
||||
---Reset current input selection and return previous value
|
||||
---@return druid.input Current input instance
|
||||
function M:reset_changes()
|
||||
self:set_text(self.previous_value)
|
||||
@@ -474,7 +474,7 @@ function M:reset_changes()
|
||||
end
|
||||
|
||||
|
||||
--- Set cursor position in input field
|
||||
---Set cursor position in input field
|
||||
---@param cursor_index number|nil Cursor index for cursor position, if nil - will be set to the end of the text
|
||||
---@param start_index number|nil Start index for cursor position, if nil - will be set to the end of the text
|
||||
---@param end_index number|nil End index for cursor position, if nil - will be set to the start_index
|
||||
@@ -496,7 +496,7 @@ function M:select_cursor(cursor_index, start_index, end_index)
|
||||
end
|
||||
|
||||
|
||||
--- Change cursor position by delta
|
||||
---Change cursor position by delta
|
||||
---@param delta number side for cursor position, -1 for left, 1 for right
|
||||
---@param is_add_to_selection boolean (Shift key)
|
||||
---@param is_move_to_end boolean (Ctrl key)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
-- Copyright (c) 2021 Maksim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
|
||||
|
||||
--- Component to wrap over GUI Text nodes with localization helpers
|
||||
---Component to wrap over GUI Text nodes with localization helpers
|
||||
--
|
||||
-- <b># Overview #</b>
|
||||
--
|
||||
@@ -17,13 +17,13 @@
|
||||
-- @within BaseComponent
|
||||
-- @alias druid.lang_text
|
||||
|
||||
--- On change text callback
|
||||
---On change text callback
|
||||
-- @tfield event on_change event
|
||||
|
||||
--- The text component
|
||||
---The text component
|
||||
-- @tfield Text text Text
|
||||
|
||||
--- Text node
|
||||
---Text node
|
||||
-- @tfield node node
|
||||
|
||||
---
|
||||
@@ -41,7 +41,7 @@ local component = require("druid.component")
|
||||
local M = component.create("lang_text")
|
||||
|
||||
|
||||
--- The LangText constructor
|
||||
---The LangText constructor
|
||||
---@param node string|node The node_id or gui.get_node(node_id)
|
||||
---@param locale_id string|nil Default locale id or text from node as default
|
||||
---@param adjust_type string|nil Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference
|
||||
@@ -67,7 +67,7 @@ function M:on_language_change()
|
||||
end
|
||||
|
||||
|
||||
--- Setup raw text to lang_text component
|
||||
---Setup raw text to lang_text component
|
||||
---@param text string Text for text node
|
||||
---@return druid.lang_text Current instance
|
||||
function M:set_to(text)
|
||||
@@ -79,7 +79,7 @@ function M:set_to(text)
|
||||
end
|
||||
|
||||
|
||||
--- Setup raw text to lang_text component
|
||||
---Setup raw text to lang_text component
|
||||
---@param text string Text for text node
|
||||
---@return druid.lang_text Current instance
|
||||
function M:set_text(text)
|
||||
@@ -87,7 +87,7 @@ function M:set_text(text)
|
||||
end
|
||||
|
||||
|
||||
--- Translate the text by locale_id
|
||||
---Translate the text by locale_id
|
||||
---@param locale_id string Locale id
|
||||
---@param ... string Optional params for string.format
|
||||
---@return druid.lang_text Current instance
|
||||
@@ -100,7 +100,7 @@ function M:translate(locale_id, ...)
|
||||
end
|
||||
|
||||
|
||||
--- Format string with new text params on localized text
|
||||
---Format string with new text params on localized text
|
||||
---@param ... string Optional params for string.format
|
||||
---@return druid.lang_text Current instance
|
||||
function M:format(...)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
-- Copyright (c) 2021 Maksim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
|
||||
|
||||
--- Druid component to handle the progress bars.
|
||||
---Druid component to handle the progress bars.
|
||||
-- <b># Overview #</b>
|
||||
--
|
||||
-- <b># Notes #</b>
|
||||
@@ -19,27 +19,27 @@
|
||||
-- @within BaseComponent
|
||||
-- @alias druid.progress
|
||||
|
||||
--- On progress bar change callback(self, new_value)
|
||||
---On progress bar change callback(self, new_value)
|
||||
-- @tfield event on_change event
|
||||
|
||||
--- Progress bar fill node
|
||||
---Progress bar fill node
|
||||
-- @tfield node node
|
||||
|
||||
--- The progress bar direction.
|
||||
---The progress bar direction.
|
||||
--
|
||||
-- The values are: "x" or "y". (const.SIDE.X or const.SIDE.Y)
|
||||
-- @tfield string key
|
||||
|
||||
--- Current progress bar scale
|
||||
---Current progress bar scale
|
||||
-- @tfield vector3 scale
|
||||
|
||||
--- Current progress bar size
|
||||
---Current progress bar size
|
||||
-- @tfield vector3 size
|
||||
|
||||
--- Maximum size of progress bar
|
||||
---Maximum size of progress bar
|
||||
-- @tfield number max_size
|
||||
|
||||
--- Progress bar slice9 settings
|
||||
---Progress bar slice9 settings
|
||||
-- @tfield vector4 slice
|
||||
|
||||
---
|
||||
@@ -117,7 +117,7 @@ local function set_bar_to(self, set_to, is_silent)
|
||||
end
|
||||
|
||||
|
||||
--- Component style params.
|
||||
---Component style params.
|
||||
-- You can override this component styles params in druid styles table
|
||||
-- or create your own style
|
||||
-- @table style
|
||||
@@ -130,7 +130,7 @@ function M:on_style_change(style)
|
||||
end
|
||||
|
||||
|
||||
--- The Progress constructor
|
||||
---The Progress constructor
|
||||
---@param node string|node Node name or GUI Node itself.
|
||||
---@param key string Progress bar direction: const.SIDE.X or const.SIDE.Y
|
||||
---@param init_value number|nil Initial value of progress bar. Default: 1
|
||||
@@ -191,19 +191,19 @@ function M:update(dt)
|
||||
end
|
||||
|
||||
|
||||
--- Fill a progress bar and stop progress animation
|
||||
---Fill a progress bar and stop progress animation
|
||||
function M:fill()
|
||||
set_bar_to(self, 1, true)
|
||||
end
|
||||
|
||||
|
||||
--- Empty a progress bar
|
||||
---Empty a progress bar
|
||||
function M:empty()
|
||||
set_bar_to(self, 0, true)
|
||||
end
|
||||
|
||||
|
||||
--- Instant fill progress bar to value
|
||||
---Instant fill progress bar to value
|
||||
---@param to number Progress bar value, from 0 to 1
|
||||
function M:set_to(to)
|
||||
to = helper.clamp(to, 0, 1)
|
||||
@@ -211,13 +211,13 @@ function M:set_to(to)
|
||||
end
|
||||
|
||||
|
||||
--- Return current progress bar value
|
||||
---Return current progress bar value
|
||||
function M:get()
|
||||
return self.last_value
|
||||
end
|
||||
|
||||
|
||||
--- Set points on progress bar to fire the callback
|
||||
---Set points on progress bar to fire the callback
|
||||
---@param steps number[] Array of progress bar values
|
||||
---@param callback function Callback on intersect step value
|
||||
-- @usage progress:set_steps({0, 0.3, 0.6, 1}, function(self, step) end)
|
||||
@@ -227,7 +227,7 @@ function M:set_steps(steps, callback)
|
||||
end
|
||||
|
||||
|
||||
--- Start animation of a progress bar
|
||||
---Start animation of a progress bar
|
||||
---@param to number value between 0..1
|
||||
---@param callback function|nil Callback on animation ends
|
||||
function M:to(to, callback)
|
||||
@@ -245,7 +245,7 @@ function M:to(to, callback)
|
||||
end
|
||||
|
||||
|
||||
--- Set progress bar max node size
|
||||
---Set progress bar max node size
|
||||
---@param max_size vector3 The new node maximum (full) size
|
||||
---@return druid.progress Progress
|
||||
function M:set_max_size(max_size)
|
||||
|
@@ -1,37 +1,37 @@
|
||||
-- Copyright (c) 2021 Maksim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
|
||||
|
||||
--- Druid slider component
|
||||
---Druid slider component
|
||||
--
|
||||
-- <a href="https://insality.github.io/druid/druid/index.html?example=general_sliders" target="_blank"><b>Example Link</b></a>
|
||||
-- @module Slider
|
||||
-- @within BaseComponent
|
||||
-- @alias druid.slider
|
||||
|
||||
--- On change value callback(self, value)
|
||||
---On change value callback(self, value)
|
||||
-- @tfield event on_change_value event
|
||||
|
||||
--- Slider pin node
|
||||
---Slider pin node
|
||||
-- @tfield node node
|
||||
|
||||
--- Start pin node position
|
||||
---Start pin node position
|
||||
-- @tfield vector3 start_pos
|
||||
|
||||
--- Current pin node position
|
||||
---Current pin node position
|
||||
-- @tfield vector3 pos
|
||||
|
||||
--- Targer pin node position
|
||||
---Targer pin node position
|
||||
-- @tfield vector3 target_pos
|
||||
|
||||
--- End pin node position
|
||||
---End pin node position
|
||||
-- @tfield vector3 end_pos
|
||||
|
||||
--- Length between start and end position
|
||||
---Length between start and end position
|
||||
-- @tfield vector3 dist
|
||||
|
||||
--- Current drag state
|
||||
---Current drag state
|
||||
-- @tfield boolean is_drag
|
||||
|
||||
--- Current slider value
|
||||
---Current slider value
|
||||
-- @tfield number value
|
||||
|
||||
---
|
||||
@@ -68,7 +68,7 @@ local function set_position(self, value)
|
||||
end
|
||||
|
||||
|
||||
--- The Slider constructor
|
||||
---The Slider constructor
|
||||
---@param node node Gui pin node
|
||||
---@param end_pos vector3 The end position of slider
|
||||
---@param callback function|nil On slider change callback
|
||||
@@ -195,7 +195,7 @@ function M:on_input(action_id, action)
|
||||
end
|
||||
|
||||
|
||||
--- Set value for slider
|
||||
---Set value for slider
|
||||
---@param value number Value from 0 to 1
|
||||
---@param is_silent boolean|nil Don't trigger event if true
|
||||
function M:set(value, is_silent)
|
||||
@@ -208,7 +208,7 @@ function M:set(value, is_silent)
|
||||
end
|
||||
|
||||
|
||||
--- Set slider steps. Pin node will
|
||||
---Set slider steps. Pin node will
|
||||
-- apply closest step position
|
||||
---@param steps number[] Array of steps
|
||||
-- @usage slider:set_steps({0, 0.2, 0.6, 1})
|
||||
@@ -219,7 +219,7 @@ function M:set_steps(steps)
|
||||
end
|
||||
|
||||
|
||||
--- Set input zone for slider.
|
||||
---Set input zone for slider.
|
||||
-- User can touch any place of node, pin instantly will
|
||||
-- move at this position and node drag will start.
|
||||
-- This function require the Defold version 1.3.0+
|
||||
@@ -236,14 +236,14 @@ function M:set_input_node(input_node)
|
||||
end
|
||||
|
||||
|
||||
--- Set Slider input enabled or disabled
|
||||
---Set Slider input enabled or disabled
|
||||
---@param is_enabled boolean
|
||||
function M:set_enabled(is_enabled)
|
||||
self._is_enabled = is_enabled
|
||||
end
|
||||
|
||||
|
||||
--- Check if Slider component is enabled
|
||||
---Check if Slider component is enabled
|
||||
---@return boolean
|
||||
function M:is_enabled()
|
||||
return self._is_enabled
|
||||
|
@@ -96,7 +96,7 @@ function M:on_input_interrupt()
|
||||
end
|
||||
|
||||
|
||||
--- Strict swipe click area. Useful for
|
||||
---Strict swipe click area. Useful for
|
||||
-- restrict events outside stencil node
|
||||
---@param zone node|string|nil Gui node
|
||||
function M:set_click_zone(zone)
|
||||
|
Reference in New Issue
Block a user