mirror of
https://github.com/Insality/druid
synced 2025-09-27 18:12:21 +02:00
More widgets stuff, cleaning code
This commit is contained in:
@@ -23,11 +23,11 @@ nodes {
|
||||
x: -200.0
|
||||
}
|
||||
scale {
|
||||
x: 0.65
|
||||
y: 0.65
|
||||
x: 0.5
|
||||
y: 0.5
|
||||
}
|
||||
size {
|
||||
x: 200.0
|
||||
x: 350.0
|
||||
y: 40.0
|
||||
}
|
||||
color {
|
||||
@@ -50,6 +50,7 @@ nodes {
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
}
|
||||
adjust_mode: ADJUST_MODE_STRETCH
|
||||
parent: "root"
|
||||
inherit_alpha: true
|
||||
outline_alpha: 0.0
|
||||
@@ -119,12 +120,12 @@ nodes {
|
||||
}
|
||||
nodes {
|
||||
scale {
|
||||
x: 0.65
|
||||
y: 0.65
|
||||
x: 0.5
|
||||
y: 0.5
|
||||
}
|
||||
size {
|
||||
x: 250.0
|
||||
y: 30.0
|
||||
x: 380.0
|
||||
y: 50.0
|
||||
}
|
||||
color {
|
||||
x: 0.722
|
||||
|
@@ -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
|
||||
|
@@ -23,11 +23,11 @@ nodes {
|
||||
x: -200.0
|
||||
}
|
||||
scale {
|
||||
x: 0.65
|
||||
y: 0.65
|
||||
x: 0.5
|
||||
y: 0.5
|
||||
}
|
||||
size {
|
||||
x: 200.0
|
||||
x: 360.0
|
||||
y: 40.0
|
||||
}
|
||||
color {
|
||||
|
@@ -1,16 +1,13 @@
|
||||
---@class property_checkbox: druid.widget
|
||||
---@field root node
|
||||
---@field druid druid_instance
|
||||
---@field text_name druid.lang_text
|
||||
---@field text_name druid.text
|
||||
---@field button druid.button
|
||||
---@field selected node
|
||||
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.icon = self:get_node("icon")
|
||||
@@ -19,7 +16,7 @@ function M:init(template, nodes)
|
||||
self.selected = self:get_node("selected")
|
||||
gui.set_alpha(self.selected, 0)
|
||||
|
||||
self.text_name = self.druid:new_lang_text("text_name")
|
||||
self.text_name = self.druid:new_text("text_name")
|
||||
|
||||
self.button = self.druid:new_button("button", self.on_click)
|
||||
|
||||
|
143
druid/widget/properties_panel/properties/property_input.gui
Normal file
143
druid/widget/properties_panel/properties/property_input.gui
Normal file
@@ -0,0 +1,143 @@
|
||||
fonts {
|
||||
name: "text_bold"
|
||||
font: "/druid/fonts/text_bold.font"
|
||||
}
|
||||
textures {
|
||||
name: "druid"
|
||||
texture: "/druid/druid.atlas"
|
||||
}
|
||||
nodes {
|
||||
size {
|
||||
x: 400.0
|
||||
y: 40.0
|
||||
}
|
||||
type: TYPE_BOX
|
||||
texture: "druid/empty"
|
||||
id: "root"
|
||||
adjust_mode: ADJUST_MODE_STRETCH
|
||||
inherit_alpha: true
|
||||
visible: false
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: -200.0
|
||||
}
|
||||
scale {
|
||||
x: 0.5
|
||||
y: 0.5
|
||||
}
|
||||
size {
|
||||
x: 350.0
|
||||
y: 50.0
|
||||
}
|
||||
color {
|
||||
x: 0.463
|
||||
y: 0.475
|
||||
z: 0.49
|
||||
}
|
||||
type: TYPE_TEXT
|
||||
text: "Button"
|
||||
font: "text_bold"
|
||||
id: "text_name"
|
||||
pivot: PIVOT_W
|
||||
outline {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
}
|
||||
shadow {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
}
|
||||
parent: "root"
|
||||
inherit_alpha: true
|
||||
outline_alpha: 0.0
|
||||
shadow_alpha: 0.0
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 200.0
|
||||
}
|
||||
size {
|
||||
x: 200.0
|
||||
y: 40.0
|
||||
}
|
||||
type: TYPE_BOX
|
||||
id: "E_Anchor"
|
||||
pivot: PIVOT_E
|
||||
parent: "root"
|
||||
inherit_alpha: true
|
||||
size_mode: SIZE_MODE_AUTO
|
||||
visible: false
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: -100.0
|
||||
}
|
||||
type: TYPE_TEMPLATE
|
||||
id: "rich_input"
|
||||
parent: "E_Anchor"
|
||||
inherit_alpha: true
|
||||
template: "/druid/custom/rich_input/rich_input.gui"
|
||||
}
|
||||
nodes {
|
||||
type: TYPE_BOX
|
||||
id: "rich_input/root"
|
||||
parent: "rich_input"
|
||||
template_node_child: true
|
||||
}
|
||||
nodes {
|
||||
type: TYPE_BOX
|
||||
id: "rich_input/button"
|
||||
parent: "rich_input/root"
|
||||
template_node_child: true
|
||||
}
|
||||
nodes {
|
||||
type: TYPE_TEXT
|
||||
id: "rich_input/placeholder_text"
|
||||
parent: "rich_input/root"
|
||||
template_node_child: true
|
||||
}
|
||||
nodes {
|
||||
type: TYPE_TEXT
|
||||
id: "rich_input/input_text"
|
||||
parent: "rich_input/root"
|
||||
template_node_child: true
|
||||
}
|
||||
nodes {
|
||||
type: TYPE_BOX
|
||||
id: "rich_input/cursor_node"
|
||||
parent: "rich_input/root"
|
||||
template_node_child: true
|
||||
}
|
||||
nodes {
|
||||
type: TYPE_TEXT
|
||||
id: "rich_input/cursor_text"
|
||||
parent: "rich_input/cursor_node"
|
||||
template_node_child: true
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: -100.0
|
||||
y: -20.0
|
||||
}
|
||||
size {
|
||||
x: 200.0
|
||||
y: 4.0
|
||||
}
|
||||
color {
|
||||
x: 0.894
|
||||
y: 0.506
|
||||
z: 0.333
|
||||
}
|
||||
type: TYPE_BOX
|
||||
texture: "druid/pixel"
|
||||
id: "selected"
|
||||
pivot: PIVOT_S
|
||||
adjust_mode: ADJUST_MODE_STRETCH
|
||||
parent: "E_Anchor"
|
||||
inherit_alpha: true
|
||||
}
|
||||
material: "/builtins/materials/gui.material"
|
||||
adjust_reference: ADJUST_REFERENCE_PARENT
|
38
druid/widget/properties_panel/properties/property_input.lua
Normal file
38
druid/widget/properties_panel/properties/property_input.lua
Normal file
@@ -0,0 +1,38 @@
|
||||
---@class property_input: druid.widget
|
||||
---@field root node
|
||||
---@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")
|
||||
self.selected = self:get_node("selected")
|
||||
gui.set_alpha(self.selected, 0)
|
||||
|
||||
self.rich_input = self.druid:new_rich_input("rich_input")
|
||||
|
||||
self.container = self.druid:new_container(self.root)
|
||||
self.container:add_container("text_name")
|
||||
self.container:add_container("E_Anchor")
|
||||
end
|
||||
|
||||
|
||||
function M:on_click()
|
||||
gui.set_alpha(self.selected, 1)
|
||||
gui.animate(self.selected, "color.w", 0, gui.EASING_INSINE, 0.16)
|
||||
end
|
||||
|
||||
|
||||
---@param text string
|
||||
---@return property_input
|
||||
function M:set_text_button(text)
|
||||
self.text_button:set_text(text)
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
return M
|
@@ -23,11 +23,11 @@ nodes {
|
||||
x: -200.0
|
||||
}
|
||||
scale {
|
||||
x: 0.65
|
||||
y: 0.65
|
||||
x: 0.5
|
||||
y: 0.5
|
||||
}
|
||||
size {
|
||||
x: 200.0
|
||||
x: 380.0
|
||||
y: 40.0
|
||||
}
|
||||
color {
|
||||
|
@@ -2,23 +2,19 @@
|
||||
---@field root node
|
||||
---@field container druid.container
|
||||
---@field druid druid_instance
|
||||
---@field text_name druid.lang_text
|
||||
---@field text_name druid.text
|
||||
---@field text_value druid.text
|
||||
---@field slider druid.slider
|
||||
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.selected = self:get_node("selected")
|
||||
gui.set_alpha(self.selected, 0)
|
||||
self._value = 0
|
||||
|
||||
self.text_name = self.druid:new_lang_text("text_name") --[[@as druid.lang_text]]
|
||||
self.text_name = self.druid:new_text("text_name")
|
||||
self.text_value = self.druid:new_text("text_value")
|
||||
self.slider = self.druid:new_slider("slider_pin", vmath.vector3(55, 0, 0), self._on_slider_change_by_user) --[[@as druid.slider]]
|
||||
self.slider:set_input_node("slider")
|
||||
@@ -36,7 +32,7 @@ end
|
||||
---@param callback fun(value:number):string
|
||||
function M:set_text_function(callback)
|
||||
self._text_function = callback
|
||||
self.text_value:set_to(self._text_function(self._value))
|
||||
self.text_value:set_text(self._text_function(self._value))
|
||||
end
|
||||
|
||||
|
||||
|
96
druid/widget/properties_panel/properties/property_text.gui
Normal file
96
druid/widget/properties_panel/properties/property_text.gui
Normal file
@@ -0,0 +1,96 @@
|
||||
fonts {
|
||||
name: "text_bold"
|
||||
font: "/druid/fonts/text_bold.font"
|
||||
}
|
||||
textures {
|
||||
name: "druid"
|
||||
texture: "/druid/druid.atlas"
|
||||
}
|
||||
nodes {
|
||||
size {
|
||||
x: 400.0
|
||||
y: 40.0
|
||||
}
|
||||
type: TYPE_BOX
|
||||
texture: "druid/empty"
|
||||
id: "root"
|
||||
adjust_mode: ADJUST_MODE_STRETCH
|
||||
inherit_alpha: true
|
||||
visible: false
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: -200.0
|
||||
}
|
||||
scale {
|
||||
x: 0.5
|
||||
y: 0.5
|
||||
}
|
||||
size {
|
||||
x: 400.0
|
||||
y: 50.0
|
||||
}
|
||||
color {
|
||||
x: 0.463
|
||||
y: 0.475
|
||||
z: 0.49
|
||||
}
|
||||
type: TYPE_TEXT
|
||||
text: "Text"
|
||||
font: "text_bold"
|
||||
id: "text_name"
|
||||
pivot: PIVOT_W
|
||||
outline {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
}
|
||||
shadow {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
}
|
||||
parent: "root"
|
||||
inherit_alpha: true
|
||||
outline_alpha: 0.0
|
||||
shadow_alpha: 0.0
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 200.0
|
||||
}
|
||||
scale {
|
||||
x: 0.5
|
||||
y: 0.5
|
||||
}
|
||||
size {
|
||||
x: 350.0
|
||||
y: 50.0
|
||||
}
|
||||
color {
|
||||
x: 0.722
|
||||
y: 0.741
|
||||
z: 0.761
|
||||
}
|
||||
type: TYPE_TEXT
|
||||
text: "Text"
|
||||
font: "text_bold"
|
||||
id: "text_right"
|
||||
pivot: PIVOT_E
|
||||
outline {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
}
|
||||
shadow {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
}
|
||||
parent: "root"
|
||||
inherit_alpha: true
|
||||
outline_alpha: 0.0
|
||||
shadow_alpha: 0.0
|
||||
}
|
||||
material: "/builtins/materials/gui.material"
|
||||
adjust_reference: ADJUST_REFERENCE_PARENT
|
39
druid/widget/properties_panel/properties/property_text.lua
Normal file
39
druid/widget/properties_panel/properties/property_text.lua
Normal file
@@ -0,0 +1,39 @@
|
||||
---@class property_text: druid.widget
|
||||
---@field root node
|
||||
---@field container druid.container
|
||||
---@field text_name druid.text
|
||||
---@field text_right druid.text
|
||||
local M = {}
|
||||
|
||||
function M:init()
|
||||
self.root = self:get_node("root")
|
||||
self.text_name = self.druid:new_text("text_name")
|
||||
self.text_right = self.druid:new_text("text_right", "")
|
||||
|
||||
self.container = self.druid:new_container(self.root)
|
||||
self.container:add_container("text_name", nil, function(_, size)
|
||||
self.text_name:set_size(size)
|
||||
end)
|
||||
self.container:add_container("text_right", nil, function(_, size)
|
||||
self.text_right:set_size(size)
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
---@param text string
|
||||
---@return property_text
|
||||
function M:set_text(text)
|
||||
self.text_name:set_text(text)
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
---@param text string
|
||||
---@return property_text
|
||||
function M:set_right_text(text)
|
||||
self.text_right:set_text(text or "")
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
return M
|
Reference in New Issue
Block a user