mirror of
https://github.com/Insality/druid.git
synced 2025-09-28 10:32:20 +02:00
Update with container examples
This commit is contained in:
@@ -0,0 +1,308 @@
|
||||
fonts {
|
||||
name: "text_bold"
|
||||
font: "/example/assets/fonts/text_bold.font"
|
||||
}
|
||||
fonts {
|
||||
name: "text_regular"
|
||||
font: "/example/assets/fonts/text_regular.font"
|
||||
}
|
||||
textures {
|
||||
name: "druid_example"
|
||||
texture: "/example/assets/druid_example.atlas"
|
||||
}
|
||||
nodes {
|
||||
size {
|
||||
x: 1000.0
|
||||
y: 1000.0
|
||||
}
|
||||
color {
|
||||
x: 0.173
|
||||
y: 0.184
|
||||
z: 0.204
|
||||
}
|
||||
type: TYPE_BOX
|
||||
texture: "druid_example/ui_circle_64"
|
||||
id: "root"
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 32.0
|
||||
y: 32.0
|
||||
z: 32.0
|
||||
w: 32.0
|
||||
}
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
y: 455.0
|
||||
}
|
||||
size {
|
||||
x: 900.0
|
||||
y: 100.0
|
||||
}
|
||||
type: TYPE_TEXT
|
||||
text: "Can be used as relative anchors"
|
||||
font: "text_bold"
|
||||
id: "text"
|
||||
parent: "root"
|
||||
inherit_alpha: true
|
||||
outline_alpha: 0.0
|
||||
shadow_alpha: 0.0
|
||||
}
|
||||
nodes {
|
||||
size {
|
||||
x: 840.0
|
||||
y: 840.0
|
||||
}
|
||||
color {
|
||||
x: 0.129
|
||||
y: 0.141
|
||||
z: 0.157
|
||||
}
|
||||
type: TYPE_BOX
|
||||
texture: "druid_example/ui_circle_32"
|
||||
id: "parent_container"
|
||||
parent: "root"
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 16.0
|
||||
y: 16.0
|
||||
z: 16.0
|
||||
w: 16.0
|
||||
}
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 400.0
|
||||
y: 400.0
|
||||
}
|
||||
size {
|
||||
x: 96.0
|
||||
y: 96.0
|
||||
}
|
||||
color {
|
||||
x: 0.902
|
||||
y: 0.875
|
||||
z: 0.624
|
||||
}
|
||||
type: TYPE_BOX
|
||||
texture: "druid_example/ui_circle_32"
|
||||
id: "anchor_ne"
|
||||
pivot: PIVOT_NE
|
||||
parent: "parent_container"
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 16.0
|
||||
y: 16.0
|
||||
z: 16.0
|
||||
w: 16.0
|
||||
}
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 400.0
|
||||
}
|
||||
size {
|
||||
x: 96.0
|
||||
y: 96.0
|
||||
}
|
||||
color {
|
||||
x: 0.902
|
||||
y: 0.875
|
||||
z: 0.624
|
||||
}
|
||||
type: TYPE_BOX
|
||||
texture: "druid_example/ui_circle_32"
|
||||
id: "anchor_e"
|
||||
pivot: PIVOT_E
|
||||
parent: "parent_container"
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 16.0
|
||||
y: 16.0
|
||||
z: 16.0
|
||||
w: 16.0
|
||||
}
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
y: 400.0
|
||||
}
|
||||
size {
|
||||
x: 96.0
|
||||
y: 96.0
|
||||
}
|
||||
color {
|
||||
x: 0.902
|
||||
y: 0.875
|
||||
z: 0.624
|
||||
}
|
||||
type: TYPE_BOX
|
||||
texture: "druid_example/ui_circle_32"
|
||||
id: "anchor_n"
|
||||
pivot: PIVOT_N
|
||||
parent: "parent_container"
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 16.0
|
||||
y: 16.0
|
||||
z: 16.0
|
||||
w: 16.0
|
||||
}
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 400.0
|
||||
y: -400.0
|
||||
}
|
||||
size {
|
||||
x: 96.0
|
||||
y: 96.0
|
||||
}
|
||||
color {
|
||||
x: 0.902
|
||||
y: 0.875
|
||||
z: 0.624
|
||||
}
|
||||
type: TYPE_BOX
|
||||
texture: "druid_example/ui_circle_32"
|
||||
id: "anchor_se"
|
||||
pivot: PIVOT_SE
|
||||
parent: "parent_container"
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 16.0
|
||||
y: 16.0
|
||||
z: 16.0
|
||||
w: 16.0
|
||||
}
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
y: -400.0
|
||||
}
|
||||
size {
|
||||
x: 96.0
|
||||
y: 96.0
|
||||
}
|
||||
color {
|
||||
x: 0.902
|
||||
y: 0.875
|
||||
z: 0.624
|
||||
}
|
||||
type: TYPE_BOX
|
||||
texture: "druid_example/ui_circle_32"
|
||||
id: "anchor_s"
|
||||
pivot: PIVOT_S
|
||||
parent: "parent_container"
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 16.0
|
||||
y: 16.0
|
||||
z: 16.0
|
||||
w: 16.0
|
||||
}
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: -400.0
|
||||
y: -400.0
|
||||
}
|
||||
size {
|
||||
x: 96.0
|
||||
y: 96.0
|
||||
}
|
||||
color {
|
||||
x: 0.902
|
||||
y: 0.875
|
||||
z: 0.624
|
||||
}
|
||||
type: TYPE_BOX
|
||||
texture: "druid_example/ui_circle_32"
|
||||
id: "anchor_sw"
|
||||
pivot: PIVOT_SW
|
||||
parent: "parent_container"
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 16.0
|
||||
y: 16.0
|
||||
z: 16.0
|
||||
w: 16.0
|
||||
}
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: -400.0
|
||||
}
|
||||
size {
|
||||
x: 96.0
|
||||
y: 96.0
|
||||
}
|
||||
color {
|
||||
x: 0.902
|
||||
y: 0.875
|
||||
z: 0.624
|
||||
}
|
||||
type: TYPE_BOX
|
||||
texture: "druid_example/ui_circle_32"
|
||||
id: "anchor_w"
|
||||
pivot: PIVOT_W
|
||||
parent: "parent_container"
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 16.0
|
||||
y: 16.0
|
||||
z: 16.0
|
||||
w: 16.0
|
||||
}
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: -400.0
|
||||
y: 400.0
|
||||
}
|
||||
size {
|
||||
x: 96.0
|
||||
y: 96.0
|
||||
}
|
||||
color {
|
||||
x: 0.902
|
||||
y: 0.875
|
||||
z: 0.624
|
||||
}
|
||||
type: TYPE_BOX
|
||||
texture: "druid_example/ui_circle_32"
|
||||
id: "anchor_nw"
|
||||
pivot: PIVOT_NW
|
||||
parent: "parent_container"
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 16.0
|
||||
y: 16.0
|
||||
z: 16.0
|
||||
w: 16.0
|
||||
}
|
||||
}
|
||||
nodes {
|
||||
size {
|
||||
x: 96.0
|
||||
y: 96.0
|
||||
}
|
||||
color {
|
||||
x: 0.902
|
||||
y: 0.875
|
||||
z: 0.624
|
||||
}
|
||||
type: TYPE_BOX
|
||||
texture: "druid_example/ui_circle_32"
|
||||
id: "anchor_center"
|
||||
parent: "parent_container"
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 16.0
|
||||
y: 16.0
|
||||
z: 16.0
|
||||
w: 16.0
|
||||
}
|
||||
}
|
||||
material: "/builtins/materials/gui.material"
|
||||
adjust_reference: ADJUST_REFERENCE_PARENT
|
@@ -0,0 +1,21 @@
|
||||
---@class widget.container_anchors: druid.widget
|
||||
local M = {}
|
||||
|
||||
|
||||
function M:init()
|
||||
self.parent_container = self.druid:new_container("parent_container")
|
||||
self.parent_container:create_draggable_corners()
|
||||
|
||||
self.parent_container:add_container("anchor_ne")
|
||||
self.parent_container:add_container("anchor_nw")
|
||||
self.parent_container:add_container("anchor_se")
|
||||
self.parent_container:add_container("anchor_sw")
|
||||
self.parent_container:add_container("anchor_n")
|
||||
self.parent_container:add_container("anchor_s")
|
||||
self.parent_container:add_container("anchor_e")
|
||||
self.parent_container:add_container("anchor_w")
|
||||
self.parent_container:add_container("anchor_center")
|
||||
end
|
||||
|
||||
|
||||
return M
|
416
example/examples/container/container_resize/container_resize.gui
Normal file
416
example/examples/container/container_resize/container_resize.gui
Normal file
@@ -0,0 +1,416 @@
|
||||
fonts {
|
||||
name: "text_bold"
|
||||
font: "/example/assets/fonts/text_bold.font"
|
||||
}
|
||||
fonts {
|
||||
name: "text_regular"
|
||||
font: "/example/assets/fonts/text_regular.font"
|
||||
}
|
||||
textures {
|
||||
name: "druid_example"
|
||||
texture: "/example/assets/druid_example.atlas"
|
||||
}
|
||||
nodes {
|
||||
size {
|
||||
x: 1000.0
|
||||
y: 1000.0
|
||||
}
|
||||
color {
|
||||
x: 0.173
|
||||
y: 0.184
|
||||
z: 0.204
|
||||
}
|
||||
type: TYPE_BOX
|
||||
texture: "druid_example/ui_circle_64"
|
||||
id: "root"
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 32.0
|
||||
y: 32.0
|
||||
z: 32.0
|
||||
w: 32.0
|
||||
}
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
y: 455.0
|
||||
}
|
||||
size {
|
||||
x: 900.0
|
||||
y: 100.0
|
||||
}
|
||||
type: TYPE_TEXT
|
||||
text: "Can be used as relative anchors"
|
||||
font: "text_bold"
|
||||
id: "text"
|
||||
parent: "root"
|
||||
inherit_alpha: true
|
||||
outline_alpha: 0.0
|
||||
shadow_alpha: 0.0
|
||||
}
|
||||
nodes {
|
||||
size {
|
||||
x: 800.0
|
||||
y: 800.0
|
||||
}
|
||||
color {
|
||||
x: 0.129
|
||||
y: 0.141
|
||||
z: 0.157
|
||||
}
|
||||
type: TYPE_BOX
|
||||
texture: "druid_example/ui_circle_32"
|
||||
id: "parent_container"
|
||||
parent: "root"
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 16.0
|
||||
y: 16.0
|
||||
z: 16.0
|
||||
w: 16.0
|
||||
}
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: -400.0
|
||||
}
|
||||
size {
|
||||
x: 200.0
|
||||
y: 800.0
|
||||
}
|
||||
color {
|
||||
x: 0.902
|
||||
y: 0.875
|
||||
z: 0.624
|
||||
}
|
||||
type: TYPE_BOX
|
||||
texture: "druid_example/ui_circle_32"
|
||||
id: "panel_left"
|
||||
pivot: PIVOT_W
|
||||
parent: "parent_container"
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 16.0
|
||||
y: 16.0
|
||||
z: 16.0
|
||||
w: 16.0
|
||||
}
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 400.0
|
||||
}
|
||||
size {
|
||||
x: 200.0
|
||||
y: 800.0
|
||||
}
|
||||
color {
|
||||
x: 0.957
|
||||
y: 0.608
|
||||
z: 0.608
|
||||
}
|
||||
type: TYPE_BOX
|
||||
texture: "druid_example/ui_circle_32"
|
||||
id: "panel_right"
|
||||
pivot: PIVOT_E
|
||||
parent: "parent_container"
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 16.0
|
||||
y: 16.0
|
||||
z: 16.0
|
||||
w: 16.0
|
||||
}
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
y: -400.0
|
||||
}
|
||||
size {
|
||||
x: 400.0
|
||||
y: 200.0
|
||||
}
|
||||
color {
|
||||
x: 0.631
|
||||
y: 0.843
|
||||
z: 0.961
|
||||
}
|
||||
type: TYPE_BOX
|
||||
texture: "druid_example/ui_circle_32"
|
||||
id: "panel_bot"
|
||||
xanchor: XANCHOR_LEFT
|
||||
pivot: PIVOT_S
|
||||
adjust_mode: ADJUST_MODE_STRETCH
|
||||
parent: "parent_container"
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 16.0
|
||||
y: 16.0
|
||||
z: 16.0
|
||||
w: 16.0
|
||||
}
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
y: 100.0
|
||||
}
|
||||
size {
|
||||
x: 400.0
|
||||
y: 600.0
|
||||
}
|
||||
color {
|
||||
x: 0.557
|
||||
y: 0.835
|
||||
z: 0.62
|
||||
}
|
||||
type: TYPE_BOX
|
||||
texture: "druid_example/ui_circle_32"
|
||||
id: "panel_content"
|
||||
xanchor: XANCHOR_LEFT
|
||||
yanchor: YANCHOR_BOTTOM
|
||||
adjust_mode: ADJUST_MODE_STRETCH
|
||||
parent: "parent_container"
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 16.0
|
||||
y: 16.0
|
||||
z: 16.0
|
||||
w: 16.0
|
||||
}
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 200.0
|
||||
y: 300.0
|
||||
}
|
||||
size {
|
||||
x: 32.0
|
||||
y: 32.0
|
||||
}
|
||||
color {
|
||||
x: 0.129
|
||||
y: 0.141
|
||||
z: 0.157
|
||||
}
|
||||
type: TYPE_BOX
|
||||
texture: "druid_example/ui_circle_32"
|
||||
id: "anchor_ne"
|
||||
pivot: PIVOT_NE
|
||||
parent: "panel_content"
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 16.0
|
||||
y: 16.0
|
||||
z: 16.0
|
||||
w: 16.0
|
||||
}
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
y: -300.0
|
||||
}
|
||||
size {
|
||||
x: 32.0
|
||||
y: 32.0
|
||||
}
|
||||
color {
|
||||
x: 0.129
|
||||
y: 0.141
|
||||
z: 0.157
|
||||
}
|
||||
type: TYPE_BOX
|
||||
texture: "druid_example/ui_circle_32"
|
||||
id: "anchor_s"
|
||||
pivot: PIVOT_S
|
||||
parent: "panel_content"
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 16.0
|
||||
y: 16.0
|
||||
z: 16.0
|
||||
w: 16.0
|
||||
}
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: -200.0
|
||||
y: -300.0
|
||||
}
|
||||
size {
|
||||
x: 32.0
|
||||
y: 32.0
|
||||
}
|
||||
color {
|
||||
x: 0.129
|
||||
y: 0.141
|
||||
z: 0.157
|
||||
}
|
||||
type: TYPE_BOX
|
||||
texture: "druid_example/ui_circle_32"
|
||||
id: "anchor_sw"
|
||||
pivot: PIVOT_SW
|
||||
parent: "panel_content"
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 16.0
|
||||
y: 16.0
|
||||
z: 16.0
|
||||
w: 16.0
|
||||
}
|
||||
}
|
||||
nodes {
|
||||
size {
|
||||
x: 32.0
|
||||
y: 32.0
|
||||
}
|
||||
color {
|
||||
x: 0.129
|
||||
y: 0.141
|
||||
z: 0.157
|
||||
}
|
||||
type: TYPE_BOX
|
||||
texture: "druid_example/ui_circle_32"
|
||||
id: "anchor_center"
|
||||
parent: "panel_content"
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 16.0
|
||||
y: 16.0
|
||||
z: 16.0
|
||||
w: 16.0
|
||||
}
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
y: 300.0
|
||||
}
|
||||
size {
|
||||
x: 32.0
|
||||
y: 32.0
|
||||
}
|
||||
color {
|
||||
x: 0.129
|
||||
y: 0.141
|
||||
z: 0.157
|
||||
}
|
||||
type: TYPE_BOX
|
||||
texture: "druid_example/ui_circle_32"
|
||||
id: "anchor_n"
|
||||
pivot: PIVOT_N
|
||||
parent: "panel_content"
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 16.0
|
||||
y: 16.0
|
||||
z: 16.0
|
||||
w: 16.0
|
||||
}
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 200.0
|
||||
}
|
||||
size {
|
||||
x: 32.0
|
||||
y: 32.0
|
||||
}
|
||||
color {
|
||||
x: 0.129
|
||||
y: 0.141
|
||||
z: 0.157
|
||||
}
|
||||
type: TYPE_BOX
|
||||
texture: "druid_example/ui_circle_32"
|
||||
id: "anchor_e"
|
||||
pivot: PIVOT_E
|
||||
parent: "panel_content"
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 16.0
|
||||
y: 16.0
|
||||
z: 16.0
|
||||
w: 16.0
|
||||
}
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: -200.0
|
||||
y: 300.0
|
||||
}
|
||||
size {
|
||||
x: 32.0
|
||||
y: 32.0
|
||||
}
|
||||
color {
|
||||
x: 0.129
|
||||
y: 0.141
|
||||
z: 0.157
|
||||
}
|
||||
type: TYPE_BOX
|
||||
texture: "druid_example/ui_circle_32"
|
||||
id: "anchor_nw"
|
||||
pivot: PIVOT_NW
|
||||
parent: "panel_content"
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 16.0
|
||||
y: 16.0
|
||||
z: 16.0
|
||||
w: 16.0
|
||||
}
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: -200.0
|
||||
}
|
||||
size {
|
||||
x: 32.0
|
||||
y: 32.0
|
||||
}
|
||||
color {
|
||||
x: 0.129
|
||||
y: 0.141
|
||||
z: 0.157
|
||||
}
|
||||
type: TYPE_BOX
|
||||
texture: "druid_example/ui_circle_32"
|
||||
id: "anchor_w"
|
||||
pivot: PIVOT_W
|
||||
parent: "panel_content"
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 16.0
|
||||
y: 16.0
|
||||
z: 16.0
|
||||
w: 16.0
|
||||
}
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 200.0
|
||||
y: -300.0
|
||||
}
|
||||
size {
|
||||
x: 32.0
|
||||
y: 32.0
|
||||
}
|
||||
color {
|
||||
x: 0.129
|
||||
y: 0.141
|
||||
z: 0.157
|
||||
}
|
||||
type: TYPE_BOX
|
||||
texture: "druid_example/ui_circle_32"
|
||||
id: "anchor_se"
|
||||
pivot: PIVOT_SE
|
||||
parent: "panel_content"
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 16.0
|
||||
y: 16.0
|
||||
z: 16.0
|
||||
w: 16.0
|
||||
}
|
||||
}
|
||||
material: "/builtins/materials/gui.material"
|
||||
adjust_reference: ADJUST_REFERENCE_PARENT
|
@@ -0,0 +1,26 @@
|
||||
---@class widget.container_anchors: druid.widget
|
||||
local M = {}
|
||||
|
||||
|
||||
function M:init()
|
||||
self.parent_container = self.druid:new_container("parent_container")
|
||||
self.parent_container:create_draggable_corners()
|
||||
|
||||
self.parent_container:add_container("panel_left", "stretch_y")
|
||||
self.parent_container:add_container("panel_right", "stretch_y")
|
||||
self.parent_container:add_container("panel_bot", "stretch_x")
|
||||
|
||||
self.container_content = self.parent_container:add_container("panel_content")
|
||||
self.container_content:add_container("anchor_ne")
|
||||
self.container_content:add_container("anchor_nw")
|
||||
self.container_content:add_container("anchor_se")
|
||||
self.container_content:add_container("anchor_sw")
|
||||
self.container_content:add_container("anchor_n")
|
||||
self.container_content:add_container("anchor_s")
|
||||
self.container_content:add_container("anchor_e")
|
||||
self.container_content:add_container("anchor_w")
|
||||
self.container_content:add_container("anchor_center")
|
||||
end
|
||||
|
||||
|
||||
return M
|
25
example/examples/container/examples_list.lua
Normal file
25
example/examples/container/examples_list.lua
Normal file
@@ -0,0 +1,25 @@
|
||||
local M = {}
|
||||
|
||||
function M.get_examples()
|
||||
---@type druid.example.data[]
|
||||
return {
|
||||
{
|
||||
name_id = "ui_example_container_anchors",
|
||||
information_text_id = "ui_example_container_anchors_description",
|
||||
template = "container_anchors",
|
||||
root = "container_anchors/root",
|
||||
code_url = "example/examples/container/container_anchors/container_anchors.lua",
|
||||
widget_class = require("example.examples.container.container_anchors.container_anchors"),
|
||||
},
|
||||
{
|
||||
name_id = "ui_example_container_resize",
|
||||
information_text_id = "ui_example_container_resize_description",
|
||||
template = "container_resize",
|
||||
root = "container_resize/root",
|
||||
code_url = "example/examples/container/container_resize/container_resize.lua",
|
||||
widget_class = require("example.examples.container.container_resize.container_resize"),
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
return M
|
Reference in New Issue
Block a user