mirror of
https://github.com/Insality/druid.git
synced 2025-09-27 18:12:19 +02:00
Update
This commit is contained in:
@@ -12,7 +12,7 @@ local M = {}
|
||||
function M:init()
|
||||
self.root = self:get_node("root")
|
||||
self.text_name = self.druid:new_text("text_name")
|
||||
:set_text_adjust("scale_then_trim_left", 0.3)
|
||||
:set_text_adjust("scale_then_trim", 0.3)
|
||||
|
||||
self.selected = self:get_node("selected")
|
||||
gui.set_alpha(self.selected, 0)
|
||||
@@ -34,6 +34,14 @@ function M:on_click()
|
||||
end
|
||||
|
||||
|
||||
---@param text string
|
||||
---@return widget.property_button
|
||||
function M:set_text_property(text)
|
||||
self.text_name:set_text(text)
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
---@param text string
|
||||
---@return widget.property_button
|
||||
function M:set_text_button(text)
|
||||
|
@@ -1,3 +1,5 @@
|
||||
local event = require("event.event")
|
||||
|
||||
---@class widget.property_checkbox: druid.widget
|
||||
---@field root node
|
||||
---@field druid druid_instance
|
||||
@@ -17,13 +19,15 @@ function M:init()
|
||||
gui.set_alpha(self.selected, 0)
|
||||
|
||||
self.text_name = self.druid:new_text("text_name")
|
||||
:set_text_adjust("scale_then_trim_left", 0.3)
|
||||
:set_text_adjust("scale_then_trim", 0.3)
|
||||
|
||||
self.button = self.druid:new_button("button", self.on_click)
|
||||
|
||||
self.container = self.druid:new_container(self.root)
|
||||
self.container:add_container("text_name")
|
||||
self.container:add_container("E_Anchor")
|
||||
|
||||
self.on_change_value = event.create()
|
||||
end
|
||||
|
||||
|
||||
@@ -35,6 +39,7 @@ function M:set_value(value, is_instant)
|
||||
|
||||
self._value = value
|
||||
gui.set_enabled(self.icon, value)
|
||||
self.on_change_value:trigger(value)
|
||||
|
||||
if not is_instant then
|
||||
gui.set_alpha(self.selected, 1)
|
||||
@@ -54,4 +59,18 @@ function M:on_click()
|
||||
end
|
||||
|
||||
|
||||
--- Set the text property of the checkbox
|
||||
---@param text string
|
||||
function M:set_text_property(text)
|
||||
self.text_name:set_text(text)
|
||||
end
|
||||
|
||||
|
||||
--- Set the callback function for when the checkbox value changes
|
||||
---@param callback function
|
||||
function M:on_change(callback)
|
||||
self.on_change_value:subscribe(callback)
|
||||
end
|
||||
|
||||
|
||||
return M
|
||||
|
@@ -3,14 +3,13 @@
|
||||
---@field container druid.container
|
||||
---@field text_name druid.text
|
||||
---@field button druid.button
|
||||
---@field text_button druid.text
|
||||
---@field druid druid_instance
|
||||
local M = {}
|
||||
|
||||
function M:init()
|
||||
self.root = self:get_node("root")
|
||||
self.text_name = self.druid:new_text("text_name")
|
||||
:set_text_adjust("scale_then_trim_left", 0.3)
|
||||
:set_text_adjust("scale_then_trim", 0.3)
|
||||
|
||||
self.selected = self:get_node("selected")
|
||||
gui.set_alpha(self.selected, 0)
|
||||
@@ -30,11 +29,23 @@ end
|
||||
|
||||
|
||||
---@param text string
|
||||
---@return property_input
|
||||
function M:set_text_button(text)
|
||||
self.text_button:set_text(text)
|
||||
---@return widget.property_input
|
||||
function M:set_text_property(text)
|
||||
self.text_name:set_text(text)
|
||||
return self
|
||||
end
|
||||
|
||||
---@param text string
|
||||
---@return widget.property_input
|
||||
function M:set_text_value(text)
|
||||
self.rich_input:set_text(text)
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
function M:on_change(callback, callback_context)
|
||||
self.rich_input.input.on_input_unselect:subscribe(callback, callback_context)
|
||||
end
|
||||
|
||||
|
||||
return M
|
||||
|
@@ -7,6 +7,7 @@ local event = require("event.event")
|
||||
---@field button druid.button
|
||||
---@field selected node
|
||||
---@field value string|number
|
||||
---@field on_change_value event fun(value: string|number)
|
||||
local M = {}
|
||||
|
||||
|
||||
@@ -16,7 +17,7 @@ function M:init()
|
||||
gui.set_alpha(self.selected, 0)
|
||||
|
||||
self.text_name = self.druid:new_text("text_name")
|
||||
:set_text_adjust("scale_then_trim_left", 0.3)
|
||||
:set_text_adjust("scale_then_trim", 0.3)
|
||||
|
||||
self.text_value = self.druid:new_text("text_value")
|
||||
self.button_left = self.druid:new_button("button_left", self.on_button_left)
|
||||
|
@@ -149,7 +149,7 @@ nodes {
|
||||
z: 0.49
|
||||
}
|
||||
type: TYPE_BOX
|
||||
texture: "druid/rect_round2_width1"
|
||||
texture: "druid/rect_round2_width2"
|
||||
id: "button"
|
||||
pivot: PIVOT_E
|
||||
parent: "E_Anchor"
|
||||
|
@@ -21,7 +21,7 @@ function M:init()
|
||||
self.max = 1
|
||||
|
||||
self.text_name = self.druid:new_text("text_name")
|
||||
:set_text_adjust("scale_then_trim_left", 0.3)
|
||||
:set_text_adjust("scale_then_trim", 0.3)
|
||||
|
||||
self.text_value = self.druid:new_text("text_value")
|
||||
self.slider = self.druid:new_slider("slider_pin", vmath.vector3(55, 0, 0), self.update_value) --[[@as druid.slider]]
|
||||
@@ -46,6 +46,20 @@ function M:set_text_function(callback)
|
||||
end
|
||||
|
||||
|
||||
--- Sets the text property of the slider
|
||||
---@param text string
|
||||
function M:set_text_property(text)
|
||||
self.text_name:set_text(text)
|
||||
end
|
||||
|
||||
|
||||
--- Sets the callback function for when the slider value changes
|
||||
---@param callback fun(value:number)
|
||||
function M:on_change(callback)
|
||||
self.on_change_value:subscribe(callback)
|
||||
end
|
||||
|
||||
|
||||
---@param value number
|
||||
function M:set_value(value, is_instant)
|
||||
local diff = math.abs(self.max - self.min)
|
||||
|
@@ -25,7 +25,7 @@ end
|
||||
|
||||
---@param text string
|
||||
---@return widget.property_text
|
||||
function M:set_text(text)
|
||||
function M:set_text_property(text)
|
||||
self.text_name:set_text(text)
|
||||
return self
|
||||
end
|
||||
@@ -33,7 +33,7 @@ end
|
||||
|
||||
---@param text string|nil
|
||||
---@return widget.property_text
|
||||
function M:set_right_text(text)
|
||||
function M:set_text_value(text)
|
||||
self.text_right:set_text(text or "")
|
||||
return self
|
||||
end
|
||||
|
Reference in New Issue
Block a user