Merge pull request #130 from Insality/develop

Release 0.6.0
This commit is contained in:
Maxim Tuprikov 2021-04-06 00:12:26 +03:00 committed by GitHub
commit c34ce714b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
160 changed files with 33418 additions and 26327 deletions

23
.github/workflows/ci-workflow.yml vendored Normal file
View File

@ -0,0 +1,23 @@
name: Run tests
on: [push]
jobs:
build_and_run:
name: Build and run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
lfs: true
- uses: actions/setup-java@v1
with:
java-version: '13'
- name: Build && Run
run: |
deployer_url="https://raw.githubusercontent.com/Insality/defold-deployer/1/deployer.sh"
curl -s ${deployer_url} | bash -s lbd --headless --settings ./unit_test.txt
- name: Upload test report
run: bash <(curl -s https://codecov.io/bash)

110
README.md
View File

@ -1,6 +1,8 @@
[![](media/druid_logo.png)](https://insality.github.io/druid/)
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/insality/druid)](https://github.com/Insality/druid/releases)
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/insality/druid/Run%20tests)](https://github.com/Insality/druid/actions)
[![codecov](https://codecov.io/gh/Insality/druid/branch/master/graph/badge.svg)](https://codecov.io/gh/Insality/druid)
**Druid** - powerful Defold component UI library. Use basic and extended **Druid** components or make your own game-specific components to make amazing GUI in your games.
@ -13,11 +15,11 @@ You can use the **Druid** extension in your own project by adding this project a
> [https://github.com/Insality/druid/archive/master.zip](https://github.com/Insality/druid/archive/master.zip)
Or point to the ZIP file of a [specific release](https://github.com/Insality/druid/releases).
Or point to the ZIP file of a [specific release](https://github.com/Insality/druid/releases).
### Input bindings
For **Druid** to work requires next input bindings:
**Druid** requires the following input bindings:
- Mouse trigger - `Button 1` -> `touch` _For basic input components_
- Key trigger - `Backspace` -> `key_backspace` _For back_handler component, input component_
@ -34,7 +36,7 @@ For **Druid** to work requires next input bindings:
By default, **Druid** will auto-capture input focus, if any input component will be created. So you don't need to call `msg.post(".", "acquire_input_focus")`
If you not need this behaviour, you can disable it by settings `druid.no_auto_input` field in _game.project_:
If you don't need this behaviour, you can disable it by settings `druid.no_auto_input` field in _game.project_:
```
[druid]
no_auto_input = 1
@ -69,58 +71,58 @@ druid.on_window_callback(event)
## Components
**Druid** provides next *basic* components:
**Druid** provides the following *basic* components:
- **[Button](master/docs_md/01-components.md#button)** - Basic Druid button input component. Handles all types of interaction (tap, long-tap, hold-tap, double-tap, simple key triggers, etc)
- **[Button](docs_md/01-components.md#button)** - Basic Druid button input component. Handles all types of interactions (tap, long-tap, hold-tap, double-tap, simple key triggers, etc)
- **[Text](master/docs_md/01-components.md#text)** - Basic Druid text component. Wrap on gui text node, handle text size adjusting.
- **[Text](docs_md/01-components.md#text)** - Basic Druid text component. Wrap on gui text node, handle text size adjusting.
- **[Scroll](master/docs_md/01-components.md#scroll)** - Basic Druid scroll component
- **[Scroll](docs_md/01-components.md#scroll)** - Basic Druid scroll component
- **[Blocker](master/docs_md/01-components.md#blocker)** - Block input in node zone component
- **[Blocker](docs_md/01-components.md#blocker)** - Block input in node zone component
- **[Back Handler](master/docs_md/01-components.md#back-handler)** - Handle back button (Android back button, backspace key)
- **[Back Handler](docs_md/01-components.md#back-handler)** - Handle back button (Android back button, backspace key)
- **[Static Grid](master/docs_md/01-components.md#static-grid)** - Component for manage node positions with equal sizes
- **[Static Grid](docs_md/01-components.md#static-grid)** - Component to manage node positions with equal sizes
- **[Hover](master/docs_md/01-components.md#hover)** - System Druid component, handle hover node state
- **[Hover](docs_md/01-components.md#hover)** - System Druid component, handle hover node state
- **[Swipe](master/docs_md/01-components.md#swipe)** - System Druid component, handle swipe gestures on node
- **[Swipe](docs_md/01-components.md#swipe)** - System Druid component, handle swipe gestures on node
- **[Drag](master/docs_md/01-components.md#drag)** - System Druid component, handle drag input on node
- **[Drag](docs_md/01-components.md#drag)** - System Druid component, handle drag input on node
**Druid** also provides next *extended* components:
**Druid** also provides the following *extended* components:
***Note**: In future, to use extended components, you should register them first. It's required for make **Druid** modular - to exclude unused components from build*
***Note**: In the future, to use extended components, you should register them first. This is required to make **Druid** modular - to exclude unused components from builds*
- **[Checkbox](master/docs_md/01-components.md#checkbox)** - Checkbox component
- **[Checkbox](docs_md/01-components.md#checkbox)** - Checkbox component
- **[Checkbox group](master/docs_md/01-components.md#checkbox-group)** - Several checkboxes in one group
- **[Checkbox group](docs_md/01-components.md#checkbox-group)** - Several checkboxes in one group
- **[Dynamic Grid](master/docs_md/01-components.md#dynamic-grid)** - Component for manage node positions with different sizes. Only in one row or column
- **[Dynamic Grid](docs_md/01-components.md#dynamic-grid)** - Component to manage node positions with different sizes. Only in one row or column
- **[Input](master/docs_md/01-components.md#input)** - User text input component
- **[Input](docs_md/01-components.md#input)** - User text input component
- **[Lang text](master/docs_md/01-components.md#lang-text)** - Wrap on Text component to handle localization
- **[Lang text](docs_md/01-components.md#lang-text)** - Wrap on Text component to handle localization
- **[Progress](master/docs_md/01-components.md#progress)** - Progress bar component
- **[Progress](docs_md/01-components.md#progress)** - Progress bar component
- **[Radio group](master/docs_md/01-components.md#radio-group)** - Several checkboxes in one group with single choice
- **[Radio group](docs_md/01-components.md#radio-group)** - Several checkboxes in one group with a single choice
- **[Slider](master/docs_md/01-components.md#slider)** - Slider component
- **[Slider](docs_md/01-components.md#slider)** - Slider component
- **[Timer](master/docs_md/01-components.md#timer)** - Handle timer work on gui text node
- **[Timer](docs_md/01-components.md#timer)** - Handle timer work on gui text node
Full info see on _[components.md](master/docs_md/01-components.md)_
For a complete overview, see: _[components.md](docs_md/01-components.md)_.
## Basic usage
For using **Druid**, first you should create Druid instance to spawn components. Pass to new Druid instance main engine functions: *update*, *on_message* and *on_input*
To use **Druid**, first you should create a Druid instance to spawn components and add Druids main engine functions: *update*, *final*, *on_message* and *on_input*.
All **Druid** components as arguments can apply node name string, you can don't do `gui.get_node()` before
All **Druid** components take node name string as arguments, don't do `gui.get_node()` before.
All **Druid** and component methods calling with `:` like `self.druid:new_button()`
All **Druid** and component methods are called with `:` like `self.druid:new_button()`.
```lua
local druid = require("druid.druid")
@ -138,16 +140,22 @@ function final(self)
self.druid:final()
end
function on_message(self, message_id, message, sender)
self.druid:on_message(message_id, message, sender)
end
function on_input(self, action_id, action)
return self.druid:on_input(action_id, action)
end
```
Learn **Druid** instance [functions here](https://insality.github.io/druid/modules/druid_instance.html))
For all **Druid** instance functions, [see here](https://insality.github.io/druid/modules/druid_instance.html).
## Druid Events
Any **Druid** components as callbacks uses [Druid Events](https://insality.github.io/druid/modules/druid_event.html). In component API ([button example](https://insality.github.io/druid/modules/druid.button.html#Events)) pointed list of component events. You can manually subscribe on this events by next API:
Any **Druid** components as callbacks use [Druid Events](https://insality.github.io/druid/modules/druid_event.html). In component API ([button example](https://insality.github.io/druid/modules/druid.button.html#Events)) pointed list of component events. You can manually subscribe to those events with the following API:
- **event:subscribe**(callback)
@ -155,11 +163,11 @@ Any **Druid** components as callbacks uses [Druid Events](https://insality.githu
- **event:clear**()
You can subscribe several callbacks on single event.
You can subscribe several callbacks to a single event.
## Druid Lifecycle
Here is full Druid lifecycle setup in your ***.gui_script** file:
Here is full Druid lifecycle setup for your ***.gui_script** file:
```lua
local druid = require("druid.druid")
@ -184,22 +192,22 @@ function on_message(self, message_id, message, sender)
end
```
- *final* **required** function for correct Druid lifecycle
- *on_input* used for almost all Druid components
- *update* used for progress bar, scroll and timer base components
- *on_message* used for specific Druid events, like language change or layout change
- *final* is a **required** function for a correct Druid lifecycle
- *on_input* is used in almost all Druid components
- *update* in used in progress bar, scroll and timer base components
- *on_message* is used for specific Druid events, like language change or layout change
Recommended is fully integrate all **Druid** lifecycles functions
It is recommended to fully integrate all **Druid** lifecycles functions.
## Details
- Druid input goes as stack. Last created button will checked first. So create your GUI from back
- Don't forget about `return` in `on_input`: `return self.druid:on_input()`. It need, if you have more than 1 acquire inputs (several Druid, other input system, etc)
- Druid by default do _acquire_input_focus_. So you don't need do it manually. Buy only if you have components, which requires _on_input_
- If you want to delete node with declared Druid component, don't forget to remove them via `druid:remove(component)`
- Don't forget about `return` in `on_input`: `return self.druid:on_input()`. It is needed if you have more than 1 acquire inputs (several Druid, other input system, etc)
- By default, Druid will automatically _acquire_input_focus_. So you don't need do it manually. But only if you have components which require _on_input_
- If you want to delete a node which has a Druid component, don't forget to remove it via `druid:remove(component)`
See full [See FAQ here](master/docs_md/FAQ.md)
[See full FAQ here](docs_md/FAQ.md)
## Examples
@ -213,14 +221,14 @@ Try the [HTML5 version](https://insality.github.io/druid/druid/) of the example
## Documentation
To learn **Druid** better, read next documentation:
- [Druid components](master/docs_md/01-components.md)
- [Create custom components](master/docs_md/02-creating_custom_components.md)
- [See FAQ article](master/docs_md/FAQ.md)
- [Druid styles](master/docs_md/03-styles.md)
- [Druid asset store](master/docs_md/04-druid_assets.md)
To better understand **Druid**, read the following documentation:
- [Druid components](docs_md/01-components.md)
- [Create custom components](docs_md/02-creating_custom_components.md)
- [See FAQ article](docs_md/FAQ.md)
- [Druid styles](docs_md/03-styles.md)
- [Druid asset store](docs_md/04-druid_assets.md)
Full **Druid** documentation you can find here:
You can fund the full **Druid** documentation here:
https://insality.github.io/druid/
@ -231,13 +239,11 @@ _You published your game and you using Druid? Note me!_
## License
- Developed and supporting by [Insality](https://github.com/Insality)
- Developed and supported by [Insality](https://github.com/Insality)
- Original idea by [AGulev](https://github.com/AGulev)
- Assets from [Kenney](http://www.kenney.nl/)
**MIT** License
## Issues and suggestions
If you have any issues, questions or suggestions please [create an issue](https://github.com/Insality/druid/issues) or contact me: [insality@gmail.com](mailto:insality@gmail.com)
If you have any issues, questions or suggestions please [create an issue](https://github.com/Insality/druid/issues) or contact me: [insality@gmail.com](mailto:insality@gmail.com)

1342
annotations.lua Normal file

File diff suppressed because it is too large Load Diff

View File

@ -11,7 +11,6 @@ package='druid'
sort=false
dir='./docs'
style='!fixed'
format='discount'
topics={"./docs_md", "README.md"}
topics={}
use_markdown_titles=true
no_space_before_args=true

View File

@ -1 +1 @@
{"content":[{"name":"game.projectc","size":3140,"pieces":[{"name":"game.projectc0","offset":0}]},{"name":"game.arci","size":5168,"pieces":[{"name":"game.arci0","offset":0}]},{"name":"game.arcd","size":287011,"pieces":[{"name":"game.arcd0","offset":0}]},{"name":"game.dmanifest","size":11332,"pieces":[{"name":"game.dmanifest0","offset":0}]},{"name":"game.public.der","size":162,"pieces":[{"name":"game.public.der0","offset":0}]}]}
{"content":[{"name":"game.projectc","size":3432,"pieces":[{"name":"game.projectc0","offset":0}]},{"name":"game.arci","size":10608,"pieces":[{"name":"game.arci0","offset":0}]},{"name":"game.arcd","size":384566,"pieces":[{"name":"game.arcd0","offset":0}]},{"name":"game.dmanifest","size":23386,"pieces":[{"name":"game.dmanifest0","offset":0}]},{"name":"game.public.der","size":162,"pieces":[{"name":"game.public.der0","offset":0}]}]}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,8 +1,12 @@
[project]
title = druid
version = 0.5.0
version = 0.6.459
write_log = 0
compress_archive = 1
publisher = Insality
developer = Insality
commit_sha = 015564f5b3e0d5e63e422056c69e53826ed689bf
build_time = 2021-04-05T21:00:43Z
[display]
width = 600
@ -14,6 +18,7 @@ update_frequency = 0
vsync = 1
display_profiles = /builtins/render/default.display_profilesc
dynamic_orientation = 0
display_device_info = 0
[render]
clear_color_red = 0
@ -40,7 +45,7 @@ ray_cast_limit_3d = 128
trigger_overlap_capacity = 16
[bootstrap]
main_collection = /example/kenney.collectionc
main_collection = /example/example.collectionc
render = /builtins/render/default.renderc
[graphics]
@ -51,6 +56,7 @@ max_characters = 8192
max_debug_vertices = 10000
texture_profiles = /example/custom.texture_profiles
verify_graphics_calls = 1
memory_size = 512
[shader]
output_spirv = 0
@ -62,6 +68,7 @@ max_sound_buffers = 32
max_sound_sources = 16
max_sound_instances = 256
max_component_count = 32
use_thread = 1
[resource]
http_cache = 0
@ -84,6 +91,9 @@ max_count = 128
[model]
max_count = 128
[mesh]
max_count = 128
[gui]
max_count = 64
max_particlefx_count = 64
@ -111,7 +121,7 @@ default_language = en
localizations = en
[android]
version_code = 1
version_code = 459
minimum_sdk_version = 16
target_sdk_version = 29
package = com.insality.druid
@ -125,6 +135,7 @@ debuggable = 0
[osx]
infoplist = /builtins/manifests/osx/Info.plist
bundle_identifier = example.unnamed
bundle_version = 1
default_language = en
localizations = en
@ -151,6 +162,8 @@ auto_finish_transactions = 1
[network]
http_timeout = 0
http_thread_count = 4
http_cache_enabled = 1
[library]
include_dirs = druid
@ -167,6 +180,7 @@ track_cpu = 0
[liveupdate]
settings = /liveupdate.settings
enabled = 1
[tilemap]
max_count = 16

Binary file not shown.

Binary file not shown.

View File

@ -1,247 +1,374 @@
// file downloader
// wraps XMLHttpRequest and adds retry support and progress updates when the
// content is gzipped (gzipped content doesn't report a computable content length
// on Google Chrome)
var FileLoader = {
options: {
retryCount: 4,
retryInterval: 1000,
},
// do xhr request with retries
request: function(url, method, responseType, currentAttempt) {
if (typeof method === 'undefined') throw "No method specified";
if (typeof method === 'responseType') throw "No responseType specified";
if (typeof currentAttempt === 'undefined') currentAttempt = 0;
var obj = {
send: function() {
var onprogress = this.onprogress;
var onload = this.onload;
var onerror = this.onerror;
var xhr = new XMLHttpRequest();
xhr.open(method, url, true);
xhr.responseType = responseType;
xhr.onprogress = function(e) {
if (onprogress) onprogress(xhr, e);
};
xhr.onerror = function(e) {
if (currentAttempt == FileLoader.options.retryCount) {
if (onerror) onerror(xhr, e);
return;
}
currentAttempt = currentAttempt + 1;
setTimeout(obj.send, FileLoader.options.retryInterval);
};
xhr.onload = function(e) {
if (onload) onload(xhr, e);
};
xhr.send(null);
}
};
return obj;
},
// Do HTTP HEAD request to get size of resource
// callback will receive size or undefined in case of an error
size: function(url, callback) {
var request = FileLoader.request(url, "HEAD", "text");
request.onerror = function(xhr, e) {
callback(undefined);
};
request.onload = function(xhr, e) {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
var total = xhr.getResponseHeader('content-length');
callback(total);
} else {
callback(undefined);
}
}
};
request.send();
},
// Do HTTP GET request
// onprogress(loaded, total)
// onerror(error)
// onload(response)
load: function(url, responseType, estimatedSize, onprogress, onerror, onload) {
var request = FileLoader.request(url, "GET", responseType);
request.onprogress = function(xhr, e) {
if (e.lengthComputable) {
onprogress(e.loaded, e.total);
return;
}
var contentLength = xhr.getResponseHeader('content-length');
var size = contentLength != undefined ? contentLength : estimatedSize;
if (size) {
onprogress(e.loaded, size);
} else {
onprogress(e.loaded, e.loaded);
}
};
request.onerror = function(xhr, e) {
onerror("Error loading '" + url + "' (" + e + ")");
};
request.onload = function(xhr, e) {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
var res = xhr.response;
if (responseType == "json" && typeof res === "string") {
onload(JSON.parse(res));
} else {
onload(res);
}
} else {
onerror("Error loading '" + url + "' (" + e + ")");
}
}
};
request.send();
}
};
var EngineLoader = {
wasm_size: 2000000,
wasm_from: 0,
wasm_to: 40,
wasmjs_size: 250000,
wasmjs_from: 40,
wasmjs_to: 50,
asmjs_size: 4000000,
asmjs_from: 0,
asmjs_to: 50,
// load .wasm and set Module.instantiateWasm to use the loaded .wasm file
// https://github.com/emscripten-core/emscripten/blob/master/tests/manual_wasm_instantiate.html#L170
loadWasmAsync: function(src, fromProgress, toProgress, callback) {
FileLoader.load(src, "arraybuffer", EngineLoader.wasm_size,
function(loaded, total) { Progress.calculateProgress(fromProgress, toProgress, loaded, total); },
function(error) { throw error; },
function(wasm) {
Module.instantiateWasm = function(imports, successCallback) {
var wasmInstantiate = WebAssembly.instantiate(new Uint8Array(wasm), imports).then(function(output) {
successCallback(output.instance);
}).catch(function(e) {
console.log('wasm instantiation failed! ' + e);
throw e;
});
return {}; // Compiling asynchronously, no exports.
}
callback();
});
},
// load and start engine script (asm.js or wasm.js)
loadScriptAsync: function(src, estimatedSize, fromProgress, toProgress) {
FileLoader.load(src, "text", estimatedSize,
function(loaded, total) { Progress.calculateProgress(fromProgress, toProgress, loaded, total); },
function(error) { throw error; },
function(response) {
var tag = document.createElement("script");
tag.text = response;
document.head.appendChild(tag);
});
},
// load engine (asm.js or wasm.js + wasm)
// engine load progress goes from 1-50% for ams.js
// engine load progress goes from 0-40% for .wasm and 40-50% for wasm.js
load: function(appCanvasId, exeName) {
Progress.addProgress(Module.setupCanvas(appCanvasId));
if (Module['isWASMSupported']) {
EngineLoader.loadWasmAsync(exeName + ".wasm", EngineLoader.wasm_from, EngineLoader.wasm_to, function(wasm) {
EngineLoader.loadScriptAsync(exeName + '_wasm.js', EngineLoader.wasmjs_size, EngineLoader.wasmjs_from, EngineLoader.wasmjs_to);
});
} else {
EngineLoader.loadScriptAsync(exeName + '_asmjs.js', EngineLoader.asmjs_size, EngineLoader.asmjs_from, EngineLoader.asmjs_to);
}
}
}
/* ********************************************************************* */
/* Load and combine data that is split into archives */
/* Load and combine game archive data that is split into archives */
/* ********************************************************************* */
var Combine = {
_targets: [],
_targetIndex: 0,
// target: build target
var GameArchiveLoader = {
// which files to load
_files: [],
_fileIndex: 0,
// file
// name: intended filepath of built object
// size: expected size of built object.
// data: combined data
// downloaded: total amount of data downloaded
// data: combined pieces
// downloaded: total bytes downloaded
// pieces: array of name, offset and data objects
// numExpectedFiles: total number of files expected in description
// lastRequestedPiece: index of last data file requested (strictly ascending)
// totalLoadedPieces: counts the number of data files received
// totalLoadedPieces: counts the number pieces received
//MAX_CONCURRENT_XHR: 6, // remove comment if throttling of XHR is desired.
isCompleted: false, // status of process
_onCombineCompleted: [], // signature: name, data.
_onAllTargetsBuilt:[], // signature: void
_onDownloadProgress: [], // signature: downloaded, total
_onFileLoadedListeners: [], // signature: name, data.
_onArchiveLoadedListeners:[], // signature: void
_onFileDownloadErrorListeners: [], // signature: name
_currentDownloadBytes: 0,
_totalDownloadBytes: 0,
_retry_time: 0, // pause before retry file loading after error
_max_retry_count: 0, // how many attempts we do when trying to download a file.
_can_not_download_file_callback: undefined, //Function that is called if you can't download file after 'retry_count' attempts.
_archiveLocationFilter: function(path) { return "split" + path; },
can_not_download_file: function(file) {
if (typeof Combine._can_not_download_file_callback === 'function') {
Combine._can_not_download_file_callback(file);
}
},
addProgressListener: function(callback) {
if (typeof callback !== 'function') {
throw "Invalid callback registration";
}
this._onDownloadProgress.push(callback);
},
addCombineCompletedListener: function(callback) {
if (typeof callback !== 'function') {
throw "Invalid callback registration";
}
this._onCombineCompleted.push(callback);
},
addAllTargetsBuiltListener: function(callback) {
if (typeof callback !== 'function') {
throw "Invalid callback registration";
}
this._onAllTargetsBuilt.push(callback);
},
// descriptUrl: location of text file describing files to be preloaded
process: function(descriptUrl, attempt_count) {
if (!attempt_count) {
attempt_count = 0;
}
var xhr = new XMLHttpRequest();
xhr.open('GET', descriptUrl);
xhr.responseType = 'text';
xhr.onload = function(evt) {
Combine.onReceiveDescription(xhr);
};
xhr.onerror = function(evt) {
attempt_count += 1;
if (attempt_count < Combine._max_retry_count) {
console.warn("Can't download file '" + descriptUrl + "' . Next try in " + Combine._retry_time + " sec.");
setTimeout(function() {
Combine.process(descriptUrl, attempt_count);
}, Combine._retry_time * 1000);
} else {
Combine.can_not_download_file(descriptUrl);
}
};
xhr.send(null);
},
cleanUp: function() {
this._targets = [];
this._targetIndex = 0;
this._files = [];
this._fileIndex = 0;
this.isCompleted = false;
this._onCombineCompleted = [];
this._onAllTargetsBuilt = [];
this._onDownloadProgress = [];
this._onGameArchiveLoaderCompletedListeners = [];
this._onAllTargetsBuiltListeners = [];
this._onFileDownloadErrorListeners = [];
this._currentDownloadBytes = 0;
this._totalDownloadBytes = 0;
},
onReceiveDescription: function(xhr) {
var json = JSON.parse(xhr.responseText);
this._targets = json.content;
addListener: function(list, callback) {
if (typeof callback !== 'function') throw "Invalid callback registration";
list.push(callback);
},
notifyListeners: function(list, data) {
for (i=0; i<list.length; ++i) {
list[i](data);
}
},
addFileDownloadErrorListener: function(callback) {
this.addListener(this._onFileDownloadErrorListeners, callback);
},
notifyFileDownloadError: function(url) {
this.notifyListeners(this._onFileDownloadErrorListeners, url);
},
addFileLoadedListener: function(callback) {
this.addListener(this._onFileLoadedListeners, callback);
},
notifyFileLoaded: function(file) {
this.notifyListeners(this._onFileLoadedListeners, { name: file.name, data: file.data });
},
addArchiveLoadedListener: function(callback) {
this.addListener(this._onArchiveLoadedListeners, callback);
},
notifyArchiveLoaded: function() {
this.notifyListeners(this._onArchiveLoadedListeners);
},
setFileLocationFilter: function(filter) {
if (typeof filter !== 'function') throw "Invalid filter";
this._archiveLocationFilter = filter;
},
// load the archive_files.json with the list of files and their individual
// pieces
// descriptionUrl: location of text file describing files to be preloaded
loadArchiveDescription: function(descriptionUrl) {
FileLoader.load(
this._archiveLocationFilter(descriptionUrl),
"json",
undefined,
function (loaded, total) { },
function (error) { GameArchiveLoader.notifyFileDownloadError(descriptionUrl); },
function (json) { GameArchiveLoader.onReceiveDescription(json); });
},
onReceiveDescription: function(json) {
this._files = json.content;
this._totalDownloadBytes = 0;
this._currentDownloadBytes = 0;
var targets = this._targets;
for(var i=0; i<targets.length; ++i) {
this._totalDownloadBytes += targets[i].size;
// calculate total download size of all files
for(var i=0; i<this._files.length; ++i) {
this._totalDownloadBytes += this._files[i].size;
}
this.requestContent();
this.downloadContent();
},
requestContent: function() {
var target = this._targets[this._targetIndex];
if (1 < target.pieces.length) {
target.data = new Uint8Array(target.size);
downloadContent: function() {
var file = this._files[this._fileIndex];
// if the file consists of more than one piece we prepare an array to store the pieces in
if (file.pieces.length > 1) {
file.data = new Uint8Array(file.size);
}
var limit = target.pieces.length;
// how many pieces to download at a time
var limit = file.pieces.length;
if (typeof this.MAX_CONCURRENT_XHR !== 'undefined') {
limit = Math.min(limit, this.MAX_CONCURRENT_XHR);
}
// download pieces
for (var i=0; i<limit; ++i) {
this.requestPiece(target, i);
this.downloadPiece(file, i);
}
},
requestPiece: function(target, index, attempt_count) {
if (!attempt_count) {
attempt_count = 0;
}
notifyDownloadProgress: function() {
Progress.calculateProgress(50, 100, this._currentDownloadBytes, this._totalDownloadBytes);
},
if (index < target.lastRequestedPiece) {
downloadPiece: function(file, index) {
if (index < file.lastRequestedPiece) {
throw "Request out of order";
}
var item = target.pieces[index];
target.lastRequestedPiece = index;
var piece = file.pieces[index];
file.lastRequestedPiece = index;
file.totalLoadedPieces = 0;
var total = 0;
var downloaded = 0;
var xhr = new XMLHttpRequest();
var url = this._archiveLocationFilter('/' + item.name);
xhr.open('GET', url, true);
xhr.responseType = 'arraybuffer';
// called periodically with information about the transaction
xhr.onprogress = function(evt) {
if (evt.total && evt.lengthComputable) {
total = evt.total;
}
if (evt.loaded && evt.lengthComputable) {
var delta = evt.loaded - downloaded;
downloaded = evt.loaded;
Combine._currentDownloadBytes += delta;
Combine.updateProgress(target);
}
};
// called when the transaction completes successfully
xhr.onload = function(evt) {
item.data = new Uint8Array(xhr.response);
item.dataLength = item.data.length;
total = item.dataLength;
downloaded = item.dataLength;
Combine.copyData(target, item);
Combine.onPieceLoaded(target, item);
Combine.updateProgress(target);
item.data = undefined;
};
// called when the transaction fails
xhr.onerror = function(evt) {
downloaded = 0;
Combine.updateProgress(target);
attempt_count += 1;
if (attempt_count < Combine._max_retry_count) {
console.warn("Can't download file '" + item.name + "' . Next try in " + Combine._retry_time + " sec.");
setTimeout(function() {
Combine.requestPiece(target, index, attempt_count);
}, Combine._retry_time * 1000);
} else {
Combine.can_not_download_file(item.name);
}
};
xhr.send(null);
var url = this._archiveLocationFilter('/' + piece.name);
FileLoader.load(
url, "arraybuffer", undefined,
function (loaded, total) {
var delta = loaded - downloaded;
downloaded = loaded;
GameArchiveLoader._currentDownloadBytes += delta;
GameArchiveLoader.notifyDownloadProgress();
},
function (error) {
GameArchiveLoader.notifyFileDownloadError(error);
},
function (response) {
piece.data = new Uint8Array(response);
piece.dataLength = piece.data.length;
total = piece.dataLength;
downloaded = piece.dataLength;
GameArchiveLoader.onPieceLoaded(file, piece);
GameArchiveLoader.notifyDownloadProgress();
piece.data = undefined;
});
},
updateProgress: function(target) {
for(i = 0; i<this._onDownloadProgress.length; ++i) {
this._onDownloadProgress[i](this._currentDownloadBytes, this._totalDownloadBytes);
}
},
copyData: function(target, item) {
if (1 == target.pieces.length) {
target.data = item.data;
addPieceToFile: function(file, piece) {
if (1 == file.pieces.length) {
file.data = piece.data;
} else {
var start = item.offset;
var end = start + item.data.length;
var start = piece.offset;
var end = start + piece.data.length;
if (0 > start) {
throw "Buffer underflow";
}
if (end > target.data.length) {
if (end > file.data.length) {
throw "Buffer overflow";
}
target.data.set(item.data, item.offset);
file.data.set(piece.data, piece.offset);
}
},
onPieceLoaded: function(target, item) {
if (typeof target.totalLoadedPieces === 'undefined') {
target.totalLoadedPieces = 0;
onPieceLoaded: function(file, piece) {
this.addPieceToFile(file, piece);
++file.totalLoadedPieces;
// is all pieces of the file loaded?
if (file.totalLoadedPieces == file.pieces.length) {
this.onFileLoaded(file);
}
++target.totalLoadedPieces;
if (target.totalLoadedPieces == target.pieces.length) {
this.finalizeTarget(target);
++this._targetIndex;
for (var i=0; i<this._onCombineCompleted.length; ++i) {
this._onCombineCompleted[i](target.name, target.data);
}
if (this._targetIndex < this._targets.length) {
this.requestContent();
} else {
this.isCompleted = true;
for (i=0; i<this._onAllTargetsBuilt.length; ++i) {
this._onAllTargetsBuilt[i]();
}
}
} else {
var next = target.lastRequestedPiece + 1;
if (next < target.pieces.length) {
this.requestPiece(target, next);
// continue loading more pieces of the file
// if not all pieces are already in progress
else {
var next = file.lastRequestedPiece + 1;
if (next < file.pieces.length) {
this.downloadPiece(file, next);
}
}
},
finalizeTarget: function(target) {
verifyFile: function(file) {
// verify that we downloaded as much as we were supposed to
var actualSize = 0;
for (var i=0;i<target.pieces.length; ++i) {
actualSize += target.pieces[i].dataLength;
for (var i=0;i<file.pieces.length; ++i) {
actualSize += file.pieces[i].dataLength;
}
if (actualSize != target.size) {
if (actualSize != file.size) {
throw "Unexpected data size";
}
if (1 < target.pieces.length) {
var output = target.data;
var pieces = target.pieces;
// verify the pieces
if (file.pieces.length > 1) {
var output = file.data;
var pieces = file.pieces;
for (i=0; i<pieces.length; ++i) {
var item = pieces[i];
// Bounds check
@ -261,6 +388,22 @@ var Combine = {
}
}
}
},
onFileLoaded: function(file) {
this.verifyFile(file);
this.notifyFileLoaded(file);
++this._fileIndex;
if (this._fileIndex == this._files.length) {
this.onArchiveLoaded();
} else {
this.downloadContent();
}
},
onArchiveLoaded: function() {
this.isCompleted = true;
this.notifyArchiveLoaded();
}
};
@ -272,6 +415,19 @@ var Progress = {
progress_id: "defold-progress",
bar_id: "defold-progress-bar",
listeners: [],
addListener: function(callback) {
if (typeof callback !== 'function') throw "Invalid callback registration";
this.listeners.push(callback);
},
notifyListeners: function(percentage) {
for (i=0; i<this.listeners.length; ++i) {
this.listeners[i](percentage);
}
},
addProgress : function (canvas) {
/* Insert default progress bar below canvas */
canvas.insertAdjacentHTML('afterend', '<div id="' + Progress.progress_id + '" class="canvas-app-progress"><div id="' + Progress.bar_id + '" class="canvas-app-progress-bar" style="width: 0%;"></div></div>');
@ -279,8 +435,15 @@ var Progress = {
Progress.progress = document.getElementById(Progress.progress_id);
},
updateProgress: function (percentage, text) {
Progress.bar.style.width = percentage + "%";
updateProgress: function(percentage) {
if (Progress.bar) {
Progress.bar.style.width = percentage + "%";
}
Progress.notifyListeners(percentage);
},
calculateProgress: function (from, to, current, total) {
this.updateProgress(from + (current / total) * (to - from));
},
removeProgress: function () {
@ -343,6 +506,8 @@ var Module = {
_syncMaxTries: 3,
_syncTries: 0,
arguments: [],
print: function(text) { console.log(text); },
printErr: function(text) { console.error(text); },
@ -350,8 +515,7 @@ var Module = {
isWASMSupported: (function() {
try {
if (typeof WebAssembly === "object"
&& typeof WebAssembly.instantiate === "function") {
if (typeof WebAssembly === "object" && typeof WebAssembly.instantiate === "function") {
const module = new WebAssembly.Module(Uint8Array.of(0x0, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00));
if (module instanceof WebAssembly.Module)
return new WebAssembly.Instance(module) instanceof WebAssembly.Instance;
@ -438,6 +602,13 @@ var Module = {
}
},
setupCanvas: function(appCanvasId) {
appCanvasId = (typeof appCanvasId === 'undefined') ? 'canvas' : appCanvasId;
Module.canvas = document.getElementById(appCanvasId);
return Module.canvas;
},
/**
* Module.runApp - Starts the application given a canvas element id
*
@ -470,8 +641,8 @@ var Module = {
* 'can_not_download_file_callback':
* Function that is called if you can't download file after 'retry_count' attempts.
**/
runApp: function(app_canvas_id, extra_params) {
app_canvas_id = (typeof app_canvas_id === 'undefined') ? 'canvas' : app_canvas_id;
runApp: function(appCanvasId, extra_params) {
Module.setupCanvas(appCanvasId);
var params = {
archive_location_filter: function(path) { return 'split' + path; },
@ -491,10 +662,14 @@ var Module = {
}
}
Module.canvas = document.getElementById(app_canvas_id);
Module.arguments = params["engine_arguments"];
Module.persistentStorage = params["persistent_storage"];
Module["TOTAL_MEMORY"] = params["custom_heap_size"];
var fullScreenContainer = params["full_screen_container"];
if (typeof fullScreenContainer === "string") {
fullScreenContainer = document.querySelector(fullScreenContainer);
}
Module.fullScreenContainer = fullScreenContainer || Module.canvas;
if (Module.hasWebGLSupport()) {
// Override game keys
@ -502,9 +677,6 @@ var Module = {
Module.setupVisibilityChangeListener();
// Add progress visuals
Progress.addProgress(Module.canvas);
// Add context menu hide-handler if requested
if (params["disable_context_menu"])
{
@ -513,19 +685,17 @@ var Module = {
};
}
Combine._retry_time = params["retry_time"];
Combine._max_retry_count = params["retry_count"];
FileLoader.options.retryCount = params["retry_count"];
FileLoader.options.retryInterval = params["retry_time"] * 1000;
if (typeof params["can_not_download_file_callback"] === "function") {
Combine._can_not_download_file_callback = params["can_not_download_file_callback"];
GameArchiveLoader.addFileDownloadErrorListener(params["can_not_download_file_callback"]);
}
// Load and assemble archive
Combine.addCombineCompletedListener(Module.onArchiveFileLoaded);
Combine.addAllTargetsBuiltListener(Module.onArchiveLoaded);
Combine.addProgressListener(Module.onArchiveLoadProgress);
Combine._archiveLocationFilter = params["archive_location_filter"];
Combine.process(Combine._archiveLocationFilter('/archive_files.json'));
GameArchiveLoader.addFileLoadedListener(Module.onArchiveFileLoaded);
GameArchiveLoader.addArchiveLoadedListener(Module.onArchiveLoaded);
GameArchiveLoader.setFileLocationFilter(params["archive_location_filter"]);
GameArchiveLoader.loadArchiveDescription('/archive_files.json');
} else {
Progress.addProgress(Module.canvas);
Progress.updateProgress(100, "Unable to start game, WebGL not supported");
Module.setStatus = function(text) {
if (text) Module.printErr('[missing WebGL] ' + text);
@ -537,16 +707,12 @@ var Module = {
}
},
onArchiveLoadProgress: function(downloaded, total) {
Progress.updateProgress(downloaded / total * 100);
},
onArchiveFileLoaded: function(name, data) {
Module._filesToPreload.push({path: name, data: data});
onArchiveFileLoaded: function(file) {
Module._filesToPreload.push({path: file.name, data: file.data});
},
onArchiveLoaded: function() {
Combine.cleanUp();
GameArchiveLoader.cleanUp();
Module._archiveLoaded = true;
Progress.updateProgress(100, "Starting...");
@ -555,11 +721,11 @@ var Module = {
}
},
toggleFullscreen: function() {
toggleFullscreen: function(element) {
if (GLFW.isFullscreen) {
GLFW.cancelFullScreen();
} else {
GLFW.requestFullScreen();
GLFW.requestFullScreen(element);
}
},
@ -654,10 +820,6 @@ var Module = {
if (!Module._archiveLoaded) {
Module._waitingForArchive = true;
} else {
// Need to set heap size before calling main
TOTAL_MEMORY = Module["TOTAL_MEMORY"] || TOTAL_MEMORY;
Module.preloadAll();
Progress.removeProgress();
if (Module.callMain === undefined) {
@ -693,8 +855,10 @@ var Module = {
};
window.onerror = function(err, url, line, column, errObj) {
var errorObject = Module.prepareErrorObject(err, url, line, column, errObj);
Module.ccall('JSWriteDump', 'null', ['string'], [JSON.stringify(errorObject.stack)]);
if (typeof Module.ccall !== 'undefined') {
var errorObject = Module.prepareErrorObject(err, url, line, column, errObj);
Module.ccall('JSWriteDump', 'null', ['string'], [JSON.stringify(errorObject.stack)]);
}
Module.setStatus('Exception thrown, see JavaScript console');
Module.setStatus = function(text) {
if (text) Module.printErr('[post-exception status] ' + text);

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -7,7 +7,7 @@
<meta name="apple-mobile-web-app-capable" content="yes">
<!-- The above 4 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>druid 0.5.0</title>
<title>druid 0.6.459</title>
<style type='text/css'>
/* Disable user selection to avoid strange bug in Chrome on Windows:
* Selecting a text outside the canvas, then clicking+draging would
@ -43,6 +43,10 @@
vertical-align: bottom;
}
#canvas-container {
position: relative;
}
canvas:focus, canvas:active {
outline: none;
border: 0;
@ -118,7 +122,9 @@
<body>
<div id="app-container" class="canvas-app-container">
<canvas id="canvas" class="canvas-app-canvas" tabindex="1" width="600" height="900"></canvas>
<div id="canvas-container" class="canvas-app-canvas-container">
<canvas id="canvas" class="canvas-app-canvas" tabindex="1" width="600" height="900"></canvas>
</div>
<div class="buttons-background">
</div>
</div>
@ -132,9 +138,12 @@
},
engine_arguments: ["--verify-graphics-calls=false",],
custom_heap_size: 67108864,
full_screen_container: "#canvas-container",
disable_context_menu: true
}
Module['INITIAL_MEMORY'] = extra_params.custom_heap_size;
Module['onRuntimeInitialized'] = function() {
Module.runApp("canvas", extra_params);
};
@ -192,20 +201,10 @@
resize_game_canvas();
window.addEventListener('resize', resize_game_canvas, false);
window.addEventListener('orientationchange', resize_game_canvas, false);
function load_engine() {
var engineJS = document.createElement('script');
engineJS.type = 'text/javascript';
if (Module['isWASMSupported']) {
engineJS.src = 'druid_wasm.js';
} else {
engineJS.src = 'druid_asmjs.js';
}
document.head.appendChild(engineJS);
}
</script>
<script id='engine-start' type='text/javascript'>
load_engine();
EngineLoader.load("canvas", "druid");
</script>
</body>
</html>

View File

@ -31,40 +31,30 @@
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="modules/druid.back_handler.html">druid.back_handler</a></li>
<li><a href="modules/druid.blocker.html">druid.blocker</a></li>
<li><a href="modules/druid.button.html">druid.button</a></li>
<li><a href="modules/druid.drag.html">druid.drag</a></li>
<li><a href="modules/druid.hover.html">druid.hover</a></li>
<li><a href="modules/druid.scroll.html">druid.scroll</a></li>
<li><a href="modules/druid.static_grid.html">druid.static_grid</a></li>
<li><a href="modules/druid.swipe.html">druid.swipe</a></li>
<li><a href="modules/druid.text.html">druid.text</a></li>
<li><a href="modules/component.html">component</a></li>
<li><a href="modules/BackHandler.html">BackHandler</a></li>
<li><a href="modules/Blocker.html">Blocker</a></li>
<li><a href="modules/Button.html">Button</a></li>
<li><a href="modules/Drag.html">Drag</a></li>
<li><a href="modules/Hover.html">Hover</a></li>
<li><a href="modules/Scroll.html">Scroll</a></li>
<li><a href="modules/StaticGrid.html">StaticGrid</a></li>
<li><a href="modules/Swipe.html">Swipe</a></li>
<li><a href="modules/Text.html">Text</a></li>
<li><a href="modules/BaseComponent.html">BaseComponent</a></li>
<li><a href="modules/druid.html">druid</a></li>
<li><a href="modules/druid_event.html">druid_event</a></li>
<li><a href="modules/druid.checkbox.html">druid.checkbox</a></li>
<li><a href="modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
<li><a href="modules/druid.dynamic_grid.html">druid.dynamic_grid</a></li>
<li><a href="modules/druid.input.html">druid.input</a></li>
<li><a href="modules/druid.lang_text.html">druid.lang_text</a></li>
<li><a href="modules/druid.progress.html">druid.progress</a></li>
<li><a href="modules/druid.radio_group.html">druid.radio_group</a></li>
<li><a href="modules/druid.slider.html">druid.slider</a></li>
<li><a href="modules/druid.timer.html">druid.timer</a></li>
<li><a href="modules/DruidEvent.html">DruidEvent</a></li>
<li><a href="modules/Checkbox.html">Checkbox</a></li>
<li><a href="modules/CheckboxGroup.html">CheckboxGroup</a></li>
<li><a href="modules/DataList.html">DataList</a></li>
<li><a href="modules/DynamicGrid.html">DynamicGrid</a></li>
<li><a href="modules/Input.html">Input</a></li>
<li><a href="modules/LangText.html">LangText</a></li>
<li><a href="modules/Progress.html">Progress</a></li>
<li><a href="modules/RadioGroup.html">RadioGroup</a></li>
<li><a href="modules/Slider.html">Slider</a></li>
<li><a href="modules/Timer.html">Timer</a></li>
<li><a href="modules/druid.helper.html">druid.helper</a></li>
<li><a href="modules/druid_instance.html">druid_instance</a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="topics/01-components.md.html">01-components</a></li>
<li><a href="topics/02-creating_custom_components.md.html">Creating custom components</a></li>
<li><a href="topics/03-styles.md.html">Styles</a></li>
<li><a href="topics/04-druid_assets.md.html">Druid assets</a></li>
<li><a href="topics/05-examples.md.html">Examples</a></li>
<li><a href="topics/changelog.md.html">Druid 0.3.0:</a></li>
<li><a href="topics/faq.md.html">faq</a></li>
<li><a href="topics/README.md.html">README</a></li>
<li><a href="modules/DruidInstance.html">DruidInstance</a></li>
</ul>
</div>
@ -77,43 +67,43 @@
<h2>Modules</h2>
<table class="module_list">
<tr>
<td class="name" nowrap><a href="modules/druid.back_handler.html">druid.back_handler</a></td>
<td class="name" nowrap><a href="modules/BackHandler.html">BackHandler</a></td>
<td class="summary">Component to handle back key (android, backspace)</td>
</tr>
<tr>
<td class="name" nowrap><a href="modules/druid.blocker.html">druid.blocker</a></td>
<td class="name" nowrap><a href="modules/Blocker.html">Blocker</a></td>
<td class="summary">Component to block input on specify zone by node</td>
</tr>
<tr>
<td class="name" nowrap><a href="modules/druid.button.html">druid.button</a></td>
<td class="name" nowrap><a href="modules/Button.html">Button</a></td>
<td class="summary">Component to handle basic GUI button</td>
</tr>
<tr>
<td class="name" nowrap><a href="modules/druid.drag.html">druid.drag</a></td>
<td class="name" nowrap><a href="modules/Drag.html">Drag</a></td>
<td class="summary">Component to handle drag action on node.</td>
</tr>
<tr>
<td class="name" nowrap><a href="modules/druid.hover.html">druid.hover</a></td>
<td class="name" nowrap><a href="modules/Hover.html">Hover</a></td>
<td class="summary">Component to handle hover node interaction</td>
</tr>
<tr>
<td class="name" nowrap><a href="modules/druid.scroll.html">druid.scroll</a></td>
<td class="name" nowrap><a href="modules/Scroll.html">Scroll</a></td>
<td class="summary">Component to handle scroll content.</td>
</tr>
<tr>
<td class="name" nowrap><a href="modules/druid.static_grid.html">druid.static_grid</a></td>
<td class="name" nowrap><a href="modules/StaticGrid.html">StaticGrid</a></td>
<td class="summary">Component to handle placing components by row and columns.</td>
</tr>
<tr>
<td class="name" nowrap><a href="modules/druid.swipe.html">druid.swipe</a></td>
<td class="name" nowrap><a href="modules/Swipe.html">Swipe</a></td>
<td class="summary">Component to handle swipe gestures on node.</td>
</tr>
<tr>
<td class="name" nowrap><a href="modules/druid.text.html">druid.text</a></td>
<td class="name" nowrap><a href="modules/Text.html">Text</a></td>
<td class="summary">Component to handle all GUI texts.</td>
</tr>
<tr>
<td class="name" nowrap><a href="modules/component.html">component</a></td>
<td class="name" nowrap><a href="modules/BaseComponent.html">BaseComponent</a></td>
<td class="summary">Basic class for all Druid components.</td>
</tr>
<tr>
@ -121,44 +111,48 @@
<td class="summary">Druid UI Library.</td>
</tr>
<tr>
<td class="name" nowrap><a href="modules/druid_event.html">druid_event</a></td>
<td class="name" nowrap><a href="modules/DruidEvent.html">DruidEvent</a></td>
<td class="summary">Lua event small library</td>
</tr>
<tr>
<td class="name" nowrap><a href="modules/druid.checkbox.html">druid.checkbox</a></td>
<td class="name" nowrap><a href="modules/Checkbox.html">Checkbox</a></td>
<td class="summary">Druid checkbox component</td>
</tr>
<tr>
<td class="name" nowrap><a href="modules/druid.checkbox_group.html">druid.checkbox_group</a></td>
<td class="name" nowrap><a href="modules/CheckboxGroup.html">CheckboxGroup</a></td>
<td class="summary">Checkbox group module</td>
</tr>
<tr>
<td class="name" nowrap><a href="modules/druid.dynamic_grid.html">druid.dynamic_grid</a></td>
<td class="name" nowrap><a href="modules/DataList.html">DataList</a></td>
<td class="summary">Component to manage data for huge dataset in scroll.</td>
</tr>
<tr>
<td class="name" nowrap><a href="modules/DynamicGrid.html">DynamicGrid</a></td>
<td class="summary">Component to handle placing components in row</td>
</tr>
<tr>
<td class="name" nowrap><a href="modules/druid.input.html">druid.input</a></td>
<td class="name" nowrap><a href="modules/Input.html">Input</a></td>
<td class="summary">Druid input text component.</td>
</tr>
<tr>
<td class="name" nowrap><a href="modules/druid.lang_text.html">druid.lang_text</a></td>
<td class="name" nowrap><a href="modules/LangText.html">LangText</a></td>
<td class="summary">Component to handle all GUI texts
Good working with localization system</td>
</tr>
<tr>
<td class="name" nowrap><a href="modules/druid.progress.html">druid.progress</a></td>
<td class="name" nowrap><a href="modules/Progress.html">Progress</a></td>
<td class="summary">Basic progress bar component.</td>
</tr>
<tr>
<td class="name" nowrap><a href="modules/druid.radio_group.html">druid.radio_group</a></td>
<td class="name" nowrap><a href="modules/RadioGroup.html">RadioGroup</a></td>
<td class="summary">Radio group module</td>
</tr>
<tr>
<td class="name" nowrap><a href="modules/druid.slider.html">druid.slider</a></td>
<td class="name" nowrap><a href="modules/Slider.html">Slider</a></td>
<td class="summary">Druid slider component</td>
</tr>
<tr>
<td class="name" nowrap><a href="modules/druid.timer.html">druid.timer</a></td>
<td class="name" nowrap><a href="modules/Timer.html">Timer</a></td>
<td class="summary">Component to handle GUI timers.</td>
</tr>
<tr>
@ -166,51 +160,16 @@
<td class="summary">Text node or icon node can be nil</td>
</tr>
<tr>
<td class="name" nowrap><a href="modules/druid_instance.html">druid_instance</a></td>
<td class="name" nowrap><a href="modules/DruidInstance.html">DruidInstance</a></td>
<td class="summary">Instance of Druid.</td>
</tr>
</table>
<h2>Topics</h2>
<table class="module_list">
<tr>
<td class="name" nowrap><a href="topics/01-components.md.html">01-components.md</a></td>
<td class="summary"></td>
</tr>
<tr>
<td class="name" nowrap><a href="topics/02-creating_custom_components.md.html">02-creating_custom_components.md</a></td>
<td class="summary"></td>
</tr>
<tr>
<td class="name" nowrap><a href="topics/03-styles.md.html">03-styles.md</a></td>
<td class="summary"></td>
</tr>
<tr>
<td class="name" nowrap><a href="topics/04-druid_assets.md.html">04-druid_assets.md</a></td>
<td class="summary"></td>
</tr>
<tr>
<td class="name" nowrap><a href="topics/05-examples.md.html">05-examples.md</a></td>
<td class="summary"></td>
</tr>
<tr>
<td class="name" nowrap><a href="topics/changelog.md.html">changelog.md</a></td>
<td class="summary"></td>
</tr>
<tr>
<td class="name" nowrap><a href="topics/faq.md.html">faq.md</a></td>
<td class="summary"></td>
</tr>
<tr>
<td class="name" nowrap><a href="topics/README.md.html">README.md</a></td>
<td class="summary"></td>
</tr>
</table>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-09-29 23:46:16 </i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@ -0,0 +1,221 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Fields">Fields</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><strong>BackHandler</strong></li>
<li><a href="../modules/Blocker.html">Blocker</a></li>
<li><a href="../modules/Button.html">Button</a></li>
<li><a href="../modules/Drag.html">Drag</a></li>
<li><a href="../modules/Hover.html">Hover</a></li>
<li><a href="../modules/Scroll.html">Scroll</a></li>
<li><a href="../modules/StaticGrid.html">StaticGrid</a></li>
<li><a href="../modules/Swipe.html">Swipe</a></li>
<li><a href="../modules/Text.html">Text</a></li>
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/DruidEvent.html">DruidEvent</a></li>
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
<li><a href="../modules/DataList.html">DataList</a></li>
<li><a href="../modules/DynamicGrid.html">DynamicGrid</a></li>
<li><a href="../modules/Input.html">Input</a></li>
<li><a href="../modules/LangText.html">LangText</a></li>
<li><a href="../modules/Progress.html">Progress</a></li>
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
<li><a href="../modules/Slider.html">Slider</a></li>
<li><a href="../modules/Timer.html">Timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/DruidInstance.html">DruidInstance</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>BackHandler</code></h1>
<p>Component to handle back key (android, backspace)</p>
<p></p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#init">init(self, callback[, params])</a></td>
<td class="summary">Component init function</td>
</tr>
<tr>
<td class="name" nowrap><a href="#on_input">on_input(self, action_id, action)</a></td>
<td class="summary">Input handler for component</td>
</tr>
</table>
<h2><a href="#Fields">Fields</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#on_back">on_back</a></td>
<td class="summary">On back handler callback(self, params)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#params">params</a></td>
<td class="summary">Params to back callback</td>
</tr>
</table>
<br/>
<br/>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "init"></a>
<strong>init(self, callback[, params])</strong>
</dt>
<dd>
Component init function
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">BackHandler</span></span>
</li>
<li><span class="parameter">callback</span>
<span class="types"><span class="type">callback</span></span>
On back button
</li>
<li><span class="parameter">params</span>
<span class="types"><span class="type">any</span></span>
Callback argument
(<em>optional</em>)
</li>
</ul>
</dd>
<dt>
<a name = "on_input"></a>
<strong>on_input(self, action_id, action)</strong>
</dt>
<dd>
Input handler for component
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">BackHandler</span></span>
</li>
<li><span class="parameter">action_id</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
on_input action id
</li>
<li><span class="parameter">action</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
on_input action
</li>
</ul>
</dd>
</dl>
<h2 class="section-header "><a name="Fields"></a>Fields</h2>
<dl class="function">
<dt>
<a name = "on_back"></a>
<strong>on_back</strong>
</dt>
<dd>
On back handler callback(self, params)
<ul>
<li><span class="parameter">on_back</span>
<span class="types"><span class="type">druid_event</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "params"></a>
<strong>params</strong>
</dt>
<dd>
Params to back callback
<ul>
<li><span class="parameter">params</span>
<span class="types"><span class="type">any</span></span>
</li>
</ul>
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View File

@ -0,0 +1,584 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Fields">Fields</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/BackHandler.html">BackHandler</a></li>
<li><a href="../modules/Blocker.html">Blocker</a></li>
<li><a href="../modules/Button.html">Button</a></li>
<li><a href="../modules/Drag.html">Drag</a></li>
<li><a href="../modules/Hover.html">Hover</a></li>
<li><a href="../modules/Scroll.html">Scroll</a></li>
<li><a href="../modules/StaticGrid.html">StaticGrid</a></li>
<li><a href="../modules/Swipe.html">Swipe</a></li>
<li><a href="../modules/Text.html">Text</a></li>
<li><strong>BaseComponent</strong></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/DruidEvent.html">DruidEvent</a></li>
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
<li><a href="../modules/DataList.html">DataList</a></li>
<li><a href="../modules/DynamicGrid.html">DynamicGrid</a></li>
<li><a href="../modules/Input.html">Input</a></li>
<li><a href="../modules/LangText.html">LangText</a></li>
<li><a href="../modules/Progress.html">Progress</a></li>
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
<li><a href="../modules/Slider.html">Slider</a></li>
<li><a href="../modules/Timer.html">Timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/DruidInstance.html">DruidInstance</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>BaseComponent</code></h1>
<p>Basic class for all Druid components.</p>
<p>
To create you component, use `component.create`</p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#set_style">set_style(self, druid_style)</a></td>
<td class="summary">Set current component style table.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_template">set_template(self, template)</a></td>
<td class="summary">Set current component template name</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_nodes">set_nodes(self, nodes)</a></td>
<td class="summary">Set current component nodes</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_context">get_context(self)</a></td>
<td class="summary">Get current component context</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_node">get_node(self, node_or_name)</a></td>
<td class="summary">Get node for component by name.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_druid">get_druid(self)</a></td>
<td class="summary">Return druid with context of calling component.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_name">get_name(self)</a></td>
<td class="summary">Return component name</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_input_priority">get_input_priority(self)</a></td>
<td class="summary">Return component input priority</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_input_priority">set_input_priority(self, value)</a></td>
<td class="summary">Set component input priority</td>
</tr>
<tr>
<td class="name" nowrap><a href="#reset_input_priority">reset_input_priority(self)</a></td>
<td class="summary">Reset component input priority to default value</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_uid">get_uid(self)</a></td>
<td class="summary">Return component uid.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_input_enabled">set_input_enabled(self, state)</a></td>
<td class="summary">Set component input state.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_parent_component">get_parent_component(self)</a></td>
<td class="summary">Return the parent for current component</td>
</tr>
<tr>
<td class="name" nowrap><a href="#setup_component">setup_component(self, druid_instance, context, style)</a></td>
<td class="summary">Setup component context and his style table</td>
</tr>
</table>
<h2><a href="#Fields">Fields</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#ALL">ALL</a></td>
<td class="summary">Component Interests</td>
</tr>
</table>
<br/>
<br/>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "set_style"></a>
<strong>set_style(self, druid_style)</strong>
</dt>
<dd>
Set current component style table.
Invoke `on_style_change` on component, if exist. BaseComponent should handle
their style changing and store all style params
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">BaseComponent</span></span>
</li>
<li><span class="parameter">druid_style</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
Druid style module
</li>
</ul>
</dd>
<dt>
<a name = "set_template"></a>
<strong>set_template(self, template)</strong>
</dt>
<dd>
Set current component template name
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">BaseComponent</span></span>
</li>
<li><span class="parameter">template</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
BaseComponent template name
</li>
</ul>
</dd>
<dt>
<a name = "set_nodes"></a>
<strong>set_nodes(self, nodes)</strong>
</dt>
<dd>
Set current component nodes
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">BaseComponent</span></span>
</li>
<li><span class="parameter">nodes</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
BaseComponent nodes table
</li>
</ul>
</dd>
<dt>
<a name = "get_context"></a>
<strong>get_context(self)</strong>
</dt>
<dd>
Get current component context
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">BaseComponent</span></span>
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
BaseComponent context
</ol>
</dd>
<dt>
<a name = "get_node"></a>
<strong>get_node(self, node_or_name)</strong>
</dt>
<dd>
Get node for component by name.
If component has nodes, node_or_name should be string
It auto pick node by template name or from nodes by clone_tree
if they was setup via component:set_nodes, component:set_template
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">BaseComponent</span></span>
</li>
<li><span class="parameter">node_or_name</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a> or <span class="type">node</span></span>
Node name or node itself
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">node</span></span>
Gui node
</ol>
</dd>
<dt>
<a name = "get_druid"></a>
<strong>get_druid(self)</strong>
</dt>
<dd>
Return druid with context of calling component.
Use it to create component inside of other components.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">BaseComponent</span></span>
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Druid</span></span>
Druid instance with component context
</ol>
</dd>
<dt>
<a name = "get_name"></a>
<strong>get_name(self)</strong>
</dt>
<dd>
Return component name
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">BaseComponent</span></span>
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
The component name
</ol>
</dd>
<dt>
<a name = "get_input_priority"></a>
<strong>get_input_priority(self)</strong>
</dt>
<dd>
Return component input priority
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">BaseComponent</span></span>
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">number</span></span>
The component input priority
</ol>
</dd>
<dt>
<a name = "set_input_priority"></a>
<strong>set_input_priority(self, value)</strong>
</dt>
<dd>
Set component input priority
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">BaseComponent</span></span>
</li>
<li><span class="parameter">value</span>
<span class="types"><span class="type">number</span></span>
The new input priority value
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">number</span></span>
The component input priority
</ol>
</dd>
<dt>
<a name = "reset_input_priority"></a>
<strong>reset_input_priority(self)</strong>
</dt>
<dd>
Reset component input priority to default value
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">BaseComponent</span></span>
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">number</span></span>
The component input priority
</ol>
</dd>
<dt>
<a name = "get_uid"></a>
<strong>get_uid(self)</strong>
</dt>
<dd>
Return component uid. UID generated in component creation order
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">BaseComponent</span></span>
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">number</span></span>
The component uid
</ol>
</dd>
<dt>
<a name = "set_input_enabled"></a>
<strong>set_input_enabled(self, state)</strong>
</dt>
<dd>
Set component input state. By default it enabled
You can disable any input of component by this function
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">BaseComponent</span></span>
</li>
<li><span class="parameter">state</span>
<span class="types"><span class="type">bool</span></span>
The component input state
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">BaseComponent</span></span>
BaseComponent itself
</ol>
</dd>
<dt>
<a name = "get_parent_component"></a>
<strong>get_parent_component(self)</strong>
</dt>
<dd>
Return the parent for current component
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">BaseComponent</span></span>
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">druid.base_component</span> or <span class="type">nil</span></span>
The druid component instance or nil
</ol>
</dd>
<dt>
<a name = "setup_component"></a>
<strong>setup_component(self, druid_instance, context, style)</strong>
</dt>
<dd>
Setup component context and his style table
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">BaseComponent</span></span>
</li>
<li><span class="parameter">druid_instance</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
The parent druid instance
</li>
<li><span class="parameter">context</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
Druid context. Usually it is self of script
</li>
<li><span class="parameter">style</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
Druid style module
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">component</span></span>
BaseComponent itself
</ol>
</dd>
</dl>
<h2 class="section-header "><a name="Fields"></a>Fields</h2>
<dl class="function">
<dt>
<a name = "ALL"></a>
<strong>ALL</strong>
</dt>
<dd>
Component Interests
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

219
docs/modules/Blocker.html Normal file
View File

@ -0,0 +1,219 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Fields">Fields</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/BackHandler.html">BackHandler</a></li>
<li><strong>Blocker</strong></li>
<li><a href="../modules/Button.html">Button</a></li>
<li><a href="../modules/Drag.html">Drag</a></li>
<li><a href="../modules/Hover.html">Hover</a></li>
<li><a href="../modules/Scroll.html">Scroll</a></li>
<li><a href="../modules/StaticGrid.html">StaticGrid</a></li>
<li><a href="../modules/Swipe.html">Swipe</a></li>
<li><a href="../modules/Text.html">Text</a></li>
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/DruidEvent.html">DruidEvent</a></li>
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
<li><a href="../modules/DataList.html">DataList</a></li>
<li><a href="../modules/DynamicGrid.html">DynamicGrid</a></li>
<li><a href="../modules/Input.html">Input</a></li>
<li><a href="../modules/LangText.html">LangText</a></li>
<li><a href="../modules/Progress.html">Progress</a></li>
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
<li><a href="../modules/Slider.html">Slider</a></li>
<li><a href="../modules/Timer.html">Timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/DruidInstance.html">DruidInstance</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>Blocker</code></h1>
<p>Component to block input on specify zone by node</p>
<p></p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#init">init(self, node)</a></td>
<td class="summary">Component init function</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_enabled">set_enabled(self, state)</a></td>
<td class="summary">Set enabled blocker component state</td>
</tr>
<tr>
<td class="name" nowrap><a href="#is_enabled">is_enabled(self)</a></td>
<td class="summary">Return blocked enabled state</td>
</tr>
</table>
<h2><a href="#Fields">Fields</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#node">node</a></td>
<td class="summary">Trigger node</td>
</tr>
</table>
<br/>
<br/>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "init"></a>
<strong>init(self, node)</strong>
</dt>
<dd>
Component init function
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Blocker</span></span>
</li>
<li><span class="parameter">node</span>
<span class="types"><a class="type" href="../modules/Blocker.html#node">node</a></span>
Gui node
</li>
</ul>
</dd>
<dt>
<a name = "set_enabled"></a>
<strong>set_enabled(self, state)</strong>
</dt>
<dd>
Set enabled blocker component state
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Blocker</span></span>
</li>
<li><span class="parameter">state</span>
<span class="types"><span class="type">bool</span></span>
Enabled state
</li>
</ul>
</dd>
<dt>
<a name = "is_enabled"></a>
<strong>is_enabled(self)</strong>
</dt>
<dd>
Return blocked enabled state
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Blocker</span></span>
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">bool</span></span>
True, if blocker is enabled
</ol>
</dd>
</dl>
<h2 class="section-header "><a name="Fields"></a>Fields</h2>
<dl class="function">
<dt>
<a name = "node"></a>
<strong>node</strong>
</dt>
<dd>
Trigger node
<ul>
<li><span class="parameter">node</span>
<span class="types"><a class="type" href="../modules/Blocker.html#node">node</a></span>
</li>
</ul>
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View File

@ -34,100 +34,140 @@
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Tables">Tables</a></li>
<li><a href="#Fields">Fields</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/druid.back_handler.html">druid.back_handler</a></li>
<li><a href="../modules/druid.blocker.html">druid.blocker</a></li>
<li><strong>druid.button</strong></li>
<li><a href="../modules/druid.drag.html">druid.drag</a></li>
<li><a href="../modules/druid.hover.html">druid.hover</a></li>
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
<li><a href="../modules/druid.static_grid.html">druid.static_grid</a></li>
<li><a href="../modules/druid.swipe.html">druid.swipe</a></li>
<li><a href="../modules/druid.text.html">druid.text</a></li>
<li><a href="../modules/component.html">component</a></li>
<li><a href="../modules/BackHandler.html">BackHandler</a></li>
<li><a href="../modules/Blocker.html">Blocker</a></li>
<li><strong>Button</strong></li>
<li><a href="../modules/Drag.html">Drag</a></li>
<li><a href="../modules/Hover.html">Hover</a></li>
<li><a href="../modules/Scroll.html">Scroll</a></li>
<li><a href="../modules/StaticGrid.html">StaticGrid</a></li>
<li><a href="../modules/Swipe.html">Swipe</a></li>
<li><a href="../modules/Text.html">Text</a></li>
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/druid_event.html">druid_event</a></li>
<li><a href="../modules/druid.checkbox.html">druid.checkbox</a></li>
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
<li><a href="../modules/druid.dynamic_grid.html">druid.dynamic_grid</a></li>
<li><a href="../modules/druid.input.html">druid.input</a></li>
<li><a href="../modules/druid.lang_text.html">druid.lang_text</a></li>
<li><a href="../modules/druid.progress.html">druid.progress</a></li>
<li><a href="../modules/druid.radio_group.html">druid.radio_group</a></li>
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
<li><a href="../modules/DruidEvent.html">DruidEvent</a></li>
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
<li><a href="../modules/DataList.html">DataList</a></li>
<li><a href="../modules/DynamicGrid.html">DynamicGrid</a></li>
<li><a href="../modules/Input.html">Input</a></li>
<li><a href="../modules/LangText.html">LangText</a></li>
<li><a href="../modules/Progress.html">Progress</a></li>
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
<li><a href="../modules/Slider.html">Slider</a></li>
<li><a href="../modules/Timer.html">Timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/01-components.md.html">01-components</a></li>
<li><a href="../topics/02-creating_custom_components.md.html">Creating custom components</a></li>
<li><a href="../topics/03-styles.md.html">Styles</a></li>
<li><a href="../topics/04-druid_assets.md.html">Druid assets</a></li>
<li><a href="../topics/05-examples.md.html">Examples</a></li>
<li><a href="../topics/changelog.md.html">Druid 0.3.0:</a></li>
<li><a href="../topics/faq.md.html">faq</a></li>
<li><a href="../topics/README.md.html">README</a></li>
<li><a href="../modules/DruidInstance.html">DruidInstance</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>druid.button</code></h1>
<h1>Module <code>Button</code></h1>
<p>Component to handle basic GUI button</p>
<p>
</p>
<p></p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#init">init(node, callback[, params[, anim_node]])</a></td>
<td class="name" nowrap><a href="#init">init(self, node, callback[, params[, anim_node]])</a></td>
<td class="summary">Component init function</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_enabled">set_enabled(state)</a></td>
<td class="name" nowrap><a href="#set_enabled">set_enabled(self, state)</a></td>
<td class="summary">Set enabled button component state</td>
</tr>
<tr>
<td class="name" nowrap><a href="#is_enabled">is_enabled()</a></td>
<td class="name" nowrap><a href="#is_enabled">is_enabled(self)</a></td>
<td class="summary">Return button enabled state</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_click_zone">set_click_zone(zone)</a></td>
<td class="name" nowrap><a href="#set_click_zone">set_click_zone(self, zone)</a></td>
<td class="summary">Strict button click area.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_key_trigger">set_key_trigger(key)</a></td>
<td class="name" nowrap><a href="#set_key_trigger">set_key_trigger(self, key)</a></td>
<td class="summary">Set key-code to trigger this button</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_key_trigger">get_key_trigger()</a></td>
<td class="name" nowrap><a href="#get_key_trigger">get_key_trigger(self)</a></td>
<td class="summary">Get key-code to trigger this button</td>
</tr>
</table>
<h2><a href="#Tables">Tables</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#Events">Events</a></td>
<td class="summary">Component events</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Fields">Fields</a></td>
<td class="summary">Component fields</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Style">Style</a></td>
<td class="name" nowrap><a href="#style">style</a></td>
<td class="summary">Component style params.</td>
</tr>
</table>
<h2><a href="#Fields">Fields</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#on_click">on_click</a></td>
<td class="summary">On release button callback(self, params, button_instance)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#on_repeated_click">on_repeated_click</a></td>
<td class="summary">On repeated action button callback(self, params, button_instance, click_amount)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#on_long_click">on_long_click</a></td>
<td class="summary">On long tap button callback(self, params, button_instance, time)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#on_double_click">on_double_click</a></td>
<td class="summary">On double tap button callback(self, params, button_instance, click_amount)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#on_hold_callback">on_hold_callback</a></td>
<td class="summary">On button hold before long_click callback(self, params, button_instance, time)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#on_click_outside">on_click_outside</a></td>
<td class="summary">On click outside of button(self, params, button_instance)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#node">node</a></td>
<td class="summary">Trigger node</td>
</tr>
<tr>
<td class="name" nowrap><a href="#anim_node">anim_node</a></td>
<td class="summary">Animation node</td>
</tr>
<tr>
<td class="name" nowrap><a href="#start_scale">start_scale</a></td>
<td class="summary">Initial scale of anim_node</td>
</tr>
<tr>
<td class="name" nowrap><a href="#start_pos">start_pos</a></td>
<td class="summary">Initial pos of anim_node</td>
</tr>
<tr>
<td class="name" nowrap><a href="#pos">pos</a></td>
<td class="summary">Initial pos of anim_node</td>
</tr>
<tr>
<td class="name" nowrap><a href="#params">params</a></td>
<td class="summary">Params to click callbacks</td>
</tr>
<tr>
<td class="name" nowrap><a href="#hover">hover</a></td>
<td class="summary">Druid hover logic component</td>
</tr>
<tr>
<td class="name" nowrap><a href="#click_zone">click_zone</a></td>
<td class="summary">Restriction zone</td>
</tr>
</table>
<br/>
<br/>
@ -138,7 +178,7 @@
<dl class="function">
<dt>
<a name = "init"></a>
<strong>init(node, callback[, params[, anim_node]])</strong>
<strong>init(self, node, callback[, params[, anim_node]])</strong>
</dt>
<dd>
Component init function
@ -146,8 +186,12 @@
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Button</span></span>
</li>
<li><span class="parameter">node</span>
<span class="types"><span class="type">node</span></span>
<span class="types"><a class="type" href="../modules/Button.html#node">node</a></span>
Gui node
</li>
<li><span class="parameter">callback</span>
@ -160,7 +204,7 @@
(<em>optional</em>)
</li>
<li><span class="parameter">anim_node</span>
<span class="types"><span class="type">node</span></span>
<span class="types"><a class="type" href="../modules/Button.html#node">node</a></span>
Button anim node (node, if not provided)
(<em>optional</em>)
</li>
@ -173,7 +217,7 @@
</dd>
<dt>
<a name = "set_enabled"></a>
<strong>set_enabled(state)</strong>
<strong>set_enabled(self, state)</strong>
</dt>
<dd>
Set enabled button component state
@ -181,6 +225,10 @@
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Button</span></span>
</li>
<li><span class="parameter">state</span>
<span class="types"><span class="type">bool</span></span>
Enabled state
@ -190,7 +238,7 @@
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">druid.button</span></span>
<span class="types"><span class="type">Button</span></span>
Current button instance
</ol>
@ -200,12 +248,19 @@
</dd>
<dt>
<a name = "is_enabled"></a>
<strong>is_enabled()</strong>
<strong>is_enabled(self)</strong>
</dt>
<dd>
Return button enabled state
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Button</span></span>
</li>
</ul>
<h3>Returns:</h3>
<ol>
@ -220,7 +275,7 @@
</dd>
<dt>
<a name = "set_click_zone"></a>
<strong>set_click_zone(zone)</strong>
<strong>set_click_zone(self, zone)</strong>
</dt>
<dd>
Strict button click area. Useful for
@ -229,8 +284,12 @@
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Button</span></span>
</li>
<li><span class="parameter">zone</span>
<span class="types"><span class="type">node</span></span>
<span class="types"><a class="type" href="../modules/Button.html#node">node</a></span>
Gui node
</li>
</ul>
@ -238,7 +297,7 @@
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">druid.button</span></span>
<span class="types"><span class="type">Button</span></span>
Current button instance
</ol>
@ -248,7 +307,7 @@
</dd>
<dt>
<a name = "set_key_trigger"></a>
<strong>set_key_trigger(key)</strong>
<strong>set_key_trigger(self, key)</strong>
</dt>
<dd>
Set key-code to trigger this button
@ -256,6 +315,10 @@
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Button</span></span>
</li>
<li><span class="parameter">key</span>
<span class="types"><span class="type">hash</span></span>
The action_id of the key
@ -265,7 +328,7 @@
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">druid.button</span></span>
<span class="types"><span class="type">Button</span></span>
Current button instance
</ol>
@ -275,12 +338,19 @@
</dd>
<dt>
<a name = "get_key_trigger"></a>
<strong>get_key_trigger()</strong>
<strong>get_key_trigger(self)</strong>
</dt>
<dd>
Get key-code to trigger this button
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Button</span></span>
</li>
</ul>
<h3>Returns:</h3>
<ol>
@ -298,100 +368,8 @@
<dl class="function">
<dt>
<a name = "Events"></a>
<strong>Events</strong>
</dt>
<dd>
Component events
<h3>Fields:</h3>
<ul>
<li><span class="parameter">on_click</span>
<span class="types"><span class="type">druid_event</span></span>
(self, params, button_instance) On release button callback
</li>
<li><span class="parameter">on_repeated_click</span>
<span class="types"><span class="type">druid_event</span></span>
(self, params, button<em>instance, click</em>amount) On repeated action button callback
</li>
<li><span class="parameter">on_long_click</span>
<span class="types"><span class="type">druid_event</span></span>
(self, params, button_instance, time) On long tap button callback
</li>
<li><span class="parameter">on_double_click</span>
<span class="types"><span class="type">druid_event</span></span>
(self, params, button<em>instance, click</em>amount) On double tap button callback
</li>
<li><span class="parameter">on_hold_callback</span>
<span class="types"><span class="type">druid_event</span></span>
(self, params, button<em>instance, time) On button hold before long</em>click callback
</li>
<li><span class="parameter">on_click_outside</span>
<span class="types"><span class="type">druid_event</span></span>
(self, params, button_instance) On click outside of button
</li>
</ul>
</dd>
<dt>
<a name = "Fields"></a>
<strong>Fields</strong>
</dt>
<dd>
Component fields
<h3>Fields:</h3>
<ul>
<li><span class="parameter">node</span>
<span class="types"><span class="type">node</span></span>
Trigger node
</li>
<li><span class="parameter">anim_node</span>
<span class="types"><span class="type">node</span></span>
Animation node
(<em>default</em> node)
</li>
<li><span class="parameter">start_scale</span>
<span class="types"><span class="type">vector3</span></span>
Initial scale of anim_node
</li>
<li><span class="parameter">start_pos</span>
<span class="types"><span class="type">vector3</span></span>
Initial pos of anim_node
</li>
<li><span class="parameter">pos</span>
<span class="types"><span class="type">vector3</span></span>
Initial pos of anim_node
</li>
<li><span class="parameter">params</span>
<span class="types"><span class="type">any</span></span>
Params to click callbacks
</li>
<li><span class="parameter">hover</span>
<span class="types"><span class="type">druid.hover</span></span>
Druid hover logic component
</li>
<li><span class="parameter">click_zone</span>
<span class="types"><span class="type">node</span></span>
Restriction zone
(<em>optional</em>)
</li>
</ul>
</dd>
<dt>
<a name = "Style"></a>
<strong>Style</strong>
<a name = "style"></a>
<strong>style</strong>
</dt>
<dd>
Component style params.
@ -403,7 +381,7 @@
<ul>
<li><span class="parameter">LONGTAP_TIME</span>
<span class="types"><span class="type">number</span></span>
Minimum time to trigger on<em>hold</em>callback
Minimum time to trigger on_hold_callback
(<em>default</em> 0.4)
</li>
<li><span class="parameter">AUTOHOLD_TRIGGER</span>
@ -442,6 +420,292 @@
</dd>
</dl>
<h2 class="section-header "><a name="Fields"></a>Fields</h2>
<dl class="function">
<dt>
<a name = "on_click"></a>
<strong>on_click</strong>
</dt>
<dd>
On release button callback(self, params, button_instance)
<ul>
<li><span class="parameter">on_click</span>
<span class="types"><span class="type">druid_event</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "on_repeated_click"></a>
<strong>on_repeated_click</strong>
</dt>
<dd>
On repeated action button callback(self, params, button_instance, click_amount)
<ul>
<li><span class="parameter">on_repeated_click</span>
<span class="types"><span class="type">druid_event</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "on_long_click"></a>
<strong>on_long_click</strong>
</dt>
<dd>
On long tap button callback(self, params, button_instance, time)
<ul>
<li><span class="parameter">on_long_click</span>
<span class="types"><span class="type">druid_event</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "on_double_click"></a>
<strong>on_double_click</strong>
</dt>
<dd>
On double tap button callback(self, params, button_instance, click_amount)
<ul>
<li><span class="parameter">on_double_click</span>
<span class="types"><span class="type">druid_event</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "on_hold_callback"></a>
<strong>on_hold_callback</strong>
</dt>
<dd>
On button hold before long_click callback(self, params, button_instance, time)
<ul>
<li><span class="parameter">on_hold_callback</span>
<span class="types"><span class="type">druid_event</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "on_click_outside"></a>
<strong>on_click_outside</strong>
</dt>
<dd>
On click outside of button(self, params, button_instance)
<ul>
<li><span class="parameter">on_click_outside</span>
<span class="types"><span class="type">druid_event</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "node"></a>
<strong>node</strong>
</dt>
<dd>
Trigger node
<ul>
<li><span class="parameter">node</span>
<span class="types"><a class="type" href="../modules/Button.html#node">node</a></span>
</li>
</ul>
</dd>
<dt>
<a name = "anim_node"></a>
<strong>anim_node</strong>
</dt>
<dd>
Animation node
<ul>
<li><span class="parameter">anim_node</span>
<span class="types"><a class="type" href="../modules/Button.html#node">node</a></span>
(<em>default</em> node)
</li>
</ul>
</dd>
<dt>
<a name = "start_scale"></a>
<strong>start_scale</strong>
</dt>
<dd>
Initial scale of anim_node
<ul>
<li><span class="parameter">start_scale</span>
<span class="types"><span class="type">vector3</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "start_pos"></a>
<strong>start_pos</strong>
</dt>
<dd>
Initial pos of anim_node
<ul>
<li><span class="parameter">start_pos</span>
<span class="types"><span class="type">vector3</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "pos"></a>
<strong>pos</strong>
</dt>
<dd>
Initial pos of anim_node
<ul>
<li><span class="parameter">pos</span>
<span class="types"><span class="type">vector3</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "params"></a>
<strong>params</strong>
</dt>
<dd>
Params to click callbacks
<ul>
<li><span class="parameter">params</span>
<span class="types"><span class="type">any</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "hover"></a>
<strong>hover</strong>
</dt>
<dd>
Druid hover logic component
<ul>
<li><span class="parameter">hover</span>
<span class="types"><span class="type">druid.hover</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "click_zone"></a>
<strong>click_zone</strong>
</dt>
<dd>
Restriction zone
<ul>
<li><span class="parameter">click_zone</span>
<span class="types"><a class="type" href="../modules/Button.html#node">node</a></span>
(<em>optional</em>)
</li>
</ul>
</dd>
</dl>
@ -450,7 +714,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-09-29 23:46:16 </i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

340
docs/modules/Checkbox.html Normal file
View File

@ -0,0 +1,340 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Tables">Tables</a></li>
<li><a href="#Fields">Fields</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/BackHandler.html">BackHandler</a></li>
<li><a href="../modules/Blocker.html">Blocker</a></li>
<li><a href="../modules/Button.html">Button</a></li>
<li><a href="../modules/Drag.html">Drag</a></li>
<li><a href="../modules/Hover.html">Hover</a></li>
<li><a href="../modules/Scroll.html">Scroll</a></li>
<li><a href="../modules/StaticGrid.html">StaticGrid</a></li>
<li><a href="../modules/Swipe.html">Swipe</a></li>
<li><a href="../modules/Text.html">Text</a></li>
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/DruidEvent.html">DruidEvent</a></li>
<li><strong>Checkbox</strong></li>
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
<li><a href="../modules/DataList.html">DataList</a></li>
<li><a href="../modules/DynamicGrid.html">DynamicGrid</a></li>
<li><a href="../modules/Input.html">Input</a></li>
<li><a href="../modules/LangText.html">LangText</a></li>
<li><a href="../modules/Progress.html">Progress</a></li>
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
<li><a href="../modules/Slider.html">Slider</a></li>
<li><a href="../modules/Timer.html">Timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/DruidInstance.html">DruidInstance</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>Checkbox</code></h1>
<p>Druid checkbox component</p>
<p></p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#init">init(self, node, callback[, click_node=node])</a></td>
<td class="summary">Component init function</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_state">set_state(self, state, is_silent)</a></td>
<td class="summary">Set checkbox state</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_state">get_state(self)</a></td>
<td class="summary">Return checkbox state</td>
</tr>
</table>
<h2><a href="#Tables">Tables</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#style">style</a></td>
<td class="summary">Component style params.</td>
</tr>
</table>
<h2><a href="#Fields">Fields</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#on_change_state">on_change_state</a></td>
<td class="summary">On change state callback(self, state)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#node">node</a></td>
<td class="summary">Visual node</td>
</tr>
<tr>
<td class="name" nowrap><a href="#click_node">click_node</a></td>
<td class="summary">Button trigger node</td>
</tr>
<tr>
<td class="name" nowrap><a href="#button">button</a></td>
<td class="summary">Button component from click_node</td>
</tr>
</table>
<br/>
<br/>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "init"></a>
<strong>init(self, node, callback[, click_node=node])</strong>
</dt>
<dd>
Component init function
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Checkbox</span></span>
</li>
<li><span class="parameter">node</span>
<span class="types"><a class="type" href="../modules/Checkbox.html#node">node</a></span>
Gui node
</li>
<li><span class="parameter">callback</span>
<span class="types"><span class="type">function</span></span>
Checkbox callback
</li>
<li><span class="parameter">click_node</span>
<span class="types"><a class="type" href="../modules/Checkbox.html#node">node</a></span>
Trigger node, by default equals to node
(<em>default</em> node)
</li>
</ul>
</dd>
<dt>
<a name = "set_state"></a>
<strong>set_state(self, state, is_silent)</strong>
</dt>
<dd>
Set checkbox state
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Checkbox</span></span>
</li>
<li><span class="parameter">state</span>
<span class="types"><span class="type">bool</span></span>
Checkbox state
</li>
<li><span class="parameter">is_silent</span>
<span class="types"><span class="type">bool</span></span>
Don't trigger on_change_state if true
</li>
</ul>
</dd>
<dt>
<a name = "get_state"></a>
<strong>get_state(self)</strong>
</dt>
<dd>
Return checkbox state
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Checkbox</span></span>
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">bool</span></span>
Checkbox state
</ol>
</dd>
</dl>
<h2 class="section-header "><a name="Tables"></a>Tables</h2>
<dl class="function">
<dt>
<a name = "style"></a>
<strong>style</strong>
</dt>
<dd>
Component style params.
You can override this component styles params in druid styles table
or create your own style
<h3>Fields:</h3>
<ul>
<li><span class="parameter">on_change_state</span>
<span class="types"><span class="type">function</span></span>
(self, node, state)
</li>
</ul>
</dd>
</dl>
<h2 class="section-header "><a name="Fields"></a>Fields</h2>
<dl class="function">
<dt>
<a name = "on_change_state"></a>
<strong>on_change_state</strong>
</dt>
<dd>
On change state callback(self, state)
<ul>
<li><span class="parameter">on_change_state</span>
<span class="types"><span class="type">druid_event</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "node"></a>
<strong>node</strong>
</dt>
<dd>
Visual node
<ul>
<li><span class="parameter">node</span>
<span class="types"><a class="type" href="../modules/Checkbox.html#node">node</a></span>
</li>
</ul>
</dd>
<dt>
<a name = "click_node"></a>
<strong>click_node</strong>
</dt>
<dd>
Button trigger node
<ul>
<li><span class="parameter">click_node</span>
<span class="types"><a class="type" href="../modules/Checkbox.html#node">node</a></span>
(<em>default</em> node)
</li>
</ul>
</dd>
<dt>
<a name = "button"></a>
<strong>button</strong>
</dt>
<dd>
Button component from click_node
<ul>
<li><span class="parameter">button</span>
<span class="types"><span class="type">Button</span></span>
</li>
</ul>
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View File

@ -33,83 +33,71 @@
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Tables">Tables</a></li>
<li><a href="#Fields">Fields</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/druid.back_handler.html">druid.back_handler</a></li>
<li><a href="../modules/druid.blocker.html">druid.blocker</a></li>
<li><a href="../modules/druid.button.html">druid.button</a></li>
<li><a href="../modules/druid.drag.html">druid.drag</a></li>
<li><a href="../modules/druid.hover.html">druid.hover</a></li>
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
<li><a href="../modules/druid.static_grid.html">druid.static_grid</a></li>
<li><a href="../modules/druid.swipe.html">druid.swipe</a></li>
<li><a href="../modules/druid.text.html">druid.text</a></li>
<li><a href="../modules/component.html">component</a></li>
<li><a href="../modules/BackHandler.html">BackHandler</a></li>
<li><a href="../modules/Blocker.html">Blocker</a></li>
<li><a href="../modules/Button.html">Button</a></li>
<li><a href="../modules/Drag.html">Drag</a></li>
<li><a href="../modules/Hover.html">Hover</a></li>
<li><a href="../modules/Scroll.html">Scroll</a></li>
<li><a href="../modules/StaticGrid.html">StaticGrid</a></li>
<li><a href="../modules/Swipe.html">Swipe</a></li>
<li><a href="../modules/Text.html">Text</a></li>
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/druid_event.html">druid_event</a></li>
<li><a href="../modules/druid.checkbox.html">druid.checkbox</a></li>
<li><strong>druid.checkbox_group</strong></li>
<li><a href="../modules/druid.dynamic_grid.html">druid.dynamic_grid</a></li>
<li><a href="../modules/druid.input.html">druid.input</a></li>
<li><a href="../modules/druid.lang_text.html">druid.lang_text</a></li>
<li><a href="../modules/druid.progress.html">druid.progress</a></li>
<li><a href="../modules/druid.radio_group.html">druid.radio_group</a></li>
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
<li><a href="../modules/DruidEvent.html">DruidEvent</a></li>
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
<li><strong>CheckboxGroup</strong></li>
<li><a href="../modules/DataList.html">DataList</a></li>
<li><a href="../modules/DynamicGrid.html">DynamicGrid</a></li>
<li><a href="../modules/Input.html">Input</a></li>
<li><a href="../modules/LangText.html">LangText</a></li>
<li><a href="../modules/Progress.html">Progress</a></li>
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
<li><a href="../modules/Slider.html">Slider</a></li>
<li><a href="../modules/Timer.html">Timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/01-components.md.html">01-components</a></li>
<li><a href="../topics/02-creating_custom_components.md.html">Creating custom components</a></li>
<li><a href="../topics/03-styles.md.html">Styles</a></li>
<li><a href="../topics/04-druid_assets.md.html">Druid assets</a></li>
<li><a href="../topics/05-examples.md.html">Examples</a></li>
<li><a href="../topics/changelog.md.html">Druid 0.3.0:</a></li>
<li><a href="../topics/faq.md.html">faq</a></li>
<li><a href="../topics/README.md.html">README</a></li>
<li><a href="../modules/DruidInstance.html">DruidInstance</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>druid.checkbox_group</code></h1>
<h1>Module <code>CheckboxGroup</code></h1>
<p>Checkbox group module</p>
<p>
</p>
<p></p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#init">init(node, callback[, click=node])</a></td>
<td class="name" nowrap><a href="#init">init(self, nodes, callback[, click_nodes=node])</a></td>
<td class="summary">Component init function</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_state">set_state(indexes)</a></td>
<td class="name" nowrap><a href="#set_state">set_state(self, indexes)</a></td>
<td class="summary">Set checkbox group state</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_state">get_state()</a></td>
<td class="name" nowrap><a href="#get_state">get_state(self)</a></td>
<td class="summary">Return checkbox group state</td>
</tr>
</table>
<h2><a href="#Tables">Tables</a></h2>
<h2><a href="#Fields">Fields</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#Events">Events</a></td>
<td class="summary">Component events</td>
<td class="name" nowrap><a href="#on_checkbox_click">on_checkbox_click</a></td>
<td class="summary">On any checkbox click callback(self, index)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Fields">Fields</a></td>
<td class="summary">Component fields</td>
<td class="name" nowrap><a href="#checkboxes">checkboxes</a></td>
<td class="summary">Array of checkbox components</td>
</tr>
</table>
@ -122,7 +110,7 @@
<dl class="function">
<dt>
<a name = "init"></a>
<strong>init(node, callback[, click=node])</strong>
<strong>init(self, nodes, callback[, click_nodes=node])</strong>
</dt>
<dd>
Component init function
@ -130,7 +118,11 @@
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">node</span>
<li><span class="parameter">self</span>
<span class="types"><span class="type">CheckboxGroup</span></span>
</li>
<li><span class="parameter">nodes</span>
<span class="types"><span class="type">node[]</span></span>
Array of gui node
</li>
@ -138,9 +130,9 @@
<span class="types"><span class="type">function</span></span>
Checkbox callback
</li>
<li><span class="parameter">click</span>
<li><span class="parameter">click_nodes</span>
<span class="types"><span class="type">node[]</span></span>
node Array of trigger nodes, by default equals to nodes
Array of trigger nodes, by default equals to nodes
(<em>default</em> node)
</li>
</ul>
@ -152,7 +144,7 @@
</dd>
<dt>
<a name = "set_state"></a>
<strong>set_state(indexes)</strong>
<strong>set_state(self, indexes)</strong>
</dt>
<dd>
Set checkbox group state
@ -160,6 +152,10 @@
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">CheckboxGroup</span></span>
</li>
<li><span class="parameter">indexes</span>
<span class="types"><span class="type">bool[]</span></span>
Array of checkbox state
@ -173,12 +169,19 @@
</dd>
<dt>
<a name = "get_state"></a>
<strong>get_state()</strong>
<strong>get_state(self)</strong>
</dt>
<dd>
Return checkbox group state
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">CheckboxGroup</span></span>
</li>
</ul>
<h3>Returns:</h3>
<ol>
@ -192,22 +195,21 @@
</dd>
</dl>
<h2 class="section-header "><a name="Tables"></a>Tables</h2>
<h2 class="section-header "><a name="Fields"></a>Fields</h2>
<dl class="function">
<dt>
<a name = "Events"></a>
<strong>Events</strong>
<a name = "on_checkbox_click"></a>
<strong>on_checkbox_click</strong>
</dt>
<dd>
Component events
On any checkbox click callback(self, index)
<h3>Fields:</h3>
<ul>
<li><span class="parameter">on_checkbox_click</span>
<span class="types"><span class="type">druid_event</span></span>
On any checkbox click
</li>
</ul>
@ -217,18 +219,17 @@
</dd>
<dt>
<a name = "Fields"></a>
<strong>Fields</strong>
<a name = "checkboxes"></a>
<strong>checkboxes</strong>
</dt>
<dd>
Component fields
Array of checkbox components
<h3>Fields:</h3>
<ul>
<li><span class="parameter">checkboxes</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
Array of checkbox components
</li>
</ul>
@ -244,7 +245,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-09-29 23:46:16 </i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

506
docs/modules/DataList.html Normal file
View File

@ -0,0 +1,506 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Fields">Fields</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/BackHandler.html">BackHandler</a></li>
<li><a href="../modules/Blocker.html">Blocker</a></li>
<li><a href="../modules/Button.html">Button</a></li>
<li><a href="../modules/Drag.html">Drag</a></li>
<li><a href="../modules/Hover.html">Hover</a></li>
<li><a href="../modules/Scroll.html">Scroll</a></li>
<li><a href="../modules/StaticGrid.html">StaticGrid</a></li>
<li><a href="../modules/Swipe.html">Swipe</a></li>
<li><a href="../modules/Text.html">Text</a></li>
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/DruidEvent.html">DruidEvent</a></li>
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
<li><strong>DataList</strong></li>
<li><a href="../modules/DynamicGrid.html">DynamicGrid</a></li>
<li><a href="../modules/Input.html">Input</a></li>
<li><a href="../modules/LangText.html">LangText</a></li>
<li><a href="../modules/Progress.html">Progress</a></li>
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
<li><a href="../modules/Slider.html">Slider</a></li>
<li><a href="../modules/Timer.html">Timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/DruidInstance.html">DruidInstance</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>DataList</code></h1>
<p>Component to manage data for huge dataset in scroll.</p>
<p>
It requires Druid Scroll and Druid Grid (Static or Dynamic) components</p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#init">init(self, scroll, grid, create_function)</a></td>
<td class="summary">Data list constructor</td>
</tr>
<tr>
<td class="name" nowrap><a href="#on_remove">on_remove(self)</a></td>
<td class="summary">Druid System on_remove function</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_data">set_data(self, data)</a></td>
<td class="summary">Set new data set for DataList component</td>
</tr>
<tr>
<td class="name" nowrap><a href="#clear">clear(self)</a></td>
<td class="summary">Clear the DataList and refresh visuals</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_first_index">get_first_index(self)</a></td>
<td class="summary">Return first index from data.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_last_index">get_last_index(self)</a></td>
<td class="summary">Return last index from data</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_length">get_length(self)</a></td>
<td class="summary">Return amount of data</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_index">get_index(self, data)</a></td>
<td class="summary">Return index for data value</td>
</tr>
<tr>
<td class="name" nowrap><a href="#scroll_to_index">scroll_to_index(self, index)</a></td>
<td class="summary">Instant scroll to element with passed index</td>
</tr>
</table>
<h2><a href="#Fields">Fields</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#scroll">scroll</a></td>
<td class="summary">The Druid scroll component</td>
</tr>
<tr>
<td class="name" nowrap><a href="#grid">grid</a></td>
<td class="summary">The Druid Grid component</td>
</tr>
<tr>
<td class="name" nowrap><a href="#top_index">top_index</a></td>
<td class="summary">The current visual top data index</td>
</tr>
<tr>
<td class="name" nowrap><a href="#last_index">last_index</a></td>
<td class="summary">The current visual last data index</td>
</tr>
<tr>
<td class="name" nowrap><a href="#scroll_progress">scroll_progress</a></td>
<td class="summary">The current progress of scroll posititon</td>
</tr>
<tr>
<td class="name" nowrap><a href="#on_scroll_progress_change">on_scroll_progress_change</a></td>
<td class="summary">Event triggered when scroll progress is changed; event(self, progress_value)</td>
</tr>
</table>
<br/>
<br/>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "init"></a>
<strong>init(self, scroll, grid, create_function)</strong>
</dt>
<dd>
Data list constructor
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">DataList</span></span>
</li>
<li><span class="parameter">scroll</span>
<span class="types"><span class="type">druid.scroll</span></span>
The Scroll instance for Data List component
</li>
<li><span class="parameter">grid</span>
<span class="types"><span class="type">druid.grid</span></span>
The Grid instance for Data List component
</li>
<li><span class="parameter">create_function</span>
<span class="types"><span class="type">function</span></span>
The create function callback(self, data, index, data_list). Function should return (node, [component])
</li>
</ul>
</dd>
<dt>
<a name = "on_remove"></a>
<strong>on_remove(self)</strong>
</dt>
<dd>
Druid System on_remove function
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">DataList</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "set_data"></a>
<strong>set_data(self, data)</strong>
</dt>
<dd>
Set new data set for DataList component
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">DataList</span></span>
</li>
<li><span class="parameter">data</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
The new data array
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">druid.data_list</span></span>
Current DataList instance
</ol>
</dd>
<dt>
<a name = "clear"></a>
<strong>clear(self)</strong>
</dt>
<dd>
Clear the DataList and refresh visuals
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">DataList</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "get_first_index"></a>
<strong>get_first_index(self)</strong>
</dt>
<dd>
Return first index from data. It not always equals to 1
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">DataList</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "get_last_index"></a>
<strong>get_last_index(self)</strong>
</dt>
<dd>
Return last index from data
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">DataList</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "get_length"></a>
<strong>get_length(self)</strong>
</dt>
<dd>
Return amount of data
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">DataList</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "get_index"></a>
<strong>get_index(self, data)</strong>
</dt>
<dd>
Return index for data value
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">DataList</span></span>
</li>
<li><span class="parameter">data</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
</li>
</ul>
</dd>
<dt>
<a name = "scroll_to_index"></a>
<strong>scroll_to_index(self, index)</strong>
</dt>
<dd>
Instant scroll to element with passed index
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">DataList</span></span>
</li>
<li><span class="parameter">index</span>
<span class="types"><span class="type">number</span></span>
</li>
</ul>
</dd>
</dl>
<h2 class="section-header "><a name="Fields"></a>Fields</h2>
<dl class="function">
<dt>
<a name = "scroll"></a>
<strong>scroll</strong>
</dt>
<dd>
The Druid scroll component
<ul>
<li><span class="parameter">scroll</span>
<span class="types"><span class="type">druid.scroll</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "grid"></a>
<strong>grid</strong>
</dt>
<dd>
The Druid Grid component
<ul>
<li><span class="parameter">grid</span>
<span class="types"><span class="type">druid.static_grid</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "top_index"></a>
<strong>top_index</strong>
</dt>
<dd>
The current visual top data index
<ul>
<li><span class="parameter">top_index</span>
<span class="types"><span class="type">number</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "last_index"></a>
<strong>last_index</strong>
</dt>
<dd>
The current visual last data index
<ul>
<li><span class="parameter">last_index</span>
<span class="types"><span class="type">number</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "scroll_progress"></a>
<strong>scroll_progress</strong>
</dt>
<dd>
The current progress of scroll posititon
<ul>
<li><span class="parameter">scroll_progress</span>
<span class="types"><span class="type">number</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "on_scroll_progress_change"></a>
<strong>on_scroll_progress_change</strong>
</dt>
<dd>
Event triggered when scroll progress is changed; event(self, progress_value)
<ul>
<li><span class="parameter">on_scroll_progress_change</span>
<span class="types"><span class="type">druid_event</span></span>
</li>
</ul>
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

496
docs/modules/Drag.html Normal file
View File

@ -0,0 +1,496 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Tables">Tables</a></li>
<li><a href="#Fields">Fields</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/BackHandler.html">BackHandler</a></li>
<li><a href="../modules/Blocker.html">Blocker</a></li>
<li><a href="../modules/Button.html">Button</a></li>
<li><strong>Drag</strong></li>
<li><a href="../modules/Hover.html">Hover</a></li>
<li><a href="../modules/Scroll.html">Scroll</a></li>
<li><a href="../modules/StaticGrid.html">StaticGrid</a></li>
<li><a href="../modules/Swipe.html">Swipe</a></li>
<li><a href="../modules/Text.html">Text</a></li>
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/DruidEvent.html">DruidEvent</a></li>
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
<li><a href="../modules/DataList.html">DataList</a></li>
<li><a href="../modules/DynamicGrid.html">DynamicGrid</a></li>
<li><a href="../modules/Input.html">Input</a></li>
<li><a href="../modules/LangText.html">LangText</a></li>
<li><a href="../modules/Progress.html">Progress</a></li>
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
<li><a href="../modules/Slider.html">Slider</a></li>
<li><a href="../modules/Timer.html">Timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/DruidInstance.html">DruidInstance</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>Drag</code></h1>
<p>Component to handle drag action on node.</p>
<p>
Drag have correct handling for multitouch and swap
touched while dragging. Drag will be processed even
the cursor is outside of node, if drag is already started</p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#init">init(self, node, on_drag_callback)</a></td>
<td class="summary">Drag component constructor</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_click_zone">set_click_zone(self, node)</a></td>
<td class="summary">Strict drag click area.</td>
</tr>
</table>
<h2><a href="#Tables">Tables</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#style">style</a></td>
<td class="summary">Component style params.</td>
</tr>
</table>
<h2><a href="#Fields">Fields</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#on_touch_start">on_touch_start</a></td>
<td class="summary">Event on touch start callback(self)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#on_touch_end">on_touch_end</a></td>
<td class="summary">Event on touch end callback(self)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#on_drag_start">on_drag_start</a></td>
<td class="summary">Event on drag start callback(self)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#on_drag">on_drag</a></td>
<td class="summary">on drag progress callback(self, dx, dy)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#on_drag_end">on_drag_end</a></td>
<td class="summary">Event on drag end callback(self)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#is_touch">is_touch</a></td>
<td class="summary">Is component now touching</td>
</tr>
<tr>
<td class="name" nowrap><a href="#is_drag">is_drag</a></td>
<td class="summary">Is component now dragging</td>
</tr>
<tr>
<td class="name" nowrap><a href="#can_x">can_x</a></td>
<td class="summary">Is drag component process vertical dragging.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#can_y">can_y</a></td>
<td class="summary">Is drag component process horizontal.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#x">x</a></td>
<td class="summary">Current touch x position</td>
</tr>
<tr>
<td class="name" nowrap><a href="#y">y</a></td>
<td class="summary">Current touch y position</td>
</tr>
<tr>
<td class="name" nowrap><a href="#touch_start_pos">touch_start_pos</a></td>
<td class="summary">Touch start position</td>
</tr>
</table>
<br/>
<br/>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "init"></a>
<strong>init(self, node, on_drag_callback)</strong>
</dt>
<dd>
Drag component constructor
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Drag</span></span>
</li>
<li><span class="parameter">node</span>
<span class="types"><span class="type">node</span></span>
GUI node to detect dragging
</li>
<li><span class="parameter">on_drag_callback</span>
<span class="types"><span class="type">function</span></span>
Callback for on_drag_event(self, dx, dy)
</li>
</ul>
</dd>
<dt>
<a name = "set_click_zone"></a>
<strong>set_click_zone(self, node)</strong>
</dt>
<dd>
Strict drag click area. Useful for
restrict events outside stencil node
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Drag</span></span>
</li>
<li><span class="parameter">node</span>
<span class="types"><span class="type">node</span></span>
Gui node
</li>
</ul>
</dd>
</dl>
<h2 class="section-header "><a name="Tables"></a>Tables</h2>
<dl class="function">
<dt>
<a name = "style"></a>
<strong>style</strong>
</dt>
<dd>
Component style params.
You can override this component styles params in druid styles table
or create your own style
<h3>Fields:</h3>
<ul>
<li><span class="parameter">DRAG_DEADZONE</span>
<span class="types"><span class="type">number</span></span>
Distance in pixels to start dragging
(<em>default</em> 10)
</li>
</ul>
</dd>
</dl>
<h2 class="section-header "><a name="Fields"></a>Fields</h2>
<dl class="function">
<dt>
<a name = "on_touch_start"></a>
<strong>on_touch_start</strong>
</dt>
<dd>
Event on touch start callback(self)
<ul>
<li><span class="parameter">on_touch_start</span>
<span class="types"><span class="type">druid_event</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "on_touch_end"></a>
<strong>on_touch_end</strong>
</dt>
<dd>
Event on touch end callback(self)
<ul>
<li><span class="parameter">on_touch_end</span>
<span class="types"><span class="type">druid_event</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "on_drag_start"></a>
<strong>on_drag_start</strong>
</dt>
<dd>
Event on drag start callback(self)
<ul>
<li><span class="parameter">on_drag_start</span>
<span class="types"><span class="type">druid_event</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "on_drag"></a>
<strong>on_drag</strong>
</dt>
<dd>
on drag progress callback(self, dx, dy)
<ul>
<li><span class="parameter">on_drag</span>
<span class="types"><span class="type">druid_event</span></span>
Event
</li>
</ul>
</dd>
<dt>
<a name = "on_drag_end"></a>
<strong>on_drag_end</strong>
</dt>
<dd>
Event on drag end callback(self)
<ul>
<li><span class="parameter">on_drag_end</span>
<span class="types"><span class="type">druid_event</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "is_touch"></a>
<strong>is_touch</strong>
</dt>
<dd>
Is component now touching
<ul>
<li><span class="parameter">is_touch</span>
<span class="types"><span class="type">bool</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "is_drag"></a>
<strong>is_drag</strong>
</dt>
<dd>
Is component now dragging
<ul>
<li><span class="parameter">is_drag</span>
<span class="types"><span class="type">bool</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "can_x"></a>
<strong>can_x</strong>
</dt>
<dd>
Is drag component process vertical dragging. Default - true
<ul>
<li><span class="parameter">can_x</span>
<span class="types"><span class="type">bool</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "can_y"></a>
<strong>can_y</strong>
</dt>
<dd>
Is drag component process horizontal. Default - true
<ul>
<li><span class="parameter">can_y</span>
<span class="types"><span class="type">bool</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "x"></a>
<strong>x</strong>
</dt>
<dd>
Current touch x position
<ul>
<li><span class="parameter">x</span>
<span class="types"><span class="type">number</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "y"></a>
<strong>y</strong>
</dt>
<dd>
Current touch y position
<ul>
<li><span class="parameter">y</span>
<span class="types"><span class="type">number</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "touch_start_pos"></a>
<strong>touch_start_pos</strong>
</dt>
<dd>
Touch start position
<ul>
<li><span class="parameter">touch_start_pos</span>
<span class="types"><span class="type">vector3</span></span>
</li>
</ul>
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View File

@ -0,0 +1,278 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/BackHandler.html">BackHandler</a></li>
<li><a href="../modules/Blocker.html">Blocker</a></li>
<li><a href="../modules/Button.html">Button</a></li>
<li><a href="../modules/Drag.html">Drag</a></li>
<li><a href="../modules/Hover.html">Hover</a></li>
<li><a href="../modules/Scroll.html">Scroll</a></li>
<li><a href="../modules/StaticGrid.html">StaticGrid</a></li>
<li><a href="../modules/Swipe.html">Swipe</a></li>
<li><a href="../modules/Text.html">Text</a></li>
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><strong>DruidEvent</strong></li>
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
<li><a href="../modules/DataList.html">DataList</a></li>
<li><a href="../modules/DynamicGrid.html">DynamicGrid</a></li>
<li><a href="../modules/Input.html">Input</a></li>
<li><a href="../modules/LangText.html">LangText</a></li>
<li><a href="../modules/Progress.html">Progress</a></li>
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
<li><a href="../modules/Slider.html">Slider</a></li>
<li><a href="../modules/Timer.html">Timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/DruidInstance.html">DruidInstance</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>DruidEvent</code></h1>
<p>Lua event small library</p>
<p></p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#initialize">initialize(self, initial_callback)</a></td>
<td class="summary">Event constructur</td>
</tr>
<tr>
<td class="name" nowrap><a href="#subscribe">subscribe(self, callback, context)</a></td>
<td class="summary">Subscribe callback on event</td>
</tr>
<tr>
<td class="name" nowrap><a href="#unsubscribe">unsubscribe(self, callback, context)</a></td>
<td class="summary">Unsubscribe callback on event</td>
</tr>
<tr>
<td class="name" nowrap><a href="#is_exist">is_exist(self)</a></td>
<td class="summary">Return true, if event have at lease one handler</td>
</tr>
<tr>
<td class="name" nowrap><a href="#clear">clear(self)</a></td>
<td class="summary">Clear the all event handlers</td>
</tr>
<tr>
<td class="name" nowrap><a href="#trigger">trigger(self, ...)</a></td>
<td class="summary">Trigger the event and call all subscribed callbacks</td>
</tr>
</table>
<br/>
<br/>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "initialize"></a>
<strong>initialize(self, initial_callback)</strong>
</dt>
<dd>
Event constructur
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">DruidEvent</span></span>
</li>
<li><span class="parameter">initial_callback</span>
<span class="types"><span class="type">function</span></span>
Subscribe the callback on new event, if callback exist
</li>
</ul>
</dd>
<dt>
<a name = "subscribe"></a>
<strong>subscribe(self, callback, context)</strong>
</dt>
<dd>
Subscribe callback on event
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">DruidEvent</span></span>
</li>
<li><span class="parameter">callback</span>
<span class="types"><span class="type">function</span></span>
Callback itself
</li>
<li><span class="parameter">context</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
Additional context as first param to callback call
</li>
</ul>
</dd>
<dt>
<a name = "unsubscribe"></a>
<strong>unsubscribe(self, callback, context)</strong>
</dt>
<dd>
Unsubscribe callback on event
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">DruidEvent</span></span>
</li>
<li><span class="parameter">callback</span>
<span class="types"><span class="type">function</span></span>
Callback itself
</li>
<li><span class="parameter">context</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
Additional context as first param to callback call
</li>
</ul>
</dd>
<dt>
<a name = "is_exist"></a>
<strong>is_exist(self)</strong>
</dt>
<dd>
Return true, if event have at lease one handler
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">DruidEvent</span></span>
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">bool</span></span>
True if event have handlers
</ol>
</dd>
<dt>
<a name = "clear"></a>
<strong>clear(self)</strong>
</dt>
<dd>
Clear the all event handlers
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">DruidEvent</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "trigger"></a>
<strong>trigger(self, ...)</strong>
</dt>
<dd>
Trigger the event and call all subscribed callbacks
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">DruidEvent</span></span>
</li>
<li><span class="parameter">...</span>
<span class="types"><span class="type">any</span></span>
All event params
</li>
</ul>
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,783 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Fields">Fields</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/BackHandler.html">BackHandler</a></li>
<li><a href="../modules/Blocker.html">Blocker</a></li>
<li><a href="../modules/Button.html">Button</a></li>
<li><a href="../modules/Drag.html">Drag</a></li>
<li><a href="../modules/Hover.html">Hover</a></li>
<li><a href="../modules/Scroll.html">Scroll</a></li>
<li><a href="../modules/StaticGrid.html">StaticGrid</a></li>
<li><a href="../modules/Swipe.html">Swipe</a></li>
<li><a href="../modules/Text.html">Text</a></li>
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/DruidEvent.html">DruidEvent</a></li>
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
<li><a href="../modules/DataList.html">DataList</a></li>
<li><strong>DynamicGrid</strong></li>
<li><a href="../modules/Input.html">Input</a></li>
<li><a href="../modules/LangText.html">LangText</a></li>
<li><a href="../modules/Progress.html">Progress</a></li>
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
<li><a href="../modules/Slider.html">Slider</a></li>
<li><a href="../modules/Timer.html">Timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/DruidInstance.html">DruidInstance</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>DynamicGrid</code></h1>
<p>Component to handle placing components in row</p>
<p></p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#init">init(self, parent)</a></td>
<td class="summary">Component init function</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_pos">get_pos(self, index, node[, origin_index])</a></td>
<td class="summary">Return pos for grid node index</td>
</tr>
<tr>
<td class="name" nowrap><a href="#add">add(self, node[, index[, shift_policy=SHIFT.RIGHT]])</a></td>
<td class="summary">Add new node to the grid</td>
</tr>
<tr>
<td class="name" nowrap><a href="#remove">remove(self, index[, shift_policy=SHIFT.RIGHT])</a></td>
<td class="summary">Remove the item from the grid.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_size">get_size(self, border)</a></td>
<td class="summary">Return grid content size</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_offset">get_offset(self)</a></td>
<td class="summary">Return DynamicGrid offset, where DynamicGrid content starts.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_borders">get_borders(self)</a></td>
<td class="summary">Return grid content borders</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_index_by_node">get_index_by_node(self, node)</a></td>
<td class="summary">Return grid index by node</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_all_pos">get_all_pos(self)</a></td>
<td class="summary">Return array of all node positions</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_position_function">set_position_function(self, callback)</a></td>
<td class="summary">Change set position function for grid nodes.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#clear">clear(self)</a></td>
<td class="summary">Clear grid nodes array.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#_get_side_vector">_get_side_vector(self, side, is_forward)</a></td>
<td class="summary">Return side vector to correct node shifting</td>
</tr>
</table>
<h2><a href="#Fields">Fields</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#on_add_item">on_add_item</a></td>
<td class="summary">On item add callback(self, node, index)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#on_remove_item">on_remove_item</a></td>
<td class="summary">On item remove callback(self, index)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#on_change_items">on_change_items</a></td>
<td class="summary">On item add or remove callback(self, index)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#on_clear">on_clear</a></td>
<td class="summary">On grid clear callback(self)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#on_update_positions">on_update_positions</a></td>
<td class="summary">On update item positions callback(self)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#parent">parent</a></td>
<td class="summary">Parent gui node</td>
</tr>
<tr>
<td class="name" nowrap><a href="#nodes">nodes</a></td>
<td class="summary">List of all grid elements.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#first_index">first_index</a></td>
<td class="summary">The first index of node in grid</td>
</tr>
<tr>
<td class="name" nowrap><a href="#last_index">last_index</a></td>
<td class="summary">The last index of node in grid</td>
</tr>
<tr>
<td class="name" nowrap><a href="#node_size">node_size</a></td>
<td class="summary">Item size</td>
</tr>
<tr>
<td class="name" nowrap><a href="#border">border</a></td>
<td class="summary">The size of item content</td>
</tr>
</table>
<br/>
<br/>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "init"></a>
<strong>init(self, parent)</strong>
</dt>
<dd>
Component init function
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">DynamicGrid</span></span>
</li>
<li><span class="parameter">parent</span>
<span class="types"><span class="type">node</span></span>
The gui node parent, where items will be placed
</li>
</ul>
</dd>
<dt>
<a name = "get_pos"></a>
<strong>get_pos(self, index, node[, origin_index])</strong>
</dt>
<dd>
Return pos for grid node index
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">DynamicGrid</span></span>
</li>
<li><span class="parameter">index</span>
<span class="types"><span class="type">number</span></span>
The grid element index
</li>
<li><span class="parameter">node</span>
<span class="types"><span class="type">node</span></span>
The node to be placed
</li>
<li><span class="parameter">origin_index</span>
<span class="types"><span class="type">number</span></span>
Index of nearby node
(<em>optional</em>)
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">vector3</span></span>
Node position
</ol>
</dd>
<dt>
<a name = "add"></a>
<strong>add(self, node[, index[, shift_policy=SHIFT.RIGHT]])</strong>
</dt>
<dd>
Add new node to the grid
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">DynamicGrid</span></span>
</li>
<li><span class="parameter">node</span>
<span class="types"><span class="type">node</span></span>
Gui node
</li>
<li><span class="parameter">index</span>
<span class="types"><span class="type">number</span></span>
The node position. By default add as last node
(<em>optional</em>)
</li>
<li><span class="parameter">shift_policy</span>
<span class="types"><span class="type">number</span></span>
How shift nodes, if required. See const.SHIFT
(<em>default</em> SHIFT.RIGHT)
</li>
</ul>
</dd>
<dt>
<a name = "remove"></a>
<strong>remove(self, index[, shift_policy=SHIFT.RIGHT])</strong>
</dt>
<dd>
Remove the item from the grid. Note that gui node will be not deleted
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">DynamicGrid</span></span>
</li>
<li><span class="parameter">index</span>
<span class="types"><span class="type">number</span></span>
The grid node index to remove
</li>
<li><span class="parameter">shift_policy</span>
<span class="types"><span class="type">number</span></span>
How shift nodes, if required. See const.SHIFT
(<em>default</em> SHIFT.RIGHT)
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Node</span></span>
The deleted gui node from grid
</ol>
</dd>
<dt>
<a name = "get_size"></a>
<strong>get_size(self, border)</strong>
</dt>
<dd>
Return grid content size
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">DynamicGrid</span></span>
</li>
<li><span class="parameter">border</span>
<span class="types"><span class="type">vector3</span></span>
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">vector3</span></span>
The grid content size
</ol>
</dd>
<dt>
<a name = "get_offset"></a>
<strong>get_offset(self)</strong>
</dt>
<dd>
Return DynamicGrid offset, where DynamicGrid content starts.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">DynamicGrid</span></span>
The DynamicGrid instance
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">vector3</span></span>
The DynamicGrid offset
</ol>
</dd>
<dt>
<a name = "get_borders"></a>
<strong>get_borders(self)</strong>
</dt>
<dd>
Return grid content borders
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">DynamicGrid</span></span>
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">vector3</span></span>
The grid content borders
</ol>
</dd>
<dt>
<a name = "get_index_by_node"></a>
<strong>get_index_by_node(self, node)</strong>
</dt>
<dd>
Return grid index by node
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">DynamicGrid</span></span>
</li>
<li><span class="parameter">node</span>
<span class="types"><span class="type">node</span></span>
The gui node in the grid
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">number</span></span>
The node index
</ol>
</dd>
<dt>
<a name = "get_all_pos"></a>
<strong>get_all_pos(self)</strong>
</dt>
<dd>
Return array of all node positions
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">DynamicGrid</span></span>
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">vector3[]</span></span>
All grid node positions
</ol>
</dd>
<dt>
<a name = "set_position_function"></a>
<strong>set_position_function(self, callback)</strong>
</dt>
<dd>
Change set position function for grid nodes. It will call on
update poses on grid elements. Default: gui.set_position
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">DynamicGrid</span></span>
</li>
<li><span class="parameter">callback</span>
<span class="types"><span class="type">function</span></span>
Function on node set position
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">druid.dynamic_grid</span></span>
Current grid instance
</ol>
</dd>
<dt>
<a name = "clear"></a>
<strong>clear(self)</strong>
</dt>
<dd>
Clear grid nodes array. GUI nodes will be not deleted!
If you want to delete GUI nodes, use dynamic_grid.nodes array before grid:clear
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">DynamicGrid</span></span>
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">druid.dynamic_grid</span></span>
Current grid instance
</ol>
</dd>
<dt>
<a name = "_get_side_vector"></a>
<strong>_get_side_vector(self, side, is_forward)</strong>
</dt>
<dd>
Return side vector to correct node shifting
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
</li>
<li><span class="parameter">side</span>
</li>
<li><span class="parameter">is_forward</span>
</li>
</ul>
</dd>
</dl>
<h2 class="section-header "><a name="Fields"></a>Fields</h2>
<dl class="function">
<dt>
<a name = "on_add_item"></a>
<strong>on_add_item</strong>
</dt>
<dd>
On item add callback(self, node, index)
<ul>
<li><span class="parameter">on_add_item</span>
<span class="types"><span class="type">druid_event</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "on_remove_item"></a>
<strong>on_remove_item</strong>
</dt>
<dd>
On item remove callback(self, index)
<ul>
<li><span class="parameter">on_remove_item</span>
<span class="types"><span class="type">druid_event</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "on_change_items"></a>
<strong>on_change_items</strong>
</dt>
<dd>
On item add or remove callback(self, index)
<ul>
<li><span class="parameter">on_change_items</span>
<span class="types"><span class="type">druid_event</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "on_clear"></a>
<strong>on_clear</strong>
</dt>
<dd>
On grid clear callback(self)
<ul>
<li><span class="parameter">on_clear</span>
<span class="types"><span class="type">druid_event</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "on_update_positions"></a>
<strong>on_update_positions</strong>
</dt>
<dd>
On update item positions callback(self)
<ul>
<li><span class="parameter">on_update_positions</span>
<span class="types"><span class="type">druid_event</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "parent"></a>
<strong>parent</strong>
</dt>
<dd>
Parent gui node
<ul>
<li><span class="parameter">parent</span>
<span class="types"><span class="type">node</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "nodes"></a>
<strong>nodes</strong>
</dt>
<dd>
List of all grid elements. Contains from node, pos, size, pivot
<ul>
<li><span class="parameter">nodes</span>
<span class="types"><span class="type">node[]</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "first_index"></a>
<strong>first_index</strong>
</dt>
<dd>
The first index of node in grid
<ul>
<li><span class="parameter">first_index</span>
<span class="types"><span class="type">number</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "last_index"></a>
<strong>last_index</strong>
</dt>
<dd>
The last index of node in grid
<ul>
<li><span class="parameter">last_index</span>
<span class="types"><span class="type">number</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "node_size"></a>
<strong>node_size</strong>
</dt>
<dd>
Item size
<ul>
<li><span class="parameter">node_size</span>
<span class="types"><span class="type">vector3</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "border"></a>
<strong>border</strong>
</dt>
<dd>
The size of item content
<ul>
<li><span class="parameter">border</span>
<span class="types"><span class="type">vector4</span></span>
</li>
</ul>
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View File

@ -33,91 +33,83 @@
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Tables">Tables</a></li>
<li><a href="#Fields">Fields</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/druid.back_handler.html">druid.back_handler</a></li>
<li><a href="../modules/druid.blocker.html">druid.blocker</a></li>
<li><a href="../modules/druid.button.html">druid.button</a></li>
<li><a href="../modules/druid.drag.html">druid.drag</a></li>
<li><strong>druid.hover</strong></li>
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
<li><a href="../modules/druid.static_grid.html">druid.static_grid</a></li>
<li><a href="../modules/druid.swipe.html">druid.swipe</a></li>
<li><a href="../modules/druid.text.html">druid.text</a></li>
<li><a href="../modules/component.html">component</a></li>
<li><a href="../modules/BackHandler.html">BackHandler</a></li>
<li><a href="../modules/Blocker.html">Blocker</a></li>
<li><a href="../modules/Button.html">Button</a></li>
<li><a href="../modules/Drag.html">Drag</a></li>
<li><strong>Hover</strong></li>
<li><a href="../modules/Scroll.html">Scroll</a></li>
<li><a href="../modules/StaticGrid.html">StaticGrid</a></li>
<li><a href="../modules/Swipe.html">Swipe</a></li>
<li><a href="../modules/Text.html">Text</a></li>
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/druid_event.html">druid_event</a></li>
<li><a href="../modules/druid.checkbox.html">druid.checkbox</a></li>
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
<li><a href="../modules/druid.dynamic_grid.html">druid.dynamic_grid</a></li>
<li><a href="../modules/druid.input.html">druid.input</a></li>
<li><a href="../modules/druid.lang_text.html">druid.lang_text</a></li>
<li><a href="../modules/druid.progress.html">druid.progress</a></li>
<li><a href="../modules/druid.radio_group.html">druid.radio_group</a></li>
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
<li><a href="../modules/DruidEvent.html">DruidEvent</a></li>
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
<li><a href="../modules/DataList.html">DataList</a></li>
<li><a href="../modules/DynamicGrid.html">DynamicGrid</a></li>
<li><a href="../modules/Input.html">Input</a></li>
<li><a href="../modules/LangText.html">LangText</a></li>
<li><a href="../modules/Progress.html">Progress</a></li>
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
<li><a href="../modules/Slider.html">Slider</a></li>
<li><a href="../modules/Timer.html">Timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/01-components.md.html">01-components</a></li>
<li><a href="../topics/02-creating_custom_components.md.html">Creating custom components</a></li>
<li><a href="../topics/03-styles.md.html">Styles</a></li>
<li><a href="../topics/04-druid_assets.md.html">Druid assets</a></li>
<li><a href="../topics/05-examples.md.html">Examples</a></li>
<li><a href="../topics/changelog.md.html">Druid 0.3.0:</a></li>
<li><a href="../topics/faq.md.html">faq</a></li>
<li><a href="../topics/README.md.html">README</a></li>
<li><a href="../modules/DruidInstance.html">DruidInstance</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>druid.hover</code></h1>
<h1>Module <code>Hover</code></h1>
<p>Component to handle hover node interaction</p>
<p>
</p>
<p></p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#init">init(node, on_hover_callback)</a></td>
<td class="name" nowrap><a href="#init">init(self, node, on_hover_callback)</a></td>
<td class="summary">Component init function</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_hover">set_hover(state)</a></td>
<td class="name" nowrap><a href="#set_hover">set_hover(self, state)</a></td>
<td class="summary">Set hover state</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_mouse_hover">set_mouse_hover(state)</a></td>
<td class="name" nowrap><a href="#set_mouse_hover">set_mouse_hover(self, state)</a></td>
<td class="summary">Set mouse hover state</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_click_zone">set_click_zone(zone)</a></td>
<td class="name" nowrap><a href="#set_click_zone">set_click_zone(self, zone)</a></td>
<td class="summary">Strict hover click area.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_enabled">set_enabled(state)</a></td>
<td class="name" nowrap><a href="#set_enabled">set_enabled(self, state)</a></td>
<td class="summary">Set enable state of hover component.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#is_enabled">is_enabled()</a></td>
<td class="name" nowrap><a href="#is_enabled">is_enabled(self)</a></td>
<td class="summary">Return current hover enabled state</td>
</tr>
</table>
<h2><a href="#Tables">Tables</a></h2>
<h2><a href="#Fields">Fields</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#Events">Events</a></td>
<td class="summary">Component events</td>
<td class="name" nowrap><a href="#on_hover">on_hover</a></td>
<td class="summary">On hover callback(self, state)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#on_mouse_hover">on_mouse_hover</a></td>
<td class="summary">On mouse hover callback(self, state)</td>
</tr>
</table>
@ -130,7 +122,7 @@
<dl class="function">
<dt>
<a name = "init"></a>
<strong>init(node, on_hover_callback)</strong>
<strong>init(self, node, on_hover_callback)</strong>
</dt>
<dd>
Component init function
@ -138,6 +130,10 @@
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Hover</span></span>
</li>
<li><span class="parameter">node</span>
<span class="types"><span class="type">node</span></span>
Gui node
@ -155,7 +151,7 @@
</dd>
<dt>
<a name = "set_hover"></a>
<strong>set_hover(state)</strong>
<strong>set_hover(self, state)</strong>
</dt>
<dd>
Set hover state
@ -163,6 +159,10 @@
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Hover</span></span>
</li>
<li><span class="parameter">state</span>
<span class="types"><span class="type">bool</span></span>
The hover state
@ -176,7 +176,7 @@
</dd>
<dt>
<a name = "set_mouse_hover"></a>
<strong>set_mouse_hover(state)</strong>
<strong>set_mouse_hover(self, state)</strong>
</dt>
<dd>
Set mouse hover state
@ -184,6 +184,10 @@
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Hover</span></span>
</li>
<li><span class="parameter">state</span>
<span class="types"><span class="type">bool</span></span>
The mouse hover state
@ -197,7 +201,7 @@
</dd>
<dt>
<a name = "set_click_zone"></a>
<strong>set_click_zone(zone)</strong>
<strong>set_click_zone(self, zone)</strong>
</dt>
<dd>
Strict hover click area. Useful for
@ -206,6 +210,10 @@
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Hover</span></span>
</li>
<li><span class="parameter">zone</span>
<span class="types"><span class="type">node</span></span>
Gui node
@ -219,7 +227,7 @@
</dd>
<dt>
<a name = "set_enabled"></a>
<strong>set_enabled(state)</strong>
<strong>set_enabled(self, state)</strong>
</dt>
<dd>
Set enable state of hover component.
@ -229,6 +237,10 @@
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Hover</span></span>
</li>
<li><span class="parameter">state</span>
<span class="types"><span class="type">bool</span></span>
The hover enabled state
@ -242,12 +254,19 @@
</dd>
<dt>
<a name = "is_enabled"></a>
<strong>is_enabled()</strong>
<strong>is_enabled(self)</strong>
</dt>
<dd>
Return current hover enabled state
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Hover</span></span>
</li>
</ul>
<h3>Returns:</h3>
<ol>
@ -261,26 +280,41 @@
</dd>
</dl>
<h2 class="section-header "><a name="Tables"></a>Tables</h2>
<h2 class="section-header "><a name="Fields"></a>Fields</h2>
<dl class="function">
<dt>
<a name = "Events"></a>
<strong>Events</strong>
<a name = "on_hover"></a>
<strong>on_hover</strong>
</dt>
<dd>
Component events
On hover callback(self, state)
<h3>Fields:</h3>
<ul>
<li><span class="parameter">on_hover</span>
<span class="types"><span class="type">druid_event</span></span>
On hover callback (Touch pressed)
</li>
</ul>
</dd>
<dt>
<a name = "on_mouse_hover"></a>
<strong>on_mouse_hover</strong>
</dt>
<dd>
On mouse hover callback(self, state)
<ul>
<li><span class="parameter">on_mouse_hover</span>
<span class="types"><span class="type">druid_event</span></span>
On mouse hover callback (Touch over without action_id)
</li>
</ul>
@ -296,7 +330,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-09-29 23:46:16 </i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

695
docs/modules/Input.html Normal file
View File

@ -0,0 +1,695 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Tables">Tables</a></li>
<li><a href="#Fields">Fields</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/BackHandler.html">BackHandler</a></li>
<li><a href="../modules/Blocker.html">Blocker</a></li>
<li><a href="../modules/Button.html">Button</a></li>
<li><a href="../modules/Drag.html">Drag</a></li>
<li><a href="../modules/Hover.html">Hover</a></li>
<li><a href="../modules/Scroll.html">Scroll</a></li>
<li><a href="../modules/StaticGrid.html">StaticGrid</a></li>
<li><a href="../modules/Swipe.html">Swipe</a></li>
<li><a href="../modules/Text.html">Text</a></li>
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/DruidEvent.html">DruidEvent</a></li>
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
<li><a href="../modules/DataList.html">DataList</a></li>
<li><a href="../modules/DynamicGrid.html">DynamicGrid</a></li>
<li><strong>Input</strong></li>
<li><a href="../modules/LangText.html">LangText</a></li>
<li><a href="../modules/Progress.html">Progress</a></li>
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
<li><a href="../modules/Slider.html">Slider</a></li>
<li><a href="../modules/Timer.html">Timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/DruidInstance.html">DruidInstance</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>Input</code></h1>
<p>Druid input text component.</p>
<p>
Carry on user text input</p>
<h3>Info:</h3>
<ul>
<li><strong>Author</strong>: Part of code from Britzl gooey input component</li>
</ul>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#set_text">set_text(self, input_text)</a></td>
<td class="summary">Set text for input field</td>
</tr>
<tr>
<td class="name" nowrap><a href="#select">select(self)</a></td>
<td class="summary">Select input field.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#unselect">unselect(self)</a></td>
<td class="summary">Remove selection from input.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_text">get_text(self)</a></td>
<td class="summary">Return current input field text</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_max_length">set_max_length(self, max_length)</a></td>
<td class="summary">Set maximum length for input field.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_allowed_characters">set_allowed_characters(self, characters)</a></td>
<td class="summary">Set allowed charaters for input field.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#reset_changes">reset_changes(self)</a></td>
<td class="summary">Reset current input selection and return previous value</td>
</tr>
</table>
<h2><a href="#Tables">Tables</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#style">style</a></td>
<td class="summary">Component style params.</td>
</tr>
</table>
<h2><a href="#Fields">Fields</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#on_input_select">on_input_select</a></td>
<td class="summary">On input field select callback(self, button_node)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#on_input_unselect">on_input_unselect</a></td>
<td class="summary">On input field unselect callback(self, button_node)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#on_input_text">on_input_text</a></td>
<td class="summary">On input field text change callback(self, input_text)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#on_input_empty">on_input_empty</a></td>
<td class="summary">On input field text change to empty string callback(self, input_text)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#on_input_full">on_input_full</a></td>
<td class="summary">On input field text change to max length string callback(self, input_text)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#on_input_wrong">on_input_wrong</a></td>
<td class="summary">On trying user input with not allowed character callback(self, params, button_instance)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#text">text</a></td>
<td class="summary">Text component</td>
</tr>
<tr>
<td class="name" nowrap><a href="#button">button</a></td>
<td class="summary">Button component</td>
</tr>
<tr>
<td class="name" nowrap><a href="#is_selected">is_selected</a></td>
<td class="summary">Is current input selected now</td>
</tr>
<tr>
<td class="name" nowrap><a href="#is_empty">is_empty</a></td>
<td class="summary">Is current input is empty now</td>
</tr>
<tr>
<td class="name" nowrap><a href="#max_length">max_length</a></td>
<td class="summary">Max length for input text</td>
</tr>
<tr>
<td class="name" nowrap><a href="#allowerd_characters">allowerd_characters</a></td>
<td class="summary">Pattern matching for user input</td>
</tr>
<tr>
<td class="name" nowrap><a href="#keyboard_type">keyboard_type</a></td>
<td class="summary">Gui keyboard type for input field</td>
</tr>
</table>
<br/>
<br/>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "set_text"></a>
<strong>set_text(self, input_text)</strong>
</dt>
<dd>
Set text for input field
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Input</span></span>
</li>
<li><span class="parameter">input_text</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
The string to apply for input field
</li>
</ul>
</dd>
<dt>
<a name = "select"></a>
<strong>select(self)</strong>
</dt>
<dd>
Select input field. It will show the keyboard and trigger on_select events
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Input</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "unselect"></a>
<strong>unselect(self)</strong>
</dt>
<dd>
Remove selection from input. It will hide the keyboard and trigger on_unselect events
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Input</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "get_text"></a>
<strong>get_text(self)</strong>
</dt>
<dd>
Return current input field text
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Input</span></span>
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
The current input field text
</ol>
</dd>
<dt>
<a name = "set_max_length"></a>
<strong>set_max_length(self, max_length)</strong>
</dt>
<dd>
Set maximum length for input field.
Pass nil to make input field unliminted (by default)
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Input</span></span>
</li>
<li><span class="parameter">max_length</span>
<span class="types"><span class="type">number</span></span>
Maximum length for input text field
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">druid.input</span></span>
Current input instance
</ol>
</dd>
<dt>
<a name = "set_allowed_characters"></a>
<strong>set_allowed_characters(self, characters)</strong>
</dt>
<dd>
Set allowed charaters for input field.
See: https://defold.com/ref/stable/string/
ex: [%a%d] for alpha and numeric
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Input</span></span>
</li>
<li><span class="parameter">characters</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
Regulax exp. for validate user input
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">druid.input</span></span>
Current input instance
</ol>
</dd>
<dt>
<a name = "reset_changes"></a>
<strong>reset_changes(self)</strong>
</dt>
<dd>
Reset current input selection and return previous value
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Input</span></span>
</li>
</ul>
</dd>
</dl>
<h2 class="section-header "><a name="Tables"></a>Tables</h2>
<dl class="function">
<dt>
<a name = "style"></a>
<strong>style</strong>
</dt>
<dd>
Component style params.
You can override this component styles params in druid styles table
or create your own style
<h3>Fields:</h3>
<ul>
<li><span class="parameter">IS_LONGTAP_ERASE</span>
<span class="types"><span class="type">bool</span></span>
Is long tap will erase current input data
(<em>default</em> false)
</li>
<li><span class="parameter">MASK_DEFAULT_CHAR</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
Default character mask for password input
(<em>default</em> *)
</li>
<li><span class="parameter">IS_UNSELECT_ON_RESELECT</span>
<span class="types"><span class="type">bool</span></span>
If true, call unselect on select selected input
(<em>default</em> false)
</li>
<li><span class="parameter">on_select</span>
<span class="types"><span class="type">function</span></span>
(self, button_node) Callback on input field selecting
</li>
<li><span class="parameter">on_unselect</span>
<span class="types"><span class="type">function</span></span>
(self, button_node) Callback on input field unselecting
</li>
<li><span class="parameter">on_input_wrong</span>
<span class="types"><span class="type">function</span></span>
(self, button_node) Callback on wrong user input
</li>
<li><span class="parameter">button_style</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
Custom button style for input node
</li>
</ul>
</dd>
</dl>
<h2 class="section-header "><a name="Fields"></a>Fields</h2>
<dl class="function">
<dt>
<a name = "on_input_select"></a>
<strong>on_input_select</strong>
</dt>
<dd>
On input field select callback(self, button_node)
<ul>
<li><span class="parameter">on_input_select</span>
<span class="types"><span class="type">druid_event</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "on_input_unselect"></a>
<strong>on_input_unselect</strong>
</dt>
<dd>
On input field unselect callback(self, button_node)
<ul>
<li><span class="parameter">on_input_unselect</span>
<span class="types"><span class="type">druid_event</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "on_input_text"></a>
<strong>on_input_text</strong>
</dt>
<dd>
On input field text change callback(self, input_text)
<ul>
<li><span class="parameter">on_input_text</span>
<span class="types"><span class="type">druid_event</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "on_input_empty"></a>
<strong>on_input_empty</strong>
</dt>
<dd>
On input field text change to empty string callback(self, input_text)
<ul>
<li><span class="parameter">on_input_empty</span>
<span class="types"><span class="type">druid_event</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "on_input_full"></a>
<strong>on_input_full</strong>
</dt>
<dd>
On input field text change to max length string callback(self, input_text)
<ul>
<li><span class="parameter">on_input_full</span>
<span class="types"><span class="type">druid_event</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "on_input_wrong"></a>
<strong>on_input_wrong</strong>
</dt>
<dd>
On trying user input with not allowed character callback(self, params, button_instance)
<ul>
<li><span class="parameter">on_input_wrong</span>
<span class="types"><span class="type">druid_event</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "text"></a>
<strong>text</strong>
</dt>
<dd>
Text component
<ul>
<li><span class="parameter">text</span>
<span class="types"><span class="type">druid.text</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "button"></a>
<strong>button</strong>
</dt>
<dd>
Button component
<ul>
<li><span class="parameter">button</span>
<span class="types"><span class="type">druid.button</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "is_selected"></a>
<strong>is_selected</strong>
</dt>
<dd>
Is current input selected now
<ul>
<li><span class="parameter">is_selected</span>
<span class="types"><span class="type">bool</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "is_empty"></a>
<strong>is_empty</strong>
</dt>
<dd>
Is current input is empty now
<ul>
<li><span class="parameter">is_empty</span>
<span class="types"><span class="type">bool</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "max_length"></a>
<strong>max_length</strong>
</dt>
<dd>
Max length for input text
<ul>
<li><span class="parameter">max_length</span>
<span class="types"><span class="type">number</span></span>
(<em>optional</em>)
</li>
</ul>
</dd>
<dt>
<a name = "allowerd_characters"></a>
<strong>allowerd_characters</strong>
</dt>
<dd>
Pattern matching for user input
<ul>
<li><span class="parameter">allowerd_characters</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
(<em>optional</em>)
</li>
</ul>
</dd>
<dt>
<a name = "keyboard_type"></a>
<strong>keyboard_type</strong>
</dt>
<dd>
Gui keyboard type for input field
<ul>
<li><span class="parameter">keyboard_type</span>
<span class="types"><span class="type">number</span></span>
</li>
</ul>
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View File

@ -33,84 +33,72 @@
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Tables">Tables</a></li>
<li><a href="#Fields">Fields</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/druid.back_handler.html">druid.back_handler</a></li>
<li><a href="../modules/druid.blocker.html">druid.blocker</a></li>
<li><a href="../modules/druid.button.html">druid.button</a></li>
<li><a href="../modules/druid.drag.html">druid.drag</a></li>
<li><a href="../modules/druid.hover.html">druid.hover</a></li>
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
<li><a href="../modules/druid.static_grid.html">druid.static_grid</a></li>
<li><a href="../modules/druid.swipe.html">druid.swipe</a></li>
<li><a href="../modules/druid.text.html">druid.text</a></li>
<li><a href="../modules/component.html">component</a></li>
<li><a href="../modules/BackHandler.html">BackHandler</a></li>
<li><a href="../modules/Blocker.html">Blocker</a></li>
<li><a href="../modules/Button.html">Button</a></li>
<li><a href="../modules/Drag.html">Drag</a></li>
<li><a href="../modules/Hover.html">Hover</a></li>
<li><a href="../modules/Scroll.html">Scroll</a></li>
<li><a href="../modules/StaticGrid.html">StaticGrid</a></li>
<li><a href="../modules/Swipe.html">Swipe</a></li>
<li><a href="../modules/Text.html">Text</a></li>
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/druid_event.html">druid_event</a></li>
<li><a href="../modules/druid.checkbox.html">druid.checkbox</a></li>
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
<li><a href="../modules/druid.dynamic_grid.html">druid.dynamic_grid</a></li>
<li><a href="../modules/druid.input.html">druid.input</a></li>
<li><strong>druid.lang_text</strong></li>
<li><a href="../modules/druid.progress.html">druid.progress</a></li>
<li><a href="../modules/druid.radio_group.html">druid.radio_group</a></li>
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
<li><a href="../modules/DruidEvent.html">DruidEvent</a></li>
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
<li><a href="../modules/DataList.html">DataList</a></li>
<li><a href="../modules/DynamicGrid.html">DynamicGrid</a></li>
<li><a href="../modules/Input.html">Input</a></li>
<li><strong>LangText</strong></li>
<li><a href="../modules/Progress.html">Progress</a></li>
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
<li><a href="../modules/Slider.html">Slider</a></li>
<li><a href="../modules/Timer.html">Timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/01-components.md.html">01-components</a></li>
<li><a href="../topics/02-creating_custom_components.md.html">Creating custom components</a></li>
<li><a href="../topics/03-styles.md.html">Styles</a></li>
<li><a href="../topics/04-druid_assets.md.html">Druid assets</a></li>
<li><a href="../topics/05-examples.md.html">Examples</a></li>
<li><a href="../topics/changelog.md.html">Druid 0.3.0:</a></li>
<li><a href="../topics/faq.md.html">faq</a></li>
<li><a href="../topics/README.md.html">README</a></li>
<li><a href="../modules/DruidInstance.html">DruidInstance</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>druid.lang_text</code></h1>
<h1>Module <code>LangText</code></h1>
<p>Component to handle all GUI texts
Good working with localization system</p>
<p>
</p>
<p></p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#init">init(node, locale_id, no_adjust)</a></td>
<td class="name" nowrap><a href="#init">init(self, node, locale_id, no_adjust)</a></td>
<td class="summary">Component init function</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_to">set_to(text)</a></td>
<td class="name" nowrap><a href="#set_to">set_to(self, text)</a></td>
<td class="summary">Setup raw text to lang_text component</td>
</tr>
<tr>
<td class="name" nowrap><a href="#translate">translate(locale_id)</a></td>
<td class="name" nowrap><a href="#translate">translate(self, locale_id)</a></td>
<td class="summary">Translate the text by locale_id</td>
</tr>
</table>
<h2><a href="#Tables">Tables</a></h2>
<h2><a href="#Fields">Fields</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#Events">Events</a></td>
<td class="summary">Component events</td>
<td class="name" nowrap><a href="#on_change">on_change</a></td>
<td class="summary">On change text callback</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Fields">Fields</a></td>
<td class="summary">Component fields</td>
<td class="name" nowrap><a href="#text">text</a></td>
<td class="summary">The text component</td>
</tr>
</table>
@ -123,7 +111,7 @@
<dl class="function">
<dt>
<a name = "init"></a>
<strong>init(node, locale_id, no_adjust)</strong>
<strong>init(self, node, locale_id, no_adjust)</strong>
</dt>
<dd>
Component init function
@ -131,13 +119,17 @@
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">LangText</span></span>
</li>
<li><span class="parameter">node</span>
<span class="types"><span class="type">node</span></span>
The text node
</li>
<li><span class="parameter">locale_id</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
Default locale id
Default locale id, optional
</li>
<li><span class="parameter">no_adjust</span>
<span class="types"><span class="type">bool</span></span>
@ -152,7 +144,7 @@
</dd>
<dt>
<a name = "set_to"></a>
<strong>set_to(text)</strong>
<strong>set_to(self, text)</strong>
</dt>
<dd>
Setup raw text to lang_text component
@ -160,6 +152,10 @@
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">LangText</span></span>
</li>
<li><span class="parameter">text</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
Text for text node
@ -173,7 +169,7 @@
</dd>
<dt>
<a name = "translate"></a>
<strong>translate(locale_id)</strong>
<strong>translate(self, locale_id)</strong>
</dt>
<dd>
Translate the text by locale_id
@ -181,6 +177,10 @@
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">LangText</span></span>
</li>
<li><span class="parameter">locale_id</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
Locale id
@ -193,22 +193,21 @@
</dd>
</dl>
<h2 class="section-header "><a name="Tables"></a>Tables</h2>
<h2 class="section-header "><a name="Fields"></a>Fields</h2>
<dl class="function">
<dt>
<a name = "Events"></a>
<strong>Events</strong>
<a name = "on_change"></a>
<strong>on_change</strong>
</dt>
<dd>
Component events
On change text callback
<h3>Fields:</h3>
<ul>
<li><span class="parameter">on_change</span>
<span class="types"><span class="type">druid_event</span></span>
On change text callback
</li>
</ul>
@ -218,18 +217,17 @@
</dd>
<dt>
<a name = "Fields"></a>
<strong>Fields</strong>
<a name = "text"></a>
<strong>text</strong>
</dt>
<dd>
Component fields
The text component
<h3>Fields:</h3>
<ul>
<li><span class="parameter">text</span>
<span class="types"><span class="type">druid.text</span></span>
The text component
<span class="types"><span class="type">Text</span></span>
</li>
</ul>
@ -245,7 +243,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-09-29 23:46:16 </i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@ -34,102 +34,117 @@
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Tables">Tables</a></li>
<li><a href="#Fields">Fields</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/druid.back_handler.html">druid.back_handler</a></li>
<li><a href="../modules/druid.blocker.html">druid.blocker</a></li>
<li><a href="../modules/druid.button.html">druid.button</a></li>
<li><a href="../modules/druid.drag.html">druid.drag</a></li>
<li><a href="../modules/druid.hover.html">druid.hover</a></li>
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
<li><a href="../modules/druid.static_grid.html">druid.static_grid</a></li>
<li><a href="../modules/druid.swipe.html">druid.swipe</a></li>
<li><a href="../modules/druid.text.html">druid.text</a></li>
<li><a href="../modules/component.html">component</a></li>
<li><a href="../modules/BackHandler.html">BackHandler</a></li>
<li><a href="../modules/Blocker.html">Blocker</a></li>
<li><a href="../modules/Button.html">Button</a></li>
<li><a href="../modules/Drag.html">Drag</a></li>
<li><a href="../modules/Hover.html">Hover</a></li>
<li><a href="../modules/Scroll.html">Scroll</a></li>
<li><a href="../modules/StaticGrid.html">StaticGrid</a></li>
<li><a href="../modules/Swipe.html">Swipe</a></li>
<li><a href="../modules/Text.html">Text</a></li>
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/druid_event.html">druid_event</a></li>
<li><a href="../modules/druid.checkbox.html">druid.checkbox</a></li>
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
<li><a href="../modules/druid.dynamic_grid.html">druid.dynamic_grid</a></li>
<li><a href="../modules/druid.input.html">druid.input</a></li>
<li><a href="../modules/druid.lang_text.html">druid.lang_text</a></li>
<li><strong>druid.progress</strong></li>
<li><a href="../modules/druid.radio_group.html">druid.radio_group</a></li>
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
<li><a href="../modules/DruidEvent.html">DruidEvent</a></li>
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
<li><a href="../modules/DataList.html">DataList</a></li>
<li><a href="../modules/DynamicGrid.html">DynamicGrid</a></li>
<li><a href="../modules/Input.html">Input</a></li>
<li><a href="../modules/LangText.html">LangText</a></li>
<li><strong>Progress</strong></li>
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
<li><a href="../modules/Slider.html">Slider</a></li>
<li><a href="../modules/Timer.html">Timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/01-components.md.html">01-components</a></li>
<li><a href="../topics/02-creating_custom_components.md.html">Creating custom components</a></li>
<li><a href="../topics/03-styles.md.html">Styles</a></li>
<li><a href="../topics/04-druid_assets.md.html">Druid assets</a></li>
<li><a href="../topics/05-examples.md.html">Examples</a></li>
<li><a href="../topics/changelog.md.html">Druid 0.3.0:</a></li>
<li><a href="../topics/faq.md.html">faq</a></li>
<li><a href="../topics/README.md.html">README</a></li>
<li><a href="../modules/DruidInstance.html">DruidInstance</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>druid.progress</code></h1>
<h1>Module <code>Progress</code></h1>
<p>Basic progress bar component.</p>
<p> For correct progress bar init it should be in max size from gui</p>
<p>
For correct progress bar init it should be in max size from gui</p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#init">init(node, key[, init_value=1])</a></td>
<td class="name" nowrap><a href="#init">init(self, node, key[, init_value=1])</a></td>
<td class="summary">Component init function</td>
</tr>
<tr>
<td class="name" nowrap><a href="#fill">fill()</a></td>
<td class="name" nowrap><a href="#fill">fill(self)</a></td>
<td class="summary">Fill a progress bar and stop progress animation</td>
</tr>
<tr>
<td class="name" nowrap><a href="#empty">empty()</a></td>
<td class="name" nowrap><a href="#empty">empty(self)</a></td>
<td class="summary">Empty a progress bar</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_to">set_to(to)</a></td>
<td class="name" nowrap><a href="#set_to">set_to(self, to)</a></td>
<td class="summary">Instant fill progress bar to value</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get">get()</a></td>
<td class="name" nowrap><a href="#get">get(self)</a></td>
<td class="summary">Return current progress bar value</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_steps">set_steps(steps, callback)</a></td>
<td class="name" nowrap><a href="#set_steps">set_steps(self, steps, callback)</a></td>
<td class="summary">Set points on progress bar to fire the callback</td>
</tr>
<tr>
<td class="name" nowrap><a href="#to">to(to[, callback])</a></td>
<td class="name" nowrap><a href="#to">to(self, to[, callback])</a></td>
<td class="summary">Start animation of a progress bar</td>
</tr>
</table>
<h2><a href="#Tables">Tables</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#Events">Events</a></td>
<td class="summary">Component events</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Fields">Fields</a></td>
<td class="summary">Component fields</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Style">Style</a></td>
<td class="name" nowrap><a href="#style">style</a></td>
<td class="summary">Component style params.</td>
</tr>
</table>
<h2><a href="#Fields">Fields</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#on_change">on_change</a></td>
<td class="summary">On progress bar change callback(self, new_value)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#node">node</a></td>
<td class="summary">Progress bar fill node</td>
</tr>
<tr>
<td class="name" nowrap><a href="#key">key</a></td>
<td class="summary">The progress bar direction</td>
</tr>
<tr>
<td class="name" nowrap><a href="#scale">scale</a></td>
<td class="summary">Current progress bar scale</td>
</tr>
<tr>
<td class="name" nowrap><a href="#size">size</a></td>
<td class="summary">Current progress bar size</td>
</tr>
<tr>
<td class="name" nowrap><a href="#max_size">max_size</a></td>
<td class="summary">Maximum size of progress bar</td>
</tr>
<tr>
<td class="name" nowrap><a href="#slice">slice</a></td>
<td class="summary">Progress bar slice9 settings</td>
</tr>
</table>
<br/>
<br/>
@ -140,7 +155,7 @@
<dl class="function">
<dt>
<a name = "init"></a>
<strong>init(node, key[, init_value=1])</strong>
<strong>init(self, node, key[, init_value=1])</strong>
</dt>
<dd>
Component init function
@ -148,8 +163,12 @@
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Progress</span></span>
</li>
<li><span class="parameter">node</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a> or <span class="type">node</span></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a> or <a class="type" href="../modules/Progress.html#node">node</a></span>
Progress bar fill node or node name
</li>
<li><span class="parameter">key</span>
@ -170,12 +189,19 @@
</dd>
<dt>
<a name = "fill"></a>
<strong>fill()</strong>
<strong>fill(self)</strong>
</dt>
<dd>
Fill a progress bar and stop progress animation
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Progress</span></span>
</li>
</ul>
@ -184,12 +210,19 @@
</dd>
<dt>
<a name = "empty"></a>
<strong>empty()</strong>
<strong>empty(self)</strong>
</dt>
<dd>
Empty a progress bar
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Progress</span></span>
</li>
</ul>
@ -198,7 +231,7 @@
</dd>
<dt>
<a name = "set_to"></a>
<strong>set_to(to)</strong>
<strong>set_to(self, to)</strong>
</dt>
<dd>
Instant fill progress bar to value
@ -206,6 +239,10 @@
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Progress</span></span>
</li>
<li><span class="parameter">to</span>
<span class="types"><span class="type">number</span></span>
Progress bar value, from 0 to 1
@ -219,12 +256,19 @@
</dd>
<dt>
<a name = "get"></a>
<strong>get()</strong>
<strong>get(self)</strong>
</dt>
<dd>
Return current progress bar value
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Progress</span></span>
</li>
</ul>
@ -233,7 +277,7 @@
</dd>
<dt>
<a name = "set_steps"></a>
<strong>set_steps(steps, callback)</strong>
<strong>set_steps(self, steps, callback)</strong>
</dt>
<dd>
Set points on progress bar to fire the callback
@ -241,6 +285,10 @@
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Progress</span></span>
</li>
<li><span class="parameter">steps</span>
<span class="types"><span class="type">number[]</span></span>
Array of progress bar values
@ -262,7 +310,7 @@
</dd>
<dt>
<a name = "to"></a>
<strong>to(to[, callback])</strong>
<strong>to(self, to[, callback])</strong>
</dt>
<dd>
Start animation of a progress bar
@ -270,6 +318,10 @@
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Progress</span></span>
</li>
<li><span class="parameter">to</span>
<span class="types"><span class="type">number</span></span>
value between 0..1
@ -291,70 +343,8 @@
<dl class="function">
<dt>
<a name = "Events"></a>
<strong>Events</strong>
</dt>
<dd>
Component events
<h3>Fields:</h3>
<ul>
<li><span class="parameter">on_change</span>
<span class="types"><span class="type">druid_event</span></span>
On progress bar change callback
</li>
</ul>
</dd>
<dt>
<a name = "Fields"></a>
<strong>Fields</strong>
</dt>
<dd>
Component fields
<h3>Fields:</h3>
<ul>
<li><span class="parameter">node</span>
<span class="types"><span class="type">node</span></span>
Progress bar fill node
</li>
<li><span class="parameter">key</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
The progress bar direction
</li>
<li><span class="parameter">scale</span>
<span class="types"><span class="type">vector3</span></span>
Current progress bar scale
</li>
<li><span class="parameter">size</span>
<span class="types"><span class="type">vector3</span></span>
Current progress bar size
</li>
<li><span class="parameter">max_size</span>
<span class="types"><span class="type">number</span></span>
Maximum size of progress bar
</li>
<li><span class="parameter">slice</span>
<span class="types"><span class="type">vector4</span></span>
Progress bar slice9 settings
</li>
</ul>
</dd>
<dt>
<a name = "Style"></a>
<strong>Style</strong>
<a name = "style"></a>
<strong>style</strong>
</dt>
<dd>
Component style params.
@ -380,6 +370,150 @@
</dd>
</dl>
<h2 class="section-header "><a name="Fields"></a>Fields</h2>
<dl class="function">
<dt>
<a name = "on_change"></a>
<strong>on_change</strong>
</dt>
<dd>
On progress bar change callback(self, new_value)
<ul>
<li><span class="parameter">on_change</span>
<span class="types"><span class="type">druid_event</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "node"></a>
<strong>node</strong>
</dt>
<dd>
Progress bar fill node
<ul>
<li><span class="parameter">node</span>
<span class="types"><a class="type" href="../modules/Progress.html#node">node</a></span>
</li>
</ul>
</dd>
<dt>
<a name = "key"></a>
<strong>key</strong>
</dt>
<dd>
The progress bar direction
<ul>
<li><span class="parameter">key</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
</li>
</ul>
</dd>
<dt>
<a name = "scale"></a>
<strong>scale</strong>
</dt>
<dd>
Current progress bar scale
<ul>
<li><span class="parameter">scale</span>
<span class="types"><span class="type">vector3</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "size"></a>
<strong>size</strong>
</dt>
<dd>
Current progress bar size
<ul>
<li><span class="parameter">size</span>
<span class="types"><span class="type">vector3</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "max_size"></a>
<strong>max_size</strong>
</dt>
<dd>
Maximum size of progress bar
<ul>
<li><span class="parameter">max_size</span>
<span class="types"><span class="type">number</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "slice"></a>
<strong>slice</strong>
</dt>
<dd>
Progress bar slice9 settings
<ul>
<li><span class="parameter">slice</span>
<span class="types"><span class="type">vector4</span></span>
</li>
</ul>
</dd>
</dl>
@ -388,7 +522,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-09-29 23:46:16 </i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@ -0,0 +1,252 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Fields">Fields</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/BackHandler.html">BackHandler</a></li>
<li><a href="../modules/Blocker.html">Blocker</a></li>
<li><a href="../modules/Button.html">Button</a></li>
<li><a href="../modules/Drag.html">Drag</a></li>
<li><a href="../modules/Hover.html">Hover</a></li>
<li><a href="../modules/Scroll.html">Scroll</a></li>
<li><a href="../modules/StaticGrid.html">StaticGrid</a></li>
<li><a href="../modules/Swipe.html">Swipe</a></li>
<li><a href="../modules/Text.html">Text</a></li>
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/DruidEvent.html">DruidEvent</a></li>
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
<li><a href="../modules/DataList.html">DataList</a></li>
<li><a href="../modules/DynamicGrid.html">DynamicGrid</a></li>
<li><a href="../modules/Input.html">Input</a></li>
<li><a href="../modules/LangText.html">LangText</a></li>
<li><a href="../modules/Progress.html">Progress</a></li>
<li><strong>RadioGroup</strong></li>
<li><a href="../modules/Slider.html">Slider</a></li>
<li><a href="../modules/Timer.html">Timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/DruidInstance.html">DruidInstance</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>RadioGroup</code></h1>
<p>Radio group module</p>
<p></p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#init">init(self, nodes, callback[, click_nodes=node])</a></td>
<td class="summary">Component init function</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_state">set_state(self, index)</a></td>
<td class="summary">Set radio group state</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_state">get_state(self)</a></td>
<td class="summary">Return radio group state</td>
</tr>
</table>
<h2><a href="#Fields">Fields</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#on_radio_click">on_radio_click</a></td>
<td class="summary">On any checkbox click</td>
</tr>
<tr>
<td class="name" nowrap><a href="#checkboxes">checkboxes</a></td>
<td class="summary">Array of checkbox components</td>
</tr>
</table>
<br/>
<br/>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "init"></a>
<strong>init(self, nodes, callback[, click_nodes=node])</strong>
</dt>
<dd>
Component init function
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">RadioGroup</span></span>
</li>
<li><span class="parameter">nodes</span>
<span class="types"><span class="type">node[]</span></span>
Array of gui node
</li>
<li><span class="parameter">callback</span>
<span class="types"><span class="type">function</span></span>
Radio callback
</li>
<li><span class="parameter">click_nodes</span>
<span class="types"><span class="type">node[]</span></span>
Array of trigger nodes, by default equals to nodes
(<em>default</em> node)
</li>
</ul>
</dd>
<dt>
<a name = "set_state"></a>
<strong>set_state(self, index)</strong>
</dt>
<dd>
Set radio group state
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">RadioGroup</span></span>
</li>
<li><span class="parameter">index</span>
<span class="types"><span class="type">number</span></span>
Index in radio group
</li>
</ul>
</dd>
<dt>
<a name = "get_state"></a>
<strong>get_state(self)</strong>
</dt>
<dd>
Return radio group state
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">RadioGroup</span></span>
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">number</span></span>
Index in radio group
</ol>
</dd>
</dl>
<h2 class="section-header "><a name="Fields"></a>Fields</h2>
<dl class="function">
<dt>
<a name = "on_radio_click"></a>
<strong>on_radio_click</strong>
</dt>
<dd>
On any checkbox click
<ul>
<li><span class="parameter">on_radio_click</span>
<span class="types"><span class="type">druid_event</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "checkboxes"></a>
<strong>checkboxes</strong>
</dt>
<dd>
Array of checkbox components
<ul>
<li><span class="parameter">checkboxes</span>
<span class="types"><span class="type">Checkbox[]</span></span>
</li>
</ul>
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

File diff suppressed because it is too large Load Diff

428
docs/modules/Slider.html Normal file
View File

@ -0,0 +1,428 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Fields">Fields</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/BackHandler.html">BackHandler</a></li>
<li><a href="../modules/Blocker.html">Blocker</a></li>
<li><a href="../modules/Button.html">Button</a></li>
<li><a href="../modules/Drag.html">Drag</a></li>
<li><a href="../modules/Hover.html">Hover</a></li>
<li><a href="../modules/Scroll.html">Scroll</a></li>
<li><a href="../modules/StaticGrid.html">StaticGrid</a></li>
<li><a href="../modules/Swipe.html">Swipe</a></li>
<li><a href="../modules/Text.html">Text</a></li>
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/DruidEvent.html">DruidEvent</a></li>
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
<li><a href="../modules/DataList.html">DataList</a></li>
<li><a href="../modules/DynamicGrid.html">DynamicGrid</a></li>
<li><a href="../modules/Input.html">Input</a></li>
<li><a href="../modules/LangText.html">LangText</a></li>
<li><a href="../modules/Progress.html">Progress</a></li>
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
<li><strong>Slider</strong></li>
<li><a href="../modules/Timer.html">Timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/DruidInstance.html">DruidInstance</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>Slider</code></h1>
<p>Druid slider component</p>
<p></p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#init">init(self, node, end_pos[, callback])</a></td>
<td class="summary">Component init function</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set">set(self, value[, is_silent])</a></td>
<td class="summary">Set value for slider</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_steps">set_steps(self, steps)</a></td>
<td class="summary">Set slider steps.</td>
</tr>
</table>
<h2><a href="#Fields">Fields</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#on_change_value">on_change_value</a></td>
<td class="summary">On change value callback(self, value)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#node">node</a></td>
<td class="summary">Slider pin node</td>
</tr>
<tr>
<td class="name" nowrap><a href="#start_pos">start_pos</a></td>
<td class="summary">Start pin node position</td>
</tr>
<tr>
<td class="name" nowrap><a href="#pos">pos</a></td>
<td class="summary">Current pin node position</td>
</tr>
<tr>
<td class="name" nowrap><a href="#target_pos">target_pos</a></td>
<td class="summary">Targer pin node position</td>
</tr>
<tr>
<td class="name" nowrap><a href="#end_pos">end_pos</a></td>
<td class="summary">End pin node position</td>
</tr>
<tr>
<td class="name" nowrap><a href="#dist">dist</a></td>
<td class="summary">Length between start and end position</td>
</tr>
<tr>
<td class="name" nowrap><a href="#is_drag">is_drag</a></td>
<td class="summary">Current drag state</td>
</tr>
<tr>
<td class="name" nowrap><a href="#value">value</a></td>
<td class="summary">Current slider value</td>
</tr>
</table>
<br/>
<br/>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "init"></a>
<strong>init(self, node, end_pos[, callback])</strong>
</dt>
<dd>
Component init function
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Slider</span></span>
</li>
<li><span class="parameter">node</span>
<span class="types"><a class="type" href="../modules/Slider.html#node">node</a></span>
Gui pin node
</li>
<li><span class="parameter">end_pos</span>
<span class="types"><span class="type">vector3</span></span>
The end position of slider
</li>
<li><span class="parameter">callback</span>
<span class="types"><span class="type">function</span></span>
On slider change callback
(<em>optional</em>)
</li>
</ul>
</dd>
<dt>
<a name = "set"></a>
<strong>set(self, value[, is_silent])</strong>
</dt>
<dd>
Set value for slider
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Slider</span></span>
</li>
<li><span class="parameter">value</span>
<span class="types"><span class="type">number</span></span>
Value from 0 to 1
</li>
<li><span class="parameter">is_silent</span>
<span class="types"><span class="type">bool</span></span>
Don't trigger event if true
(<em>optional</em>)
</li>
</ul>
</dd>
<dt>
<a name = "set_steps"></a>
<strong>set_steps(self, steps)</strong>
</dt>
<dd>
Set slider steps. Pin node will
apply closest step position
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Slider</span></span>
</li>
<li><span class="parameter">steps</span>
<span class="types"><span class="type">number[]</span></span>
Array of steps
</li>
</ul>
<h3>Usage:</h3>
<ul>
<pre class="example">slider:set_steps({<span class="number">0</span>, <span class="number">0.2</span>, <span class="number">0.6</span>, <span class="number">1</span>})</pre>
</ul>
</dd>
</dl>
<h2 class="section-header "><a name="Fields"></a>Fields</h2>
<dl class="function">
<dt>
<a name = "on_change_value"></a>
<strong>on_change_value</strong>
</dt>
<dd>
On change value callback(self, value)
<ul>
<li><span class="parameter">on_change_value</span>
<span class="types"><span class="type">druid_event</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "node"></a>
<strong>node</strong>
</dt>
<dd>
Slider pin node
<ul>
<li><span class="parameter">node</span>
<span class="types"><a class="type" href="../modules/Slider.html#node">node</a></span>
</li>
</ul>
</dd>
<dt>
<a name = "start_pos"></a>
<strong>start_pos</strong>
</dt>
<dd>
Start pin node position
<ul>
<li><span class="parameter">start_pos</span>
<span class="types"><span class="type">vector3</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "pos"></a>
<strong>pos</strong>
</dt>
<dd>
Current pin node position
<ul>
<li><span class="parameter">pos</span>
<span class="types"><span class="type">vector3</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "target_pos"></a>
<strong>target_pos</strong>
</dt>
<dd>
Targer pin node position
<ul>
<li><span class="parameter">target_pos</span>
<span class="types"><span class="type">vector3</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "end_pos"></a>
<strong>end_pos</strong>
</dt>
<dd>
End pin node position
<ul>
<li><span class="parameter">end_pos</span>
<span class="types"><span class="type">vector3</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "dist"></a>
<strong>dist</strong>
</dt>
<dd>
Length between start and end position
<ul>
<li><span class="parameter">dist</span>
<span class="types"><span class="type">number</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "is_drag"></a>
<strong>is_drag</strong>
</dt>
<dd>
Current drag state
<ul>
<li><span class="parameter">is_drag</span>
<span class="types"><span class="type">bool</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "value"></a>
<strong>value</strong>
</dt>
<dd>
Current slider value
<ul>
<li><span class="parameter">value</span>
<span class="types"><span class="type">number</span></span>
</li>
</ul>
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View File

@ -0,0 +1,838 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Fields">Fields</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/BackHandler.html">BackHandler</a></li>
<li><a href="../modules/Blocker.html">Blocker</a></li>
<li><a href="../modules/Button.html">Button</a></li>
<li><a href="../modules/Drag.html">Drag</a></li>
<li><a href="../modules/Hover.html">Hover</a></li>
<li><a href="../modules/Scroll.html">Scroll</a></li>
<li><strong>StaticGrid</strong></li>
<li><a href="../modules/Swipe.html">Swipe</a></li>
<li><a href="../modules/Text.html">Text</a></li>
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/DruidEvent.html">DruidEvent</a></li>
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
<li><a href="../modules/DataList.html">DataList</a></li>
<li><a href="../modules/DynamicGrid.html">DynamicGrid</a></li>
<li><a href="../modules/Input.html">Input</a></li>
<li><a href="../modules/LangText.html">LangText</a></li>
<li><a href="../modules/Progress.html">Progress</a></li>
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
<li><a href="../modules/Slider.html">Slider</a></li>
<li><a href="../modules/Timer.html">Timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/DruidInstance.html">DruidInstance</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>StaticGrid</code></h1>
<p>Component to handle placing components by row and columns.</p>
<p>
Grid can anchor your elements, get content size and other</p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#init">init(self, parent, element[, in_row=1])</a></td>
<td class="summary">Component init function</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_pos">get_pos(self, index)</a></td>
<td class="summary">Return pos for grid node index</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_index">get_index(self, pos)</a></td>
<td class="summary">Return index for grid pos</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_index_by_node">get_index_by_node(self, node)</a></td>
<td class="summary">Return grid index by node</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_anchor">set_anchor(self, anchor)</a></td>
<td class="summary">Set grid anchor.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#add">add(self, item[, index[, shift_policy=SHIFT.RIGHT]])</a></td>
<td class="summary">Add new item to the grid</td>
</tr>
<tr>
<td class="name" nowrap><a href="#remove">remove(self, index[, shift_policy=SHIFT.RIGHT])</a></td>
<td class="summary">Remove the item from the grid.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_size">get_size(self)</a></td>
<td class="summary">Return grid content size</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_borders">get_borders(self)</a></td>
<td class="summary">Return grid content borders</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_all_pos">get_all_pos(self)</a></td>
<td class="summary">Return array of all node positions</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_position_function">set_position_function(self, callback)</a></td>
<td class="summary">Change set position function for grid nodes.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#clear">clear(self)</a></td>
<td class="summary">Clear grid nodes array.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_offset">get_offset(self)</a></td>
<td class="summary">Return StaticGrid offset, where StaticGrid content starts.</td>
</tr>
</table>
<h2><a href="#Fields">Fields</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#on_add_item">on_add_item</a></td>
<td class="summary">On item add callback(self, node, index)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#on_remove_item">on_remove_item</a></td>
<td class="summary">On item remove callback(self, index)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#on_change_items">on_change_items</a></td>
<td class="summary">On item add or remove callback(self, index)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#on_clear">on_clear</a></td>
<td class="summary">On grid clear callback(self)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#on_update_positions">on_update_positions</a></td>
<td class="summary">On update item positions callback(self)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#parent">parent</a></td>
<td class="summary">Parent gui node</td>
</tr>
<tr>
<td class="name" nowrap><a href="#nodes">nodes</a></td>
<td class="summary">List of all grid nodes</td>
</tr>
<tr>
<td class="name" nowrap><a href="#first_index">first_index</a></td>
<td class="summary">The first index of node in grid</td>
</tr>
<tr>
<td class="name" nowrap><a href="#last_index">last_index</a></td>
<td class="summary">The last index of node in grid</td>
</tr>
<tr>
<td class="name" nowrap><a href="#anchor">anchor</a></td>
<td class="summary">Item anchor</td>
</tr>
<tr>
<td class="name" nowrap><a href="#node_size">node_size</a></td>
<td class="summary">Item size</td>
</tr>
<tr>
<td class="name" nowrap><a href="#border">border</a></td>
<td class="summary">The size of item content</td>
</tr>
</table>
<br/>
<br/>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "init"></a>
<strong>init(self, parent, element[, in_row=1])</strong>
</dt>
<dd>
Component init function
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">StaticGrid</span></span>
</li>
<li><span class="parameter">parent</span>
<span class="types"><span class="type">node</span></span>
The gui node parent, where items will be placed
</li>
<li><span class="parameter">element</span>
<span class="types"><span class="type">node</span></span>
Element prefab. Need to get it size
</li>
<li><span class="parameter">in_row</span>
<span class="types"><span class="type">number</span></span>
How many nodes in row can be placed
(<em>default</em> 1)
</li>
</ul>
</dd>
<dt>
<a name = "get_pos"></a>
<strong>get_pos(self, index)</strong>
</dt>
<dd>
Return pos for grid node index
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">StaticGrid</span></span>
</li>
<li><span class="parameter">index</span>
<span class="types"><span class="type">number</span></span>
The grid element index
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">vector3</span></span>
Node position
</ol>
</dd>
<dt>
<a name = "get_index"></a>
<strong>get_index(self, pos)</strong>
</dt>
<dd>
Return index for grid pos
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">StaticGrid</span></span>
</li>
<li><span class="parameter">pos</span>
<span class="types"><span class="type">vector3</span></span>
The node position in the grid
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">number</span></span>
The node index
</ol>
</dd>
<dt>
<a name = "get_index_by_node"></a>
<strong>get_index_by_node(self, node)</strong>
</dt>
<dd>
Return grid index by node
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">StaticGrid</span></span>
</li>
<li><span class="parameter">node</span>
<span class="types"><span class="type">node</span></span>
The gui node in the grid
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">number</span></span>
The node index
</ol>
</dd>
<dt>
<a name = "set_anchor"></a>
<strong>set_anchor(self, anchor)</strong>
</dt>
<dd>
Set grid anchor. Default anchor is equal to anchor of grid parent node
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">StaticGrid</span></span>
</li>
<li><span class="parameter">anchor</span>
<span class="types"><span class="type">vector3</span></span>
Anchor
</li>
</ul>
</dd>
<dt>
<a name = "add"></a>
<strong>add(self, item[, index[, shift_policy=SHIFT.RIGHT]])</strong>
</dt>
<dd>
Add new item to the grid
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">StaticGrid</span></span>
</li>
<li><span class="parameter">item</span>
<span class="types"><span class="type">node</span></span>
Gui node
</li>
<li><span class="parameter">index</span>
<span class="types"><span class="type">number</span></span>
The item position. By default add as last item
(<em>optional</em>)
</li>
<li><span class="parameter">shift_policy</span>
<span class="types"><span class="type">number</span></span>
How shift nodes, if required. See const.SHIFT
(<em>default</em> SHIFT.RIGHT)
</li>
</ul>
</dd>
<dt>
<a name = "remove"></a>
<strong>remove(self, index[, shift_policy=SHIFT.RIGHT])</strong>
</dt>
<dd>
Remove the item from the grid. Note that gui node will be not deleted
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">StaticGrid</span></span>
</li>
<li><span class="parameter">index</span>
<span class="types"><span class="type">number</span></span>
The grid node index to remove
</li>
<li><span class="parameter">shift_policy</span>
<span class="types"><span class="type">number</span></span>
How shift nodes, if required. See const.SHIFT
(<em>default</em> SHIFT.RIGHT)
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Node</span></span>
The deleted gui node from grid
</ol>
</dd>
<dt>
<a name = "get_size"></a>
<strong>get_size(self)</strong>
</dt>
<dd>
Return grid content size
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">StaticGrid</span></span>
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">vector3</span></span>
The grid content size
</ol>
</dd>
<dt>
<a name = "get_borders"></a>
<strong>get_borders(self)</strong>
</dt>
<dd>
Return grid content borders
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">StaticGrid</span></span>
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">vector3</span></span>
The grid content borders
</ol>
</dd>
<dt>
<a name = "get_all_pos"></a>
<strong>get_all_pos(self)</strong>
</dt>
<dd>
Return array of all node positions
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">StaticGrid</span></span>
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">vector3[]</span></span>
All grid node positions
</ol>
</dd>
<dt>
<a name = "set_position_function"></a>
<strong>set_position_function(self, callback)</strong>
</dt>
<dd>
Change set position function for grid nodes. It will call on
update poses on grid elements. Default: gui.set_position
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">StaticGrid</span></span>
</li>
<li><span class="parameter">callback</span>
<span class="types"><span class="type">function</span></span>
Function on node set position
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">druid.static_grid</span></span>
Current grid instance
</ol>
</dd>
<dt>
<a name = "clear"></a>
<strong>clear(self)</strong>
</dt>
<dd>
Clear grid nodes array. GUI nodes will be not deleted!
If you want to delete GUI nodes, use static_grid.nodes array before grid:clear
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">StaticGrid</span></span>
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">druid.static_grid</span></span>
Current grid instance
</ol>
</dd>
<dt>
<a name = "get_offset"></a>
<strong>get_offset(self)</strong>
</dt>
<dd>
Return StaticGrid offset, where StaticGrid content starts.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">StaticGrid</span></span>
The StaticGrid instance
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">vector3</span></span>
The StaticGrid offset
</ol>
</dd>
</dl>
<h2 class="section-header "><a name="Fields"></a>Fields</h2>
<dl class="function">
<dt>
<a name = "on_add_item"></a>
<strong>on_add_item</strong>
</dt>
<dd>
On item add callback(self, node, index)
<ul>
<li><span class="parameter">on_add_item</span>
<span class="types"><span class="type">druid_event</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "on_remove_item"></a>
<strong>on_remove_item</strong>
</dt>
<dd>
On item remove callback(self, index)
<ul>
<li><span class="parameter">on_remove_item</span>
<span class="types"><span class="type">druid_event</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "on_change_items"></a>
<strong>on_change_items</strong>
</dt>
<dd>
On item add or remove callback(self, index)
<ul>
<li><span class="parameter">on_change_items</span>
<span class="types"><span class="type">druid_event</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "on_clear"></a>
<strong>on_clear</strong>
</dt>
<dd>
On grid clear callback(self)
<ul>
<li><span class="parameter">on_clear</span>
<span class="types"><span class="type">druid_event</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "on_update_positions"></a>
<strong>on_update_positions</strong>
</dt>
<dd>
On update item positions callback(self)
<ul>
<li><span class="parameter">on_update_positions</span>
<span class="types"><span class="type">druid_event</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "parent"></a>
<strong>parent</strong>
</dt>
<dd>
Parent gui node
<ul>
<li><span class="parameter">parent</span>
<span class="types"><span class="type">node</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "nodes"></a>
<strong>nodes</strong>
</dt>
<dd>
List of all grid nodes
<ul>
<li><span class="parameter">nodes</span>
<span class="types"><span class="type">node[]</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "first_index"></a>
<strong>first_index</strong>
</dt>
<dd>
The first index of node in grid
<ul>
<li><span class="parameter">first_index</span>
<span class="types"><span class="type">number</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "last_index"></a>
<strong>last_index</strong>
</dt>
<dd>
The last index of node in grid
<ul>
<li><span class="parameter">last_index</span>
<span class="types"><span class="type">number</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "anchor"></a>
<strong>anchor</strong>
</dt>
<dd>
Item anchor
<ul>
<li><span class="parameter">anchor</span>
<span class="types"><span class="type">vector3</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "node_size"></a>
<strong>node_size</strong>
</dt>
<dd>
Item size
<ul>
<li><span class="parameter">node_size</span>
<span class="types"><span class="type">vector3</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "border"></a>
<strong>border</strong>
</dt>
<dd>
The size of item content
<ul>
<li><span class="parameter">border</span>
<span class="types"><span class="type">vector4</span></span>
</li>
</ul>
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View File

@ -34,83 +34,82 @@
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Tables">Tables</a></li>
<li><a href="#Fields">Fields</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/druid.back_handler.html">druid.back_handler</a></li>
<li><a href="../modules/druid.blocker.html">druid.blocker</a></li>
<li><a href="../modules/druid.button.html">druid.button</a></li>
<li><a href="../modules/druid.drag.html">druid.drag</a></li>
<li><a href="../modules/druid.hover.html">druid.hover</a></li>
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
<li><a href="../modules/druid.static_grid.html">druid.static_grid</a></li>
<li><strong>druid.swipe</strong></li>
<li><a href="../modules/druid.text.html">druid.text</a></li>
<li><a href="../modules/component.html">component</a></li>
<li><a href="../modules/BackHandler.html">BackHandler</a></li>
<li><a href="../modules/Blocker.html">Blocker</a></li>
<li><a href="../modules/Button.html">Button</a></li>
<li><a href="../modules/Drag.html">Drag</a></li>
<li><a href="../modules/Hover.html">Hover</a></li>
<li><a href="../modules/Scroll.html">Scroll</a></li>
<li><a href="../modules/StaticGrid.html">StaticGrid</a></li>
<li><strong>Swipe</strong></li>
<li><a href="../modules/Text.html">Text</a></li>
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/druid_event.html">druid_event</a></li>
<li><a href="../modules/druid.checkbox.html">druid.checkbox</a></li>
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
<li><a href="../modules/druid.dynamic_grid.html">druid.dynamic_grid</a></li>
<li><a href="../modules/druid.input.html">druid.input</a></li>
<li><a href="../modules/druid.lang_text.html">druid.lang_text</a></li>
<li><a href="../modules/druid.progress.html">druid.progress</a></li>
<li><a href="../modules/druid.radio_group.html">druid.radio_group</a></li>
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
<li><a href="../modules/DruidEvent.html">DruidEvent</a></li>
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
<li><a href="../modules/DataList.html">DataList</a></li>
<li><a href="../modules/DynamicGrid.html">DynamicGrid</a></li>
<li><a href="../modules/Input.html">Input</a></li>
<li><a href="../modules/LangText.html">LangText</a></li>
<li><a href="../modules/Progress.html">Progress</a></li>
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
<li><a href="../modules/Slider.html">Slider</a></li>
<li><a href="../modules/Timer.html">Timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/01-components.md.html">01-components</a></li>
<li><a href="../topics/02-creating_custom_components.md.html">Creating custom components</a></li>
<li><a href="../topics/03-styles.md.html">Styles</a></li>
<li><a href="../topics/04-druid_assets.md.html">Druid assets</a></li>
<li><a href="../topics/05-examples.md.html">Examples</a></li>
<li><a href="../topics/changelog.md.html">Druid 0.3.0:</a></li>
<li><a href="../topics/faq.md.html">faq</a></li>
<li><a href="../topics/README.md.html">README</a></li>
<li><a href="../modules/DruidInstance.html">DruidInstance</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>druid.swipe</code></h1>
<h1>Module <code>Swipe</code></h1>
<p>Component to handle swipe gestures on node.</p>
<p> Swipe will be triggered, if swipe was started and
<p>
Swipe will be triggered, if swipe was started and
ended on one node</p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#init">init(node, on_swipe_callback)</a></td>
<td class="name" nowrap><a href="#init">init(self, node, on_swipe_callback)</a></td>
<td class="summary">Component init function</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_click_zone">set_click_zone(zone)</a></td>
<td class="name" nowrap><a href="#set_click_zone">set_click_zone(self, zone)</a></td>
<td class="summary">Strict swipe click area.</td>
</tr>
</table>
<h2><a href="#Tables">Tables</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#Fields">Fields</a></td>
<td class="summary">Components fields</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Events">Events</a></td>
<td class="summary">Component events</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Style">Style</a></td>
<td class="name" nowrap><a href="#style">style</a></td>
<td class="summary">Component style params.</td>
</tr>
</table>
<h2><a href="#Fields">Fields</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#node">node</a></td>
<td class="summary">Swipe node</td>
</tr>
<tr>
<td class="name" nowrap><a href="#click_zone">click_zone</a></td>
<td class="summary">Restriction zone</td>
</tr>
<tr>
<td class="name" nowrap><a href="#on_swipe">on_swipe</a></td>
<td class="summary">Trigger on swipe event(self, swipe_side, dist, delta_time</td>
</tr>
</table>
<br/>
<br/>
@ -121,7 +120,7 @@
<dl class="function">
<dt>
<a name = "init"></a>
<strong>init(node, on_swipe_callback)</strong>
<strong>init(self, node, on_swipe_callback)</strong>
</dt>
<dd>
Component init function
@ -129,13 +128,17 @@
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Swipe</span></span>
</li>
<li><span class="parameter">node</span>
<span class="types"><span class="type">node</span></span>
<span class="types"><a class="type" href="../modules/Swipe.html#node">node</a></span>
Gui node
</li>
<li><span class="parameter">on_swipe_callback</span>
<span class="types"><span class="type">function</span></span>
Swipe callback for on<em>swipe</em>end event
Swipe callback for on_swipe_end event
</li>
</ul>
@ -146,7 +149,7 @@
</dd>
<dt>
<a name = "set_click_zone"></a>
<strong>set_click_zone(zone)</strong>
<strong>set_click_zone(self, zone)</strong>
</dt>
<dd>
Strict swipe click area. Useful for
@ -155,8 +158,12 @@
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Swipe</span></span>
</li>
<li><span class="parameter">zone</span>
<span class="types"><span class="type">node</span></span>
<span class="types"><a class="type" href="../modules/Swipe.html#node">node</a></span>
Gui node
</li>
</ul>
@ -171,55 +178,8 @@
<dl class="function">
<dt>
<a name = "Fields"></a>
<strong>Fields</strong>
</dt>
<dd>
Components fields
<h3>Fields:</h3>
<ul>
<li><span class="parameter">node</span>
<span class="types"><span class="type">node</span></span>
Swipe node
</li>
<li><span class="parameter">click_zone</span>
<span class="types"><span class="type">node</span></span>
Restriction zone
(<em>optional</em>)
</li>
</ul>
</dd>
<dt>
<a name = "Events"></a>
<strong>Events</strong>
</dt>
<dd>
Component events
<h3>Fields:</h3>
<ul>
<li><span class="parameter">on_swipe</span>
<span class="types"><span class="type">druid_event</span></span>
Trigger on swipe event
</li>
</ul>
</dd>
<dt>
<a name = "Style"></a>
<strong>Style</strong>
<a name = "style"></a>
<strong>style</strong>
</dt>
<dd>
Component style params.
@ -250,6 +210,71 @@
</dd>
</dl>
<h2 class="section-header "><a name="Fields"></a>Fields</h2>
<dl class="function">
<dt>
<a name = "node"></a>
<strong>node</strong>
</dt>
<dd>
Swipe node
<ul>
<li><span class="parameter">node</span>
<span class="types"><a class="type" href="../modules/Swipe.html#node">node</a></span>
</li>
</ul>
</dd>
<dt>
<a name = "click_zone"></a>
<strong>click_zone</strong>
</dt>
<dd>
Restriction zone
<ul>
<li><span class="parameter">click_zone</span>
<span class="types"><a class="type" href="../modules/Swipe.html#node">node</a></span>
(<em>optional</em>)
</li>
</ul>
</dd>
<dt>
<a name = "on_swipe"></a>
<strong>on_swipe</strong>
</dt>
<dd>
Trigger on swipe event(self, swipe_side, dist, delta_time
<ul>
<li><span class="parameter">on_swipe</span>
<span class="types"><span class="type">druid_event</span></span>
)
</li>
</ul>
</dd>
</dl>
@ -258,7 +283,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-09-29 23:46:16 </i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

618
docs/modules/Text.html Normal file
View File

@ -0,0 +1,618 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Fields">Fields</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/BackHandler.html">BackHandler</a></li>
<li><a href="../modules/Blocker.html">Blocker</a></li>
<li><a href="../modules/Button.html">Button</a></li>
<li><a href="../modules/Drag.html">Drag</a></li>
<li><a href="../modules/Hover.html">Hover</a></li>
<li><a href="../modules/Scroll.html">Scroll</a></li>
<li><a href="../modules/StaticGrid.html">StaticGrid</a></li>
<li><a href="../modules/Swipe.html">Swipe</a></li>
<li><strong>Text</strong></li>
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/DruidEvent.html">DruidEvent</a></li>
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
<li><a href="../modules/DataList.html">DataList</a></li>
<li><a href="../modules/DynamicGrid.html">DynamicGrid</a></li>
<li><a href="../modules/Input.html">Input</a></li>
<li><a href="../modules/LangText.html">LangText</a></li>
<li><a href="../modules/Progress.html">Progress</a></li>
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
<li><a href="../modules/Slider.html">Slider</a></li>
<li><a href="../modules/Timer.html">Timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/DruidInstance.html">DruidInstance</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>Text</code></h1>
<p>Component to handle all GUI texts.</p>
<p>
Druid text can adjust itself for text node size
Text will never will be outside of his text size (even multiline)</p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#init">init(self, node[, value[, no_adjust]])</a></td>
<td class="summary">Component init function</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_text_width">get_text_width(self[, text])</a></td>
<td class="summary">Calculate text width with font with respect to trailing space</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_to">set_to(self, set_to)</a></td>
<td class="summary">Set text to text field</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_color">set_color(self, color)</a></td>
<td class="summary">Set color</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_alpha">set_alpha(self, alpha)</a></td>
<td class="summary">Set alpha</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_scale">set_scale(self, scale)</a></td>
<td class="summary">Set scale</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_pivot">set_pivot(self, pivot)</a></td>
<td class="summary">Set text pivot.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#is_multiline">is_multiline(self)</a></td>
<td class="summary">Return true, if text with line break</td>
</tr>
</table>
<h2><a href="#Fields">Fields</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#on_set_text">on_set_text</a></td>
<td class="summary">On set text callback(self, text)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#on_update_text_scale">on_update_text_scale</a></td>
<td class="summary">On adjust text size callback(self, new_scale)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#on_set_pivot">on_set_pivot</a></td>
<td class="summary">On change pivot callback(self, pivot)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#node">node</a></td>
<td class="summary">Text node</td>
</tr>
<tr>
<td class="name" nowrap><a href="#pos">pos</a></td>
<td class="summary">Current text position</td>
</tr>
<tr>
<td class="name" nowrap><a href="#start_scale">start_scale</a></td>
<td class="summary">Initial text node scale</td>
</tr>
<tr>
<td class="name" nowrap><a href="#scale">scale</a></td>
<td class="summary">Current text node scale</td>
</tr>
<tr>
<td class="name" nowrap><a href="#start_size">start_size</a></td>
<td class="summary">Initial text node size</td>
</tr>
<tr>
<td class="name" nowrap><a href="#text_area">text_area</a></td>
<td class="summary">Current text node available are</td>
</tr>
<tr>
<td class="name" nowrap><a href="#is_no_adjust">is_no_adjust</a></td>
<td class="summary">Current text size adjust settings</td>
</tr>
<tr>
<td class="name" nowrap><a href="#color">color</a></td>
<td class="summary">Current text color</td>
</tr>
</table>
<br/>
<br/>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "init"></a>
<strong>init(self, node[, value[, no_adjust]])</strong>
</dt>
<dd>
Component init function
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Text</span></span>
</li>
<li><span class="parameter">node</span>
<span class="types"><a class="type" href="../modules/Text.html#node">node</a></span>
Gui text node
</li>
<li><span class="parameter">value</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
Initial text. Default value is node text from GUI scene.
(<em>optional</em>)
</li>
<li><span class="parameter">no_adjust</span>
<span class="types"><span class="type">bool</span></span>
If true, text will be not auto-adjust size
(<em>optional</em>)
</li>
</ul>
</dd>
<dt>
<a name = "get_text_width"></a>
<strong>get_text_width(self[, text])</strong>
</dt>
<dd>
Calculate text width with font with respect to trailing space
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Text</span></span>
</li>
<li><span class="parameter">text</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
(<em>optional</em>)
</li>
</ul>
</dd>
<dt>
<a name = "set_to"></a>
<strong>set_to(self, set_to)</strong>
</dt>
<dd>
Set text to text field
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Text</span></span>
</li>
<li><span class="parameter">set_to</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
Text for node
</li>
</ul>
</dd>
<dt>
<a name = "set_color"></a>
<strong>set_color(self, color)</strong>
</dt>
<dd>
Set color
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Text</span></span>
</li>
<li><span class="parameter">color</span>
<span class="types"><span class="type">vector4</span></span>
Color for node
</li>
</ul>
</dd>
<dt>
<a name = "set_alpha"></a>
<strong>set_alpha(self, alpha)</strong>
</dt>
<dd>
Set alpha
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Text</span></span>
</li>
<li><span class="parameter">alpha</span>
<span class="types"><span class="type">number</span></span>
Alpha for node
</li>
</ul>
</dd>
<dt>
<a name = "set_scale"></a>
<strong>set_scale(self, scale)</strong>
</dt>
<dd>
Set scale
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Text</span></span>
</li>
<li><span class="parameter">scale</span>
<span class="types"><span class="type">vector3</span></span>
Scale for node
</li>
</ul>
</dd>
<dt>
<a name = "set_pivot"></a>
<strong>set_pivot(self, pivot)</strong>
</dt>
<dd>
Set text pivot. Text will re-anchor inside
his text area
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Text</span></span>
</li>
<li><span class="parameter">pivot</span>
<span class="types"><span class="type">gui.pivot</span></span>
Gui pivot constant
</li>
</ul>
</dd>
<dt>
<a name = "is_multiline"></a>
<strong>is_multiline(self)</strong>
</dt>
<dd>
Return true, if text with line break
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Text</span></span>
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">bool</span></span>
Is text node with line break
</ol>
</dd>
</dl>
<h2 class="section-header "><a name="Fields"></a>Fields</h2>
<dl class="function">
<dt>
<a name = "on_set_text"></a>
<strong>on_set_text</strong>
</dt>
<dd>
On set text callback(self, text)
<ul>
<li><span class="parameter">on_set_text</span>
<span class="types"><span class="type">druid_event</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "on_update_text_scale"></a>
<strong>on_update_text_scale</strong>
</dt>
<dd>
On adjust text size callback(self, new_scale)
<ul>
<li><span class="parameter">on_update_text_scale</span>
<span class="types"><span class="type">druid_event</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "on_set_pivot"></a>
<strong>on_set_pivot</strong>
</dt>
<dd>
On change pivot callback(self, pivot)
<ul>
<li><span class="parameter">on_set_pivot</span>
<span class="types"><span class="type">druid_event</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "node"></a>
<strong>node</strong>
</dt>
<dd>
Text node
<ul>
<li><span class="parameter">node</span>
<span class="types"><a class="type" href="../modules/Text.html#node">node</a></span>
</li>
</ul>
</dd>
<dt>
<a name = "pos"></a>
<strong>pos</strong>
</dt>
<dd>
Current text position
<ul>
<li><span class="parameter">pos</span>
<span class="types"><span class="type">vector3</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "start_scale"></a>
<strong>start_scale</strong>
</dt>
<dd>
Initial text node scale
<ul>
<li><span class="parameter">start_scale</span>
<span class="types"><span class="type">vector3</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "scale"></a>
<strong>scale</strong>
</dt>
<dd>
Current text node scale
<ul>
<li><span class="parameter">scale</span>
<span class="types"><span class="type">vector3</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "start_size"></a>
<strong>start_size</strong>
</dt>
<dd>
Initial text node size
<ul>
<li><span class="parameter">start_size</span>
<span class="types"><span class="type">vector3</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "text_area"></a>
<strong>text_area</strong>
</dt>
<dd>
Current text node available are
<ul>
<li><span class="parameter">text_area</span>
<span class="types"><span class="type">vector3</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "is_no_adjust"></a>
<strong>is_no_adjust</strong>
</dt>
<dd>
Current text size adjust settings
<ul>
<li><span class="parameter">is_no_adjust</span>
<span class="types"><span class="type">bool</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "color"></a>
<strong>color</strong>
</dt>
<dd>
Current text color
<ul>
<li><span class="parameter">color</span>
<span class="types"><span class="type">vector3</span></span>
</li>
</ul>
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

410
docs/modules/Timer.html Normal file
View File

@ -0,0 +1,410 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Fields">Fields</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/BackHandler.html">BackHandler</a></li>
<li><a href="../modules/Blocker.html">Blocker</a></li>
<li><a href="../modules/Button.html">Button</a></li>
<li><a href="../modules/Drag.html">Drag</a></li>
<li><a href="../modules/Hover.html">Hover</a></li>
<li><a href="../modules/Scroll.html">Scroll</a></li>
<li><a href="../modules/StaticGrid.html">StaticGrid</a></li>
<li><a href="../modules/Swipe.html">Swipe</a></li>
<li><a href="../modules/Text.html">Text</a></li>
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/DruidEvent.html">DruidEvent</a></li>
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
<li><a href="../modules/DataList.html">DataList</a></li>
<li><a href="../modules/DynamicGrid.html">DynamicGrid</a></li>
<li><a href="../modules/Input.html">Input</a></li>
<li><a href="../modules/LangText.html">LangText</a></li>
<li><a href="../modules/Progress.html">Progress</a></li>
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
<li><a href="../modules/Slider.html">Slider</a></li>
<li><strong>Timer</strong></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/DruidInstance.html">DruidInstance</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>Timer</code></h1>
<p>Component to handle GUI timers.</p>
<p>
Timer updating by game delta time. If game is not focused -
timer will be not updated.</p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#init">init(self, node, seconds_from[, seconds_to=0[, callback]])</a></td>
<td class="summary">Component init function</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_to">set_to(self, set_to)</a></td>
<td class="summary">Set text to text field</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_state">set_state(self, is_on)</a></td>
<td class="summary">Called when update</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_interval">set_interval(self, from, to)</a></td>
<td class="summary">Set time interval</td>
</tr>
</table>
<h2><a href="#Fields">Fields</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#on_tick">on_tick</a></td>
<td class="summary">On timer tick.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#on_set_enabled">on_set_enabled</a></td>
<td class="summary">On timer change enabled state callback(self, is_enabled)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#on_timer_end">on_timer_end</a></td>
<td class="summary">On timer end callback</td>
</tr>
<tr>
<td class="name" nowrap><a href="#node">node</a></td>
<td class="summary">Trigger node</td>
</tr>
<tr>
<td class="name" nowrap><a href="#from">from</a></td>
<td class="summary">Initial timer value</td>
</tr>
<tr>
<td class="name" nowrap><a href="#target">target</a></td>
<td class="summary">Target timer value</td>
</tr>
<tr>
<td class="name" nowrap><a href="#value">value</a></td>
<td class="summary">Current timer value</td>
</tr>
</table>
<br/>
<br/>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "init"></a>
<strong>init(self, node, seconds_from[, seconds_to=0[, callback]])</strong>
</dt>
<dd>
Component init function
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Timer</span></span>
</li>
<li><span class="parameter">node</span>
<span class="types"><a class="type" href="../modules/Timer.html#node">node</a></span>
Gui text node
</li>
<li><span class="parameter">seconds_from</span>
<span class="types"><span class="type">number</span></span>
Start timer value in seconds
</li>
<li><span class="parameter">seconds_to</span>
<span class="types"><span class="type">number</span></span>
End timer value in seconds
(<em>default</em> 0)
</li>
<li><span class="parameter">callback</span>
<span class="types"><span class="type">function</span></span>
Function on timer end
(<em>optional</em>)
</li>
</ul>
</dd>
<dt>
<a name = "set_to"></a>
<strong>set_to(self, set_to)</strong>
</dt>
<dd>
Set text to text field
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Timer</span></span>
</li>
<li><span class="parameter">set_to</span>
<span class="types"><span class="type">number</span></span>
Value in seconds
</li>
</ul>
</dd>
<dt>
<a name = "set_state"></a>
<strong>set_state(self, is_on)</strong>
</dt>
<dd>
Called when update
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Timer</span></span>
</li>
<li><span class="parameter">is_on</span>
<span class="types"><span class="type">bool</span></span>
Timer enable state
</li>
</ul>
</dd>
<dt>
<a name = "set_interval"></a>
<strong>set_interval(self, from, to)</strong>
</dt>
<dd>
Set time interval
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Timer</span></span>
</li>
<li><span class="parameter">from</span>
<span class="types"><span class="type">number</span></span>
Start time in seconds
</li>
<li><span class="parameter">to</span>
<span class="types"><span class="type">number</span></span>
Target time in seconds
</li>
</ul>
</dd>
</dl>
<h2 class="section-header "><a name="Fields"></a>Fields</h2>
<dl class="function">
<dt>
<a name = "on_tick"></a>
<strong>on_tick</strong>
</dt>
<dd>
On timer tick. Fire every second callback(self, value)
<ul>
<li><span class="parameter">on_tick</span>
<span class="types"><span class="type">druid_event</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "on_set_enabled"></a>
<strong>on_set_enabled</strong>
</dt>
<dd>
On timer change enabled state callback(self, is_enabled)
<ul>
<li><span class="parameter">on_set_enabled</span>
<span class="types"><span class="type">druid_event</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "on_timer_end"></a>
<strong>on_timer_end</strong>
</dt>
<dd>
On timer end callback
<ul>
<li><span class="parameter">on_timer_end</span>
<span class="types"><span class="type">druid_event</span></span>
(self, Timer)
</li>
</ul>
</dd>
<dt>
<a name = "node"></a>
<strong>node</strong>
</dt>
<dd>
Trigger node
<ul>
<li><span class="parameter">node</span>
<span class="types"><a class="type" href="../modules/Timer.html#node">node</a></span>
</li>
</ul>
</dd>
<dt>
<a name = "from"></a>
<strong>from</strong>
</dt>
<dd>
Initial timer value
<ul>
<li><span class="parameter">from</span>
<span class="types"><span class="type">number</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "target"></a>
<strong>target</strong>
</dt>
<dd>
Target timer value
<ul>
<li><span class="parameter">target</span>
<span class="types"><span class="type">number</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "value"></a>
<strong>value</strong>
</dt>
<dd>
Current timer value
<ul>
<li><span class="parameter">value</span>
<span class="types"><span class="type">number</span></span>
</li>
</ul>
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View File

@ -1,601 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/druid.back_handler.html">druid.back_handler</a></li>
<li><a href="../modules/druid.blocker.html">druid.blocker</a></li>
<li><a href="../modules/druid.button.html">druid.button</a></li>
<li><a href="../modules/druid.drag.html">druid.drag</a></li>
<li><a href="../modules/druid.hover.html">druid.hover</a></li>
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
<li><a href="../modules/druid.static_grid.html">druid.static_grid</a></li>
<li><a href="../modules/druid.swipe.html">druid.swipe</a></li>
<li><a href="../modules/druid.text.html">druid.text</a></li>
<li><strong>component</strong></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/druid_event.html">druid_event</a></li>
<li><a href="../modules/druid.checkbox.html">druid.checkbox</a></li>
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
<li><a href="../modules/druid.dynamic_grid.html">druid.dynamic_grid</a></li>
<li><a href="../modules/druid.input.html">druid.input</a></li>
<li><a href="../modules/druid.lang_text.html">druid.lang_text</a></li>
<li><a href="../modules/druid.progress.html">druid.progress</a></li>
<li><a href="../modules/druid.radio_group.html">druid.radio_group</a></li>
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/01-components.md.html">01-components</a></li>
<li><a href="../topics/02-creating_custom_components.md.html">Creating custom components</a></li>
<li><a href="../topics/03-styles.md.html">Styles</a></li>
<li><a href="../topics/04-druid_assets.md.html">Druid assets</a></li>
<li><a href="../topics/05-examples.md.html">Examples</a></li>
<li><a href="../topics/changelog.md.html">Druid 0.3.0:</a></li>
<li><a href="../topics/faq.md.html">faq</a></li>
<li><a href="../topics/README.md.html">README</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>component</code></h1>
<p>Basic class for all Druid components.</p>
<p> To create you component, use <a href="../modules/component.html#Component.create">component.create</a></p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#set_style">set_style(style)</a></td>
<td class="summary">Set current component style table.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_template">set_template(template)</a></td>
<td class="summary">Set current component template name</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_nodes">set_nodes(nodes)</a></td>
<td class="summary">Set current component nodes</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_context">get_context()</a></td>
<td class="summary">Get current component context</td>
</tr>
<tr>
<td class="name" nowrap><a href="#increase_input_priority">increase_input_priority()</a></td>
<td class="summary">Increase input priority in current input stack</td>
</tr>
<tr>
<td class="name" nowrap><a href="#reset_input_priority">reset_input_priority()</a></td>
<td class="summary">Reset input priority in current input stack</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_node">get_node(node_or_name)</a></td>
<td class="summary">Get node for component by name.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_druid">get_druid()</a></td>
<td class="summary">Return druid with context of calling component.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_name">get_name()</a></td>
<td class="summary">Return component name</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_input_enabled">set_input_enabled(state)</a></td>
<td class="summary">Set component input state.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_parent_component">get_parent_component()</a></td>
<td class="summary">Return the parent for current component</td>
</tr>
<tr>
<td class="name" nowrap><a href="#setup_component">setup_component(table, table, table)</a></td>
<td class="summary">Setup component context and his style table</td>
</tr>
<tr>
<td class="name" nowrap><a href="#__set_context">__set_context(context)</a></td>
<td class="summary">Set current component context</td>
</tr>
<tr>
<td class="name" nowrap><a href="#__get_interests">__get_interests()</a></td>
<td class="summary">Get current component interests</td>
</tr>
<tr>
<td class="name" nowrap><a href="#__get_template">__get_template()</a></td>
<td class="summary">Get current component template name</td>
</tr>
<tr>
<td class="name" nowrap><a href="#__get_nodes">__get_nodes()</a></td>
<td class="summary">Get current component nodes</td>
</tr>
<tr>
<td class="name" nowrap><a href="#__add_children">__add_children(children)</a></td>
<td class="summary">Add child to component children list</td>
</tr>
<tr>
<td class="name" nowrap><a href="#__remove_children">__remove_children(children)</a></td>
<td class="summary">Remove child from component children list</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Component.create">Component.create(name[, interest={}])</a></td>
<td class="summary">Create new component.</td>
</tr>
</table>
<br/>
<br/>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "set_style"></a>
<strong>set_style(style)</strong>
</dt>
<dd>
Set current component style table.
Invoke <code>on_style_change</code> on component, if exist. Component should handle
their style changing and store all style params
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">style</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
Druid style module
</li>
</ul>
</dd>
<dt>
<a name = "set_template"></a>
<strong>set_template(template)</strong>
</dt>
<dd>
Set current component template name
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">template</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
Component template name
</li>
</ul>
</dd>
<dt>
<a name = "set_nodes"></a>
<strong>set_nodes(nodes)</strong>
</dt>
<dd>
Set current component nodes
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">nodes</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
Component nodes table
</li>
</ul>
</dd>
<dt>
<a name = "get_context"></a>
<strong>get_context()</strong>
</dt>
<dd>
Get current component context
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
Component context
</ol>
</dd>
<dt>
<a name = "increase_input_priority"></a>
<strong>increase_input_priority()</strong>
</dt>
<dd>
Increase input priority in current input stack
</dd>
<dt>
<a name = "reset_input_priority"></a>
<strong>reset_input_priority()</strong>
</dt>
<dd>
Reset input priority in current input stack
</dd>
<dt>
<a name = "get_node"></a>
<strong>get_node(node_or_name)</strong>
</dt>
<dd>
Get node for component by name.
If component has nodes, node<em>or</em>name should be string
It auto pick node by template name or from nodes by clone<em>tree
if they was setup via component:set</em>nodes, component:set_template
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">node_or_name</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a> or <span class="type">node</span></span>
Node name or node itself
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">node</span></span>
Gui node
</ol>
</dd>
<dt>
<a name = "get_druid"></a>
<strong>get_druid()</strong>
</dt>
<dd>
Return druid with context of calling component.
Use it to create component inside of other components.
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Druid</span></span>
Druid instance with component context
</ol>
</dd>
<dt>
<a name = "get_name"></a>
<strong>get_name()</strong>
</dt>
<dd>
Return component name
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
The component name
</ol>
</dd>
<dt>
<a name = "set_input_enabled"></a>
<strong>set_input_enabled(state)</strong>
</dt>
<dd>
Set component input state. By default it enabled
You can disable any input of component by this function
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">state</span>
<span class="types"><span class="type">bool</span></span>
The component input state
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Component</span></span>
Component itself
</ol>
</dd>
<dt>
<a name = "get_parent_component"></a>
<strong>get_parent_component()</strong>
</dt>
<dd>
Return the parent for current component
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Component</span> or <span class="type">nil</span></span>
The druid component instance or nil
</ol>
</dd>
<dt>
<a name = "setup_component"></a>
<strong>setup_component(table, table, table)</strong>
</dt>
<dd>
Setup component context and his style table
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">table</span>
<span class="types"><span class="type">style</span></span>
Druid style module
</li>
<li><span class="parameter">table</span>
<span class="types"><span class="type">style</span></span>
Druid style module
</li>
<li><span class="parameter">table</span>
<span class="types"><span class="type">style</span></span>
Druid style module
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">component</span></span>
Component itself
</ol>
</dd>
<dt>
<a name = "__set_context"></a>
<strong>__set_context(context)</strong>
</dt>
<dd>
Set current component context
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">context</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
Druid context. Usually it is self of script
</li>
</ul>
</dd>
<dt>
<a name = "__get_interests"></a>
<strong>__get_interests()</strong>
</dt>
<dd>
Get current component interests
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
List of component interests
</ol>
</dd>
<dt>
<a name = "__get_template"></a>
<strong>__get_template()</strong>
</dt>
<dd>
Get current component template name
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
Component template name
</ol>
</dd>
<dt>
<a name = "__get_nodes"></a>
<strong>__get_nodes()</strong>
</dt>
<dd>
Get current component nodes
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
Component nodes table
</ol>
</dd>
<dt>
<a name = "__add_children"></a>
<strong>__add_children(children)</strong>
</dt>
<dd>
Add child to component children list
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">children</span>
<span class="types"><span class="type">component</span></span>
The druid component instance
</li>
</ul>
</dd>
<dt>
<a name = "__remove_children"></a>
<strong>__remove_children(children)</strong>
</dt>
<dd>
Remove child from component children list
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">children</span>
<span class="types"><span class="type">component</span></span>
The druid component instance
</li>
</ul>
</dd>
<dt>
<a name = "Component.create"></a>
<strong>Component.create(name[, interest={}])</strong>
</dt>
<dd>
Create new component. It will inheritance from basic
druid component.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">name</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
Component name
</li>
<li><span class="parameter">interest</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
List of component's interest
(<em>default</em> {})
</li>
</ul>
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-09-29 23:46:16 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View File

@ -1,227 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Tables">Tables</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><strong>druid.back_handler</strong></li>
<li><a href="../modules/druid.blocker.html">druid.blocker</a></li>
<li><a href="../modules/druid.button.html">druid.button</a></li>
<li><a href="../modules/druid.drag.html">druid.drag</a></li>
<li><a href="../modules/druid.hover.html">druid.hover</a></li>
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
<li><a href="../modules/druid.static_grid.html">druid.static_grid</a></li>
<li><a href="../modules/druid.swipe.html">druid.swipe</a></li>
<li><a href="../modules/druid.text.html">druid.text</a></li>
<li><a href="../modules/component.html">component</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/druid_event.html">druid_event</a></li>
<li><a href="../modules/druid.checkbox.html">druid.checkbox</a></li>
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
<li><a href="../modules/druid.dynamic_grid.html">druid.dynamic_grid</a></li>
<li><a href="../modules/druid.input.html">druid.input</a></li>
<li><a href="../modules/druid.lang_text.html">druid.lang_text</a></li>
<li><a href="../modules/druid.progress.html">druid.progress</a></li>
<li><a href="../modules/druid.radio_group.html">druid.radio_group</a></li>
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/01-components.md.html">01-components</a></li>
<li><a href="../topics/02-creating_custom_components.md.html">Creating custom components</a></li>
<li><a href="../topics/03-styles.md.html">Styles</a></li>
<li><a href="../topics/04-druid_assets.md.html">Druid assets</a></li>
<li><a href="../topics/05-examples.md.html">Examples</a></li>
<li><a href="../topics/changelog.md.html">Druid 0.3.0:</a></li>
<li><a href="../topics/faq.md.html">faq</a></li>
<li><a href="../topics/README.md.html">README</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>druid.back_handler</code></h1>
<p>Component to handle back key (android, backspace)</p>
<p>
</p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#init">init(callback[, Callback])</a></td>
<td class="summary">Component init function</td>
</tr>
<tr>
<td class="name" nowrap><a href="#on_input">on_input(action_id, action)</a></td>
<td class="summary">Input handler for component</td>
</tr>
</table>
<h2><a href="#Tables">Tables</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#Events">Events</a></td>
<td class="summary">Component events</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Fields">Fields</a></td>
<td class="summary">Component fields</td>
</tr>
</table>
<br/>
<br/>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "init"></a>
<strong>init(callback[, Callback])</strong>
</dt>
<dd>
Component init function
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">callback</span>
<span class="types"><span class="type">callback</span></span>
On back button
</li>
<li><span class="parameter">Callback</span>
<span class="types"><span class="type">params</span></span>
argument
(<em>optional</em>)
</li>
</ul>
</dd>
<dt>
<a name = "on_input"></a>
<strong>on_input(action_id, action)</strong>
</dt>
<dd>
Input handler for component
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">action_id</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
on_input action id
</li>
<li><span class="parameter">action</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
on_input action
</li>
</ul>
</dd>
</dl>
<h2 class="section-header "><a name="Tables"></a>Tables</h2>
<dl class="function">
<dt>
<a name = "Events"></a>
<strong>Events</strong>
</dt>
<dd>
Component events
<h3>Fields:</h3>
<ul>
<li><span class="parameter">on_back</span>
<span class="types"><span class="type">druid_event</span></span>
On back handler callback
</li>
</ul>
</dd>
<dt>
<a name = "Fields"></a>
<strong>Fields</strong>
</dt>
<dd>
Component fields
<h3>Fields:</h3>
<ul>
<li><span class="parameter">params</span>
<span class="types"><span class="type">any</span></span>
Params to click callbacks
</li>
</ul>
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-09-29 23:46:16 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View File

@ -1,246 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Tables">Tables</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/druid.back_handler.html">druid.back_handler</a></li>
<li><strong>druid.blocker</strong></li>
<li><a href="../modules/druid.button.html">druid.button</a></li>
<li><a href="../modules/druid.drag.html">druid.drag</a></li>
<li><a href="../modules/druid.hover.html">druid.hover</a></li>
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
<li><a href="../modules/druid.static_grid.html">druid.static_grid</a></li>
<li><a href="../modules/druid.swipe.html">druid.swipe</a></li>
<li><a href="../modules/druid.text.html">druid.text</a></li>
<li><a href="../modules/component.html">component</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/druid_event.html">druid_event</a></li>
<li><a href="../modules/druid.checkbox.html">druid.checkbox</a></li>
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
<li><a href="../modules/druid.dynamic_grid.html">druid.dynamic_grid</a></li>
<li><a href="../modules/druid.input.html">druid.input</a></li>
<li><a href="../modules/druid.lang_text.html">druid.lang_text</a></li>
<li><a href="../modules/druid.progress.html">druid.progress</a></li>
<li><a href="../modules/druid.radio_group.html">druid.radio_group</a></li>
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/01-components.md.html">01-components</a></li>
<li><a href="../topics/02-creating_custom_components.md.html">Creating custom components</a></li>
<li><a href="../topics/03-styles.md.html">Styles</a></li>
<li><a href="../topics/04-druid_assets.md.html">Druid assets</a></li>
<li><a href="../topics/05-examples.md.html">Examples</a></li>
<li><a href="../topics/changelog.md.html">Druid 0.3.0:</a></li>
<li><a href="../topics/faq.md.html">faq</a></li>
<li><a href="../topics/README.md.html">README</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>druid.blocker</code></h1>
<p>Component to block input on specify zone by node</p>
<p>
</p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#init">init(node)</a></td>
<td class="summary">Component init function</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_enabled">set_enabled(state)</a></td>
<td class="summary">Set enabled blocker component state</td>
</tr>
<tr>
<td class="name" nowrap><a href="#is_enabled">is_enabled()</a></td>
<td class="summary">Return blocked enabled state</td>
</tr>
</table>
<h2><a href="#Tables">Tables</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#Events">Events</a></td>
<td class="summary">Component events</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Fields">Fields</a></td>
<td class="summary">Component fields</td>
</tr>
</table>
<br/>
<br/>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "init"></a>
<strong>init(node)</strong>
</dt>
<dd>
Component init function
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">node</span>
<span class="types"><span class="type">node</span></span>
Gui node
</li>
</ul>
</dd>
<dt>
<a name = "set_enabled"></a>
<strong>set_enabled(state)</strong>
</dt>
<dd>
Set enabled blocker component state
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">state</span>
<span class="types"><span class="type">bool</span></span>
Enabled state
</li>
</ul>
</dd>
<dt>
<a name = "is_enabled"></a>
<strong>is_enabled()</strong>
</dt>
<dd>
Return blocked enabled state
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">bool</span></span>
True, if blocker is enabled
</ol>
</dd>
</dl>
<h2 class="section-header "><a name="Tables"></a>Tables</h2>
<dl class="function">
<dt>
<a name = "Events"></a>
<strong>Events</strong>
</dt>
<dd>
Component events
<h3>Fields:</h3>
<ul>
<li><span class="parameter">on_click</span>
<span class="types"><span class="type">druid_event</span></span>
On release button callback
</li>
<li><span class="parameter">on_enable_change</span>
<span class="types"><span class="type">druid_event</span></span>
On enable/disable callback
</li>
</ul>
</dd>
<dt>
<a name = "Fields"></a>
<strong>Fields</strong>
</dt>
<dd>
Component fields
<h3>Fields:</h3>
<ul>
<li><span class="parameter">node</span>
<span class="types"><span class="type">node</span></span>
Trigger node
</li>
</ul>
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-09-29 23:46:16 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View File

@ -1,291 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Tables">Tables</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/druid.back_handler.html">druid.back_handler</a></li>
<li><a href="../modules/druid.blocker.html">druid.blocker</a></li>
<li><a href="../modules/druid.button.html">druid.button</a></li>
<li><a href="../modules/druid.drag.html">druid.drag</a></li>
<li><a href="../modules/druid.hover.html">druid.hover</a></li>
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
<li><a href="../modules/druid.static_grid.html">druid.static_grid</a></li>
<li><a href="../modules/druid.swipe.html">druid.swipe</a></li>
<li><a href="../modules/druid.text.html">druid.text</a></li>
<li><a href="../modules/component.html">component</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/druid_event.html">druid_event</a></li>
<li><strong>druid.checkbox</strong></li>
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
<li><a href="../modules/druid.dynamic_grid.html">druid.dynamic_grid</a></li>
<li><a href="../modules/druid.input.html">druid.input</a></li>
<li><a href="../modules/druid.lang_text.html">druid.lang_text</a></li>
<li><a href="../modules/druid.progress.html">druid.progress</a></li>
<li><a href="../modules/druid.radio_group.html">druid.radio_group</a></li>
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/01-components.md.html">01-components</a></li>
<li><a href="../topics/02-creating_custom_components.md.html">Creating custom components</a></li>
<li><a href="../topics/03-styles.md.html">Styles</a></li>
<li><a href="../topics/04-druid_assets.md.html">Druid assets</a></li>
<li><a href="../topics/05-examples.md.html">Examples</a></li>
<li><a href="../topics/changelog.md.html">Druid 0.3.0:</a></li>
<li><a href="../topics/faq.md.html">faq</a></li>
<li><a href="../topics/README.md.html">README</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>druid.checkbox</code></h1>
<p>Druid checkbox component</p>
<p>
</p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#init">init(node, callback[, click=node])</a></td>
<td class="summary">Component init function</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_state">set_state(state, is_silent)</a></td>
<td class="summary">Set checkbox state</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_state">get_state()</a></td>
<td class="summary">Return checkbox state</td>
</tr>
</table>
<h2><a href="#Tables">Tables</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#Events">Events</a></td>
<td class="summary">Component events</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Fields">Fields</a></td>
<td class="summary">Component fields</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Style">Style</a></td>
<td class="summary">Component style params.</td>
</tr>
</table>
<br/>
<br/>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "init"></a>
<strong>init(node, callback[, click=node])</strong>
</dt>
<dd>
Component init function
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">node</span>
<span class="types"><span class="type">node</span></span>
Gui node
</li>
<li><span class="parameter">callback</span>
<span class="types"><span class="type">function</span></span>
Checkbox callback
</li>
<li><span class="parameter">click</span>
<span class="types"><span class="type">node</span></span>
node Trigger node, by default equals to node
(<em>default</em> node)
</li>
</ul>
</dd>
<dt>
<a name = "set_state"></a>
<strong>set_state(state, is_silent)</strong>
</dt>
<dd>
Set checkbox state
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">state</span>
<span class="types"><span class="type">bool</span></span>
Checkbox state
</li>
<li><span class="parameter">is_silent</span>
<span class="types"><span class="type">bool</span></span>
Don't trigger on<em>change</em>state if true
</li>
</ul>
</dd>
<dt>
<a name = "get_state"></a>
<strong>get_state()</strong>
</dt>
<dd>
Return checkbox state
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">bool</span></span>
Checkbox state
</ol>
</dd>
</dl>
<h2 class="section-header "><a name="Tables"></a>Tables</h2>
<dl class="function">
<dt>
<a name = "Events"></a>
<strong>Events</strong>
</dt>
<dd>
Component events
<h3>Fields:</h3>
<ul>
<li><span class="parameter">on_change_state</span>
<span class="types"><span class="type">druid_event</span></span>
On change state callback
</li>
</ul>
</dd>
<dt>
<a name = "Fields"></a>
<strong>Fields</strong>
</dt>
<dd>
Component fields
<h3>Fields:</h3>
<ul>
<li><span class="parameter">node</span>
<span class="types"><span class="type">node</span></span>
Visual node
</li>
<li><span class="parameter">click_node</span>
<span class="types"><span class="type">node</span></span>
Button trigger node
(<em>default</em> node)
</li>
<li><span class="parameter">button</span>
<span class="types"><span class="type">druid.button</span></span>
Button component from click_node
</li>
</ul>
</dd>
<dt>
<a name = "Style"></a>
<strong>Style</strong>
</dt>
<dd>
Component style params.
You can override this component styles params in druid styles table
or create your own style
<h3>Fields:</h3>
<ul>
<li><span class="parameter">on_change_state</span>
<span class="types"><span class="type">function</span></span>
(self, node, state)
</li>
</ul>
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-09-29 23:46:16 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View File

@ -1,291 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Tables">Tables</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/druid.back_handler.html">druid.back_handler</a></li>
<li><a href="../modules/druid.blocker.html">druid.blocker</a></li>
<li><a href="../modules/druid.button.html">druid.button</a></li>
<li><strong>druid.drag</strong></li>
<li><a href="../modules/druid.hover.html">druid.hover</a></li>
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
<li><a href="../modules/druid.static_grid.html">druid.static_grid</a></li>
<li><a href="../modules/druid.swipe.html">druid.swipe</a></li>
<li><a href="../modules/druid.text.html">druid.text</a></li>
<li><a href="../modules/component.html">component</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/druid_event.html">druid_event</a></li>
<li><a href="../modules/druid.checkbox.html">druid.checkbox</a></li>
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
<li><a href="../modules/druid.dynamic_grid.html">druid.dynamic_grid</a></li>
<li><a href="../modules/druid.input.html">druid.input</a></li>
<li><a href="../modules/druid.lang_text.html">druid.lang_text</a></li>
<li><a href="../modules/druid.progress.html">druid.progress</a></li>
<li><a href="../modules/druid.radio_group.html">druid.radio_group</a></li>
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/01-components.md.html">01-components</a></li>
<li><a href="../topics/02-creating_custom_components.md.html">Creating custom components</a></li>
<li><a href="../topics/03-styles.md.html">Styles</a></li>
<li><a href="../topics/04-druid_assets.md.html">Druid assets</a></li>
<li><a href="../topics/05-examples.md.html">Examples</a></li>
<li><a href="../topics/changelog.md.html">Druid 0.3.0:</a></li>
<li><a href="../topics/faq.md.html">faq</a></li>
<li><a href="../topics/README.md.html">README</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>druid.drag</code></h1>
<p>Component to handle drag action on node.</p>
<p> Drag have correct handling for multitouch and swap
touched while dragging. Drag will be processed even
the cursor is outside of node, if drag is already started</p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#init">init(node, on_drag_callback)</a></td>
<td class="summary">Drag component constructor</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_click_zone">set_click_zone(zone)</a></td>
<td class="summary">Strict drag click area.</td>
</tr>
</table>
<h2><a href="#Tables">Tables</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#Events">Events</a></td>
<td class="summary">Component events</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Fields">Fields</a></td>
<td class="summary">Components fields</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Style">Style</a></td>
<td class="summary">Component style params.</td>
</tr>
</table>
<br/>
<br/>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "init"></a>
<strong>init(node, on_drag_callback)</strong>
</dt>
<dd>
Drag component constructor
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">node</span>
<span class="types"><span class="type">node</span></span>
GUI node to detect dragging
</li>
<li><span class="parameter">on_drag_callback</span>
<span class="types"><span class="type">function</span></span>
Callback for on<em>drag</em>event(self, dx, dy)
</li>
</ul>
</dd>
<dt>
<a name = "set_click_zone"></a>
<strong>set_click_zone(zone)</strong>
</dt>
<dd>
Strict drag click area. Useful for
restrict events outside stencil node
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">zone</span>
<span class="types"><span class="type">node</span></span>
Gui node
</li>
</ul>
</dd>
</dl>
<h2 class="section-header "><a name="Tables"></a>Tables</h2>
<dl class="function">
<dt>
<a name = "Events"></a>
<strong>Events</strong>
</dt>
<dd>
Component events
<h3>Fields:</h3>
<ul>
<li><span class="parameter">on_touch_start</span>
<span class="types"><span class="type">druid_event</span></span>
(self) Event on touch start
</li>
<li><span class="parameter">on_touch_end</span>
<span class="types"><span class="type">druid_event</span></span>
(self) Event on touch end
</li>
<li><span class="parameter">on_drag_start</span>
<span class="types"><span class="type">druid_event</span></span>
(self) Event on drag start
</li>
<li><span class="parameter">on_drag</span>
<span class="types"><span class="type">druid_event</span></span>
(self, dx, dy) Event on drag progress
</li>
<li><span class="parameter">on_drag_end</span>
<span class="types"><span class="type">druid_event</span></span>
(self) Event on drag end
</li>
</ul>
</dd>
<dt>
<a name = "Fields"></a>
<strong>Fields</strong>
</dt>
<dd>
Components fields
<h3>Fields:</h3>
<ul>
<li><span class="parameter">is_touch</span>
<span class="types"><span class="type">bool</span></span>
Is component now touching
</li>
<li><span class="parameter">is_drag</span>
<span class="types"><span class="type">bool</span></span>
Is component now dragging
</li>
<li><span class="parameter">can_x</span>
<span class="types"><span class="type">bool</span></span>
Is drag component process vertical dragging. Default - true
</li>
<li><span class="parameter">can_y</span>
<span class="types"><span class="type">bool</span></span>
Is drag component process horizontal. Default - true
</li>
<li><span class="parameter">x</span>
<span class="types"><span class="type">number</span></span>
Current touch x position
</li>
<li><span class="parameter">y</span>
<span class="types"><span class="type">number</span></span>
Current touch y position
</li>
<li><span class="parameter">touch_start_pos</span>
<span class="types"><span class="type">vector3</span></span>
Touch start position
</li>
</ul>
</dd>
<dt>
<a name = "Style"></a>
<strong>Style</strong>
</dt>
<dd>
Component style params.
You can override this component styles params in druid styles table
or create your own style
<h3>Fields:</h3>
<ul>
<li><span class="parameter">DRAG_DEADZONE</span>
<span class="types"><span class="type">number</span></span>
Distance in pixels to start dragging
(<em>default</em> 10)
</li>
</ul>
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-09-29 23:46:16 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View File

@ -1,496 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Tables">Tables</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/druid.back_handler.html">druid.back_handler</a></li>
<li><a href="../modules/druid.blocker.html">druid.blocker</a></li>
<li><a href="../modules/druid.button.html">druid.button</a></li>
<li><a href="../modules/druid.drag.html">druid.drag</a></li>
<li><a href="../modules/druid.hover.html">druid.hover</a></li>
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
<li><a href="../modules/druid.static_grid.html">druid.static_grid</a></li>
<li><a href="../modules/druid.swipe.html">druid.swipe</a></li>
<li><a href="../modules/druid.text.html">druid.text</a></li>
<li><a href="../modules/component.html">component</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/druid_event.html">druid_event</a></li>
<li><a href="../modules/druid.checkbox.html">druid.checkbox</a></li>
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
<li><strong>druid.dynamic_grid</strong></li>
<li><a href="../modules/druid.input.html">druid.input</a></li>
<li><a href="../modules/druid.lang_text.html">druid.lang_text</a></li>
<li><a href="../modules/druid.progress.html">druid.progress</a></li>
<li><a href="../modules/druid.radio_group.html">druid.radio_group</a></li>
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/01-components.md.html">01-components</a></li>
<li><a href="../topics/02-creating_custom_components.md.html">Creating custom components</a></li>
<li><a href="../topics/03-styles.md.html">Styles</a></li>
<li><a href="../topics/04-druid_assets.md.html">Druid assets</a></li>
<li><a href="../topics/05-examples.md.html">Examples</a></li>
<li><a href="../topics/changelog.md.html">Druid 0.3.0:</a></li>
<li><a href="../topics/faq.md.html">faq</a></li>
<li><a href="../topics/README.md.html">README</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>druid.dynamic_grid</code></h1>
<p>Component to handle placing components in row</p>
<p>
</p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#init">init(parent)</a></td>
<td class="summary">Component init function</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_pos">get_pos(index, node)</a></td>
<td class="summary">Return pos for grid node index</td>
</tr>
<tr>
<td class="name" nowrap><a href="#add">add(node[, index[, is_shift_left=false]])</a></td>
<td class="summary">Add new node to the grid</td>
</tr>
<tr>
<td class="name" nowrap><a href="#remove">remove(index[, is_shift_left=false])</a></td>
<td class="summary">Remove the item from the grid.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_size">get_size()</a></td>
<td class="summary">Return grid content size</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_index_by_node">get_index_by_node(node)</a></td>
<td class="summary">Return grid index by node</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_all_pos">get_all_pos()</a></td>
<td class="summary">Return array of all node positions</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_position_function">set_position_function(callback)</a></td>
<td class="summary">Change set position function for grid nodes.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#clear">clear()</a></td>
<td class="summary">Clear grid nodes array.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#DynamicGrid:_get_side_vector">DynamicGrid:_get_side_vector(side, is_forward)</a></td>
<td class="summary">Return side vector to correct node shifting</td>
</tr>
</table>
<h2><a href="#Tables">Tables</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#Events">Events</a></td>
<td class="summary">Component events</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Fields">Fields</a></td>
<td class="summary">Component fields</td>
</tr>
</table>
<br/>
<br/>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "init"></a>
<strong>init(parent)</strong>
</dt>
<dd>
Component init function
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">parent</span>
<span class="types"><span class="type">node</span></span>
The gui node parent, where items will be placed
</li>
</ul>
</dd>
<dt>
<a name = "get_pos"></a>
<strong>get_pos(index, node)</strong>
</dt>
<dd>
Return pos for grid node index
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">index</span>
<span class="types"><span class="type">number</span></span>
The grid element index
</li>
<li><span class="parameter">node</span>
<span class="types"><span class="type">node</span></span>
The node to be placed
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">vector3</span></span>
Node position
</ol>
</dd>
<dt>
<a name = "add"></a>
<strong>add(node[, index[, is_shift_left=false]])</strong>
</dt>
<dd>
Add new node to the grid
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">node</span>
<span class="types"><span class="type">node</span></span>
Gui node
</li>
<li><span class="parameter">index</span>
<span class="types"><span class="type">number</span></span>
The node position. By default add as last node
(<em>optional</em>)
</li>
<li><span class="parameter">is_shift_left</span>
<span class="types"><span class="type">bool</span></span>
If true, shift all nodes to the left, otherwise shift nodes to the right
(<em>default</em> false)
</li>
</ul>
</dd>
<dt>
<a name = "remove"></a>
<strong>remove(index[, is_shift_left=false])</strong>
</dt>
<dd>
Remove the item from the grid. Note that gui node will be not deleted
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">index</span>
<span class="types"><span class="type">number</span></span>
The grid node index to remove
</li>
<li><span class="parameter">is_shift_left</span>
<span class="types"><span class="type">bool</span></span>
If true, shift all nodes to the left, otherwise shift nodes to the right
(<em>default</em> false)
</li>
</ul>
</dd>
<dt>
<a name = "get_size"></a>
<strong>get_size()</strong>
</dt>
<dd>
Return grid content size
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">vector3</span></span>
The grid content size
</ol>
</dd>
<dt>
<a name = "get_index_by_node"></a>
<strong>get_index_by_node(node)</strong>
</dt>
<dd>
Return grid index by node
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">node</span>
<span class="types"><span class="type">node</span></span>
The gui node in the grid
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">number</span></span>
The node index
</ol>
</dd>
<dt>
<a name = "get_all_pos"></a>
<strong>get_all_pos()</strong>
</dt>
<dd>
Return array of all node positions
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">vector3[]</span></span>
All grid node positions
</ol>
</dd>
<dt>
<a name = "set_position_function"></a>
<strong>set_position_function(callback)</strong>
</dt>
<dd>
Change set position function for grid nodes. It will call on
update poses on grid elements. Default: gui.set_position
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">callback</span>
<span class="types"><span class="type">function</span></span>
Function on node set position
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">druid.dynamic_grid</span></span>
Current grid instance
</ol>
</dd>
<dt>
<a name = "clear"></a>
<strong>clear()</strong>
</dt>
<dd>
Clear grid nodes array. GUI nodes will be not deleted!
If you want to delete GUI nodes, use dynamic_grid.nodes array before grid:clear
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">druid.dynamic_grid</span></span>
Current grid instance
</ol>
</dd>
<dt>
<a name = "DynamicGrid:_get_side_vector"></a>
<strong>DynamicGrid:_get_side_vector(side, is_forward)</strong>
</dt>
<dd>
Return side vector to correct node shifting
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">side</span>
</li>
<li><span class="parameter">is_forward</span>
</li>
</ul>
</dd>
</dl>
<h2 class="section-header "><a name="Tables"></a>Tables</h2>
<dl class="function">
<dt>
<a name = "Events"></a>
<strong>Events</strong>
</dt>
<dd>
Component events
<h3>Fields:</h3>
<ul>
<li><span class="parameter">on_add_item</span>
<span class="types"><span class="type">druid_event</span></span>
On item add callback
</li>
<li><span class="parameter">on_remove_item</span>
<span class="types"><span class="type">druid_event</span></span>
On item remove callback
</li>
<li><span class="parameter">on_change_items</span>
<span class="types"><span class="type">druid_event</span></span>
On item add or remove callback
</li>
<li><span class="parameter">on_clear</span>
<span class="types"><span class="type">druid_event</span></span>
On grid clear callback
</li>
<li><span class="parameter">on_update_positions</span>
<span class="types"><span class="type">druid_event</span></span>
On update item positions callback
</li>
</ul>
</dd>
<dt>
<a name = "Fields"></a>
<strong>Fields</strong>
</dt>
<dd>
Component fields
<h3>Fields:</h3>
<ul>
<li><span class="parameter">parent</span>
<span class="types"><span class="type">node</span></span>
Parent gui node
</li>
<li><span class="parameter">nodes</span>
<span class="types"><span class="type">node[]</span></span>
List of all grid nodes
</li>
<li><span class="parameter">first_index</span>
<span class="types"><span class="type">number</span></span>
The first index of node in grid
</li>
<li><span class="parameter">last_index</span>
<span class="types"><span class="type">number</span></span>
The last index of node in grid
</li>
<li><span class="parameter">node_size</span>
<span class="types"><span class="type">vector3</span></span>
Item size
</li>
<li><span class="parameter">border</span>
<span class="types"><span class="type">vector4</span></span>
The size of item content
</li>
</ul>
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-09-29 23:46:16 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View File

@ -1,381 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Tables">Tables</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/druid.back_handler.html">druid.back_handler</a></li>
<li><a href="../modules/druid.blocker.html">druid.blocker</a></li>
<li><a href="../modules/druid.button.html">druid.button</a></li>
<li><a href="../modules/druid.checkbox.html">druid.checkbox</a></li>
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
<li><a href="../modules/druid.drag.html">druid.drag</a></li>
<li><strong>druid.grid</strong></li>
<li><a href="../modules/druid.hover.html">druid.hover</a></li>
<li><a href="../modules/druid.input.html">druid.input</a></li>
<li><a href="../modules/druid.lang_text.html">druid.lang_text</a></li>
<li><a href="../modules/druid.progress.html">druid.progress</a></li>
<li><a href="../modules/druid.radio_group.html">druid.radio_group</a></li>
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
<li><a href="../modules/druid.swipe.html">druid.swipe</a></li>
<li><a href="../modules/druid.text.html">druid.text</a></li>
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
<li><a href="../modules/component.html">component</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/druid_event.html">druid_event</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/01-components.md.html">01-components</a></li>
<li><a href="../topics/02-creating_custom_components.md.html">Creating custom components</a></li>
<li><a href="../topics/03-styles.md.html">Styles</a></li>
<li><a href="../topics/04-druid_assets.md.html">Druid assets</a></li>
<li><a href="../topics/05-examples.md.html">Examples</a></li>
<li><a href="../topics/changelog.md.html">changelog</a></li>
<li><a href="../topics/README.md.html">README</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>druid.grid</code></h1>
<p>Component to handle placing components by row and columns.</p>
<p> Grid can anchor your elements, get content size and other</p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#init">init(parent, element[, in_row=1])</a></td>
<td class="summary">Component init function</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_offset">set_offset(offset)</a></td>
<td class="summary">Set grid items offset, the distance between items</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_anchor">set_anchor(acnhor)</a></td>
<td class="summary">Set grid anchor</td>
</tr>
<tr>
<td class="name" nowrap><a href="#add">add(item[, index])</a></td>
<td class="summary">Add new item to the grid</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_size">get_size()</a></td>
<td class="summary">Return grid content size</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_all_pos">get_all_pos()</a></td>
<td class="summary">Return array of all node positions</td>
</tr>
<tr>
<td class="name" nowrap><a href="#clear">clear()</a></td>
<td class="summary">Clear grid nodes array.</td>
</tr>
</table>
<h2><a href="#Tables">Tables</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#Events">Events</a></td>
<td class="summary">Component events</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Fields">Fields</a></td>
<td class="summary">Component fields</td>
</tr>
</table>
<br/>
<br/>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "init"></a>
<strong>init(parent, element[, in_row=1])</strong>
</dt>
<dd>
Component init function
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">parent</span>
<span class="types"><span class="type">node</span></span>
The gui node parent, where items will be placed
</li>
<li><span class="parameter">element</span>
<span class="types"><span class="type">node</span></span>
Element prefab. Need to get it size
</li>
<li><span class="parameter">in_row</span>
<span class="types"><span class="type">number</span></span>
How many nodes in row can be placed
(<em>default</em> 1)
</li>
</ul>
</dd>
<dt>
<a name = "set_offset"></a>
<strong>set_offset(offset)</strong>
</dt>
<dd>
Set grid items offset, the distance between items
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">offset</span>
<span class="types"><span class="type">vector3</span></span>
Offset
</li>
</ul>
</dd>
<dt>
<a name = "set_anchor"></a>
<strong>set_anchor(acnhor)</strong>
</dt>
<dd>
Set grid anchor
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">acnhor</span>
<span class="types"><span class="type">vector3</span></span>
Anchor
</li>
</ul>
</dd>
<dt>
<a name = "add"></a>
<strong>add(item[, index])</strong>
</dt>
<dd>
Add new item to the grid
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">item</span>
<span class="types"><span class="type">node</span></span>
Gui node
</li>
<li><span class="parameter">index</span>
<span class="types"><span class="type">number</span></span>
The item position. By default add as last item
(<em>optional</em>)
</li>
</ul>
</dd>
<dt>
<a name = "get_size"></a>
<strong>get_size()</strong>
</dt>
<dd>
Return grid content size
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">vector3</span></span>
The grid content size
</ol>
</dd>
<dt>
<a name = "get_all_pos"></a>
<strong>get_all_pos()</strong>
</dt>
<dd>
Return array of all node positions
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">vector3[]</span></span>
All grid node positions
</ol>
</dd>
<dt>
<a name = "clear"></a>
<strong>clear()</strong>
</dt>
<dd>
Clear grid nodes array. GUI nodes will be not deleted!
If you want to delete GUI nodes, use grid.nodes array before grid:clear
</dd>
</dl>
<h2 class="section-header "><a name="Tables"></a>Tables</h2>
<dl class="function">
<dt>
<a name = "Events"></a>
<strong>Events</strong>
</dt>
<dd>
Component events
<h3>Fields:</h3>
<ul>
<li><span class="parameter">on_add_item</span>
<span class="types"><span class="type">druid_event</span></span>
On item add callback
</li>
<li><span class="parameter">on_remove_item</span>
<span class="types"><span class="type">druid_event</span></span>
On item remove callback
</li>
<li><span class="parameter">on_clear</span>
<span class="types"><span class="type">druid_event</span></span>
On grid clear callback
</li>
<li><span class="parameter">on_update_positions</span>
<span class="types"><span class="type">druid_event</span></span>
On update item positions callback
</li>
</ul>
</dd>
<dt>
<a name = "Fields"></a>
<strong>Fields</strong>
</dt>
<dd>
Component fields
<h3>Fields:</h3>
<ul>
<li><span class="parameter">parent</span>
<span class="types"><span class="type">node</span></span>
Parent gui node
</li>
<li><span class="parameter">nodes</span>
<span class="types"><span class="type">node[]</span></span>
List of all grid nodes
</li>
<li><span class="parameter">offset</span>
<span class="types"><span class="type">vector3</span></span>
Item distance between each other items
</li>
<li><span class="parameter">anchor</span>
<span class="types"><span class="type">vector3</span></span>
Item anchor
</li>
<li><span class="parameter">node_size</span>
<span class="types"><span class="type">vector3</span></span>
Item size
</li>
<li><span class="parameter">border</span>
<span class="types"><span class="type">vector4</span></span>
The size of item content
</li>
<li><span class="parameter">border_offer</span>
<span class="types"><span class="type">vector3</span></span>
The border offset for correct anchor calculations
</li>
</ul>
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View File

@ -38,40 +38,30 @@
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/druid.back_handler.html">druid.back_handler</a></li>
<li><a href="../modules/druid.blocker.html">druid.blocker</a></li>
<li><a href="../modules/druid.button.html">druid.button</a></li>
<li><a href="../modules/druid.drag.html">druid.drag</a></li>
<li><a href="../modules/druid.hover.html">druid.hover</a></li>
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
<li><a href="../modules/druid.static_grid.html">druid.static_grid</a></li>
<li><a href="../modules/druid.swipe.html">druid.swipe</a></li>
<li><a href="../modules/druid.text.html">druid.text</a></li>
<li><a href="../modules/component.html">component</a></li>
<li><a href="../modules/BackHandler.html">BackHandler</a></li>
<li><a href="../modules/Blocker.html">Blocker</a></li>
<li><a href="../modules/Button.html">Button</a></li>
<li><a href="../modules/Drag.html">Drag</a></li>
<li><a href="../modules/Hover.html">Hover</a></li>
<li><a href="../modules/Scroll.html">Scroll</a></li>
<li><a href="../modules/StaticGrid.html">StaticGrid</a></li>
<li><a href="../modules/Swipe.html">Swipe</a></li>
<li><a href="../modules/Text.html">Text</a></li>
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/druid_event.html">druid_event</a></li>
<li><a href="../modules/druid.checkbox.html">druid.checkbox</a></li>
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
<li><a href="../modules/druid.dynamic_grid.html">druid.dynamic_grid</a></li>
<li><a href="../modules/druid.input.html">druid.input</a></li>
<li><a href="../modules/druid.lang_text.html">druid.lang_text</a></li>
<li><a href="../modules/druid.progress.html">druid.progress</a></li>
<li><a href="../modules/druid.radio_group.html">druid.radio_group</a></li>
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
<li><a href="../modules/DruidEvent.html">DruidEvent</a></li>
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
<li><a href="../modules/DataList.html">DataList</a></li>
<li><a href="../modules/DynamicGrid.html">DynamicGrid</a></li>
<li><a href="../modules/Input.html">Input</a></li>
<li><a href="../modules/LangText.html">LangText</a></li>
<li><a href="../modules/Progress.html">Progress</a></li>
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
<li><a href="../modules/Slider.html">Slider</a></li>
<li><a href="../modules/Timer.html">Timer</a></li>
<li><strong>druid.helper</strong></li>
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/01-components.md.html">01-components</a></li>
<li><a href="../topics/02-creating_custom_components.md.html">Creating custom components</a></li>
<li><a href="../topics/03-styles.md.html">Styles</a></li>
<li><a href="../topics/04-druid_assets.md.html">Druid assets</a></li>
<li><a href="../topics/05-examples.md.html">Examples</a></li>
<li><a href="../topics/changelog.md.html">Druid 0.3.0:</a></li>
<li><a href="../topics/faq.md.html">faq</a></li>
<li><a href="../topics/README.md.html">README</a></li>
<li><a href="../modules/DruidInstance.html">DruidInstance</a></li>
</ul>
</div>
@ -80,9 +70,7 @@
<h1>Module <code>druid.helper</code></h1>
<p>Text node or icon node can be nil</p>
<p>
</p>
<p></p>
<h2><a href="#Functions">Functions</a></h2>
@ -96,6 +84,10 @@
<td class="summary">Center two nodes.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#centrate_nodes">centrate_nodes([margin=0[, ...]])</a></td>
<td class="summary">Center several nodes nodes.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#is_enabled">is_enabled(node)</a></td>
<td class="summary">Check if node is enabled in gui hierarchy.</td>
</tr>
@ -112,8 +104,8 @@
<td class="summary">Check if device is HTML5</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_border">get_border()</a></td>
<td class="summary">Distance from node to size border</td>
<td class="name" nowrap><a href="#get_border">get_border(node, offset)</a></td>
<td class="summary">Distance from node position to his borders</td>
</tr>
<tr>
<td class="name" nowrap><a href="#deprecated">deprecated(message)</a></td>
@ -194,6 +186,34 @@
</dd>
<dt>
<a name = "centrate_nodes"></a>
<strong>centrate_nodes([margin=0[, ...]])</strong>
</dt>
<dd>
Center several nodes nodes.
Nodes will be center around 0 x position
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">margin</span>
<span class="types"><span class="type">number</span></span>
Offset between nodes
(<em>default</em> 0)
</li>
<li><span class="parameter">...</span>
<span class="types"><span class="type">Node</span></span>
Any count of gui Node
(<em>optional</em>)
</li>
</ul>
</dd>
<dt>
<a name = "is_enabled"></a>
@ -280,17 +300,28 @@
</dd>
<dt>
<a name = "get_border"></a>
<strong>get_border()</strong>
<strong>get_border(node, offset)</strong>
</dt>
<dd>
Distance from node to size border
Distance from node position to his borders
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">node</span>
<span class="types"><span class="type">node</span></span>
The gui node to check
</li>
<li><span class="parameter">offset</span>
<span class="types"><span class="type">vector3</span></span>
The offset to add to result
</li>
</ul>
<h3>Returns:</h3>
<ol>
vector4 (left, top, right, down)
vector4 Vector with distance to node border: (left, top, right, down)
</ol>
@ -325,7 +356,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-09-29 23:46:16 </i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@ -38,40 +38,30 @@
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/druid.back_handler.html">druid.back_handler</a></li>
<li><a href="../modules/druid.blocker.html">druid.blocker</a></li>
<li><a href="../modules/druid.button.html">druid.button</a></li>
<li><a href="../modules/druid.drag.html">druid.drag</a></li>
<li><a href="../modules/druid.hover.html">druid.hover</a></li>
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
<li><a href="../modules/druid.static_grid.html">druid.static_grid</a></li>
<li><a href="../modules/druid.swipe.html">druid.swipe</a></li>
<li><a href="../modules/druid.text.html">druid.text</a></li>
<li><a href="../modules/component.html">component</a></li>
<li><a href="../modules/BackHandler.html">BackHandler</a></li>
<li><a href="../modules/Blocker.html">Blocker</a></li>
<li><a href="../modules/Button.html">Button</a></li>
<li><a href="../modules/Drag.html">Drag</a></li>
<li><a href="../modules/Hover.html">Hover</a></li>
<li><a href="../modules/Scroll.html">Scroll</a></li>
<li><a href="../modules/StaticGrid.html">StaticGrid</a></li>
<li><a href="../modules/Swipe.html">Swipe</a></li>
<li><a href="../modules/Text.html">Text</a></li>
<li><a href="../modules/BaseComponent.html">BaseComponent</a></li>
<li><strong>druid</strong></li>
<li><a href="../modules/druid_event.html">druid_event</a></li>
<li><a href="../modules/druid.checkbox.html">druid.checkbox</a></li>
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
<li><a href="../modules/druid.dynamic_grid.html">druid.dynamic_grid</a></li>
<li><a href="../modules/druid.input.html">druid.input</a></li>
<li><a href="../modules/druid.lang_text.html">druid.lang_text</a></li>
<li><a href="../modules/druid.progress.html">druid.progress</a></li>
<li><a href="../modules/druid.radio_group.html">druid.radio_group</a></li>
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
<li><a href="../modules/DruidEvent.html">DruidEvent</a></li>
<li><a href="../modules/Checkbox.html">Checkbox</a></li>
<li><a href="../modules/CheckboxGroup.html">CheckboxGroup</a></li>
<li><a href="../modules/DataList.html">DataList</a></li>
<li><a href="../modules/DynamicGrid.html">DynamicGrid</a></li>
<li><a href="../modules/Input.html">Input</a></li>
<li><a href="../modules/LangText.html">LangText</a></li>
<li><a href="../modules/Progress.html">Progress</a></li>
<li><a href="../modules/RadioGroup.html">RadioGroup</a></li>
<li><a href="../modules/Slider.html">Slider</a></li>
<li><a href="../modules/Timer.html">Timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/01-components.md.html">01-components</a></li>
<li><a href="../topics/02-creating_custom_components.md.html">Creating custom components</a></li>
<li><a href="../topics/03-styles.md.html">Styles</a></li>
<li><a href="../topics/04-druid_assets.md.html">Druid assets</a></li>
<li><a href="../topics/05-examples.md.html">Examples</a></li>
<li><a href="../topics/changelog.md.html">Druid 0.3.0:</a></li>
<li><a href="../topics/faq.md.html">faq</a></li>
<li><a href="../topics/README.md.html">README</a></li>
<li><a href="../modules/DruidInstance.html">DruidInstance</a></li>
</ul>
</div>
@ -81,23 +71,16 @@
<h1>Module <code>druid</code></h1>
<p>Druid UI Library.</p>
<p>
<p> Powerful Defold component based UI library. Use standart
Powerful Defold component based UI library. Use standart
components or make your own game-specific components to
make amazing GUI in your games.</p>
make amazing GUI in your games.
<p> Contains the several basic components and examples
to how to do your custom complex components to
separate UI game logic to small files</p>
<pre>
<span class="global">require</span>(<span class="string">"druid.druid"</span>)
<span class="keyword">function</span> init(self)
self.druid = druid.new(self)
<span class="keyword">end</span>
</pre>
separate UI game logic to small files
<p> require("druid.druid")
function init(self)
self.druid = druid.new(self)
end
</p>
@ -153,7 +136,7 @@
<dd>
Register external druid component.
After register you can create the component with
druid<em>instance:new</em>{name}. For example <code>druid:new_button(...)</code>
druid_instance:new_{name}. For example `druid:new_button(...)`
<h3>Parameters:</h3>
@ -233,7 +216,7 @@
<dd>
Set text function
Druid locale component will call this function
to get translated text. After set<em>text</em>funtion
to get translated text. After set_text_funtion
all existing locale component will be updated
@ -279,7 +262,7 @@
</dt>
<dd>
Callback on global window event.
Used to trigger on<em>focus</em>lost and on<em>focus</em>gain
Used to trigger on_focus_lost and on_focus_gain
<h3>Parameters:</h3>
@ -331,7 +314,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-09-29 23:46:16 </i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@ -1,397 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Tables">Tables</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/druid.back_handler.html">druid.back_handler</a></li>
<li><a href="../modules/druid.blocker.html">druid.blocker</a></li>
<li><a href="../modules/druid.button.html">druid.button</a></li>
<li><a href="../modules/druid.drag.html">druid.drag</a></li>
<li><a href="../modules/druid.hover.html">druid.hover</a></li>
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
<li><a href="../modules/druid.static_grid.html">druid.static_grid</a></li>
<li><a href="../modules/druid.swipe.html">druid.swipe</a></li>
<li><a href="../modules/druid.text.html">druid.text</a></li>
<li><a href="../modules/component.html">component</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/druid_event.html">druid_event</a></li>
<li><a href="../modules/druid.checkbox.html">druid.checkbox</a></li>
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
<li><a href="../modules/druid.dynamic_grid.html">druid.dynamic_grid</a></li>
<li><strong>druid.input</strong></li>
<li><a href="../modules/druid.lang_text.html">druid.lang_text</a></li>
<li><a href="../modules/druid.progress.html">druid.progress</a></li>
<li><a href="../modules/druid.radio_group.html">druid.radio_group</a></li>
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/01-components.md.html">01-components</a></li>
<li><a href="../topics/02-creating_custom_components.md.html">Creating custom components</a></li>
<li><a href="../topics/03-styles.md.html">Styles</a></li>
<li><a href="../topics/04-druid_assets.md.html">Druid assets</a></li>
<li><a href="../topics/05-examples.md.html">Examples</a></li>
<li><a href="../topics/changelog.md.html">Druid 0.3.0:</a></li>
<li><a href="../topics/faq.md.html">faq</a></li>
<li><a href="../topics/README.md.html">README</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>druid.input</code></h1>
<p>Druid input text component.</p>
<p> Carry on user text input</p>
<h3>Info:</h3>
<ul>
<li><strong>Author</strong>: Part of code from Britzl gooey input component</li>
</ul>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#set_text">set_text(input_text)</a></td>
<td class="summary">Set text for input field</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_text">get_text()</a></td>
<td class="summary">Return current input field text</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_max_length">set_max_length(max_length)</a></td>
<td class="summary">Set maximum length for input field.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_allowerd_characters">set_allowerd_characters(characters)</a></td>
<td class="summary">Set allowed charaters for input field.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#reset_changes">reset_changes()</a></td>
<td class="summary">Reset current input selection and return previous value</td>
</tr>
</table>
<h2><a href="#Tables">Tables</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#Events">Events</a></td>
<td class="summary">Component events</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Fields">Fields</a></td>
<td class="summary">Component fields</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Style">Style</a></td>
<td class="summary">Component style params.</td>
</tr>
</table>
<br/>
<br/>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "set_text"></a>
<strong>set_text(input_text)</strong>
</dt>
<dd>
Set text for input field
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">input_text</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
The string to apply for input field
</li>
</ul>
</dd>
<dt>
<a name = "get_text"></a>
<strong>get_text()</strong>
</dt>
<dd>
Return current input field text
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
The current input field text
</ol>
</dd>
<dt>
<a name = "set_max_length"></a>
<strong>set_max_length(max_length)</strong>
</dt>
<dd>
Set maximum length for input field.
Pass nil to make input field unliminted (by default)
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">max_length</span>
<span class="types"><span class="type">number</span></span>
Maximum length for input text field
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">druid.input</span></span>
Current input instance
</ol>
</dd>
<dt>
<a name = "set_allowerd_characters"></a>
<strong>set_allowerd_characters(characters)</strong>
</dt>
<dd>
Set allowed charaters for input field.
See: https://defold.com/ref/stable/string/
ex: [%a%d] for alpha and numeric
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">characters</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
Regulax exp. for validate user input
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">druid.input</span></span>
Current input instance
</ol>
</dd>
<dt>
<a name = "reset_changes"></a>
<strong>reset_changes()</strong>
</dt>
<dd>
Reset current input selection and return previous value
</dd>
</dl>
<h2 class="section-header "><a name="Tables"></a>Tables</h2>
<dl class="function">
<dt>
<a name = "Events"></a>
<strong>Events</strong>
</dt>
<dd>
Component events
<h3>Fields:</h3>
<ul>
<li><span class="parameter">on_input_select</span>
<span class="types"><span class="type">druid_event</span></span>
(self, button_node) On input field select callback
</li>
<li><span class="parameter">on_input_unselect</span>
<span class="types"><span class="type">druid_event</span></span>
(self, button_node) On input field unselect callback
</li>
<li><span class="parameter">on_input_text</span>
<span class="types"><span class="type">druid_event</span></span>
(self, input_text) On input field text change callback
</li>
<li><span class="parameter">on_input_empty</span>
<span class="types"><span class="type">druid_event</span></span>
(self, input_text) On input field text change to empty string callback
</li>
<li><span class="parameter">on_input_full</span>
<span class="types"><span class="type">druid_event</span></span>
(self, input_text) On input field text change to max length string callback
</li>
<li><span class="parameter">on_input_wrong</span>
<span class="types"><span class="type">druid_event</span></span>
(self, params, button_instance) On trying user input with not allowed character callback
</li>
</ul>
</dd>
<dt>
<a name = "Fields"></a>
<strong>Fields</strong>
</dt>
<dd>
Component fields
<h3>Fields:</h3>
<ul>
<li><span class="parameter">text</span>
<span class="types"><span class="type">druid.text</span></span>
Text component
</li>
<li><span class="parameter">button</span>
<span class="types"><span class="type">druid.button</span></span>
Button component
</li>
<li><span class="parameter">is_selected</span>
<span class="types"><span class="type">bool</span></span>
Is current input selected now
</li>
<li><span class="parameter">is_empty</span>
<span class="types"><span class="type">bool</span></span>
Is current input is empty now
</li>
<li><span class="parameter">max_length</span>
<span class="types"><span class="type">number</span></span>
Max length for input text
(<em>optional</em>)
</li>
<li><span class="parameter">allowerd_characters</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
Pattern matching for user input
(<em>optional</em>)
</li>
<li><span class="parameter">keyboard_type</span>
<span class="types"><span class="type">number</span></span>
Gui keyboard type for input field
</li>
</ul>
</dd>
<dt>
<a name = "Style"></a>
<strong>Style</strong>
</dt>
<dd>
Component style params.
You can override this component styles params in druid styles table
or create your own style
<h3>Fields:</h3>
<ul>
<li><span class="parameter">IS_LONGTAP_ERASE</span>
<span class="types"><span class="type">bool</span></span>
Is long tap will erase current input data
(<em>default</em> false)
</li>
<li><span class="parameter">MASK_DEFAULT_CHAR</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
Default character mask for password input
(<em>default</em> *)
</li>
<li><span class="parameter">on_select</span>
<span class="types"><span class="type">function</span></span>
(self, button_node) Callback on input field selecting
</li>
<li><span class="parameter">on_unselect</span>
<span class="types"><span class="type">function</span></span>
(self, button_node) Callback on input field unselecting
</li>
<li><span class="parameter">on_input_wrong</span>
<span class="types"><span class="type">function</span></span>
(self, button_node) Callback on wrong user input
</li>
<li><span class="parameter">button_style</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
Custom button style for input node
</li>
</ul>
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-09-29 23:46:16 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View File

@ -1,251 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Tables">Tables</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/druid.back_handler.html">druid.back_handler</a></li>
<li><a href="../modules/druid.blocker.html">druid.blocker</a></li>
<li><a href="../modules/druid.button.html">druid.button</a></li>
<li><a href="../modules/druid.drag.html">druid.drag</a></li>
<li><a href="../modules/druid.hover.html">druid.hover</a></li>
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
<li><a href="../modules/druid.static_grid.html">druid.static_grid</a></li>
<li><a href="../modules/druid.swipe.html">druid.swipe</a></li>
<li><a href="../modules/druid.text.html">druid.text</a></li>
<li><a href="../modules/component.html">component</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/druid_event.html">druid_event</a></li>
<li><a href="../modules/druid.checkbox.html">druid.checkbox</a></li>
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
<li><a href="../modules/druid.dynamic_grid.html">druid.dynamic_grid</a></li>
<li><a href="../modules/druid.input.html">druid.input</a></li>
<li><a href="../modules/druid.lang_text.html">druid.lang_text</a></li>
<li><a href="../modules/druid.progress.html">druid.progress</a></li>
<li><strong>druid.radio_group</strong></li>
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/01-components.md.html">01-components</a></li>
<li><a href="../topics/02-creating_custom_components.md.html">Creating custom components</a></li>
<li><a href="../topics/03-styles.md.html">Styles</a></li>
<li><a href="../topics/04-druid_assets.md.html">Druid assets</a></li>
<li><a href="../topics/05-examples.md.html">Examples</a></li>
<li><a href="../topics/changelog.md.html">Druid 0.3.0:</a></li>
<li><a href="../topics/faq.md.html">faq</a></li>
<li><a href="../topics/README.md.html">README</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>druid.radio_group</code></h1>
<p>Radio group module</p>
<p>
</p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#init">init(node, callback[, click=node])</a></td>
<td class="summary">Component init function</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_state">set_state(index)</a></td>
<td class="summary">Set radio group state</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_state">get_state()</a></td>
<td class="summary">Return radio group state</td>
</tr>
</table>
<h2><a href="#Tables">Tables</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#Events">Events</a></td>
<td class="summary">Component events</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Fields">Fields</a></td>
<td class="summary">Component fields</td>
</tr>
</table>
<br/>
<br/>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "init"></a>
<strong>init(node, callback[, click=node])</strong>
</dt>
<dd>
Component init function
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">node</span>
<span class="types"><span class="type">node[]</span></span>
Array of gui node
</li>
<li><span class="parameter">callback</span>
<span class="types"><span class="type">function</span></span>
Radio callback
</li>
<li><span class="parameter">click</span>
<span class="types"><span class="type">node[]</span></span>
node Array of trigger nodes, by default equals to nodes
(<em>default</em> node)
</li>
</ul>
</dd>
<dt>
<a name = "set_state"></a>
<strong>set_state(index)</strong>
</dt>
<dd>
Set radio group state
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">index</span>
<span class="types"><span class="type">number</span></span>
Index in radio group
</li>
</ul>
</dd>
<dt>
<a name = "get_state"></a>
<strong>get_state()</strong>
</dt>
<dd>
Return radio group state
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">number</span></span>
Index in radio group
</ol>
</dd>
</dl>
<h2 class="section-header "><a name="Tables"></a>Tables</h2>
<dl class="function">
<dt>
<a name = "Events"></a>
<strong>Events</strong>
</dt>
<dd>
Component events
<h3>Fields:</h3>
<ul>
<li><span class="parameter">on_radio_click</span>
<span class="types"><span class="type">druid_event</span></span>
On any checkbox click
</li>
</ul>
</dd>
<dt>
<a name = "Fields"></a>
<strong>Fields</strong>
</dt>
<dd>
Component fields
<h3>Fields:</h3>
<ul>
<li><span class="parameter">checkboxes</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
Array of checkbox components
</li>
</ul>
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-09-29 23:46:16 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View File

@ -1,290 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Tables">Tables</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/druid.back_handler.html">druid.back_handler</a></li>
<li><a href="../modules/druid.blocker.html">druid.blocker</a></li>
<li><a href="../modules/druid.button.html">druid.button</a></li>
<li><a href="../modules/druid.drag.html">druid.drag</a></li>
<li><a href="../modules/druid.hover.html">druid.hover</a></li>
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
<li><a href="../modules/druid.static_grid.html">druid.static_grid</a></li>
<li><a href="../modules/druid.swipe.html">druid.swipe</a></li>
<li><a href="../modules/druid.text.html">druid.text</a></li>
<li><a href="../modules/component.html">component</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/druid_event.html">druid_event</a></li>
<li><a href="../modules/druid.checkbox.html">druid.checkbox</a></li>
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
<li><a href="../modules/druid.dynamic_grid.html">druid.dynamic_grid</a></li>
<li><a href="../modules/druid.input.html">druid.input</a></li>
<li><a href="../modules/druid.lang_text.html">druid.lang_text</a></li>
<li><a href="../modules/druid.progress.html">druid.progress</a></li>
<li><a href="../modules/druid.radio_group.html">druid.radio_group</a></li>
<li><strong>druid.slider</strong></li>
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/01-components.md.html">01-components</a></li>
<li><a href="../topics/02-creating_custom_components.md.html">Creating custom components</a></li>
<li><a href="../topics/03-styles.md.html">Styles</a></li>
<li><a href="../topics/04-druid_assets.md.html">Druid assets</a></li>
<li><a href="../topics/05-examples.md.html">Examples</a></li>
<li><a href="../topics/changelog.md.html">Druid 0.3.0:</a></li>
<li><a href="../topics/faq.md.html">faq</a></li>
<li><a href="../topics/README.md.html">README</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>druid.slider</code></h1>
<p>Druid slider component</p>
<p>
</p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#init">init(node, end_pos[, callback])</a></td>
<td class="summary">Component init function</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set">set(value[, is_silent])</a></td>
<td class="summary">Set value for slider</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_steps">set_steps(steps)</a></td>
<td class="summary">Set slider steps.</td>
</tr>
</table>
<h2><a href="#Tables">Tables</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#Events">Events</a></td>
<td class="summary">Component events</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Fields">Fields</a></td>
<td class="summary">Component fields</td>
</tr>
</table>
<br/>
<br/>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "init"></a>
<strong>init(node, end_pos[, callback])</strong>
</dt>
<dd>
Component init function
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">node</span>
<span class="types"><span class="type">node</span></span>
Gui pin node
</li>
<li><span class="parameter">end_pos</span>
<span class="types"><span class="type">vector3</span></span>
The end position of slider
</li>
<li><span class="parameter">callback</span>
<span class="types"><span class="type">function</span></span>
On slider change callback
(<em>optional</em>)
</li>
</ul>
</dd>
<dt>
<a name = "set"></a>
<strong>set(value[, is_silent])</strong>
</dt>
<dd>
Set value for slider
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">value</span>
<span class="types"><span class="type">number</span></span>
Value from 0 to 1
</li>
<li><span class="parameter">is_silent</span>
<span class="types"><span class="type">bool</span></span>
Don't trigger event if true
(<em>optional</em>)
</li>
</ul>
</dd>
<dt>
<a name = "set_steps"></a>
<strong>set_steps(steps)</strong>
</dt>
<dd>
Set slider steps. Pin node will
apply closest step position
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">steps</span>
<span class="types"><span class="type">number[]</span></span>
Array of steps
</li>
</ul>
<h3>Usage:</h3>
<ul>
<pre class="example">slider:set_steps({<span class="number">0</span>, <span class="number">0.2</span>, <span class="number">0.6</span>, <span class="number">1</span>})</pre>
</ul>
</dd>
</dl>
<h2 class="section-header "><a name="Tables"></a>Tables</h2>
<dl class="function">
<dt>
<a name = "Events"></a>
<strong>Events</strong>
</dt>
<dd>
Component events
<h3>Fields:</h3>
<ul>
<li><span class="parameter">on_change_value</span>
<span class="types"><span class="type">druid_event</span></span>
On change value callback
</li>
</ul>
</dd>
<dt>
<a name = "Fields"></a>
<strong>Fields</strong>
</dt>
<dd>
Component fields
<h3>Fields:</h3>
<ul>
<li><span class="parameter">node</span>
<span class="types"><span class="type">node</span></span>
Slider pin node
</li>
<li><span class="parameter">start_pos</span>
<span class="types"><span class="type">vector3</span></span>
Start pin node position
</li>
<li><span class="parameter">pos</span>
<span class="types"><span class="type">vector3</span></span>
Current pin node position
</li>
<li><span class="parameter">target_pos</span>
<span class="types"><span class="type">vector3</span></span>
Targer pin node position
</li>
<li><span class="parameter">end_pos</span>
<span class="types"><span class="type">vector3</span></span>
End pin node position
</li>
<li><span class="parameter">dist</span>
<span class="types"><span class="type">number</span></span>
Length between start and end position
</li>
<li><span class="parameter">is_drag</span>
<span class="types"><span class="type">bool</span></span>
Current drag state
</li>
<li><span class="parameter">value</span>
<span class="types"><span class="type">number</span></span>
Current slider value
</li>
</ul>
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-09-29 23:46:16 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View File

@ -1,522 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Tables">Tables</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/druid.back_handler.html">druid.back_handler</a></li>
<li><a href="../modules/druid.blocker.html">druid.blocker</a></li>
<li><a href="../modules/druid.button.html">druid.button</a></li>
<li><a href="../modules/druid.drag.html">druid.drag</a></li>
<li><a href="../modules/druid.hover.html">druid.hover</a></li>
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
<li><strong>druid.static_grid</strong></li>
<li><a href="../modules/druid.swipe.html">druid.swipe</a></li>
<li><a href="../modules/druid.text.html">druid.text</a></li>
<li><a href="../modules/component.html">component</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/druid_event.html">druid_event</a></li>
<li><a href="../modules/druid.checkbox.html">druid.checkbox</a></li>
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
<li><a href="../modules/druid.dynamic_grid.html">druid.dynamic_grid</a></li>
<li><a href="../modules/druid.input.html">druid.input</a></li>
<li><a href="../modules/druid.lang_text.html">druid.lang_text</a></li>
<li><a href="../modules/druid.progress.html">druid.progress</a></li>
<li><a href="../modules/druid.radio_group.html">druid.radio_group</a></li>
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/01-components.md.html">01-components</a></li>
<li><a href="../topics/02-creating_custom_components.md.html">Creating custom components</a></li>
<li><a href="../topics/03-styles.md.html">Styles</a></li>
<li><a href="../topics/04-druid_assets.md.html">Druid assets</a></li>
<li><a href="../topics/05-examples.md.html">Examples</a></li>
<li><a href="../topics/changelog.md.html">Druid 0.3.0:</a></li>
<li><a href="../topics/faq.md.html">faq</a></li>
<li><a href="../topics/README.md.html">README</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>druid.static_grid</code></h1>
<p>Component to handle placing components by row and columns.</p>
<p> Grid can anchor your elements, get content size and other</p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#init">init(parent, element[, in_row=1])</a></td>
<td class="summary">Component init function</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_pos">get_pos(index)</a></td>
<td class="summary">Return pos for grid node index</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_index">get_index(pos)</a></td>
<td class="summary">Return index for grid pos</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_index_by_node">get_index_by_node(node)</a></td>
<td class="summary">Return grid index by node</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_anchor">set_anchor(anchor)</a></td>
<td class="summary">Set grid anchor.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#add">add(item[, index])</a></td>
<td class="summary">Add new item to the grid</td>
</tr>
<tr>
<td class="name" nowrap><a href="#remove">remove(index, is_shift_nodes)</a></td>
<td class="summary">Remove the item from the grid.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_size">get_size()</a></td>
<td class="summary">Return grid content size</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_all_pos">get_all_pos()</a></td>
<td class="summary">Return array of all node positions</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_position_function">set_position_function(callback)</a></td>
<td class="summary">Change set position function for grid nodes.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#clear">clear()</a></td>
<td class="summary">Clear grid nodes array.</td>
</tr>
</table>
<h2><a href="#Tables">Tables</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#Events">Events</a></td>
<td class="summary">Component events</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Fields">Fields</a></td>
<td class="summary">Component fields</td>
</tr>
</table>
<br/>
<br/>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "init"></a>
<strong>init(parent, element[, in_row=1])</strong>
</dt>
<dd>
Component init function
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">parent</span>
<span class="types"><span class="type">node</span></span>
The gui node parent, where items will be placed
</li>
<li><span class="parameter">element</span>
<span class="types"><span class="type">node</span></span>
Element prefab. Need to get it size
</li>
<li><span class="parameter">in_row</span>
<span class="types"><span class="type">number</span></span>
How many nodes in row can be placed
(<em>default</em> 1)
</li>
</ul>
</dd>
<dt>
<a name = "get_pos"></a>
<strong>get_pos(index)</strong>
</dt>
<dd>
Return pos for grid node index
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">index</span>
<span class="types"><span class="type">number</span></span>
The grid element index
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">vector3</span></span>
Node position
</ol>
</dd>
<dt>
<a name = "get_index"></a>
<strong>get_index(pos)</strong>
</dt>
<dd>
Return index for grid pos
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">pos</span>
<span class="types"><span class="type">vector3</span></span>
The node position in the grid
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">number</span></span>
The node index
</ol>
</dd>
<dt>
<a name = "get_index_by_node"></a>
<strong>get_index_by_node(node)</strong>
</dt>
<dd>
Return grid index by node
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">node</span>
<span class="types"><span class="type">node</span></span>
The gui node in the grid
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">number</span></span>
The node index
</ol>
</dd>
<dt>
<a name = "set_anchor"></a>
<strong>set_anchor(anchor)</strong>
</dt>
<dd>
Set grid anchor. Default anchor is equal to anchor of grid parent node
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">anchor</span>
<span class="types"><span class="type">vector3</span></span>
Anchor
</li>
</ul>
</dd>
<dt>
<a name = "add"></a>
<strong>add(item[, index])</strong>
</dt>
<dd>
Add new item to the grid
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">item</span>
<span class="types"><span class="type">node</span></span>
Gui node
</li>
<li><span class="parameter">index</span>
<span class="types"><span class="type">number</span></span>
The item position. By default add as last item
(<em>optional</em>)
</li>
</ul>
</dd>
<dt>
<a name = "remove"></a>
<strong>remove(index, is_shift_nodes)</strong>
</dt>
<dd>
Remove the item from the grid. Note that gui node will be not deleted
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">index</span>
<span class="types"><span class="type">number</span></span>
The grid node index to remove
</li>
<li><span class="parameter">is_shift_nodes</span>
<span class="types"><span class="type">bool</span></span>
If true, will shift nodes left after index
</li>
</ul>
</dd>
<dt>
<a name = "get_size"></a>
<strong>get_size()</strong>
</dt>
<dd>
Return grid content size
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">vector3</span></span>
The grid content size
</ol>
</dd>
<dt>
<a name = "get_all_pos"></a>
<strong>get_all_pos()</strong>
</dt>
<dd>
Return array of all node positions
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">vector3[]</span></span>
All grid node positions
</ol>
</dd>
<dt>
<a name = "set_position_function"></a>
<strong>set_position_function(callback)</strong>
</dt>
<dd>
Change set position function for grid nodes. It will call on
update poses on grid elements. Default: gui.set_position
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">callback</span>
<span class="types"><span class="type">function</span></span>
Function on node set position
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">druid.static_grid</span></span>
Current grid instance
</ol>
</dd>
<dt>
<a name = "clear"></a>
<strong>clear()</strong>
</dt>
<dd>
Clear grid nodes array. GUI nodes will be not deleted!
If you want to delete GUI nodes, use static_grid.nodes array before grid:clear
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">druid.static_grid</span></span>
Current grid instance
</ol>
</dd>
</dl>
<h2 class="section-header "><a name="Tables"></a>Tables</h2>
<dl class="function">
<dt>
<a name = "Events"></a>
<strong>Events</strong>
</dt>
<dd>
Component events
<h3>Fields:</h3>
<ul>
<li><span class="parameter">on_add_item</span>
<span class="types"><span class="type">druid_event</span></span>
On item add callback
</li>
<li><span class="parameter">on_remove_item</span>
<span class="types"><span class="type">druid_event</span></span>
On item remove callback
</li>
<li><span class="parameter">on_change_items</span>
<span class="types"><span class="type">druid_event</span></span>
On item add or remove callback
</li>
<li><span class="parameter">on_clear</span>
<span class="types"><span class="type">druid_event</span></span>
On grid clear callback
</li>
<li><span class="parameter">on_update_positions</span>
<span class="types"><span class="type">druid_event</span></span>
On update item positions callback
</li>
</ul>
</dd>
<dt>
<a name = "Fields"></a>
<strong>Fields</strong>
</dt>
<dd>
Component fields
<h3>Fields:</h3>
<ul>
<li><span class="parameter">parent</span>
<span class="types"><span class="type">node</span></span>
Parent gui node
</li>
<li><span class="parameter">nodes</span>
<span class="types"><span class="type">node[]</span></span>
List of all grid nodes
</li>
<li><span class="parameter">first_index</span>
<span class="types"><span class="type">number</span></span>
The first index of node in grid
</li>
<li><span class="parameter">last_index</span>
<span class="types"><span class="type">number</span></span>
The last index of node in grid
</li>
<li><span class="parameter">anchor</span>
<span class="types"><span class="type">vector3</span></span>
Item anchor
</li>
<li><span class="parameter">node_size</span>
<span class="types"><span class="type">vector3</span></span>
Item size
</li>
<li><span class="parameter">border</span>
<span class="types"><span class="type">vector4</span></span>
The size of item content
</li>
</ul>
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-09-29 23:46:16 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View File

@ -1,416 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Tables">Tables</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/druid.back_handler.html">druid.back_handler</a></li>
<li><a href="../modules/druid.blocker.html">druid.blocker</a></li>
<li><a href="../modules/druid.button.html">druid.button</a></li>
<li><a href="../modules/druid.drag.html">druid.drag</a></li>
<li><a href="../modules/druid.hover.html">druid.hover</a></li>
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
<li><a href="../modules/druid.static_grid.html">druid.static_grid</a></li>
<li><a href="../modules/druid.swipe.html">druid.swipe</a></li>
<li><strong>druid.text</strong></li>
<li><a href="../modules/component.html">component</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/druid_event.html">druid_event</a></li>
<li><a href="../modules/druid.checkbox.html">druid.checkbox</a></li>
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
<li><a href="../modules/druid.dynamic_grid.html">druid.dynamic_grid</a></li>
<li><a href="../modules/druid.input.html">druid.input</a></li>
<li><a href="../modules/druid.lang_text.html">druid.lang_text</a></li>
<li><a href="../modules/druid.progress.html">druid.progress</a></li>
<li><a href="../modules/druid.radio_group.html">druid.radio_group</a></li>
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/01-components.md.html">01-components</a></li>
<li><a href="../topics/02-creating_custom_components.md.html">Creating custom components</a></li>
<li><a href="../topics/03-styles.md.html">Styles</a></li>
<li><a href="../topics/04-druid_assets.md.html">Druid assets</a></li>
<li><a href="../topics/05-examples.md.html">Examples</a></li>
<li><a href="../topics/changelog.md.html">Druid 0.3.0:</a></li>
<li><a href="../topics/faq.md.html">faq</a></li>
<li><a href="../topics/README.md.html">README</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>druid.text</code></h1>
<p>Component to handle all GUI texts.</p>
<p> Druid text can adjust itself for text node size
Text will never will be outside of his text size (even multiline)</p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#init">init(node[, value[, no_adjust]])</a></td>
<td class="summary">Component init function</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_text_width">get_text_width([text])</a></td>
<td class="summary">Calculate text width with font with respect to trailing space</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_to">set_to(set_to)</a></td>
<td class="summary">Set text to text field</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_color">set_color(color)</a></td>
<td class="summary">Set color</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_alpha">set_alpha(alpha)</a></td>
<td class="summary">Set alpha</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_scale">set_scale(scale)</a></td>
<td class="summary">Set scale</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_pivot">set_pivot(pivot)</a></td>
<td class="summary">Set text pivot.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#is_multiline">is_multiline()</a></td>
<td class="summary">Return true, if text with line break</td>
</tr>
</table>
<h2><a href="#Tables">Tables</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#Events">Events</a></td>
<td class="summary">Component events</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Fields">Fields</a></td>
<td class="summary">Component fields</td>
</tr>
</table>
<br/>
<br/>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "init"></a>
<strong>init(node[, value[, no_adjust]])</strong>
</dt>
<dd>
Component init function
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">node</span>
<span class="types"><span class="type">node</span></span>
Gui text node
</li>
<li><span class="parameter">value</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
Initial text. Default value is node text from GUI scene.
(<em>optional</em>)
</li>
<li><span class="parameter">no_adjust</span>
<span class="types"><span class="type">bool</span></span>
If true, text will be not auto-adjust size
(<em>optional</em>)
</li>
</ul>
</dd>
<dt>
<a name = "get_text_width"></a>
<strong>get_text_width([text])</strong>
</dt>
<dd>
Calculate text width with font with respect to trailing space
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">text</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
(<em>optional</em>)
</li>
</ul>
</dd>
<dt>
<a name = "set_to"></a>
<strong>set_to(set_to)</strong>
</dt>
<dd>
Set text to text field
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">set_to</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
Text for node
</li>
</ul>
</dd>
<dt>
<a name = "set_color"></a>
<strong>set_color(color)</strong>
</dt>
<dd>
Set color
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">color</span>
<span class="types"><span class="type">vector4</span></span>
Color for node
</li>
</ul>
</dd>
<dt>
<a name = "set_alpha"></a>
<strong>set_alpha(alpha)</strong>
</dt>
<dd>
Set alpha
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">alpha</span>
<span class="types"><span class="type">number</span></span>
Alpha for node
</li>
</ul>
</dd>
<dt>
<a name = "set_scale"></a>
<strong>set_scale(scale)</strong>
</dt>
<dd>
Set scale
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">scale</span>
<span class="types"><span class="type">vector3</span></span>
Scale for node
</li>
</ul>
</dd>
<dt>
<a name = "set_pivot"></a>
<strong>set_pivot(pivot)</strong>
</dt>
<dd>
Set text pivot. Text will re-anchor inside
his text area
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">pivot</span>
<span class="types"><span class="type">gui.pivot</span></span>
Gui pivot constant
</li>
</ul>
</dd>
<dt>
<a name = "is_multiline"></a>
<strong>is_multiline()</strong>
</dt>
<dd>
Return true, if text with line break
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">bool</span></span>
Is text node with line break
</ol>
</dd>
</dl>
<h2 class="section-header "><a name="Tables"></a>Tables</h2>
<dl class="function">
<dt>
<a name = "Events"></a>
<strong>Events</strong>
</dt>
<dd>
Component events
<h3>Fields:</h3>
<ul>
<li><span class="parameter">on_set_text</span>
<span class="types"><span class="type">druid_event</span></span>
On set text callback
</li>
<li><span class="parameter">on_update_text_scale</span>
<span class="types"><span class="type">druid_event</span></span>
On adjust text size callback
</li>
<li><span class="parameter">on_set_pivot</span>
<span class="types"><span class="type">druid_event</span></span>
On change pivot callback
</li>
</ul>
</dd>
<dt>
<a name = "Fields"></a>
<strong>Fields</strong>
</dt>
<dd>
Component fields
<h3>Fields:</h3>
<ul>
<li><span class="parameter">node</span>
<span class="types"><span class="type">node</span></span>
Text node
</li>
<li><span class="parameter">pos</span>
<span class="types"><span class="type">vector3</span></span>
Current text position
</li>
<li><span class="parameter">start_scale</span>
<span class="types"><span class="type">vector3</span></span>
Initial text node scale
</li>
<li><span class="parameter">scale</span>
<span class="types"><span class="type">vector3</span></span>
Current text node scale
</li>
<li><span class="parameter">start_size</span>
<span class="types"><span class="type">vector3</span></span>
Initial text node size
</li>
<li><span class="parameter">text_area</span>
<span class="types"><span class="type">vector3</span></span>
Current text node available are
</li>
<li><span class="parameter">is_no_adjust</span>
<span class="types"><span class="type">bool</span></span>
Current text size adjust settings
</li>
<li><span class="parameter">color</span>
<span class="types"><span class="type">vector3</span></span>
Current text color
</li>
</ul>
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-09-29 23:46:16 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View File

@ -1,305 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Tables">Tables</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/druid.back_handler.html">druid.back_handler</a></li>
<li><a href="../modules/druid.blocker.html">druid.blocker</a></li>
<li><a href="../modules/druid.button.html">druid.button</a></li>
<li><a href="../modules/druid.drag.html">druid.drag</a></li>
<li><a href="../modules/druid.hover.html">druid.hover</a></li>
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
<li><a href="../modules/druid.static_grid.html">druid.static_grid</a></li>
<li><a href="../modules/druid.swipe.html">druid.swipe</a></li>
<li><a href="../modules/druid.text.html">druid.text</a></li>
<li><a href="../modules/component.html">component</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/druid_event.html">druid_event</a></li>
<li><a href="../modules/druid.checkbox.html">druid.checkbox</a></li>
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
<li><a href="../modules/druid.dynamic_grid.html">druid.dynamic_grid</a></li>
<li><a href="../modules/druid.input.html">druid.input</a></li>
<li><a href="../modules/druid.lang_text.html">druid.lang_text</a></li>
<li><a href="../modules/druid.progress.html">druid.progress</a></li>
<li><a href="../modules/druid.radio_group.html">druid.radio_group</a></li>
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
<li><strong>druid.timer</strong></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/01-components.md.html">01-components</a></li>
<li><a href="../topics/02-creating_custom_components.md.html">Creating custom components</a></li>
<li><a href="../topics/03-styles.md.html">Styles</a></li>
<li><a href="../topics/04-druid_assets.md.html">Druid assets</a></li>
<li><a href="../topics/05-examples.md.html">Examples</a></li>
<li><a href="../topics/changelog.md.html">Druid 0.3.0:</a></li>
<li><a href="../topics/faq.md.html">faq</a></li>
<li><a href="../topics/README.md.html">README</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>druid.timer</code></h1>
<p>Component to handle GUI timers.</p>
<p> Timer updating by game delta time. If game is not focused -
timer will be not updated.</p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#init">init(node, seconds_from[, seconds_to=0[, callback]])</a></td>
<td class="summary">Component init function</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_to">set_to(set_to)</a></td>
<td class="summary">Set text to text field</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_state">set_state(is_on)</a></td>
<td class="summary">Called when update</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_interval">set_interval(from, to)</a></td>
<td class="summary">Set time interval</td>
</tr>
</table>
<h2><a href="#Tables">Tables</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#Events">Events</a></td>
<td class="summary">Component events</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Fields">Fields</a></td>
<td class="summary">Component fields</td>
</tr>
</table>
<br/>
<br/>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "init"></a>
<strong>init(node, seconds_from[, seconds_to=0[, callback]])</strong>
</dt>
<dd>
Component init function
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">node</span>
<span class="types"><span class="type">node</span></span>
Gui text node
</li>
<li><span class="parameter">seconds_from</span>
<span class="types"><span class="type">number</span></span>
Start timer value in seconds
</li>
<li><span class="parameter">seconds_to</span>
<span class="types"><span class="type">number</span></span>
End timer value in seconds
(<em>default</em> 0)
</li>
<li><span class="parameter">callback</span>
<span class="types"><span class="type">function</span></span>
Function on timer end
(<em>optional</em>)
</li>
</ul>
</dd>
<dt>
<a name = "set_to"></a>
<strong>set_to(set_to)</strong>
</dt>
<dd>
Set text to text field
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">set_to</span>
<span class="types"><span class="type">number</span></span>
Value in seconds
</li>
</ul>
</dd>
<dt>
<a name = "set_state"></a>
<strong>set_state(is_on)</strong>
</dt>
<dd>
Called when update
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">is_on</span>
<span class="types"><span class="type">bool</span></span>
Timer enable state
</li>
</ul>
</dd>
<dt>
<a name = "set_interval"></a>
<strong>set_interval(from, to)</strong>
</dt>
<dd>
Set time interval
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">from</span>
<span class="types"><span class="type">number</span></span>
Start time in seconds
</li>
<li><span class="parameter">to</span>
<span class="types"><span class="type">number</span></span>
Target time in seconds
</li>
</ul>
</dd>
</dl>
<h2 class="section-header "><a name="Tables"></a>Tables</h2>
<dl class="function">
<dt>
<a name = "Events"></a>
<strong>Events</strong>
</dt>
<dd>
Component events
<h3>Fields:</h3>
<ul>
<li><span class="parameter">on_tick</span>
<span class="types"><span class="type">druid_event</span></span>
On timer tick callback. Fire every second
</li>
<li><span class="parameter">on_set_enabled</span>
<span class="types"><span class="type">druid_event</span></span>
On timer change enabled state callback
</li>
<li><span class="parameter">on_timer_end</span>
<span class="types"><span class="type">druid_event</span></span>
On timer end callback
</li>
</ul>
</dd>
<dt>
<a name = "Fields"></a>
<strong>Fields</strong>
</dt>
<dd>
Component fields
<h3>Fields:</h3>
<ul>
<li><span class="parameter">node</span>
<span class="types"><span class="type">node</span></span>
Trigger node
</li>
<li><span class="parameter">from</span>
<span class="types"><span class="type">number</span></span>
Initial timer value
</li>
<li><span class="parameter">target</span>
<span class="types"><span class="type">number</span></span>
Target timer value
</li>
<li><span class="parameter">value</span>
<span class="types"><span class="type">number</span></span>
Current timer value
</li>
</ul>
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-09-29 23:46:16 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View File

@ -1,251 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/druid.back_handler.html">druid.back_handler</a></li>
<li><a href="../modules/druid.blocker.html">druid.blocker</a></li>
<li><a href="../modules/druid.button.html">druid.button</a></li>
<li><a href="../modules/druid.drag.html">druid.drag</a></li>
<li><a href="../modules/druid.hover.html">druid.hover</a></li>
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
<li><a href="../modules/druid.static_grid.html">druid.static_grid</a></li>
<li><a href="../modules/druid.swipe.html">druid.swipe</a></li>
<li><a href="../modules/druid.text.html">druid.text</a></li>
<li><a href="../modules/component.html">component</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><strong>druid_event</strong></li>
<li><a href="../modules/druid.checkbox.html">druid.checkbox</a></li>
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
<li><a href="../modules/druid.dynamic_grid.html">druid.dynamic_grid</a></li>
<li><a href="../modules/druid.input.html">druid.input</a></li>
<li><a href="../modules/druid.lang_text.html">druid.lang_text</a></li>
<li><a href="../modules/druid.progress.html">druid.progress</a></li>
<li><a href="../modules/druid.radio_group.html">druid.radio_group</a></li>
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/01-components.md.html">01-components</a></li>
<li><a href="../topics/02-creating_custom_components.md.html">Creating custom components</a></li>
<li><a href="../topics/03-styles.md.html">Styles</a></li>
<li><a href="../topics/04-druid_assets.md.html">Druid assets</a></li>
<li><a href="../topics/05-examples.md.html">Examples</a></li>
<li><a href="../topics/changelog.md.html">Druid 0.3.0:</a></li>
<li><a href="../topics/faq.md.html">faq</a></li>
<li><a href="../topics/README.md.html">README</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>druid_event</code></h1>
<p>Lua event small library</p>
<p>
</p>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#Event">Event(initial_callback)</a></td>
<td class="summary">Event constructur</td>
</tr>
<tr>
<td class="name" nowrap><a href="#event:subscribe">event:subscribe(callback)</a></td>
<td class="summary">Subscribe callback on event</td>
</tr>
<tr>
<td class="name" nowrap><a href="#event:unsubscribe">event:unsubscribe(callback)</a></td>
<td class="summary">Unsubscribe callback on event</td>
</tr>
<tr>
<td class="name" nowrap><a href="#event:is_exist">event:is_exist()</a></td>
<td class="summary">Return true, if event have at lease one handler</td>
</tr>
<tr>
<td class="name" nowrap><a href="#event:clear">event:clear()</a></td>
<td class="summary">Clear the all event handlers</td>
</tr>
<tr>
<td class="name" nowrap><a href="#event:trigger">event:trigger(...)</a></td>
<td class="summary">Trigger the event and call all subscribed callbacks</td>
</tr>
</table>
<br/>
<br/>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "Event"></a>
<strong>Event(initial_callback)</strong>
</dt>
<dd>
Event constructur
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">initial_callback</span>
<span class="types"><span class="type">function</span></span>
Subscribe the callback on new event, if callback exist
</li>
</ul>
</dd>
<dt>
<a name = "event:subscribe"></a>
<strong>event:subscribe(callback)</strong>
</dt>
<dd>
Subscribe callback on event
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">callback</span>
<span class="types"><span class="type">function</span></span>
Callback itself
</li>
</ul>
</dd>
<dt>
<a name = "event:unsubscribe"></a>
<strong>event:unsubscribe(callback)</strong>
</dt>
<dd>
Unsubscribe callback on event
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">callback</span>
<span class="types"><span class="type">function</span></span>
Callback itself
</li>
</ul>
</dd>
<dt>
<a name = "event:is_exist"></a>
<strong>event:is_exist()</strong>
</dt>
<dd>
Return true, if event have at lease one handler
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">bool</span></span>
True if event have handlers
</ol>
</dd>
<dt>
<a name = "event:clear"></a>
<strong>event:clear()</strong>
</dt>
<dd>
Clear the all event handlers
</dd>
<dt>
<a name = "event:trigger"></a>
<strong>event:trigger(...)</strong>
</dt>
<dd>
Trigger the event and call all subscribed callbacks
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">...</span>
All event params
</li>
</ul>
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-09-29 23:46:16 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View File

@ -1,997 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/druid.back_handler.html">druid.back_handler</a></li>
<li><a href="../modules/druid.blocker.html">druid.blocker</a></li>
<li><a href="../modules/druid.button.html">druid.button</a></li>
<li><a href="../modules/druid.drag.html">druid.drag</a></li>
<li><a href="../modules/druid.hover.html">druid.hover</a></li>
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
<li><a href="../modules/druid.static_grid.html">druid.static_grid</a></li>
<li><a href="../modules/druid.swipe.html">druid.swipe</a></li>
<li><a href="../modules/druid.text.html">druid.text</a></li>
<li><a href="../modules/component.html">component</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/druid_event.html">druid_event</a></li>
<li><a href="../modules/druid.checkbox.html">druid.checkbox</a></li>
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
<li><a href="../modules/druid.dynamic_grid.html">druid.dynamic_grid</a></li>
<li><a href="../modules/druid.input.html">druid.input</a></li>
<li><a href="../modules/druid.lang_text.html">druid.lang_text</a></li>
<li><a href="../modules/druid.progress.html">druid.progress</a></li>
<li><a href="../modules/druid.radio_group.html">druid.radio_group</a></li>
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><strong>druid_instance</strong></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/01-components.md.html">01-components</a></li>
<li><a href="../topics/02-creating_custom_components.md.html">Creating custom components</a></li>
<li><a href="../topics/03-styles.md.html">Styles</a></li>
<li><a href="../topics/04-druid_assets.md.html">Druid assets</a></li>
<li><a href="../topics/05-examples.md.html">Examples</a></li>
<li><a href="../topics/changelog.md.html">Druid 0.3.0:</a></li>
<li><a href="../topics/faq.md.html">faq</a></li>
<li><a href="../topics/README.md.html">README</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>druid_instance</code></h1>
<p>Instance of Druid.</p>
<p> Make one instance per gui_script with next code:</p>
<pre>
<span class="keyword">local</span> druid = <span class="global">require</span>(<span class="string">"druid.druid"</span>)
<span class="keyword">function</span> init(self)
self.druid = druid.new(self)
<span class="keyword">local</span> button = self.druid:new_button(...)
<span class="keyword">end</span>
</pre>
<p> Learn Druid instance function here</p>
<h3>See also:</h3>
<ul>
<li><a href="../modules/druid.button.html#">druid.button</a></li>
<li><a href="../modules/druid.blocker.html#">druid.blocker</a></li>
<li><a href="../modules/druid.back_handler.html#">druid.back_handler</a></li>
<li><a href="../modules/druid.input.html#">druid.input</a></li>
<li><a href="../modules/druid.text.html#">druid.text</a></li>
<li><a href="../modules/druid.lang_text.html#">druid.lang_text</a></li>
<li><a href="../modules/druid.timer.html#">druid.timer</a></li>
<li><a href="../modules/druid.progress.html#">druid.progress</a></li>
<li><a href="../modules/druid.static_grid.html#">druid.static_grid</a></li>
<li><a href="../modules/druid.dynamic_grid.html#">druid.dynamic_grid</a></li>
<li><a href="../modules/druid.scroll.html#">druid.scroll</a></li>
<li><a href="../modules/druid.slider.html#">druid.slider</a></li>
<li><a href="../modules/druid.checkbox.html#">druid.checkbox</a></li>
<li><a href="../modules/druid.checkbox_group.html#">druid.checkbox_group</a></li>
<li><a href="../modules/druid.radio_group.html#">druid.radio_group</a></li>
<li><a href="../modules/druid.swipe.html#">druid.swipe</a></li>
<li><a href="../modules/druid.drag.html#">druid.drag</a></li>
</ul>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#druid:initialize">druid:initialize(table, table)</a></td>
<td class="summary">Druid class constructor</td>
</tr>
<tr>
<td class="name" nowrap><a href="#druid:create">druid:create(component, ...)</a></td>
<td class="summary">Create new druid component</td>
</tr>
<tr>
<td class="name" nowrap><a href="#druid:final">druid:final()</a></td>
<td class="summary">Call on final function on gui_script.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#druid:remove">druid:remove(component)</a></td>
<td class="summary">Remove component from druid instance.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#druid:update">druid:update(dt)</a></td>
<td class="summary">Druid update function</td>
</tr>
<tr>
<td class="name" nowrap><a href="#druid:on_input">druid:on_input(action_id, action)</a></td>
<td class="summary">Druid on_input function</td>
</tr>
<tr>
<td class="name" nowrap><a href="#druid:on_message">druid:on_message(message_id, message, sender)</a></td>
<td class="summary">Druid on_message function</td>
</tr>
<tr>
<td class="name" nowrap><a href="#druid:on_focus_lost">druid:on_focus_lost()</a></td>
<td class="summary">Druid on focus lost interest function.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#druid:on_focus_gained">druid:on_focus_gained()</a></td>
<td class="summary">Druid on focus gained interest function.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#druid:on_layout_change">druid:on_layout_change()</a></td>
<td class="summary">Druid on layout change function.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#druid.on_language_change">druid.on_language_change()</a></td>
<td class="summary">Druid on language change.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#druid:new_button">druid:new_button(...)</a></td>
<td class="summary">Create button basic component</td>
</tr>
<tr>
<td class="name" nowrap><a href="#druid:new_blocker">druid:new_blocker(...)</a></td>
<td class="summary">Create blocker basic component</td>
</tr>
<tr>
<td class="name" nowrap><a href="#druid:new_back_handler">druid:new_back_handler(...)</a></td>
<td class="summary">Create back_handler basic component</td>
</tr>
<tr>
<td class="name" nowrap><a href="#druid:new_hover">druid:new_hover(...)</a></td>
<td class="summary">Create hover basic component</td>
</tr>
<tr>
<td class="name" nowrap><a href="#druid:new_text">druid:new_text(...)</a></td>
<td class="summary">Create text basic component</td>
</tr>
<tr>
<td class="name" nowrap><a href="#druid:new_grid">druid:new_grid(...)</a></td>
<td class="summary">Create grid basic component
Deprecated</td>
</tr>
<tr>
<td class="name" nowrap><a href="#druid:new_static_grid">druid:new_static_grid(...)</a></td>
<td class="summary">Create static grid basic component</td>
</tr>
<tr>
<td class="name" nowrap><a href="#druid:new_scroll">druid:new_scroll(...)</a></td>
<td class="summary">Create scroll basic component</td>
</tr>
<tr>
<td class="name" nowrap><a href="#druid:new_swipe">druid:new_swipe(...)</a></td>
<td class="summary">Create swipe basic component</td>
</tr>
<tr>
<td class="name" nowrap><a href="#druid:new_drag">druid:new_drag(...)</a></td>
<td class="summary">Create drag basic component</td>
</tr>
<tr>
<td class="name" nowrap><a href="#druid:new_dynamic_grid">druid:new_dynamic_grid(...)</a></td>
<td class="summary">Create dynamic grid component</td>
</tr>
<tr>
<td class="name" nowrap><a href="#druid:new_lang_text">druid:new_lang_text(...)</a></td>
<td class="summary">Create lang_text component</td>
</tr>
<tr>
<td class="name" nowrap><a href="#druid:new_slider">druid:new_slider(...)</a></td>
<td class="summary">Create slider component</td>
</tr>
<tr>
<td class="name" nowrap><a href="#druid:new_checkbox">druid:new_checkbox(...)</a></td>
<td class="summary">Create checkbox component</td>
</tr>
<tr>
<td class="name" nowrap><a href="#druid:new_input">druid:new_input(...)</a></td>
<td class="summary">Create input component</td>
</tr>
<tr>
<td class="name" nowrap><a href="#druid:new_checkbox_group">druid:new_checkbox_group(...)</a></td>
<td class="summary">Create checkbox_group component</td>
</tr>
<tr>
<td class="name" nowrap><a href="#druid:new_radio_group">druid:new_radio_group(...)</a></td>
<td class="summary">Create radio_group component</td>
</tr>
<tr>
<td class="name" nowrap><a href="#druid:new_timer">druid:new_timer(...)</a></td>
<td class="summary">Create timer component</td>
</tr>
<tr>
<td class="name" nowrap><a href="#druid:new_progress">druid:new_progress(...)</a></td>
<td class="summary">Create progress component</td>
</tr>
</table>
<br/>
<br/>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "druid:initialize"></a>
<strong>druid:initialize(table, table)</strong>
</dt>
<dd>
Druid class constructor
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">table</span>
<span class="types"><span class="type">style</span></span>
Druid style module
</li>
<li><span class="parameter">table</span>
<span class="types"><span class="type">style</span></span>
Druid style module
</li>
</ul>
</dd>
<dt>
<a name = "druid:create"></a>
<strong>druid:create(component, ...)</strong>
</dt>
<dd>
Create new druid component
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">component</span>
<span class="types"><span class="type">Component</span></span>
Component module
</li>
<li><span class="parameter">...</span>
<span class="types"><span class="type">args</span></span>
Other component params to pass it to component:init function
</li>
</ul>
</dd>
<dt>
<a name = "druid:final"></a>
<strong>druid:final()</strong>
</dt>
<dd>
Call on final function on gui<em>script. It will call on</em>remove
on all druid components
</dd>
<dt>
<a name = "druid:remove"></a>
<strong>druid:remove(component)</strong>
</dt>
<dd>
Remove component from druid instance.
Component <code>on_remove</code> function will be invoked, if exist.
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">component</span>
<span class="types"><span class="type">Component</span></span>
Component instance
</li>
</ul>
</dd>
<dt>
<a name = "druid:update"></a>
<strong>druid:update(dt)</strong>
</dt>
<dd>
Druid update function
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">dt</span>
<span class="types"><span class="type">number</span></span>
Delta time
</li>
</ul>
</dd>
<dt>
<a name = "druid:on_input"></a>
<strong>druid:on_input(action_id, action)</strong>
</dt>
<dd>
Druid on_input function
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">action_id</span>
<span class="types"><span class="type">hash</span></span>
Action<em>id from on</em>input
</li>
<li><span class="parameter">action</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
Action from on_input
</li>
</ul>
</dd>
<dt>
<a name = "druid:on_message"></a>
<strong>druid:on_message(message_id, message, sender)</strong>
</dt>
<dd>
Druid on_message function
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">message_id</span>
<span class="types"><span class="type">hash</span></span>
Message<em>id from on</em>message
</li>
<li><span class="parameter">message</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
Message from on_message
</li>
<li><span class="parameter">sender</span>
<span class="types"><span class="type">hash</span></span>
Sender from on_message
</li>
</ul>
</dd>
<dt>
<a name = "druid:on_focus_lost"></a>
<strong>druid:on_focus_lost()</strong>
</dt>
<dd>
Druid on focus lost interest function.
This one called by on<em>window</em>callback by global window listener
</dd>
<dt>
<a name = "druid:on_focus_gained"></a>
<strong>druid:on_focus_gained()</strong>
</dt>
<dd>
Druid on focus gained interest function.
This one called by on<em>window</em>callback by global window listener
</dd>
<dt>
<a name = "druid:on_layout_change"></a>
<strong>druid:on_layout_change()</strong>
</dt>
<dd>
Druid on layout change function.
Called on update gui layout
</dd>
<dt>
<a name = "druid.on_language_change"></a>
<strong>druid.on_language_change()</strong>
</dt>
<dd>
Druid on language change.
This one called by global gruid.on<em>language</em>change, but can be
call manualy to update all translations
</dd>
<dt>
<a name = "druid:new_button"></a>
<strong>druid:new_button(...)</strong>
</dt>
<dd>
Create button basic component
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">...</span>
<span class="types"><span class="type">args</span></span>
button init args
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Component</span></span>
button component
</ol>
</dd>
<dt>
<a name = "druid:new_blocker"></a>
<strong>druid:new_blocker(...)</strong>
</dt>
<dd>
Create blocker basic component
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">...</span>
<span class="types"><span class="type">args</span></span>
blocker init args
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Component</span></span>
blocker component
</ol>
</dd>
<dt>
<a name = "druid:new_back_handler"></a>
<strong>druid:new_back_handler(...)</strong>
</dt>
<dd>
Create back_handler basic component
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">...</span>
<span class="types"><span class="type">args</span></span>
back_handler init args
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Component</span></span>
back_handler component
</ol>
</dd>
<dt>
<a name = "druid:new_hover"></a>
<strong>druid:new_hover(...)</strong>
</dt>
<dd>
Create hover basic component
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">...</span>
<span class="types"><span class="type">args</span></span>
hover init args
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Component</span></span>
hover component
</ol>
</dd>
<dt>
<a name = "druid:new_text"></a>
<strong>druid:new_text(...)</strong>
</dt>
<dd>
Create text basic component
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">...</span>
<span class="types"><span class="type">args</span></span>
text init args
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Component</span></span>
text component
</ol>
</dd>
<dt>
<a name = "druid:new_grid"></a>
<strong>druid:new_grid(...)</strong>
</dt>
<dd>
Create grid basic component
Deprecated
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">...</span>
<span class="types"><span class="type">args</span></span>
grid init args
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Component</span></span>
grid component
</ol>
</dd>
<dt>
<a name = "druid:new_static_grid"></a>
<strong>druid:new_static_grid(...)</strong>
</dt>
<dd>
Create static grid basic component
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">...</span>
<span class="types"><span class="type">args</span></span>
grid init args
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Component</span></span>
grid component
</ol>
</dd>
<dt>
<a name = "druid:new_scroll"></a>
<strong>druid:new_scroll(...)</strong>
</dt>
<dd>
Create scroll basic component
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">...</span>
<span class="types"><span class="type">args</span></span>
scroll init args
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Component</span></span>
scroll component
</ol>
</dd>
<dt>
<a name = "druid:new_swipe"></a>
<strong>druid:new_swipe(...)</strong>
</dt>
<dd>
Create swipe basic component
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">...</span>
<span class="types"><span class="type">args</span></span>
swipe init args
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Component</span></span>
swipe component
</ol>
</dd>
<dt>
<a name = "druid:new_drag"></a>
<strong>druid:new_drag(...)</strong>
</dt>
<dd>
Create drag basic component
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">...</span>
<span class="types"><span class="type">args</span></span>
drag init args
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Componetn</span></span>
drag component
</ol>
</dd>
<dt>
<a name = "druid:new_dynamic_grid"></a>
<strong>druid:new_dynamic_grid(...)</strong>
</dt>
<dd>
Create dynamic grid component
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">...</span>
<span class="types"><span class="type">args</span></span>
grid init args
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Component</span></span>
grid component
</ol>
</dd>
<dt>
<a name = "druid:new_lang_text"></a>
<strong>druid:new_lang_text(...)</strong>
</dt>
<dd>
Create lang_text component
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">...</span>
<span class="types"><span class="type">args</span></span>
lang_text init args
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Component</span></span>
lang_text component
</ol>
</dd>
<dt>
<a name = "druid:new_slider"></a>
<strong>druid:new_slider(...)</strong>
</dt>
<dd>
Create slider component
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">...</span>
<span class="types"><span class="type">args</span></span>
slider init args
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Component</span></span>
slider component
</ol>
</dd>
<dt>
<a name = "druid:new_checkbox"></a>
<strong>druid:new_checkbox(...)</strong>
</dt>
<dd>
Create checkbox component
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">...</span>
<span class="types"><span class="type">args</span></span>
checkbox init args
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Component</span></span>
checkbox component
</ol>
</dd>
<dt>
<a name = "druid:new_input"></a>
<strong>druid:new_input(...)</strong>
</dt>
<dd>
Create input component
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">...</span>
<span class="types"><span class="type">args</span></span>
input init args
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Component</span></span>
input component
</ol>
</dd>
<dt>
<a name = "druid:new_checkbox_group"></a>
<strong>druid:new_checkbox_group(...)</strong>
</dt>
<dd>
Create checkbox_group component
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">...</span>
<span class="types"><span class="type">args</span></span>
checkbox_group init args
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Component</span></span>
checkbox_group component
</ol>
</dd>
<dt>
<a name = "druid:new_radio_group"></a>
<strong>druid:new_radio_group(...)</strong>
</dt>
<dd>
Create radio_group component
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">...</span>
<span class="types"><span class="type">args</span></span>
radio_group init args
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Component</span></span>
radio_group component
</ol>
</dd>
<dt>
<a name = "druid:new_timer"></a>
<strong>druid:new_timer(...)</strong>
</dt>
<dd>
Create timer component
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">...</span>
<span class="types"><span class="type">args</span></span>
timer init args
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Component</span></span>
timer component
</ol>
</dd>
<dt>
<a name = "druid:new_progress"></a>
<strong>druid:new_progress(...)</strong>
</dt>
<dd>
Create progress component
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">...</span>
<span class="types"><span class="type">args</span></span>
progress init args
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Component</span></span>
progress component
</ol>
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-09-29 23:46:16 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View File

@ -1,513 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Button">Button </a></li>
<li><a href="#Text">Text </a></li>
<li><a href="#Blocker">Blocker </a></li>
<li><a href="#Back_Handler">Back Handler </a></li>
<li><a href="#Lang_text">Lang text </a></li>
<li><a href="#Scroll">Scroll </a></li>
<li><a href="#Progress">Progress </a></li>
<li><a href="#Slider">Slider </a></li>
<li><a href="#Input">Input </a></li>
<li><a href="#Checkbox">Checkbox </a></li>
<li><a href="#Checkbox_group">Checkbox group </a></li>
<li><a href="#Radio_group">Radio group </a></li>
<li><a href="#Timer">Timer </a></li>
<li><a href="#Static_Grid">Static Grid </a></li>
<li><a href="#Dynamic_Grid">Dynamic Grid </a></li>
<li><a href="#Hover">Hover </a></li>
<li><a href="#Swipe">Swipe </a></li>
<li><a href="#Drag">Drag </a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><strong>01-components</strong></li>
<li><a href="../topics/02-creating_custom_components.md.html">Creating custom components</a></li>
<li><a href="../topics/03-styles.md.html">Styles</a></li>
<li><a href="../topics/04-druid_assets.md.html">Druid assets</a></li>
<li><a href="../topics/05-examples.md.html">Examples</a></li>
<li><a href="../topics/changelog.md.html">Druid 0.3.0:</a></li>
<li><a href="../topics/faq.md.html">faq</a></li>
<li><a href="../topics/README.md.html">README</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/druid.back_handler.html">druid.back_handler</a></li>
<li><a href="../modules/druid.blocker.html">druid.blocker</a></li>
<li><a href="../modules/druid.button.html">druid.button</a></li>
<li><a href="../modules/druid.drag.html">druid.drag</a></li>
<li><a href="../modules/druid.hover.html">druid.hover</a></li>
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
<li><a href="../modules/druid.static_grid.html">druid.static_grid</a></li>
<li><a href="../modules/druid.swipe.html">druid.swipe</a></li>
<li><a href="../modules/druid.text.html">druid.text</a></li>
<li><a href="../modules/component.html">component</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/druid_event.html">druid_event</a></li>
<li><a href="../modules/druid.checkbox.html">druid.checkbox</a></li>
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
<li><a href="../modules/druid.dynamic_grid.html">druid.dynamic_grid</a></li>
<li><a href="../modules/druid.input.html">druid.input</a></li>
<li><a href="../modules/druid.lang_text.html">druid.lang_text</a></li>
<li><a href="../modules/druid.progress.html">druid.progress</a></li>
<li><a href="../modules/druid.radio_group.html">druid.radio_group</a></li>
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
</ul>
</div>
<div id="content">
<h1>Druid components</h1>
<p><a name="Button"></a></p>
<h2>Button</h2>
<p><a href="https://insality.github.io/druid/modules/druid.button.html">Button API here</a></p>
<h3>Overview</h3>
<p>Basic Druid input component. Handle input on node and provide different callbacks on touch events.</p>
<h3>Setup</h3>
<p>Create button with druid: <code>button = druid:new_button(node_name, callback, [params], [animation_node])</code>
Where node name is name of node from GUI scene. You can use <code>node_name</code> as input trigger zone and point another node for animation via <code>animation_node</code></p>
<h3>Usecase</h3>
<p><em>fill example usecases</em></p>
<h3>Notes</h3>
<p>- Button callback have next params: (self, params, button_instance)</p>
<pre>
- **self** - Druid self context
- **params** - Additional params, specified on button creating
- **button_instance** - button itself
</pre>
<p>- You can set <em>params</em> on button callback on button creating: <code>druid:new_button(&quot;node_name&quot;, callback, params)</code>. This <em>params</em> will pass in callback as second argument
- Button have next events:</p>
<pre>
- **on_click** - basic button callback
- **on_repeated_click** - repeated click callback, <span class="keyword">while</span> holding the button, don<span class="string">'t trigger if callback is empty
- **on_long_click** - callback on long button tap, don'</span>t trigger <span class="keyword">if</span> callback is empty
- **on_hold_click** - hold callback, before long_click trigger, don<span class="string">'t trigger if callback is empty
- **on_double_click** - different callback, if tap button 2+ in row, don'</span>t trigger <span class="keyword">if</span> callback is empty
</pre>
<p>- Click event will not trigger, if between pressed and released state cursor was outside of node zone
- 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 <a href="../modules/druid.button.html#set_click_zone">button:set_click_zone</a> to restrict button click zone
- Button can have key trigger to use then by key: <a href="../modules/druid.button.html#set_key_trigger">button:set_key_trigger</a>
- Animation node can be used for example to animate small icon on big panel. Node name of trigger zone will be <code>big panel</code> and animation node will be <code>small icon</code></p>
<p><a name="Text"></a></p>
<h2>Text</h2>
<p><a href="https://insality.github.io/druid/modules/druid.text.html">Text API here</a></p>
<h3>Overview</h3>
<p>Basic Druid text component. Text components by default have the text size adjusting.</p>
<h3>Setup</h3>
<p>Create text node with druid: <code>text = druid:new_text(node_name, [initial_value], [is_disable_size_adjust])</code></p>
<h3>Notes</h3>
<p>- 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 <code>is_no_adjust</code> to <em>true</em></p>
<p><img src="../media/text_autosize.png" alt=""/></p>
<ul>
<li>Text pivot can be changed with <a href="../modules/druid.text.html#set_pivot">text:set_pivot</a>, and text will save their position inside their text size box:</li>
</ul>
<p><img src="../media/text_anchor.gif" alt=""/></p>
<p><a name="Blocker"></a></p>
<h2>Blocker</h2>
<p><a href="https://insality.github.io/druid/modules/druid.blocker.html">Blocker API here</a></p>
<h3>Overview</h3>
<p>Druid component for block input. Use it to block input in special zone.</p>
<h3>Setup</h3>
<p>Create blocker component with druid: <code>druid:new_blocker(node_name)</code></p>
<h3>Notes</h3>
<p>Explanation:
<img src="../media/blocker_scheme.png" alt=""/></p>
<p>Blue zone is <strong>button</strong> with close_window callback</p>
<p>Yellow zone is blocker with window content</p>
<p>So you can do the safe zones, when you have the big buttons</p>
<p><a name="Back_Handler"></a></p>
<h2>Back Handler</h2>
<p><a href="https://insality.github.io/druid/modules/druid.back_handler.html">Back handler API here</a></p>
<h3>Overview</h3>
<p>Component to handle back button. It handle Android back button and Backspace key. Key triggers in <code>input.binding</code> should be setup for correct working.</p>
<h3>Setup</h3>
<p>Setup callback with <code>druid:new_back_handler(callback)</code></p>
<h3>Notes</h3>
<p><a name="Lang_text"></a></p>
<h2>Lang text</h2>
<p><a href="https://insality.github.io/druid/modules/druid.lang_text.html">Lang text API here</a></p>
<h3>Overview</h3>
<p>Wrap on Text component to handle localization. It uses druid get<em>text</em>function to set text by it's id</p>
<h3>Setup</h3>
<p>Create lang text component with druid <code>text = druid:new_lang_text(node_name, locale_id)</code></p>
<h3>Notes</h3>
<p><a name="Scroll"></a></p>
<h2>Scroll</h2>
<p><a href="https://insality.github.io/druid/modules/druid.scroll.html">Scroll API here</a></p>
<h3>Overview</h3>
<p>Basic Druid scroll component. Handle all scrolling stuff in druid GUI</p>
<h3>Setup</h3>
<p>Create scroll component with druid: <code>scroll = druid:new_scroll(view_node, content_node)</code>.</p>
<p><em>View</em>node_ - is static part. It capturing user input and recognize scrolling touches</p>
<p><em>Content</em>node_ - is dynamic part. This node will change position by scroll system</p>
<p>Initial scroll size will be equal to <em>content</em>node_ node size. The initial view box will be equal to <em>view</em>node_ node size</p>
<p>Usually, Place <em>view</em>node_ and as children add <em>content</em>node_:
<img src="../media/scroll_scheme.png" alt=""/>
<img src="../media/scroll_outline.png" alt=""/></p>
<p>*Here content<em>node below view</em>node, in game content_node be able to scroll left until end*</p>
<h3>Notes</h3>
<p>- Scroll by default style have inertion and extra size for strecthing effect. It can be adjust via scroll <a href="https://insality.github.io/druid/modules/druid.scroll.html#Style">style settings</a>
- You can setup "points of interest". Scroll always will be centered on closes point of interest. It is able to create slider without inertion and points of interest on each scroll element.
- Scroll have next events:</p>
<pre>
- *on_scroll* (self, position) On scroll move callback
- *on_scroll_to* (self, position, is_instant) On scroll_to <span class="keyword">function</span> callback
- *on_point_scroll* (self, item_index, position) On scroll_to_index <span class="keyword">function</span> callback
</pre>
<p>- You can adjust scroll content size by <code>scroll:set_size(node_size)</code>. It will setup new size to <em>content node</em>
- You can enabled or disable inertion mode via <code>scroll:set_intert(state)</code>
- You can adjust extra stretch size via <a href="../modules/druid.scroll.html#set_extra_stretch_size">scroll:set_extra_stretch_size</a>
- Multitouch is required for scroll. Scroll is correctly handling touch_id swap while dragging scroll</p>
<p><a name="Progress"></a></p>
<h2>Progress</h2>
<p><a href="https://insality.github.io/druid/modules/druid.progress.html">Progress API here</a></p>
<h3>Overview</h3>
<p>Basic Druid progress bar component</p>
<h3>Setup</h3>
<p>Create progress bar component with druid: <code>progress = druid:new_progress(node_name, key, init_value)</code></p>
<p>Node name should have maximum node size, so in GUI scene, node_name should be fully filled.
Key is value from druid const: const.SIDE.X (or just "x") or const.SIDE.Y (or just "y")</p>
<h3>Notes</h3>
<p>- Progress correct working with 9slice nodes, it trying to set size by <em>set</em>size_ first, if it is not possible, it set up sizing via <em>set</em>scale_
- Progress bar can fill only by vertical or horizontal size. If you want make diagonal progress bar, just rotate node in GUI scene
- If you have glitchy or dark texture bug with progress bar, try to disable mipmaps in your texture profiles</p>
<p><a name="Slider"></a></p>
<h2>Slider</h2>
<p><a href="https://insality.github.io/druid/modules/druid.slider.html">Slider API here</a></p>
<h3>Overview</h3>
<p>Basic Druid slider component</p>
<h3>Setup</h3>
<p>Create slider component with druid: <code>slider = druid:new_slider(node_name, end_pos, callback)</code></p>
<p>Pin node (node_name in params) should be placed in zero position (initial). It will be available to mode Pin node between start pos and end pos. </p>
<h3>Notes</h3>
<p>- You can setup points of interests on slider via <a href="../modules/druid.slider.html#set_steps">slider:set_steps</a>. If steps are exist, slider values will be only from this steps (notched slider)
- For now, start pos and end pos should be on vertical or horizontal line (their x or y value should be equal)</p>
<p><a name="Input"></a></p>
<h2>Input</h2>
<p><a href="https://insality.github.io/druid/modules/druid.input.html">Input API here</a></p>
<h3>Overview</h3>
<p>Basic Druid text input component</p>
<h3>Setup</h3>
<p>Create input component with druid: <code>input = druid:new_input(button_node_name, text_node_name, keyboard_type)</code></p>
<h3>Notes</h3>
<p>- Input component handle user text input. Input contains from button and text components. Button needed for selecting/unselecting input field
- Long click on input field for clear and select input field (clearing can be disable via styles)
- Click outside of button to unselect input field
- On focus lost (game minimized) input field will be unselected
- You can setup max length of the text
- You can setup allowed characters. On add not allowed characters <code>on_input_wrong</code> will be called. By default it cause simple shake animation
- The keyboard for input will not show on mobile HTML5. So input field in mobile HTML5 is not working now
- To make work different keyboard type, make sure value in game.project Android:InputMethod set to HidderInputField (https://defold.com/manuals/project-settings/#input-method)</p>
<p><a name="Checkbox"></a></p>
<h2>Checkbox</h2>
<p><a href="https://insality.github.io/druid/modules/druid.checkbox.html">Checkbox API here</a></p>
<h3>Overview</h3>
<p>Basic Druid checkbox component.</p>
<h3>Setup</h3>
<p>Create checkbox component with druid: <code>checkbox = druid:new_checkbox(node, callback)</code></p>
<h3>Notes</h3>
<p>- Checkbox uses button to handle click
- You can setup another node to handle input with click_node arg in component init: <code>druid:new_checkbox(node, callback, [click_node])</code></p>
<p><a name="Checkbox_group"></a></p>
<h2>Checkbox group</h2>
<p><a href="https://insality.github.io/druid/modules/druid.checkbox_group.html">Checkbox group API here</a></p>
<h3>Overview</h3>
<p>Several checkboxes in one group</p>
<h3>Setup</h3>
<p>Create checkbox_group component with druid: <code>group = druid:new_checkbox_group(nodes[], callback)</code></p>
<h3>Notes</h3>
<p>- Callback arguments: <code>function(self, checkbox_index)</code>. Index is equals in <em>nodes[]</em> array in component constructor
- You can get/set checkbox_group state with <code>group:set_state()</code> and <code>group:get_state()</code></p>
<p><a name="Radio_group"></a></p>
<h2>Radio group</h2>
<p><a href="https://insality.github.io/druid/modules/druid.radio_group.html">Radio group API here</a></p>
<h3>Overview</h3>
<p>Several checkboxes in one group with single choice</p>
<h3>Setup</h3>
<p>Create radio_group component with druid: <code>group = druid:new_radio_group(nodes[], callback)</code></p>
<h3>Notes</h3>
<p>- Callback arguments: <code>function(self, checkbox_index)</code>. Index is equals in <em>nodes[]</em> array in component constructor
- You can get/set radio_group state with <code>group:set_state()</code> and <code>group:get_state()</code>
- Only different from checkbox_group: on click another checkboxes in this group will be unchecked</p>
<p><a name="Timer"></a></p>
<h2>Timer</h2>
<p><a href="https://insality.github.io/druid/modules/druid.timer.html">Timer API here</a></p>
<h3>Overview</h3>
<p>Handle timer work on gui text node</p>
<h3>Setup</h3>
<p>Create timer component with druid: <code>timer = druid:new_timer(text_node, from_seconds, to_seconds, callback)</code></p>
<h3>Notes</h3>
<p>- Timer fires callback, when timer value equals to <em>to</em>seconds_
- Timer will setup text node with current timer value
- Timer uses update function to handle time</p>
<p><a name="Static_Grid"></a></p>
<h2>Static Grid</h2>
<p><a href="https://insality.github.io/druid/modules/druid.static_grid.html">Static Grid API here</a></p>
<h3>Overview</h3>
<p>Component for manage node positions.
Static grid have constant node size, so it possible to calculate node positions before placement. Nodes can be placed with gaps.
Static grid can shift elements on add/remove functions.</p>
<h3>Setup</h3>
<p>Create component with druid: <code>grid = druid:new_static_grid(parent_node, prefab_node, max_in_row_elements)</code></p>
<h3>Notes</h3>
<p>- On <em>add node</em> grid will set node parent to <em>parent</em>node_
- You can get array of position of every element for setup points of interest in scroll component
- You can get size of all elements for setup size in scroll component
- You can also bind the grid to the scroll component for auto resize scroll content size
- Pivot of parent_node matter for node placement
- <em>Prefab node</em> used to get node size and anchor
- You can point *position_function* for animations with <em>static</em>grid:set<em>position</em>function(node, pos)_ callback. Default - *gui.set_position()*</p>
<p><a name="Dynamic_Grid"></a></p>
<h2>Dynamic Grid</h2>
<p><a href="https://insality.github.io/druid/modules/druid.dynamic_grid.html">Dynamic Grid API here</a></p>
<h3>Overview</h3>
<p>Component for manage node positions with different node sizes.
Unlike Static Grid, Dynamic Grid can place nodes only in one row or in one column.
Dynamic Grid can't have gaps between elements - you will get error, if try spawn element far away from others.
Dynamic Grid should have <strong>West</strong>, <strong>East</strong>, <strong>South</strong> or <strong>North</strong> pivot (vertical or horizontal element placement)</p>
<h3>Setup</h3>
<p>Create component with druid: <code>grid = druid:new_dynamic_grid(parent_node)</code></p>
<p>Check the <em>parent</em>node_ have correct pivot point. You will get the error otherwise.</p>
<h3>Notes</h3>
<p>- On <em>add node</em> grid will set node parent to <em>parent</em>node_
- You can get array of position of every element for setup points of interest in scroll component
- You can get size of all elements for setup size in scroll component
- You can also bind the grid to the scroll component for auto resize scroll content size
- Pivot of parent<em>node matter for node placement
- You can point *position</em>function* for animations with <em>static</em>grid:set<em>position</em>function(node, pos)_ callback. Default - *gui.set_position()*
- First node placed at Grid pivot point. Other nodes placed nearby of other nodes.
- On <em>add/remove</em> nodes always shifted. You can point the shift side in this functions (*is<em>shift</em>left* boolean argument)</p>
<p><a name="Hover"></a></p>
<h2>Hover</h2>
<p><a href="https://insality.github.io/druid/modules/druid.hover.html">Hover API here</a></p>
<h3>Overview</h3>
<p>System Druid component, handle hover node state.</p>
<h3>Setup</h3>
<p>Create hover component with druid: <code>hover = druid:new_hover(node, callback)</code></p>
<h3>Notes</h3>
<p>- By default, hover handles <em>hover event</em> with pressed touch action_id. So it's mean, what mouse or touch have to be pressed
- On desktop platforms there is <em>on</em>mouse<em>hover</em> event. It's event on mouse hover without any action id
- By default, assume what node is on not hovered state (both <em>hover</em> and <em>mouse</em>hover_)</p>
<p><a name="Swipe"></a></p>
<h2>Swipe</h2>
<p><a href="https://insality.github.io/druid/modules/druid.swipe.html">Swipe API here</a></p>
<h3>Overview</h3>
<p>System Druid component, handle swipe actions on node</p>
<h3>Setup</h3>
<p>Create swipe component with druid: <code>hover = druid:new_swipe(node, swipe_callback)</code></p>
<h3>Notes</h3>
<p>- Swipe callback have next params: (self, swipe_side, distance, time)</p>
<pre>
- **self** - Druid self context
- **swipe_side**: *<span class="global">string</span>* - values from [<span class="string">"up"</span>, <span class="string">"down"</span>, <span class="string">"left"</span>, <span class="string">"right"</span>]
- **distance**: *number* - <span class="keyword">in</span> pixels, distance of swipe
- **time**: *number* - <span class="keyword">in</span> seconds, time of swiping
</pre>
<p>- Swipe trigger only, if all input actions was on swipe node. If action will be outside of node, swipe status will be reseted
- In swipe style table you can adjust minimal distance and maximum time to trigg- Hover state trigger only with touch on mobile devices or button mouse holding. Just mouse over swipe
- In swipe style table you can toggle type of swipe triggering. if SWIPE<em>TRIGGER</em>ON_MOVE setup to true - swipe will trigger as swipe can be triggered. If setup to false - swipe will trigger only on released action
- If you have stencil on swipe node and you don't want trigger it outside of stencil node, you can use <a href="../modules/druid.swipe.html#set_click_zone">swipe:set_click_zone</a> to restrict swipe zonethout buttons is now not allowed.</p>
<p><a name="Drag"></a></p>
<h2>Drag</h2>
<p><a href="https://insality.github.io/druid/modules/druid.drag.html">Drag API here</a></p>
<h3>Overview</h3>
<p>System Druid component, handle drag actions on node</p>
<h3>Setup</h3>
<p>Create drag component with druid: <code>hover = druid:new_drag(node, drag_callback)</code></p>
<h3>Notes</h3>
<p>- Drag callback have next params: (self, swipe_side, distance, time)</p>
<pre>
- **self**: Druid self context
- **dx**: *number* - delta x position
- **dy**: *number* - delta y position
</pre>
<p>- In styles, you can point the drag start deadzone. Default value is 10 pixels
- Drag correctly process multitouch. You can switch touch_id, while dragging on node with correct <em>dx</em> and <em>dy</em> values (made for correct scrolling)
- You can restrict horizontal or vertical dragging by setting <code>drag.can_x</code> or <code>drag.can_y</code> to <em>false</em> value
- You can get info about current drag state:</p>
<pre>
- _is_touch_ - Is currently node touching
- _is_drag_ - Is currently node is dragging
- _x_ <span class="keyword">and</span> _y_ - Current touch position
- _touch_start_pos_ - Touch stat positions
</pre>
<p>- Drag have next events:</p>
<pre>
- _on_touch_start_ (self) - Event on touch start
- _on_touch_end_ (self) - Event on touch <span class="keyword">end</span>
- _on_drag_start_ (self) - Event on drag start
- _on_drag_ (self, dx, dy) - Event on drag process
- _on_drag_end_ (self) - Event on drag <span class="keyword">end</span>
</pre>
<p>- Drag node zone can be restricted via <code>drag:set_click_zone(node)</code></p>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-09-29 23:46:16 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View File

@ -1,254 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Overview">Overview </a></li>
<li><a href="#Custom_components">Custom components </a></li>
<li><a href="#Best_practice_on_custom_components">Best practice on custom components </a></li>
<li><a href="#Power_of_using_templates">Power of using templates </a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/01-components.md.html">01-components</a></li>
<li><strong>Creating custom components</strong></li>
<li><a href="../topics/03-styles.md.html">Styles</a></li>
<li><a href="../topics/04-druid_assets.md.html">Druid assets</a></li>
<li><a href="../topics/05-examples.md.html">Examples</a></li>
<li><a href="../topics/changelog.md.html">Druid 0.3.0:</a></li>
<li><a href="../topics/faq.md.html">faq</a></li>
<li><a href="../topics/README.md.html">README</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/druid.back_handler.html">druid.back_handler</a></li>
<li><a href="../modules/druid.blocker.html">druid.blocker</a></li>
<li><a href="../modules/druid.button.html">druid.button</a></li>
<li><a href="../modules/druid.drag.html">druid.drag</a></li>
<li><a href="../modules/druid.hover.html">druid.hover</a></li>
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
<li><a href="../modules/druid.static_grid.html">druid.static_grid</a></li>
<li><a href="../modules/druid.swipe.html">druid.swipe</a></li>
<li><a href="../modules/druid.text.html">druid.text</a></li>
<li><a href="../modules/component.html">component</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/druid_event.html">druid_event</a></li>
<li><a href="../modules/druid.checkbox.html">druid.checkbox</a></li>
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
<li><a href="../modules/druid.dynamic_grid.html">druid.dynamic_grid</a></li>
<li><a href="../modules/druid.input.html">druid.input</a></li>
<li><a href="../modules/druid.lang_text.html">druid.lang_text</a></li>
<li><a href="../modules/druid.progress.html">druid.progress</a></li>
<li><a href="../modules/druid.radio_group.html">druid.radio_group</a></li>
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
</ul>
</div>
<div id="content">
<h1>Creating custom components</h1>
<p><a name="Overview"></a></p>
<h2>Overview</h2>
<p>Druid allows you to create your custom components from druid basic components or other custom components.</p>
<p>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}</p>
<p><a name="Custom_components"></a></p>
<h2>Custom components</h2>
<p>Basic custom component template looks like this:</p>
<pre>
<span class="keyword">local</span> const = <span class="global">require</span>(<span class="string">"druid.const"</span>)
<span class="keyword">local</span> component = <span class="global">require</span>(<span class="string">"druid.component"</span>)
<span class="keyword">local</span> M = component.create(<span class="string">"my_component"</span>)
<span class="comment">-- Component constructor
</span><span class="keyword">function</span> M.init(self, ...)
<span class="keyword">end</span>
<span class="comment">-- Call only if exist interest: const.ON_UPDATE
</span><span class="keyword">function</span> M.update(self, dt)
<span class="keyword">end</span>
<span class="comment">-- Call only if exist interest: const.ON_INPUT or const.ON_INPUT_HIGH
</span><span class="keyword">function</span> M.on_input(self, action_id, action)
<span class="keyword">end</span>
<span class="comment">-- Call on component creation and on component:set_style() function
</span><span class="keyword">function</span> M.on_style_change(self, style)
<span class="keyword">end</span>
<span class="comment">-- Call only if exist interest: const.ON_MESSAGE
</span><span class="keyword">function</span> M.on_message(self, message_id, message, sender)
<span class="keyword">end</span>
<span class="comment">-- Call only if component with ON_ANGUAGECHANinterest
</span><span class="keyword">function</span> M.on_anguagechanself)
<span class="keyword">end</span>
<span class="comment">-- Call only if component with ON_LAYOUT_CHANGE interest
</span><span class="keyword">function</span> M.on_layout_change(self)
<span class="keyword">end</span>
<span class="comment">-- Call, if input was capturing before this component
</span><span class="comment">-- Example: scroll is start scrolling, so you need unhover button
</span><span class="keyword">function</span> M.on_input_interrupt(self)
<span class="keyword">end</span>
<span class="comment">-- Call, if game lost focus. Need ON_FOCUS_LOST intereset
</span><span class="keyword">function</span> M.on_focus_lost(self)
<span class="keyword">end</span>
<span class="comment">-- Call, if game gained focus. Need ON_FOCUS_GAINED intereset
</span><span class="keyword">function</span> M.on_focus_gained(self)
<span class="keyword">end</span>
<span class="comment">-- Call on component remove or on druid:final
</span><span class="keyword">function</span> M.on_remove(self)
<span class="keyword">end</span>
<span class="keyword">return</span> M
</pre>
<p>Add your custom component to druid via <a href="../modules/druid.html#register">druid.register</a></p>
<pre>
<span class="keyword">local</span> druid = <span class="global">require</span>(<span class="string">"druid.druid"</span>)
<span class="keyword">local</span> my_component = <span class="global">require</span>(<span class="string">"my.amazing.component"</span>)
<span class="keyword">function</span> init(self)
druid.register(<span class="string">"my_component"</span>, my_component)
<span class="keyword">end</span>
</pre>
<p>Registering make new function with "new<em>{component</em>name}". In our example it will be: <code>druid:new_my_component()</code>.</p>
<p>Or you can create component without registering with <code>druid:create(my_component_module)</code></p>
<p>As component registered, you can create your component with next code:</p>
<pre>
<span class="keyword">local</span> druid = <span class="global">require</span>(<span class="string">"druid.druid"</span>)
<span class="keyword">local</span> my_component = <span class="global">require</span>(<span class="string">"my.amazing.component"</span>)
<span class="keyword">function</span> init(self)
self.druid = druid.new(self)
<span class="keyword">local</span> my_component = self.druid:new_my_component(...)
<span class="comment">-- or --
</span> <span class="keyword">local</span> my_component = self.druid:create(my_component, ...)
<span class="keyword">end</span>
</pre>
<h3>Interest</h3>
<p>Interest - is a way to indicate what events your component will respond to.
There is next interests in druid:
- <strong>ON_MESSAGE</strong> - component will receive messages from on_message</p>
<ul>
<li><p><strong>ON_UPDATE</strong> - component will be updated from update</p></li>
<li><p><strong>ON<em>INPUT</em>HIGH</strong> - component will receive input from on<em>input, before other components with ON</em>INPUT</p></li>
<li><p><strong>ON_INPUT</strong> - component will receive input from on<em>input, after other components with ON</em>INPUT_HIGH</p></li>
<li><p><strong>ON<em>LANGUAGE</em>CHANGE</strong> - will call <em>on</em>language<em>change</em> function on language change trigger</p></li>
<li><p><strong>ON<em>LAYOUT</em>CHANGE</strong> will call <em>on</em>layout<em>change</em> function on layout change trigger</p></li>
<li><p><strong>ON<em>FOCUS</em>LOST</strong> will call <em>on</em>focust<em>lost</em> function in on focus lost event. You need to pass window_callback to global <a href="../modules/druid.html#on_window_callback">druid:on_window_callback</a></p></li>
<li><p><strong>ON<em>FOCUS</em>GAINED</strong> will call <em>on</em>focust<em>gained</em> function in on focus gained event. You need to pass window_callback to global <a href="../modules/druid.html#on_window_callback">druid:on_window_callback</a></p></li>
</ul>
<p><a name="Best_practice_on_custom_components"></a></p>
<h2>Best practice on custom components</h2>
<p>On each component recommended describe component scheme in next way:</p>
<pre>
<span class="comment">-- Component module
</span><span class="keyword">local</span> component = <span class="global">require</span>(<span class="string">"druid.component"</span>)
<span class="keyword">local</span> M = component.create(<span class="string">"your_component"</span>)
<span class="keyword">local</span> SCHEME = {
ROOT = <span class="string">"root"</span>,
ITEM = <span class="string">"item"</span>,
TITLE = <span class="string">"title"</span>
}
<span class="keyword">function</span> M.init(self, template_name, node_table)
<span class="comment">-- If component use template, setup it:
</span> self:set_template(template_name)
<span class="comment">-- If component was cloned with gui.clone_tree, pass his nodes
</span> self:set_nodes(node_table)
<span class="comment">-- helper can get node from gui/template/table
</span> <span class="keyword">local</span> root = self:get_node(SCHEME.ROOT)
<span class="comment">-- This component can spawn another druid components:
</span> <span class="keyword">local</span> druid = self:get_druid()
<span class="comment">-- Button self on callback is self of _this_ component
</span> <span class="keyword">local</span> button = druid:new_button(...)
<span class="keyword">end</span>
</pre>
<p><a name="Power_of_using_templates"></a></p>
<h2>Power of using templates</h2>
<p>You can use one component, but creating and customizing templates for them. Templates only requires to match the component scheme.</p>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-09-29 23:46:16 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View File

@ -1,164 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Overview">Overview </a></li>
<li><a href="#Usage">Usage </a></li>
<li><a href="#Create_your_own_styles">Create your own styles </a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/01-components.md.html">01-components</a></li>
<li><a href="../topics/02-creating_custom_components.md.html">Creating custom components</a></li>
<li><strong>Styles</strong></li>
<li><a href="../topics/04-druid_assets.md.html">Druid assets</a></li>
<li><a href="../topics/05-examples.md.html">Examples</a></li>
<li><a href="../topics/changelog.md.html">Druid 0.3.0:</a></li>
<li><a href="../topics/faq.md.html">faq</a></li>
<li><a href="../topics/README.md.html">README</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/druid.back_handler.html">druid.back_handler</a></li>
<li><a href="../modules/druid.blocker.html">druid.blocker</a></li>
<li><a href="../modules/druid.button.html">druid.button</a></li>
<li><a href="../modules/druid.drag.html">druid.drag</a></li>
<li><a href="../modules/druid.hover.html">druid.hover</a></li>
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
<li><a href="../modules/druid.static_grid.html">druid.static_grid</a></li>
<li><a href="../modules/druid.swipe.html">druid.swipe</a></li>
<li><a href="../modules/druid.text.html">druid.text</a></li>
<li><a href="../modules/component.html">component</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/druid_event.html">druid_event</a></li>
<li><a href="../modules/druid.checkbox.html">druid.checkbox</a></li>
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
<li><a href="../modules/druid.dynamic_grid.html">druid.dynamic_grid</a></li>
<li><a href="../modules/druid.input.html">druid.input</a></li>
<li><a href="../modules/druid.lang_text.html">druid.lang_text</a></li>
<li><a href="../modules/druid.progress.html">druid.progress</a></li>
<li><a href="../modules/druid.radio_group.html">druid.radio_group</a></li>
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
</ul>
</div>
<div id="content">
<h1>Styles</h1>
<p><a name="Overview"></a></p>
<h2>Overview</h2>
<p>Styles - set of functions and parameters for components to customize their behavior.</p>
<p>Styles is a table, where key is name of component, and value is style table for this component.</p>
<p>In component API documentation, you can find the style API for this component. Or just lookup for existing styles and modify them.</p>
<p><a name="Usage"></a></p>
<h2>Usage</h2>
<p>Setup default druid style for all druid instances via <a href="../modules/druid.html#set_default_style">druid.set_default_style</a>
You can pass <em>nil</em> or <em>empty</em>table_ to use default values for all components (no styles)</p>
<pre>
<span class="keyword">local</span> druid = <span class="global">require</span>(<span class="string">"druid.druid"</span>)
<span class="keyword">local</span> my_style = <span class="global">require</span>(<span class="string">"my.amazing.style"</span>)
<span class="keyword">local</span> <span class="keyword">function</span> init(self)
druid.set_default_style(my_style)
<span class="keyword">end</span>
</pre>
<p>Setup custom style to specific druid instance:</p>
<pre>
<span class="keyword">local</span> druid = <span class="global">require</span>(<span class="string">"druid.druid"</span>)
<span class="keyword">local</span> my_style = <span class="global">require</span>(<span class="string">"my.amazing.style"</span>)
<span class="keyword">local</span> <span class="keyword">function</span> init(self)
<span class="comment">-- This druid instance will be use my_style as default
</span> self.druid = druid.new(self, my_style)
<span class="keyword">end</span>
</pre>
<p>Change component style with <em>set</em>style_ function</p>
<pre>
<span class="keyword">local</span> druid = <span class="global">require</span>(<span class="string">"druid.druid"</span>)
<span class="keyword">local</span> my_style = <span class="global">require</span>(<span class="string">"my.amazing.style"</span>)
<span class="keyword">local</span> <span class="keyword">function</span> init(self)
self.druid = druid.new(self)
self.button = self.druid:new_button(self, <span class="string">"node"</span>)
<span class="comment">-- Setup custom style for specific component
</span> self.button:set_style(my_style)
<span class="keyword">end</span>
</pre>
<p><a name="Create_your_own_styles"></a></p>
<h2>Create your own styles</h2>
<p>The most components have their styles. You can explore it on <a href="https://insality.github.io/druid/">Druid API</a> in table style section (<a href="https://insality.github.io/druid/modules/druid.button.html#Style">button example</a>). Or you can see, what fields component uses in code in function <code>on_style_change</code></p>
<p>To create you style, create lua module, what return &lt;<em>component</em>name_, <em>component</em>style_> table</p>
<p>Example: <a href="https://github.com/Insality/druid/blob/develop/druid/styles/default/style.lua">default druid style</a></p>
<p>Override all fields you want and set your style with one of next ways:</p>
<ul>
<li>Set your style as global via <a href="../modules/druid.html#set_default_style">druid.set_default_style</a></li>
<li>Set style for concrete druid instance via <code>druid = druid.new(self, style)</code></li>
<li>Set style for concrete instance via <code>component:set_style(style)</code></li>
</ul>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-09-29 23:46:16 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View File

@ -1,101 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Overview">Overview </a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/01-components.md.html">01-components</a></li>
<li><a href="../topics/02-creating_custom_components.md.html">Creating custom components</a></li>
<li><a href="../topics/03-styles.md.html">Styles</a></li>
<li><strong>Druid assets</strong></li>
<li><a href="../topics/05-examples.md.html">Examples</a></li>
<li><a href="../topics/changelog.md.html">Druid 0.3.0:</a></li>
<li><a href="../topics/faq.md.html">faq</a></li>
<li><a href="../topics/README.md.html">README</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/druid.back_handler.html">druid.back_handler</a></li>
<li><a href="../modules/druid.blocker.html">druid.blocker</a></li>
<li><a href="../modules/druid.button.html">druid.button</a></li>
<li><a href="../modules/druid.drag.html">druid.drag</a></li>
<li><a href="../modules/druid.hover.html">druid.hover</a></li>
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
<li><a href="../modules/druid.static_grid.html">druid.static_grid</a></li>
<li><a href="../modules/druid.swipe.html">druid.swipe</a></li>
<li><a href="../modules/druid.text.html">druid.text</a></li>
<li><a href="../modules/component.html">component</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/druid_event.html">druid_event</a></li>
<li><a href="../modules/druid.checkbox.html">druid.checkbox</a></li>
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
<li><a href="../modules/druid.dynamic_grid.html">druid.dynamic_grid</a></li>
<li><a href="../modules/druid.input.html">druid.input</a></li>
<li><a href="../modules/druid.lang_text.html">druid.lang_text</a></li>
<li><a href="../modules/druid.progress.html">druid.progress</a></li>
<li><a href="../modules/druid.radio_group.html">druid.radio_group</a></li>
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
</ul>
</div>
<div id="content">
<h1>Druid assets</h1>
<p><a name="Overview"></a></p>
<h2>Overview</h2>
<p>I've created <a href="https://github.com/Insality/druid-assets">druid-assets repository</a> to make a <em>marketplace</em> with custom styles and components.</p>
<p>Any of Druid users can push their own components and styles to share it with the other users</p>
<p>Also, this marketplace is great example to how you can create your custom components</p>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-09-29 23:46:16 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View File

@ -1,99 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Overview">Overview </a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/01-components.md.html">01-components</a></li>
<li><a href="../topics/02-creating_custom_components.md.html">Creating custom components</a></li>
<li><a href="../topics/03-styles.md.html">Styles</a></li>
<li><a href="../topics/04-druid_assets.md.html">Druid assets</a></li>
<li><strong>Examples</strong></li>
<li><a href="../topics/changelog.md.html">Druid 0.3.0:</a></li>
<li><a href="../topics/faq.md.html">faq</a></li>
<li><a href="../topics/README.md.html">README</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/druid.back_handler.html">druid.back_handler</a></li>
<li><a href="../modules/druid.blocker.html">druid.blocker</a></li>
<li><a href="../modules/druid.button.html">druid.button</a></li>
<li><a href="../modules/druid.drag.html">druid.drag</a></li>
<li><a href="../modules/druid.hover.html">druid.hover</a></li>
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
<li><a href="../modules/druid.static_grid.html">druid.static_grid</a></li>
<li><a href="../modules/druid.swipe.html">druid.swipe</a></li>
<li><a href="../modules/druid.text.html">druid.text</a></li>
<li><a href="../modules/component.html">component</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/druid_event.html">druid_event</a></li>
<li><a href="../modules/druid.checkbox.html">druid.checkbox</a></li>
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
<li><a href="../modules/druid.dynamic_grid.html">druid.dynamic_grid</a></li>
<li><a href="../modules/druid.input.html">druid.input</a></li>
<li><a href="../modules/druid.lang_text.html">druid.lang_text</a></li>
<li><a href="../modules/druid.progress.html">druid.progress</a></li>
<li><a href="../modules/druid.radio_group.html">druid.radio_group</a></li>
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
</ul>
</div>
<div id="content">
<h1>Examples</h1>
<p><a name="Overview"></a></p>
<h2>Overview</h2>
<p>See the <a href="https://github.com/Insality/druid/tree/develop/example/kenney">example folder</a> for examples of how to use Druid</p>
<p>Try the <a href="https://insality.github.io/druid/druid/">HTML5 version</a> of the example app</p>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-09-29 23:46:16 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View File

@ -1,358 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Setup">Setup </a></li>
<li><a href="#Components">Components </a></li>
<li><a href="#Basic_usage">Basic usage </a></li>
<li><a href="#Druid_Events">Druid Events </a></li>
<li><a href="#Druid_Lifecycle">Druid Lifecycle </a></li>
<li><a href="#Details">Details </a></li>
<li><a href="#Examples">Examples </a></li>
<li><a href="#Documentation">Documentation </a></li>
<li><a href="#Games_powered_by_Druid">Games powered by Druid </a></li>
<li><a href="#License">License </a></li>
<li><a href="#Issues_and_suggestions">Issues and suggestions </a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/01-components.md.html">01-components</a></li>
<li><a href="../topics/02-creating_custom_components.md.html">Creating custom components</a></li>
<li><a href="../topics/03-styles.md.html">Styles</a></li>
<li><a href="../topics/04-druid_assets.md.html">Druid assets</a></li>
<li><a href="../topics/05-examples.md.html">Examples</a></li>
<li><a href="../topics/changelog.md.html">Druid 0.3.0:</a></li>
<li><a href="../topics/faq.md.html">faq</a></li>
<li><strong>README</strong></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/druid.back_handler.html">druid.back_handler</a></li>
<li><a href="../modules/druid.blocker.html">druid.blocker</a></li>
<li><a href="../modules/druid.button.html">druid.button</a></li>
<li><a href="../modules/druid.drag.html">druid.drag</a></li>
<li><a href="../modules/druid.hover.html">druid.hover</a></li>
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
<li><a href="../modules/druid.static_grid.html">druid.static_grid</a></li>
<li><a href="../modules/druid.swipe.html">druid.swipe</a></li>
<li><a href="../modules/druid.text.html">druid.text</a></li>
<li><a href="../modules/component.html">component</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/druid_event.html">druid_event</a></li>
<li><a href="../modules/druid.checkbox.html">druid.checkbox</a></li>
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
<li><a href="../modules/druid.dynamic_grid.html">druid.dynamic_grid</a></li>
<li><a href="../modules/druid.input.html">druid.input</a></li>
<li><a href="../modules/druid.lang_text.html">druid.lang_text</a></li>
<li><a href="../modules/druid.progress.html">druid.progress</a></li>
<li><a href="../modules/druid.radio_group.html">druid.radio_group</a></li>
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
</ul>
</div>
<div id="content">
<a href="https://insality.github.io/druid/"><img src="media/druid_logo.png" alt=""/></a></p>
<p><a href="https://github.com/Insality/druid/releases"><img src="https://img.shields.io/github/v/release/insality/druid" alt="GitHub release (latest by date)"/></a></p>
<p><strong>Druid</strong> - powerful Defold component UI library. Use basic and extended <strong>Druid</strong> components or make your own game-specific components to make amazing GUI in your games.</p>
<p><a name="Setup"></a></p>
<h2>Setup</h2>
<h3>Dependency</h3>
<p>You can use the <strong>Druid</strong> extension in your own project by adding this project as a <a href="https://www.defold.com/manuals/libraries/">Defold library dependency</a>. Open your game.project file and in the dependencies field under project add:</p>
<blockquote>
<p><a href="https://github.com/Insality/druid/archive/master.zip">https://github.com/Insality/druid/archive/master.zip</a></p>
</blockquote>
<p>Or point to the ZIP file of a <a href="https://github.com/Insality/druid/releases">specific release</a>.</p>
<h3>Input bindings</h3>
<p>For <strong>Druid</strong> to work requires next input bindings:</p>
<ul>
<li>Mouse trigger - <code>Button 1</code> -> <code>touch</code> <em>For basic input components</em></li>
<li>Key trigger - <code>Backspace</code> -> <code>key_backspace</code> <em>For back</em>handler component, input component_</li>
<li>Key trigger - <code>Back</code> -> <code>key_back</code> <em>For back</em>handler component, Android back button, input component_</li>
<li>Key trigger - <code>Enter</code> -> <code>key_enter</code> <em>For input component, optional</em></li>
<li>Key trigger - <code>Esc</code> -> <code>key_esc</code> <em>For input component, optional</em></li>
<li>Touch triggers - <code>Touch multi</code> -> <code>multitouch</code> <em>For scroll component</em></li>
</ul>
<p><img src="media/input_binding_2.png" alt=""/>
<img src="media/input_binding_1.png" alt=""/></p>
<h3>Input capturing [optional]</h3>
<p>By default, <strong>Druid</strong> will auto-capture input focus, if any input component will be created. So you don't need to call <code>msg.post(&quot;.&quot;, &quot;acquire_input_focus&quot;)</code></p>
<p>If you not need this behaviour, you can disable it by settings <code>druid.no_auto_input</code> field in <em>game.project</em>:</p>
<pre><code> [druid]
no_auto_input = 1
</code></pre>
<h3>Code [optional]</h3>
<p>Adjust <strong>Druid</strong> settings, if needed:</p>
<pre>
<span class="keyword">local</span> druid = <span class="global">require</span>(<span class="string">"druid.druid"</span>)
<span class="comment">-- Used for button component and custom components
</span><span class="comment">-- Callback should play sound by name
</span>druid.set_sound_function(callback)
<span class="comment">-- Used for lang_text component
</span><span class="comment">-- Callback should return localized string by locale id
</span>druid.set_text_function(callback)
<span class="comment">-- Used for change default druid style
</span>druid.set_default_style(your_style)
<span class="comment">-- Call this function on language changing in the game,
</span><span class="comment">-- to retranslate all lang_text components:
</span>druid.on_language_change()
<span class="comment">-- Call this function inside window.set_listener
</span><span class="comment">-- to catch game focus lost/gained callbacks:
</span>druid.on_window_callback(event)
</pre>
<p><a name="Components"></a></p>
<h2>Components</h2>
<p><strong>Druid</strong> provides next <em>basic</em> components:</p>
<ul>
<li><p><strong><a href="master/docs_md/01-components.md#button">Button</a></strong> - Basic Druid button input component. Handles all types of interaction (tap, long-tap, hold-tap, double-tap, simple key triggers, etc)</p></li>
<li><p><strong><a href="master/docs_md/01-components.md#text">Text</a></strong> - Basic Druid text component. Wrap on gui text node, handle text size adjusting.</p></li>
<li><p><strong><a href="master/docs_md/01-components.md#scroll">Scroll</a></strong> - Basic Druid scroll component</p></li>
<li><p><strong><a href="master/docs_md/01-components.md#blocker">Blocker</a></strong> - Block input in node zone component</p></li>
<li><p><strong><a href="master/docs_md/01-components.md#back-handler">Back Handler</a></strong> - Handle back button (Android back button, backspace key)</p></li>
<li><p><strong><a href="master/docs_md/01-components.md#static-grid">Static Grid</a></strong> - Component for manage node positions with equal sizes</p></li>
<li><p><strong><a href="master/docs_md/01-components.md#hover">Hover</a></strong> - System Druid component, handle hover node state</p></li>
<li><p><strong><a href="master/docs_md/01-components.md#swipe">Swipe</a></strong> - System Druid component, handle swipe gestures on node</p></li>
<li><p><strong><a href="master/docs_md/01-components.md#drag">Drag</a></strong> - System Druid component, handle drag input on node </p></li>
</ul>
<p><strong>Druid</strong> also provides next <em>extended</em> components:</p>
<p><strong>*Note</strong>: In future, to use extended components, you should register them first. It's required for make <strong>Druid</strong> modular - to exclude unused components from build*</p>
<ul>
<li><p><strong><a href="master/docs_md/01-components.md#checkbox">Checkbox</a></strong> - Checkbox component</p></li>
<li><p><strong><a href="master/docs_md/01-components.md#checkbox-group">Checkbox group</a></strong> - Several checkboxes in one group</p></li>
<li><p><strong><a href="master/docs_md/01-components.md#dynamic-grid">Dynamic Grid</a></strong> - Component for manage node positions with different sizes. Only in one row or column</p></li>
<li><p><strong><a href="master/docs_md/01-components.md#input">Input</a></strong> - User text input component</p></li>
<li><p><strong><a href="master/docs_md/01-components.md#lang-text">Lang text</a></strong> - Wrap on Text component to handle localization</p></li>
<li><p><strong><a href="master/docs_md/01-components.md#progress">Progress</a></strong> - Progress bar component</p></li>
<li><p><strong><a href="master/docs_md/01-components.md#radio-group">Radio group</a></strong> - Several checkboxes in one group with single choice</p></li>
<li><p><strong><a href="master/docs_md/01-components.md#slider">Slider</a></strong> - Slider component</p></li>
<li><p><strong><a href="master/docs_md/01-components.md#timer">Timer</a></strong> - Handle timer work on gui text node</p></li>
</ul>
<p>Full info see on <em><a href="master/docs_md/01-components.md">components.md</a></em></p>
<p><a name="Basic_usage"></a></p>
<h2>Basic usage</h2>
<p>For using <strong>Druid</strong>, first you should create Druid instance to spawn components. Pass to new Druid instance main engine functions: <em>update</em>, *on<em>message* and *on</em>input*</p>
<p>All <strong>Druid</strong> components as arguments can apply node name string, you can don't do <code>gui.get_node()</code> before</p>
<p>All <strong>Druid</strong> and component methods calling with <code>:</code> like <code>self.druid:new_button()</code></p>
<pre>
<span class="keyword">local</span> druid = <span class="global">require</span>(<span class="string">"druid.druid"</span>)
<span class="keyword">local</span> <span class="keyword">function</span> button_callback(self)
<span class="global">print</span>(<span class="string">"Button was clicked!"</span>)
<span class="keyword">end</span>
<span class="keyword">function</span> init(self)
self.druid = druid.new(self)
self.druid:new_button(<span class="string">"button_node_name"</span>, button_callback)
<span class="keyword">end</span>
<span class="keyword">function</span> final(self)
self.druid:final()
<span class="keyword">end</span>
<span class="keyword">function</span> on_input(self, action_id, action)
<span class="keyword">return</span> self.druid:on_input(action_id, action)
<span class="keyword">end</span>
</pre>
<p>Learn <strong>Druid</strong> instance <a href="https://insality.github.io/druid/modules/druid_instance.html">functions here</a>)</p>
<p><a name="Druid_Events"></a></p>
<h2>Druid Events</h2>
<p>Any <strong>Druid</strong> components as callbacks uses <a href="https://insality.github.io/druid/modules/druid_event.html">Druid Events</a>. In component API (<a href="https://insality.github.io/druid/modules/druid.button.html#Events">button example</a>) pointed list of component events. You can manually subscribe on this events by next API:</p>
<ul>
<li><p><strong>event:subscribe</strong>(callback)</p></li>
<li><p><strong>event:unsubscribe</strong>(callback)</p></li>
<li><p><strong>event:clear</strong>()</p></li>
</ul>
<p>You can subscribe several callbacks on single event.</p>
<p><a name="Druid_Lifecycle"></a></p>
<h2>Druid Lifecycle</h2>
<p>Here is full Druid lifecycle setup in your <strong>*.gui_script</strong> file:</p>
<pre>
<span class="keyword">local</span> druid = <span class="global">require</span>(<span class="string">"druid.druid"</span>)
<span class="keyword">function</span> init(self)
self.druid = druid.new(self)
<span class="keyword">end</span>
<span class="keyword">function</span> final(self)
self.druid:final()
<span class="keyword">end</span>
<span class="keyword">function</span> update(self, dt)
self.druid:update(dt)
<span class="keyword">end</span>
<span class="keyword">function</span> on_input(self, action_id, action)
<span class="keyword">return</span> self.druid:on_input(action_id, action)
<span class="keyword">end</span>
<span class="keyword">function</span> on_message(self, message_id, message, sender)
self.druid:on_message(message_id, message, sender)
<span class="keyword">end</span>
</pre>
<ul>
<li><em>final</em> <strong>required</strong> function for correct Druid lifecycle</li>
<li>*on_input* used for almost all Druid components</li>
<li><em>update</em> used for progress bar, scroll and timer base components</li>
<li>*on_message* used for specific Druid events, like language change or layout change</li>
</ul>
<p>Recommended is fully integrate all <strong>Druid</strong> lifecycles functions</p>
<p><a name="Details"></a></p>
<h2>Details</h2>
<ul>
<li>Druid input goes as stack. Last created button will checked first. So create your GUI from back</li>
<li>Don't forget about <code>return</code> in <code>on_input</code>: <code>return self.druid:on_input()</code>. It need, if you have more than 1 acquire inputs (several Druid, other input system, etc)</li>
<li>Druid by default do <em>acquire</em>input<em>focus</em>. So you don't need do it manually. Buy only if you have components, which requires <em>on</em>input_ </li>
<li>If you want to delete node with declared Druid component, don't forget to remove them via <code>druid:remove(component)</code></li>
</ul>
<p>See full <a href="master/docs_md/FAQ.md">See FAQ here</a></p>
<p><a name="Examples"></a></p>
<h2>Examples</h2>
<p>See the <a href="https://github.com/Insality/druid/tree/develop/example">example folder</a> for examples of how to use <strong>Druid</strong></p>
<p>See the <a href="https://github.com/insality/druid-assets">druid-assets repository</a> for examples of how to create custom components and styles</p>
<p>Try the <a href="https://insality.github.io/druid/druid/">HTML5 version</a> of the example app</p>
<p><a name="Documentation"></a></p>
<h2>Documentation</h2>
<p>To learn <strong>Druid</strong> better, read next documentation:
- <a href="master/docs_md/01-components.md">Druid components</a>
- <a href="master/docs_md/02-creating_custom_components.md">Create custom components</a>
- <a href="master/docs_md/FAQ.md">See FAQ article</a>
- <a href="master/docs_md/03-styles.md">Druid styles</a>
- <a href="master/docs_md/04-druid_assets.md">Druid asset store</a></p>
<p>Full <strong>Druid</strong> documentation you can find here:
https://insality.github.io/druid/</p>
<p><a name="Games_powered_by_Druid"></a></p>
<h2>Games powered by Druid</h2>
<p><em>You published your game and you using Druid? Note me!</em></p>
<p><a name="License"></a></p>
<h2>License</h2>
<ul>
<li>Developed and supporting by <a href="https://github.com/Insality">Insality</a></li>
<li>Original idea by <a href="https://github.com/AGulev">AGulev</a></li>
<li>Assets from <a href="http://www.kenney.nl/">Kenney</a></li>
</ul>
<p><strong>MIT</strong> License</p>
<p><a name="Issues_and_suggestions"></a></p>
<h2>Issues and suggestions</h2>
<p>If you have any issues, questions or suggestions please <a href="https://github.com/Insality/druid/issues">create an issue</a> or contact me: <a href="mailto:insality@gmail.com">insality@gmail.com</a>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-09-29 23:46:16 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View File

@ -1,252 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/01-components.md.html">01-components</a></li>
<li><a href="../topics/02-creating_custom_components.md.html">Creating custom components</a></li>
<li><a href="../topics/03-styles.md.html">Styles</a></li>
<li><a href="../topics/04-druid_assets.md.html">Druid assets</a></li>
<li><a href="../topics/05-examples.md.html">Examples</a></li>
<li><strong>Druid 0.3.0:</strong></li>
<li><a href="../topics/faq.md.html">faq</a></li>
<li><a href="../topics/README.md.html">README</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/druid.back_handler.html">druid.back_handler</a></li>
<li><a href="../modules/druid.blocker.html">druid.blocker</a></li>
<li><a href="../modules/druid.button.html">druid.button</a></li>
<li><a href="../modules/druid.drag.html">druid.drag</a></li>
<li><a href="../modules/druid.hover.html">druid.hover</a></li>
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
<li><a href="../modules/druid.static_grid.html">druid.static_grid</a></li>
<li><a href="../modules/druid.swipe.html">druid.swipe</a></li>
<li><a href="../modules/druid.text.html">druid.text</a></li>
<li><a href="../modules/component.html">component</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/druid_event.html">druid_event</a></li>
<li><a href="../modules/druid.checkbox.html">druid.checkbox</a></li>
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
<li><a href="../modules/druid.dynamic_grid.html">druid.dynamic_grid</a></li>
<li><a href="../modules/druid.input.html">druid.input</a></li>
<li><a href="../modules/druid.lang_text.html">druid.lang_text</a></li>
<li><a href="../modules/druid.progress.html">druid.progress</a></li>
<li><a href="../modules/druid.radio_group.html">druid.radio_group</a></li>
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
</ul>
</div>
<div id="content">
<h3>Druid 0.3.0:</h3>
<ul>
<li><p><code>Druid:final()</code> now is important function for correct working</p></li>
<li><p>Add <em>swipe</em> basic component</p>
<pre>
- Swipe component handle simple swipe gestures on node. It has single callback with direction on swipe. You can adjust a several parameters of swipe <span class="keyword">in</span> druid style.
- Swipe can be triggered on action.released <span class="keyword">or</span> <span class="keyword">while</span> user is make swiping (<span class="keyword">in</span> process)
- Add swipe example at main Druid example. Try swipe left/right to switch example pages.
</pre>
</li>
<li><p>Add <em>input</em> basic component</p>
<pre>
- Input component handle user text input. Input contains from button <span class="keyword">and</span> text components. Button needed <span class="keyword">for</span> selecting/unselecting input field
- Long click on input field <span class="keyword">for</span> clear <span class="keyword">and</span> <span class="global">select</span> input field (clearing can be disable via styles)
- Click outside of button to unselect input field
- On focus lost (game minimized) input field will be unselected
- You can setup max length of the text
- You can setup allowed characters. On add <span class="keyword">not</span> allowed characters <span class="backtick"><code>on_input_wrong</code></span> will be called. By default it cause simple shake animation
- The keyboard <span class="keyword">for</span> input will <span class="keyword">not</span> show on mobile HTML5. So input field <span class="keyword">in</span> mobile HTML5 is <span class="keyword">not</span> working now
- To make work different keyboard <span class="global">type</span>, make sure value <span class="keyword">in</span> game.project Android:InputMethod set to HiddenInputField (https://defold.com/manuals/project-settings/#input-method)
</pre>
</li>
<li><p>Add two functions to basic component: <code>increase_input_priority</code> and <code>reset_input_priority</code>. It used to process component input first in current input stack (there is two input stacks now: INPUT and INPUT_HIGH). Example: on selecting input field, it increase input self priority until it be unselected</p></li>
<li><p>Add two new component interests: <code>on_focus_gain</code> and <code>on_focus_lost</code></p></li>
<li><p>Add global druid events:</p>
<pre>
- on_window_callback: call <span class="backtick"><code>druid.on_window_callback(event)</code></span> <span class="keyword">for</span> on_focus_gain/lost correct work
- on_language_change: call <span class="backtick"><code>druid.on_language_change()</code></span> (#<span class="number">38</span>) <span class="keyword">for</span> update all druid instances lang components
- on_layout_change: call <span class="backtick"><code>druid.on_layout_change()</code></span> (#<span class="number">37</span>) <span class="keyword">for</span> update all gui layouts (unimplemented now)
</pre>
</li>
<li><p>Add button <code>on_click_outside</code> event. You can subscribe on this event in button. Was needed for Input component (click outside to deselect input field)</p></li>
<li><p>Add <em>start</em>pos_ field to button component</p></li>
<li><p>Changed input binding settings. Add esc, enter, text and marked_text. Backspace now is different from android back button event. Check the README setup section</p></li>
<li><p>Renamed <em>on</em>change<em>language</em> -> <em>on</em>language<em>change</em> component interest</p></li>
<li><p>Add several examples to druid-assets respository (see live example here): https://insality.github.io/druid-assets/)</p></li>
<li><p>Known issues:</p>
<pre>
- Adjusting text size by height works wrong. Adjusting single line texting works fine
- Space is <span class="keyword">not</span> working <span class="keyword">in</span> HTML5
</pre>
<h3>Druid 0.4.0:</h3></li>
<li><p>Add <em>Drag</em> basic component</p>
<pre>
- Drag component allow you detect dragging on GUI node
- Drag will be processed even the cursor is outside of node, <span class="keyword">if</span> drag is already started
- Drag provides correct handle of several touches. Drag can switch between them (no more scroll gliches with position)
- Drag have <span class="global">next</span> events:
- on_touch_start (self)
- on_touch_end (self)
- on_drag_start (self)
- on_drag (self, dx, dy)
- on_drag_end (self)
- You can restriction side of dragging by changing _drag.can_x_ <span class="keyword">and</span> _drag.can_y_ fields
- You can setup drag deadzone to detect, when dragging is started (_by default <span class="number">10</span> pixels_)
</pre>
</li>
<li><p>[Breaking changes] Druid <em>Scroll</em> component fully reworked. Input logic moved to <em>Drag</em> component</p>
<pre>
- Update scroll documentation
- Change constructor order params
- Change _scroll:set_border_ to _scroll:set_size_
- Scroll now contains from view <span class="keyword">and</span> content node
- _View node_ - static node, which size determine the <span class="string">"camera"</span> zone
- _Content node_ - dynamic node, moving by _Scroll_ component
- Scroll will be disabled only <span class="keyword">if</span> content size equals to view size (by width <span class="keyword">or</span> height separatly)
- You can adjust start scroll size via _.gui_ scene. Just setup correct node size
- Different anchoring is supported (<span class="keyword">for</span> easier layouting)
- Function _scroll_to_ now accept position relative to _content node_. It's more easier <span class="keyword">for</span> handling. _Example:_ <span class="keyword">if</span> you have children node of _content_node_, you can pass this node position to scroll to this.
- **Resolve #<span class="number">52</span>**: _Content node size_ now can be less than _view node size_. In this case, content will be scrolled only inside _view size_ (can be disabled via style field: _SMALL_CONTENT_SCROLL_)
- **Fix #<span class="number">50</span>**: If style.SOFT_ZONE_SIZE equals to [<span class="number">0.</span>.<span class="number">1</span>], scroll can be disappeared
</pre>
</li>
<li><p>Druid <em>Grid</em> Update</p>
<pre>
- Anchor by default equals to node pivot (so, more component settings <span class="keyword">in</span> _.gui_ settings) (#<span class="number">51</span>)
- Function <span class="backtick"><code>grid:clear</code></span> now don't delete any GUI nodes. Druid will <span class="keyword">not</span> care about <span class="backtick"><code>gui.delete_node</code></span> logic anymore (#<span class="number">56</span>)
</pre>
</li>
<li><p>Druid <em>Hover</em> component now have two <em>hover</em> events (#49):</p>
<pre>
- _on_hover_ is usual hover event. Trigger only <span class="keyword">if</span> touch <span class="keyword">or</span> mouse action_id pressed on node
- _on_mouse_hover_ action on node without action_id (desktop mouse over). Works only on desktop platform
</pre>
</li>
<li><p>Styles update:</p>
<pre>
- Styles <span class="global">table</span> now can be empty, every component have their default style values
- Remove <span class="backtick"><code>component:get_style</code></span> <span class="keyword">function</span>. Now you can only set styles
- To get style values <span class="keyword">in</span> component, add <span class="backtick"><code>component:on_style_change</code></span> <span class="keyword">function</span>. It's invoked on <span class="backtick"><a href="../modules/component.html#set_style">component:set_style</a></span> <span class="keyword">function</span>
- You can look up default values inside <span class="backtick"><code>component:on_style_change</code></span> <span class="keyword">function</span> <span class="keyword">or</span> style component API on [Druid API](https://insality.github.<span class="global">io</span>/druid/index.html)
</pre>
</li>
<li><p>Druid update:</p>
<pre>
- Now <span class="keyword">function</span> <span class="backtick"><code>druid:remove</code></span> remove instance <span class="keyword">and</span> all instance children components. No more manual deleting child components (#<span class="number">41</span>)
</pre>
</li>
<li><p><strong>Fix:</strong> Blocker component bug (blocker had very high priority, so it's block even button components, created after blocker)</p></li>
<li><p><strong>Fix #58:</strong> Bug, when druid instance should be always named <a href="../modules/druid.html#">druid</a> (ex: <code>self.druid = druid.new(self)</code>)</p></li>
<li><p><strong>Fix #53:</strong> Bug with final <em>Druid instance</em> without any components</p></li>
</ul>
<h3>Druid 0.5.0:</h3>
<p>Besides a lot of fixes (thanks for feedback!) two components was add: <em>StaticGrid</em> and <em>DynamicGrid</em> instead of usual <em>Grid</em> component (it is deprecated now).
Add <em>component:set</em>input<em>enabled</em> for basic component class. So you can enable/disable user input for any component.
Finaly implemented <em>on</em>layout<em>changed</em> support. Druid components now will try keep their data between layout changing! You also can use this callback in your custom components.
Also check <em>component.template.lua</em> what you can use for your own custom components!</p>
<ul>
<li><strong>#77</strong> Grid update:
<pre>
- The _grid_ component now is __deprecated__. Use _static_grid_ instead. Druid will show you deprecated message, <span class="keyword">if</span> you still using _grid_ component
- __[BREAKING]__ Remove the _grid:set_offset_ grid functions. To adjust the distance between nodes inside grid - setup correct node sizes
- Add _static_grid_ component
- The behaviour like previous _grid_ component
- Have constant element size, so have ability to precalculate positions, indexes <span class="keyword">and</span> size of content
- By default, <span class="keyword">not</span> shifting elements on removing element. Add _is_shift_ flag to _static_grid:remove_ <span class="keyword">function</span>
- This grid can spawn elements with several rows <span class="keyword">and</span> columns
- Add _dynamic_grid_ component
- Can have different element size. So have no ability to precalculate stuff like _static_grid_
- This grid can't have gaps between elements. You will get the <span class="global">error</span>, <span class="keyword">if</span> spawn element far away from other elements
- The grid can spawn elements only <span class="keyword">in</span> row <span class="keyword">or</span> <span class="keyword">in</span> column
- The grid node should have __West__, __East__, __South__ <span class="keyword">or</span> __North__ pivot (vertical <span class="keyword">or</span> horizontal element placement)
- Able to shift nodes left <span class="keyword">or</span> right on _grid:add_ / _grid:remove_ functions
</pre>
</li>
<li>Scroll update:
<pre>
- Add _scroll:set_vertical_scroll_ <span class="keyword">and</span> _scroll:set_horizontal_scroll_ <span class="keyword">for</span> disable scroll sides
- Add _scroll:bind_grid_ <span class="keyword">function</span>. Now is possible to bind Druid Grid component (Static <span class="keyword">or</span> Dynamic) to the scroll <span class="keyword">for</span> auto refresh the scroll size on grid nodes changing
</pre>
</li>
<li><strong>#37</strong> Add <em>on</em>layout<em>change</em> support. Druid will keep and restore GUI component data between changing game layout. Override function <em>on</em>layout<em>change</em> in your custom components to do stuff you need.</li>
<li><strong>#85</strong> Move several components from <code>base</code> folder to <code>extended</code>. In future to use them, you have to register them manually. This is done for decrease build size by excluding unused components</li>
<li><strong>Fix #61:</strong> Button component: fix button animation node creation</li>
<li><strong>Fix #64:</strong> Hover component: wrong mouse_hover default state</li>
<li><strong>Fix #71:</strong> Blocker: blocker now correct block mouse hover event</li>
<li><strong>Fix #72:</strong> Fix <code>return nil</code> in some <code>on_input</code> functions</li>
<li><strong>Fix #74:</strong> <strong>[BREAKING]</strong> Fix typo: strech -> stretch. Scroll function <code>set_extra_stretch_size</code> renamed</li>
<li><strong>Fix #76:</strong> Add params for lang text localization component</li>
<li><strong>Fix #79:</strong> Fix <em>druid:remove</em> inside on_input callback</li>
<li><strong>Fix #80:</strong> Fix <em>hover:set</em>enable_ typo function call</li>
<li><strong>Fix #88:</strong> Add <em>component:set</em>input<em>enabled</em> function to enable/disable input for druid component. Now you can disable input of any druid component, even complex (with other components inside)</li>
<li>Add <code>component.template.lua</code> as template for Druid custom component</li>
<li>Update the example app</li>
</ul>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-09-29 23:46:16 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View File

@ -1,162 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Button">Button </a></li>
<li><a href="#Text">Text </a></li>
<li><a href="#Blocker">Blocker </a></li>
<li><a href="#Back_Handler">Back Handler </a></li>
<li><a href="#Locale">Locale </a></li>
<li><a href="#Timer">Timer </a></li>
<li><a href="#Progress">Progress </a></li>
<li><a href="#Scroll">Scroll </a></li>
<li><a href="#Grid">Grid </a></li>
<li><a href="#Slider">Slider </a></li>
<li><a href="#Checkbox">Checkbox </a></li>
<li><a href="#Checkbox_group">Checkbox group </a></li>
<li><a href="#Radio_group">Radio group </a></li>
<li><a href="#Hover">Hover </a></li>
<li><a href="#Input">Input </a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><strong>Druid components</strong></li>
<li><a href="../topics/creating_custom_components.md.html">Creating custom components</a></li>
<li><a href="../topics/druid_assets.md.html">Druid assets</a></li>
<li><a href="../topics/examples.md.html">Examples</a></li>
<li><a href="../topics/styles.md.html">Styles</a></li>
<li><a href="../topics/README.md.html">README</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/druid.back_handler.html">druid.back_handler</a></li>
<li><a href="../modules/druid.blocker.html">druid.blocker</a></li>
<li><a href="../modules/druid.button.html">druid.button</a></li>
<li><a href="../modules/druid.checkbox.html">druid.checkbox</a></li>
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
<li><a href="../modules/druid.grid.html">druid.grid</a></li>
<li><a href="../modules/druid.hover.html">druid.hover</a></li>
<li><a href="../modules/druid.input.html">druid.input</a></li>
<li><a href="../modules/druid.lang_text.html">druid.lang_text</a></li>
<li><a href="../modules/druid.progress.html">druid.progress</a></li>
<li><a href="../modules/druid.radio_group.html">druid.radio_group</a></li>
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
<li><a href="../modules/druid.text.html">druid.text</a></li>
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
<li><a href="../modules/component.html">component</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/druid_event.html">druid_event</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
</ul>
</div>
<div id="content">
<h1>Druid components</h1>
<p><a name="Button"></a></p>
<h2>Button</h2>
<p>Basic game button</p>
<p><a name="Text"></a></p>
<h2>Text</h2>
<p>Wrap on text node with text size adjusting</p>
<p><a name="Blocker"></a></p>
<h2>Blocker</h2>
<p>Block input in node zone</p>
<p><a name="Back_Handler"></a></p>
<h2>Back Handler</h2>
<p>Handle back button (Android, backspace)</p>
<p><a name="Locale"></a></p>
<h2>Locale</h2>
<p>Text component with handle localization system</p>
<p><a name="Timer"></a></p>
<h2>Timer</h2>
<p>Run timer on text node</p>
<p><a name="Progress"></a></p>
<h2>Progress</h2>
<p>Basic progress bar</p>
<p><a name="Scroll"></a></p>
<h2>Scroll</h2>
<p>Basic scroll component</p>
<p><a name="Grid"></a></p>
<h2>Grid</h2>
<p>Component for manage node positions</p>
<p><a name="Slider"></a></p>
<h2>Slider</h2>
<p>Basic slider component</p>
<p><a name="Checkbox"></a></p>
<h2>Checkbox</h2>
<p>Basic checkbox component</p>
<p><a name="Checkbox_group"></a></p>
<h2>Checkbox group</h2>
<p>Several checkboxes in one group</p>
<p><a name="Radio_group"></a></p>
<h2>Radio group</h2>
<p>Several checkboxes in one group with single choice</p>
<p><a name="Hover"></a></p>
<h2>Hover</h2>
<p>Trigger component for check node hover state</p>
<p><a name="Input"></a></p>
<h2>Input</h2>
<p>Component to process user text input</p>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-03-21 22:59:46 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View File

@ -1,172 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/components.md.html">Druid components</a></li>
<li><strong>Custom components</strong></li>
<li><a href="../topics/druid_assets.md.html">Druid assets</a></li>
<li><a href="../topics/online_example.md.html">Online example</a></li>
<li><a href="../topics/styles.md.html">Styles</a></li>
<li><a href="../topics/README.md.html">README</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/druid.back_handler.html">druid.back_handler</a></li>
<li><a href="../modules/druid.blocker.html">druid.blocker</a></li>
<li><a href="../modules/druid.button.html">druid.button</a></li>
<li><a href="../modules/druid.checkbox.html">druid.checkbox</a></li>
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
<li><a href="../modules/druid.grid.html">druid.grid</a></li>
<li><a href="../modules/druid.hover.html">druid.hover</a></li>
<li><a href="../modules/druid.input.html">druid.input</a></li>
<li><a href="../modules/druid.lang_text.html">druid.lang_text</a></li>
<li><a href="../modules/druid.progress.html">druid.progress</a></li>
<li><a href="../modules/druid.radio_group.html">druid.radio_group</a></li>
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
<li><a href="../modules/druid.text.html">druid.text</a></li>
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
<li><a href="../modules/component.html">component</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/druid_event.html">druid_event</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
</ul>
</div>
<div id="content">
<h2>Custom components</h2>
<p>Add your custom components via <a href="../modules/druid.html#register">druid.register</a></p>
<pre>
<span class="keyword">local</span> druid = <span class="global">require</span>(<span class="string">"druid.druid"</span>)
<span class="keyword">local</span> my_component = <span class="global">require</span>(<span class="string">"my.amazing.component"</span>)
<span class="keyword">local</span> <span class="keyword">function</span> init(self)
druid.register(<span class="string">"my_component"</span>, my_component)
<span class="keyword">end</span>
</pre>
<p>Basic custom component template looks like this:</p>
<pre>
<span class="keyword">local</span> const = <span class="global">require</span>(<span class="string">"druid.const"</span>)
<span class="keyword">local</span> M = {}
M.interest = { const.ON_INPUT }
<span class="keyword">function</span> M.init(self, ...)
<span class="comment">-- Component constructor
</span><span class="keyword">end</span>
<span class="comment">-- Call only if exist interest: const.ON_UPDATE
</span><span class="keyword">function</span> M.update(self, dt)
<span class="keyword">end</span>
<span class="comment">-- Call only if exist interest: const.ON_INPUT or const.ON_SWIPE
</span><span class="keyword">function</span> M.on_input(self, action_id, action)
<span class="keyword">end</span>
<span class="comment">-- Call only if exist interest: const.ON_MESSAGE
</span><span class="keyword">function</span> M.on_message(self, message_id, message, sender)
<span class="keyword">end</span>
<span class="comment">-- Call only if swipe was started on another component (ex. scroll)
</span><span class="keyword">function</span> M.on_swipe(self)
<span class="keyword">end</span>
<span class="keyword">return</span> M
</pre>
<h2>Best practice on custom components</h2>
<p>On each component recomended describe component schema in next way:</p>
<pre>
<span class="comment">-- Component module
</span><span class="keyword">local</span> helper = <span class="global">require</span>(<span class="string">"druid.helper"</span>)
<span class="keyword">local</span> M = {}
<span class="keyword">local</span> SCHEME = {
ROOT = <span class="string">"/root"</span>,
ITEM = <span class="string">"/item"</span>,
TITLE = <span class="string">"/title"</span>
}
<span class="comment">-- TODO: Rework self.template/self.nodes
</span><span class="comment">-- Make self._inner_data? { component_name, template, nodes }
</span><span class="keyword">function</span> M.init(self, template_name, node_table)
<span class="comment">-- If component use template, setup it:
</span> self.template = template_name
<span class="comment">-- If component was cloned with gui.clone_tree, pass his nodes
</span> self.nodes = node_table
<span class="comment">-- helper can get node from gui/template/table
</span> <span class="keyword">local</span> root = helper.node(self, SCHEME.ROOT)
<span class="comment">-- This component can spawn another druid components:
</span> <span class="keyword">local</span> druid = helper.get_druid(self)
<span class="comment">-- Button self on callback is self of _this_ component
</span> <span class="keyword">local</span> button = druid:new_button(...)
<span class="comment">-- helper can return you the component style
</span> <span class="keyword">local</span> my_style = helper.get_style(self, <span class="string">"component_name"</span>)
<span class="keyword">end</span>
</pre>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-03-21 22:00:04 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View File

@ -1,200 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Overview">Overview </a></li>
<li><a href="#Custom_components">Custom components </a></li>
<li><a href="#Best_practice_on_custom_components">Best practice on custom components </a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/components.md.html">Druid components</a></li>
<li><strong>Creating custom components</strong></li>
<li><a href="../topics/druid_assets.md.html">Druid assets</a></li>
<li><a href="../topics/examples.md.html">Examples</a></li>
<li><a href="../topics/styles.md.html">Styles</a></li>
<li><a href="../topics/README.md.html">README</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/druid.back_handler.html">druid.back_handler</a></li>
<li><a href="../modules/druid.blocker.html">druid.blocker</a></li>
<li><a href="../modules/druid.button.html">druid.button</a></li>
<li><a href="../modules/druid.checkbox.html">druid.checkbox</a></li>
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
<li><a href="../modules/druid.grid.html">druid.grid</a></li>
<li><a href="../modules/druid.hover.html">druid.hover</a></li>
<li><a href="../modules/druid.input.html">druid.input</a></li>
<li><a href="../modules/druid.lang_text.html">druid.lang_text</a></li>
<li><a href="../modules/druid.progress.html">druid.progress</a></li>
<li><a href="../modules/druid.radio_group.html">druid.radio_group</a></li>
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
<li><a href="../modules/druid.text.html">druid.text</a></li>
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
<li><a href="../modules/component.html">component</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/druid_event.html">druid_event</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
</ul>
</div>
<div id="content">
<h1>Creating custom components</h1>
<p><a name="Overview"></a></p>
<h2>Overview</h2>
<p>Druid allows you to create your custom components from druid basic components or other custom components</p>
<p><a name="Custom_components"></a></p>
<h2>Custom components</h2>
<p>Basic custom component template looks like this:</p>
<pre>
<span class="keyword">local</span> const = <span class="global">require</span>(<span class="string">"druid.const"</span>)
<span class="keyword">local</span> component = <span class="global">require</span>(<span class="string">"druid.component"</span>)
<span class="keyword">local</span> M = component.create(<span class="string">"your_component"</span>)
<span class="comment">-- Component constructor
</span><span class="keyword">function</span> M.init(self, ...)
<span class="keyword">end</span>
<span class="comment">-- Call only if exist interest: const.ON_UPDATE
</span><span class="keyword">function</span> M.update(self, dt)
<span class="keyword">end</span>
<span class="comment">-- Call only if exist interest: const.ON_INPUT or const.ON_INPUT_HIGH
</span><span class="keyword">function</span> M.on_input(self, action_id, action)
<span class="keyword">end</span>
<span class="comment">-- Call only if exist interest: const.ON_MESSAGE
</span><span class="keyword">function</span> M.on_message(self, message_id, message, sender)
<span class="keyword">end</span>
<span class="comment">-- Call only if component with ON_CHANGE_LANGUAGE interest
</span><span class="keyword">function</span> M.on_change_language(self)
<span class="keyword">end</span>
<span class="comment">-- Call only if component with ON_LAYOUT_CHANGE interest
</span><span class="keyword">function</span> M.on_layout_change(self)
<span class="keyword">end</span>
<span class="keyword">return</span> M
</pre>
<p>Add your custom component to druid via <a href="../modules/druid.html#register">druid.register</a></p>
<pre>
<span class="keyword">local</span> druid = <span class="global">require</span>(<span class="string">"druid.druid"</span>)
<span class="keyword">local</span> my_component = <span class="global">require</span>(<span class="string">"my.amazing.component"</span>)
<span class="keyword">local</span> <span class="keyword">function</span> init(self)
druid.register(<span class="string">"my_component"</span>, my_component)
<span class="keyword">end</span>
</pre>
<h3>Interest</h3>
<p>Interest - is a way to indicate what events your component will respond to.
There is next interests in druid:
- <strong>ON_MESSAGE</strong> - component will receive messages from on_message</p>
<ul>
<li><p><strong>ON_UPDATE</strong> - component will be updated from update</p></li>
<li><p><strong>ON<em>INPUT</em>HIGH</strong> - component will receive input from on<em>input, before other components with ON</em>INPUT</p></li>
<li><p><strong>ON_INPUT</strong> - component will receive input from on<em>input, after other components with ON</em>INPUT_HIGH</p></li>
<li><p><strong>ON<em>CHANGE</em>LANGUAGE</strong> - will call <em>on</em>change<em>language</em> function on language change trigger</p></li>
<li><p><strong>ON<em>LAYOUT</em>CHANGED</strong> will call <em>on</em>layout<em>change</em> function on layout change trigger</p></li>
</ul>
<p><a name="Best_practice_on_custom_components"></a></p>
<h2>Best practice on custom components</h2>
<p>On each component recomended describe component scheme in next way:</p>
<pre>
<span class="comment">-- Component module
</span><span class="keyword">local</span> component = <span class="global">require</span>(<span class="string">"druid.component"</span>)
<span class="keyword">local</span> M = component.create(<span class="string">"your_component"</span>)
<span class="keyword">local</span> SCHEME = {
ROOT = <span class="string">"/root"</span>,
ITEM = <span class="string">"/item"</span>,
TITLE = <span class="string">"/title"</span>
}
<span class="keyword">function</span> M.init(self, template_name, node_table)
<span class="comment">-- If component use template, setup it:
</span> self:set_template(template_name)
<span class="comment">-- If component was cloned with gui.clone_tree, pass his nodes
</span> self:set_nodes(node_table)
<span class="comment">-- helper can get node from gui/template/table
</span> <span class="keyword">local</span> root = self:get_node(SCHEME.ROOT)
<span class="comment">-- This component can spawn another druid components:
</span> <span class="keyword">local</span> druid = self:get_druid()
<span class="comment">-- Button self on callback is self of _this_ component
</span> <span class="keyword">local</span> button = druid:new_button(...)
<span class="comment">-- helper can return you the component style for current component
</span> <span class="comment">-- It return by component name from
</span> <span class="keyword">local</span> my_style = self:get_style()
<span class="keyword">end</span>
</pre>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-03-21 22:59:46 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View File

@ -1,96 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Overview">Overview </a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/components.md.html">Druid components</a></li>
<li><a href="../topics/creating_custom_components.md.html">Creating custom components</a></li>
<li><strong>Druid assets</strong></li>
<li><a href="../topics/examples.md.html">Examples</a></li>
<li><a href="../topics/styles.md.html">Styles</a></li>
<li><a href="../topics/README.md.html">README</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/druid.back_handler.html">druid.back_handler</a></li>
<li><a href="../modules/druid.blocker.html">druid.blocker</a></li>
<li><a href="../modules/druid.button.html">druid.button</a></li>
<li><a href="../modules/druid.checkbox.html">druid.checkbox</a></li>
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
<li><a href="../modules/druid.grid.html">druid.grid</a></li>
<li><a href="../modules/druid.hover.html">druid.hover</a></li>
<li><a href="../modules/druid.input.html">druid.input</a></li>
<li><a href="../modules/druid.lang_text.html">druid.lang_text</a></li>
<li><a href="../modules/druid.progress.html">druid.progress</a></li>
<li><a href="../modules/druid.radio_group.html">druid.radio_group</a></li>
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
<li><a href="../modules/druid.text.html">druid.text</a></li>
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
<li><a href="../modules/component.html">component</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/druid_event.html">druid_event</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
</ul>
</div>
<div id="content">
<h1>Druid assets</h1>
<p><a name="Overview"></a></p>
<h2>Overview</h2>
<p>I've created <a href="https://github.com/Insality/druid-assets">druid-assets repository</a> to make a <em>marketplace</em> with custom styles and components.</p>
<p>Any of druid users can push their own components and styles to share it with the other users</p>
<p>Also, this marketplace is great example to how you can create your custom components</p>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-03-21 22:59:46 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View File

@ -1,94 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Overview">Overview </a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/components.md.html">Druid components</a></li>
<li><a href="../topics/creating_custom_components.md.html">Creating custom components</a></li>
<li><a href="../topics/druid_assets.md.html">Druid assets</a></li>
<li><strong>Examples</strong></li>
<li><a href="../topics/styles.md.html">Styles</a></li>
<li><a href="../topics/README.md.html">README</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/druid.back_handler.html">druid.back_handler</a></li>
<li><a href="../modules/druid.blocker.html">druid.blocker</a></li>
<li><a href="../modules/druid.button.html">druid.button</a></li>
<li><a href="../modules/druid.checkbox.html">druid.checkbox</a></li>
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
<li><a href="../modules/druid.grid.html">druid.grid</a></li>
<li><a href="../modules/druid.hover.html">druid.hover</a></li>
<li><a href="../modules/druid.input.html">druid.input</a></li>
<li><a href="../modules/druid.lang_text.html">druid.lang_text</a></li>
<li><a href="../modules/druid.progress.html">druid.progress</a></li>
<li><a href="../modules/druid.radio_group.html">druid.radio_group</a></li>
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
<li><a href="../modules/druid.text.html">druid.text</a></li>
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
<li><a href="../modules/component.html">component</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/druid_event.html">druid_event</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
</ul>
</div>
<div id="content">
<h1>Examples</h1>
<p><a name="Overview"></a></p>
<h2>Overview</h2>
<p>See the <a href="https://github.com/Insality/druid/tree/develop/example/kenney">example folder</a> for examples of how to use Druid</p>
<p>Try the HTML5 version of the example app</p>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-03-21 22:59:46 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View File

@ -1,161 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/01-components.md.html">01-components</a></li>
<li><a href="../topics/02-creating_custom_components.md.html">Creating custom components</a></li>
<li><a href="../topics/03-styles.md.html">Styles</a></li>
<li><a href="../topics/04-druid_assets.md.html">Druid assets</a></li>
<li><a href="../topics/05-examples.md.html">Examples</a></li>
<li><a href="../topics/changelog.md.html">Druid 0.3.0:</a></li>
<li><strong>faq</strong></li>
<li><a href="../topics/README.md.html">README</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/druid.back_handler.html">druid.back_handler</a></li>
<li><a href="../modules/druid.blocker.html">druid.blocker</a></li>
<li><a href="../modules/druid.button.html">druid.button</a></li>
<li><a href="../modules/druid.drag.html">druid.drag</a></li>
<li><a href="../modules/druid.hover.html">druid.hover</a></li>
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
<li><a href="../modules/druid.static_grid.html">druid.static_grid</a></li>
<li><a href="../modules/druid.swipe.html">druid.swipe</a></li>
<li><a href="../modules/druid.text.html">druid.text</a></li>
<li><a href="../modules/component.html">component</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/druid_event.html">druid_event</a></li>
<li><a href="../modules/druid.checkbox.html">druid.checkbox</a></li>
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
<li><a href="../modules/druid.dynamic_grid.html">druid.dynamic_grid</a></li>
<li><a href="../modules/druid.input.html">druid.input</a></li>
<li><a href="../modules/druid.lang_text.html">druid.lang_text</a></li>
<li><a href="../modules/druid.progress.html">druid.progress</a></li>
<li><a href="../modules/druid.radio_group.html">druid.radio_group</a></li>
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
</ul>
</div>
<div id="content">
<h1>Druid FAQ</h1>
<blockquote>
<p><em>Have questions about Druid? Ask me!</em>
<em>Here is questions you might have</em></p>
</blockquote>
<h3>Q: Why I want use Druid?</h3>
<p><strong>A:</strong> ---</p>
<h3>Q: How to remove the Druid component instance?</h3>
<p><strong>A:</strong> Any created <strong>Druid</strong> component can be removed with <em>druid:remove</em>. <a href="https://insality.github.io/druid/modules/druid_instance.html#druid:remove">API reference link</a>.</p>
<h3>Q: How to make scroll work?</h3>
<p><strong>A:</strong> ---</p>
<h3>Q: How the input is processing?</h3>
<p><strong>A:</strong>
<em>SImply</em>: the <strong>Druid</strong> has a LIFO queue to check input. Last added buttons have more priority than first. Placing your buttons from behind to the front is correct in most cases.</p>
<h3>Q: For what purpose Blocker component is exist?</h3>
<p><strong>A:</strong> Component explanation <a href="https://github.com/Insality/druid/blob/master/docs_md/01-components.md#notes-2">here</a>.
With Blocker you can block input in some zone. It is useful for make unclickable zone in buttons or kind of buttons panel on other big button (ex. close windows on window background click)</p>
<h3>Q: Which stuff can I do with custom components?</h3>
<p><strong>A:</strong> Any of you can imagine! There is a lot of examples, but in general: custom components allow you place component and some game logic separately from other stuff. It will be reusable, easier for testing and developing.</p>
<p>For example it can be element in scroll with buttons, your custom GUI widget or even component with your game logic. Usually custom components going with templates. You can do several templates for single component module (for different visuals!)</p>
<p>Some examples of custom components you can find <a href="https://github.com/Insality/druid-assets">here</a>.</p>
<h3>Q: How *self:get_node()* is working?</h3>
<p><strong>A:</strong> The node can be placed in gui directly or can be cloned via *gui.clone_tree()*. Also nodes can be placed as templates, so full node id will be composed from template name and node name (in cloned nodes too).</p>
<p><strong>Druid</strong> component *self:get<em>node()* trying to search in all of this places. Use *self:set</em>template()* and *self:set<em>component</em>nodes()* for correct setup component nodes before any call of *self:get_node()*.</p>
<p>Remember, usually you should pass <em><strong>string name</strong> of the node</em>, not gui node itself. It's better and more druid-way. </p>
<h3>Q: My button in scroll is clickable outside the stencil node</h3>
<p><strong>A:</strong> Since <strong>Druid</strong> checking click node with <em>gui.pick</em>node_, stencil is not prevent this. You can setup additional click zone on your buttons with <em>button:set</em>click<em>zone</em>.</p>
<p>The usual Druid way after add button to the scroll do:</p>
<pre>
<span class="comment">-- Scroll view node usually is stencil node
</span>button:set_click_zone(scroll.view_node)
</pre>
<h3>Q: How to use EmmyLua annotations? <em>(from Druid 0.6.0)</em></h3>
<p><strong>A:</strong> Since the dependencies can't be processed by external editors, for use generated EmmyLua annotations you should copy the <em>annotations.lua</em> to your project. For EmmyLua it will be enough. Remember you can <em>restart emmylua server</em> for refresh the changes, if something goes wrong.
After the annotations is processed, you should point the type of druid in requires:</p>
<pre>
<span class="comment">---@type druid
</span><span class="keyword">local</span> druid = <span class="global">require</span>(<span class="string">"druid.druid"</span>)
<span class="comment">-- Now the autocomplete is working</span>
</pre>
<h3>Q: When I should use *on<em>layout</em>change*?</h3>
<p><strong>A:</strong> ---</p>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-09-29 23:46:16 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View File

@ -1,86 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/components.md.html">Druid components</a></li>
<li><a href="../topics/create_custom_components.md.html">Custom components</a></li>
<li><a href="../topics/druid_assets.md.html">Druid assets</a></li>
<li><strong>Online example</strong></li>
<li><a href="../topics/styles.md.html">Styles</a></li>
<li><a href="../topics/README.md.html">README</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/druid.back_handler.html">druid.back_handler</a></li>
<li><a href="../modules/druid.blocker.html">druid.blocker</a></li>
<li><a href="../modules/druid.button.html">druid.button</a></li>
<li><a href="../modules/druid.checkbox.html">druid.checkbox</a></li>
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
<li><a href="../modules/druid.grid.html">druid.grid</a></li>
<li><a href="../modules/druid.hover.html">druid.hover</a></li>
<li><a href="../modules/druid.input.html">druid.input</a></li>
<li><a href="../modules/druid.lang_text.html">druid.lang_text</a></li>
<li><a href="../modules/druid.progress.html">druid.progress</a></li>
<li><a href="../modules/druid.radio_group.html">druid.radio_group</a></li>
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
<li><a href="../modules/druid.text.html">druid.text</a></li>
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
<li><a href="../modules/component.html">component</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/druid_event.html">druid_event</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
</ul>
</div>
<div id="content">
<h1>Online example</h1>
<p>Check druid --here-- (link)</p>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-03-21 22:00:04 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View File

@ -1,145 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Defold Druid UI Library</title>
<link rel="stylesheet" href="../ldoc_fixed.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Druid</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Overview">Overview </a></li>
<li><a href="#Usage">Usage </a></li>
<li><a href="#Create_custom_components">Create custom components </a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/components.md.html">Druid components</a></li>
<li><a href="../topics/creating_custom_components.md.html">Creating custom components</a></li>
<li><a href="../topics/druid_assets.md.html">Druid assets</a></li>
<li><a href="../topics/examples.md.html">Examples</a></li>
<li><strong>Styles</strong></li>
<li><a href="../topics/README.md.html">README</a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/druid.back_handler.html">druid.back_handler</a></li>
<li><a href="../modules/druid.blocker.html">druid.blocker</a></li>
<li><a href="../modules/druid.button.html">druid.button</a></li>
<li><a href="../modules/druid.checkbox.html">druid.checkbox</a></li>
<li><a href="../modules/druid.checkbox_group.html">druid.checkbox_group</a></li>
<li><a href="../modules/druid.grid.html">druid.grid</a></li>
<li><a href="../modules/druid.hover.html">druid.hover</a></li>
<li><a href="../modules/druid.input.html">druid.input</a></li>
<li><a href="../modules/druid.lang_text.html">druid.lang_text</a></li>
<li><a href="../modules/druid.progress.html">druid.progress</a></li>
<li><a href="../modules/druid.radio_group.html">druid.radio_group</a></li>
<li><a href="../modules/druid.scroll.html">druid.scroll</a></li>
<li><a href="../modules/druid.slider.html">druid.slider</a></li>
<li><a href="../modules/druid.text.html">druid.text</a></li>
<li><a href="../modules/druid.timer.html">druid.timer</a></li>
<li><a href="../modules/component.html">component</a></li>
<li><a href="../modules/druid.html">druid</a></li>
<li><a href="../modules/druid_event.html">druid_event</a></li>
<li><a href="../modules/druid.helper.html">druid.helper</a></li>
<li><a href="../modules/druid_instance.html">druid_instance</a></li>
</ul>
</div>
<div id="content">
<h1>Styles</h1>
<p><a name="Overview"></a></p>
<h2>Overview</h2>
<p>Styles - set of functions and parameters for components to customize their behavior.</p>
<p>Styles is a table, where key is name of component, and value is style table for this component.</p>
<p>In component API documentation, you can find the style API for this component. Or just lookup for existing styles and modify them.</p>
<p><a name="Usage"></a></p>
<h2>Usage</h2>
<p>Setup default druid style for all druid instances via <code>druid.set_default_style</code></p>
<pre>
<span class="keyword">local</span> druid = <span class="global">require</span>(<span class="string">"druid.druid"</span>)
<span class="keyword">local</span> my_style = <span class="global">require</span>(<span class="string">"my.amazing.style"</span>)
<span class="keyword">local</span> <span class="keyword">function</span> init(self)
druid.set_default_style(my_style)
<span class="keyword">end</span>
</pre>
<p>Setup custom style to specific druid instance:</p>
<pre>
<span class="keyword">local</span> druid = <span class="global">require</span>(<span class="string">"druid.druid"</span>)
<span class="keyword">local</span> my_style = <span class="global">require</span>(<span class="string">"my.amazing.style"</span>)
<span class="keyword">local</span> <span class="keyword">function</span> init(self)
<span class="comment">-- This druid instance will be use my_style as default
</span> self.druid = druid.new(self, my_style)
<span class="keyword">end</span>
</pre>
<p>Change component style with <em>set</em>style_ function</p>
<pre>
<span class="keyword">local</span> druid = <span class="global">require</span>(<span class="string">"druid.druid"</span>)
<span class="keyword">local</span> my_style = <span class="global">require</span>(<span class="string">"my.amazing.style"</span>)
<span class="keyword">local</span> <span class="keyword">function</span> init(self)
self.druid = druid.new(self)
self.button = self.druid:new_button(self, <span class="string">"node"</span>)
<span class="comment">-- Setup custom style for specific component
</span> self.button:set_style(my_style)
<span class="keyword">end</span>
</pre>
<p><a name="Create_custom_components"></a></p>
<h2>Create custom components</h2>
<p>Styles is just lua table, so it can be described in just one single file
<strong>TODO</strong></p>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-03-21 22:59:46 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>

View File

@ -240,7 +240,7 @@ Create timer component with druid: `timer = druid:new_timer(text_node, from_seco
### Notes
- Timer fires callback, when timer value equals to _to_seconds_
- Timer will setup text node with current timer value
- Timer will set text node with current timer value
- Timer uses update function to handle time
@ -256,7 +256,7 @@ Static grid can shift elements on add/remove functions.
Create component with druid: `grid = druid:new_static_grid(parent_node, prefab_node, max_in_row_elements)`
### Notes
- On _add node_ grid will set node parent to _parent_node_
- On _add node_ grid will set nodeup parent to _parent_node_
- You can get array of position of every element for setup points of interest in scroll component
- You can get size of all elements for setup size in scroll component
- You can also bind the grid to the scroll component for auto resize scroll content size
@ -271,7 +271,8 @@ Create component with druid: `grid = druid:new_static_grid(parent_node, prefab_
### Overview
Component for manage node positions with different node sizes.
Unlike Static Grid, Dynamic Grid can place nodes only in one row or in one column.
Dynamic Grid can't have gaps between elements - you will get error, if try spawn element far away from others.
Dynamic Grid can't have gaps between elements
- you will get error, if try spawn element far away from others.
Dynamic Grid should have __West__, __East__, __South__ or __North__ pivot (vertical or horizontal element placement)
### Setup
@ -287,7 +288,7 @@ Check the _parent_node_ have correct pivot point. You will get the error otherwi
- Pivot of parent_node matter for node placement
- You can point *position_function* for animations with _static_grid:set_position_function(node, pos)_ callback. Default - *gui.set_position()*
- First node placed at Grid pivot point. Other nodes placed nearby of other nodes.
- On *add/remove* nodes always shifted. You can point the shift side in this functions (*is_shift_left* boolean argument)
- On *add/remove* nodes always shifted. You can point the shift side in this functions (*is_shift_left* boolean argumentp
## Hover
[Hover API here](https://insality.github.io/druid/modules/druid.hover.html)

View File

@ -11,7 +11,6 @@ Every component is the children of Basic Druid component. Read the [basic compon
Basic custom component template looks like this:
```lua
local const = require("druid.const")
local component = require("druid.component")
local M = component.create("my_component")
@ -20,11 +19,11 @@ local M = component.create("my_component")
function M.init(self, ...)
end
-- Call only if exist interest: const.ON_UPDATE
-- Call only if exist interest: component.ON_UPDATE
function M.update(self, dt)
end
-- Call only if exist interest: const.ON_INPUT or const.ON_INPUT_HIGH
-- Call only if exist interest: component.ON_INPUT or component.ON_INPUT_HIGH
function M.on_input(self, action_id, action)
end
@ -32,7 +31,7 @@ end
function M.on_style_change(self, style)
end
-- Call only if exist interest: const.ON_MESSAGE
-- Call only if exist interest: component.ON_MESSAGE
function M.on_message(self, message_id, message, sender)
end

View File

@ -131,3 +131,74 @@ Also check _component.template.lua_ what you can use for your own custom compone
- Add `component.template.lua` as template for Druid custom component
- Update the example app
### Druid 0.6.0:
Hey! Are you tired from **Druid** updates? _(It's a joke)_
Finally, got a time to release component to process huge amount of data. So introducing: **DataList** component. I can't say what it's "infinity" scroll, but it can help to solve your problem with `GUI nodes limit reached` and helps with scroll optimization. Give feedback about it!
The next important stuff is **EmmyLua** docs. I'm implemented EmmyLua doc generator from LuaDoc and Protofiles, so now you can use EmmyLua annotations inside your IDE instead of website API looking or source code scanning.
Also the **Druid examples** is reworked, so each example will be in separate collection. Now it's become a much easier to learn Druid via examples. A lot of stuff in progress now, but you already can see on it!
Input priority got reworked too. Now instead of two input stacks: usual and high, Druid use simple input priority value.
And I should note here is several breaking changes, take a look in changelogs.
Wanna something more? [Add an issues!](https://github.com/Insality/druid/issues)
Have a good day.
**Changelog 0.6.0**
---
- **#43** Add **DataList** Druid extended component. Component used to manage huge amount of data to make stuff like _infinity_ scroll.
- This versions is first basic implementation. But it should be enough for almost all basic stuff.
- Create Data List with `druid:new_data_list(scroll, grid, create_function)`.
- _scroll_ - already created __Scroll__ component
- _grid_ - already created __StaticGrid__ or __DynamicGrid__ component
- _create_function_ - your function to create node instances. This callback have next parameters: `fun(self, data, index, data_list)`
- _self_ - Script/Druid context
- _data_- your element data
- _index_ - element index
- _data_list_ - current __DataList__ component
- Create function should return root node and optionaly, _Druid_ component. It's required to manage create/remove lifecycle
- Set data with `data_list:set_data({...})`
- In current version there is no `add/remove` functions
- Add EmmyLua annotations (_ta-daaa_). See how to [use it FAQ](https://github.com/Insality/druid/blob/develop/docs_md/FAQ.md)!
- Add context argument to Druid Event. You can pass this argument to forward it first in your callbacks (for example - object context)
- Add _SHIFT_POLICY_ for _Static_ and _Dynamic_ Grids. It mean how nodes will be shifted if you append data between nodes. There are `const.SHIFT.RIGHT`, `const.SHIFT.LEFT` and `const.SHIFT.NO_SHIFT`.
- __[BREAKING]__ Please check your `StaticGrid:remove` and `DynamicGrid:remove` functions
- **#102** __[BREAKING]__ Removed `component:increase_input_priority` component function. Use `component:set_input_priority` function instead. The bigger priority value processed first. The value 10 is default for Druid components, the 100 value is maximum priority for acquire input in _drag_ and _input_ components
- Add constants for priorities: _const.PRIORITY_INPUT_, _const.PRIORITY_INPUT_HIGH_, _const.PRIORITY_INPUT_MAX_.
- __[BREAKING]__ If you use in you custom components interest: `component.ON_INPUT_HIGH` you should replace it with `component.ON_INPUT` and add `const.PRIORITY_INPUT_HIGH` as third param. For example:
_before:_
```lua
local Drag = component.create("drag", { component.ON_INPUT_HIGH })
```
_after:_
```lua
local Drag = component.create("drag", { component.ON_INPUT }, const.PRIORITY_INPUT_HIGH)
```
- Lang text now can be initialized without default locale id
- Input component: rename field _selected_ to _is_selected_ (according to the docs)
- **#92** Setup repo for CI and unit tests. (Yea, successful build and tests badges!)
- **#86** Fix a lot of event triggers on scroll inertia moving
- **#101** Fix scroll to other node instead of swipe direction with scroll's points of interest (without inert settings)
- **#103** Add `helper.centate_nodes` function. It can horizontal align several Box and Text nodes
- **#105** Add `Input:select` and `Input:unselect` function.
- **#106** Add `Input.style.IS_UNSELECT_ON_RESELECT` style param. If true, it will be unselect input on click on input box, not only on outside click.
- **#108** Add component interests const to `component.lua`
- **#116** You can pass Text component in Input component instead of text node
- **#117** Move each Druid example in separate collection. It's a lot of easier now to learn via examples, check it!
- Examples in progress, so a lot of stuff are locked now, stay tuned!
- **#118** Druid.scroll freezes if held in one place for a long time
- **#123** Add scroll for Scroll component via mouse wheel or touchpad:
- Added Scroll style params: `WHEEL_SCROLL_SPEED`, `WHEEL_SCROLL_INVERTED`
- Mouse scroll working when cursor is hover on scroll view node
- Vertical scroll have more priority than horizontal
- Fix: When Hover component node became disabled, reset hover state (throw on_hover and on_mouse_hover events)
- By default mouse scroll is disabled
- This is basic implementation, it is work not perfect
- **#124** Add `Scroll:set_click_zone` function. This is just link to `Drag:set_click_zone` function inside scroll component.
- **#127** The `druid:create` is deprecated. Use `druid:new` for creating custom components

View File

@ -1,37 +1,38 @@
--- Component to handle back key (android, backspace)
-- @module druid.back_handler
-- @module BackHandler
-- @within BaseComponent
-- @alias druid.back_handler
--- Component events
-- @table Events
-- @tfield druid_event on_back On back handler callback
--- On back handler callback(self, params)
-- @tfield druid_event on_back
--- Component fields
-- @table Fields
-- @tfield any params Params to click callbacks
--- Params to back callback
-- @tfield any params
---
local Event = require("druid.event")
local const = require("druid.const")
local component = require("druid.component")
local BackHandler = component.create("back_handler", { const.ON_INPUT })
local BackHandler = component.create("back_handler", { component.ON_INPUT })
--- Component init function
-- @function back_handler:init
-- @tparam BackHandler self
-- @tparam callback callback On back button
-- @tparam[opt] params Callback argument
function BackHandler:init(callback, params)
-- @tparam[opt] any params Callback argument
function BackHandler.init(self, callback, params)
self.params = params
self.on_back = Event(callback)
end
--- Input handler for component
-- @function back_handler:on_input
-- @tparam BackHandler self
-- @tparam string action_id on_input action id
-- @tparam table action on_input action
function BackHandler:on_input(action_id, action)
function BackHandler.on_input(self, action_id, action)
if not action[const.RELEASED] then
return false
end

View File

@ -1,34 +1,28 @@
--- Component to block input on specify zone by node
-- @module druid.blocker
-- @module Blocker
-- @within BaseComponent
-- @alias druid.blocker
--- Component events
-- @table Events
-- @tfield druid_event on_click On release button callback
-- @tfield druid_event on_enable_change On enable/disable callback
---Trigger node
-- @tfield node node
--- Component fields
-- @table Fields
-- @tfield node node Trigger node
---
local Event = require("druid.event")
local const = require("druid.const")
local component = require("druid.component")
local Blocker = component.create("blocker", { const.ON_INPUT })
local Blocker = component.create("blocker", { component.ON_INPUT })
--- Component init function
-- @function blocker:init
-- @tparam Blocker self
-- @tparam node node Gui node
function Blocker:init(node)
function Blocker.init(self, node)
self.node = self:get_node(node)
self.on_click = Event()
self.on_enable_change = Event()
end
function Blocker:on_input(action_id, action)
function Blocker.on_input(self, action_id, action)
if action_id ~= const.ACTION_TOUCH and
action_id ~= const.ACTION_MULTITOUCH and
action_id ~= nil then
@ -48,17 +42,17 @@ end
--- Set enabled blocker component state
-- @function blocker:set_enabled
-- @tparam Blocker self
-- @tparam bool state Enabled state
function Blocker:set_enabled(state)
function Blocker.set_enabled(self, state)
gui.set_enabled(self.node, state)
end
--- Return blocked enabled state
-- @function blocker:is_enabled
-- @tparam Blocker self
-- @treturn bool True, if blocker is enabled
function Blocker:is_enabled(state)
function Blocker.is_enabled(self)
return gui.is_enabled(self.node)
end

View File

@ -1,32 +1,58 @@
--- Component to handle basic GUI button
-- @module druid.button
-- @module Button
-- @within BaseComponent
-- @alias druid.button
--- Component events
-- @table Events
-- @tfield druid_event on_click (self, params, button_instance) On release button callback
-- @tfield druid_event on_repeated_click (self, params, button_instance, click_amount) On repeated action button callback
-- @tfield druid_event on_long_click (self, params, button_instance, time) On long tap button callback
-- @tfield druid_event on_double_click (self, params, button_instance, click_amount) On double tap button callback
-- @tfield druid_event on_hold_callback (self, params, button_instance, time) On button hold before long_click callback
-- @tfield druid_event on_click_outside (self, params, button_instance) On click outside of button
--- On release button callback(self, params, button_instance)
-- @tfield druid_event on_click
--- Component fields
-- @table Fields
-- @tfield node node Trigger node
-- @tfield[opt=node] node anim_node Animation node
-- @tfield vector3 start_scale Initial scale of anim_node
-- @tfield vector3 start_pos Initial pos of anim_node
-- @tfield vector3 pos Initial pos of anim_node
-- @tfield any params Params to click callbacks
-- @tfield druid.hover hover Druid hover logic component
-- @tfield[opt] node click_zone Restriction zone
--- On repeated action button callback(self, params, button_instance, click_amount)
-- @tfield druid_event on_repeated_click
---On long tap button callback(self, params, button_instance, time)
-- @tfield druid_event on_long_click
---On double tap button callback(self, params, button_instance, click_amount)
-- @tfield druid_event on_double_click
---On button hold before long_click callback(self, params, button_instance, time)
-- @tfield druid_event on_hold_callback
---On click outside of button(self, params, button_instance)
-- @tfield druid_event on_click_outside
---Trigger node
-- @tfield node node
---Animation node
-- @tfield[opt=node] node anim_node
---Initial scale of anim_node
-- @tfield vector3 start_scale
---Initial pos of anim_node
-- @tfield vector3 start_pos
---Initial pos of anim_node
-- @tfield vector3 pos
---Params to click callbacks
-- @tfield any params
---Druid hover logic component
-- @tfield druid.hover hover
---Restriction zone
-- @tfield[opt] node click_zone
---
local Event = require("druid.event")
local const = require("druid.const")
local helper = require("druid.helper")
local component = require("druid.component")
local Button = component.create("button", { const.ON_INPUT })
local Button = component.create("button", { component.ON_INPUT })
local function is_input_match(self, action_id)
@ -132,7 +158,7 @@ end
--- Component style params.
-- You can override this component styles params in druid styles table
-- 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.8] number AUTOHOLD_TRIGGER Maximum hold time to trigger button release while holding
-- @tfield[opt=0.4] number DOUBLETAP_TIME Time between double taps
@ -141,7 +167,7 @@ end
-- @tfield function on_hover (self, node, hover_state)
-- @tfield function on_mouse_hover (self, node, hover_state)
-- @tfield function on_set_enabled (self, node, enabled_state)
function Button:on_style_change(style)
function Button.on_style_change(self, style)
self.style = {}
self.style.LONGTAP_TIME = style.LONGTAP_TIME or 0.4
self.style.AUTOHOLD_TRIGGER = style.AUTOHOLD_TRIGGER or 0.8
@ -156,12 +182,12 @@ end
--- Component init function
-- @function button:init
-- @tparam Button self
-- @tparam node node Gui node
-- @tparam function callback Button callback
-- @tparam[opt] table params Button callback params
-- @tparam[opt] node anim_node Button anim node (node, if not provided)
function Button:init(node, callback, params, anim_node)
function Button.init(self, node, callback, params, anim_node)
self.druid = self:get_druid()
self.node = self:get_node(node)
@ -188,7 +214,7 @@ function Button:init(node, callback, params, anim_node)
end
function Button:on_input(action_id, action)
function Button.on_input(self, action_id, action)
if not is_input_match(self, action_id) then
return false
end
@ -257,16 +283,16 @@ function Button:on_input(action_id, action)
end
function Button:on_input_interrupt()
function Button.on_input_interrupt(self)
self.can_action = false
end
--- Set enabled button component state
-- @function button:set_enabled
-- @tparam Button self
-- @tparam bool state Enabled state
-- @treturn druid.button Current button instance
function Button:set_enabled(state)
-- @treturn Button Current button instance
function Button.set_enabled(self, state)
self.disabled = not state
self.hover:set_enabled(state)
self.style.on_set_enabled(self, self.node, state)
@ -276,19 +302,19 @@ end
--- Return button enabled state
-- @function button:is_enabled
-- @tparam Button self
-- @treturn bool True, if button is enabled
function Button:is_enabled()
function Button.is_enabled(self)
return not self.disabled
end
--- Strict button click area. Useful for
-- no click events outside stencil node
-- @function button:set_click_zone
-- @tparam Button self
-- @tparam node zone Gui node
-- @treturn druid.button Current button instance
function Button:set_click_zone(zone)
-- @treturn Button Current button instance
function Button.set_click_zone(self, zone)
self.click_zone = self:get_node(zone)
self.hover:set_click_zone(zone)
@ -297,10 +323,10 @@ end
--- Set key-code to trigger this button
-- @function button:set_key_trigger
-- @tparam Button self
-- @tparam hash key The action_id of the key
-- @treturn druid.button Current button instance
function Button:set_key_trigger(key)
-- @treturn Button Current button instance
function Button.set_key_trigger(self, key)
self.key_trigger = hash(key)
return self
@ -308,9 +334,9 @@ end
--- Get key-code to trigger this button
-- @function button:get_key_trigger
-- @tparam Button self
-- @treturn hash The action_id of the key
function Button:get_key_trigger()
function Button.get_key_trigger(self)
return self.key_trigger
end

View File

@ -2,32 +2,54 @@
-- Drag have correct handling for multitouch and swap
-- touched while dragging. Drag will be processed even
-- the cursor is outside of node, if drag is already started
-- @module druid.drag
-- @module Drag
-- @within BaseComponent
-- @alias druid.drag
--- Component events
-- @table Events
-- @tfield druid_event on_touch_start (self) Event on touch start
-- @tfield druid_event on_touch_end (self) Event on touch end
-- @tfield druid_event on_drag_start (self) Event on drag start
-- @tfield druid_event on_drag (self, dx, dy) Event on drag progress
-- @tfield druid_event on_drag_end (self) Event on drag end
--- Event on touch start callback(self)
-- @tfield druid_event on_touch_start
--- Components fields
-- @table Fields
-- @tfield bool is_touch Is component now touching
-- @tfield bool is_drag Is component now dragging
-- @tfield bool can_x Is drag component process vertical dragging. Default - true
-- @tfield bool can_y Is drag component process horizontal. Default - true
-- @tfield number x Current touch x position
-- @tfield number y Current touch y position
-- @tfield vector3 touch_start_pos Touch start position
--- Event on touch end callback(self)
-- @tfield druid_event on_touch_end
--- Event on drag start callback(self)
-- @tfield druid_event on_drag_start
--- on drag progress callback(self, dx, dy)
-- @tfield druid_event on_drag Event
--- Event on drag end callback(self)
-- @tfield druid_event on_drag_end
--- Is component now touching
-- @tfield bool is_touch
--- Is component now dragging
-- @tfield bool is_drag
--- Is drag component process vertical dragging. Default - true
-- @tfield bool can_x
--- Is drag component process horizontal. Default - true
-- @tfield bool can_y
--- Current touch x position
-- @tfield number x
--- Current touch y position
-- @tfield number y
--- Touch start position
-- @tfield vector3 touch_start_pos
---
local Event = require("druid.event")
local const = require("druid.const")
local helper = require("druid.helper")
local component = require("druid.component")
local Drag = component.create("drag", { const.ON_INPUT_HIGH })
local Drag = component.create("drag", { component.ON_INPUT }, const.PRIORITY_INPUT_HIGH)
local function start_touch(self, touch)
@ -50,8 +72,10 @@ local function end_touch(self)
end
self.is_drag = false
self.is_touch = false
self.on_touch_end:trigger(self:get_context())
if self.is_touch then
self.is_touch = false
self.on_touch_end:trigger(self:get_context())
end
self:reset_input_priority()
self.touch_id = 0
end
@ -70,7 +94,7 @@ local function process_touch(self, touch)
if not self.is_drag and distance >= self.style.DRAG_DEADZONE then
self.is_drag = true
self.on_drag_start:trigger(self:get_context())
self:increase_input_priority()
self:set_input_priority(const.PRIORITY_INPUT_MAX)
end
end
@ -127,19 +151,19 @@ end
--- Component style params.
-- You can override this component styles params in druid styles table
-- or create your own style
-- @table Style
-- @table style
-- @tfield[opt=10] number DRAG_DEADZONE Distance in pixels to start dragging
function Drag:on_style_change(style)
function Drag.on_style_change(self, style)
self.style = {}
self.style.DRAG_DEADZONE = style.DRAG_DEADZONE or 10
end
--- Drag component constructor
-- @tparam Drag self
-- @tparam node node GUI node to detect dragging
-- @tparam function on_drag_callback Callback for on_drag_event(self, dx, dy)
-- @function drag:init
function Drag:init(node, on_drag_callback)
function Drag.init(self, node, on_drag_callback)
self.node = self:get_node(node)
self.dx = 0
@ -163,14 +187,14 @@ function Drag:init(node, on_drag_callback)
end
function Drag:on_input_interrupt()
function Drag.on_input_interrupt(self)
if self.is_drag or self.is_touch then
end_touch(self)
end
end
function Drag:on_input(action_id, action)
function Drag.on_input(self, action_id, action)
if action_id ~= const.ACTION_TOUCH and action_id ~= const.ACTION_MULTITOUCH then
return false
end
@ -241,10 +265,10 @@ end
--- Strict drag click area. Useful for
-- restrict events outside stencil node
-- @function drag:set_click_zone
-- @tparam node zone Gui node
function Drag:set_click_zone(zone)
self.click_zone = self:get_node(zone)
-- @tparam Drag self
-- @tparam node node Gui node
function Drag.set_click_zone(self, node)
self.click_zone = self:get_node(node)
end

View File

@ -1,46 +1,54 @@
--- Component to handle hover node interaction
-- @module druid.hover
-- @module Hover
-- @within BaseComponent
-- @alias druid.hover
--- Component events
-- @table Events
-- @tfield druid_event on_hover On hover callback (Touch pressed)
-- @tfield druid_event on_mouse_hover On mouse hover callback (Touch over without action_id)
--- On hover callback(self, state)
-- @tfield druid_event on_hover
--- On mouse hover callback(self, state)
-- @tfield druid_event on_mouse_hover
---
local Event = require("druid.event")
local const = require("druid.const")
local helper = require("druid.helper")
local component = require("druid.component")
local Hover = component.create("hover", { const.ON_INPUT })
local Hover = component.create("hover", { component.ON_INPUT })
--- Component init function
-- @function hover:init
-- @tparam Hover self
-- @tparam node node Gui node
-- @tparam function on_hover_callback Hover callback
function Hover:init(node, on_hover_callback)
function Hover.init(self, node, on_hover_callback)
self.node = self:get_node(node)
self._is_hovered = false
self._is_mouse_hovered = false
self._is_enabled = true
self._is_mobile = helper.is_mobile()
self.on_hover = Event(on_hover_callback)
self.on_mouse_hover = Event()
end
function Hover:on_input(action_id, action)
function Hover.on_input(self, action_id, action)
if action_id ~= const.ACTION_TOUCH and action_id ~= nil then
return false
end
if not action_id and helper.is_mobile() then
-- Disable nil (it's mouse) hover or mobile platforms
if self._is_mobile and not action_id then
return false
end
if not helper.is_enabled(self.node) or not self._is_enabled then
self:set_hover(false)
self:set_mouse_hover(false)
return false
end
@ -64,15 +72,15 @@ function Hover:on_input(action_id, action)
end
function Hover:on_input_interrupt()
function Hover.on_input_interrupt(self)
self:set_hover(false)
end
--- Set hover state
-- @function hover:set_hover
-- @tparam Hover self
-- @tparam bool state The hover state
function Hover:set_hover(state)
function Hover.set_hover(self, state)
if self._is_hovered ~= state then
self._is_hovered = state
self.on_hover:trigger(self:get_context(), state)
@ -80,9 +88,9 @@ function Hover:set_hover(state)
end
--- Set mouse hover state
-- @function hover:set_mouse_hover
-- @tparam Hover self
-- @tparam bool state The mouse hover state
function Hover:set_mouse_hover(state)
function Hover.set_mouse_hover(self, state)
if self._is_mouse_hovered ~= state then
self._is_mouse_hovered = state
self.on_mouse_hover:trigger(self:get_context(), state)
@ -92,9 +100,9 @@ end
--- Strict hover click area. Useful for
-- no click events outside stencil node
-- @function hover:set_click_zone
-- @tparam Hover self
-- @tparam node zone Gui node
function Hover:set_click_zone(zone)
function Hover.set_click_zone(self, zone)
self.click_zone = self:get_node(zone)
end
@ -102,9 +110,9 @@ end
--- Set enable state of hover component.
-- If hover is not enabled, it will not generate
-- any hover events
-- @function hover:set_enabled
-- @tparam Hover self
-- @tparam bool state The hover enabled state
function Hover:set_enabled(state)
function Hover.set_enabled(self, state)
self._is_enabled = state
if not state then
@ -119,9 +127,9 @@ end
--- Return current hover enabled state
-- @function hover:is_enabled
-- @tparam Hover self
-- @treturn bool The hover enabled state
function Hover:is_enabled()
function Hover.is_enabled(self)
return self._is_enabled
end

View File

@ -5,34 +5,61 @@
-- Setup initial scroll size by changing scroll parent size. If scroll parent
-- size will be less than scroll_input size, no scroll is available. For scroll
-- parent size should be more than input size
-- @module druid.scroll
-- @module Scroll
-- @within BaseComponent
-- @alias druid.scroll
--- Component events
-- @table Events
-- @tfield druid_event on_scroll On scroll move callback
-- @tfield druid_event on_scroll_to On scroll_to function callback
-- @tfield druid_event on_point_scroll On scroll_to_index function callback
--- Component fields
-- @table Fields
-- @tfield node view_node Scroll view node
-- @tfield node content_node Scroll content node
-- @tfield bool is_inert Flag, if scroll now moving by inertion
-- @tfield vector3 inertion Current inert speed
-- @tfield vector3 position Current scroll posisition
-- @tfield vector3 target_position Current scroll target position
-- @tfield vector4 available_pos Available position for content node: (min_x, max_y, max_x, min_y)
-- @tfield vector3 available_size Size of available positions: (width, height, 0)
-- @tfield druid.drag drag Drag component
-- @tfield[opt] selected Current index of points of interests
-- @tfield bool is_animate Flag, if scroll now animating by gui.animate
--- On scroll move callback(self, position)
-- @tfield druid_event on_scroll
--- On scroll_to function callback(self, target, is_instant)
-- @tfield druid_event on_scroll_to
--- On scroll_to_index function callback(self, index, point)
-- @tfield druid_event on_point_scroll
--- Scroll view node
-- @tfield node view_node
--- Scroll content node
-- @tfield node content_node
--- Flag, if scroll now moving by inertion
-- @tfield bool is_inert
--- Current inert speed
-- @tfield vector3 inertion
--- Current scroll posisition
-- @tfield vector3 position
--- Current scroll target position
-- @tfield vector3 target_position
--- Available position for content node: (min_x, max_y, max_x, min_y)
-- @tfield vector4 available_pos
--- Size of available positions: (width, height, 0)
-- @tfield vector3 available_size
--- Drag Druid component
-- @tfield Drag drag
--- Current index of points of interests
-- @tfield[opt] number selected
--- Flag, if scroll now animating by gui.animate
-- @tfield bool is_animate
---
local Event = require("druid.event")
local const = require("druid.const")
local helper = require("druid.helper")
local component = require("druid.component")
local Scroll = component.create("scroll", { const.ON_UPDATE, const.ON_LAYOUT_CHANGE })
local Scroll = component.create("scroll", { component.ON_INPUT, component.ON_UPDATE, component.ON_LAYOUT_CHANGE })
local function inverse_lerp(min, max, current)
@ -43,14 +70,17 @@ end
--- Update vector with next conditions:
-- Field x have to <= field z
-- Field y have to <= field w
local function get_border_vector(vector)
local function get_border_vector(vector, offset)
if vector.x > vector.z then
vector.x, vector.z = vector.z, vector.x
end
if vector.y > vector.w then
vector.y, vector.w = vector.w, vector.y
end
vector.x = vector.x - offset.x
vector.z = vector.z - offset.x
vector.y = vector.y - offset.y
vector.w = vector.w - offset.y
return vector
end
@ -64,7 +94,7 @@ end
--- Component style params.
-- You can override this component styles params in druid styles table
-- or create your own style
-- @table Style
-- @table style
-- @tfield[opt=0] number FRICT Multiplier for free inertion
-- @tfield[opt=0] number FRICT_HOLD Multiplier for inertion, while touching
-- @tfield[opt=3] number INERT_THRESHOLD Scroll speed to stop inertion
@ -74,7 +104,9 @@ end
-- @tfield[opt=0.2] number ANIM_SPEED Scroll gui.animation speed for scroll_to function
-- @tfield[opt=0] number EXTRA_STRETCH_SIZE extra size in pixels outside of scroll (stretch effect)
-- @tfield[opt=false] bool SMALL_CONTENT_SCROLL If true, content node with size less than view node size can be scrolled
function Scroll:on_style_change(style)
-- @tfield[opt=0] bool WHEEL_SCROLL_SPEED The scroll speed via mouse wheel scroll or touchpad. Set to 0 to disable wheel scrolling
-- @tfield[opt=false] bool WHEEL_SCROLL_INVERTED If true, invert direction for touchpad and mouse wheel scroll
function Scroll.on_style_change(self, style)
self.style = {}
self.style.EXTRA_STRETCH_SIZE = style.EXTRA_STRETCH_SIZE or 0
self.style.ANIM_SPEED = style.ANIM_SPEED or 0.2
@ -87,6 +119,8 @@ function Scroll:on_style_change(style)
self.style.INERT_SPEED = style.INERT_SPEED or 30
self.style.POINTS_DEADZONE = style.POINTS_DEADZONE or 20
self.style.SMALL_CONTENT_SCROLL = style.SMALL_CONTENT_SCROLL or false
self.style.WHEEL_SCROLL_SPEED = style.WHEEL_SCROLL_SPEED or 0
self.style.WHEEL_SCROLL_INVERTED = style.WHEEL_SCROLL_INVERTED or false
self._is_inert = not (self.style.FRICT == 0 or
self.style.FRICT_HOLD == 0 or
@ -94,16 +128,18 @@ function Scroll:on_style_change(style)
end
--- Scroll constructor.
-- @function scroll:init
--- Scroll constructor
-- @tparam Scroll self
-- @tparam node view_node GUI view scroll node
-- @tparam node content_node GUI content scroll node
function Scroll:init(view_node, content_node)
function Scroll.init(self, view_node, content_node)
self.druid = self:get_druid()
self.view_node = self:get_node(view_node)
self.content_node = self:get_node(content_node)
self.view_size = vmath.mul_per_elem(gui.get_size(self.view_node), gui.get_scale(self.view_node))
self.position = gui.get_position(self.content_node)
self.target_position = vmath.vector3(self.position)
self.inertion = vmath.vector3(0)
@ -112,6 +148,10 @@ function Scroll:init(view_node, content_node)
self.drag.on_touch_start:subscribe(self._on_touch_start)
self.drag.on_touch_end:subscribe(self._on_touch_end)
self.hover = self.druid:new_hover(view_node)
self.hover.on_mouse_hover:subscribe(self._on_mouse_hover)
self._is_mouse_hover = false
self.on_scroll = Event()
self.on_scroll_to = Event()
self.on_point_scroll = Event()
@ -119,21 +159,25 @@ function Scroll:init(view_node, content_node)
self.selected = nil
self.is_animate = false
self._offset = vmath.vector3(0)
self._is_horizontal_scroll = true
self._is_vertical_scroll = true
self._grid_on_change = nil
self._grid_on_change_callback = nil
self._outside_offset_vector = vmath.vector3(0)
self:_update_size()
end
function Scroll:on_layout_change()
function Scroll.on_layout_change(self)
gui.set_position(self.content_node, self.position)
end
function Scroll:update(dt)
function Scroll.update(self, dt)
self:_update_params()
if self.drag.is_drag then
self:_update_hand_scroll(dt)
else
@ -142,20 +186,28 @@ function Scroll:update(dt)
end
function Scroll:on_remove()
function Scroll.on_input(self, action_id, action)
return self:_process_scroll_wheel(action_id, action)
end
function Scroll.on_remove(self)
self:bind_grid(nil)
end
--- Start scroll to target point.
-- @function scroll:scroll_to
-- @tparam point vector3 Target point
-- @tparam Scroll self
-- @tparam vector3 point Target point
-- @tparam[opt] bool is_instant Instant scroll flag
-- @usage scroll:scroll_to(vmath.vector3(0, 50, 0))
-- @usage scroll:scroll_to(vmath.vector3(0), true)
function Scroll:scroll_to(point, is_instant)
function Scroll.scroll_to(self, point, is_instant)
local b = self.available_pos
local target = vmath.vector3(-point.x, -point.y, 0)
local target = vmath.vector3(
self._is_horizontal_scroll and -point.x or self.target_position.x,
self._is_vertical_scroll and -point.y or self.target_position.y,
0)
target.x = helper.clamp(target.x, b.x, b.z)
target.y = helper.clamp(target.y, b.y, b.w)
@ -179,10 +231,10 @@ end
--- Scroll to item in scroll by point index.
-- @function scroll:scroll_to_index
-- @tparam Scroll self
-- @tparam number index Point index
-- @tparam[opt] bool skip_cb If true, skip the point callback
function Scroll:scroll_to_index(index, skip_cb)
function Scroll.scroll_to_index(self, index, skip_cb)
if not self.points then
return
end
@ -202,11 +254,11 @@ end
--- Start scroll to target scroll percent
-- @function scroll:scroll_to_percent
-- @tparam point vector3 target percent
-- @tparam Scroll self
-- @tparam vector3 percent target percent
-- @tparam[opt] bool is_instant instant scroll flag
-- @usage scroll:scroll_to_percent(vmath.vector3(0.5, 0, 0))
function Scroll:scroll_to_percent(percent, is_instant)
function Scroll.scroll_to_percent(self, percent, is_instant)
local border = self.available_pos
local pos = vmath.vector3(
@ -221,9 +273,9 @@ end
--- Return current scroll progress status.
-- Values will be in [0..1] interval
-- @function scroll:get_percent
-- @tparam Scroll self
-- @treturn vector3 New vector with scroll progress values
function Scroll:get_percent()
function Scroll.get_percent(self)
local x_perc = 1 - inverse_lerp(self.available_pos.x, self.available_pos.z, self.position.x)
local y_perc = inverse_lerp(self.available_pos.w, self.available_pos.y, self.position.y)
@ -233,10 +285,14 @@ end
--- Set scroll content size.
-- It will change content gui node size
-- @function scroll:set_size
-- @tparam Scroll self
-- @tparam vector3 size The new size for content node
-- @tparam vector3 offset Offset value to set, where content is starts
-- @treturn druid.scroll Current scroll instance
function Scroll:set_size(size)
function Scroll.set_size(self, size, offset)
if offset then
self._offset = offset
end
gui.set_size(self.content_node, size)
self:_update_size()
@ -247,10 +303,10 @@ end
--- Enable or disable scroll inert.
-- If disabled, scroll through points (if exist)
-- If no points, just simple drag without inertion
-- @function scroll:set_inert
-- @tparam Scroll self
-- @tparam bool state Inert scroll state
-- @treturn druid.scroll Current scroll instance
function Scroll:set_inert(state)
function Scroll.set_inert(self, state)
self._is_inert = state
return self
@ -258,19 +314,19 @@ end
--- Return if scroll have inertion.
-- @function scroll:is_inert
-- @tparam Scroll self
-- @treturn bool If scroll have inertion
function Scroll:is_inert()
function Scroll.is_inert(self)
return self._is_inert
end
--- Set extra size for scroll stretching.
-- Set 0 to disable stretching effect
-- @function scroll:set_extra_stretch_size
-- @tparam Scroll self
-- @tparam[opt=0] number stretch_size Size in pixels of additional scroll area
-- @treturn druid.scroll Current scroll instance
function Scroll:set_extra_stretch_size(stretch_size)
function Scroll.set_extra_stretch_size(self, stretch_size)
self.style.EXTRA_STRETCH_SIZE = stretch_size or 0
self:_update_size()
@ -279,19 +335,19 @@ end
--- Return vector of scroll size with width and height.
-- @function scroll:get_scroll_size
-- @tparam Scroll self
-- @treturn vector3 Available scroll size
function Scroll:get_scroll_size()
function Scroll.get_scroll_size(self)
return self.available_size
end
--- Set points of interest.
-- Scroll will always centered on closer points
-- @function scroll:set_points
-- @tparam Scroll self
-- @tparam table points Array of vector3 points
-- @treturn druid.scroll Current scroll instance
function Scroll:set_points(points)
function Scroll.set_points(self, points)
self.points = points
table.sort(self.points, function(a, b)
@ -305,10 +361,10 @@ end
--- Lock or unlock horizontal scroll
-- @function scroll:set_horizontal_scroll
-- @tparam Scroll self
-- @tparam bool state True, if horizontal scroll is enabled
-- @treturn druid.scroll Current scroll instance
function Scroll:set_horizontal_scroll(state)
function Scroll.set_horizontal_scroll(self, state)
self._is_horizontal_scroll = state
self.drag.can_x = self.available_size.x > 0 and state
return self
@ -316,23 +372,45 @@ end
--- Lock or unlock vertical scroll
-- @function scroll:set_vertical_scroll
-- @tparam Scroll self
-- @tparam bool state True, if vertical scroll is enabled
-- @treturn druid.scroll Current scroll instance
function Scroll:set_vertical_scroll(state)
function Scroll.set_vertical_scroll(self, state)
self._is_vertical_scroll = state
self.drag.can_y = self.available_size.y > 0 and state
return self
end
--- Check node if it visible now on scroll.
-- Extra border is not affected. Return true for elements in extra scroll zone
-- @tparam Scroll self
-- @tparam node node The node to check
-- @treturn boolean True if node in visible scroll area
function Scroll.is_node_in_view(self, node)
local node_border = helper.get_border(node, gui.get_position(node))
local view_border = helper.get_border(self.view_node, -(self.position - self._outside_offset_vector))
-- Check is vertical outside (Left or Right):
if node_border.z < view_border.x or node_border.x > view_border.z then
return false
end
-- Check is horizontal outside (Up or Down):
if node_border.w > view_border.y or node_border.y < view_border.w then
return false
end
return true
end
--- Bind the grid component (Static or Dynamic) to recalculate
-- scroll size on grid changes
-- @function scroll:bind_grid
-- @tparam druid.static_grid|druid.dynamic_grid Druid grid component
-- @tparam Scroll self
-- @tparam StaticGrid|DynamicGrid grid Druid grid component
-- @treturn druid.scroll Current scroll instance
function Scroll:bind_grid(grid)
function Scroll.bind_grid(self, grid)
if self._grid_on_change then
self._grid_on_change:unsubscribe(self._grid_on_change_callback)
@ -346,15 +424,24 @@ function Scroll:bind_grid(grid)
self._grid_on_change = grid.on_change_items
self._grid_on_change_callback = self._grid_on_change:subscribe(function()
self:set_size(grid:get_size())
self:set_size(grid:get_size(), grid:get_offset())
end)
self:set_size(grid:get_size())
self:set_size(grid:get_size(), grid:get_offset())
return self
end
function Scroll:_on_scroll_drag(dx, dy)
--- Strict drag scroll area. Useful for
-- restrict events outside stencil node
-- @tparam Drag self
-- @tparam node node Gui node
function Scroll.set_click_zone(self, node)
self.drag:set_click_zone(node)
end
function Scroll._on_scroll_drag(self, dx, dy)
local t = self.target_position
local b = self.available_pos
local eb = self.available_pos_extra
@ -395,32 +482,36 @@ function Scroll:_on_scroll_drag(dx, dy)
end
function Scroll:_check_soft_zone()
function Scroll._check_soft_zone(self)
local target = self.target_position
local border = self.available_pos
local speed = self.style.BACK_SPEED
-- Right border (minimum x)
if target.x < border.x then
target.x = helper.step(target.x, border.x, math.abs(target.x - border.x) * speed)
local step = math.max(math.abs(target.x - border.x) * speed, 1)
target.x = helper.step(target.x, border.x, step)
end
-- Left border (maximum x)
if target.x > border.z then
target.x = helper.step(target.x, border.z, math.abs(target.x - border.z) * speed)
local step = math.max(math.abs(target.x - border.z) * speed, 1)
target.x = helper.step(target.x, border.z, step)
end
-- Top border (maximum y)
if target.y < border.y then
target.y = helper.step(target.y, border.y, math.abs(target.y - border.y) * speed)
local step = math.max(math.abs(target.y - border.y) * speed, 1)
target.y = helper.step(target.y, border.y, step)
end
-- Bot border (minimum y)
if target.y > border.w then
target.y = helper.step(target.y, border.w, math.abs(target.y - border.w) * speed)
local step = math.max(math.abs(target.y - border.w) * speed, 1)
target.y = helper.step(target.y, border.w, step)
end
end
--- Cancel animation on other animation or input touch
function Scroll:_cancel_animate()
function Scroll._cancel_animate(self)
if self.is_animate then
self.target_position = gui.get_position(self.content_node)
self.position.x = self.target_position.x
@ -431,7 +522,7 @@ function Scroll:_cancel_animate()
end
function Scroll:_set_scroll_position(position)
function Scroll._set_scroll_position(self, position)
local available_extra = self.available_pos_extra
position.x = helper.clamp(position.x, available_extra.x, available_extra.z)
position.y = helper.clamp(position.y, available_extra.w, available_extra.y)
@ -439,6 +530,7 @@ function Scroll:_set_scroll_position(position)
if self.position.x ~= position.x or self.position.y ~= position.y then
self.position.x = position.x
self.position.y = position.y
self:_update_params()
gui.set_position(self.content_node, position)
self.on_scroll:trigger(self:get_context(), self.position)
@ -450,7 +542,7 @@ end
-- if no inert, scroll to next point by scroll direction
-- if inert, find next point by scroll director
-- @local
function Scroll:_check_points()
function Scroll._check_points(self)
if not self.points then
return
end
@ -458,7 +550,7 @@ function Scroll:_check_points()
local inert = self.inertion
if not self._is_inert then
if math.abs(inert.x) > self.style.POINTS_DEADZONE then
self:scroll_to_index(self.selected - helper.sign(inert.x))
self:scroll_to_index(self.selected + helper.sign(inert.x))
return
end
if math.abs(inert.y) > self.style.POINTS_DEADZONE then
@ -502,14 +594,14 @@ function Scroll:_check_points()
end
function Scroll:_check_threshold()
function Scroll._check_threshold(self)
local is_stopped = false
if self.inertion.x ~= 0 and math.abs(self.inertion.x) < self.style.INERT_THRESHOLD then
if math.abs(self.inertion.x) < self.style.INERT_THRESHOLD then
is_stopped = true
self.inertion.x = 0
end
if self.inertion.y ~= 0 and math.abs(self.inertion.y) < self.style.INERT_THRESHOLD then
if math.abs(self.inertion.y) < self.style.INERT_THRESHOLD then
is_stopped = true
self.inertion.y = 0
end
@ -520,7 +612,7 @@ function Scroll:_check_threshold()
end
function Scroll:_update_free_scroll(dt)
function Scroll._update_free_scroll(self, dt)
local target = self.target_position
if self._is_inert and (self.inertion.x ~= 0 or self.inertion.y ~= 0) then
@ -541,7 +633,7 @@ function Scroll:_update_free_scroll(dt)
end
function Scroll:_update_hand_scroll(dt)
function Scroll._update_hand_scroll(self, dt)
local dx = self.target_position.x - self.position.x
local dy = self.target_position.y - self.position.y
@ -552,7 +644,7 @@ function Scroll:_update_hand_scroll(dt)
end
function Scroll:_on_touch_start()
function Scroll._on_touch_start(self)
self.inertion.x = 0
self.inertion.y = 0
self.target_position.x = self.position.x
@ -560,19 +652,18 @@ function Scroll:_on_touch_start()
end
function Scroll:_on_touch_end()
function Scroll._on_touch_end(self)
self:_check_threshold()
end
function Scroll:_update_size()
function Scroll._update_size(self)
local view_border = helper.get_border(self.view_node)
local view_size = vmath.mul_per_elem(gui.get_size(self.view_node), gui.get_scale(self.view_node))
local content_border = helper.get_border(self.content_node)
local content_size = vmath.mul_per_elem(gui.get_size(self.content_node), gui.get_scale(self.content_node))
self.available_pos = get_border_vector(view_border - content_border)
self.available_pos = get_border_vector(view_border - content_border, self._offset)
self.available_size = get_size_vector(self.available_pos)
self.drag.can_x = self.available_size.x > 0 and self._is_horizontal_scroll
@ -585,24 +676,83 @@ function Scroll:_update_size()
local stretch_size = self.style.EXTRA_STRETCH_SIZE
if self.drag.can_x then
local sign = content_size.x > view_size.x and 1 or -1
local sign = content_size.x > self.view_size.x and 1 or -1
content_border_extra.x = content_border_extra.x - stretch_size * sign
content_border_extra.z = content_border_extra.z + stretch_size * sign
end
if self.drag.can_y then
local sign = content_size.y > view_size.y and 1 or -1
local sign = content_size.y > self.view_size.y and 1 or -1
content_border_extra.y = content_border_extra.y + stretch_size * sign
content_border_extra.w = content_border_extra.w - stretch_size * sign
end
if not self.style.SMALL_CONTENT_SCROLL then
self.drag.can_x = content_size.x > view_size.x
self.drag.can_y = content_size.y > view_size.y
self.drag.can_x = content_size.x > self.view_size.x
self.drag.can_y = content_size.y > self.view_size.y
end
self.available_pos_extra = get_border_vector(view_border - content_border_extra)
self.available_pos_extra = get_border_vector(view_border - content_border_extra, self._offset)
self.available_size_extra = get_size_vector(self.available_pos_extra)
self:_set_scroll_position(self.position)
self.target_position.x = self.position.x
self.target_position.y = self.position.y
end
function Scroll._update_params(self)
local t = self.target_position
local b = self.available_pos
self._outside_offset_vector.x = 0
self._outside_offset_vector.y = 0
-- Right border (minimum x)
if t.x < b.x then
self._outside_offset_vector.x = t.x - b.x
end
-- Left border (maximum x)
if t.x > b.z then
self._outside_offset_vector.x = t.x - b.z
end
-- Top border (minimum y)
if t.y < b.y then
self._outside_offset_vector.y = t.y - b.y
end
-- Bot border (maximum y)
if t.y > b.w then
self._outside_offset_vector.y = t.y - b.w
end
end
function Scroll._process_scroll_wheel(self, action_id, action)
if not self._is_mouse_hover or self.style.WHEEL_SCROLL_SPEED == 0 then
return false
end
if action_id ~= const.ACTION_SCROLL_UP and action_id ~= const.ACTION_SCROLL_DOWN then
return false
end
local koef = (action_id == const.ACTION_SCROLL_UP) and 1 or -1
if self.style.WHEEL_SCROLL_INVERTED then
koef = -koef
end
if self.drag.can_y then
self.inertion.y = (self.inertion.y + self.style.WHEEL_SCROLL_SPEED * koef) * self.style.FRICT_HOLD
else
self.inertion.x = (self.inertion.x + self.style.WHEEL_SCROLL_SPEED * koef) * self.style.FRICT_HOLD
end
return true
end
function Scroll._on_mouse_hover(self, state)
self._is_mouse_hover = state
end

View File

@ -1,39 +1,74 @@
--- Component to handle placing components by row and columns.
-- Grid can anchor your elements, get content size and other
-- @module druid.static_grid
-- @module StaticGrid
-- @within BaseComponent
-- @alias druid.static_grid
--- Component events
-- @table Events
-- @tfield druid_event on_add_item On item add callback
-- @tfield druid_event on_remove_item On item remove callback
-- @tfield druid_event on_change_items On item add or remove callback
-- @tfield druid_event on_clear On grid clear callback
-- @tfield druid_event on_update_positions On update item positions callback
--- On item add callback(self, node, index)
-- @tfield druid_event on_add_item
--- Component fields
-- @table Fields
-- @tfield node parent Parent gui node
-- @tfield node[] nodes List of all grid nodes
-- @tfield number first_index The first index of node in grid
-- @tfield number last_index The last index of node in grid
-- @tfield vector3 anchor Item anchor
-- @tfield vector3 node_size Item size
-- @tfield vector4 border The size of item content
--- On item remove callback(self, index)
-- @tfield druid_event on_remove_item
--- On item add or remove callback(self, index)
-- @tfield druid_event on_change_items
--- On grid clear callback(self)
-- @tfield druid_event on_clear
--- On update item positions callback(self)
-- @tfield druid_event on_update_positions
--- Parent gui node
-- @tfield node parent
--- List of all grid nodes
-- @tfield node[] nodes
--- The first index of node in grid
-- @tfield number first_index
--- The last index of node in grid
-- @tfield number last_index
--- Item anchor
-- @tfield vector3 anchor
--- Item size
-- @tfield vector3 node_size
--- The size of item content
-- @tfield vector4 border
---
local const = require("druid.const")
local Event = require("druid.event")
local helper = require("druid.helper")
local component = require("druid.component")
local StaticGrid = component.create("static_grid", { const.ON_LAYOUT_CHANGE })
local StaticGrid = component.create("static_grid", { component.ON_LAYOUT_CHANGE })
local function _extend_border(border, pos, size, pivot)
local left = pos.x - size.x/2 - (size.x * pivot.x)
local right = pos.x + size.x/2 - (size.x * pivot.x)
local top = pos.y + size.y/2 - (size.y * pivot.y)
local bottom = pos.y - size.y/2 - (size.y * pivot.y)
border.x = math.min(border.x, left)
border.y = math.max(border.y, top)
border.z = math.max(border.z, right)
border.w = math.min(border.w, bottom)
end
--- Component init function
-- @function static_grid:init
-- @tparam StaticGrid self
-- @tparam node parent The gui node parent, where items will be placed
-- @tparam node element Element prefab. Need to get it size
-- @tparam[opt=1] number in_row How many nodes in row can be placed
function StaticGrid:init(parent, element, in_row)
function StaticGrid.init(self, parent, element, in_row)
self.parent = self:get_node(parent)
self.nodes = {}
@ -46,8 +81,15 @@ function StaticGrid:init(parent, element, in_row)
self.node_size = gui.get_size(self._prefab)
self.node_pivot = const.PIVOTS[gui.get_pivot(self._prefab)]
self._grid_horizonal_offset = self.node_size.x * (self.in_row - 1) * self.anchor.x
self._zero_offset = vmath.vector3(
self.node_size.x * self.node_pivot.x - self.node_size.x * self.pivot.x - self._grid_horizonal_offset,
self.node_size.y * self.node_pivot.y - self.node_size.y * self.pivot.y,
0)
self.border = vmath.vector4(0) -- Current grid content size
self.on_add_item = Event()
self.on_remove_item = Event()
self.on_change_items = Event()
@ -60,15 +102,15 @@ end
local _temp_pos = vmath.vector3(0)
--- Return pos for grid node index
-- @function static_grid:get_pos
-- @tparam StaticGrid self
-- @tparam number index The grid element index
-- @treturn vector3 Node position
function StaticGrid:get_pos(index)
function StaticGrid.get_pos(self, index)
local row = math.ceil(index / self.in_row) - 1
local col = (index - row * self.in_row) - 1
_temp_pos.x = col * self.node_size.x
_temp_pos.y = -row * self.node_size.y
_temp_pos.x = col * self.node_size.x + self._zero_offset.x
_temp_pos.y = -row * self.node_size.y + self._zero_offset.y
_temp_pos.z = 0
return _temp_pos
@ -76,10 +118,10 @@ end
--- Return index for grid pos
-- @function static_grid:get_index
-- @tparam StaticGrid self
-- @tparam vector3 pos The node position in the grid
-- @treturn number The node index
function StaticGrid:get_index(pos)
function StaticGrid.get_index(self, pos)
local col = pos.x / self.node_size.x + 1
local row = -pos.y / self.node_size.y
@ -92,10 +134,10 @@ end
--- Return grid index by node
-- @function static_grid:get_index_by_node
-- @tparam StaticGrid self
-- @tparam node node The gui node in the grid
-- @treturn number The node index
function StaticGrid:get_index_by_node(node)
function StaticGrid.get_index_by_node(self, node)
for index, grid_node in pairs(self.nodes) do
if node == grid_node then
return index
@ -106,43 +148,50 @@ function StaticGrid:get_index_by_node(node)
end
function StaticGrid:on_layout_change()
function StaticGrid.on_layout_change(self)
self:_update(true)
end
--- Set grid anchor. Default anchor is equal to anchor of grid parent node
-- @function static_grid:set_anchor
-- @tparam StaticGrid self
-- @tparam vector3 anchor Anchor
function StaticGrid:set_anchor(anchor)
function StaticGrid.set_anchor(self, anchor)
self.anchor = anchor
self:_update()
end
--- Add new item to the grid
-- @function static_grid:add
-- @tparam StaticGrid self
-- @tparam node item Gui node
-- @tparam[opt] number index The item position. By default add as last item
function StaticGrid:add(item, index)
-- @tparam[opt=SHIFT.RIGHT] number shift_policy How shift nodes, if required. See const.SHIFT
function StaticGrid.add(self, item, index, shift_policy)
shift_policy = shift_policy or const.SHIFT.RIGHT
index = index or ((self.last_index or 0) + 1)
if self.nodes[index] then
-- Move nodes to right
for i = self.last_index, index, -1 do
self.nodes[i + 1] = self.nodes[i]
if shift_policy == const.SHIFT.RIGHT then
for i = self.last_index, index, -1 do
self.nodes[i + 1] = self.nodes[i]
end
end
if shift_policy == const.SHIFT.LEFT then
for i = self.first_index, index do
self.nodes[i - 1] = self.nodes[i]
end
end
end
self.nodes[index] = item
gui.set_parent(item, self.parent)
-- Add new item instantly in new pos. Break update function for correct positioning
self:_update_indexes()
self:_update_borders()
gui.set_position(item, self:get_pos(index) + self:_get_zero_offset())
gui.set_position(item, self:get_pos(index))
self:_update_pos()
@ -152,31 +201,41 @@ end
--- Remove the item from the grid. Note that gui node will be not deleted
-- @function static_grid:remove
-- @tparam StaticGrid self
-- @tparam number index The grid node index to remove
-- @tparam bool is_shift_nodes If true, will shift nodes left after index
function StaticGrid:remove(index, is_shift_nodes)
-- @tparam[opt=SHIFT.RIGHT] number shift_policy How shift nodes, if required. See const.SHIFT
-- @treturn Node The deleted gui node from grid
function StaticGrid.remove(self, index, shift_policy)
shift_policy = shift_policy or const.SHIFT.RIGHT
assert(self.nodes[index], "No grid item at given index " .. index)
local remove_node = self.nodes[index]
self.nodes[index] = nil
if is_shift_nodes then
if shift_policy == const.SHIFT.RIGHT then
for i = index, self.last_index do
self.nodes[i] = self.nodes[i + 1]
end
end
if shift_policy == const.SHIFT.LEFT then
for i = index, self.first_index, -1 do
self.nodes[i] = self.nodes[i - 1]
end
end
self:_update()
self.on_add_item:trigger(self:get_context(), index)
self.on_remove_item:trigger(self:get_context(), index)
self.on_change_items:trigger(self:get_context(), index)
return remove_node
end
--- Return grid content size
-- @function static_grid:get_size
-- @tparam StaticGrid self
-- @treturn vector3 The grid content size
function StaticGrid:get_size()
function StaticGrid.get_size(self)
return vmath.vector3(
self.border.z - self.border.x,
self.border.y - self.border.w,
@ -184,10 +243,41 @@ function StaticGrid:get_size()
end
function StaticGrid.get_size_for(self, count)
if not count or count == 0 then
return vmath.vector3(0)
end
local border = vmath.vector4(math.huge, -math.huge, -math.huge, math.huge)
local size = self.node_size
local pivot = self.node_pivot
_extend_border(border, self:get_pos(1), size, pivot)
_extend_border(border, self:get_pos(count), size, pivot)
if count >= self.in_row then
_extend_border(border, self:get_pos(self.in_row), size, pivot)
end
return vmath.vector3(
border.z - border.x,
border.y - border.w,
0)
end
--- Return grid content borders
-- @tparam StaticGrid self
-- @treturn vector3 The grid content borders
function StaticGrid.get_borders(self)
return self.border
end
--- Return array of all node positions
-- @function static_grid:get_all_pos
-- @tparam StaticGrid self
-- @treturn vector3[] All grid node positions
function StaticGrid:get_all_pos()
function StaticGrid.get_all_pos(self)
local result = {}
for i, node in pairs(self.nodes) do
table.insert(result, gui.get_position(node))
@ -199,10 +289,10 @@ end
--- Change set position function for grid nodes. It will call on
-- update poses on grid elements. Default: gui.set_position
-- @function static_grid:set_position_function
-- @tparam StaticGrid self
-- @tparam function callback Function on node set position
-- @treturn druid.static_grid Current grid instance
function StaticGrid:set_position_function(callback)
function StaticGrid.set_position_function(self, callback)
self._set_position_function = callback or gui.set_position
return self
@ -211,9 +301,9 @@ end
--- Clear grid nodes array. GUI nodes will be not deleted!
-- If you want to delete GUI nodes, use static_grid.nodes array before grid:clear
-- @function static_grid:clear
-- @tparam StaticGrid self
-- @treturn druid.static_grid Current grid instance
function StaticGrid:clear()
function StaticGrid.clear(self)
self.border.x = 0
self.border.y = 0
self.border.w = 0
@ -222,30 +312,33 @@ function StaticGrid:clear()
self.nodes = {}
self:_update()
self.on_clear:trigger(self:get_context())
return self
end
--- Return elements offset for correct posing nodes. Correct posing at
-- parent pivot node (0:0) with adjusting of node sizes and anchoring
-- @function static_grid:_get_zero_offset
-- @treturn vector3 The offset vector
-- @local
function StaticGrid:_get_zero_offset()
-- zero offset: center pos - border size * anchor
return vmath.vector3(
-((self.border.x + self.border.z)/2 + (self.border.z - self.border.x) * self.pivot.x),
-((self.border.y + self.border.w)/2 + (self.border.y - self.border.w) * self.pivot.y),
0
)
--- Return StaticGrid offset, where StaticGrid content starts.
-- @tparam StaticGrid self The StaticGrid instance
-- @treturn vector3 The StaticGrid offset
function StaticGrid:get_offset()
local borders = self:get_borders()
local size = self:get_size()
local offset = vmath.vector3(
(borders.z + borders.x)/2 + size.x * self.pivot.x,
(borders.y + borders.w)/2 + size.y * self.pivot.y,
0)
return offset
end
--- Update grid inner state
-- @function static_grid:_update
-- @tparam StaticGrid self
-- @tparam bool is_instant If true, node position update instantly, otherwise with set_position_function callback
-- @local
function StaticGrid:_update(is_instant)
function StaticGrid._update(self, is_instant)
self:_update_indexes()
self:_update_borders()
self:_update_pos(is_instant)
@ -253,9 +346,9 @@ end
--- Update first and last indexes of grid nodes
-- @function static_grid:_update_indexes
-- @tparam StaticGrid self
-- @local
function StaticGrid:_update_indexes()
function StaticGrid._update_indexes(self)
self.first_index = nil
self.last_index = nil
for index in pairs(self.nodes) do
@ -269,9 +362,9 @@ end
--- Update grid content borders, recalculate min and max values
-- @function static_grid:_update_borders
-- @tparam StaticGrid self
-- @local
function StaticGrid:_update_borders()
function StaticGrid._update_borders(self)
if not self.first_index then
self.border = vmath.vector4(0)
return
@ -282,32 +375,18 @@ function StaticGrid:_update_borders()
local size = self.node_size
local pivot = self.node_pivot
for index, node in pairs(self.nodes) do
local pos = self:get_pos(index)
local left = pos.x - size.x/2 - (size.x * pivot.x)
local right = pos.x + size.x/2 - (size.x * pivot.x)
local top = pos.y + size.y/2 - (size.y * pivot.y)
local bottom = pos.y - size.y/2 - (size.y * pivot.y)
self.border.x = math.min(self.border.x, left)
self.border.y = math.max(self.border.y, top)
self.border.z = math.max(self.border.z, right)
self.border.w = math.min(self.border.w, bottom)
_extend_border(self.border, self:get_pos(index), size, pivot)
end
end
--- Update grid nodes position
-- @function static_grid:_update_indexes
-- @tparam StaticGrid self
-- @tparam bool is_instant If true, node position update instantly, otherwise with set_position_function callback
-- @local
function StaticGrid:_update_pos(is_instant)
local zero_offset = self:_get_zero_offset()
function StaticGrid._update_pos(self, is_instant)
for i, node in pairs(self.nodes) do
local pos = self:get_pos(i)
pos.x = pos.x + zero_offset.x
pos.y = pos.y + zero_offset.y
if is_instant then
gui.set_position(node, pos)

View File

@ -1,23 +1,27 @@
--- Component to handle swipe gestures on node.
-- Swipe will be triggered, if swipe was started and
-- ended on one node
-- @module druid.swipe
-- @module Swipe
-- @within BaseComponent
-- @alias druid.swipe
--- Components fields
-- @table Fields
-- @tparam node node Swipe node
-- @tparam[opt] node click_zone Restriction zone
--- Swipe node
-- @tparam node node
--- Component events
-- @table Events
-- @tfield druid_event on_swipe Trigger on swipe event
--- Restriction zone
-- @tparam[opt] node click_zone
--- Trigger on swipe event(self, swipe_side, dist, delta_time
-- @tfield druid_event on_swipe)
---
local Event = require("druid.event")
local const = require("druid.const")
local helper = require("druid.helper")
local component = require("druid.component")
local Swipe = component.create("swipe", { const.ON_INPUT })
local Swipe = component.create("swipe", { component.ON_INPUT })
local function start_swipe(self, action)
@ -65,11 +69,11 @@ end
--- Component style params.
-- You can override this component styles params in druid styles table
-- or create your own style
-- @table Style
-- @table style
-- @tfield[opt=0.4] number SWIPE_TIME Maximum time for swipe trigger
-- @tfield[opt=50] number SWIPE_THRESHOLD Minimum distance for swipe trigger
-- @tfield[opt=false] bool SWIPE_TRIGGER_ON_MOVE If true, trigger on swipe moving, not only release action
function Swipe:on_style_change(style)
function Swipe.on_style_change(self, style)
self.style = {}
self.style.SWIPE_TIME = style.SWIPE_TIME or 0.4
self.style.SWIPE_THRESHOLD = style.SWIPE_THRESHOLD or 50
@ -78,10 +82,10 @@ end
--- Component init function
-- @function swipe:init
-- @tparam Swipe self
-- @tparam node node Gui node
-- @tparam function on_swipe_callback Swipe callback for on_swipe_end event
function Swipe:init(node, on_swipe_callback)
function Swipe.init(self, node, on_swipe_callback)
self._trigger_on_move = self.style.SWIPE_TRIGGER_ON_MOVE
self.node = self:get_node(node)
@ -93,7 +97,7 @@ function Swipe:init(node, on_swipe_callback)
end
function Swipe:on_input(action_id, action)
function Swipe.on_input(self, action_id, action)
if action_id ~= const.ACTION_TOUCH then
return false
end
@ -126,16 +130,16 @@ function Swipe:on_input(action_id, action)
end
function Swipe:on_input_interrupt()
function Swipe.on_input_interrupt(self)
reset_swipe(self)
end
--- Strict swipe click area. Useful for
-- restrict events outside stencil node
-- @function swipe:set_click_zone
-- @tparam Swipe self
-- @tparam node zone Gui node
function Swipe:set_click_zone(zone)
function Swipe.set_click_zone(self, zone)
self.click_zone = self:get_node(zone)
end

View File

@ -1,30 +1,50 @@
--- Component to handle all GUI texts.
-- Druid text can adjust itself for text node size
-- Text will never will be outside of his text size (even multiline)
-- @module druid.text
-- @module Text
-- @within BaseComponent
-- @alias druid.text
--- Component events
-- @table Events
-- @tfield druid_event on_set_text On set text callback
-- @tfield druid_event on_update_text_scale On adjust text size callback
-- @tfield druid_event on_set_pivot On change pivot callback
--- On set text callback(self, text)
-- @tfield druid_event on_set_text
--- Component fields
-- @table Fields
-- @tfield node node Text node
-- @tfield vector3 pos Current text position
-- @tfield vector3 start_scale Initial text node scale
-- @tfield vector3 scale Current text node scale
-- @tfield vector3 start_size Initial text node size
-- @tfield vector3 text_area Current text node available are
-- @tfield bool is_no_adjust Current text size adjust settings
-- @tfield vector3 color Current text color
--- On adjust text size callback(self, new_scale)
-- @tfield druid_event on_update_text_scale
--- On change pivot callback(self, pivot)
-- @tfield druid_event on_set_pivot
--- Text node
-- @tfield node node
--- Current text position
-- @tfield vector3 pos
--- Initial text node scale
-- @tfield vector3 start_scale
--- Current text node scale
-- @tfield vector3 scale
--- Initial text node size
-- @tfield vector3 start_size
--- Current text node available are
-- @tfield vector3 text_area
--- Current text size adjust settings
-- @tfield bool is_no_adjust
--- Current text color
-- @tfield vector3 color
---
local Event = require("druid.event")
local const = require("druid.const")
local component = require("druid.component")
local Text = component.create("text", { const.ON_LAYOUT_CHANGE })
local Text = component.create("text", { component.ON_LAYOUT_CHANGE })
local function update_text_size(self)
@ -77,11 +97,11 @@ end
--- Component init function
-- @function text:init
-- @tparam Text self
-- @tparam node node Gui text node
-- @tparam[opt] string value Initial text. Default value is node text from GUI scene.
-- @tparam[opt] bool no_adjust If true, text will be not auto-adjust size
function Text:init(node, value, no_adjust)
function Text.init(self, node, value, no_adjust)
self.node = self:get_node(node)
self.pos = gui.get_position(self.node)
@ -107,15 +127,15 @@ function Text:init(node, value, no_adjust)
end
function Text:on_layout_change()
function Text.on_layout_change(self)
self:set_to(self.last_value)
end
--- Calculate text width with font with respect to trailing space
-- @function text:get_text_width
-- @tparam Text self
-- @tparam[opt] string text
function Text:get_text_width(text)
function Text.get_text_width(self, text)
text = text or self.last_value
local font = gui.get_font(self.node)
local scale = gui.get_scale(self.node)
@ -134,9 +154,9 @@ end
--- Set text to text field
-- @function text:set_to
-- @tparam Text self
-- @tparam string set_to Text for node
function Text:set_to(set_to)
function Text.set_to(self, set_to)
self.last_value = set_to
gui.set_text(self.node, set_to)
@ -149,27 +169,27 @@ end
--- Set color
-- @function text:set_color
-- @tparam Text self
-- @tparam vector4 color Color for node
function Text:set_color(color)
function Text.set_color(self, color)
self.color = color
gui.set_color(self.node, color)
end
--- Set alpha
-- @function text:set_alpha
-- @tparam Text self
-- @tparam number alpha Alpha for node
function Text:set_alpha(alpha)
function Text.set_alpha(self, alpha)
self.color.w = alpha
gui.set_color(self.node, self.color)
end
--- Set scale
-- @function text:set_scale
-- @tparam Text self
-- @tparam vector3 scale Scale for node
function Text:set_scale(scale)
function Text.set_scale(self, scale)
self.last_scale = scale
gui.set_scale(self.node, scale)
end
@ -177,9 +197,9 @@ end
--- Set text pivot. Text will re-anchor inside
-- his text area
-- @function text:set_pivot
-- @tparam Text self
-- @tparam gui.pivot pivot Gui pivot constant
function Text:set_pivot(pivot)
function Text.set_pivot(self, pivot)
local prev_pivot = gui.get_pivot(self.node)
local prev_offset = const.PIVOTS[prev_pivot]
@ -200,9 +220,9 @@ end
--- Return true, if text with line break
-- @function text:is_multiline
-- @tparam Text self
-- @treturn bool Is text node with line break
function Text:is_multiline()
function Text.is_multiline(self)
return gui.get_line_break(self.node)
end

View File

@ -1,20 +1,66 @@
--- Basic class for all Druid components.
-- To create you component, use `component.create`
-- @module component
-- @module BaseComponent
-- @alias druid.base_component
local const = require("druid.const")
local class = require("druid.system.middleclass")
local helper = require("druid.helper")
-- @classmod Component
local Component = class("druid.component")
local BaseComponent = class("druid.component")
--- Component Interests
BaseComponent.ALL = const.ALL
BaseComponent.ON_INPUT = const.ON_INPUT
BaseComponent.ON_UPDATE = const.ON_UPDATE
BaseComponent.ON_MESSAGE = const.ON_MESSAGE
BaseComponent.ON_FOCUS_LOST = const.ON_FOCUS_LOST
BaseComponent.ON_FOCUS_GAINED = const.ON_FOCUS_GAINED
BaseComponent.ON_LAYOUT_CHANGE = const.ON_LAYOUT_CHANGE
BaseComponent.ON_LANGUAGE_CHANGE = const.ON_LANGUAGE_CHANGE
BaseComponent.ALL_INTERESTS = {
BaseComponent.ALL,
BaseComponent.ON_INPUT,
BaseComponent.ON_UPDATE,
BaseComponent.ON_MESSAGE,
BaseComponent.ON_FOCUS_LOST,
BaseComponent.ON_FOCUS_GAINED,
BaseComponent.ON_LAYOUT_CHANGE,
BaseComponent.ON_LANGUAGE_CHANGE,
}
-- Value is method name of component
BaseComponent.SPECIFIC_UI_MESSAGES = {
[BaseComponent.ON_FOCUS_LOST] = "on_focus_lost",
[BaseComponent.ON_FOCUS_GAINED] = "on_focus_gained",
[BaseComponent.ON_LAYOUT_CHANGE] = "on_layout_change",
[BaseComponent.ON_LANGUAGE_CHANGE] = "on_language_change",
}
BaseComponent.UI_INPUT = {
[BaseComponent.ON_INPUT] = true
}
local uid = 0
function BaseComponent.static.get_uid()
uid = uid + 1
return uid
end
--- Set current component style table.
-- Invoke `on_style_change` on component, if exist. Component should handle
-- Invoke `on_style_change` on component, if exist. BaseComponent should handle
-- their style changing and store all style params
-- @function component:set_style
-- @tparam table style Druid style module
function Component:set_style(druid_style)
-- @tparam BaseComponent self
-- @tparam table druid_style Druid style module
function BaseComponent.set_style(self, druid_style)
self._meta.style = druid_style or const.EMPTY_TABLE
local component_style = self._meta.style[self._component.name] or const.EMPTY_TABLE
@ -25,51 +71,46 @@ end
--- Set current component template name
-- @function component:set_template
-- @tparam string template Component template name
function Component:set_template(template)
-- @tparam BaseComponent self
-- @tparam string template BaseComponent template name
function BaseComponent.set_template(self, template)
self._meta.template = template
end
--- Set current component nodes
-- @function component:set_nodes
-- @tparam table nodes Component nodes table
function Component:set_nodes(nodes)
-- @tparam BaseComponent self
-- @tparam table nodes BaseComponent nodes table
function BaseComponent.set_nodes(self, nodes)
self._meta.nodes = nodes
end
--- Get current component context
-- @function component:get_context
-- @treturn table Component context
function Component:get_context(context)
-- @tparam BaseComponent self
-- @treturn table BaseComponent context
function BaseComponent.get_context(self)
return self._meta.context
end
--- Increase input priority in current input stack
-- @function component:increase_input_priority
function Component:increase_input_priority()
self._meta.increased_input_priority = true
-- @tparam BaseComponent self
-- @local
function BaseComponent.increase_input_priority(self)
helper.deprecated("The component:increase_input_priority is deprecated. Please use component:set_input_priority(druid_const.PRIORITY_INPUT_MAX) instead")
end
--- Reset input priority in current input stack
-- @function component:reset_input_priority
function Component:reset_input_priority()
self._meta.increased_input_priority = false
end
--- Get node for component by name.
-- If component has nodes, node_or_name should be string
-- It auto pick node by template name or from nodes by clone_tree
-- if they was setup via component:set_nodes, component:set_template
-- @function component:get_node
-- @tparam BaseComponent self
-- @tparam string|node node_or_name Node name or node itself
-- @treturn node Gui node
function Component:get_node(node_or_name)
function BaseComponent.get_node(self, node_or_name)
local template_name = self:__get_template() or const.EMPTY_STRING
local nodes = self:__get_nodes()
@ -94,28 +135,69 @@ end
--- Return druid with context of calling component.
-- Use it to create component inside of other components.
-- @function component:get_druid
-- @tparam BaseComponent self
-- @treturn Druid Druid instance with component context
function Component:get_druid()
function BaseComponent.get_druid(self)
local context = { _context = self }
return setmetatable(context, { __index = self._meta.druid })
end
--- Return component name
-- @function component:get_name
-- @tparam BaseComponent self
-- @treturn string The component name
function Component:get_name()
function BaseComponent.get_name(self)
return self._component.name
end
--- Return component input priority
-- @tparam BaseComponent self
-- @treturn number The component input priority
function BaseComponent.get_input_priority(self)
return self._component.input_priority
end
--- Set component input priority
-- @tparam BaseComponent self
-- @tparam number value The new input priority value
-- @treturn number The component input priority
function BaseComponent.set_input_priority(self, value)
assert(value)
if self._component.input_priority ~= value then
self._component.input_priority = value
self._component._is_input_priority_changed = true
end
return self
end
--- Reset component input priority to default value
-- @tparam BaseComponent self
-- @treturn number The component input priority
function BaseComponent.reset_input_priority(self)
self:set_input_priority(self._component.default_input_priority)
return self
end
--- Return component uid. UID generated in component creation order
-- @tparam BaseComponent self
-- @treturn number The component uid
function BaseComponent.get_uid(self)
return self._component._uid
end
--- Set component input state. By default it enabled
-- You can disable any input of component by this function
-- @function component:set_input_enabled
-- @tparam BaseComponent self
-- @tparam bool state The component input state
-- @treturn Component Component itself
function Component:set_input_enabled(state)
-- @treturn BaseComponent BaseComponent itself
function BaseComponent.set_input_enabled(self, state)
self._meta.input_enabled = state
for index = 1, #self._meta.children do
@ -127,12 +209,12 @@ end
--- Return the parent for current component
-- @function component:get_parent_component
-- @treturn Component|nil The druid component instance or nil
function Component:get_parent_component()
-- @tparam BaseComponent self
-- @treturn druid.base_component|nil The druid component instance or nil
function BaseComponent.get_parent_component(self)
local context = self:get_context()
if context.isInstanceOf and context:isInstanceOf(Component) then
if context.isInstanceOf and context:isInstanceOf(BaseComponent) then
return context
end
@ -141,19 +223,18 @@ end
--- Setup component context and his style table
-- @function component:setup_component
-- @tparam druid_instance table The parent druid instance
-- @tparam context table Druid context. Usually it is self of script
-- @tparam style table Druid style module
-- @treturn component Component itself
function Component:setup_component(druid_instance, context, style)
-- @tparam BaseComponent self
-- @tparam table druid_instance The parent druid instance
-- @tparam table context Druid context. Usually it is self of script
-- @tparam table style Druid style module
-- @treturn component BaseComponent itself
function BaseComponent.setup_component(self, druid_instance, context, style)
self._meta = {
template = nil,
context = nil,
nodes = nil,
style = nil,
druid = druid_instance,
increased_input_priority = false,
input_enabled = true,
children = {}
}
@ -171,70 +252,97 @@ end
--- Basic constructor of component. It will call automaticaly
-- by `Component.static.create`
-- @function component:initialize
-- @tparam string name Component name
-- by `BaseComponent.static.create`
-- @tparam BaseComponent self
-- @tparam string name BaseComponent name
-- @tparam[opt={}] table interest List of component's interest
-- @tparam[opt=DEFAULT] number input_priority The input priority. The bigger number processed first
-- @local
function Component:initialize(name, interest)
function BaseComponent.initialize(self, name, interest, input_priority)
interest = interest or {}
self._component = {
name = name,
interest = interest
interest = interest,
input_priority = input_priority or const.PRIORITY_INPUT,
default_input_priority = input_priority or const.PRIORITY_INPUT,
_is_input_priority_changed = true, -- Default true for sort once time after GUI init
_uid = BaseComponent.get_uid()
}
end
function Component:__tostring()
--- Return true, if input priority was changed
-- @tparam BaseComponent self
-- @local
function BaseComponent._is_input_priority_changed(self)
return self._component._is_input_priority_changed
end
--- Reset is_input_priority_changed field
-- @tparam BaseComponent self
-- @local
function BaseComponent._reset_input_priority_changed(self)
self._component._is_input_priority_changed = false
end
function BaseComponent.__tostring(self)
return self._component.name
end
--- Set current component context
-- @function component:__set_context
-- @tparam BaseComponent self
-- @tparam table context Druid context. Usually it is self of script
function Component:__set_context(context)
-- @local
function BaseComponent.__set_context(self, context)
self._meta.context = context
end
--- Get current component interests
-- @function component:__get_interests
-- @tparam BaseComponent self
-- @treturn table List of component interests
function Component:__get_interests()
-- @local
function BaseComponent.__get_interests(self)
return self._component.interest
end
--- Get current component template name
-- @function component:__get_template
-- @treturn string Component template name
function Component:__get_template()
-- @tparam BaseComponent self
-- @treturn string BaseComponent template name
-- @local
function BaseComponent.__get_template(self)
return self._meta.template
end
--- Get current component nodes
-- @function component:__get_nodes
-- @treturn table Component nodes table
function Component:__get_nodes()
-- @tparam BaseComponent self
-- @treturn table BaseComponent nodes table
-- @local
function BaseComponent.__get_nodes(self)
return self._meta.nodes
end
--- Add child to component children list
-- @function component:__add_children
-- @tparam BaseComponent self
-- @tparam component children The druid component instance
function Component:__add_children(children)
-- @local
function BaseComponent.__add_children(self, children)
table.insert(self._meta.children, children)
end
--- Remove child from component children list
-- @function component:__remove_children
-- @tparam BaseComponent self
-- @tparam component children The druid component instance
function Component:__remove_children(children)
-- @local
function BaseComponent.__remove_children(self, children)
for i = #self._meta.children, 1, -1 do
if self._meta.children[i] == children then
table.remove(self._meta.children, i)
@ -245,19 +353,20 @@ end
--- Create new component. It will inheritance from basic
-- druid component.
-- @function Component.create
-- @tparam string name Component name
-- @tparam string name BaseComponent name
-- @tparam[opt={}] table interest List of component's interest
function Component.static.create(name, interest)
-- @tparam[opt=DEFAULT] number input_priority The input priority. The bigger number processed first
-- @local
function BaseComponent.static.create(name, interest, input_priority)
-- Yea, inheritance here
local new_class = class(name, Component)
local new_class = class(name, BaseComponent)
new_class.initialize = function(self)
Component.initialize(self, name, interest)
BaseComponent.initialize(self, name, interest, input_priority)
end
return new_class
end
return Component
return BaseComponent

View File

@ -1,6 +1,7 @@
--- Druid constants
-- @local
-- @module const
-- @module DruidConst
-- @alias druid_const
local M = {}
@ -23,31 +24,22 @@ M.PRESSED = "pressed"
M.STRING = "string"
M.TABLE = "table"
M.ZERO = "0"
M.ALL = "all"
--- Component Interests
M.ALL = "all"
M.ON_INPUT = hash("on_input")
M.ON_UPDATE = hash("on_update")
M.ON_MESSAGE = hash("on_message")
M.ON_INPUT_HIGH = hash("on_input_high")
M.ON_FOCUS_LOST = hash("on_focus_lost")
M.ON_FOCUS_GAINED = hash("on_focus_gained")
M.ON_LAYOUT_CHANGE = hash("layout_changed")
M.ON_LANGUAGE_CHANGE = hash("on_language_change")
M.ALL_INTERESTS = {
M.ALL,
M.ON_INPUT,
M.ON_UPDATE,
M.ON_MESSAGE,
M.ON_FOCUS_LOST,
M.ON_INPUT_HIGH,
M.ON_FOCUS_GAINED,
M.ON_LAYOUT_CHANGE,
M.ON_LANGUAGE_CHANGE,
}
M.PRIORITY_INPUT = 10
M.PRIORITY_INPUT_HIGH = 20
M.PRIORITY_INPUT_MAX = 100
M.PIVOTS = {
@ -63,19 +55,8 @@ M.PIVOTS = {
}
-- Value is method name of component
M.SPECIFIC_UI_MESSAGES = {
[M.ON_FOCUS_LOST] = "on_focus_lost",
[M.ON_FOCUS_GAINED] = "on_focus_gained",
[M.ON_LAYOUT_CHANGE] = "on_layout_change",
[M.ON_LANGUAGE_CHANGE] = "on_language_change",
}
M.UI_INPUT = {
[M.ON_INPUT_HIGH] = true,
[M.ON_INPUT] = true
}
M.SYS_INFO = sys.get_sys_info()
M.CURRENT_SYSTEM_NAME = M.SYS_INFO.system_name
M.OS = {
@ -88,6 +69,13 @@ M.OS = {
}
M.SHIFT = {
NO_SHIFT = 0,
LEFT = -1,
RIGHT = 1,
}
M.SIDE = {
X = "x",
Y = "y"

View File

@ -15,8 +15,9 @@
-- @module druid
local const = require("druid.const")
local druid_instance = require("druid.system.druid_instance")
local base_component = require("druid.component")
local settings = require("druid.system.settings")
local druid_instance = require("druid.system.druid_instance")
local default_style = require("druid.styles.default.style")
@ -34,6 +35,7 @@ local function get_druid_instances()
return _instances
end
--- Register external druid component.
-- After register you can create the component with
-- druid_instance:new_{name}. For example `druid:new_button(...)`
@ -44,7 +46,7 @@ function M.register(name, module)
-- TODO: Find better solution to creating elements?
-- Current way is very implicit
druid_instance["new_" .. name] = function(self, ...)
return druid_instance.create(self, module, ...)
return druid_instance.new(self, module, ...)
end
end
@ -105,13 +107,13 @@ function M.on_window_callback(event)
if event == window.WINDOW_EVENT_FOCUS_LOST then
for i = 1, #instances do
msg.post(instances[i].url, const.ON_FOCUS_LOST)
msg.post(instances[i].url, base_component.ON_FOCUS_LOST)
end
end
if event == window.WINDOW_EVENT_FOCUS_GAINED then
for i = 1, #instances do
msg.post(instances[i].url, const.ON_FOCUS_GAINED)
msg.post(instances[i].url, base_component.ON_FOCUS_GAINED)
end
end
end
@ -123,7 +125,7 @@ function M.on_layout_change()
local instances = get_druid_instances()
for i = 1, #instances do
msg.post(instances[i].url, const.ON_LAYOUT_CHANGE)
msg.post(instances[i].url, base_component.ON_LAYOUT_CHANGE)
end
end
@ -135,7 +137,7 @@ function M.on_language_change()
local instances = get_druid_instances()
for i = 1, #instances do
msg.post(instances[i].url, const.ON_LANGUAGE_CHANGE)
msg.post(instances[i].url, base_component.ON_LANGUAGE_CHANGE)
end
end

View File

@ -1,16 +1,16 @@
--- Lua event small library
-- @module druid_event
-- @module DruidEvent
-- @alias druid_event
local class = require("druid.system.middleclass")
-- @class DruidEvent
local Event = class("druid.event")
local DruidEvent = class("druid.event")
--- Event constructur
-- @function Event
-- @tparam DruidEvent self
-- @tparam function initial_callback Subscribe the callback on new event, if callback exist
function Event:initialize(initial_callback)
function DruidEvent.initialize(self, initial_callback)
self._callbacks = {}
if initial_callback then
@ -20,25 +20,30 @@ end
--- Subscribe callback on event
-- @function event:subscribe
-- @tparam DruidEvent self
-- @tparam function callback Callback itself
function Event:subscribe(callback)
-- @tparam table context Additional context as first param to callback call
function DruidEvent.subscribe(self, callback, context)
assert(type(self) == "table", "You should subscribe to event with : syntax")
assert(type(callback) == "function", "Callback should be function")
table.insert(self._callbacks, callback)
table.insert(self._callbacks, {
callback = callback,
context = context
})
return callback
end
--- Unsubscribe callback on event
-- @function event:unsubscribe
-- @tparam DruidEvent self
-- @tparam function callback Callback itself
function Event:unsubscribe(callback)
for i = 1, #self._callbacks do
if self._callbacks[i] == callback then
table.remove(self._callbacks, i)
-- @tparam table context Additional context as first param to callback call
function DruidEvent.unsubscribe(self, callback, context)
for index, callback_info in ipairs(self._callbacks) do
if callback_info.callback == callback and callback_info.context == context then
table.remove(self._callbacks, index)
return
end
end
@ -46,28 +51,32 @@ end
--- Return true, if event have at lease one handler
-- @function event:is_exist
-- @tparam DruidEvent self
-- @treturn bool True if event have handlers
function Event:is_exist()
function DruidEvent.is_exist(self)
return #self._callbacks > 0
end
--- Clear the all event handlers
-- @function event:clear
function Event:clear()
-- @tparam DruidEvent self
function DruidEvent.clear(self)
self._callbacks = {}
end
--- Trigger the event and call all subscribed callbacks
-- @function event:trigger
-- @param ... All event params
function Event:trigger(...)
for i = 1, #self._callbacks do
self._callbacks[i](...)
-- @tparam DruidEvent self
-- @tparam any ... All event params
function DruidEvent.trigger(self, ...)
for index, callback_info in ipairs(self._callbacks) do
if callback_info.context then
callback_info.callback(callback_info.context, ...)
else
callback_info.callback(...)
end
end
end
return Event
return DruidEvent

View File

@ -1,21 +1,26 @@
--- Druid checkbox component
-- @module druid.checkbox
-- @module Checkbox
-- @within BaseComponent
-- @alias druid.checkbox
--- Component events
-- @table Events
-- @tfield druid_event on_change_state On change state callback
--- On change state callback(self, state)
-- @tfield druid_event on_change_state
--- Component fields
-- @table Fields
-- @tfield node node Visual node
-- @tfield[opt=node] node click_node Button trigger node
-- @tfield druid.button button Button component from click_node
--- Visual node
-- @tfield node node
--- Button trigger node
-- @tfield[opt=node] node click_node
--- Button component from click_node
-- @tfield Button button
---
local const = require("druid.const")
local Event = require("druid.event")
local component = require("druid.component")
local Checkbox = component.create("checkbox", { const.ON_LAYOUT_CHANGE })
local Checkbox = component.create("checkbox", { component.ON_LAYOUT_CHANGE })
local function on_click(self)
@ -26,9 +31,9 @@ end
--- Component style params.
-- You can override this component styles params in druid styles table
-- or create your own style
-- @table Style
-- @table style
-- @tfield function on_change_state (self, node, state)
function Checkbox:on_style_change(style)
function Checkbox.on_style_change(self, style)
self.style = {}
self.style.on_change_state = style.on_change_state or function(_, node, state)
@ -38,11 +43,11 @@ end
--- Component init function
-- @function checkbox:init
-- @tparam Checkbox self
-- @tparam node node Gui node
-- @tparam function callback Checkbox callback
-- @tparam[opt=node] node click node Trigger node, by default equals to node
function Checkbox:init(node, callback, click_node)
-- @tparam[opt=node] node click_node Trigger node, by default equals to node
function Checkbox.init(self, node, callback, click_node)
self.druid = self:get_druid()
self.node = self:get_node(node)
self.click_node = self:get_node(click_node)
@ -54,16 +59,16 @@ function Checkbox:init(node, callback, click_node)
end
function Checkbox:on_layout_change()
function Checkbox.on_layout_change(self)
self:set_state(self.state, true)
end
--- Set checkbox state
-- @function checkbox:set_state
-- @tparam Checkbox self
-- @tparam bool state Checkbox state
-- @tparam bool is_silent Don't trigger on_change_state if true
function Checkbox:set_state(state, is_silent)
function Checkbox.set_state(self, state, is_silent)
self.state = state
self.style.on_change_state(self, self.node, state)
@ -74,9 +79,9 @@ end
--- Return checkbox state
-- @function checkbox:get_state
-- @tparam Checkbox self
-- @treturn bool Checkbox state
function Checkbox:get_state()
function Checkbox.get_state(self)
return self.state
end

View File

@ -1,13 +1,15 @@
--- Checkbox group module
-- @module druid.checkbox_group
-- @module CheckboxGroup
-- @within BaseComponent
-- @alias druid.checkbox_group
--- Component events
-- @table Events
-- @tfield druid_event on_checkbox_click On any checkbox click
--- On any checkbox click callback(self, index)
-- @tfield druid_event on_checkbox_click
--- Component fields
-- @table Fields
-- @tfield table checkboxes Array of checkbox components
--- Array of checkbox components
-- @tfield table checkboxes
---
local Event = require("druid.event")
local component = require("druid.component")
@ -16,11 +18,11 @@ local CheckboxGroup = component.create("checkbox_group")
--- Component init function
-- @function checkbox_group:init
-- @tparam node[] node Array of gui node
-- @tparam CheckboxGroup self
-- @tparam node[] nodes Array of gui node
-- @tparam function callback Checkbox callback
-- @tparam[opt=node] node[] click node Array of trigger nodes, by default equals to nodes
function CheckboxGroup:init(nodes, callback, click_nodes)
-- @tparam[opt=node] node[] click_nodes Array of trigger nodes, by default equals to nodes
function CheckboxGroup.init(self, nodes, callback, click_nodes)
self.druid = self:get_druid()
self.checkboxes = {}
@ -38,9 +40,9 @@ end
--- Set checkbox group state
-- @function checkbox_group:set_state
-- @tparam CheckboxGroup self
-- @tparam bool[] indexes Array of checkbox state
function CheckboxGroup:set_state(indexes)
function CheckboxGroup.set_state(self, indexes)
for i = 1, #indexes do
if self.checkboxes[i] then
self.checkboxes[i]:set_state(indexes[i], true)
@ -50,9 +52,9 @@ end
--- Return checkbox group state
-- @function checkbox_group:get_state
-- @tparam CheckboxGroup self
-- @treturn bool[] Array if checkboxes state
function CheckboxGroup:get_state()
function CheckboxGroup.get_state(self)
local result = {}
for i = 1, #self.checkboxes do

View File

@ -1,10 +1,9 @@
--- Druid component template
-- @module druid.component
-- @local
local const = require("druid.const")
local component = require("druid.component")
local Component = component.create("my_component_name", { const.ON_UPDATE })
local Component = component.create("my_component_name", { component.ON_UPDATE })
-- Component constructor
@ -12,12 +11,12 @@ function Component:init(...)
end
-- Call only if exist interest: const.ON_UPDATE
-- Call only if exist interest: component.ON_UPDATE
function Component:update(dt)
end
-- Call only if exist interest: const.ON_INPUT or const.ON_INPUT_HIGH
-- Call only if exist interest: component.ON_INPUT
function Component:on_input(action_id, action)
return false
end
@ -28,7 +27,7 @@ function Component:on_style_change(style)
end
-- Call only if exist interest: const.ON_MESSAGE
-- Call only if exist interest: component.ON_MESSAGE
function Component:on_message(message_id, message, sender)
end

View File

@ -0,0 +1,335 @@
--- Component to manage data for huge dataset in scroll.
-- It requires Druid Scroll and Druid Grid (Static or Dynamic) components
-- @module DataList
-- @within BaseComponent
-- @alias druid.data_list
--- The Druid scroll component
-- @tfield druid.scroll scroll
--- The Druid Grid component
-- @tfield druid.static_grid grid
--- The current visual top data index
-- @tfield number top_index
--- The current visual last data index
-- @tfield number last_index
--- The current progress of scroll posititon
-- @tfield number scroll_progress
--- Event triggered when scroll progress is changed; event(self, progress_value)
-- @tfield druid_event on_scroll_progress_change
---
local const = require("druid.const")
local helper = require("druid.helper")
local component = require("druid.component")
local Event = require("druid.event")
local DataList = component.create("data_list")
--- Data list constructor
-- @tparam DataList self
-- @tparam druid.scroll scroll The Scroll instance for Data List component
-- @tparam druid.grid grid The Grid instance for Data List component
-- @tparam function create_function The create function callback(self, data, index, data_list). Function should return (node, [component])
function DataList.init(self, scroll, grid, create_function)
self.druid = self:get_druid()
self.scroll = scroll
self.grid = grid
self.scroll:bind_grid(grid)
-- Current visual elements indexes
self.top_index = 1
self.last_index = 1
self.scroll_progress = 0
self._create_function = create_function
self._data = {}
self._data_first_index = false
self._data_last_index = false
self._data_length = 0
self._data_visual = {}
self.scroll.on_scroll:subscribe(self._check_elements, self)
self.on_scroll_progress_change = Event()
end
--- Druid System on_remove function
-- @tparam DataList self
function DataList.on_remove(self)
self.scroll.on_scroll:unsubscribe(self._check_elements, self)
end
--- Set new data set for DataList component
-- @tparam DataList self
-- @tparam table data The new data array
-- @treturn druid.data_list Current DataList instance
function DataList.set_data(self, data)
self._data = data or {}
self:_update_data_info()
self:_refresh()
return self
end
--- Add element to DataList. Currenly untested
-- @tparam DataList self
-- @tparam table data
-- @tparam number index
-- @tparam number shift_policy The constant from const.SHIFT.*
-- @local
function DataList.add(self, data, index, shift_policy)
index = index or self._data_last_index + 1
shift_policy = shift_policy or const.SHIFT.RIGHT
if self._data[index] then
if shift_policy == const.SHIFT.RIGHT then
for i = self._data_last_index, index, -1 do
self._data[i + 1] = self._data[i]
end
end
if shift_policy == const.SHIFT.LEFT then
for i = self._data_first_index, index do
self._data[i - 1] = self._data[i]
end
end
end
self._data[index] = data
self:_update_data_info()
self:_check_elements()
end
--- Remove element from DataList. Currenly untested
-- @tparam DataList self
-- @tparam number index
-- @tparam number shift_policy The constant from const.SHIFT.*
-- @local
function DataList.remove(self, index, shift_policy)
table.remove(self._data, index)
self:_refresh()
end
--- Remove element from DataList by data value. Currenly untested
-- @tparam DataList self
-- @tparam tabe data
-- @tparam number shift_policy The constant from const.SHIFT.*
-- @local
function DataList.remove_by_data(self, data, shift_policy)
local index = helper.contains(self._data, data)
if index then
table.remove(self._data, index)
self:_refresh()
end
end
--- Clear the DataList and refresh visuals
-- @tparam DataList self
function DataList.clear(self)
self._data = {}
self:_refresh()
end
--- Return first index from data. It not always equals to 1
-- @tparam DataList self
function DataList.get_first_index(self)
return self._data_first_index
end
--- Return last index from data
-- @tparam DataList self
function DataList.get_last_index(self)
return self._data_last_index
end
--- Return amount of data
-- @tparam DataList self
function DataList.get_length(self)
return self._data_length
end
--- Return index for data value
-- @tparam DataList self
-- @tparam table data
function DataList.get_index(self, data)
for index, value in pairs(self._data) do
if value == data then
return index
end
end
return nil
end
--- Instant scroll to element with passed index
-- @tparam DataList self
-- @tparam number index
function DataList.scroll_to_index(self, index)
local target = helper.clamp(index, self:get_first_index(), self:get_last_index())
self.top_index = target
self:_refresh()
if self._data_visual[target] then
self.scroll:scroll_to(gui.get_position(self._data_visual[target].node), true)
end
end
--- Add element at passed index
-- @tparam DataList self
-- @tparam number index
-- @local
function DataList._add_at(self, index)
if self._data_visual[index] then
self:_remove_at(index)
end
local node, instance = self._create_function(self:get_context(), self._data[index], index, self)
self.grid:add(node, index, const.SHIFT.NO_SHIFT)
self._data_visual[index] = {
node = node,
component = instance
}
end
--- Remove element from passed index
-- @tparam DataList self
-- @tparam number index
-- @local
function DataList._remove_at(self, index)
self.grid:remove(index, const.SHIFT.NO_SHIFT)
local node = self._data_visual[index].node
gui.delete_node(node)
if self._data_visual[index].component then
self.druid:remove(self._data_visual[index].component)
end
self._data_visual[index] = nil
end
--- Fully refresh all DataList elements
-- @tparam DataList self
-- @local
function DataList._refresh(self)
for index, _ in pairs(self._data_visual) do
self:_remove_at(index)
end
self:_check_elements()
end
--- Check elements which should be created
-- @tparam DataList self
-- @local
function DataList._check_elements(self)
for index, data in pairs(self._data_visual) do
if self.scroll:is_node_in_view(data.node) then
self.top_index = index
self.last_index = index
end
end
self:_check_elements_from(self.top_index, -1)
self:_check_elements_from(self.top_index + 1, 1)
for index, data in pairs(self._data_visual) do
self.top_index = math.min(self.top_index or index, index)
self.last_index = math.max(self.last_index or index, index)
end
-- Progress report
local middle_index = (self.last_index + self.top_index) / 2
local progress = (middle_index - self._data_first_index) / (self._data_last_index - self._data_first_index)
progress = helper.clamp(progress, 0, 1)
if self.last_index == self:get_last_index() then
progress = 1
end
if self.top_index == self:get_first_index() then
progress = 0
end
if self.scroll_progress ~= progress then
self.scroll_progress = progress
self.on_scroll_progress_change:trigger(self:get_context(), progress)
end
end
--- Check elements which should be created.
-- Start from index with step until element is outside of scroll view
-- @tparam DataList self
-- @tparam number index
-- @tparam number step
-- @local
function DataList._check_elements_from(self, index, step)
local is_outside = false
while not is_outside do
if not self._data[index] then
break
end
if not self._data_visual[index] then
self:_add_at(index)
end
if not self.scroll:is_node_in_view(self._data_visual[index].node) then
is_outside = true
-- remove nexts:
-- We add one more element, which is not in view to
-- check what it's always outside to stop spawning
local remove_index = index + step
while self._data_visual[remove_index] do
self:_remove_at(remove_index)
remove_index = remove_index + step
end
end
index = index + step
end
end
--- Update actual data params
-- @tparam DataList self
-- @local
function DataList._update_data_info(self)
self._data_first_index = false
self._data_last_index = false
self._data_length = 0
for index, data in pairs(self._data) do
self._data_first_index = math.min(self._data_first_index or index, index)
self._data_last_index = math.max(self._data_last_index or index, index)
self._data_length = self._data_length + 1
end
if self._data_length == 0 then
self._data_first_index = 1
self._data_last_index = 1
end
end
return DataList

View File

@ -1,29 +1,49 @@
--- Component to handle placing components in row
-- @module druid.dynamic_grid
-- @module DynamicGrid
-- @within BaseComponent
-- @alias druid.dynamic_grid
--- Component events
-- @table Events
-- @tfield druid_event on_add_item On item add callback
-- @tfield druid_event on_remove_item On item remove callback
-- @tfield druid_event on_change_items On item add or remove callback
-- @tfield druid_event on_clear On grid clear callback
-- @tfield druid_event on_update_positions On update item positions callback
--- On item add callback(self, node, index)
-- @tfield druid_event on_add_item
--- Component fields
-- @table Fields
-- @tfield node parent Parent gui node
-- @tfield node[] nodes List of all grid nodes
-- @tfield number first_index The first index of node in grid
-- @tfield number last_index The last index of node in grid
-- @tfield vector3 node_size Item size
-- @tfield vector4 border The size of item content
--- On item remove callback(self, index)
-- @tfield druid_event on_remove_item
--- On item add or remove callback(self, index)
-- @tfield druid_event on_change_items
--- On grid clear callback(self)
-- @tfield druid_event on_clear
--- On update item positions callback(self)
-- @tfield druid_event on_update_positions
--- Parent gui node
-- @tfield node parent
--- List of all grid elements. Contains from node, pos, size, pivot
-- @tfield node[] nodes
--- The first index of node in grid
-- @tfield number first_index
--- The last index of node in grid
-- @tfield number last_index
--- Item size
-- @tfield vector3 node_size
--- The size of item content
-- @tfield vector4 border
---
local const = require("druid.const")
local Event = require("druid.event")
local helper = require("druid.helper")
local component = require("druid.component")
local DynamicGrid = component.create("dynamic_grid", { const.ON_LAYOUT_CHANGE })
local DynamicGrid = component.create("dynamic_grid", { component.ON_LAYOUT_CHANGE })
local SIDE_VECTORS = {
@ -42,9 +62,9 @@ local AVAILABLE_PIVOTS = {
--- Component init function
-- @function dynamic_grid:init
-- @tparam DynamicGrid self
-- @tparam node parent The gui node parent, where items will be placed
function DynamicGrid:init(parent)
function DynamicGrid.init(self, parent)
self.parent = self:get_node(parent)
local parent_pivot = gui.get_pivot(self.parent)
@ -67,17 +87,18 @@ function DynamicGrid:init(parent)
end
function DynamicGrid:on_layout_change()
function DynamicGrid.on_layout_change(self)
self:_update(true)
end
--- Return pos for grid node index
-- @function dynamic_grid:get_pos
-- @tparam DynamicGrid self
-- @tparam number index The grid element index
-- @tparam node node The node to be placed
-- @tparam[opt] number origin_index Index of nearby node
-- @treturn vector3 Node position
function DynamicGrid:get_pos(index, node, origin_index)
function DynamicGrid.get_pos(self, index, node, origin_index)
local origin_node = self.nodes[origin_index]
-- If anchor node is not exist, check around nodes
@ -113,21 +134,22 @@ end
--- Add new node to the grid
-- @function dynamic_grid:add
-- @tparam DynamicGrid self
-- @tparam node node Gui node
-- @tparam[opt] number index The node position. By default add as last node
-- @tparam[opt=false] bool is_shift_left If true, shift all nodes to the left, otherwise shift nodes to the right
function DynamicGrid:add(node, index, is_shift_left)
local delta = is_shift_left and -1 or 1
-- @tparam[opt=SHIFT.RIGHT] number shift_policy How shift nodes, if required. See const.SHIFT
function DynamicGrid.add(self, node, index, shift_policy)
shift_policy = shift_policy or const.SHIFT.RIGHT
local delta = shift_policy -- -1 or 1 or 0
-- By default add node at end
index = index or ((self.last_index or 0) + 1)
-- If node exist at index place, shifting them
local is_shift = self.nodes[index]
local is_shift = self.nodes[index] and shift_policy ~= const.SHIFT.NO_SHIFT
if is_shift then
-- We need to iterate from index to start or end grid, depends of shift side
local start_index = is_shift_left and self.first_index or self.last_index
local start_index = shift_policy == const.SHIFT.LEFT and self.first_index or self.last_index
for i = start_index, index, -delta do
self.nodes[i + delta] = self.nodes[i]
end
@ -138,14 +160,13 @@ function DynamicGrid:add(node, index, is_shift_left)
-- After shifting we should recalc node poses
if is_shift then
-- We need to iterate from placed node to start or end grid, depends of shift side
local target_index = is_shift_left and self.first_index or self.last_index
local target_index = shift_policy == const.SHIFT.LEFT and self.first_index or self.last_index
for i = index + delta, target_index + delta, delta do
local move_node = self.nodes[i]
move_node.pos = self:get_pos(i, move_node.node, i - delta)
end
end
-- Sync grid data
self:_update()
@ -155,38 +176,46 @@ end
--- Remove the item from the grid. Note that gui node will be not deleted
-- @function dynamic_grid:remove
-- @tparam DynamicGrid self
-- @tparam number index The grid node index to remove
-- @tparam[opt=false] bool is_shift_left If true, shift all nodes to the left, otherwise shift nodes to the right
function DynamicGrid:remove(index, is_shift_left)
local delta = is_shift_left and -1 or 1
-- @tparam[opt=SHIFT.RIGHT] number shift_policy How shift nodes, if required. See const.SHIFT
-- @treturn Node The deleted gui node from grid
function DynamicGrid.remove(self, index, shift_policy)
shift_policy = shift_policy or const.SHIFT.RIGHT
local delta = shift_policy -- -1 or 1 or 0
assert(self.nodes[index], "No grid item at given index " .. index)
-- Just set nil for delete node data
local removed_node = self.nodes[index].node
self.nodes[index] = nil
-- After delete node, we should shift nodes and recalc their poses, depends from is_shift_left
local target_index = is_shift_left and self.first_index or self.last_index
for i = index, target_index, delta do
self.nodes[i] = self.nodes[i + delta]
if self.nodes[i] then
self.nodes[i].pos = self:get_pos(i, self.nodes[i].node, i - delta)
if shift_policy ~= const.SHIFT.NO_SHIFT then
local target_index = shift_policy == const.SHIFT.LEFT and self.first_index or self.last_index
for i = index, target_index, delta do
self.nodes[i] = self.nodes[i + delta]
if self.nodes[i] then
self.nodes[i].pos = self:get_pos(i, self.nodes[i].node, i - delta)
end
end
end
-- Sync grid data
self:_update()
self.on_add_item:trigger(self:get_context(), index)
self.on_remove_item:trigger(self:get_context(), index)
self.on_change_items:trigger(self:get_context(), index)
return removed_node
end
--- Return grid content size
-- @function dynamic_grid:get_size
-- @tparam DynamicGrid self
-- @tparam vector3 border
-- @treturn vector3 The grid content size
function DynamicGrid:get_size(border)
function DynamicGrid.get_size(self, border)
border = border or self.border
return vmath.vector3(
border.z - border.x,
@ -195,11 +224,34 @@ function DynamicGrid:get_size(border)
end
--- Return DynamicGrid offset, where DynamicGrid content starts.
-- @tparam DynamicGrid self The DynamicGrid instance
-- @treturn vector3 The DynamicGrid offset
function DynamicGrid.get_offset(self)
local size = self:get_size()
local borders = self:get_borders()
local offset = vmath.vector3(
(borders.z + borders.x)/2 + size.x * self.pivot.x,
(borders.y + borders.w)/2 + size.y * self.pivot.y,
0)
return offset
end
--- Return grid content borders
-- @tparam DynamicGrid self
-- @treturn vector3 The grid content borders
function DynamicGrid.get_borders(self)
return self.border
end
--- Return grid index by node
-- @function dynamic_grid:get_index_by_node
-- @tparam DynamicGrid self
-- @tparam node node The gui node in the grid
-- @treturn number The node index
function DynamicGrid:get_index_by_node(node)
function DynamicGrid.get_index_by_node(self, node)
for index, node_info in pairs(self.nodes) do
if node == node_info.node then
return index
@ -211,9 +263,9 @@ end
--- Return array of all node positions
-- @function dynamic_grid:get_all_pos
-- @tparam DynamicGrid self
-- @treturn vector3[] All grid node positions
function DynamicGrid:get_all_pos()
function DynamicGrid.get_all_pos(self)
local result = {}
for i, node in pairs(self.nodes) do
table.insert(result, gui.get_position(node))
@ -225,10 +277,10 @@ end
--- Change set position function for grid nodes. It will call on
-- update poses on grid elements. Default: gui.set_position
-- @function dynamic_grid:set_position_function
-- @tparam DynamicGrid self
-- @tparam function callback Function on node set position
-- @treturn druid.dynamic_grid Current grid instance
function DynamicGrid:set_position_function(callback)
function DynamicGrid.set_position_function(self, callback)
self._set_position_function = callback or gui.set_position
return self
end
@ -236,16 +288,19 @@ end
--- Clear grid nodes array. GUI nodes will be not deleted!
-- If you want to delete GUI nodes, use dynamic_grid.nodes array before grid:clear
-- @function dynamic_grid:clear
-- @tparam DynamicGrid self
-- @treturn druid.dynamic_grid Current grid instance
function DynamicGrid:clear()
function DynamicGrid.clear(self)
self.nodes = {}
self:_update()
self.on_clear:trigger(self:get_context())
return self
end
function DynamicGrid:_add_node(node, index, origin_index)
function DynamicGrid._add_node(self, node, index, origin_index)
self.nodes[index] = {
node = node,
pos = self:get_pos(index, node, origin_index),
@ -255,15 +310,15 @@ function DynamicGrid:_add_node(node, index, origin_index)
-- Add new item instantly in new pos
gui.set_parent(node, self.parent)
gui.set_position(node, self.nodes[index].pos + self:_get_zero_offset())
gui.set_position(node, self.nodes[index].pos)
end
--- Update grid inner state
-- @function dynamic_grid:_update
-- @tparam DynamicGrid self
-- @tparam bool is_instant If true, node position update instantly, otherwise with set_position_function callback
-- @local
function DynamicGrid:_update(is_instant)
function DynamicGrid._update(self, is_instant)
self:_update_indexes()
self:_update_borders()
self:_update_pos(is_instant)
@ -271,9 +326,9 @@ end
--- Update first and last indexes of grid nodes
-- @function dynamic_grid:_update_indexes
-- @tparam DynamicGrid self
-- @local
function DynamicGrid:_update_indexes()
function DynamicGrid._update_indexes(self)
self.first_index = nil
self.last_index = nil
for index in pairs(self.nodes) do
@ -287,9 +342,9 @@ end
--- Update grid content borders, recalculate min and max values
-- @function dynamic_grid:_update_borders
-- @tparam DynamicGrid self
-- @local
function DynamicGrid:_update_borders()
function DynamicGrid._update_borders(self)
if not self.first_index then
self.border = vmath.vector4(0)
return
@ -316,17 +371,15 @@ end
--- Update grid nodes position
-- @function dynamic_grid:_update_indexes
-- @tparam DynamicGrid self
-- @tparam bool is_instant If true, node position update instantly, otherwise with set_position_function callback
-- @local
function DynamicGrid:_update_pos(is_instant)
local offset = self:_get_zero_offset()
function DynamicGrid._update_pos(self, is_instant)
for index, node in pairs(self.nodes) do
if is_instant then
gui.set_position(node.node, node.pos + offset)
gui.set_position(node.node, node.pos)
else
self._set_position_function(node.node, node.pos + offset)
self._set_position_function(node.node, node.pos)
end
end
@ -334,7 +387,7 @@ function DynamicGrid:_update_pos(is_instant)
end
function DynamicGrid:_get_next_node_pos(origin_node_index, new_node, place_side)
function DynamicGrid._get_next_node_pos(self, origin_node_index, new_node, place_side)
local node = self.nodes[origin_node_index]
local new_node_size = self:_get_node_size(new_node)
@ -353,27 +406,14 @@ function DynamicGrid:_get_next_node_pos(origin_node_index, new_node, place_side)
end
function DynamicGrid:_get_node_size(node)
function DynamicGrid._get_node_size(self, node)
return vmath.mul_per_elem(gui.get_size(node), gui.get_scale(node))
end
--- Return elements offset for correct posing nodes. Correct posing at
-- parent pivot node (0:0) with adjusting of node sizes and anchoring
-- @function dynamic_grid:_get_zero_offset
-- @treturn vector3 The offset vector
-- @local
function DynamicGrid:_get_zero_offset()
-- zero offset: center pos - border size * anchor
return vmath.vector3(
-((self.border.x + self.border.z)/2 + (self.border.z - self.border.x) * self.pivot.x),
-((self.border.y + self.border.w)/2 + (self.border.y - self.border.w) * self.pivot.y),
0)
end
--- Return side vector to correct node shifting
function DynamicGrid:_get_side_vector(side, is_forward)
function DynamicGrid._get_side_vector(self, side, is_forward)
if side == const.SIDE.X then
return is_forward and SIDE_VECTORS.RIGHT or SIDE_VECTORS.LEFT
end

View File

@ -1,33 +1,57 @@
--- Druid input text component.
-- Carry on user text input
-- @author Part of code from Britzl gooey input component
-- @module druid.input
-- @module Input
-- @within BaseComponent
-- @alias druid.input
--- Component events
-- @table Events
-- @tfield druid_event on_input_select (self, button_node) On input field select callback
-- @tfield druid_event on_input_unselect (self, button_node) On input field unselect callback
-- @tfield druid_event on_input_text (self, input_text) On input field text change callback
-- @tfield druid_event on_input_empty (self, input_text) On input field text change to empty string callback
-- @tfield druid_event on_input_full (self, input_text) On input field text change to max length string callback
-- @tfield druid_event on_input_wrong (self, params, button_instance) On trying user input with not allowed character callback
--- On input field select callback(self, button_node)
-- @tfield druid_event on_input_select
--- Component fields
-- @table Fields
-- @tfield druid.text text Text component
-- @tfield druid.button button Button component
-- @tfield bool is_selected Is current input selected now
-- @tfield bool is_empty Is current input is empty now
-- @tfield[opt] number max_length Max length for input text
-- @tfield[opt] string allowerd_characters Pattern matching for user input
-- @tfield number keyboard_type Gui keyboard type for input field
--- On input field unselect callback(self, button_node)
-- @tfield druid_event on_input_unselect
--- On input field text change callback(self, input_text)
-- @tfield druid_event on_input_text
--- On input field text change to empty string callback(self, input_text)
-- @tfield druid_event on_input_empty
--- On input field text change to max length string callback(self, input_text)
-- @tfield druid_event on_input_full
--- On trying user input with not allowed character callback(self, params, button_instance)
-- @tfield druid_event on_input_wrong
--- Text component
-- @tfield druid.text text
--- Button component
-- @tfield druid.button button
--- Is current input selected now
-- @tfield bool is_selected
--- Is current input is empty now
-- @tfield bool is_empty
--- Max length for input text
-- @tfield[opt] number max_length
--- Pattern matching for user input
-- @tfield[opt] string allowerd_characters
--- Gui keyboard type for input field
-- @tfield number keyboard_type
---
local Event = require("druid.event")
local const = require("druid.const")
local component = require("druid.component")
local utf8 = require("druid.system.utf8")
local Input = component.create("input", { const.ON_INPUT, const.ON_FOCUS_LOST })
local Input = component.create("input", { component.ON_INPUT, component.ON_FOCUS_LOST })
--- Mask text by replacing every character with a mask character
@ -45,63 +69,32 @@ local function mask_text(text, mask)
end
local function select(self)
gui.reset_keyboard()
self.marked_value = ""
if not self.selected then
self:increase_input_priority()
self.button:increase_input_priority()
self.previous_value = self.value
self.selected = true
gui.show_keyboard(self.keyboard_type, false)
self.on_input_select:trigger(self:get_context())
self.style.on_select(self, self.button.node)
end
end
local function unselect(self)
gui.reset_keyboard()
self.marked_value = ""
if self.selected then
self:reset_input_priority()
self.button:reset_input_priority()
self.selected = false
gui.hide_keyboard()
self.on_input_unselect:trigger(self:get_context())
self.style.on_unselect(self, self.button.node)
end
end
local function clear_and_select(self)
if self.style.IS_LONGTAP_ERASE then
self:set_text("")
end
select(self)
self:select()
end
--- Component style params.
-- You can override this component styles params in druid styles table
-- or create your own style
-- @table Style
-- @table style
-- @tfield[opt=false] bool IS_LONGTAP_ERASE Is long tap will erase current input data
-- @tfield[opt=*] string MASK_DEFAULT_CHAR Default character mask for password input
-- @tfield[opt=false] bool IS_UNSELECT_ON_RESELECT If true, call unselect on select selected input
-- @tfield function on_select (self, button_node) Callback on input field selecting
-- @tfield function on_unselect (self, button_node) Callback on input field unselecting
-- @tfield function on_input_wrong (self, button_node) Callback on wrong user input
-- @tfield table button_style Custom button style for input node
function Input:on_style_change(style)
function Input.on_style_change(self, style)
self.style = {}
self.style.IS_LONGTAP_ERASE = style.IS_LONGTAP_ERASE or false
self.style.MASK_DEFAULT_CHAR = style.MASK_DEFAULT_CHAR or "*"
self.style.IS_UNSELECT_ON_RESELECT = style.IS_UNSELECT_ON_RESELECT or false
self.style.on_select = style.on_select or function(_, button_node) end
self.style.on_unselect = style.on_unselect or function(_, button_node) end
@ -115,11 +108,19 @@ function Input:on_style_change(style)
end
function Input:init(click_node, text_node, keyboard_type)
-- @tparam node click_node Button node to enabled input component
-- @tparam node|druid.text text_node Text node what will be changed on user input. You can pass text component instead of text node name
-- @tparam[opt] number keyboard_type Gui keyboard type for input field
function Input.init(self, click_node, text_node, keyboard_type)
self.druid = self:get_druid(self)
self.text = self.druid:new_text(text_node)
self.selected = false
if type(text_node) == const.TABLE then
self.text = text_node
else
self.text = self.druid:new_text(text_node)
end
self.is_selected = false
self.value = self.text.last_value
self.previous_value = self.text.last_value
self.current_value = self.text.last_value
@ -135,9 +136,9 @@ function Input:init(click_node, text_node, keyboard_type)
self.keyboard_type = keyboard_type or gui.KEYBOARD_TYPE_DEFAULT
self.button = self.druid:new_button(click_node, select)
self.button = self.druid:new_button(click_node, self.select)
self.button:set_style(self.button_style)
self.button.on_click_outside:subscribe(unselect)
self.button.on_click_outside:subscribe(self.unselect)
self.button.on_long_click:subscribe(clear_and_select)
self.on_input_select = Event()
@ -149,8 +150,8 @@ function Input:init(click_node, text_node, keyboard_type)
end
function Input:on_input(action_id, action)
if self.selected then
function Input.on_input(self, action_id, action)
if self.is_selected then
local input_text = nil
if action_id == const.ACTION_TEXT then
-- ignore return key
@ -189,17 +190,17 @@ function Input:on_input(action_id, action)
end
if action_id == const.ACTION_ENTER and action.released then
unselect(self)
self:unselect()
return true
end
if action_id == const.ACTION_BACK and action.released then
unselect(self)
self:unselect()
return true
end
if action_id == const.ACTION_ESC and action.released then
unselect(self)
self:unselect()
return true
end
@ -209,24 +210,24 @@ function Input:on_input(action_id, action)
end
end
return self.selected
return self.is_selected
end
function Input:on_focus_lost()
unselect(self)
function Input.on_focus_lost(self)
self:unselect()
end
function Input:on_input_interrupt()
-- unselect(self)
function Input.on_input_interrupt(self)
-- self:unselect()
end
--- Set text for input field
-- @function input:set_text
-- @tparam Input self
-- @tparam string input_text The string to apply for input field
function Input:set_text(input_text)
function Input.set_text(self, input_text)
-- Case when update with marked text
if input_text then
self.value = input_text
@ -270,20 +271,61 @@ function Input:set_text(input_text)
end
--- Select input field. It will show the keyboard and trigger on_select events
-- @tparam Input self
function Input.select(self)
gui.reset_keyboard()
self.marked_value = ""
if not self.is_selected then
self:set_input_priority(const.PRIORITY_INPUT_MAX)
self.button:set_input_priority(const.PRIORITY_INPUT_MAX)
self.previous_value = self.value
self.is_selected = true
gui.show_keyboard(self.keyboard_type, false)
self.on_input_select:trigger(self:get_context())
self.style.on_select(self, self.button.node)
else
if self.style.IS_UNSELECT_ON_RESELECT then
self:unselect(self)
end
end
end
--- Remove selection from input. It will hide the keyboard and trigger on_unselect events
-- @tparam Input self
function Input.unselect(self)
gui.reset_keyboard()
self.marked_value = ""
if self.is_selected then
self:reset_input_priority()
self.button:reset_input_priority()
self.is_selected = false
gui.hide_keyboard()
self.on_input_unselect:trigger(self:get_context())
self.style.on_unselect(self, self.button.node)
end
end
--- Return current input field text
-- @function input:get_text
-- @tparam Input self
-- @treturn string The current input field text
function Input:get_text()
function Input.get_text(self)
return self.value .. self.marked_value
end
--- Set maximum length for input field.
-- Pass nil to make input field unliminted (by default)
-- @function input:set_max_length
-- @tparam Input self
-- @tparam number max_length Maximum length for input text field
-- @treturn druid.input Current input instance
function Input:set_max_length(max_length)
function Input.set_max_length(self, max_length)
self.max_length = max_length
return self
end
@ -292,20 +334,20 @@ end
--- Set allowed charaters for input field.
-- See: https://defold.com/ref/stable/string/
-- ex: [%a%d] for alpha and numeric
-- @function input:set_allowerd_characters
-- @tparam Input self
-- @tparam string characters Regulax exp. for validate user input
-- @treturn druid.input Current input instance
function Input:set_allowed_characters(characters)
function Input.set_allowed_characters(self, characters)
self.allowed_characters = characters
return self
end
--- Reset current input selection and return previous value
-- @function input:reset_changes
function Input:reset_changes()
-- @tparam Input self
function Input.reset_changes(self)
self:set_text(self.previous_value)
unselect(self)
self:unselect()
end

View File

@ -1,42 +1,45 @@
--- Component to handle all GUI texts
-- Good working with localization system
-- @module druid.lang_text
-- @module LangText
-- @within BaseComponent
-- @alias druid.lang_text
--- Component events
-- @table Events
-- @tfield druid_event on_change On change text callback
--- On change text callback
-- @tfield druid_event on_change
--- Component fields
-- @table Fields
-- @tfield druid.text text The text component
--- The text component
-- @tfield Text text
---
local Event = require("druid.event")
local const = require("druid.const")
local settings = require("druid.system.settings")
local component = require("druid.component")
local LangText = component.create("lang_text", { const.ON_LANGUAGE_CHANGE })
local LangText = component.create("lang_text", { component.ON_LANGUAGE_CHANGE })
--- Component init function
-- @function lang_text:init
-- @tparam LangText self
-- @tparam node node The text node
-- @tparam string locale_id Default locale id
-- @tparam string locale_id Default locale id, optional
-- @tparam bool no_adjust If true, will not correct text size
function LangText:init(node, locale_id, no_adjust)
function LangText.init(self, node, locale_id, no_adjust)
self.druid = self:get_druid()
self.text = self.druid:new_text(node, locale_id, no_adjust)
self.last_locale_args = {}
self.on_change = Event()
self:translate(locale_id)
if locale_id then
self:translate(locale_id)
end
return self
end
function LangText:on_language_change()
function LangText.on_language_change(self)
if self.last_locale then
self:translate(self.last_locale, unpack(self.last_locale_args))
end
@ -44,9 +47,9 @@ end
--- Setup raw text to lang_text component
-- @function lang_text:set_to
-- @tparam LangText self
-- @tparam string text Text for text node
function LangText:set_to(text)
function LangText.set_to(self, text)
self.last_locale = false
self.text:set_to(text)
self.on_change:trigger()
@ -54,12 +57,12 @@ end
--- Translate the text by locale_id
-- @function lang_text:translate
-- @tparam LangText self
-- @tparam string locale_id Locale id
function LangText:translate(locale_id, ...)
function LangText.translate(self, locale_id, ...)
self.last_locale_args = {...}
self.last_locale = locale_id or self.last_locale
self.text:set_to(settings.get_text(self.last_locale, ...))
self.text:set_to(settings.get_text(self.last_locale, ...) or "")
end

View File

@ -1,26 +1,38 @@
--- Basic progress bar component.
-- For correct progress bar init it should be in max size from gui
-- @module druid.progress
-- @module Progress
-- @within BaseComponent
-- @alias druid.progress
--- Component events
-- @table Events
-- @tfield druid_event on_change On progress bar change callback
--- On progress bar change callback(self, new_value)
-- @tfield druid_event on_change
--- Component fields
-- @table Fields
-- @tfield node node Progress bar fill node
-- @tfield string key The progress bar direction
-- @tfield vector3 scale Current progress bar scale
-- @tfield vector3 size Current progress bar size
-- @tfield number max_size Maximum size of progress bar
-- @tfield vector4 slice Progress bar slice9 settings
--- Progress bar fill node
-- @tfield node node
--- The progress bar direction
-- @tfield string key
--- Current progress bar scale
-- @tfield vector3 scale
--- Current progress bar size
-- @tfield vector3 size
--- Maximum size of progress bar
-- @tfield number max_size
--- Progress bar slice9 settings
-- @tfield vector4 slice
---
local Event = require("druid.event")
local const = require("druid.const")
local helper = require("druid.helper")
local component = require("druid.component")
local Progress = component.create("progress", { const.ON_UPDATE, const.ON_LAYOUT_CHANGE })
local Progress = component.create("progress", { component.ON_UPDATE, component.ON_LAYOUT_CHANGE })
local function check_steps(self, from, to, exactly)
@ -68,10 +80,10 @@ end
--- Component style params.
-- You can override this component styles params in druid styles table
-- or create your own style
-- @table Style
-- @table style
-- @tfield[opt=5] number SPEED Progress bas fill rate. More -> faster
-- @tfield[opt=0.005] number MIN_DELTA Minimum step to fill progress bar
function Progress:on_style_change(style)
function Progress.on_style_change(self, style)
self.style = {}
self.style.SPEED = style.SPEED or 5
self.style.MIN_DELTA = style.MIN_DELTA or 0.005
@ -79,11 +91,11 @@ end
--- Component init function
-- @function progress:init
-- @tparam Progress self
-- @tparam string|node node Progress bar fill node or node name
-- @tparam string key Progress bar direction: const.SIDE.X or const.SIDE.Y
-- @tparam[opt=1] number init_value Initial value of progress bar
function Progress:init(node, key, init_value)
function Progress.init(self, node, key, init_value)
assert(key == const.SIDE.X or const.SIDE.Y, "Progress bar key should be 'x' or 'y'")
self.prop = hash("scale."..key)
@ -106,12 +118,12 @@ function Progress:init(node, key, init_value)
end
function Progress:on_layout_change()
function Progress.on_layout_change(self)
self:set_to(self.last_value)
end
function Progress:update(dt)
function Progress.update(self, dt)
if self.target then
local prev_value = self.last_value
local step = math.abs(self.last_value - self.target) * (self.style.SPEED*dt)
@ -132,50 +144,50 @@ end
--- Fill a progress bar and stop progress animation
-- @function progress:fill
function Progress:fill()
-- @tparam Progress self
function Progress.fill(self)
set_bar_to(self, 1, true)
end
--- Empty a progress bar
-- @function progress:empty
function Progress:empty()
-- @tparam Progress self
function Progress.empty(self)
set_bar_to(self, 0, true)
end
--- Instant fill progress bar to value
-- @function progress:set_to
-- @tparam Progress self
-- @tparam number to Progress bar value, from 0 to 1
function Progress:set_to(to)
function Progress.set_to(self, to)
set_bar_to(self, to)
end
--- Return current progress bar value
-- @function progress:get
function Progress:get()
-- @tparam Progress self
function Progress.get(self)
return self.last_value
end
--- Set points on progress bar to fire the callback
-- @function progress:set_steps
-- @tparam Progress self
-- @tparam number[] steps Array of progress bar values
-- @tparam function callback Callback on intersect step value
-- @usage progress:set_steps({0, 0.3, 0.6, 1}, function(self, step) end)
function Progress:set_steps(steps, callback)
function Progress.set_steps(self, steps, callback)
self.steps = steps
self.step_callback = callback
end
--- Start animation of a progress bar
-- @function progress:to
-- @tparam Progress self
-- @tparam number to value between 0..1
-- @tparam[opt] function callback Callback on animation ends
function Progress:to(to, callback)
function Progress.to(self, to, callback)
to = helper.clamp(to, 0, 1)
-- cause of float error
local value = helper.round(to, 5)

View File

@ -1,13 +1,15 @@
--- Radio group module
-- @module druid.radio_group
-- @module RadioGroup
-- @within BaseComponent
-- @alias druid.radio_group
--- Component events
-- @table Events
-- @tfield druid_event on_radio_click On any checkbox click
--- On any checkbox click
-- @tfield druid_event on_radio_click
--- Component fields
-- @table Fields
-- @tfield table checkboxes Array of checkbox components
--- Array of checkbox components
-- @tfield Checkbox[] checkboxes
---
local Event = require("druid.event")
local component = require("druid.component")
@ -25,11 +27,11 @@ end
--- Component init function
-- @function radio_group:init
-- @tparam node[] node Array of gui node
-- @tparam RadioGroup self
-- @tparam node[] nodes Array of gui node
-- @tparam function callback Radio callback
-- @tparam[opt=node] node[] click node Array of trigger nodes, by default equals to nodes
function RadioGroup:init(nodes, callback, click_nodes)
-- @tparam[opt=node] node[] click_nodes Array of trigger nodes, by default equals to nodes
function RadioGroup.init(self, nodes, callback, click_nodes)
self.druid = self:get_druid()
self.checkboxes = {}
@ -47,17 +49,17 @@ end
--- Set radio group state
-- @function radio_group:set_state
-- @tparam RadioGroup self
-- @tparam number index Index in radio group
function RadioGroup:set_state(index)
function RadioGroup.set_state(self, index)
on_checkbox_click(self, index)
end
--- Return radio group state
-- @function radio_group:get_state
-- @tparam RadioGroup self
-- @treturn number Index in radio group
function RadioGroup:get_state()
function RadioGroup.get_state(self)
local result = -1
for i = 1, #self.checkboxes do

View File

@ -1,20 +1,36 @@
--- Druid slider component
-- @module druid.slider
-- @module Slider
-- @within BaseComponent
-- @alias druid.slider
--- Component events
-- @table Events
-- @tfield druid_event on_change_value On change value callback
--- On change value callback(self, value)
-- @tfield druid_event on_change_value
--- Component fields
-- @table Fields
-- @tfield node node Slider pin node
-- @tfield vector3 start_pos Start pin node position
-- @tfield vector3 pos Current pin node position
-- @tfield vector3 target_pos Targer pin node position
-- @tfield vector3 end_pos End pin node position
-- @tfield number dist Length between start and end position
-- @tfield bool is_drag Current drag state
-- @tfield number value Current slider value
--- Slider pin node
-- @tfield node node
--- Start pin node position
-- @tfield vector3 start_pos
--- Current pin node position
-- @tfield vector3 pos
--- Targer pin node position
-- @tfield vector3 target_pos
--- End pin node position
-- @tfield vector3 end_pos
--- Length between start and end position
-- @tfield number dist
--- Current drag state
-- @tfield bool is_drag
--- Current slider value
-- @tfield number value
---
local Event = require("druid.event")
@ -22,7 +38,7 @@ local helper = require("druid.helper")
local const = require("druid.const")
local component = require("druid.component")
local Slider = component.create("slider", { const.ON_INPUT_HIGH, const.ON_LAYOUT_CHANGE })
local Slider = component.create("slider", { component.ON_INPUT, component.ON_LAYOUT_CHANGE }, const.PRIORITY_INPUT_HIGH)
local function on_change_value(self)
@ -37,11 +53,11 @@ end
--- Component init function
-- @function slider:init
-- @tparam Slider self
-- @tparam node node Gui pin node
-- @tparam vector3 end_pos The end position of slider
-- @tparam[opt] function callback On slider change callback
function Slider:init(node, end_pos, callback)
function Slider.init(self, node, end_pos, callback)
self.node = self:get_node(node)
self.start_pos = gui.get_position(self.node)
@ -59,12 +75,12 @@ function Slider:init(node, end_pos, callback)
end
function Slider:on_layout_change()
function Slider.on_layout_change(self)
self:set(self.value, true)
end
function Slider:on_input(action_id, action)
function Slider.on_input(self, action_id, action)
if action_id ~= const.ACTION_TOUCH then
return false
end
@ -130,10 +146,10 @@ end
--- Set value for slider
-- @function slider:set
-- @tparam Slider self
-- @tparam number value Value from 0 to 1
-- @tparam[opt] bool is_silent Don't trigger event if true
function Slider:set(value, is_silent)
function Slider.set(self, value, is_silent)
value = helper.clamp(value, 0, 1)
set_position(self, value)
self.value = value
@ -145,10 +161,10 @@ end
--- Set slider steps. Pin node will
-- apply closest step position
-- @function slider:set_steps
-- @tparam Slider self
-- @tparam number[] steps Array of steps
-- @usage slider:set_steps({0, 0.2, 0.6, 1})
function Slider:set_steps(steps)
function Slider.set_steps(self, steps)
self.steps = steps
end

View File

@ -1,37 +1,48 @@
--- Component to handle GUI timers.
-- Timer updating by game delta time. If game is not focused -
-- timer will be not updated.
-- @module druid.timer
-- @module Timer
-- @within BaseComponent
-- @alias druid.timer
--- Component events
-- @table Events
-- @tfield druid_event on_tick On timer tick callback. Fire every second
-- @tfield druid_event on_set_enabled On timer change enabled state callback
-- @tfield druid_event on_timer_end On timer end callback
--- On timer tick. Fire every second callback(self, value)
-- @tfield druid_event on_tick
--- Component fields
-- @table Fields
-- @tfield node node Trigger node
-- @tfield number from Initial timer value
-- @tfield number target Target timer value
-- @tfield number value Current timer value
--- On timer change enabled state callback(self, is_enabled)
-- @tfield druid_event on_set_enabled
--- On timer end callback
-- @tfield druid_event on_timer_end(self, Timer)
--- Trigger node
-- @tfield node node
--- Initial timer value
-- @tfield number from
--- Target timer value
-- @tfield number target
--- Current timer value
-- @tfield number value
---
local Event = require("druid.event")
local const = require("druid.const")
local formats = require("druid.helper.formats")
local helper = require("druid.helper")
local component = require("druid.component")
local Timer = component.create("timer", { const.ON_UPDATE })
local Timer = component.create("timer", { component.ON_UPDATE })
--- Component init function
-- @function timer:init
-- @tparam Timer self
-- @tparam node node Gui text node
-- @tparam number seconds_from Start timer value in seconds
-- @tparam[opt=0] number seconds_to End timer value in seconds
-- @tparam[opt] function callback Function on timer end
function Timer:init(node, seconds_from, seconds_to, callback)
function Timer.init(self, node, seconds_from, seconds_to, callback)
self.node = self:get_node(node)
seconds_from = math.max(seconds_from, 0)
seconds_to = math.max(seconds_to or 0, 0)
@ -52,7 +63,7 @@ function Timer:init(node, seconds_from, seconds_to, callback)
end
function Timer:update(dt)
function Timer.update(self, dt)
if not self.is_on then
return
end
@ -75,18 +86,18 @@ function Timer:update(dt)
end
--- Set text to text field
-- @function timer:set_to
-- @tparam Timer self
-- @tparam number set_to Value in seconds
function Timer:set_to(set_to)
function Timer.set_to(self, set_to)
self.last_value = set_to
gui.set_text(self.node, formats.second_string_min(set_to))
end
--- Called when update
-- @function timer:set_state
-- @tparam Timer self
-- @tparam bool is_on Timer enable state
function Timer:set_state(is_on)
function Timer.set_state(self, is_on)
self.is_on = is_on
self.on_set_enabled:trigger(self:get_context(), is_on)
@ -94,10 +105,10 @@ end
--- Set time interval
-- @function timer:set_interval
-- @tparam Timer self
-- @tparam number from Start time in seconds
-- @tparam number to Target time in seconds
function Timer:set_interval(from, to)
function Timer.set_interval(self, from, to)
self.from = from
self.value = from
self.temp = 0

View File

@ -5,7 +5,6 @@ local const = require("druid.const")
local M = {}
--- Text node or icon node can be nil
local function get_text_width(text_node)
if text_node then
@ -28,6 +27,11 @@ local function get_icon_width(icon_node)
end
local function get_width(node)
return gui.get_text(node) and get_text_width(node) or get_icon_width(node)
end
--- Center two nodes.
-- Nodes will be center around 0 x position
-- text_node will be first (at left side)
@ -36,22 +40,7 @@ end
-- @tparam[opt] box icon_node Gui box node
-- @tparam number margin Offset between nodes
function M.centrate_text_with_icon(text_node, icon_node, margin)
margin = margin or 0
local text_width = get_text_width(text_node)
local icon_width = get_icon_width(icon_node)
local width = text_width + icon_width
if text_node then
local pos = gui.get_position(text_node)
pos.x = -width/2 + text_width - margin/2
gui.set_position(text_node, pos)
end
if icon_node then
local icon_pos = gui.get_position(icon_node)
icon_pos.x = width/2 - icon_width + margin/2
gui.set_position(icon_node, icon_pos)
end
M.centrate_nodes(margin, text_node, icon_node)
end
@ -63,21 +52,43 @@ end
-- @tparam[opt] text text_node Gui text node
-- @tparam[opt=0] number margin Offset between nodes
function M.centrate_icon_with_text(icon_node, text_node, margin)
margin = margin or 0
local icon_width = get_icon_width(icon_node)
local text_width = get_text_width(text_node)
local width = text_width + icon_width
M.centrate_nodes(margin, icon_node, text_node)
end
if text_node then
local pos = gui.get_position(text_node)
pos.x = width/2 - text_width + margin/2
gui.set_position(text_node, pos)
--- Center several nodes nodes.
-- Nodes will be center around 0 x position
-- @function helper.centrate_nodes
-- @tparam[opt=0] number margin Offset between nodes
-- @tparam[opt] Node ... Any count of gui Node
function M.centrate_nodes(margin, ...)
margin = margin or 0
local width = 0
local count = select("#", ...)
local node_widths = {}
-- We need to get total width
for i = 1, count do
local node = select(i, ...)
node_widths[i] = get_width(node)
width = width + node_widths[i]
end
if icon_node then
local icon_pos = gui.get_position(icon_node)
icon_pos.x = -width/2 + icon_width - margin/2
gui.set_position(icon_node, icon_pos)
-- Posing all elements
local pos_x = 0
for i = 1, count do
local node = select(i, ...)
local node_width = node_widths[i]
local pos = gui.get_position(node)
pos_x = pos_x + node_width/2 -- made offset for single item
local pivot_offset = M.get_pivot_offset(gui.get_pivot(node))
pos.x = pos_x - width/2 + pivot_offset.x * node_width -- centrate node
gui.set_position(node, pos)
pos_x = pos_x + node_widths[i]/2 + margin -- add second part of offset
end
end
@ -170,32 +181,42 @@ end
--- Check if device is mobile (Android or iOS)
-- @function helper..is_mobile
function M.is_mobile()
local system_name = sys.get_sys_info().system_name
return system_name == const.OS.IOS or system_name == const.OS.ANDROID
return const.CURRENT_SYSTEM_NAME == const.OS.IOS or
const.CURRENT_SYSTEM_NAME == const.OS.ANDROID
end
--- Check if device is HTML5
-- @function helper.is_web
function M.is_web()
local system_name = sys.get_sys_info().system_name
return system_name == const.OS.BROWSER
return const.CURRENT_SYSTEM_NAME == const.OS.BROWSER
end
--- Distance from node to size border
--- Distance from node position to his borders
-- @function helper.get_border
-- @return vector4 (left, top, right, down)
function M.get_border(node)
-- @tparam node node The gui node to check
-- @tparam vector3 offset The offset to add to result
-- @return vector4 Vector with distance to node border: (left, top, right, down)
function M.get_border(node, offset)
local pivot = gui.get_pivot(node)
local pivot_offset = M.get_pivot_offset(pivot)
local size = vmath.mul_per_elem(gui.get_size(node), gui.get_scale(node))
return vmath.vector4(
local border = vmath.vector4(
-size.x*(0.5 + pivot_offset.x),
size.y*(0.5 - pivot_offset.y),
size.x*(0.5 - pivot_offset.x),
-size.y*(0.5 + pivot_offset.y)
)
if offset then
border.x = border.x + offset.x
border.y = border.y + offset.y
border.z = border.z + offset.x
border.w = border.w + offset.y
end
return border
end

Some files were not shown because too many files have changed in this diff Show More