Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Insality committed Oct 16, 2024
1 parent 6e4490a commit aa6310d
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 47 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"it",
"utf8",
"defos",
"clipboard"
"clipboard",
"editor"
],
"Lua.workspace.checkThirdParty": false,
"Lua.diagnostics.neededFileStatus": {
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)_**.

Expand Down
4 changes: 1 addition & 3 deletions docs_md/02-creating_custom_components.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion docs_md/advanced-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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)
Expand Down Expand Up @@ -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
```


Expand Down
36 changes: 18 additions & 18 deletions docs_md/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
- 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
- [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.
- [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
2 changes: 2 additions & 0 deletions druid/base/button.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
28 changes: 16 additions & 12 deletions druid/base/hover.lua
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,15 @@ end
-- @tparam Hover self @{Hover}
-- @tparam boolean|nil state The hover state
function Hover.set_hover(self, state)
if self._is_hovered ~= state then
self._is_hovered = state
self.on_hover:trigger(self:get_context(), state, self)
if self._is_hovered == state then
return
end

if defos and self.style.ON_HOVER_CURSOR then
self:_set_cursor(3, state and self.style.ON_HOVER_CURSOR or nil)
end
self._is_hovered = state
self.on_hover:trigger(self:get_context(), state, self)

if defos and self.style.ON_HOVER_CURSOR then
self:_set_cursor(3, state and self.style.ON_HOVER_CURSOR or nil)
end
end

Expand All @@ -131,13 +133,15 @@ 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
self._is_mouse_hovered = state
self.on_mouse_hover:trigger(self:get_context(), state, self)
if self._is_mouse_hovered == state then
return
end

if defos and self.style.ON_MOUSE_HOVER_CURSOR then
self:_set_cursor(2, state and self.style.ON_MOUSE_HOVER_CURSOR or nil)
end
self._is_mouse_hovered = state
self.on_mouse_hover:trigger(self:get_context(), state, self)

if defos and self.style.ON_MOUSE_HOVER_CURSOR then
self:_set_cursor(2, state and self.style.ON_MOUSE_HOVER_CURSOR or nil)
end
end

Expand Down
2 changes: 1 addition & 1 deletion druid/component.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion druid/const.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion druid/custom/rich_input/rich_input.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions druid/custom/rich_text/rich_text.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion druid/editor_scripts/druid.editor_script
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ end
function M.get_commands()
return {
{
label = "Assign layers",
label = "Assign Layers",

locations = {"Edit"},

Expand Down
11 changes: 8 additions & 3 deletions druid/extended/layout.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion druid/styles/default/style.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit aa6310d

Please sign in to comment.