mirror of
https://github.com/Insality/druid.git
synced 2025-09-28 18:42:19 +02:00
Update example with new brand one
This commit is contained in:
30
example/examples/basic/slider/basic_slider.lua
Normal file
30
example/examples/basic/slider/basic_slider.lua
Normal file
@@ -0,0 +1,30 @@
|
||||
local component = require("druid.component")
|
||||
local slider = require("druid.extended.slider")
|
||||
|
||||
---@class basic_slider: druid.base_component
|
||||
---@field druid druid_instance
|
||||
---@field root node
|
||||
---@field slider druid.slider
|
||||
local M = component.create("basic_slider")
|
||||
|
||||
|
||||
---@param template string
|
||||
---@param nodes table<hash, node>
|
||||
function M:init(template, nodes)
|
||||
self.druid = self:get_druid(template, nodes)
|
||||
|
||||
self.slider = self.druid:new(slider, "slider/slider_pin", vmath.vector3(118, 0, 0), self.on_slider_change) --[[@as druid.slider]]
|
||||
|
||||
-- To add input across all slider widget add a root node to acquire additional input
|
||||
self.slider:set_input_node("slider/root")
|
||||
|
||||
self.text_value = self:get_node("slider_value")
|
||||
end
|
||||
|
||||
|
||||
function M:on_slider_change(value)
|
||||
gui.set_text(self.text_value, math.ceil(value * 100) .. "%")
|
||||
end
|
||||
|
||||
|
||||
return M
|
Reference in New Issue
Block a user