diff --git a/.vscode/settings.json b/.vscode/settings.json index fc31eb25..44850ee8 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -11,7 +11,8 @@ "it", "utf8", "defos", - "clipboard" + "clipboard", + "editor" ], "Lua.workspace.checkThirdParty": false, "Lua.diagnostics.neededFileStatus": { diff --git a/README.md b/README.md index 7ab2388f..760392e6 100644 --- a/README.md +++ b/README.md @@ -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) | | | **[Timer](https://insality.github.io/druid/modules/Timer.html)** | Logic over GUI Text. Handle basic timer functions. | ❌ | | | **[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) | | -| **[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) | | +| **[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) | | For a complete overview, see: **_[components.md](docs_md/01-components.md)_**. diff --git a/docs_md/02-creating_custom_components.md b/docs_md/02-creating_custom_components.md index b763f6f2..cf9c32cc 100644 --- a/docs_md/02-creating_custom_components.md +++ b/docs_md/02-creating_custom_components.md @@ -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 diff --git a/docs_md/advanced-setup.md b/docs_md/advanced-setup.md index b18369a4..5e047a7c 100644 --- a/docs_md/advanced-setup.md +++ b/docs_md/advanced-setup.md @@ -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 ``` diff --git a/docs_md/changelog.md b/docs_md/changelog.md index 3ef28906..f04f2843 100644 --- a/docs_md/changelog.md +++ b/docs_md/changelog.md @@ -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 diff --git a/druid/base/button.lua b/druid/base/button.lua index ada2a26f..9b09c489 100755 --- a/druid/base/button.lua +++ b/druid/base/button.lua @@ -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 diff --git a/druid/base/hover.lua b/druid/base/hover.lua index 97758c36..f178cf21 100644 --- a/druid/base/hover.lua +++ b/druid/base/hover.lua @@ -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 @@ -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 diff --git a/druid/component.lua b/druid/component.lua index d5bf7619..1bd76c98 100644 --- a/druid/component.lua +++ b/druid/component.lua @@ -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 diff --git a/druid/const.lua b/druid/const.lua index 6801e35b..70667dec 100755 --- a/druid/const.lua +++ b/druid/const.lua @@ -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" diff --git a/druid/custom/rich_input/rich_input.lua b/druid/custom/rich_input/rich_input.lua index 8e1a059c..a1c6987e 100644 --- a/druid/custom/rich_input/rich_input.lua +++ b/druid/custom/rich_input/rich_input.lua @@ -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 diff --git a/druid/custom/rich_text/rich_text.lua b/druid/custom/rich_text/rich_text.lua index b3d49734..81ac7ac4 100644 --- a/druid/custom/rich_text/rich_text.lua +++ b/druid/custom/rich_text/rich_text.lua @@ -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") diff --git a/druid/editor_scripts/druid.editor_script b/druid/editor_scripts/druid.editor_script index f72488a1..7903c003 100644 --- a/druid/editor_scripts/druid.editor_script +++ b/druid/editor_scripts/druid.editor_script @@ -26,7 +26,7 @@ end function M.get_commands() return { { - label = "Assign layers", + label = "Assign Layers", locations = {"Edit"}, diff --git a/druid/extended/layout.lua b/druid/extended/layout.lua index 7d2dc04c..2380d587 100644 --- a/druid/extended/layout.lua +++ b/druid/extended/layout.lua @@ -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 diff --git a/druid/styles/default/style.lua b/druid/styles/default/style.lua index 1a857b99..7477e213 100644 --- a/druid/styles/default/style.lua +++ b/druid/styles/default/style.lua @@ -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,