mirror of
https://github.com/Insality/druid
synced 2025-06-27 10:27:48 +02:00
Update properties panel
This commit is contained in:
parent
2e1f280944
commit
0cf5ba30db
@ -1,3 +1,6 @@
|
||||
local event = require("event.event")
|
||||
|
||||
local color = require("druid.color")
|
||||
local helper = require("druid.helper")
|
||||
local property_checkbox = require("druid.widget.properties_panel.properties.property_checkbox")
|
||||
local property_slider = require("druid.widget.properties_panel.properties.property_slider")
|
||||
@ -22,6 +25,8 @@ local property_vector3 = require("druid.widget.properties_panel.properties.prope
|
||||
---@field properties_constructors fun()[] List of properties functions to create a new widget. Used to not spawn non-visible widgets but keep the reference
|
||||
local M = {}
|
||||
|
||||
local COLOR_BUTTON = "#4E4F50"
|
||||
local COLOR_REFRESH_ACTIVE = "#8BD092"
|
||||
|
||||
function M:init()
|
||||
self.root = self:get_node("root")
|
||||
@ -62,7 +67,7 @@ function M:init()
|
||||
gui.set_enabled(self.button_back.node, false)
|
||||
|
||||
self.button_refresh = self.druid:new_button("icon_refresh", function()
|
||||
self.is_dirty = true
|
||||
self:toggle_auto_refresh()
|
||||
end)
|
||||
|
||||
-- We not using as a part of properties, since it handled in a way to be paginable
|
||||
@ -93,6 +98,23 @@ function M:on_remove()
|
||||
end
|
||||
|
||||
|
||||
function M:toggle_auto_refresh()
|
||||
self._is_auto_refresh = not self._is_auto_refresh
|
||||
|
||||
if self._is_auto_refresh then
|
||||
self.is_dirty = true
|
||||
color.set_color(self.button_refresh.node, COLOR_REFRESH_ACTIVE)
|
||||
self._timer_refresh = timer.delay(1, true, function()
|
||||
self.is_dirty = true
|
||||
end)
|
||||
else
|
||||
color.set_color(self.button_refresh.node, COLOR_BUTTON)
|
||||
timer.cancel(self._timer_refresh)
|
||||
self._timer_refresh = nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function M:on_drag_widget(dx, dy)
|
||||
local position = self.container:get_position()
|
||||
self.container:set_position(position.x + dx, position.y + dy)
|
||||
@ -431,6 +453,16 @@ function M:add_property_component(component_id, data)
|
||||
local component_type = type(component)
|
||||
|
||||
if component_type == "table" then
|
||||
local is_event = event.is_event(component)
|
||||
if is_event then
|
||||
self:add_button(function(button)
|
||||
button:set_text_property(tostring(component_id))
|
||||
button:set_text_button("Call Event (" .. #component .. ")")
|
||||
button.button.on_click:subscribe(function()
|
||||
component:trigger()
|
||||
end)
|
||||
end)
|
||||
else
|
||||
self:add_button(function(button)
|
||||
local is_empty = next(component) == nil
|
||||
local is_array = component[1] ~= nil
|
||||
@ -460,6 +492,7 @@ function M:add_property_component(component_id, data)
|
||||
end)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
if component_type == "string" then
|
||||
self:add_input(function(input)
|
||||
|
Loading…
x
Reference in New Issue
Block a user