From 25f02fd116cc74716752e2923190d8fc2ee572bb Mon Sep 17 00:00:00 2001 From: Insality Date: Sun, 26 Oct 2025 19:40:19 +0200 Subject: [PATCH 1/6] Update property panel, add small button for more text --- .../properties/property_checkbox.gui | 6 +- .../properties/property_checkbox.lua | 1 + .../properties_panel/properties_panel.gui | 77 +++++++++++++++++++ .../properties_panel/properties_panel.lua | 8 ++ 4 files changed, 89 insertions(+), 3 deletions(-) diff --git a/druid/widget/properties_panel/properties/property_checkbox.gui b/druid/widget/properties_panel/properties/property_checkbox.gui index aeb1180..1edfc64 100644 --- a/druid/widget/properties_panel/properties/property_checkbox.gui +++ b/druid/widget/properties_panel/properties/property_checkbox.gui @@ -27,7 +27,7 @@ nodes { y: 0.5 } size { - x: 360.0 + x: 700.0 y: 40.0 } color { @@ -60,7 +60,7 @@ nodes { x: 200.0 } size { - x: 200.0 + x: 40.0 y: 40.0 } type: TYPE_BOX @@ -73,7 +73,7 @@ nodes { } nodes { position { - x: -180.0 + x: -20.0 } size { x: 40.0 diff --git a/druid/widget/properties_panel/properties/property_checkbox.lua b/druid/widget/properties_panel/properties/property_checkbox.lua index d267f2a..e091e8f 100644 --- a/druid/widget/properties_panel/properties/property_checkbox.lua +++ b/druid/widget/properties_panel/properties/property_checkbox.lua @@ -77,6 +77,7 @@ end ---@param enabled boolean function M:set_enabled(enabled) self.button:set_enabled(enabled) + gui.set_alpha(self.button.node, enabled and 1 or 0.75) end diff --git a/druid/widget/properties_panel/properties_panel.gui b/druid/widget/properties_panel/properties_panel.gui index 7657a9e..7ed9cd7 100644 --- a/druid/widget/properties_panel/properties_panel.gui +++ b/druid/widget/properties_panel/properties_panel.gui @@ -747,5 +747,82 @@ nodes { parent: "property_vector3/field_z" template_node_child: true } +nodes { + position { + y: -100.0 + } + type: TYPE_TEMPLATE + id: "property_button_small" + parent: "propeties" + inherit_alpha: true + template: "/druid/widget/properties_panel/properties/property_button.gui" +} +nodes { + type: TYPE_BOX + id: "property_button_small/root" + parent: "property_button_small" + template_node_child: true +} +nodes { + size { + x: 700.0 + y: 40.0 + } + type: TYPE_TEXT + id: "property_button_small/text_name" + parent: "property_button_small/root" + overridden_fields: 4 + template_node_child: true +} +nodes { + size { + x: 40.0 + y: 40.0 + } + type: TYPE_BOX + id: "property_button_small/E_Anchor" + parent: "property_button_small/root" + overridden_fields: 4 + template_node_child: true +} +nodes { + position { + x: -20.0 + } + size { + x: 40.0 + y: 40.0 + } + type: TYPE_BOX + id: "property_button_small/button" + parent: "property_button_small/E_Anchor" + overridden_fields: 1 + overridden_fields: 4 + template_node_child: true +} +nodes { + size { + x: 40.0 + y: 4.0 + } + type: TYPE_BOX + id: "property_button_small/selected" + parent: "property_button_small/button" + overridden_fields: 4 + template_node_child: true +} +nodes { + size { + x: 40.0 + y: 50.0 + } + type: TYPE_TEXT + text: ">" + id: "property_button_small/text_button" + parent: "property_button_small/button" + overridden_fields: 4 + overridden_fields: 8 + template_node_child: true +} material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/druid/widget/properties_panel/properties_panel.lua b/druid/widget/properties_panel/properties_panel.lua index 83c30af..25ff9a1 100644 --- a/druid/widget/properties_panel/properties_panel.lua +++ b/druid/widget/properties_panel/properties_panel.lua @@ -88,6 +88,7 @@ function M:init() gui.set_enabled(self:get_node("property_checkbox/root"), false) gui.set_enabled(self:get_node("property_slider/root"), false) gui.set_enabled(self:get_node("property_button/root"), false) + gui.set_enabled(self:get_node("property_button_small/root"), false) gui.set_enabled(self:get_node("property_input/root"), false) gui.set_enabled(self:get_node("property_text/root"), false) gui.set_enabled(self:get_node("property_left_right_selector/root"), false) @@ -254,6 +255,12 @@ function M:add_button(on_create) return self:add_inner_widget(property_button, "property_button", "root", on_create) end +---@param on_create fun(button: druid.widget.property_button)|nil +---@return druid.widget.properties_panel +function M:add_button_small(on_create) + return self:add_inner_widget(property_button, "property_button_small", "root", on_create) +end + ---@param on_create fun(input: druid.widget.property_input)|nil ---@return druid.widget.properties_panel @@ -378,6 +385,7 @@ function M:set_hidden(is_hidden) gui.set_enabled(self.text_header.node, not self._is_hidden) gui.set_enabled(self.content, not self._is_hidden) gui.set_enabled(self.button_refresh.node, not self._is_hidden) + gui.set_visible(self.button_back.node, not self._is_hidden) if not self._is_hidden then self.is_dirty = true From 3e0d898b32e5c45b900cfe2da240b18274450a7a Mon Sep 17 00:00:00 2001 From: Insality Date: Sun, 26 Oct 2025 21:53:03 +0200 Subject: [PATCH 2/6] Update default state of property button small --- druid/widget/properties_panel/properties_panel.gui | 1 + 1 file changed, 1 insertion(+) diff --git a/druid/widget/properties_panel/properties_panel.gui b/druid/widget/properties_panel/properties_panel.gui index 7ed9cd7..19982eb 100644 --- a/druid/widget/properties_panel/properties_panel.gui +++ b/druid/widget/properties_panel/properties_panel.gui @@ -756,6 +756,7 @@ nodes { parent: "propeties" inherit_alpha: true template: "/druid/widget/properties_panel/properties/property_button.gui" + enabled: false } nodes { type: TYPE_BOX From f0f90ce9b17785faf030258687ffe6fe21e0271c Mon Sep 17 00:00:00 2001 From: Insality Date: Sun, 26 Oct 2025 22:35:03 +0200 Subject: [PATCH 3/6] Update property panels layers --- druid/helper.lua | 3 ++- .../properties/property_button.gui | 11 +++++++++ .../properties/property_checkbox.gui | 11 +++++++++ .../properties/property_input.gui | 9 ++++++++ .../property_left_right_selector.gui | 14 +++++++++++ .../properties/property_slider.gui | 14 +++++++++++ .../properties/property_text.gui | 9 ++++++++ .../properties/property_vector3.gui | 23 ++++++++++++++++--- .../properties_panel/properties_panel.gui | 16 ++++++++++++- 9 files changed, 105 insertions(+), 5 deletions(-) diff --git a/druid/helper.lua b/druid/helper.lua index 021a2b2..bb43d0c 100644 --- a/druid/helper.lua +++ b/druid/helper.lua @@ -366,7 +366,8 @@ end ---Check if device is desktop ---@return boolean function M.is_desktop() - return const.CURRENT_SYSTEM_NAME == const.OS.WINDOWS or const.CURRENT_SYSTEM_NAME == const.OS.MAC or const.CURRENT_SYSTEM_NAME == const.OS.LINUX + local name = const.CURRENT_SYSTEM_NAME + return name == const.OS.WINDOWS or name == const.OS.MAC or name == const.OS.LINUX end diff --git a/druid/widget/properties_panel/properties/property_button.gui b/druid/widget/properties_panel/properties/property_button.gui index a7e55c8..e2c9973 100644 --- a/druid/widget/properties_panel/properties/property_button.gui +++ b/druid/widget/properties_panel/properties/property_button.gui @@ -15,6 +15,7 @@ nodes { texture: "druid/empty" id: "root" adjust_mode: ADJUST_MODE_STRETCH + layer: "druid" inherit_alpha: true visible: false } @@ -52,6 +53,7 @@ nodes { } adjust_mode: ADJUST_MODE_STRETCH parent: "root" + layer: "druid_text_bold" inherit_alpha: true outline_alpha: 0.0 shadow_alpha: 0.0 @@ -89,6 +91,7 @@ nodes { texture: "druid/rect_round2_width2" id: "button" parent: "E_Anchor" + layer: "druid" inherit_alpha: true slice9 { x: 5.0 @@ -116,6 +119,7 @@ nodes { pivot: PIVOT_S adjust_mode: ADJUST_MODE_STRETCH parent: "button" + layer: "druid" inherit_alpha: true } nodes { @@ -147,9 +151,16 @@ nodes { z: 1.0 } parent: "button" + layer: "druid_text_bold" inherit_alpha: true outline_alpha: 0.0 shadow_alpha: 0.0 } +layers { + name: "druid" +} +layers { + name: "druid_text_bold" +} material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/druid/widget/properties_panel/properties/property_checkbox.gui b/druid/widget/properties_panel/properties/property_checkbox.gui index 1edfc64..9cf5768 100644 --- a/druid/widget/properties_panel/properties/property_checkbox.gui +++ b/druid/widget/properties_panel/properties/property_checkbox.gui @@ -15,6 +15,7 @@ nodes { texture: "druid/empty" id: "root" adjust_mode: ADJUST_MODE_STRETCH + layer: "druid" inherit_alpha: true visible: false } @@ -51,6 +52,7 @@ nodes { z: 1.0 } parent: "root" + layer: "druid_text_bold" inherit_alpha: true outline_alpha: 0.0 shadow_alpha: 0.0 @@ -88,6 +90,7 @@ nodes { texture: "druid/rect_round2_width2" id: "button" parent: "E_Anchor" + layer: "druid" inherit_alpha: true slice9 { x: 5.0 @@ -106,6 +109,7 @@ nodes { texture: "druid/ui_circle_16" id: "icon" parent: "button" + layer: "druid" inherit_alpha: true size_mode: SIZE_MODE_AUTO } @@ -128,7 +132,14 @@ nodes { pivot: PIVOT_S adjust_mode: ADJUST_MODE_STRETCH parent: "button" + layer: "druid" inherit_alpha: true } +layers { + name: "druid" +} +layers { + name: "druid_text_bold" +} material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/druid/widget/properties_panel/properties/property_input.gui b/druid/widget/properties_panel/properties/property_input.gui index c204d30..bb599c9 100644 --- a/druid/widget/properties_panel/properties/property_input.gui +++ b/druid/widget/properties_panel/properties/property_input.gui @@ -15,6 +15,7 @@ nodes { texture: "druid/empty" id: "root" adjust_mode: ADJUST_MODE_STRETCH + layer: "druid" inherit_alpha: true visible: false } @@ -51,6 +52,7 @@ nodes { z: 1.0 } parent: "root" + layer: "druid_text_bold" inherit_alpha: true outline_alpha: 0.0 shadow_alpha: 0.0 @@ -137,7 +139,14 @@ nodes { pivot: PIVOT_S adjust_mode: ADJUST_MODE_STRETCH parent: "E_Anchor" + layer: "druid" inherit_alpha: true } +layers { + name: "druid" +} +layers { + name: "druid_text_bold" +} material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/druid/widget/properties_panel/properties/property_left_right_selector.gui b/druid/widget/properties_panel/properties/property_left_right_selector.gui index 69f8b73..19c6a3d 100644 --- a/druid/widget/properties_panel/properties/property_left_right_selector.gui +++ b/druid/widget/properties_panel/properties/property_left_right_selector.gui @@ -15,6 +15,7 @@ nodes { texture: "druid/empty" id: "root" adjust_mode: ADJUST_MODE_STRETCH + layer: "druid" inherit_alpha: true visible: false } @@ -51,6 +52,7 @@ nodes { z: 1.0 } parent: "root" + layer: "druid_text_bold" inherit_alpha: true outline_alpha: 0.0 shadow_alpha: 0.0 @@ -88,6 +90,7 @@ nodes { texture: "druid/rect_round2_width2" id: "button_left" parent: "E_Anchor" + layer: "druid" inherit_alpha: true slice9 { x: 5.0 @@ -109,6 +112,7 @@ nodes { texture: "druid/icon_arrow" id: "icon_left" parent: "button_left" + layer: "druid" inherit_alpha: true size_mode: SIZE_MODE_AUTO } @@ -129,6 +133,7 @@ nodes { texture: "druid/rect_round2_width2" id: "button_right" parent: "E_Anchor" + layer: "druid" inherit_alpha: true slice9 { x: 5.0 @@ -147,6 +152,7 @@ nodes { texture: "druid/icon_arrow" id: "icon_right" parent: "button_right" + layer: "druid" inherit_alpha: true size_mode: SIZE_MODE_AUTO } @@ -170,6 +176,7 @@ nodes { pivot: PIVOT_S adjust_mode: ADJUST_MODE_STRETCH parent: "E_Anchor" + layer: "druid" inherit_alpha: true } nodes { @@ -204,9 +211,16 @@ nodes { z: 1.0 } parent: "E_Anchor" + layer: "druid_text_bold" inherit_alpha: true outline_alpha: 0.0 shadow_alpha: 0.0 } +layers { + name: "druid" +} +layers { + name: "druid_text_bold" +} material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/druid/widget/properties_panel/properties/property_slider.gui b/druid/widget/properties_panel/properties/property_slider.gui index 4a2f739..22b5b3b 100644 --- a/druid/widget/properties_panel/properties/property_slider.gui +++ b/druid/widget/properties_panel/properties/property_slider.gui @@ -15,6 +15,7 @@ nodes { texture: "druid/empty" id: "root" adjust_mode: ADJUST_MODE_STRETCH + layer: "druid" inherit_alpha: true visible: false } @@ -51,6 +52,7 @@ nodes { z: 1.0 } parent: "root" + layer: "druid_text_bold" inherit_alpha: true outline_alpha: 0.0 shadow_alpha: 0.0 @@ -89,6 +91,7 @@ nodes { texture: "druid/empty" id: "slider" parent: "E_Anchor" + layer: "druid" inherit_alpha: true } nodes { @@ -105,6 +108,7 @@ nodes { texture: "druid/ui_circle_8" id: "slider_back" parent: "slider" + layer: "druid" inherit_alpha: true slice9 { x: 4.0 @@ -130,6 +134,7 @@ nodes { texture: "druid/ui_circle_8" id: "slider_pin" parent: "slider" + layer: "druid" inherit_alpha: true slice9 { x: 4.0 @@ -153,6 +158,7 @@ nodes { id: "button" pivot: PIVOT_E parent: "E_Anchor" + layer: "druid" inherit_alpha: true slice9 { x: 4.0 @@ -180,6 +186,7 @@ nodes { pivot: PIVOT_SE adjust_mode: ADJUST_MODE_STRETCH parent: "button" + layer: "druid" inherit_alpha: true } nodes { @@ -214,9 +221,16 @@ nodes { z: 1.0 } parent: "button" + layer: "druid_text_bold" inherit_alpha: true outline_alpha: 0.0 shadow_alpha: 0.0 } +layers { + name: "druid" +} +layers { + name: "druid_text_bold" +} material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/druid/widget/properties_panel/properties/property_text.gui b/druid/widget/properties_panel/properties/property_text.gui index 1f1af0a..f1a8937 100644 --- a/druid/widget/properties_panel/properties/property_text.gui +++ b/druid/widget/properties_panel/properties/property_text.gui @@ -15,6 +15,7 @@ nodes { texture: "druid/empty" id: "root" adjust_mode: ADJUST_MODE_STRETCH + layer: "druid" inherit_alpha: true visible: false } @@ -51,6 +52,7 @@ nodes { z: 1.0 } parent: "root" + layer: "druid_text_bold" inherit_alpha: true outline_alpha: 0.0 shadow_alpha: 0.0 @@ -88,9 +90,16 @@ nodes { z: 1.0 } parent: "root" + layer: "druid_text_bold" inherit_alpha: true outline_alpha: 0.0 shadow_alpha: 0.0 } +layers { + name: "druid" +} +layers { + name: "druid_text_bold" +} material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/druid/widget/properties_panel/properties/property_vector3.gui b/druid/widget/properties_panel/properties/property_vector3.gui index 71b30f2..f5091e6 100644 --- a/druid/widget/properties_panel/properties/property_vector3.gui +++ b/druid/widget/properties_panel/properties/property_vector3.gui @@ -19,6 +19,7 @@ nodes { texture: "druid/empty" id: "root" adjust_mode: ADJUST_MODE_STRETCH + layer: "druid" inherit_alpha: true visible: false } @@ -55,6 +56,7 @@ nodes { z: 1.0 } parent: "root" + layer: "druid_text_bold" inherit_alpha: true outline_alpha: 0.0 shadow_alpha: 0.0 @@ -113,6 +115,7 @@ nodes { font: "druid_text_regular" id: "text_x" parent: "field_x" + layer: "druid_text_regular" inherit_alpha: true outline_alpha: 0.0 shadow_alpha: 0.0 @@ -167,7 +170,7 @@ nodes { y: 50.0 } type: TYPE_TEXT - text: "20.0" + text: "20" id: "rich_input_x/input_text" parent: "rich_input_x/root" overridden_fields: 4 @@ -210,6 +213,7 @@ nodes { pivot: PIVOT_S adjust_mode: ADJUST_MODE_STRETCH parent: "field_x" + layer: "druid" inherit_alpha: true } nodes { @@ -250,6 +254,7 @@ nodes { font: "druid_text_regular" id: "text_y" parent: "field_y" + layer: "druid_text_regular" inherit_alpha: true outline_alpha: 0.0 shadow_alpha: 0.0 @@ -304,7 +309,7 @@ nodes { y: 50.0 } type: TYPE_TEXT - text: "20.0" + text: "20" id: "rich_input_y/input_text" parent: "rich_input_y/root" overridden_fields: 4 @@ -347,6 +352,7 @@ nodes { pivot: PIVOT_S adjust_mode: ADJUST_MODE_STRETCH parent: "field_y" + layer: "druid" inherit_alpha: true } nodes { @@ -387,6 +393,7 @@ nodes { font: "druid_text_regular" id: "text_z" parent: "field_z" + layer: "druid_text_regular" inherit_alpha: true outline_alpha: 0.0 shadow_alpha: 0.0 @@ -441,7 +448,7 @@ nodes { y: 50.0 } type: TYPE_TEXT - text: "20.0" + text: "20" id: "rich_input_z/input_text" parent: "rich_input_z/root" overridden_fields: 4 @@ -484,7 +491,17 @@ nodes { pivot: PIVOT_S adjust_mode: ADJUST_MODE_STRETCH parent: "field_z" + layer: "druid" inherit_alpha: true } +layers { + name: "druid" +} +layers { + name: "druid_text_bold" +} +layers { + name: "druid_text_regular" +} material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/druid/widget/properties_panel/properties_panel.gui b/druid/widget/properties_panel/properties_panel.gui index 19982eb..9f801af 100644 --- a/druid/widget/properties_panel/properties_panel.gui +++ b/druid/widget/properties_panel/properties_panel.gui @@ -24,6 +24,7 @@ nodes { texture: "druid/ui_circle_16" id: "root" pivot: PIVOT_N + layer: "druid" inherit_alpha: true slice9 { x: 8.0 @@ -50,6 +51,7 @@ nodes { id: "header" pivot: PIVOT_NE parent: "root" + layer: "druid" inherit_alpha: true slice9 { x: 8.0 @@ -92,6 +94,7 @@ nodes { z: 1.0 } parent: "header" + layer: "druid_text_regular" inherit_alpha: true outline_alpha: 0.0 shadow_alpha: 0.0 @@ -111,6 +114,7 @@ nodes { id: "icon_drag" pivot: PIVOT_NE parent: "header" + layer: "druid" inherit_alpha: true size_mode: SIZE_MODE_AUTO } @@ -129,6 +133,7 @@ nodes { id: "icon_refresh" pivot: PIVOT_NE parent: "header" + layer: "druid" inherit_alpha: true size_mode: SIZE_MODE_AUTO } @@ -150,6 +155,7 @@ nodes { id: "icon_back" pivot: PIVOT_NW parent: "header" + layer: "druid" inherit_alpha: true size_mode: SIZE_MODE_AUTO } @@ -184,8 +190,8 @@ nodes { pivot: PIVOT_NW adjust_mode: ADJUST_MODE_STRETCH parent: "content" + layer: "druid" inherit_alpha: true - clipping_mode: CLIPPING_MODE_STENCIL } nodes { size { @@ -198,6 +204,7 @@ nodes { pivot: PIVOT_NW adjust_mode: ADJUST_MODE_STRETCH parent: "scroll_view" + layer: "druid" inherit_alpha: true slice9 { x: 8.0 @@ -214,6 +221,7 @@ nodes { texture: "druid/empty" id: "propeties" parent: "content" + layer: "druid" inherit_alpha: true size_mode: SIZE_MODE_AUTO visible: false @@ -825,5 +833,11 @@ nodes { overridden_fields: 8 template_node_child: true } +layers { + name: "druid" +} +layers { + name: "druid_text_regular" +} material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT From 40dbca0dff1430b8c884cd47f78c299b040c3b50 Mon Sep 17 00:00:00 2001 From: Insality Date: Sun, 26 Oct 2025 23:00:50 +0200 Subject: [PATCH 4/6] Update --- wiki/changelog.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/wiki/changelog.md b/wiki/changelog.md index 4ee0243..3e305c7 100644 --- a/wiki/changelog.md +++ b/wiki/changelog.md @@ -727,14 +727,16 @@ Please support me if you like this project! It will help me keep engaged to upda - Create with `druid:new_image(node_or_node_id)` - Currently used to load image from resource path, absolute path or URL - Can be fit inside (keeping aspect ratio) stretched to the node area, depends on the GUI adjust mode -- [Blocker] Fix for internal is_enabled state -- [Button] expose all click functions for the button +- [Blocker] Fix for internal `is_enabled` state +- [Button] Expose all click functions for the button - [Scroll] Add `scroll_to_make_node_visible` function - [Palette] Add Druid Color module + - Use `local color = require("druid.color")` to access the module - Manage color palettes - - Color convertations + - Color conversions - Convenient usage -- [Container] Fix for container stretch mode (stretch and fit is not worked in init function) +- [Container] Fix for container stretch mode + - `stretch` and `fit` was not init correctly in the `init` function arguments - [Rich Text] Using color names from the palette - [Rich Text] Add `rich_text:set_split_to_characters(true)` to split each letter node separately - Weird implementation, but nice to have From c43356d74336339813ba8f58300fbe32a6e61822 Mon Sep 17 00:00:00 2001 From: Insality Date: Sun, 26 Oct 2025 23:05:14 +0200 Subject: [PATCH 5/6] Update --- example/druid.gui | 42 +++++++++++++++ .../example_properties_panel.gui | 54 +++++++++++++++++++ game.project | 4 +- 3 files changed, 98 insertions(+), 2 deletions(-) diff --git a/example/druid.gui b/example/druid.gui index b8244ef..54017d6 100644 --- a/example/druid.gui +++ b/example/druid.gui @@ -4621,6 +4621,48 @@ nodes { parent: "properties_panel/property_vector3/field_z" template_node_child: true } +nodes { + type: TYPE_TEMPLATE + id: "properties_panel/property_button_small" + parent: "properties_panel/propeties" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_button_small/root" + parent: "properties_panel/property_button_small" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_button_small/text_name" + parent: "properties_panel/property_button_small/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_button_small/E_Anchor" + parent: "properties_panel/property_button_small/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_button_small/button" + parent: "properties_panel/property_button_small/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_button_small/selected" + parent: "properties_panel/property_button_small/button" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_button_small/text_button" + parent: "properties_panel/property_button_small/button" + template_node_child: true +} nodes { type: TYPE_TEMPLATE id: "memory_panel" diff --git a/example/examples/widgets/properties_panel/example_properties_panel.gui b/example/examples/widgets/properties_panel/example_properties_panel.gui index c88910a..032830a 100644 --- a/example/examples/widgets/properties_panel/example_properties_panel.gui +++ b/example/examples/widgets/properties_panel/example_properties_panel.gui @@ -40,6 +40,18 @@ nodes { parent: "properties_panel/header" template_node_child: true } +nodes { + type: TYPE_BOX + id: "properties_panel/icon_refresh" + parent: "properties_panel/header" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/icon_back" + parent: "properties_panel/header" + template_node_child: true +} nodes { type: TYPE_BOX id: "properties_panel/content" @@ -568,5 +580,47 @@ nodes { parent: "properties_panel/property_vector3/field_z" template_node_child: true } +nodes { + type: TYPE_TEMPLATE + id: "properties_panel/property_button_small" + parent: "properties_panel/propeties" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_button_small/root" + parent: "properties_panel/property_button_small" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_button_small/text_name" + parent: "properties_panel/property_button_small/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_button_small/E_Anchor" + parent: "properties_panel/property_button_small/root" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_button_small/button" + parent: "properties_panel/property_button_small/E_Anchor" + template_node_child: true +} +nodes { + type: TYPE_BOX + id: "properties_panel/property_button_small/selected" + parent: "properties_panel/property_button_small/button" + template_node_child: true +} +nodes { + type: TYPE_TEXT + id: "properties_panel/property_button_small/text_button" + parent: "properties_panel/property_button_small/button" + template_node_child: true +} material: "/builtins/materials/gui.material" adjust_reference: ADJUST_REFERENCE_PARENT diff --git a/game.project b/game.project index e1be0a5..2a3093d 100644 --- a/game.project +++ b/game.project @@ -23,7 +23,7 @@ dependencies#1 = https://github.com/Insality/defold-saver/archive/refs/tags/5.zi dependencies#2 = https://github.com/Insality/defold-tweener/archive/refs/tags/3.zip dependencies#3 = https://github.com/Insality/panthera/archive/refs/tags/runtime.4.zip dependencies#4 = https://github.com/Insality/defold-lang/archive/refs/tags/3.zip -dependencies#5 = https://github.com/Insality/defold-event/archive/refs/tags/12.zip +dependencies#5 = https://github.com/Insality/defold-event/archive/refs/tags/13.zip dependencies#6 = https://github.com/subsoap/defos/archive/refs/tags/v2.8.0.zip [library] @@ -58,7 +58,7 @@ cssfile = /builtins/manifests/web/dark_theme.css show_console_banner = 0 [native_extension] -app_manifest = +app_manifest = [graphics] texture_profiles = /builtins/graphics/default.texture_profiles From 2a169da3afd8bb94eff10fe26eea830c9603f648 Mon Sep 17 00:00:00 2001 From: Insality Date: Mon, 27 Oct 2025 22:25:37 +0200 Subject: [PATCH 6/6] Add Druid logger --- druid/druid.lua | 22 ++++++++++++++++++++ druid/helper.lua | 38 ++++++++++++++++++++++++++-------- druid/system/druid_logger.lua | 39 +++++++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+), 9 deletions(-) create mode 100644 druid/system/druid_logger.lua diff --git a/druid/druid.lua b/druid/druid.lua index 1fcf995..3e9aba7 100644 --- a/druid/druid.lua +++ b/druid/druid.lua @@ -2,6 +2,7 @@ local event = require("event.event") local events = require("event.events") local settings = require("druid.system.settings") local druid_instance = require("druid.system.druid_instance") +local logger = require("druid.system.druid_logger") local default_style = require("druid.styles.default.style") @@ -193,4 +194,25 @@ function M.unregister_druid_as_widget() end +---@param logger_instance druid.logger|table|nil +function M.set_logger(logger_instance) + logger.set_logger(logger_instance) +end + + +---@param name string? +---@param level string|nil +---@return druid.logger +function M.get_logger(name, level) + if not name then + local current_script_path = debug.getinfo(3).short_src + local basename = string.match(current_script_path, "([^/\\]+)$") + basename = string.match(basename, "(.*)%..*$") + name = basename + end + + return setmetatable({ name = name, level = level }, { __index = logger }) +end + + return M diff --git a/druid/helper.lua b/druid/helper.lua index bb43d0c..4892a08 100644 --- a/druid/helper.lua +++ b/druid/helper.lua @@ -404,24 +404,44 @@ function M.is_multitouch_supported() end ----Simple table to one-line string converter +---Converts table to one-line string ---@param t table ----@return string -function M.table_to_string(t) - if not t then - return "" +---@param depth number? +---@param result string|nil Internal parameter +---@return string, boolean result String representation of table, Is max string length reached +function M.table_to_string(t, depth, result) + if type(t) ~= "table" then + return tostring(t) or "", false end - local result = "{" + depth = depth or 0 + result = result or "{" for key, value in pairs(t) do if #result > 1 then - result = result .. "," + result = result .. ", " + end + + if type(value) == "table" then + if depth == 0 then + local table_len = 0 + for _ in pairs(value) do + table_len = table_len + 1 + end + result = result .. key .. ": {... #" .. table_len .. "}" + else + local convert_result, is_limit = M.table_to_string(value, depth - 1, "") + result = result .. key .. ": {" .. convert_result + if is_limit then + break + end + end + else + result = result .. key .. ": " .. tostring(value) end - result = result .. key .. ": " .. value end - return result .. "}" + return result .. "}", false end diff --git a/druid/system/druid_logger.lua b/druid/system/druid_logger.lua new file mode 100644 index 0000000..74a0d46 --- /dev/null +++ b/druid/system/druid_logger.lua @@ -0,0 +1,39 @@ +local helper = require("druid.helper") + +---@class druid.logger +---@field trace fun(_, msg: string, data: any) +---@field debug fun(_, msg: string, data: any) +---@field info fun(_, msg: string, data: any) +---@field warn fun(_, msg: string, data: any) +---@field error fun(_, msg: string, data: any) +local M = {} + +local EMPTY_FUNCTION = function(_, message, context) end + +---@type druid.logger +local empty_logger = { + trace = EMPTY_FUNCTION, + debug = EMPTY_FUNCTION, + info = EMPTY_FUNCTION, + warn = EMPTY_FUNCTION, + error = EMPTY_FUNCTION, +} + +---@type druid.logger +local default_logger = { + trace = function(_, msg, data) print("TRACE: " .. msg, helper.table_to_string(data)) end, + debug = function(_, msg, data) print("DEBUG: " .. msg, helper.table_to_string(data)) end, + info = function(_, msg, data) print("INFO: " .. msg, helper.table_to_string(data)) end, + warn = function(_, msg, data) print("WARN: " .. msg, helper.table_to_string(data)) end, + error = function(_, msg, data) print("ERROR: " .. msg, helper.table_to_string(data)) end +} + +local METATABLE = { __index = default_logger } + +---@param logger druid.logger|table|nil +function M.set_logger(logger) + METATABLE.__index = logger or empty_logger +end + + +return setmetatable(M, METATABLE)