Update README

This commit is contained in:
Insality
2020-03-22 12:54:56 +03:00
parent 6367e66203
commit 7b2578c0ef
6 changed files with 84 additions and 27 deletions

View File

@@ -1,19 +1,50 @@
# Druid components
## Button
Basic game button
Basic Druid input component
- Button callback have next params: (self, params, button_instance)
- **self** - Druid self context
- **params** - Additional params, specified on button creating
- **button_instance** - button itself
- Button have next events:
- **on_click** - basic button callback
- **on_repeated_click** - repeated click callback, while holding the button, don't trigger if callback is empty
- **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 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`
## Text
Wrap on text node with text size adjusting
Basic Druid text component
- Text component by default have auto adjust text sizing. Text never will be more, than text size, which you can setup in gui scene. It can be disabled on component creating
![](media/text_autosize.png)
- Text pivot can be changed with `text:set_pivot`, and text will save their position inside their text size box:
![](media/text_anchor.gif)
## Blocker
Block input in node zone
Druid component for block input
It can be used for block input in special zone.
Example:
![](media/blocker_scheme.png)
Blue zone is **button** with close_window callback
Yellow zone is blocker with window content
So you can do the safe zones, when you have the big buttons
## Back Handler
Handle back button (Android, backspace)
Component to handle back button
It works on Android back button and Backspace. Key triggers in `input.binding` should be setup
## Locale
Text component with handle localization system
Wrap on Druid text component to handle localization
## Timer
Run timer on text node

View File

@@ -1,10 +1,12 @@
# Creating custom components
## Overview
Druid allows you to create your custom components from druid basic components or other custom components
## Custom components
Basic custom component template looks like this:
```lua
local const = require("druid.const")
@@ -102,4 +104,9 @@ function M.init(self, template_name, node_table)
local my_style = self:get_style()
end
```
```
## Power of using templates
You can use one component, but creating and customizing templates for them. Templates only requires to match the component scheme.