Update properties panel, add refresh button

This commit is contained in:
Insality 2025-05-17 18:06:26 +03:00
parent 22c49540df
commit 2133492efe
4 changed files with 61 additions and 37 deletions

View File

@ -28,4 +28,7 @@ images {
images {
image: "/druid/images/icons/icon_arrow.png"
}
images {
image: "/druid/images/icons/icon_refresh.png"
}
extrude_borders: 2

Binary file not shown.

After

Width:  |  Height:  |  Size: 593 B

View File

@ -106,6 +106,24 @@ nodes {
x: 152.0
y: -4.0
}
color {
x: 0.306
y: 0.31
z: 0.314
}
type: TYPE_BOX
texture: "druid/icon_refresh"
id: "icon_refresh"
pivot: PIVOT_NE
parent: "header"
inherit_alpha: true
size_mode: SIZE_MODE_AUTO
}
nodes {
position {
x: 112.0
y: -4.0
}
scale {
x: -1.0
}

View File

@ -61,6 +61,10 @@ function M:init()
end)
gui.set_enabled(self.button_back.node, false)
self.button_refresh = self.druid:new_button("icon_refresh", function()
self.is_dirty = true
end)
-- We not using as a part of properties, since it handled in a way to be paginable
self.paginator = self.druid:new_widget(property_left_right_selector, "property_left_right_selector", "root")
self.paginator:set_text("Page")
@ -388,8 +392,7 @@ function M:render_lua_table(data)
for i = 1, #component_order do
local component_id = component_order[i]
local component = data[component_id]
self:add_property_component(component_id, component, data)
self:add_property_component(component_id, data)
end
local metatable = getmetatable(data)
@ -403,7 +406,7 @@ function M:render_lua_table(data)
for i = 1, #metatable_order do
local component_id = metatable_order[i]
local component = metatable.__index[component_id]
self:add_property_component("M:" .. component_id, component, data)
self:add_property_component("M:" .. component_id, data)
end
end
end
@ -411,12 +414,13 @@ end
---@private
---@param component_id string
---@param component table
---@param context table
function M:add_property_component(component_id, component, context)
---@param data table
function M:add_property_component(component_id, data)
local component = data[component_id]
local component_type = type(component)
if component_type == "table" then
self:add_button(function(button)
local is_empty = next(component) == nil
local is_array = component[1] ~= nil
local name = "Inspect"
@ -436,7 +440,6 @@ function M:add_property_component(component_id, component, context)
end
end
self:add_button(function(button)
button:set_text_property(button_name)
button:set_text_button(name)
button.button.on_click:subscribe(function()
@ -450,9 +453,9 @@ function M:add_property_component(component_id, component, context)
if component_type == "string" then
self:add_input(function(input)
input:set_text_property(tostring(component_id))
input:set_text_value(tostring(component))
input:set_text_value(tostring(data[component_id]))
input:on_change(function(_, value)
context[component_id] = value
data[component_id] = value
end)
end)
end
@ -460,9 +463,9 @@ function M:add_property_component(component_id, component, context)
if component_type == "number" then
self:add_input(function(input)
input:set_text_property(tostring(component_id))
input:set_text_value(tostring(helper.round(component, 3)))
input:set_text_value(tostring(helper.round(data[component_id], 3)))
input:on_change(function(_, value)
context[component_id] = tonumber(value)
data[component_id] = tonumber(value)
end)
end)
end
@ -470,9 +473,9 @@ function M:add_property_component(component_id, component, context)
if component_type == "boolean" then
self:add_checkbox(function(checkbox)
checkbox:set_text_property(tostring(component_id))
checkbox:set_value(component)
checkbox:set_value(data[component_id])
checkbox:on_change(function(value)
context[component_id] = value
data[component_id] = value
end)
end)
end
@ -482,17 +485,17 @@ function M:add_property_component(component_id, component, context)
---@cast component vector3
self:add_vector3(function(vector3)
vector3:set_text_property(tostring(component_id))
vector3:set_value(component.x, component.y, component.z)
vector3:set_value(data[component_id].x, data[component_id].y, data[component_id].z)
vector3.on_change:subscribe(function(value)
component.x = value.x
component.y = value.y
component.z = value.z
data[component_id].x = value.x
data[component_id].y = value.y
data[component_id].z = value.z
end)
end)
else
self:add_text(function(text)
text:set_text_property(tostring(component_id))
text:set_text_value(tostring(component))
text:set_text_value(tostring(data[component_id]))
end)
end
end
@ -502,7 +505,7 @@ function M:add_property_component(component_id, component, context)
button:set_text_property(tostring(component_id))
button:set_text_button("Call")
button.button.on_click:subscribe(function()
component(context)
component(data)
end)
end)
end