mirror of
https://github.com/Insality/druid
synced 2025-06-27 10:27:48 +02:00
Update
This commit is contained in:
parent
1aa96d8dbc
commit
11aeb377c2
@ -0,0 +1,235 @@
|
||||
# widget.mini_graph API
|
||||
|
||||
> at /druid/widget/mini_graph/mini_graph.lua
|
||||
|
||||
Widget to display a several lines with different height in a row
|
||||
Init, set amount of samples and max value of value means that the line will be at max height
|
||||
Use `push_line_value` to add a new value to the line
|
||||
Or `set_line_value` to set a value to the line by index
|
||||
Setup colors inside template file (at minimum and maximum)
|
||||
|
||||
## Table of Contents
|
||||
|
||||
|
||||
## Functions
|
||||
- [init](#init)
|
||||
- [on_remove](#on_remove)
|
||||
- [clear](#clear)
|
||||
- [set_samples](#set_samples)
|
||||
- [get_samples](#get_samples)
|
||||
- [set_line_value](#set_line_value)
|
||||
- [get_line_value](#get_line_value)
|
||||
- [push_line_value](#push_line_value)
|
||||
- [set_max_value](#set_max_value)
|
||||
- [set_line_height](#set_line_height)
|
||||
- [get_lowest_value](#get_lowest_value)
|
||||
- [get_highest_value](#get_highest_value)
|
||||
- [on_drag_widget](#on_drag_widget)
|
||||
- [toggle_hide](#toggle_hide)
|
||||
|
||||
|
||||
## Fields
|
||||
- [root](#root)
|
||||
- [text_header](#text_header)
|
||||
- [icon_drag](#icon_drag)
|
||||
- [content](#content)
|
||||
- [layout](#layout)
|
||||
- [prefab_line](#prefab_line)
|
||||
- [color_zero](#color_zero)
|
||||
- [color_one](#color_one)
|
||||
- [is_hidden](#is_hidden)
|
||||
- [max_value](#max_value)
|
||||
- [lines](#lines)
|
||||
- [values](#values)
|
||||
- [container](#container)
|
||||
- [default_size](#default_size)
|
||||
- [samples](#samples)
|
||||
|
||||
|
||||
|
||||
### init
|
||||
|
||||
---
|
||||
```lua
|
||||
mini_graph:init()
|
||||
```
|
||||
|
||||
### on_remove
|
||||
|
||||
---
|
||||
```lua
|
||||
mini_graph:on_remove()
|
||||
```
|
||||
|
||||
### clear
|
||||
|
||||
---
|
||||
```lua
|
||||
mini_graph:clear()
|
||||
```
|
||||
|
||||
### set_samples
|
||||
|
||||
---
|
||||
```lua
|
||||
mini_graph:set_samples([samples])
|
||||
```
|
||||
|
||||
- **Parameters:**
|
||||
- `[samples]` *(any)*:
|
||||
|
||||
### get_samples
|
||||
|
||||
---
|
||||
```lua
|
||||
mini_graph:get_samples()
|
||||
```
|
||||
|
||||
- **Returns:**
|
||||
- `` *(unknown)*:
|
||||
|
||||
### set_line_value
|
||||
|
||||
---
|
||||
```lua
|
||||
mini_graph:set_line_value(index, value)
|
||||
```
|
||||
|
||||
Set normalized to control the color of the line
|
||||
for index = 1, mini_graph:get_samples() do
|
||||
end
|
||||
|
||||
- **Parameters:**
|
||||
- `index` *(number)*:
|
||||
- `value` *(number)*: The normalized value from 0 to 1
|
||||
|
||||
- **Example Usage:**
|
||||
|
||||
```lua
|
||||
mini_graph:set_line_value(index, math.random())
|
||||
```
|
||||
### get_line_value
|
||||
|
||||
---
|
||||
```lua
|
||||
mini_graph:get_line_value([index])
|
||||
```
|
||||
|
||||
- **Parameters:**
|
||||
- `[index]` *(any)*:
|
||||
|
||||
- **Returns:**
|
||||
- `` *(number)*:
|
||||
|
||||
### push_line_value
|
||||
|
||||
---
|
||||
```lua
|
||||
mini_graph:push_line_value([value])
|
||||
```
|
||||
|
||||
- **Parameters:**
|
||||
- `[value]` *(any)*:
|
||||
|
||||
### set_max_value
|
||||
|
||||
---
|
||||
```lua
|
||||
mini_graph:set_max_value([max_value])
|
||||
```
|
||||
|
||||
- **Parameters:**
|
||||
- `[max_value]` *(any)*:
|
||||
|
||||
### set_line_height
|
||||
|
||||
---
|
||||
```lua
|
||||
mini_graph:set_line_height([index])
|
||||
```
|
||||
|
||||
- **Parameters:**
|
||||
- `[index]` *(any)*:
|
||||
|
||||
### get_lowest_value
|
||||
|
||||
---
|
||||
```lua
|
||||
mini_graph:get_lowest_value()
|
||||
```
|
||||
|
||||
### get_highest_value
|
||||
|
||||
---
|
||||
```lua
|
||||
mini_graph:get_highest_value()
|
||||
```
|
||||
|
||||
### on_drag_widget
|
||||
|
||||
---
|
||||
```lua
|
||||
mini_graph:on_drag_widget([dx], [dy])
|
||||
```
|
||||
|
||||
- **Parameters:**
|
||||
- `[dx]` *(any)*:
|
||||
- `[dy]` *(any)*:
|
||||
|
||||
### toggle_hide
|
||||
|
||||
---
|
||||
```lua
|
||||
mini_graph:toggle_hide()
|
||||
```
|
||||
|
||||
- **Returns:**
|
||||
- `` *(widget.mini_graph)*:
|
||||
|
||||
|
||||
## Fields
|
||||
<a name="root"></a>
|
||||
- **root** (_node_)
|
||||
|
||||
<a name="text_header"></a>
|
||||
- **text_header** (_druid.text_)
|
||||
|
||||
<a name="icon_drag"></a>
|
||||
- **icon_drag** (_node_)
|
||||
|
||||
<a name="content"></a>
|
||||
- **content** (_node_)
|
||||
|
||||
<a name="layout"></a>
|
||||
- **layout** (_druid.layout_)
|
||||
|
||||
<a name="prefab_line"></a>
|
||||
- **prefab_line** (_node_)
|
||||
|
||||
<a name="color_zero"></a>
|
||||
- **color_zero** (_unknown_)
|
||||
|
||||
<a name="color_one"></a>
|
||||
- **color_one** (_unknown_)
|
||||
|
||||
<a name="is_hidden"></a>
|
||||
- **is_hidden** (_boolean_)
|
||||
|
||||
<a name="max_value"></a>
|
||||
- **max_value** (_integer_): in this value line will be at max height
|
||||
|
||||
<a name="lines"></a>
|
||||
- **lines** (_table_)
|
||||
|
||||
<a name="values"></a>
|
||||
- **values** (_table_)
|
||||
|
||||
<a name="container"></a>
|
||||
- **container** (_druid.container_)
|
||||
|
||||
<a name="default_size"></a>
|
||||
- **default_size** (_vector3_)
|
||||
|
||||
<a name="samples"></a>
|
||||
- **samples** (_any_)
|
||||
|
@ -4,8 +4,7 @@ local helper = require("druid.helper")
|
||||
local component = require("druid.component")
|
||||
|
||||
---Button style params.
|
||||
---You can override this component styles params in Druid styles table
|
||||
---or create your own style
|
||||
---You can override this component styles params in Druid styles table or create your own style
|
||||
---@class druid.button.style
|
||||
---@field LONGTAP_TIME number|nil Minimum time to trigger on_hold_callback. Default: 0.4
|
||||
---@field AUTOHOLD_TRIGGER number|nil Maximum hold time to trigger button release while holding. Default: 0.8
|
||||
|
@ -5,27 +5,6 @@ local druid_instance = require("druid.system.druid_instance")
|
||||
|
||||
local default_style = require("druid.styles.default.style")
|
||||
|
||||
--- Use empty function to save a bit of memory
|
||||
local EMPTY_FUNCTION = function(_, message, context) end
|
||||
|
||||
---@type druid.logger
|
||||
local empty_logger = {
|
||||
trace = EMPTY_FUNCTION,
|
||||
debug = EMPTY_FUNCTION,
|
||||
info = EMPTY_FUNCTION,
|
||||
warn = EMPTY_FUNCTION,
|
||||
error = EMPTY_FUNCTION,
|
||||
}
|
||||
|
||||
---@type druid.logger
|
||||
local logger = {
|
||||
trace = EMPTY_FUNCTION,
|
||||
debug = EMPTY_FUNCTION,
|
||||
info = EMPTY_FUNCTION,
|
||||
warn = EMPTY_FUNCTION,
|
||||
error = EMPTY_FUNCTION,
|
||||
}
|
||||
|
||||
|
||||
---Entry point for Druid UI Framework.
|
||||
---Create a new Druid instance and adjust the Druid settings here.
|
||||
@ -45,13 +24,6 @@ function M.new(context, style)
|
||||
end
|
||||
|
||||
|
||||
---Set the logger for the Druid instance.
|
||||
---@param logger_instance druid.logger The logger
|
||||
function M:set_logger(logger_instance)
|
||||
self.logger = logger_instance or empty_logger
|
||||
end
|
||||
|
||||
|
||||
---Register a new external Druid component.
|
||||
---Register component just makes the druid:new_{name} function.
|
||||
---For example, if you register a component called "my_component", you can create it using druid:new_my_component(...).
|
||||
|
@ -178,7 +178,7 @@ local function schedule_late_init(self)
|
||||
end
|
||||
|
||||
|
||||
---Druid class constructor
|
||||
---Druid class constructor which used to create a Druid's components
|
||||
---@param context table Druid context. Usually it is self of gui script
|
||||
---@param style table? Druid style table
|
||||
---@return druid.instance
|
||||
|
@ -1,6 +1,11 @@
|
||||
local color = require("druid.color")
|
||||
local helper = require("druid.helper")
|
||||
|
||||
---Widget to display a several lines with different height in a row
|
||||
---Init, set amount of samples and max value of value means that the line will be at max height
|
||||
---Use `push_line_value` to add a new value to the line
|
||||
---Or `set_line_value` to set a value to the line by index
|
||||
---Setup colors inside template file (at minimum and maximum)
|
||||
---@class widget.mini_graph: druid.widget
|
||||
local M = {}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user