More widgets stuff, cleaning code

This commit is contained in:
Insality
2024-11-19 23:06:57 +02:00
parent 37190684c4
commit c35dfc7066
36 changed files with 1494 additions and 508 deletions

View File

@@ -1,3 +1,5 @@
local color = require("druid.color")
---@class property_button: druid.widget
---@field root node
---@field container druid.container
@@ -7,11 +9,7 @@
---@field druid druid_instance
local M = {}
---@param template string
---@param nodes table<hash, node>
function M:init(template, nodes)
self.druid = self:get_druid(template, nodes)
function M:init()
self.root = self:get_node("root")
self.text_name = self.druid:new_text("text_name")
self.selected = self:get_node("selected")
@@ -21,7 +19,9 @@ function M:init(template, nodes)
self.text_button = self.druid:new_text("text_button")
self.container = self.druid:new_container(self.root)
self.container:add_container("text_name")
self.container:add_container("text_name", nil, function(_, size)
self.text_button:set_size(size)
end)
self.container:add_container("E_Anchor")
end
@@ -32,4 +32,17 @@ function M:on_click()
end
---@param text string
---@return property_button
function M:set_text_button(text)
self.text_button:set_text(text)
return self
end
function M:set_color(color_value)
color.set_color(self:get_node("button"), color_value)
end
return M