Skip to content

Commit 9e2a14c

Browse files
committed
Update docs
1 parent e2c9a7d commit 9e2a14c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1098
-1290
lines changed

CONTRIBUTING.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ Finally, there are set of instructions that will help you to contribute to the p
66

77
Thanks for your help!
88

9-
## Update Documentation
10-
11-
If you see any mistakes in the documentation, you can update it by yourself.
12-
13-
You can push changes to the `master` branch directly. In case of small fixes, please also update the relative API `md` files. If there is a lot of changes, I will regenerate them manually.
14-
159
## Issue Reporting
1610

1711
If you find any bugs, please report them to the [issue tracker](https://github.com/druid-js/druid/issues).
@@ -26,6 +20,17 @@ You fix should contains only changes, which are related to the issue. Also pleas
2620

2721
Thanks <3
2822

23+
## Update Documentation
24+
25+
If you see any mistakes in the documentation, you can update it by yourself with the following steps:
26+
27+
- Fork Druid repository
28+
- Create a new branch for your changes
29+
- Make your changes and commit them
30+
- Push your changes to your fork
31+
- Create a pull request to the Druid repository `develop` branch
32+
33+
2934
## Add or Update Examples
3035

3136
Examples contains a GUI scene, a Druid widget for this GUI. This GUI is included to the `examples.gui` and the information about examples are added in `examples_list.lua` file
@@ -34,4 +39,12 @@ You can add new examples or update existing ones.
3439

3540
To add new example, you need to create a new folder in the `examples` directory.
3641

42+
On your repo fork:
43+
44+
- Create a gui file with the example inside `/example/examples` directory
45+
- Add the example info to the `examples_list.lua` file.
46+
- Add this GUI template to the `/example/druid.gui` file
47+
- GUI should be placed inside relative example parent, e.g. `root -> container_center -> examples -> widgets`
48+
- Test the example by running the game
49+
- Create a pull request to the `develop` branch
3750

README.md

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ In this example you can inspect a variety of **Druid** components and see how th
1717

1818
## Features
1919

20-
- **Components** - Provides a extensive set of components, from basic buttons to infinity data lists and rich texts
21-
- **Customizable** - You can customize components appearance and behaviour
20+
- **Components Rich** - Provides a extensive set of components, from basic buttons to infinity data lists and rich texts
21+
- **Customizable** - You can customize components appearance and behaviour with their API and styles
2222
- **Widgets** - Powerful way to create your own reusable components
2323
- **Input Handling** - Handles input in a stack-based manner and manage input priority
2424
- **Event Based** - Uses [Defold Event](https://github.com/Insality/defold-event) for components callbacks and communication between components
@@ -66,7 +66,34 @@ Here is a list of [all releases](https://github.com/Insality/druid/releases).
6666

6767
### Basic usage
6868

69-
Read more in the [Basic Usage](wiki/basic_usage.md)
69+
The basic template for `gui_script` is:
70+
71+
```lua
72+
local druid = require("druid.druid")
73+
74+
function init(self)
75+
self.druid = druid.new(self)
76+
end
77+
78+
function final(self)
79+
self.druid:final()
80+
end
81+
82+
function update(self, dt)
83+
self.druid:update(dt)
84+
end
85+
86+
function on_message(self, message_id, message, sender)
87+
self.druid:on_message(message_id, message, sender)
88+
end
89+
90+
function on_input(self, action_id, action)
91+
return self.druid:on_input(action_id, action)
92+
end
93+
```
94+
95+
Read the [Basic Usage](wiki/basic_usage.md) to learn how to use **Druid**, how to create your own components and how to use widgets.
96+
7097

7198
### API Documentation
7299

@@ -160,8 +187,8 @@ To better understand **Druid**, read the following documentation:
160187

161188
- [How To GUI in Defold](https://forum.defold.com/t/how-to-gui-in-defold/73256)
162189
- [Widgets](wiki/widgets.md)
163-
- [Create custom components](docs_md/02-creating_custom_components.md)
164-
- [Druid styles](docs_md/03-styles.md)
190+
- [Create custom components](wiki/creating_custom_components.md)
191+
- [Druid styles](wiki/styles.md)
165192

166193

167194
## Licenses

api/components/base/back_handler_api.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,21 @@
22

33
> at /druid/base/back_handler.lua
44
5-
The component that handles the back handler action, like backspace or android back button
5+
Component to handle back button. It handles Android back button and Backspace key.
66

7+
### Setup
8+
Create back handler component with druid: `druid:new_back_handler(callback)`
9+
10+
### Notes
11+
- Key triggers in `input.binding` should be setup for correct working
12+
- It uses a key_back and key_backspace action ids
713

814
## Functions
9-
- [init](#init)
1015

16+
- [init](#init)
1117

1218
## Fields
19+
1320
- [on_back](#on_back)
1421
- [params](#params)
1522

@@ -22,6 +29,8 @@ The component that handles the back handler action, like backspace or android ba
2229
back_handler:init([callback], [params])
2330
```
2431

32+
The Back Handler constructor
33+
2534
- **Parameters:**
2635
- `[callback]` *(function|nil)*: The callback to call when the back handler is triggered
2736
- `[params]` *(any)*: Custom args to pass in the callback

api/components/base/blocker_api.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,24 @@
22

33
> at /druid/base/blocker.lua
44
5+
Druid component for block input. Use it to block input in special zone.
6+
7+
### Setup
8+
Create blocker component with druid: `druid:new_blocker(node_name)`
9+
10+
### Notes
11+
- Blocker can be used to create safe zones, where you have big buttons
12+
- Blocker will capture all input events that hit the node, preventing them from reaching other components
13+
- Blocker works placed as usual component in stack, so any other component can be placed on top of it and will work as usual
514

615
## Functions
16+
717
- [init](#init)
818
- [set_enabled](#set_enabled)
919
- [is_enabled](#is_enabled)
1020

11-
1221
## Fields
22+
1323
- [node](#node)
1424

1525

@@ -21,6 +31,8 @@
2131
blocker:init(node)
2232
```
2333

34+
The Blocker constructor
35+
2436
- **Parameters:**
2537
- `node` *(string|node)*: The node to use as a blocker
2638

@@ -54,5 +66,5 @@ Get blocker enabled state
5466

5567
## Fields
5668
<a name="node"></a>
57-
- **node** (_node_)
69+
- **node** (_node_): The node that will block input
5870

api/components/base/button_api.md

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,25 @@
22

33
> at /druid/base/button.lua
44
5-
Druid component to make clickable node with various interaction callbacks
6-
5+
Basic Druid input component. Handle input on node and provide different callbacks on touch events.
6+
7+
### Setup
8+
Create button with druid: `button = druid:new_button(node_name, callback, [params], [animation_node])`
9+
Where node_name is name of node from GUI scene. You can use `node_name` as input trigger zone and point another node for animation via `animation_node`
10+
11+
### Notes
12+
- Button callback have next params: (self, params, button_instance)
13+
- - **self** - Druid self context
14+
- - **params** - Additional params, specified on button creating
15+
- - **button_instance** - button itself
16+
- You can set _params_ on button callback on button creating: `druid:new_button("node_name", callback, params)`.
17+
- Button have several events like on_click, on_repeated_click, on_long_click, on_hold_click, on_double_click
18+
- Click event will not trigger if between pressed and released state cursor was outside of node zone
19+
- Button can have key trigger to use them by key: `button:set_key_trigger`
20+
-
721

822
## Functions
23+
924
- [init](#init)
1025
- [set_animations_disabled](#set_animations_disabled)
1126
- [set_enabled](#set_enabled)
@@ -16,8 +31,8 @@ Druid component to make clickable node with various interaction callbacks
1631
- [set_check_function](#set_check_function)
1732
- [set_web_user_interaction](#set_web_user_interaction)
1833

19-
2034
## Fields
35+
2136
- [on_click](#on_click)
2237
- [on_pressed](#on_pressed)
2338
- [on_repeated_click](#on_repeated_click)
@@ -57,8 +72,8 @@ The constructor for the button component
5772
- **Parameters:**
5873
- `node_or_node_id` *(string|node)*: Node name or GUI Node itself
5974
- `[callback]` *(fun()|nil)*: Callback on button click
60-
- `[custom_args]` *(any)*: Custom args for any Button event
61-
- `[anim_node]` *(string|node|nil)*: Node to animate instead of trigger node
75+
- `[custom_args]` *(any)*: Custom args for any Button event, will be passed to callbacks
76+
- `[anim_node]` *(string|node|nil)*: Node to animate instead of trigger node, useful for animating small icons on big panels
6277

6378
### set_animations_disabled
6479

@@ -189,16 +204,16 @@ If the game is not HTML, html mode will be not enabled
189204
- **on_pressed** (_event_): function(self, custom_args, button_instance)
190205

191206
<a name="on_repeated_click"></a>
192-
- **on_repeated_click** (_event_): function(self, custom_args, button_instance, click_count)
207+
- **on_repeated_click** (_event_): function(self, custom_args, button_instance, click_count) Repeated click callback, while holding the button
193208

194209
<a name="on_long_click"></a>
195-
- **on_long_click** (_event_): function(self, custom_args, button_instance, hold_time)
210+
- **on_long_click** (_event_): function(self, custom_args, button_instance, hold_time) Callback on long button tap
196211

197212
<a name="on_double_click"></a>
198-
- **on_double_click** (_event_): function(self, custom_args, button_instance, click_amount)
213+
- **on_double_click** (_event_): function(self, custom_args, button_instance, click_amount) Different callback, if tap button 2+ in row
199214

200215
<a name="on_hold_callback"></a>
201-
- **on_hold_callback** (_event_): function(self, custom_args, button_instance, press_time)
216+
- **on_hold_callback** (_event_): function(self, custom_args, button_instance, press_time) Hold callback, before long_click trigger
202217

203218
<a name="on_click_outside"></a>
204219
- **on_click_outside** (_event_): function(self, custom_args, button_instance)

api/components/base/component_api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
> at /druid/component.lua
44
5-
65
## Functions
6+
77
- [create](#create)
88
- [create_widget](#create_widget)
99

@@ -39,8 +39,8 @@
3939
- [get_nodes](#get_nodes)
4040
- [get_childrens](#get_childrens)
4141

42-
4342
## Fields
43+
4444
- [druid](#druid)
4545

4646

api/components/base/drag_api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
55
A component that allows you to subscribe to drag events over a node
66

7-
87
## Functions
8+
99
- [init](#init)
1010
- [set_drag_cursors](#set_drag_cursors)
1111
- [set_click_zone](#set_click_zone)
1212
- [set_enabled](#set_enabled)
1313
- [is_enabled](#is_enabled)
1414

15-
1615
## Fields
16+
1717
- [node](#node)
1818
- [on_touch_start](#on_touch_start)
1919
- [on_touch_end](#on_touch_end)

api/components/base/hover_api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
55
The component for handling hover events on a node
66

7-
87
## Functions
8+
99
- [init](#init)
1010
- [set_hover](#set_hover)
1111
- [is_hovered](#is_hovered)
@@ -15,8 +15,8 @@ The component for handling hover events on a node
1515
- [set_enabled](#set_enabled)
1616
- [is_enabled](#is_enabled)
1717

18-
1918
## Fields
19+
2020
- [node](#node)
2121
- [on_hover](#on_hover)
2222
- [on_mouse_hover](#on_mouse_hover)

api/components/base/scroll_api.md

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,26 @@
22

33
> at /druid/base/scroll.lua
44
5+
Basic Druid scroll component. Handles all scrolling behavior in Druid GUI.
6+
7+
### Setup
8+
Create scroll component with druid: `druid:new_scroll(view_node, content_node)`
9+
10+
### Notes
11+
- View_node is the static part that captures user input and recognizes scrolling touches
12+
- Content_node is the dynamic part that will change position according to the scroll system
13+
- Initial scroll size will be equal to content_node size
14+
- The initial view box will be equal to view_node size
15+
- Scroll by default style has inertia and extra size for stretching effect
16+
- You can setup "points of interest" to make scroll always center on closest point
17+
- Scroll events:
18+
- - on_scroll(self, position): On scroll move callback
19+
- - on_scroll_to(self, position, is_instant): On scroll_to function callback
20+
- - on_point_scroll(self, item_index, position): On scroll_to_index function callback
21+
- Multitouch is required for scroll. Scroll correctly handles touch_id swap while dragging
522

623
## Functions
24+
725
- [init](#init)
826
- [scroll_to](#scroll_to)
927
- [scroll_to_index](#scroll_to_index)
@@ -23,8 +41,8 @@
2341
- [bind_grid](#bind_grid)
2442
- [set_click_zone](#set_click_zone)
2543

26-
2744
## Fields
45+
2846
- [node](#node)
2947
- [click_zone](#click_zone)
3048
- [on_scroll](#on_scroll)
@@ -60,8 +78,8 @@ scroll:init(view_node, content_node)
6078
The Scroll constructor
6179

6280
- **Parameters:**
63-
- `view_node` *(string|node)*: GUI view scroll node
64-
- `content_node` *(string|node)*: GUI content scroll node
81+
- `view_node` *(string|node)*: GUI view scroll node - the static part that captures user input
82+
- `content_node` *(string|node)*: GUI content scroll node - the dynamic part that will change position
6583

6684
### scroll_to
6785

@@ -316,13 +334,13 @@ Strict drag scroll area. Useful for
316334
- **click_zone** (_node_): Optional click zone to restrict scroll area
317335

318336
<a name="on_scroll"></a>
319-
- **on_scroll** (_event_): Triggered on scroll move with (self, position)
337+
- **on_scroll** (_event_): Triggered on scroll move with fun(self, position)
320338

321339
<a name="on_scroll_to"></a>
322-
- **on_scroll_to** (_event_): Triggered on scroll_to with (self, target, is_instant)
340+
- **on_scroll_to** (_event_): Triggered on scroll_to with fun(self, target, is_instant)
323341

324342
<a name="on_point_scroll"></a>
325-
- **on_point_scroll** (_event_): Triggered on scroll_to_index with (self, index, point)
343+
- **on_point_scroll** (_event_): Triggered on scroll_to_index with fun(self, index, point)
326344

327345
<a name="view_node"></a>
328346
- **view_node** (_node_): The scroll view node (static part)
@@ -370,7 +388,7 @@ Strict drag scroll area. Useful for
370388
- **points** (_table_)
371389

372390
<a name="available_pos_extra"></a>
373-
- **available_pos_extra** (_unknown_)
391+
- **available_pos_extra** (_vector4_)
374392

375393
<a name="available_size_extra"></a>
376394
- **available_size_extra** (_vector3_)

0 commit comments

Comments
 (0)