Update README

This commit is contained in:
Insality
2025-04-10 01:07:12 +03:00
parent 34be76777b
commit e2c9a7d9d6
4 changed files with 66 additions and 33 deletions

View File

@@ -586,26 +586,35 @@ Hello! Druid 1.1 is here! It's brings a lot of new features and improvements. Le
**Changelog 1.1**
- Remove external annotations, remove old HTML API page
- Fully annotated code and new API README page (hope more comfortable to use)
- Fully annotated code and new API README page
- Widgets here!
- A replacement for `custom_components`. Basically it's the same, but `widgets` contains no boilerplate code and more convinient to use.
- Now I can include a kind of `widgets` with Druid and you can use it almost instantly in your project.
- Removed `druid.register()`. Now all components are available by default and available with `self.druid:new_*` functions
- Deprecated `druid.register()`. Now all Druid's components are available by default and available with `self.druid:new_*` functions
- This means the Druid will be bigger in size, but it's much comfortable to use
- In case you want to delete components you not using, you can do it in fork in `druid.lua` file
- In case you want to delete components you are not using, you can do it in fork in `druid.lua` file
- Read [optimize_druid_size.md](optimize_druid_size.md) to learn how to reduce the size of the Druid library if you need
- Any additional widgets, color library will be not included until you use it
- Remove `druid.event`, replaced with `defold-event` library. Now it required to double dependency to use Druid.
- Add Druid UI kit, contains atlas so now you can use Druid GUI files in your projects.
- Remove `druid.event`, replaced with `defold-event` library. Now it required to two dependencies to use Druid.
- This allow to make more flexible features, like shaders and sync init between script and gui_script in various cases.
- Use 11+ version of `defold-event` library: `https://github.com/Insality/defold-event/archive/refs/tags/11.zip`
- Add Druid UI Kit, contains atlas so now you can use Druid GUI files in your projects.
- Contains mostly basic shapes for the UI and can contains several icons. Atlas is a small, only `128x128` size and will be included in build only if you use it.
- A long waited feature which allows try or just use some Druid GUI features almost instantly.
- [System]: Huge code refactoring and improvements. The goal is to raise maintainability and readability of the code to help people to contribute to the Druid.
- Add [CONTRIBUTING.md](/CONTRIBUTING.md) file with various information to help people to contribute to the Druid.
- All Druid Examples was migrated to use Widgets instead of Custom Components.
- [Text]: Add `trim_left` and `scale_then_trim_left` text adjust modes
- [Text]: Add `set_text` function instead `set_to` (now it deprecated)
- [Text]: Add `set_text` function instead `set_to` (the `set_to` now deprecated)
- Add `druid.color` module to work with colors and palettes
- Add `container` component to handle more complex adaptive layouts
- The container component is still in a development and I expected the various changes in the future
- [Shaders] Add repeat, hard image stencil and world gui materials
- [Widget] Add widget `mini_graph`
- [Widget] Add widget `memory_panel`
- [Widget] Add widget `fps_panel`
- [Widget] Add widget `properties_panel`
- A widget where you can add different properties to the panel to make easy edit/debug panels
- Include `property_button` widget
- Include `property_checkbox` widget
- Include `property_input` widget

View File

@@ -14,12 +14,20 @@ local component = require("druid.component")
---@class my_component: druid.component
local M = component.create("my_component")
function M:init(template, nodes, output_string)
function M:init(template, nodes)
self:set_template(template)
self:set_nodes(nodes)
self.druid = self:get_druid()
self.druid:new_button("button_node_name", print, output_string)
self.druid:new_button("button_node_name", self.on_click)
end
function M:on_click()
print("Current output string: " .. self.output_string)
end
function M:set_output_string(output_string)
self.output_string = output_string
end
```
@@ -29,7 +37,8 @@ Basic components are created with the `druid:new()` function:
local template = "my_component" -- The template name on GUI scene, if nil will take nodes directly by gui.get_node()
local nodes = gui.clone_tree(gui.get_node("my_component/root")) -- We can clone component nodes and init over cloned nodes
local my_component = druid:new("my_component", template, nodes, "Hello world!")
local my_component = druid:new("my_component", template, nodes)
my_component:set_output_string("Hello world!")
```
Now, let's see how to do it with widgets:
@@ -38,8 +47,17 @@ Now, let's see how to do it with widgets:
---@type my_widget: druid.widget
local M = {}
function M:init(output_string)
self.druid:new_button("button_node_name", print, output_string)
function M:init()
self.druid:new_button("button_node_name", self.on_click)
self.output_string = ""
end
function M:on_click()
print("Current output string: " .. self.output_string)
end
function M:set_output_string(output_string)
self.output_string = output_string
end
return M
@@ -55,7 +73,10 @@ local my_widget = require("widgets.my_widget.my_widget")
function init(self)
self.druid = druid.new(self)
self.my_widget = self.druid:new_widget(my_widget, template, nodes, "Hello world!")
local template_id = "my_widget" -- If using a GUI template, set a template id, otherwise set nil
local nodes = nil -- If nodes are cloned with gui.clone_tree(), set a nodes table, otherwise set nil
self.my_widget = self.druid:new_widget(my_widget, template_id, nodes)
self.my_widget:set_output_string("Hello world!")
end
```