diff --git a/docs_md/components/widgets/mini_graph_api.md b/docs_md/components/widgets/mini_graph_api.md index e69de29..38416e1 100644 --- a/docs_md/components/widgets/mini_graph_api.md +++ b/docs_md/components/widgets/mini_graph_api.md @@ -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 + +- **root** (_node_) + + +- **text_header** (_druid.text_) + + +- **icon_drag** (_node_) + + +- **content** (_node_) + + +- **layout** (_druid.layout_) + + +- **prefab_line** (_node_) + + +- **color_zero** (_unknown_) + + +- **color_one** (_unknown_) + + +- **is_hidden** (_boolean_) + + +- **max_value** (_integer_): in this value line will be at max height + + +- **lines** (_table_) + + +- **values** (_table_) + + +- **container** (_druid.container_) + + +- **default_size** (_vector3_) + + +- **samples** (_any_) + diff --git a/druid/base/button.lua b/druid/base/button.lua index 8f143d4..840597c 100755 --- a/druid/base/button.lua +++ b/druid/base/button.lua @@ -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 diff --git a/druid/druid.lua b/druid/druid.lua index ff23fd4..31c6e70 100644 --- a/druid/druid.lua +++ b/druid/druid.lua @@ -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(...). diff --git a/druid/system/druid_instance.lua b/druid/system/druid_instance.lua index c205d77..031378a 100755 --- a/druid/system/druid_instance.lua +++ b/druid/system/druid_instance.lua @@ -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 diff --git a/druid/widget/mini_graph/mini_graph.lua b/druid/widget/mini_graph/mini_graph.lua index d237dc8..bd6de20 100644 --- a/druid/widget/mini_graph/mini_graph.lua +++ b/druid/widget/mini_graph/mini_graph.lua @@ -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 = {}