Update docs

This commit is contained in:
Insality
2020-04-13 19:36:32 +03:00
parent 0539746519
commit 2cfc6e477e
29 changed files with 66 additions and 62 deletions

View File

@@ -25,6 +25,7 @@ Where node name is name of node from GUI scene. You can use `node_name` as input
- **on_long_click** - callback on long button tap, don't trigger if callback is empty
- **on_hold_click** - hold callback, before long_click trigger, don't trigger if callback is empty
- **on_double_click** - different callback, if tap button 2+ in row, don't trigger if callback is empty
- If button have double click event and it is triggered, usual callback will be not invoked
- If you have stencil on buttons and you don't want trigger them outside of stencil node, you can use `button:set_click_zone` to restrict button click zone
- Button can have key trigger to use then by key: `button:set_key_trigger`
- Animation node can be used for example to animate small icon on big panel. Node name of trigger zone will be `big panel` and animation node will be `small icon`
@@ -37,7 +38,7 @@ Where node name is name of node from GUI scene. You can use `node_name` as input
Basic Druid text component. Text components by default have the text size adjusting.
### Setup
Create text node with druid: `text = druid:new_text(node_name, [initial_value])`
Create text node with druid: `text = druid:new_text(node_name, [initial_value], [is_disable_size_adjust])`
### Notes
- Text component by default have auto adjust text sizing. Text never will be bigger, than text node size, which you can setup in GUI scene. It can be disabled on component creating by settings argument `is_no_adjust` to _true_

View File

@@ -2,7 +2,9 @@
## Overview
Druid allows you to create your custom components from druid basic components or other custom components. Read the [basic component API here].(https://insality.github.io/druid/modules/component.html)
Druid allows you to create your custom components from druid basic components or other custom components.
Every component is the children of Basic Druid component. Read the [basic component API here].(https://insality.github.io/druid/modules/component.html), Methods of basic components you can call via self:{method_name}
## Custom components
@@ -12,7 +14,7 @@ Basic custom component template looks like this:
local const = require("druid.const")
local component = require("druid.component")
local M = component.create("name_your_component")
local M = component.create("my_component")
-- Component constructor
function M.init(self, ...)
@@ -61,15 +63,21 @@ function init(self)
end
```
Registering make new function with "new_{component_name}". In our example it will be: `druid:new_my_component()`
Registering make new function with "new_{component_name}". In our example it will be: `druid:new_my_component()`.
Or you can create component without registering with `druid:create(my_component_module)`
As component registered, you can create your component with next code:
```lua
local druid = require("druid.druid")
local my_component = require("my.amazing.component")
function init(self)
self.druid = druid.new(self)
local my_component = self.druid:new_my_component(...)
-- or --
local my_component = self.druid:create(my_component, ...)
end
```