This commit is contained in:
Insality 2024-10-16 20:30:55 +03:00
parent 6e4490a3a7
commit aa6310db91
14 changed files with 60 additions and 47 deletions

View File

@ -11,7 +11,8 @@
"it",
"utf8",
"defos",
"clipboard"
"clipboard",
"editor"
],
"Lua.workspace.checkThirdParty": false,
"Lua.diagnostics.neededFileStatus": {

View File

@ -148,7 +148,7 @@ druid.register("data_list", data_list)
| **[Slider](https://insality.github.io/druid/modules/Slider.html)** | Logic over GUI Node. Handle draggable node with position restrictions. | [Slider Example](https://insality.github.io/druid/druid/?example=general_sliders) | <img src="media/preview/slider.gif" width="200" height="100"> |
| **[Timer](https://insality.github.io/druid/modules/Timer.html)** | Logic over GUI Text. Handle basic timer functions. | ❌ | <img src="media/preview/timer.gif" width="200" height="100"> |
| **[Hotkey](https://insality.github.io/druid/modules/Hotkey.html)** | Allow to set callbacks for keyboard hotkeys with key modificators. | [Hotkey Example](https://insality.github.io/druid/druid/?example=general_hotkey) | <img src="media/preview/hotkey.gif" width="200" height="100"> |
| **[Layout](https://insality.github.io/druid/modules/Layout.html)** | Logic over GUI Node. Handle node size depends on layout mode and screen aspect ratio. Contains helpers to build more complex UI layout. | [Layout Example](https://insality.github.io/druid/druid/?example=general_layout) | <img src="media/preview/layout.gif" width="200" height="100"> |
| **[Layout](https://insality.github.io/druid/modules/Layout.html)** | Logic over GUI Node. Arrange nodes inside layout node with margin/paddings settings. | [Layout Example](https://insality.github.io/druid/druid/?example=general_layout) | <img src="media/preview/layout.gif" width="200" height="100"> |
For a complete overview, see: **_[components.md](docs_md/01-components.md)_**.

View File

@ -133,9 +133,7 @@ Available keywords:
- `blocker`: Adds a [Druid Blocker](01-components.md#blocker) component.
- `slider`: Adds a [Druid Slider](01-components.md#slider) component. You should adjust the end position of the Slider after generating the file.
- `progress`: Adds a [Druid Progress](01-components.md#progress) component.
- `timer`: Adds a [Dr
uid Timer](01-components.md#timer) component.
- `timer`: Adds a [Druid Timer](01-components.md#timer) component.
## The Power of Using Templates

View File

@ -3,7 +3,7 @@
## Input Bindings
By default, **Druid** utilizes the `/builtins/input/all.input_binding` for input bindings.
By default, **Druid** uses all key names from Defold's default `/builtins/input/all.input_binding` for input bindings.
**Druid** requires the following input bindings:
@ -18,6 +18,7 @@ By default, **Druid** utilizes the `/builtins/input/all.input_binding` for input
- Key trigger: `Right` -> `key_right` (for Rich Input component, optional)
- Key trigger: `Shift` -> `key_lshift` (for Rich Input component, optional)
- Key trigger: `Ctrl` -> `key_lctrl` (for Rich Input component, optional)
- Key trigger: `Super` -> `key_lsuper` (for Rich Input component, optional)
- Touch triggers: `Touch multi` -> `touch_multi` (for Scroll component)
![](../media/input_binding_2.png)
@ -45,6 +46,7 @@ input_key_left = key_left
input_key_right = key_right
input_key_lshift = key_lshift
input_key_lctrl = key_lctrl
input_key_lsuper = key_lsuper
```

View File

@ -506,22 +506,22 @@ Please support me if you like this project! It will help me keep engaged to upda
### Druid 0.12.0
**Changelog 0.12.0**
- Remove `middleclass.lua`
- The Rich Text now applied to the text node instead of Rich Text Template (contained 3 nodes before - root, text and image prefabs)
- New Logo!
- New Example Page with 40+ examples
- Updated and fixed annotations
- Add `self:get_druid(template, nodes)` to escape the `self:set_template(template)` and `self:set_nodes(nodes)` calls
- Update Rich Input. Now with selection and cursor navigation. Updated Input settings for Druid
- Rework Data List. Now only works with Static Grid only. Now the Data List more stable with extended API.
- [Example] New Example Page with 40+ examples
- [Data List] Rework Data List. Now only works with Static Grid only. Now the Data List more stable with extended API.
- Add Cached Data List option. This used less memory (it's really much optimized) but requires uses the `on_add_element` and `on_remove_element` events to setup your nodes. All components should be the same class.
- Now user can tap from one text input area to another with one click. Before first tap is closed the focus on selected input.
- Removed Layout component. Add new Layout component what do a some different things. It's like Dynamic Grid but with more control and settings.
- Deprecated Dynamic Grid. Layout will be instead of it.
- Add touch param to Drag callbacks, it's much easier to add custom logic with knowledge of input action data.
- Add `scroll.view_size`, `scroll:set_view_size(size)` and `scroll:update_view_size()` functions to manage with current scroll input area and scroll visible part
- Add `grid:set_item_size(size)`, `grid:sort_nodes(comparator)` functions
- Seems adjust by height for multiline text is workings good now
- Extended Rich Input API
- More accurate scaling for progress bars fow images with slice9 params
- Fix several slider issues
- [Rich Text] The Rich Text now applied to the text node instead of Rich Text Template (contained 3 nodes before - root, text and image prefabs)
- [Rich Input] Updated Rich Input. Now it goes with selection and cursor navigation. Added new input keys for setup in Druid (arrows keys, ctrl, shift)
- [System] Updated and fixed annotations
- [System] Removed `middleclass.lua`
- [System] Add `self:get_druid(template, nodes)` to escape the `self:set_template(template)` and `self:set_nodes(nodes)` calls in custom components
- [Input] Now user can tap from one text input area to another with one click. Before first tap is closed the focus on selected input.
- [Layout] Removed Layout component. Add new Layout component what do a some different things. It's like Dynamic Grid but with more control and settings.
- [Dynamic Grid] Deprecated Dynamic Grid. Layout will be instead of it.
- [Drag] Add touch param to Drag callbacks, it's much easier to add custom logic with knowledge of input action data.
- [Scroll] Add `scroll.view_size`, `scroll:set_view_size(size)` and `scroll:update_view_size()` functions to manage with current scroll input area and scroll visible part
- [Static Grid] Add `grid:set_item_size(size)`, `grid:sort_nodes(comparator)` functions
- [Text] Seems adjust by height for multiline text is workings good now
- [Rich Input] Extended Rich Input API
- [Progress Bar] More accurate scaling for progress bars fow images with slice9 params
- [Slider] Fix several slider issues in slider setup

View File

@ -418,6 +418,8 @@ end
function Button.on_input_interrupt(self)
self.can_action = false
self.hover:set_hover(false)
self.hover:set_mouse_hover(false)
end

View File

@ -108,7 +108,10 @@ end
-- @tparam Hover self @{Hover}
-- @tparam boolean|nil state The hover state
function Hover.set_hover(self, state)
if self._is_hovered ~= state then
if self._is_hovered == state then
return
end
self._is_hovered = state
self.on_hover:trigger(self:get_context(), state, self)
@ -116,7 +119,6 @@ function Hover.set_hover(self, state)
self:_set_cursor(3, state and self.style.ON_HOVER_CURSOR or nil)
end
end
end
--- Return current hover state. True if touch action was on the node at current time
@ -131,7 +133,10 @@ end
-- @tparam Hover self @{Hover}
-- @tparam boolean|nil state The mouse hover state
function Hover.set_mouse_hover(self, state)
if self._is_mouse_hovered ~= state then
if self._is_mouse_hovered == state then
return
end
self._is_mouse_hovered = state
self.on_mouse_hover:trigger(self:get_context(), state, self)
@ -139,7 +144,6 @@ function Hover.set_mouse_hover(self, state)
self:_set_cursor(2, state and self.style.ON_MOUSE_HOVER_CURSOR or nil)
end
end
end
--- Return current hover state. True if nil action_id (usually desktop mouse) was on the node at current time

View File

@ -24,7 +24,7 @@ local helper = require("druid.helper")
local BaseComponent = {}
local INTERESTS = {} -- Cache interests per component class in runtime
local IS_AUTO_TEMPLATE = not (sys.get_config_int("druid.no_auto_template", 0) == "1")
local IS_AUTO_TEMPLATE = not (sys.get_config_int("druid.no_auto_template", 0) == 1)
-- Component Interests
BaseComponent.ON_INPUT = const.ON_INPUT

View File

@ -21,8 +21,9 @@ M.ACTION_LEFT = hash(sys.get_config_string("druid.input_key_left", "key_left"))
M.ACTION_RIGHT = hash(sys.get_config_string("druid.input_key_right", "key_right"))
M.ACTION_LSHIFT = hash(sys.get_config_string("druid.input_key_lshift", "key_lshift"))
M.ACTION_LCTRL = hash(sys.get_config_string("druid.input_key_lctrl", "key_lctrl"))
M.ACTION_LCMD = hash(sys.get_config_string("druid.input_key_lsuper", "key_lsuper"))
M.IS_STENCIL_CHECK = not (sys.get_config_string("druid.no_stencil_check") == "1")
M.IS_STENCIL_CHECK = not (sys.get_config_int("druid.no_stencil_check", 0) == 1)
M.ON_INPUT = "on_input"

View File

@ -224,7 +224,7 @@ function RichInput.on_input(self, action_id, action)
end
end
if action_id == const.ACTION_LCTRL then
if action_id == const.ACTION_LCTRL or action_id == const.ACTION_LCMD then
if action.pressed then
self.is_lctrl = true
elseif action.released then

View File

@ -71,9 +71,6 @@
--- The text prefab node
-- @tfield node text_prefab
--- The icon prefab node
-- @tfield node icon_prefab
--
local component = require("druid.component")

View File

@ -26,7 +26,7 @@ end
function M.get_commands()
return {
{
label = "Assign layers",
label = "Assign Layers",
locations = {"Edit"},

View File

@ -207,15 +207,20 @@ function M.refresh_layout(self)
end
if type == "vertical" then
position_x = current_x + row.width * (0.5 - pivot_offset.x)
position_y = current_y - node_height * (0.5 + pivot_offset.y)
local node_margin = margin.y
if is_justify then
node_margin = (max_height - rows_data.total_height) / (#rows - 1) + margin.y
end
current_x = -row.width * (0.5 + layout_pivot_offset.x)
position_x = current_x + row.width * (0.5 + pivot_offset.x)
position_y = current_y - node_height * (0.5 - pivot_offset.y)
current_y = current_y - node_height - node_margin
row_index = row_index + 1
row = rows[row_index]
end
if type == "horizontal_wrap" then

View File

@ -36,7 +36,10 @@ M["button"] = {
on_click = function(self, node)
local scale_to = self.start_scale + M.button.SCALE_CHANGE
gui.set_scale(node, scale_to)
gui.animate(node, gui.PROP_SCALE, self.start_scale, gui.EASING_OUTBACK, 0.24)
local is_hover = self.hover:is_mouse_hovered()
local target_scale = is_hover and self.start_scale + M.button.HOVER_MOUSE_SCALE or self.start_scale
gui.animate(node, gui.PROP_SCALE, target_scale, gui.EASING_OUTBACK, 0.24)
settings.play_sound(M.button.BTN_SOUND)
end,