mirror of
https://github.com/Insality/druid
synced 2025-06-27 10:27:48 +02:00
Update docs
This commit is contained in:
parent
4896f38e09
commit
15cf72df27
@ -7,7 +7,7 @@
|
|||||||
[](https://github.com/Insality/druid/actions)
|
[](https://github.com/Insality/druid/actions)
|
||||||
[](https://codecov.io/gh/Insality/druid)
|
[](https://codecov.io/gh/Insality/druid)
|
||||||
|
|
||||||
**Druid** - most powerful Defold component UI framework. Use basic and extended **Druid** components or make your own game-specific components with ease to make stunning and customizable GUI in your games.
|
**Druid** - powerful Defold component UI framework. Use huge list of embedeed **Druid** components or make your own game-specific components with ease to make stunning and customizable GUI in your games.
|
||||||
|
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
@ -133,7 +133,7 @@ Usually, Place _view_node_ and as children add _content_node_:
|
|||||||
- *on_scroll_to* (self, position, is_instant) On scroll_to function callback
|
- *on_scroll_to* (self, position, is_instant) On scroll_to function callback
|
||||||
- *on_point_scroll* (self, item_index, position) On scroll_to_index function callback
|
- *on_point_scroll* (self, item_index, position) On scroll_to_index function callback
|
||||||
- You can adjust scroll content size by `scroll:set_size(node_size)`. It will setup new size to _content node_
|
- You can adjust scroll content size by `scroll:set_size(node_size)`. It will setup new size to _content node_
|
||||||
- You can enabled or disable inertion mode via `scroll:set_intert(state)`
|
- You can enabled or disable inertion mode via `scroll:set_inert(state)`
|
||||||
- You can adjust extra stretch size via `scroll:set_extra_stretch_size`
|
- You can adjust extra stretch size via `scroll:set_extra_stretch_size`
|
||||||
- Multitouch is required for scroll. Scroll is correctly handling touch_id swap while dragging scroll
|
- Multitouch is required for scroll. Scroll is correctly handling touch_id swap while dragging scroll
|
||||||
|
|
||||||
|
@ -245,7 +245,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Component style params.
|
--- Component style params.
|
||||||
-- You can override this component styles params in druid styles table
|
-- You can override this component styles params in Druid styles table
|
||||||
-- or create your own style
|
-- or create your own style
|
||||||
-- @table style
|
-- @table style
|
||||||
-- @tfield[opt=0.4] number LONGTAP_TIME Minimum time to trigger on_hold_callback
|
-- @tfield[opt=0.4] number LONGTAP_TIME Minimum time to trigger on_hold_callback
|
||||||
@ -270,13 +270,13 @@ function Button.on_style_change(self, style)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Button component constructor
|
--- @{Button} constructor
|
||||||
-- @tparam Button self @{Button}
|
-- @tparam Button self @{Button}
|
||||||
-- @tparam node node Gui node
|
-- @tparam string|Node node Node name or GUI Node itself
|
||||||
-- @tparam function callback Button callback
|
-- @tparam function callback On click button callback
|
||||||
-- @tparam[opt] table params Button callback params
|
-- @tparam[opt] table custom_args Button events custom arguments
|
||||||
-- @tparam[opt] node anim_node Button anim node (node, if not provided)
|
-- @tparam[opt] string|Node anim_node Node to animate instead of trigger node
|
||||||
function Button.init(self, node, callback, params, anim_node)
|
function Button.init(self, node, callback, custom_args, anim_node)
|
||||||
self.druid = self:get_druid()
|
self.druid = self:get_druid()
|
||||||
self.node = self:get_node(node)
|
self.node = self:get_node(node)
|
||||||
self.node_id = gui.get_id(self.node)
|
self.node_id = gui.get_id(self.node)
|
||||||
@ -284,7 +284,7 @@ function Button.init(self, node, callback, params, anim_node)
|
|||||||
self.anim_node = anim_node and self:get_node(anim_node) or self.node
|
self.anim_node = anim_node and self:get_node(anim_node) or self.node
|
||||||
self.start_scale = gui.get_scale(self.anim_node)
|
self.start_scale = gui.get_scale(self.anim_node)
|
||||||
self.start_pos = gui.get_position(self.anim_node)
|
self.start_pos = gui.get_position(self.anim_node)
|
||||||
self.params = params
|
self.params = custom_args
|
||||||
self.hover = self.druid:new_hover(node, on_button_hover)
|
self.hover = self.druid:new_hover(node, on_button_hover)
|
||||||
self.hover.on_mouse_hover:subscribe(on_button_mouse_hover)
|
self.hover.on_mouse_hover:subscribe(on_button_mouse_hover)
|
||||||
self.click_zone = nil
|
self.click_zone = nil
|
||||||
@ -297,7 +297,7 @@ function Button.init(self, node, callback, params, anim_node)
|
|||||||
self._check_function = nil
|
self._check_function = nil
|
||||||
self._failure_callback = nil
|
self._failure_callback = nil
|
||||||
|
|
||||||
-- Event stubs
|
-- Events
|
||||||
self.on_click = Event(callback)
|
self.on_click = Event(callback)
|
||||||
self.on_pressed = Event()
|
self.on_pressed = Event()
|
||||||
self.on_repeated_click = Event()
|
self.on_repeated_click = Event()
|
||||||
@ -451,6 +451,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
--- Get button enabled state.
|
--- Get button enabled state.
|
||||||
|
--
|
||||||
|
-- By default all Buttons is enabled on creating.
|
||||||
-- @tparam Button self @{Button}
|
-- @tparam Button self @{Button}
|
||||||
-- @treturn bool True, if button is enabled now, False overwise
|
-- @treturn bool True, if button is enabled now, False overwise
|
||||||
-- @usage
|
-- @usage
|
||||||
@ -503,7 +505,7 @@ end
|
|||||||
--- Set function for additional check for button click availability
|
--- Set function for additional check for button click availability
|
||||||
-- @tparam Button self
|
-- @tparam Button self
|
||||||
-- @tparam[opt] function check_function Should return true or false. If true - button can be pressed.
|
-- @tparam[opt] function check_function Should return true or false. If true - button can be pressed.
|
||||||
-- @tparam[opt] function failure_callback Function what will be called on button click, if check function return false
|
-- @tparam[opt] function failure_callback Function will be called on button click, if check function return false
|
||||||
-- @treturn Button Current button instance
|
-- @treturn Button Current button instance
|
||||||
function Button.set_check_function(self, check_function, failure_callback)
|
function Button.set_check_function(self, check_function, failure_callback)
|
||||||
self._check_function = check_function
|
self._check_function = check_function
|
||||||
@ -511,16 +513,19 @@ function Button.set_check_function(self, check_function, failure_callback)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Set buttom click mode to call itself inside html5 callback in user interaction event
|
--- Set Button mode to work inside user HTML5 interaction event.
|
||||||
-- It required to do protected stuff like copy/paste text, show html keyboard, etc
|
--
|
||||||
-- The HTML5 button doesn't call any events except on_click event
|
-- It's required to make protected things like copy & paste text, show mobile keyboard, etc
|
||||||
|
-- The HTML5 button's doesn't call any events except on_click event.
|
||||||
|
--
|
||||||
|
-- If the game is not HTML, HTML html mode will be not enabled
|
||||||
-- @tparam Button self
|
-- @tparam Button self
|
||||||
-- @tparam[opt] boolean is_html_mode If true - button will be called inside html5 callback
|
-- @tparam[opt] boolean is_web_mode If true - button will be called inside html5 callback
|
||||||
-- @treturn Button Current button instance
|
-- @treturn Button Current button instance
|
||||||
-- @usage
|
-- @usage
|
||||||
-- button:set_html5_user_interaction(true)
|
-- button:set_web_user_interaction(true)
|
||||||
function Button.set_html5_user_interaction(self, is_html_mode)
|
function Button.set_web_user_interaction(self, is_web_mode)
|
||||||
self._is_html5_mode = is_html_mode and html5
|
self._is_html5_mode = is_web_mode and html5
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
-- Copyright (c) 2021 Maksim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
|
-- Copyright (c) 2021 Maksim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
|
||||||
|
|
||||||
--- Component to handle all GUI texts.
|
--- Component to handle all GUI texts.
|
||||||
-- Druid text can adjust itself for text node size
|
-- Druid Text adjust itself for text node size
|
||||||
-- Text will never will be outside of his text size (even multiline)
|
-- Text will never will be outside of his text size (even multiline)
|
||||||
-- @module Text
|
-- @module Text
|
||||||
-- @within BaseComponent
|
-- @within BaseComponent
|
||||||
|
@ -486,7 +486,7 @@ function M.adjust_to_area(words, settings, lines_metrics)
|
|||||||
end
|
end
|
||||||
|
|
||||||
adjust_scale = adjust_scale + step
|
adjust_scale = adjust_scale + step
|
||||||
local lines = M.apply_scale_without_update(words, settings, adjust_scale)
|
lines = M.apply_scale_without_update(words, settings, adjust_scale)
|
||||||
is_fit = M.is_fit_info_area(lines, settings)
|
is_fit = M.is_fit_info_area(lines, settings)
|
||||||
|
|
||||||
if i == M.ADJUST_STEPS then
|
if i == M.ADJUST_STEPS then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user