Update examples

This commit is contained in:
Insality
2025-03-27 00:30:37 +02:00
parent 7640e207a4
commit b053b5044b
15 changed files with 125 additions and 146 deletions

View File

@@ -1,17 +1,12 @@
local component = require("druid.component")
---@class examples.button_component: druid.component
---@class examples.button_component: druid.widget
---@field root node
---@field druid druid.instance
---@field text druid.text
---@field button druid.button
---@field data any
local M = component.create("button_component")
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.button = self.druid:new_button(self.root)

View File

@@ -1,18 +1,17 @@
local event = require("event.event")
local component = require("druid.component")
local button_component = require("example.examples.data_list.cache_with_component.button_component")
---@class examples.data_list_cache_with_component: druid.component
---@field druid druid.instance
local M = component.create("data_list_cache_with_component")
---@class examples.data_list_cache_with_component: druid.widget
---@field prefab node
---@field scroll druid.scroll
---@field grid druid.grid
---@field data_list druid.data_list
---@field on_item_click event
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.prefab = self:get_node("button_component/root")
gui.set_enabled(self.prefab, false)
@@ -39,7 +38,7 @@ end
function M:create_item_callback(item_data, index)
local nodes = gui.clone_tree(self.prefab)
local instance = self.druid:new(button_component, "button_component", nodes)
local instance = self.druid:new_widget(button_component, "button_component", nodes)
gui.set_enabled(instance.root, true)
return instance.root, instance