From 8155d649ab11e7576ea94735d7c32f08e9ce4fef Mon Sep 17 00:00:00 2001 From: Insality Date: Thu, 24 Apr 2025 23:46:39 +0300 Subject: [PATCH] Fix for drag end touch fro mobule, update contributing, update input examples to make better for mobile (move up) --- CONTRIBUTING | 127 ++++++++++++------ README.md | 2 +- druid/base/drag.lua | 9 +- example/examples/basic/input/basic_input.gui | 5 +- .../examples/basic/input/input_password.gui | 3 + example/examples/basic/input/rich_input.gui | 5 +- wiki/changelog.md | 5 + 7 files changed, 110 insertions(+), 46 deletions(-) diff --git a/CONTRIBUTING b/CONTRIBUTING index 8430af8..d3415e9 100644 --- a/CONTRIBUTING +++ b/CONTRIBUTING @@ -1,67 +1,116 @@ -# Contribution Guidelines +# Contributing to Druid -Hello, Defolder! Thanks for your interest in contributing to the **Druid** project. It's a massive project that has been around for a long time, and it's still growing. This project has a lot of places where you can help! +Thank you for your interest in contributing to **Druid**! We welcome contributions of all sizes - even small fixes make a big difference. -Finally, there are set of instructions that will help you to contribute to the project. +## Table of Contents +- [How to Report Issues](#how-to-report-issues) +- [Small Fixes](#small-fixes) +- [Larger Contributions](#larger-contributions) +- [Documentation Updates](#documentation-updates) +- [Adding or Updating Examples](#adding-or-updating-examples) +- [Unit Tests](#unit-tests) -Thanks for your help! +## How to Report Issues -## Issue Reporting +Found a bug? Please report it to our [issue tracker](https://github.com/druid-js/druid/issues) with: +- A clear description of the problem +- Steps to reproduce the issue +- Expected vs. actual behavior +- Your environment (Defold version, OS, etc.) -If you find any bugs, please report them to the [issue tracker](https://github.com/druid-js/druid/issues). +## Small Fixes -## Pull Requests +**We highly encourage small improvements!** For bug fixes, typo corrections, or minor improvements, you can create a pull request directly to the `master` or `develop` branch. -Any pull requests are welcome! +When making these contributions, you **must**: -Please, open PR against the `develop` branch. Very nice to have an issue, which this PR fixes. +1. Update the patch version number in both: + - `README.md` file (in the dependency section) + - `game.project` file (in the project section) +2. Add your changes to `wiki/changelog.md` +3. These steps are required to properly tag a new release -You fix should contains only changes, which are related to the issue. Also please keep the code style the same! +**Example of version updates:** -❤️ Thanks ❤️ +For README.md: +``` +# Before +https://github.com/Insality/druid/archive/refs/tags/1.1.0.zip -## Update Documentation +# After (patch version increased) +https://github.com/Insality/druid/archive/refs/tags/1.1.1.zip +``` -If you see any mistakes in the documentation, you can update it by yourself with the following steps: +For game.project: +``` +# Before +[project] +title = Druid +version = 1.1.0 -- Fork Druid repository -- Create a new branch for your changes -- Make your changes and commit them -- Push your changes to your fork -- Create a pull request to the Druid repository `develop` branch +# After (patch version increased) +[project] +title = Druid +version = 1.1.1 +``` +## Larger Contributions -## Add or Update Examples +For new features, major improvements, or complex fixes: -Examples contains a GUI scene, a Druid widget for this GUI. This GUI is included to the `examples.gui` and the information about examples are added in `examples_list.lua` file +1. Fork the repository +2. Create a branch from `develop` +3. Make your changes +4. Ensure code follows project style guidelines +5. Test your changes thoroughly +6. Submit a pull request to the `develop` branch +7. Include references to any related issues (e.g., "Fixes #123") -You can add new examples or update existing ones. +Please keep changes focused on addressing specific issues or features, and maintain the existing code style. -To add new example, you need to create a new folder in the `examples` directory. +## Documentation Updates -On your repo fork: +To improve documentation: -- Create a gui file with the example inside `/example/examples` directory -- Add the example info to the `examples_list.lua` file. -- Add this GUI template to the `/example/druid.gui` file - - GUI should be placed inside relative example parent, e.g. `root -> container_center -> examples -> widgets` -- Test the example by running the game -- Create a pull request to the `develop` branch +1. Fork the repository +2. Create a branch for your changes +3. Update the relevant documentation files +4. Submit a pull request to the `master` or `develop` branch +Clear, accurate documentation helps everyone, so documentation improvements are always appreciated! -## Add or Update Unit Tests +## Adding or Updating Examples -The unit tests was updated to cover more Druid's source code. So now I have more examples how to run and check some parts of the code. +Examples are vital for helping users understand how to use Druid. Each example should include: -In case you face issue and want to reproduce it, you also can starts from the unit tests: +1. A GUI scene with a Druid widget +2. Information about the example in `examples_list.lua` -All tests placed in the `/test/tests` directory. +To add a new example: -To run tests you need to set the bootstrap collection to `/test/test.collection` and run it. +1. Create a new GUI file in the `/example/examples` directory +2. Add the example information to `examples_list.lua` +3. Include your GUI template in `/example/druid.gui` + - Place it inside the proper hierarchy: `root -> container_center -> examples -> widgets` +4. Test your example by running the game +5. Submit a pull request to the `develop` branch -So the flow will be the similar: +## Unit Tests -- Create a new branch for your changes -- Make your changes and commit them -- Push your changes to your fork -- Create a pull request to the Druid repository `develop` branch +Unit tests help ensure Druid works correctly. If you're facing an issue, unit tests can be a good starting point to understand or reproduce it. + +All tests are located in the `/test/tests` directory. + +To run tests: +1. Set the bootstrap collection to `/test/test.collection` +2. Run the project + +To submit new or updated tests: +1. Create a branch for your changes +2. Add or modify tests +3. Verify your tests pass +4. Submit a pull request to the `develop` branch + +--- + +Thank you for contributing to making Druid better for everyone! ❤️ diff --git a/README.md b/README.md index 3bb00b7..5b97d56 100644 --- a/README.md +++ b/README.md @@ -223,7 +223,7 @@ Special thanks to all the contributors who have helped make **Druid** better! -Read the [CONTRIBUTING.md](CONTRIBUTING.md) file for more information. +Read the [CONTRIBUTING](CONTRIBUTING) file for more information. ## ❤️ Support project ❤️ diff --git a/druid/base/drag.lua b/druid/base/drag.lua index 65a3674..12dd51c 100644 --- a/druid/base/drag.lua +++ b/druid/base/drag.lua @@ -162,7 +162,7 @@ function M:on_input(action_id, action) if touch.released and self.is_touch then if action.touch then -- Mobile - self:_on_touch_release(action_id, action) + self:_on_touch_release(action_id, action, touch) else -- PC self:_end_touch(touch) @@ -321,7 +321,8 @@ end ---touches exists to switch to another touch. ---@param action_id hash Action id from on_input ---@param action table Action from on_input -function M:_on_touch_release(action_id, action) +---@param touch table Touch action +function M:_on_touch_release(action_id, action, touch) if #action.touch >= 2 then -- Find next unpressed touch local next_touch @@ -337,10 +338,10 @@ function M:_on_touch_release(action_id, action) self.y = next_touch.y self.touch_id = next_touch.id else - self:_end_touch() + self:_end_touch(touch) end elseif #action.touch == 1 then - self:_end_touch() + self:_end_touch(touch) end end diff --git a/example/examples/basic/input/basic_input.gui b/example/examples/basic/input/basic_input.gui index df53e44..cb3516d 100644 --- a/example/examples/basic/input/basic_input.gui +++ b/example/examples/basic/input/basic_input.gui @@ -9,6 +9,9 @@ nodes { visible: false } nodes { + position { + y: 301.0 + } type: TYPE_TEMPLATE id: "input" parent: "root" @@ -29,7 +32,7 @@ nodes { } nodes { position { - y: -150.0 + y: 151.0 } type: TYPE_TEMPLATE id: "input_2" diff --git a/example/examples/basic/input/input_password.gui b/example/examples/basic/input/input_password.gui index ade46cd..f2a0d84 100644 --- a/example/examples/basic/input/input_password.gui +++ b/example/examples/basic/input/input_password.gui @@ -9,6 +9,9 @@ nodes { visible: false } nodes { + position { + y: 249.0 + } type: TYPE_TEMPLATE id: "input" parent: "root" diff --git a/example/examples/basic/input/rich_input.gui b/example/examples/basic/input/rich_input.gui index 02a00eb..e5efcba 100644 --- a/example/examples/basic/input/rich_input.gui +++ b/example/examples/basic/input/rich_input.gui @@ -13,6 +13,9 @@ nodes { visible: false } nodes { + position { + y: 309.0 + } type: TYPE_TEMPLATE id: "rich_input" parent: "root" @@ -57,7 +60,7 @@ nodes { } nodes { position { - y: -150.0 + y: 159.0 } type: TYPE_TEMPLATE id: "rich_input_2" diff --git a/wiki/changelog.md b/wiki/changelog.md index 6abc3d4..66dc857 100644 --- a/wiki/changelog.md +++ b/wiki/changelog.md @@ -681,3 +681,8 @@ And all my other supporters! Very appreciated! Please support me if you like this project! It will help me keep engaged to update **Druid** and make it even better! [![Github-sponsors](https://img.shields.io/badge/sponsor-30363D?style=for-the-badge&logo=GitHub-Sponsors&logoColor=#EA4AAA)](https://github.com/sponsors/insality) [![Ko-Fi](https://img.shields.io/badge/Ko--fi-F16061?style=for-the-badge&logo=ko-fi&logoColor=white)](https://ko-fi.com/insality) [![BuyMeACoffee](https://img.shields.io/badge/Buy%20Me%20a%20Coffee-ffdd00?style=for-the-badge&logo=buy-me-a-coffee&logoColor=black)](https://www.buymeacoffee.com/insality) + + +### Druid 1.1.X + +- {Place for the community changelogs}