mirror of
https://github.com/Insality/druid
synced 2025-09-27 10:02:19 +02:00
Update docs
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
# Styles
|
||||
|
||||
## Overview
|
||||
|
||||
Styles - set of functions and parameters for components to customize their behavior.
|
||||
|
||||
Styles is a table, where key is name of component, and value is style table for this component.
|
||||
@@ -8,29 +9,33 @@ Styles is a table, where key is name of component, and value is style table for
|
||||
In component API documentation, you can find the style API for this component. Or just lookup for existing styles and modify them.
|
||||
|
||||
## Usage
|
||||
|
||||
Setup default druid style for all druid instances via `druid.set_default_style`
|
||||
You can pass _nil_ or _empty_table_ to use default values for all components (no styles)
|
||||
|
||||
```lua
|
||||
local druid = require("druid.druid")
|
||||
local my_style = require("my.amazing.style")
|
||||
|
||||
function init(self)
|
||||
druid.set_default_style(my_style)
|
||||
druid.set_default_style(my_style)
|
||||
end
|
||||
```
|
||||
|
||||
Setup custom style to specific druid instance:
|
||||
|
||||
```lua
|
||||
local druid = require("druid.druid")
|
||||
local my_style = require("my.amazing.style")
|
||||
|
||||
function init(self)
|
||||
-- This druid instance will be use my_style as default
|
||||
self.druid = druid.new(self, my_style)
|
||||
-- This druid instance will be use my_style as default
|
||||
self.druid = druid.new(self, my_style)
|
||||
end
|
||||
```
|
||||
|
||||
Change component style with _set_style_ function
|
||||
|
||||
```lua
|
||||
local druid = require("druid.druid")
|
||||
local my_style = require("my.amazing.style")
|
||||
|
@@ -1,6 +1,5 @@
|
||||
# Advanced Druid Setup
|
||||
|
||||
|
||||
## Input Bindings
|
||||
|
||||
By default, **Druid** uses all key names from Defold's default `/builtins/input/all.input_binding` for input bindings.
|
||||
@@ -96,23 +95,3 @@ local function on_window_callback(self, event, data)
|
||||
end
|
||||
window.set_listener(on_window_callback)
|
||||
```
|
||||
|
||||
|
||||
## Lua Annotations
|
||||
|
||||
[EmmyLua](https://emmylua.github.io/annotation.html) is a Lua annotation library. It is a useful tool for enabling Lua code autocompletion in editors such as [VSCode](https://github.com/EmmyLua/VSCode-EmmyLua) and [IntelliJ IDEA](https://github.com/EmmyLua/IntelliJ-EmmyLua).
|
||||
|
||||
Since dependencies cannot be processed by external editors, to use the EmmyLua annotations, you should copy the _druid/annotations.lua_ file to your project.
|
||||
|
||||
Remember that you can restart the EmmyLua server to refresh the changes if something goes wrong.
|
||||
|
||||
After the annotations are processed, you should specify the type of "Druid" in the "require" statement:
|
||||
|
||||
```lua
|
||||
---@type druid
|
||||
local druid = require("druid.druid")
|
||||
|
||||
-- Now the autocomplete is working
|
||||
```
|
||||
|
||||
<img src="../media/emmy_lua_preview.png" width="700">
|
||||
|
Reference in New Issue
Block a user