diff --git a/.github/branch-metadata.yml b/.github/branch-metadata.yml index 2d5ea3c5f09..1752567a98c 100644 --- a/.github/branch-metadata.yml +++ b/.github/branch-metadata.yml @@ -1,7 +1,13 @@ master: + api-level: API12 + labels: [ API12 ] + tizen-branch: tizen + version-prefix: 12.0.0 + +API11: api-level: API11 labels: [ API11 ] - tizen-branch: tizen + tizen-branch: tizen_8.0 version-prefix: 11.0.0 API10: diff --git a/.github/workflows/nightly-release.yml b/.github/workflows/nightly-release.yml index ce309c0b7f3..2bad9f9baac 100644 --- a/.github/workflows/nightly-release.yml +++ b/.github/workflows/nightly-release.yml @@ -7,7 +7,7 @@ on: workflow_dispatch: env: - TARGET_BRANCHES: 'master API10 API9' + TARGET_BRANCHES: 'master API11 API10' jobs: nightly: diff --git a/README.md b/README.md index cabe17afd2a..8c31a49867f 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,8 @@ TizenFX API, which allows you to access platform-specific features not covered b | Branch | API Level | Target Framework | API Reference | Platform | myget.org | nuget.org | |--------|:---------:|------------------|---------------|-------------------|-----------|------------| -|master | 11 | net6.0-tizen8.0 | [Link](https://samsung.github.io/TizenFX/master/) | Tizen 8.0 | [![api11_myget](https://img.shields.io/tizen.myget/dotnet/vpre/Tizen.NET.API11.svg)](https://tizen.myget.org/feed/dotnet/package/nuget/Tizen.NET) | | +|master | 12 | net6.0-tizen9.0 | [Link](https://samsung.github.io/TizenFX/master/) | Tizen vNext | [![api12_myget](https://img.shields.io/tizen.myget/dotnet/vpre/Tizen.NET.API12.svg)](https://tizen.myget.org/feed/dotnet/package/nuget/Tizen.NET) | | +|API11 | 11 | net6.0-tizen8.0 | [Link](https://samsung.github.io/TizenFX/API11/) | Tizen 8.0 | [![api11_myget](https://img.shields.io/tizen.myget/dotnet/vpre/Tizen.NET.API11.svg)](https://tizen.myget.org/feed/dotnet/package/nuget/Tizen.NET) | | |API10 | 10 | tizen10.0 | [Link](https://samsung.github.io/TizenFX/API10/) | Tizen 7.0 | [![api10_myget](https://img.shields.io/tizen.myget/dotnet/vpre/Tizen.NET.API10.svg)](https://tizen.myget.org/feed/dotnet/package/nuget/Tizen.NET) | [![api10_nuget](https://img.shields.io/nuget/v/Tizen.NET.API10.svg)](https://www.nuget.org/packages/Tizen.NET/) | |API9 | 9 | tizen90 | [Link](https://samsung.github.io/TizenFX/API9/) | Tizen 6.5 | [![api9_myget](https://img.shields.io/tizen.myget/dotnet/vpre/Tizen.NET.API9.svg)](https://tizen.myget.org/feed/dotnet/package/nuget/Tizen.NET) | [![api9_nuget](https://img.shields.io/nuget/v/Tizen.NET.API9.svg)](https://www.nuget.org/packages/Tizen.NET/) | |API8 | 8 | tizen80 | [Link](https://samsung.github.io/TizenFX/API8/) | Tizen 6.0 | [![api8_myget](https://img.shields.io/tizen.myget/dotnet/vpre/Tizen.NET.API8.svg)](https://tizen.myget.org/feed/dotnet/package/nuget/Tizen.NET) | [![api8_nuget](https://img.shields.io/nuget/v/Tizen.NET.API8.svg)](https://www.nuget.org/packages/Tizen.NET/) | @@ -19,7 +20,7 @@ TizenFX API, which allows you to access platform-specific features not covered b |API4 | 4 | tizen40 | [Link](https://samsung.github.io/TizenFX/API4/) | Tizen 4.0 | [![api4_myget](https://img.shields.io/tizen.myget/dotnet/vpre/Tizen.NET.API4.svg)](https://tizen.myget.org/feed/dotnet/package/nuget/Tizen.NET) | [![api4_nuget](https://img.shields.io/nuget/v/Tizen.NET.API4.svg)](https://www.nuget.org/packages/Tizen.NET/) | ### master -The __master__ branch is the main development branch for the Tizen .NET __API Level 11__. +The __master__ branch is the main development branch for the Tizen .NET __API Level 12__. The following NuGet packages will be published to [Tizen MyGet Gallery](https://tizen.myget.org/gallery/dotnet) and [Github Packages Registry](https://github.com/orgs/Samsung/packages?tab=packages&q=Tizen.NET) every day if there are any changes. (Nightly Build) @@ -27,18 +28,18 @@ The following NuGet packages will be published to [Tizen MyGet Gallery](https:// > - GitHub Packages Feed : ```https://nuget.pkg.github.com/Samsung/index.json``` > - GitHub Packages only supports authentication using a personal access token (classic). For more information, see [Working with the NuGet registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-nuget-registry) and [Managing your personal access tokens](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) -* Tizen.NET 11.0.0.##### -* Tizen.NET.API11 11.0.0.##### -* Tizen.NET.Internals 11.0.0.##### +* Tizen.NET 12.0.0.##### +* Tizen.NET.API12 12.0.0.##### +* Tizen.NET.Internals 12.0.0.##### And, This branch is pushed to the [tizen branch](https://git.tizen.org/cgit/platform/core/csapi/tizenfx/?h=tizen) in the tizen gerrit and submitted for the next Tizen platform. -### API4 ~ API10 branches +### API4 ~ API11 branches The __API#__ branches are the release branch for Tizen .NET __API Level #__. These release branches were __FROZEN__. No new public APIs can be added to these branches, only bug fixes and internal APIs can be added. -## Using `net6.0-tizen` target framework +## Using `net6.0-tizen` target framework for API11 or above If you want to use the `net6.0-tizen` target framework, you need to [install Tizen workload](https://github.com/Samsung/Tizen.NET/wiki/Installing-Tizen-.NET-Workload). ## Using `tizen` target framework @@ -55,6 +56,7 @@ For more information, please see [Using Tizen.NET.Sdk as SDK-style](https://deve ### Minimum required versions of Tizen.NET.Sdk and Visual Studio | API Level | Target Framework | Tizen.NET.Sdk | Visual Studio | |:---------:|------------------|---------------|-------------------| +| API12 | net6.0-tizen9.0 | [Tizen .NET Workloads](https://github.com/samsung/Tizen.NET) | 2022 | | API11 | net6.0-tizen8.0 | [Tizen .NET Workloads](https://github.com/samsung/Tizen.NET) | 2022 | | API10 | tizen10.0 | 1.1.9 | 2019 | | API9 | tizen90 | 1.1.7 | 2019 | @@ -92,4 +94,5 @@ You can download the latest binaries with TizenFX from the link below : | Tizen 6.0 | http://download.tizen.org/snapshots/TIZEN/Tizen-6.0/Tizen-6.0-Unified/latest/ | | Tizen 6.5 | http://download.tizen.org/snapshots/TIZEN/Tizen-6.5/Tizen-6.5-Unified/latest/ | | Tizen 7.0 | http://download.tizen.org/snapshots/TIZEN/Tizen-7.0/Tizen-7.0-Unified/latest/ | -| Tizen 8.0 | http://download.tizen.org/snapshots/TIZEN/Tizen/Tizen-Unified/ | +| Tizen 8.0 | http://download.tizen.org/snapshots/TIZEN/Tizen-8.0/Tizen-8.0-Unified/latest/ | +| Tizen 9.0 | http://download.tizen.org/snapshots/TIZEN/Tizen/Tizen-Unified/latest | diff --git a/packaging/500.tizenfx_upgrade.sh b/packaging/500.tizenfx_upgrade.sh index 6b175c5a080..77ce941ddc7 100644 --- a/packaging/500.tizenfx_upgrade.sh +++ b/packaging/500.tizenfx_upgrade.sh @@ -3,6 +3,6 @@ PATH=/bin:/usr/bin -vconftool set -f -t int db/dotnet/tizen_api_version 10 -vconftool set -f -t string db/dotnet/tizen_rid_version "4.0.0:5.0.0:5.5.0:6.0.0:6.5.0:7.0.0" -vconftool set -f -t string db/dotnet/tizen_tfm_support "tizen10.0:tizen90:tizen80:tizen70:tizen60:tizen50:tizen40" +vconftool set -f -t int db/dotnet/tizen_api_version 12 +vconftool set -f -t string db/dotnet/tizen_rid_version "4.0.0:5.0.0:5.5.0:6.0.0:6.5.0:7.0.0:8.0.0:9.0.0" +vconftool set -f -t string db/dotnet/tizen_tfm_support "net6.0-tizen9.0:net6.0-tizen8.0:tizen10.0:tizen90:tizen80:tizen70:tizen60:tizen50:tizen40" diff --git a/packaging/csapi-tizenfx.spec b/packaging/csapi-tizenfx.spec index 4843a3974b4..a8b1ebae132 100644 --- a/packaging/csapi-tizenfx.spec +++ b/packaging/csapi-tizenfx.spec @@ -1,8 +1,8 @@ # Auto-generated from csapi-tizenfx.spec.in by makespec.sh -%define TIZEN_NET_API_VERSION 11 -%define TIZEN_NET_RPM_VERSION 11.0.0.999+nui22243 -%define TIZEN_NET_NUGET_VERSION 11.0.0.99999 +%define TIZEN_NET_API_VERSION 12 +%define TIZEN_NET_RPM_VERSION 12.0.0.999+nui22249 +%define TIZEN_NET_NUGET_VERSION 12.0.0.99999 %define DOTNET_ASSEMBLY_PATH /usr/share/dotnet.tizen/framework %define DOTNET_ASSEMBLY_DUMMY_PATH %{DOTNET_ASSEMBLY_PATH}/ref @@ -11,8 +11,8 @@ %define DOTNET_PRELOAD_PATH /usr/share/dotnet.tizen/preload %define DOTNET_NUGET_SOURCE /nuget -%define TIZEN_NET_RUNTIME_IDENTIFIERS 4.0.0:5.0.0:5.5.0:6.0.0:6.5.0:7.0.0:8.0.0 -%define TIZEN_NET_TARGET_FRAMEWORK_MONIKERS tizen11.0:tizen10.0:tizen90:tizen80:tizen70:tizen60:tizen50:tizen40 +%define TIZEN_NET_RUNTIME_IDENTIFIERS 4.0.0:5.0.0:5.5.0:6.0.0:6.5.0:7.0.0:8.0.0:9.0.0 +%define TIZEN_NET_TARGET_FRAMEWORK_MONIKERS net6.0-tizen9.0:net6.0-tizen8.0:tizen11.0:tizen10.0:tizen90:tizen80:tizen70:tizen60:tizen50:tizen40 %define DOTNET_CORE_RUNTIME_VERSION 6.0 %define UPGRADE_SCRIPT_PATH /usr/share/upgrade/scripts diff --git a/packaging/version.txt b/packaging/version.txt index fb2e7134ab2..c75a1afc92a 100755 --- a/packaging/version.txt +++ b/packaging/version.txt @@ -1,9 +1,9 @@ # Tizen .NET API Level -API_VERSION=11 +API_VERSION=12 # Default Versions (will be replaced by CI) -RPM_VERSION=11.0.0.999 -NUGET_VERSION=11.0.0.99999 +RPM_VERSION=12.0.0.999 +NUGET_VERSION=12.0.0.99999 # RPM Version Suffix -RPM_VERSION_SUFFIX=nui22243 +RPM_VERSION_SUFFIX=nui22249 diff --git a/pkg/Tizen.NET.API10/xamlbuild/Tizen.NUI.XamlBuild.dll b/pkg/Tizen.NET.API10/xamlbuild/Tizen.NUI.XamlBuild.dll deleted file mode 100644 index 24c85252cbf..00000000000 Binary files a/pkg/Tizen.NET.API10/xamlbuild/Tizen.NUI.XamlBuild.dll and /dev/null differ diff --git a/pkg/Tizen.NET.API11/Tizen.NET.API11.nuspec b/pkg/Tizen.NET.API12/Tizen.NET.API12.nuspec old mode 100755 new mode 100644 similarity index 75% rename from pkg/Tizen.NET.API11/Tizen.NET.API11.nuspec rename to pkg/Tizen.NET.API12/Tizen.NET.API12.nuspec index 2de5308b9b2..20025ea1dc9 --- a/pkg/Tizen.NET.API11/Tizen.NET.API11.nuspec +++ b/pkg/Tizen.NET.API12/Tizen.NET.API12.nuspec @@ -1,7 +1,7 @@ - Tizen.NET.API11 + Tizen.NET.API12 $fxversion$ Samsung Electronics Samsung Electronics @@ -9,13 +9,13 @@ https://www.apache.org/licenses/LICENSE-2.0 https://www.tizen.org/ https://developer.tizen.org/sites/default/files/images/tizen-pinwheel-on-light-rgb_64_64.png - Reference assemblies of Tizen .NET API Level 11. + Reference assemblies of Tizen .NET API Level 12. © Samsung Electronics Co., Ltd All Rights Reserved - - - + + + diff --git a/pkg/Tizen.NET.API11/build/net6.0/Tizen.NET.API11.props b/pkg/Tizen.NET.API12/build/net6.0/Tizen.NET.API12.props similarity index 100% rename from pkg/Tizen.NET.API11/build/net6.0/Tizen.NET.API11.props rename to pkg/Tizen.NET.API12/build/net6.0/Tizen.NET.API12.props diff --git a/pkg/Tizen.NET.API11/build/net6.0/Tizen.NET.API11.targets b/pkg/Tizen.NET.API12/build/net6.0/Tizen.NET.API12.targets old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/net6.0/Tizen.NET.API11.targets rename to pkg/Tizen.NET.API12/build/net6.0/Tizen.NET.API12.targets diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/LICENSE.Microsoft.NETCore.App.Ref.txt b/pkg/Tizen.NET.API12/build/tizen11.0/LICENSE.Microsoft.NETCore.App.Ref.txt similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/LICENSE.Microsoft.NETCore.App.Ref.txt rename to pkg/Tizen.NET.API12/build/tizen11.0/LICENSE.Microsoft.NETCore.App.Ref.txt diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/PlatformManifest.txt b/pkg/Tizen.NET.API12/build/tizen11.0/PlatformManifest.txt similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/PlatformManifest.txt rename to pkg/Tizen.NET.API12/build/tizen11.0/PlatformManifest.txt diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/Tizen.NET.API11.props b/pkg/Tizen.NET.API12/build/tizen11.0/Tizen.NET.API12.props old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/Tizen.NET.API11.props rename to pkg/Tizen.NET.API12/build/tizen11.0/Tizen.NET.API12.props diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/Tizen.NET.API11.targets b/pkg/Tizen.NET.API12/build/tizen11.0/Tizen.NET.API12.targets old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/Tizen.NET.API11.targets rename to pkg/Tizen.NET.API12/build/tizen11.0/Tizen.NET.API12.targets diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/Microsoft.CSharp.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/Microsoft.CSharp.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/Microsoft.CSharp.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/Microsoft.CSharp.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/Microsoft.CSharp.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/Microsoft.CSharp.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/Microsoft.CSharp.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/Microsoft.CSharp.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/Microsoft.VisualBasic.Core.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/Microsoft.VisualBasic.Core.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/Microsoft.VisualBasic.Core.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/Microsoft.VisualBasic.Core.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/Microsoft.VisualBasic.Core.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/Microsoft.VisualBasic.Core.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/Microsoft.VisualBasic.Core.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/Microsoft.VisualBasic.Core.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/Microsoft.VisualBasic.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/Microsoft.VisualBasic.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/Microsoft.VisualBasic.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/Microsoft.VisualBasic.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/Microsoft.Win32.Primitives.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/Microsoft.Win32.Primitives.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/Microsoft.Win32.Primitives.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/Microsoft.Win32.Primitives.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/Microsoft.Win32.Primitives.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/Microsoft.Win32.Primitives.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/Microsoft.Win32.Primitives.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/Microsoft.Win32.Primitives.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/Microsoft.Win32.Registry.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/Microsoft.Win32.Registry.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/Microsoft.Win32.Registry.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/Microsoft.Win32.Registry.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/Microsoft.Win32.Registry.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/Microsoft.Win32.Registry.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/Microsoft.Win32.Registry.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/Microsoft.Win32.Registry.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.AppContext.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.AppContext.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.AppContext.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.AppContext.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Buffers.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Buffers.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Buffers.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Buffers.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Collections.Concurrent.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Collections.Concurrent.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Collections.Concurrent.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Collections.Concurrent.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Collections.Concurrent.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Collections.Concurrent.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Collections.Concurrent.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Collections.Concurrent.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Collections.Immutable.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Collections.Immutable.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Collections.Immutable.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Collections.Immutable.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Collections.Immutable.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Collections.Immutable.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Collections.Immutable.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Collections.Immutable.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Collections.NonGeneric.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Collections.NonGeneric.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Collections.NonGeneric.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Collections.NonGeneric.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Collections.NonGeneric.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Collections.NonGeneric.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Collections.NonGeneric.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Collections.NonGeneric.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Collections.Specialized.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Collections.Specialized.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Collections.Specialized.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Collections.Specialized.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Collections.Specialized.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Collections.Specialized.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Collections.Specialized.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Collections.Specialized.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Collections.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Collections.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Collections.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Collections.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Collections.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Collections.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Collections.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Collections.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.ComponentModel.Annotations.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.ComponentModel.Annotations.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.ComponentModel.Annotations.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.ComponentModel.Annotations.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.ComponentModel.Annotations.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.ComponentModel.Annotations.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.ComponentModel.Annotations.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.ComponentModel.Annotations.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.ComponentModel.DataAnnotations.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.ComponentModel.DataAnnotations.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.ComponentModel.DataAnnotations.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.ComponentModel.DataAnnotations.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.ComponentModel.EventBasedAsync.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.ComponentModel.EventBasedAsync.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.ComponentModel.EventBasedAsync.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.ComponentModel.EventBasedAsync.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.ComponentModel.EventBasedAsync.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.ComponentModel.EventBasedAsync.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.ComponentModel.EventBasedAsync.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.ComponentModel.EventBasedAsync.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.ComponentModel.Primitives.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.ComponentModel.Primitives.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.ComponentModel.Primitives.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.ComponentModel.Primitives.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.ComponentModel.Primitives.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.ComponentModel.Primitives.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.ComponentModel.Primitives.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.ComponentModel.Primitives.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.ComponentModel.TypeConverter.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.ComponentModel.TypeConverter.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.ComponentModel.TypeConverter.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.ComponentModel.TypeConverter.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.ComponentModel.TypeConverter.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.ComponentModel.TypeConverter.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.ComponentModel.TypeConverter.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.ComponentModel.TypeConverter.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.ComponentModel.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.ComponentModel.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.ComponentModel.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.ComponentModel.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.ComponentModel.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.ComponentModel.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.ComponentModel.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.ComponentModel.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Configuration.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Configuration.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Configuration.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Configuration.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Console.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Console.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Console.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Console.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Console.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Console.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Console.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Console.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Core.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Core.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Core.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Core.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Data.Common.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Data.Common.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Data.Common.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Data.Common.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Data.Common.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Data.Common.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Data.Common.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Data.Common.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Data.DataSetExtensions.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Data.DataSetExtensions.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Data.DataSetExtensions.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Data.DataSetExtensions.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Data.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Data.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Data.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Data.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Diagnostics.Contracts.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Diagnostics.Contracts.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Diagnostics.Contracts.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Diagnostics.Contracts.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Diagnostics.Contracts.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Diagnostics.Contracts.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Diagnostics.Contracts.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Diagnostics.Contracts.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Diagnostics.Debug.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Diagnostics.Debug.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Diagnostics.Debug.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Diagnostics.Debug.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Diagnostics.DiagnosticSource.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Diagnostics.DiagnosticSource.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Diagnostics.DiagnosticSource.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Diagnostics.DiagnosticSource.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Diagnostics.DiagnosticSource.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Diagnostics.DiagnosticSource.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Diagnostics.DiagnosticSource.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Diagnostics.DiagnosticSource.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Diagnostics.FileVersionInfo.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Diagnostics.FileVersionInfo.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Diagnostics.FileVersionInfo.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Diagnostics.FileVersionInfo.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Diagnostics.FileVersionInfo.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Diagnostics.FileVersionInfo.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Diagnostics.FileVersionInfo.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Diagnostics.FileVersionInfo.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Diagnostics.Process.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Diagnostics.Process.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Diagnostics.Process.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Diagnostics.Process.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Diagnostics.Process.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Diagnostics.Process.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Diagnostics.Process.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Diagnostics.Process.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Diagnostics.StackTrace.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Diagnostics.StackTrace.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Diagnostics.StackTrace.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Diagnostics.StackTrace.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Diagnostics.StackTrace.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Diagnostics.StackTrace.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Diagnostics.StackTrace.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Diagnostics.StackTrace.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Diagnostics.TextWriterTraceListener.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Diagnostics.TextWriterTraceListener.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Diagnostics.TextWriterTraceListener.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Diagnostics.TextWriterTraceListener.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Diagnostics.TextWriterTraceListener.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Diagnostics.TextWriterTraceListener.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Diagnostics.TextWriterTraceListener.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Diagnostics.TextWriterTraceListener.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Diagnostics.Tools.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Diagnostics.Tools.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Diagnostics.Tools.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Diagnostics.Tools.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Diagnostics.TraceSource.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Diagnostics.TraceSource.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Diagnostics.TraceSource.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Diagnostics.TraceSource.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Diagnostics.TraceSource.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Diagnostics.TraceSource.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Diagnostics.TraceSource.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Diagnostics.TraceSource.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Diagnostics.Tracing.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Diagnostics.Tracing.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Diagnostics.Tracing.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Diagnostics.Tracing.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Diagnostics.Tracing.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Diagnostics.Tracing.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Diagnostics.Tracing.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Diagnostics.Tracing.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Drawing.Primitives.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Drawing.Primitives.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Drawing.Primitives.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Drawing.Primitives.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Drawing.Primitives.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Drawing.Primitives.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Drawing.Primitives.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Drawing.Primitives.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Drawing.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Drawing.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Drawing.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Drawing.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Dynamic.Runtime.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Dynamic.Runtime.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Dynamic.Runtime.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Dynamic.Runtime.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Formats.Asn1.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Formats.Asn1.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Formats.Asn1.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Formats.Asn1.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Formats.Asn1.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Formats.Asn1.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Formats.Asn1.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Formats.Asn1.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Globalization.Calendars.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Globalization.Calendars.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Globalization.Calendars.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Globalization.Calendars.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Globalization.Extensions.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Globalization.Extensions.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Globalization.Extensions.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Globalization.Extensions.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Globalization.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Globalization.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Globalization.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Globalization.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.Compression.Brotli.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.Compression.Brotli.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.Compression.Brotli.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.Compression.Brotli.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.Compression.FileSystem.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.Compression.FileSystem.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.Compression.FileSystem.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.Compression.FileSystem.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.Compression.ZipFile.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.Compression.ZipFile.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.Compression.ZipFile.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.Compression.ZipFile.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.Compression.ZipFile.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.Compression.ZipFile.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.Compression.ZipFile.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.Compression.ZipFile.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.Compression.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.Compression.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.Compression.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.Compression.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.Compression.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.Compression.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.Compression.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.Compression.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.FileSystem.AccessControl.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.FileSystem.AccessControl.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.FileSystem.AccessControl.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.FileSystem.AccessControl.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.FileSystem.AccessControl.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.FileSystem.AccessControl.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.FileSystem.AccessControl.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.FileSystem.AccessControl.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.FileSystem.DriveInfo.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.FileSystem.DriveInfo.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.FileSystem.DriveInfo.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.FileSystem.DriveInfo.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.FileSystem.DriveInfo.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.FileSystem.DriveInfo.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.FileSystem.DriveInfo.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.FileSystem.DriveInfo.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.FileSystem.Primitives.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.FileSystem.Primitives.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.FileSystem.Primitives.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.FileSystem.Primitives.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.FileSystem.Watcher.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.FileSystem.Watcher.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.FileSystem.Watcher.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.FileSystem.Watcher.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.FileSystem.Watcher.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.FileSystem.Watcher.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.FileSystem.Watcher.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.FileSystem.Watcher.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.FileSystem.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.FileSystem.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.FileSystem.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.FileSystem.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.IsolatedStorage.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.IsolatedStorage.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.IsolatedStorage.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.IsolatedStorage.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.IsolatedStorage.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.IsolatedStorage.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.IsolatedStorage.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.IsolatedStorage.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.MemoryMappedFiles.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.MemoryMappedFiles.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.MemoryMappedFiles.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.MemoryMappedFiles.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.MemoryMappedFiles.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.MemoryMappedFiles.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.MemoryMappedFiles.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.MemoryMappedFiles.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.Pipes.AccessControl.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.Pipes.AccessControl.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.Pipes.AccessControl.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.Pipes.AccessControl.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.Pipes.AccessControl.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.Pipes.AccessControl.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.Pipes.AccessControl.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.Pipes.AccessControl.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.Pipes.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.Pipes.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.Pipes.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.Pipes.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.Pipes.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.Pipes.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.Pipes.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.Pipes.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.UnmanagedMemoryStream.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.UnmanagedMemoryStream.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.UnmanagedMemoryStream.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.UnmanagedMemoryStream.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.IO.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.IO.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Linq.Expressions.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Linq.Expressions.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Linq.Expressions.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Linq.Expressions.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Linq.Expressions.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Linq.Expressions.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Linq.Expressions.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Linq.Expressions.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Linq.Parallel.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Linq.Parallel.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Linq.Parallel.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Linq.Parallel.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Linq.Parallel.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Linq.Parallel.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Linq.Parallel.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Linq.Parallel.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Linq.Queryable.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Linq.Queryable.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Linq.Queryable.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Linq.Queryable.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Linq.Queryable.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Linq.Queryable.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Linq.Queryable.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Linq.Queryable.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Linq.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Linq.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Linq.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Linq.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Linq.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Linq.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Linq.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Linq.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Memory.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Memory.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Memory.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Memory.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Memory.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Memory.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Memory.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Memory.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.Http.Json.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.Http.Json.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.Http.Json.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.Http.Json.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.Http.Json.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.Http.Json.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.Http.Json.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.Http.Json.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.Http.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.Http.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.Http.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.Http.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.Http.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.Http.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.Http.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.Http.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.HttpListener.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.HttpListener.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.HttpListener.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.HttpListener.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.HttpListener.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.HttpListener.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.HttpListener.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.HttpListener.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.Mail.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.Mail.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.Mail.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.Mail.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.Mail.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.Mail.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.Mail.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.Mail.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.NameResolution.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.NameResolution.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.NameResolution.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.NameResolution.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.NameResolution.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.NameResolution.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.NameResolution.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.NameResolution.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.NetworkInformation.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.NetworkInformation.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.NetworkInformation.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.NetworkInformation.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.NetworkInformation.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.NetworkInformation.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.NetworkInformation.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.NetworkInformation.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.Ping.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.Ping.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.Ping.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.Ping.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.Ping.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.Ping.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.Ping.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.Ping.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.Primitives.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.Primitives.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.Primitives.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.Primitives.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.Primitives.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.Primitives.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.Primitives.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.Primitives.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.Requests.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.Requests.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.Requests.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.Requests.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.Requests.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.Requests.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.Requests.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.Requests.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.Security.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.Security.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.Security.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.Security.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.Security.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.Security.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.Security.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.Security.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.ServicePoint.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.ServicePoint.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.ServicePoint.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.ServicePoint.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.ServicePoint.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.ServicePoint.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.ServicePoint.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.ServicePoint.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.Sockets.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.Sockets.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.Sockets.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.Sockets.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.Sockets.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.Sockets.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.Sockets.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.Sockets.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.WebClient.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.WebClient.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.WebClient.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.WebClient.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.WebClient.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.WebClient.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.WebClient.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.WebClient.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.WebHeaderCollection.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.WebHeaderCollection.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.WebHeaderCollection.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.WebHeaderCollection.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.WebHeaderCollection.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.WebHeaderCollection.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.WebHeaderCollection.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.WebHeaderCollection.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.WebProxy.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.WebProxy.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.WebProxy.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.WebProxy.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.WebProxy.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.WebProxy.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.WebProxy.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.WebProxy.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.WebSockets.Client.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.WebSockets.Client.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.WebSockets.Client.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.WebSockets.Client.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.WebSockets.Client.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.WebSockets.Client.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.WebSockets.Client.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.WebSockets.Client.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.WebSockets.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.WebSockets.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.WebSockets.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.WebSockets.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.WebSockets.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.WebSockets.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.WebSockets.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.WebSockets.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Net.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Net.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Numerics.Vectors.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Numerics.Vectors.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Numerics.Vectors.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Numerics.Vectors.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Numerics.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Numerics.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Numerics.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Numerics.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.ObjectModel.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.ObjectModel.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.ObjectModel.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.ObjectModel.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.ObjectModel.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.ObjectModel.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.ObjectModel.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.ObjectModel.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Reflection.DispatchProxy.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Reflection.DispatchProxy.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Reflection.DispatchProxy.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Reflection.DispatchProxy.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Reflection.DispatchProxy.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Reflection.DispatchProxy.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Reflection.DispatchProxy.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Reflection.DispatchProxy.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Reflection.Emit.ILGeneration.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Reflection.Emit.ILGeneration.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Reflection.Emit.ILGeneration.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Reflection.Emit.ILGeneration.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Reflection.Emit.ILGeneration.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Reflection.Emit.ILGeneration.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Reflection.Emit.ILGeneration.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Reflection.Emit.ILGeneration.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Reflection.Emit.Lightweight.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Reflection.Emit.Lightweight.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Reflection.Emit.Lightweight.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Reflection.Emit.Lightweight.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Reflection.Emit.Lightweight.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Reflection.Emit.Lightweight.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Reflection.Emit.Lightweight.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Reflection.Emit.Lightweight.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Reflection.Emit.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Reflection.Emit.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Reflection.Emit.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Reflection.Emit.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Reflection.Emit.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Reflection.Emit.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Reflection.Emit.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Reflection.Emit.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Reflection.Extensions.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Reflection.Extensions.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Reflection.Extensions.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Reflection.Extensions.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Reflection.Metadata.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Reflection.Metadata.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Reflection.Metadata.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Reflection.Metadata.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Reflection.Metadata.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Reflection.Metadata.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Reflection.Metadata.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Reflection.Metadata.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Reflection.Primitives.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Reflection.Primitives.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Reflection.Primitives.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Reflection.Primitives.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Reflection.Primitives.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Reflection.Primitives.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Reflection.Primitives.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Reflection.Primitives.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Reflection.TypeExtensions.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Reflection.TypeExtensions.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Reflection.TypeExtensions.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Reflection.TypeExtensions.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Reflection.TypeExtensions.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Reflection.TypeExtensions.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Reflection.TypeExtensions.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Reflection.TypeExtensions.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Reflection.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Reflection.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Reflection.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Reflection.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Resources.Reader.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Resources.Reader.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Resources.Reader.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Resources.Reader.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Resources.ResourceManager.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Resources.ResourceManager.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Resources.ResourceManager.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Resources.ResourceManager.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Resources.Writer.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Resources.Writer.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Resources.Writer.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Resources.Writer.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Resources.Writer.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Resources.Writer.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Resources.Writer.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Resources.Writer.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.CompilerServices.Unsafe.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.CompilerServices.Unsafe.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.CompilerServices.Unsafe.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.CompilerServices.Unsafe.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.CompilerServices.Unsafe.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.CompilerServices.Unsafe.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.CompilerServices.Unsafe.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.CompilerServices.Unsafe.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.CompilerServices.VisualC.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.CompilerServices.VisualC.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.CompilerServices.VisualC.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.CompilerServices.VisualC.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.CompilerServices.VisualC.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.CompilerServices.VisualC.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.CompilerServices.VisualC.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.CompilerServices.VisualC.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.Extensions.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.Extensions.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.Extensions.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.Extensions.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.Handles.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.Handles.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.Handles.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.Handles.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.InteropServices.RuntimeInformation.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.InteropServices.RuntimeInformation.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.InteropServices.RuntimeInformation.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.InteropServices.RuntimeInformation.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.InteropServices.RuntimeInformation.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.InteropServices.RuntimeInformation.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.InteropServices.RuntimeInformation.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.InteropServices.RuntimeInformation.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.InteropServices.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.InteropServices.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.InteropServices.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.InteropServices.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.InteropServices.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.InteropServices.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.InteropServices.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.InteropServices.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.Intrinsics.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.Intrinsics.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.Intrinsics.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.Intrinsics.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.Intrinsics.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.Intrinsics.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.Intrinsics.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.Intrinsics.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.Loader.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.Loader.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.Loader.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.Loader.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.Loader.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.Loader.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.Loader.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.Loader.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.Numerics.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.Numerics.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.Numerics.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.Numerics.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.Numerics.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.Numerics.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.Numerics.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.Numerics.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.Serialization.Formatters.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.Serialization.Formatters.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.Serialization.Formatters.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.Serialization.Formatters.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.Serialization.Formatters.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.Serialization.Formatters.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.Serialization.Formatters.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.Serialization.Formatters.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.Serialization.Json.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.Serialization.Json.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.Serialization.Json.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.Serialization.Json.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.Serialization.Json.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.Serialization.Json.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.Serialization.Json.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.Serialization.Json.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.Serialization.Primitives.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.Serialization.Primitives.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.Serialization.Primitives.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.Serialization.Primitives.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.Serialization.Primitives.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.Serialization.Primitives.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.Serialization.Primitives.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.Serialization.Primitives.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.Serialization.Xml.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.Serialization.Xml.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.Serialization.Xml.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.Serialization.Xml.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.Serialization.Xml.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.Serialization.Xml.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.Serialization.Xml.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.Serialization.Xml.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.Serialization.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.Serialization.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.Serialization.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.Serialization.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Runtime.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Runtime.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.AccessControl.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.AccessControl.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.AccessControl.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.AccessControl.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.AccessControl.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.AccessControl.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.AccessControl.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.AccessControl.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.Claims.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.Claims.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.Claims.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.Claims.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.Claims.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.Claims.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.Claims.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.Claims.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.Cryptography.Algorithms.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.Cryptography.Algorithms.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.Cryptography.Algorithms.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.Cryptography.Algorithms.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.Cryptography.Algorithms.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.Cryptography.Algorithms.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.Cryptography.Algorithms.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.Cryptography.Algorithms.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.Cryptography.Cng.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.Cryptography.Cng.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.Cryptography.Cng.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.Cryptography.Cng.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.Cryptography.Cng.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.Cryptography.Cng.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.Cryptography.Cng.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.Cryptography.Cng.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.Cryptography.Csp.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.Cryptography.Csp.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.Cryptography.Csp.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.Cryptography.Csp.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.Cryptography.Csp.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.Cryptography.Csp.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.Cryptography.Csp.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.Cryptography.Csp.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.Cryptography.Encoding.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.Cryptography.Encoding.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.Cryptography.Encoding.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.Cryptography.Encoding.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.Cryptography.Encoding.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.Cryptography.Encoding.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.Cryptography.Encoding.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.Cryptography.Encoding.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.Cryptography.OpenSsl.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.Cryptography.OpenSsl.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.Cryptography.OpenSsl.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.Cryptography.OpenSsl.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.Cryptography.OpenSsl.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.Cryptography.OpenSsl.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.Cryptography.OpenSsl.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.Cryptography.OpenSsl.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.Cryptography.Primitives.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.Cryptography.Primitives.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.Cryptography.Primitives.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.Cryptography.Primitives.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.Cryptography.Primitives.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.Cryptography.Primitives.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.Cryptography.Primitives.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.Cryptography.Primitives.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.Cryptography.X509Certificates.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.Cryptography.X509Certificates.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.Cryptography.X509Certificates.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.Cryptography.X509Certificates.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.Cryptography.X509Certificates.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.Cryptography.X509Certificates.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.Cryptography.X509Certificates.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.Cryptography.X509Certificates.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.Principal.Windows.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.Principal.Windows.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.Principal.Windows.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.Principal.Windows.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.Principal.Windows.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.Principal.Windows.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.Principal.Windows.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.Principal.Windows.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.Principal.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.Principal.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.Principal.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.Principal.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.SecureString.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.SecureString.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.SecureString.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.SecureString.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Security.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Security.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.ServiceModel.Web.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.ServiceModel.Web.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.ServiceModel.Web.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.ServiceModel.Web.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.ServiceProcess.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.ServiceProcess.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.ServiceProcess.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.ServiceProcess.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Text.Encoding.CodePages.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Text.Encoding.CodePages.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Text.Encoding.CodePages.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Text.Encoding.CodePages.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Text.Encoding.CodePages.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Text.Encoding.CodePages.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Text.Encoding.CodePages.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Text.Encoding.CodePages.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Text.Encoding.Extensions.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Text.Encoding.Extensions.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Text.Encoding.Extensions.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Text.Encoding.Extensions.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Text.Encoding.Extensions.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Text.Encoding.Extensions.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Text.Encoding.Extensions.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Text.Encoding.Extensions.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Text.Encoding.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Text.Encoding.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Text.Encoding.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Text.Encoding.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Text.Encodings.Web.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Text.Encodings.Web.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Text.Encodings.Web.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Text.Encodings.Web.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Text.Encodings.Web.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Text.Encodings.Web.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Text.Encodings.Web.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Text.Encodings.Web.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Text.Json.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Text.Json.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Text.Json.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Text.Json.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Text.Json.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Text.Json.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Text.Json.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Text.Json.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Text.RegularExpressions.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Text.RegularExpressions.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Text.RegularExpressions.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Text.RegularExpressions.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Text.RegularExpressions.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Text.RegularExpressions.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Text.RegularExpressions.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Text.RegularExpressions.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Threading.Channels.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Threading.Channels.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Threading.Channels.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Threading.Channels.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Threading.Channels.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Threading.Channels.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Threading.Channels.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Threading.Channels.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Threading.Overlapped.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Threading.Overlapped.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Threading.Overlapped.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Threading.Overlapped.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Threading.Overlapped.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Threading.Overlapped.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Threading.Overlapped.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Threading.Overlapped.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Threading.Tasks.Dataflow.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Threading.Tasks.Dataflow.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Threading.Tasks.Dataflow.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Threading.Tasks.Dataflow.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Threading.Tasks.Dataflow.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Threading.Tasks.Dataflow.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Threading.Tasks.Dataflow.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Threading.Tasks.Dataflow.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Threading.Tasks.Extensions.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Threading.Tasks.Extensions.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Threading.Tasks.Extensions.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Threading.Tasks.Extensions.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Threading.Tasks.Parallel.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Threading.Tasks.Parallel.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Threading.Tasks.Parallel.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Threading.Tasks.Parallel.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Threading.Tasks.Parallel.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Threading.Tasks.Parallel.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Threading.Tasks.Parallel.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Threading.Tasks.Parallel.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Threading.Tasks.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Threading.Tasks.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Threading.Tasks.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Threading.Tasks.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Threading.Thread.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Threading.Thread.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Threading.Thread.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Threading.Thread.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Threading.Thread.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Threading.Thread.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Threading.Thread.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Threading.Thread.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Threading.ThreadPool.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Threading.ThreadPool.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Threading.ThreadPool.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Threading.ThreadPool.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Threading.ThreadPool.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Threading.ThreadPool.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Threading.ThreadPool.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Threading.ThreadPool.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Threading.Timer.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Threading.Timer.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Threading.Timer.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Threading.Timer.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Threading.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Threading.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Threading.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Threading.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Threading.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Threading.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Threading.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Threading.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Transactions.Local.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Transactions.Local.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Transactions.Local.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Transactions.Local.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Transactions.Local.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Transactions.Local.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Transactions.Local.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Transactions.Local.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Transactions.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Transactions.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Transactions.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Transactions.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.ValueTuple.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.ValueTuple.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.ValueTuple.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.ValueTuple.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Web.HttpUtility.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Web.HttpUtility.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Web.HttpUtility.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Web.HttpUtility.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Web.HttpUtility.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Web.HttpUtility.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Web.HttpUtility.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Web.HttpUtility.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Web.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Web.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Web.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Web.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Windows.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Windows.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Windows.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Windows.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Xml.Linq.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Xml.Linq.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Xml.Linq.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Xml.Linq.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Xml.ReaderWriter.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Xml.ReaderWriter.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Xml.ReaderWriter.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Xml.ReaderWriter.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Xml.ReaderWriter.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Xml.ReaderWriter.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Xml.ReaderWriter.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Xml.ReaderWriter.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Xml.Serialization.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Xml.Serialization.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Xml.Serialization.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Xml.Serialization.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Xml.XDocument.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Xml.XDocument.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Xml.XDocument.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Xml.XDocument.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Xml.XDocument.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Xml.XDocument.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Xml.XDocument.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Xml.XDocument.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Xml.XPath.XDocument.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Xml.XPath.XDocument.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Xml.XPath.XDocument.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Xml.XPath.XDocument.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Xml.XPath.XDocument.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Xml.XPath.XDocument.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Xml.XPath.XDocument.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Xml.XPath.XDocument.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Xml.XPath.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Xml.XPath.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Xml.XPath.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Xml.XPath.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Xml.XPath.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Xml.XPath.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Xml.XPath.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Xml.XPath.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Xml.XmlDocument.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Xml.XmlDocument.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Xml.XmlDocument.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Xml.XmlDocument.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Xml.XmlSerializer.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Xml.XmlSerializer.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Xml.XmlSerializer.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Xml.XmlSerializer.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Xml.XmlSerializer.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Xml.XmlSerializer.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Xml.XmlSerializer.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Xml.XmlSerializer.xml diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Xml.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Xml.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.Xml.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.Xml.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/System.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/System.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/System.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/System.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/WindowsBase.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/WindowsBase.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/WindowsBase.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/WindowsBase.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/mscorlib.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/mscorlib.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/mscorlib.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/mscorlib.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/netstandard.dll b/pkg/Tizen.NET.API12/build/tizen11.0/ref/netstandard.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/netstandard.dll rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/netstandard.dll diff --git a/pkg/Tizen.NET.API11/build/tizen11.0/ref/netstandard.xml b/pkg/Tizen.NET.API12/build/tizen11.0/ref/netstandard.xml old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/build/tizen11.0/ref/netstandard.xml rename to pkg/Tizen.NET.API12/build/tizen11.0/ref/netstandard.xml diff --git a/pkg/Tizen.NET.API11/design/Tizen.NUI.Components.Design.dll b/pkg/Tizen.NET.API12/design/Tizen.NUI.Components.Design.dll similarity index 100% rename from pkg/Tizen.NET.API11/design/Tizen.NUI.Components.Design.dll rename to pkg/Tizen.NET.API12/design/Tizen.NUI.Components.Design.dll diff --git a/pkg/Tizen.NET.API11/design/Tizen.NUI.Design.dll b/pkg/Tizen.NET.API12/design/Tizen.NUI.Design.dll similarity index 100% rename from pkg/Tizen.NET.API11/design/Tizen.NUI.Design.dll rename to pkg/Tizen.NET.API12/design/Tizen.NUI.Design.dll diff --git a/pkg/Tizen.NET.API11/xamlbuild/Mono.Cecil.Mdb.dll b/pkg/Tizen.NET.API12/xamlbuild/Mono.Cecil.Mdb.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/xamlbuild/Mono.Cecil.Mdb.dll rename to pkg/Tizen.NET.API12/xamlbuild/Mono.Cecil.Mdb.dll diff --git a/pkg/Tizen.NET.API11/xamlbuild/Mono.Cecil.Pdb.dll b/pkg/Tizen.NET.API12/xamlbuild/Mono.Cecil.Pdb.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/xamlbuild/Mono.Cecil.Pdb.dll rename to pkg/Tizen.NET.API12/xamlbuild/Mono.Cecil.Pdb.dll diff --git a/pkg/Tizen.NET.API11/xamlbuild/Mono.Cecil.Rocks.dll b/pkg/Tizen.NET.API12/xamlbuild/Mono.Cecil.Rocks.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/xamlbuild/Mono.Cecil.Rocks.dll rename to pkg/Tizen.NET.API12/xamlbuild/Mono.Cecil.Rocks.dll diff --git a/pkg/Tizen.NET.API11/xamlbuild/Mono.Cecil.dll b/pkg/Tizen.NET.API12/xamlbuild/Mono.Cecil.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/xamlbuild/Mono.Cecil.dll rename to pkg/Tizen.NET.API12/xamlbuild/Mono.Cecil.dll diff --git a/pkg/Tizen.NET.API11/xamlbuild/System.CodeDom.dll b/pkg/Tizen.NET.API12/xamlbuild/System.CodeDom.dll old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/xamlbuild/System.CodeDom.dll rename to pkg/Tizen.NET.API12/xamlbuild/System.CodeDom.dll diff --git a/pkg/Tizen.NET.API11/xamlbuild/Tizen.NUI.XamlBuild.dll b/pkg/Tizen.NET.API12/xamlbuild/Tizen.NUI.XamlBuild.dll similarity index 100% rename from pkg/Tizen.NET.API11/xamlbuild/Tizen.NUI.XamlBuild.dll rename to pkg/Tizen.NET.API12/xamlbuild/Tizen.NUI.XamlBuild.dll diff --git a/pkg/Tizen.NET.API11/xamlbuild/Tizen.NUI.XamlBuild.props b/pkg/Tizen.NET.API12/xamlbuild/Tizen.NUI.XamlBuild.props old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/xamlbuild/Tizen.NUI.XamlBuild.props rename to pkg/Tizen.NET.API12/xamlbuild/Tizen.NUI.XamlBuild.props diff --git a/pkg/Tizen.NET.API11/xamlbuild/Tizen.NUI.XamlBuild.targets b/pkg/Tizen.NET.API12/xamlbuild/Tizen.NUI.XamlBuild.targets old mode 100755 new mode 100644 similarity index 100% rename from pkg/Tizen.NET.API11/xamlbuild/Tizen.NUI.XamlBuild.targets rename to pkg/Tizen.NET.API12/xamlbuild/Tizen.NUI.XamlBuild.targets diff --git a/pkg/Tizen.NET/Tizen.NET.nuspec b/pkg/Tizen.NET/Tizen.NET.nuspec index 08687b19366..d4f6274cb33 100644 --- a/pkg/Tizen.NET/Tizen.NET.nuspec +++ b/pkg/Tizen.NET/Tizen.NET.nuspec @@ -49,7 +49,11 @@ - + + + + + diff --git a/src/Tizen.Applications.Common/Interop/Interop.Libc.cs b/src/Tizen.Applications.Common/Interop/Interop.Libc.cs index 81aacdd73c9..09c256e7db9 100644 --- a/src/Tizen.Applications.Common/Interop/Interop.Libc.cs +++ b/src/Tizen.Applications.Common/Interop/Interop.Libc.cs @@ -23,9 +23,6 @@ internal static partial class Interop { internal static partial class Libc { - [DllImport(Libraries.Libc, EntryPoint = "free", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Free(IntPtr ptr); - [DllImport(Libraries.Libc, EntryPoint = "getenv")] internal static extern IntPtr GetEnvironmentVariable(string name); diff --git a/src/Tizen.Applications.Common/Tizen.Applications/AppControl.cs b/src/Tizen.Applications.Common/Tizen.Applications/AppControl.cs index 3bd02e21ef6..60c213fb4d7 100755 --- a/src/Tizen.Applications.Common/Tizen.Applications/AppControl.cs +++ b/src/Tizen.Applications.Common/Tizen.Applications/AppControl.cs @@ -1335,9 +1335,9 @@ public bool TryGet(string key, out IEnumerable value) { IntPtr charArr = Marshal.ReadIntPtr(valuePtr, IntPtr.Size * i); stringList.Add(Marshal.PtrToStringAnsi(charArr)); - _ = Interop.Libc.Free(charArr); + Marshal.FreeHGlobal(charArr); } - _ = Interop.Libc.Free(valuePtr); + Marshal.FreeHGlobal(valuePtr); value = stringList; return true; } @@ -1491,9 +1491,9 @@ private IEnumerable GetDataCollection(string key) { IntPtr charArr = Marshal.ReadIntPtr(valuePtr, IntPtr.Size * i); valueArray.Add(Marshal.PtrToStringAnsi(charArr)); - _ = Interop.Libc.Free(charArr); + Marshal.FreeHGlobal(charArr); } - _ = Interop.Libc.Free(valuePtr); + Marshal.FreeHGlobal(valuePtr); } return valueArray; } diff --git a/src/Tizen.Content.MimeType/Interop/Interop.Libraries.cs b/src/Tizen.Content.MimeType/Interop/Interop.Libraries.cs index 365b82e957e..aa8e2956396 100755 --- a/src/Tizen.Content.MimeType/Interop/Interop.Libraries.cs +++ b/src/Tizen.Content.MimeType/Interop/Interop.Libraries.cs @@ -20,6 +20,5 @@ internal static partial class Libraries { public const string Mime = "libcapi-content-mime-type.so.0"; public const string Glib = "libglib-2.0.so.0"; - public const string Libc = "libc.so.6"; } } diff --git a/src/Tizen.Content.MimeType/Tizen.Content.MimeType/MimeUtil.cs b/src/Tizen.Content.MimeType/Tizen.Content.MimeType/MimeUtil.cs index dfce9476d3b..02e45a37ab7 100644 --- a/src/Tizen.Content.MimeType/Tizen.Content.MimeType/MimeUtil.cs +++ b/src/Tizen.Content.MimeType/Tizen.Content.MimeType/MimeUtil.cs @@ -86,9 +86,9 @@ public static IEnumerable GetFileExtension(string mime) foreach (IntPtr extension in extensionList) { coll.Add(Marshal.PtrToStringAnsi(extension)); - Interop.Libc.Free(extension); + Marshal.FreeHGlobal(extension); } - Interop.Libc.Free(extensionArray); + Marshal.FreeHGlobal(extensionArray); return coll; } diff --git a/src/Tizen.Data.Tdbc.Driver.Sqlite/Tizen.Data.Tdbc.Driver.Sqlite/Connection.cs b/src/Tizen.Data.Tdbc.Driver.Sqlite/Tizen.Data.Tdbc.Driver.Sqlite/Connection.cs index b1463f6ba44..5518e21f540 100644 --- a/src/Tizen.Data.Tdbc.Driver.Sqlite/Tizen.Data.Tdbc.Driver.Sqlite/Connection.cs +++ b/src/Tizen.Data.Tdbc.Driver.Sqlite/Tizen.Data.Tdbc.Driver.Sqlite/Connection.cs @@ -28,7 +28,7 @@ internal class Connection : IConnection private bool disposedValue; private readonly object _lock = new object(); private EventHandler _recordChanged; - + private Interop.Sqlite.UpdateHookCallback _hook; static Connection() { @@ -70,6 +70,7 @@ public void Close() Interop.Sqlite.UpdateHook(_db, null, IntPtr.Zero); Interop.Sqlite.Close(_db); _opened = false; + _hook = null; } } @@ -154,7 +155,12 @@ public void Open(Uri uri) if (ret != (int)Interop.Sqlite.ResultCode.SQLITE_OK) throw new InvalidOperationException("code:" + ret); - Interop.Sqlite.UpdateHook(_db, UpdateHookCallback, IntPtr.Zero); + if (_hook == null) + { + _hook = new Interop.Sqlite.UpdateHookCallback(UpdateHookCallback); + } + + Interop.Sqlite.UpdateHook(_db, _hook, IntPtr.Zero); _opened = true; } diff --git a/src/Tizen.Location.Geofence/Tizen.Location.Geofence/Fence.cs b/src/Tizen.Location.Geofence/Tizen.Location.Geofence/Fence.cs index 60ae5834b0f..56c8ce7aed3 100755 --- a/src/Tizen.Location.Geofence/Tizen.Location.Geofence/Fence.cs +++ b/src/Tizen.Location.Geofence/Tizen.Location.Geofence/Fence.cs @@ -31,6 +31,7 @@ namespace Tizen.Location.Geofence /// and the manufacturer's assigned 24-bit identifier for the radio chipset in the WAP. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public class Fence : IDisposable { private bool _disposed = false; @@ -59,6 +60,7 @@ internal Fence(IntPtr handle) /// Gets the type of geofence. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public FenceType Type { get @@ -78,6 +80,7 @@ public FenceType Type /// Gets the ID of the place. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public int PlaceId { get @@ -97,6 +100,7 @@ public int PlaceId /// Gets the longitude of geofence. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public double Longitude { get @@ -117,6 +121,7 @@ public double Longitude /// Gets the latitude of geofence. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public double Latitude { get @@ -136,6 +141,7 @@ public double Latitude /// Gets the radius of geofence. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public int Radius { get @@ -155,6 +161,7 @@ public int Radius /// Gets the address of geofence. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public string Address { get @@ -174,6 +181,7 @@ public string Address /// Gets the BSSID of geofence. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public string Bssid { get @@ -193,6 +201,7 @@ public string Bssid /// Gets the SSID of geofence. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public string Ssid { get @@ -221,6 +230,7 @@ public string Ssid /// In case of an invalid parameter. /// In case of any system error. /// In case the geofence is not supported. + [Obsolete("Deprecated since API11. Might be removed in API13")] public static Fence CreateGPSFence(int placeId, double latitude, double longitude, int radius, string address) { IntPtr handle = IntPtr.Zero; @@ -244,6 +254,7 @@ public static Fence CreateGPSFence(int placeId, double latitude, double longitud /// In case of an invalid parameter. /// In case of any system error. /// In case the geofence is not supported. + [Obsolete("Deprecated since API11. Might be removed in API13")] public static Fence CreateWifiFence(int placeId, string bssid, string ssid) { IntPtr handle = IntPtr.Zero; @@ -267,6 +278,7 @@ public static Fence CreateWifiFence(int placeId, string bssid, string ssid) /// In case of an invalid parameter. /// In case of any system error. /// In case the geofence is not supported. + [Obsolete("Deprecated since API11. Might be removed in API13")] public static Fence CreateBTFence(int placeId, string bssid, string ssid) { IntPtr handle = IntPtr.Zero; @@ -283,6 +295,7 @@ public static Fence CreateBTFence(int placeId, string bssid, string ssid) /// The overloaded Dispose API for destroying the fence handle. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public void Dispose() { Dispose(true); @@ -293,6 +306,7 @@ public void Dispose() /// Dispose. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] protected virtual void Dispose(bool disposing) { if (_disposed) diff --git a/src/Tizen.Location.Geofence/Tizen.Location.Geofence/FenceData.cs b/src/Tizen.Location.Geofence/Tizen.Location.Geofence/FenceData.cs index d328f4e4f64..10442195c56 100755 --- a/src/Tizen.Location.Geofence/Tizen.Location.Geofence/FenceData.cs +++ b/src/Tizen.Location.Geofence/Tizen.Location.Geofence/FenceData.cs @@ -21,6 +21,7 @@ namespace Tizen.Location.Geofence /// Represents the geofence list item data. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public class FenceData { internal FenceData(int fenceId, IntPtr handle, int index, int count) @@ -34,6 +35,7 @@ internal FenceData(int fenceId, IntPtr handle, int index, int count) /// The geofence instance. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public Fence Fence { get; @@ -44,6 +46,7 @@ public Fence Fence /// The geofence ID. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public int GeofenceId { get; @@ -55,6 +58,7 @@ public int GeofenceId /// /// 3 /// The index value starts from 1. + [Obsolete("Deprecated since API11. Might be removed in API13")] public int Index { get; @@ -65,6 +69,7 @@ public int Index /// The total number of fences that exists for the requester. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public int Count { get; @@ -76,6 +81,7 @@ public int Count /// Represents the place list item data. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public class PlaceData { internal PlaceData(int id, string name, int index, int count) @@ -89,6 +95,7 @@ internal PlaceData(int id, string name, int index, int count) /// The current place ID. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public int PlaceId { get; @@ -99,6 +106,7 @@ public int PlaceId /// The current place name. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public string Name { get; @@ -110,6 +118,7 @@ public string Name /// /// 3 /// The index value starts from 1. + [Obsolete("Deprecated since API11. Might be removed in API13")] public int Index { get; @@ -120,6 +129,7 @@ public int Index /// The total number of places that exists for the requester. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public int Count { get; diff --git a/src/Tizen.Location.Geofence/Tizen.Location.Geofence/FenceStatus.cs b/src/Tizen.Location.Geofence/Tizen.Location.Geofence/FenceStatus.cs index 23c0efb12f7..0012cb13c59 100644 --- a/src/Tizen.Location.Geofence/Tizen.Location.Geofence/FenceStatus.cs +++ b/src/Tizen.Location.Geofence/Tizen.Location.Geofence/FenceStatus.cs @@ -26,6 +26,7 @@ namespace Tizen.Location.Geofence /// /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public class FenceStatus : IDisposable { private bool _disposed = false; @@ -43,6 +44,7 @@ internal IntPtr Handle /// The geofence ID. /// In case of an invalid parameter. /// In case of geofence is not supported. + [Obsolete("Deprecated since API11. Might be removed in API13")] public FenceStatus(int fenceId) { IntPtr handle; @@ -69,6 +71,7 @@ public FenceStatus(int fenceId) /// /// 3 /// In case the geofence is not supported. + [Obsolete("Deprecated since API11. Might be removed in API13")] public GeofenceState State { get @@ -89,6 +92,7 @@ public GeofenceState State /// /// 3 /// In case the geofence is not supported. + [Obsolete("Deprecated since API11. Might be removed in API13")] public int Duration { get @@ -108,6 +112,7 @@ public int Duration /// The overloaded Dispose API for destroying the fence handle. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public void Dispose() { Dispose(true); @@ -118,6 +123,7 @@ public void Dispose() /// Dispose. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] protected virtual void Dispose(bool disposing) { if (_disposed) diff --git a/src/Tizen.Location.Geofence/Tizen.Location.Geofence/GeofenceEnum.cs b/src/Tizen.Location.Geofence/Tizen.Location.Geofence/GeofenceEnum.cs index 9f18ecabd90..48c5601f3c6 100755 --- a/src/Tizen.Location.Geofence/Tizen.Location.Geofence/GeofenceEnum.cs +++ b/src/Tizen.Location.Geofence/Tizen.Location.Geofence/GeofenceEnum.cs @@ -14,12 +14,15 @@ * limitations under the License. */ +using System; + namespace Tizen.Location.Geofence { /// /// Enumeration for the geofence types. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public enum FenceType { /// @@ -45,6 +48,7 @@ public enum FenceType /// Enumeration for the state of geofence. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public enum GeofenceState { /// @@ -70,6 +74,7 @@ public enum GeofenceState /// Enumeration for the geofence management events. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public enum GeofenceEventType { /// @@ -131,6 +136,7 @@ public enum GeofenceEventType /// Enumeration for the provider of proximity. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public enum ProximityProvider { /// @@ -168,6 +174,7 @@ public enum ProximityProvider /// Enumeration for the state of proximity. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public enum ProximityState { /// diff --git a/src/Tizen.Location.Geofence/Tizen.Location.Geofence/GeofenceErrorFactory.cs b/src/Tizen.Location.Geofence/Tizen.Location.Geofence/GeofenceErrorFactory.cs index a48e0074913..42f0ea1dbe7 100755 --- a/src/Tizen.Location.Geofence/Tizen.Location.Geofence/GeofenceErrorFactory.cs +++ b/src/Tizen.Location.Geofence/Tizen.Location.Geofence/GeofenceErrorFactory.cs @@ -24,6 +24,7 @@ namespace Tizen.Location.Geofence /// Enumeration for the types of error occured, if any. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public enum GeofenceError { /// diff --git a/src/Tizen.Location.Geofence/Tizen.Location.Geofence/GeofenceEventArgs.cs b/src/Tizen.Location.Geofence/Tizen.Location.Geofence/GeofenceEventArgs.cs index b16ee117cac..dd5bbffc300 100755 --- a/src/Tizen.Location.Geofence/Tizen.Location.Geofence/GeofenceEventArgs.cs +++ b/src/Tizen.Location.Geofence/Tizen.Location.Geofence/GeofenceEventArgs.cs @@ -22,6 +22,7 @@ namespace Tizen.Location.Geofence /// Event arguments are passed when an event is triggered to notify the proximity state change. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public class ProximityStateEventArgs : EventArgs { /// @@ -42,6 +43,7 @@ internal ProximityStateEventArgs(int id, ProximityState state, ProximityProvider /// The geofence ID. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public int GeofenceId { get; @@ -51,6 +53,7 @@ public int GeofenceId /// The proximity state. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public ProximityState State { get; @@ -60,6 +63,7 @@ public ProximityState State /// The proximity provider. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public ProximityProvider Provider { get; @@ -70,6 +74,7 @@ public ProximityProvider Provider /// Event arguments are passed when an event is triggered to notify the geofence state change. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public class GeofenceStateEventArgs : EventArgs { /// @@ -88,6 +93,7 @@ internal GeofenceStateEventArgs(int fenceId, GeofenceState state) /// The specified geofence ID. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public int GeofenceId { get; @@ -97,6 +103,7 @@ public int GeofenceId /// The geofence state. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public GeofenceState State { get; @@ -107,6 +114,7 @@ public GeofenceState State /// Event arguments are passed when an event occurs in geofence and the place, such as add, update, etc.. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public class GeofenceResponseEventArgs : EventArgs { /// @@ -129,6 +137,7 @@ internal GeofenceResponseEventArgs(int placeId, int fenceId, GeofenceError error /// The place ID. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public int PlaceId { get; @@ -138,6 +147,7 @@ public int PlaceId /// The specified geofence ID. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public int FenceId { get; @@ -147,6 +157,7 @@ public int FenceId /// The error code for the particular action. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public GeofenceError ErrorCode { get; @@ -156,6 +167,7 @@ public GeofenceError ErrorCode /// The result code for the particular place and geofence management. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public GeofenceEventType EventType { get; diff --git a/src/Tizen.Location.Geofence/Tizen.Location.Geofence/GeofenceManager.cs b/src/Tizen.Location.Geofence/Tizen.Location.Geofence/GeofenceManager.cs index 6019721ff48..11f683e05ba 100755 --- a/src/Tizen.Location.Geofence/Tizen.Location.Geofence/GeofenceManager.cs +++ b/src/Tizen.Location.Geofence/Tizen.Location.Geofence/GeofenceManager.cs @@ -36,6 +36,7 @@ namespace Tizen.Location.Geofence /// /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public class GeofenceManager : IDisposable { private bool _disposed = false; @@ -53,6 +54,7 @@ internal IntPtr Handle /// In case of out of memory condition. /// In case of any system error. /// In case the geofence is not supported. + [Obsolete("Deprecated since API11. Might be removed in API13")] public GeofenceManager() { IntPtr handle; @@ -78,6 +80,7 @@ public GeofenceManager() /// Checks whether the Geofence manager is available or not. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public static bool IsSupported { get @@ -106,6 +109,7 @@ public static bool IsSupported /// In case of any system error. /// In case privileges are not defined. /// In case the geofence is not supported. + [Obsolete("Deprecated since API11. Might be removed in API13")] public void Start(int geofenceId) { GeofenceError ret = (GeofenceError)Interop.GeofenceManager.Start(Handle, geofenceId); @@ -129,6 +133,7 @@ public void Start(int geofenceId) /// In case of any system error. /// In case privileges are not defined. /// In case the geofence is not supported. + [Obsolete("Deprecated since API11. Might be removed in API13")] public void Stop(int geofenceId) { GeofenceError ret = (GeofenceError)Interop.GeofenceManager.Stop(Handle, geofenceId); @@ -155,6 +160,7 @@ public void Stop(int geofenceId) /// Call to Start() will invoke this event. /// /// In case the feature is not supported. + [Obsolete("Deprecated since API11. Might be removed in API13")] public event EventHandler StateChanged { add @@ -200,6 +206,7 @@ public event EventHandler StateChanged /// Call to Start() will invoke this event. /// /// In case the feature is not supported. + [Obsolete("Deprecated since API11. Might be removed in API13")] public event EventHandler ProximityChanged { add @@ -247,6 +254,7 @@ public event EventHandler ProximityChanged /// The value of place_id or geofence_id is -1 when the place ID or geofence ID is not assigned. /// /// In case the feature is not supported. + [Obsolete("Deprecated since API11. Might be removed in API13")] public event EventHandler GeofenceEventChanged { add @@ -279,6 +287,7 @@ public event EventHandler GeofenceEventChanged /// The overloaded Dispose API for destroying the GeofenceManager handle. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public void Dispose() { Dispose(true); @@ -289,6 +298,7 @@ public void Dispose() /// Dispose. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] protected virtual void Dispose(bool disposing) { if (_disposed) diff --git a/src/Tizen.Location.Geofence/Tizen.Location.Geofence/VirtualPerimeter.cs b/src/Tizen.Location.Geofence/Tizen.Location.Geofence/VirtualPerimeter.cs index 3923657bcad..7a3f95f08e4 100755 --- a/src/Tizen.Location.Geofence/Tizen.Location.Geofence/VirtualPerimeter.cs +++ b/src/Tizen.Location.Geofence/Tizen.Location.Geofence/VirtualPerimeter.cs @@ -24,6 +24,7 @@ namespace Tizen.Location.Geofence /// A user can manage all the geofence or place related data and events. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public class VirtualPerimeter { private IntPtr Handle; @@ -34,6 +35,7 @@ public class VirtualPerimeter /// 3 /// The GeofenceManager instance. /// In case of an invalid parameter. + [Obsolete("Deprecated since API11. Might be removed in API13")] public VirtualPerimeter(GeofenceManager manager) { if (manager == null) @@ -57,6 +59,7 @@ public VirtualPerimeter(GeofenceManager manager) /// In case of any system error. /// In case privileges are not defined. /// In case the geofence is not supported. + [Obsolete("Deprecated since API11. Might be removed in API13")] public int AddPlaceName(string name) { int placeId = 0; @@ -80,6 +83,7 @@ public int AddPlaceName(string name) /// In case of any System error. /// In case privileges are not defined. /// In case the geofence is not supported. + [Obsolete("Deprecated since API11. Might be removed in API13")] public void UpdatePlace(int placeId, string name) { GeofenceError ret = (GeofenceError)Interop.VirtualPerimeter.UpdatePlace(Handle, placeId, name); @@ -99,6 +103,7 @@ public void UpdatePlace(int placeId, string name) /// In case of any system error. /// In case privileges are not defined. /// In case the geofence is not supported. + [Obsolete("Deprecated since API11. Might be removed in API13")] public void RemovePlace(int placeId) { GeofenceError ret = (GeofenceError)Interop.VirtualPerimeter.RemovePlace(Handle, placeId); @@ -120,6 +125,7 @@ public void RemovePlace(int placeId) /// In case of any system error. /// In case privileges are not defined. /// In case the geofence is not supported. + [Obsolete("Deprecated since API11. Might be removed in API13")] public int AddGeofence(Fence fence) { int fenceId = 0; @@ -142,6 +148,7 @@ public int AddGeofence(Fence fence) /// In case of any system error. /// In case privileges are not defined. /// In case the geofence is not supported. + [Obsolete("Deprecated since API11. Might be removed in API13")] public void RemoveGeofence(int fenceId) { GeofenceError ret = (GeofenceError)Interop.VirtualPerimeter.RemoveFence(Handle, fenceId); @@ -162,6 +169,7 @@ public void RemoveGeofence(int fenceId) /// In case of any system error. /// In case privileges are not defined. /// In case the geofence is not supported. + [Obsolete("Deprecated since API11. Might be removed in API13")] public string GetPlaceName(int placeId) { string name = ""; @@ -183,6 +191,7 @@ public string GetPlaceName(int placeId) /// In case of any system error. /// In case privileges are not defined. /// In case the geofence is not supported. + [Obsolete("Deprecated since API11. Might be removed in API13")] public IEnumerable GetPlaceDataList() { List places = new List(); @@ -214,6 +223,7 @@ public IEnumerable GetPlaceDataList() /// In case of any system error. /// In case privileges are not defined. /// In case geofence is not supported. + [Obsolete("Deprecated since API11. Might be removed in API13")] public IEnumerable GetFenceDataList() { List fences = new List(); @@ -247,6 +257,7 @@ public IEnumerable GetFenceDataList() /// In case of any system error. /// In case privileges are not defined. /// In case the geofence is not supported. + [Obsolete("Deprecated since API11. Might be removed in API13")] public IEnumerable GetGeofenceDataListByPlaceId(int placeId) { List fences = new List(); diff --git a/src/Tizen.Location.Geofence/doc/api/Tizen.Location.Geofence.md b/src/Tizen.Location.Geofence/doc/api/Tizen.Location.Geofence.md index 6d992aee60e..56a923499a7 100755 --- a/src/Tizen.Location.Geofence/doc/api/Tizen.Location.Geofence.md +++ b/src/Tizen.Location.Geofence/doc/api/Tizen.Location.Geofence.md @@ -4,6 +4,10 @@ summary: The Tizen.Location.Geofence namespace provides classes for virtual peri remarks: *content --- ## Overview + +> [!NOTE] +> All Geofence APIs have been deprecated since Tizen 8.0 (API Level 11) which means they are planned to be removed after two releases. + This API provides functions to set the gofence with a geopoint, MAC address of Wi-Fi, and Bluetooth address. Also, notifications on events like changing in service status are provided. diff --git a/src/Tizen.Messaging/Tizen.Messaging.Email/EmailAttachment.cs b/src/Tizen.Messaging/Tizen.Messaging.Email/EmailAttachment.cs index b561ddca1af..9f3a44dccc7 100644 --- a/src/Tizen.Messaging/Tizen.Messaging.Email/EmailAttachment.cs +++ b/src/Tizen.Messaging/Tizen.Messaging.Email/EmailAttachment.cs @@ -14,23 +14,28 @@ * limitations under the License. */ +using System; + namespace Tizen.Messaging.Email { /// /// Represents an email attachment. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public class EmailAttachment { /// /// The absolute full path of the file to be attached. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public string FilePath { get; set; } /// /// The constructor. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public EmailAttachment() { diff --git a/src/Tizen.Messaging/Tizen.Messaging.Email/EmailEnumerations.cs b/src/Tizen.Messaging/Tizen.Messaging.Email/EmailEnumerations.cs index 36d31171ec0..13a58b5bf76 100755 --- a/src/Tizen.Messaging/Tizen.Messaging.Email/EmailEnumerations.cs +++ b/src/Tizen.Messaging/Tizen.Messaging.Email/EmailEnumerations.cs @@ -14,12 +14,15 @@ * limitations under the License. */ +using System; + namespace Tizen.Messaging.Email { /// /// Result of sending the email. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public enum EmailSendResult { /// diff --git a/src/Tizen.Messaging/Tizen.Messaging.Email/EmailMessage.cs b/src/Tizen.Messaging/Tizen.Messaging.Email/EmailMessage.cs index 65306b00a6a..664d41ff001 100644 --- a/src/Tizen.Messaging/Tizen.Messaging.Email/EmailMessage.cs +++ b/src/Tizen.Messaging/Tizen.Messaging.Email/EmailMessage.cs @@ -24,6 +24,7 @@ namespace Tizen.Messaging.Email /// This class contains the Messaging API to support sending email messages. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public class EmailMessage : IDisposable { internal IntPtr _emailHandle = IntPtr.Zero; @@ -39,6 +40,7 @@ public class EmailMessage : IDisposable /// The constructor. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public EmailMessage() { int ret = Interop.Email.CreateEmail(out _emailHandle); @@ -53,6 +55,7 @@ public EmailMessage() /// The subject of the email message. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public string Subject { set @@ -76,6 +79,7 @@ public string Subject /// The body of the email message. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public string Body { set @@ -98,6 +102,7 @@ public string Body /// The list of file attachments. /// /// 3 +[Obsolete("Deprecated since API11. Might be removed in API13")] public IList Attachments { get @@ -113,6 +118,7 @@ public IList Attachments /// The email address should be in the standard format (as described in the Internet standards RFC 5321 and RFC 5322). /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public ICollection To { get @@ -128,6 +134,7 @@ public ICollection To /// The email address should be in the standard format (as described in the Internet standards RFC 5321 and RFC 5322). /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public ICollection Cc { get @@ -143,6 +150,7 @@ public ICollection Cc /// The email address should be in the standard format (as described in the Internet standards RFC 5321 and RFC 5322). /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public ICollection Bcc { get @@ -169,6 +177,7 @@ internal void Save() /// Releases all resources used by the EmailMessage. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public void Dispose() { Dispose(true); @@ -180,6 +189,7 @@ public void Dispose() /// /// Disposing by User /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] protected virtual void Dispose(bool disposing) { if (_disposed) diff --git a/src/Tizen.Messaging/Tizen.Messaging.Email/EmailRecipient.cs b/src/Tizen.Messaging/Tizen.Messaging.Email/EmailRecipient.cs index 69ff5039e06..c5ca528a19e 100644 --- a/src/Tizen.Messaging/Tizen.Messaging.Email/EmailRecipient.cs +++ b/src/Tizen.Messaging/Tizen.Messaging.Email/EmailRecipient.cs @@ -14,23 +14,28 @@ * limitations under the License. */ +using System; + namespace Tizen.Messaging.Email { /// /// This class represents recipients of an email. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public class EmailRecipient { /// /// The email address of the recipient. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public string Address { get; set; } /// /// The constructor. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public EmailRecipient() { diff --git a/src/Tizen.Messaging/Tizen.Messaging.Email/EmailSender.cs b/src/Tizen.Messaging/Tizen.Messaging.Email/EmailSender.cs index 3d60634e1c6..648c0340251 100644 --- a/src/Tizen.Messaging/Tizen.Messaging.Email/EmailSender.cs +++ b/src/Tizen.Messaging/Tizen.Messaging.Email/EmailSender.cs @@ -24,6 +24,7 @@ namespace Tizen.Messaging.Email /// This class is used to send email messages. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public static class EmailSender { static private Dictionary _sendCbMap = new Dictionary(); @@ -35,6 +36,7 @@ public static class EmailSender /// The email message. /// Failure if the email sending activity failed, otherwise Success. /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13")] public static async Task SendAsync(EmailMessage email) { var task = new TaskCompletionSource(); diff --git a/src/Tizen.Messaging/Tizen.Messaging.Messages/CBMessage.cs b/src/Tizen.Messaging/Tizen.Messaging.Messages/CBMessage.cs index 08ddae8a9e2..1a24ef0c4f9 100755 --- a/src/Tizen.Messaging/Tizen.Messaging.Messages/CBMessage.cs +++ b/src/Tizen.Messaging/Tizen.Messaging.Messages/CBMessage.cs @@ -22,6 +22,7 @@ namespace Tizen.Messaging.Messages /// This class represents the cell broadcast messages. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public class CBMessage : Message { internal CBMessage(IntPtr messageHandle) : base(messageHandle) diff --git a/src/Tizen.Messaging/Tizen.Messaging.Messages/Message.cs b/src/Tizen.Messaging/Tizen.Messaging.Messages/Message.cs index c2c2a28f7dc..3ac8630b293 100644 --- a/src/Tizen.Messaging/Tizen.Messaging.Messages/Message.cs +++ b/src/Tizen.Messaging/Tizen.Messaging.Messages/Message.cs @@ -24,6 +24,7 @@ namespace Tizen.Messaging.Messages /// This class represents all the messages. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public abstract class Message : IDisposable { internal IntPtr _messageHandle = IntPtr.Zero; @@ -72,6 +73,7 @@ internal void FillHandle() /// Releases all resources used by the Message. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public void Dispose() { Dispose(true); @@ -189,6 +191,7 @@ private void GetAllAddresses() /// After creating the Message object, the default value of this property is 0. After sending, this value is changed. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public int Id { get @@ -208,6 +211,7 @@ public int Id /// The destination port of the message. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public int Port { get @@ -227,6 +231,7 @@ public int Port /// The message box type. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public MessageBoxType BoxType { get @@ -255,6 +260,7 @@ public MessageBoxType BoxType /// The text of the message. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public string Text { get @@ -283,6 +289,7 @@ public string Text /// The time of the message. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public DateTime Time { get @@ -311,6 +318,7 @@ public DateTime Time /// The SIM slot index of the message. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public SimSlotId SimId { get @@ -339,6 +347,7 @@ public SimSlotId SimId /// Indicates the sender of the message. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public IReadOnlyCollection From { get diff --git a/src/Tizen.Messaging/Tizen.Messaging.Messages/MessageReceivedEventArgs.cs b/src/Tizen.Messaging/Tizen.Messaging.Messages/MessageReceivedEventArgs.cs index c91c6019a36..25d60fffeb1 100755 --- a/src/Tizen.Messaging/Tizen.Messaging.Messages/MessageReceivedEventArgs.cs +++ b/src/Tizen.Messaging/Tizen.Messaging.Messages/MessageReceivedEventArgs.cs @@ -22,6 +22,7 @@ namespace Tizen.Messaging.Messages /// An extended EventArgs class, which contains a received message. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public class MessageReceivedEventArgs : EventArgs { private Message _message; @@ -35,6 +36,7 @@ internal MessageReceivedEventArgs(Message message) /// The received message. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public Message ReceivedMessage { get diff --git a/src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesAddress.cs b/src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesAddress.cs index 74f834f10e0..8b03b5d4aae 100755 --- a/src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesAddress.cs +++ b/src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesAddress.cs @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +using System; namespace Tizen.Messaging.Messages { @@ -20,6 +21,7 @@ namespace Tizen.Messaging.Messages /// This class is used to manage the information of the message address. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public class MessagesAddress { internal RecipientType Type; @@ -34,6 +36,7 @@ public class MessagesAddress /// /// The recipient's address to receive a message. /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public MessagesAddress(string number) { Number = number; diff --git a/src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesAttachment.cs b/src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesAttachment.cs index d06d605b774..bfd4db6b23c 100755 --- a/src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesAttachment.cs +++ b/src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesAttachment.cs @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +using System; namespace Tizen.Messaging.Messages { @@ -20,18 +21,21 @@ namespace Tizen.Messaging.Messages /// This class is used to manage the information of the message attachment. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public class MessagesAttachment { /// /// The media type of the attachment. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public MediaType Type { get; } /// /// The file path of the attachment. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public string FilePath { get; } /// @@ -40,6 +44,7 @@ public class MessagesAttachment /// The attachment's type. /// The file path to attach. /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public MessagesAttachment(MediaType type, string filePath) { Type = type; diff --git a/src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesEnumerations.cs b/src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesEnumerations.cs index f95ed7c3521..e6cc1f1e039 100755 --- a/src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesEnumerations.cs +++ b/src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesEnumerations.cs @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +using System; namespace Tizen.Messaging.Messages { @@ -20,6 +21,7 @@ namespace Tizen.Messaging.Messages /// Enumeration for the result of sending a message. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public enum SentResult { /// @@ -36,6 +38,7 @@ public enum SentResult /// Enumeration for the message type. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public enum MessageType { /// @@ -64,6 +67,7 @@ public enum MessageType /// Enumeration for the message box type. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public enum MessageBoxType { /// @@ -92,6 +96,7 @@ public enum MessageBoxType /// Enumeration for the SIM slot index of a message. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public enum SimSlotId { /// @@ -135,6 +140,7 @@ internal enum RecipientType /// Enumeration for the attachment type for the MMS messaging. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public enum MediaType { /// diff --git a/src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesManager.cs b/src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesManager.cs index ce41df0f992..6349861cfcc 100755 --- a/src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesManager.cs +++ b/src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesManager.cs @@ -25,6 +25,7 @@ namespace Tizen.Messaging.Messages /// /// http://tizen.org/privilege/message.read /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public static class MessagesManager { /// @@ -39,6 +40,7 @@ public static class MessagesManager /// Thrown when input coordinates are invalid. /// Thrown when an application does not have proper privileges. /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public static Task SendMessageAsync(Message message, bool saveToSentbox) { return MessagesManagerImpl.Instance.SendMessageAsync(message, saveToSentbox); @@ -56,6 +58,7 @@ public static Task SendMessageAsync(Message message, bool saveToSent /// Thrown when failed due to out of memory. /// Thrown when an application does not have proper privileges. /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public static Task> SearchMessageAsync(MessagesSearchFilter filter) { return MessagesManagerImpl.Instance.SearchMessageAsync(filter); @@ -66,6 +69,7 @@ public static Task> SearchMessageAsync(MessagesSearchFilter /// /// http://tizen.org/privilege/message.read /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] static public event EventHandler MessageReceived { add diff --git a/src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesSearchFilter.cs b/src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesSearchFilter.cs index 44d7f54a463..03d7dbbd2cc 100755 --- a/src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesSearchFilter.cs +++ b/src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesSearchFilter.cs @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +using System; namespace Tizen.Messaging.Messages { @@ -20,12 +21,14 @@ namespace Tizen.Messaging.Messages /// This class represents message search filters. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public class MessagesSearchFilter { /// /// Creates a search filter for searching messages. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public MessagesSearchFilter() { } @@ -34,21 +37,25 @@ public MessagesSearchFilter() /// The message box type. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public MessageBoxType MessageBoxType { get; set; } /// /// The message type. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public MessageType MessageType { get; set; } /// /// The keyword to search in the text and the subject. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public string TextKeyword { get; set; } /// /// The recipient address. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public string AddressKeyword { get; set; } } } diff --git a/src/Tizen.Messaging/Tizen.Messaging.Messages/MmsMessage.cs b/src/Tizen.Messaging/Tizen.Messaging.Messages/MmsMessage.cs index 83d9fdc6ae4..43a8d2ec539 100755 --- a/src/Tizen.Messaging/Tizen.Messaging.Messages/MmsMessage.cs +++ b/src/Tizen.Messaging/Tizen.Messaging.Messages/MmsMessage.cs @@ -23,6 +23,7 @@ namespace Tizen.Messaging.Messages /// This class represents multimedia messages. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public class MmsMessage : Message { private IList _attachment = new List(); @@ -31,6 +32,7 @@ public class MmsMessage : Message /// Creates a multimedia message. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public MmsMessage() : base(MessageType.Mms) { } @@ -44,6 +46,7 @@ internal MmsMessage(IntPtr messageHandle) : base(messageHandle) /// The subject of the multimedia message. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public string Subject { get @@ -72,6 +75,7 @@ public string Subject /// The collection of normal message recipients. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public ICollection To { get @@ -84,6 +88,7 @@ public ICollection To /// The collection of CC (carbon copy) message recipients. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public ICollection Cc { get @@ -96,6 +101,7 @@ public ICollection Cc /// The collection of BCC (blind carbon copy) message recipients. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public ICollection Bcc { get @@ -108,6 +114,7 @@ public ICollection Bcc /// The list of attachment files. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public IList Attachments { get diff --git a/src/Tizen.Messaging/Tizen.Messaging.Messages/PushMessage.cs b/src/Tizen.Messaging/Tizen.Messaging.Messages/PushMessage.cs index eaca56ac516..2352ce5396d 100755 --- a/src/Tizen.Messaging/Tizen.Messaging.Messages/PushMessage.cs +++ b/src/Tizen.Messaging/Tizen.Messaging.Messages/PushMessage.cs @@ -22,6 +22,7 @@ namespace Tizen.Messaging.Messages /// This class represents the WAP push messages. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public class PushMessage : Message { internal PushMessage(IntPtr messageHandle) : base(messageHandle) diff --git a/src/Tizen.Messaging/Tizen.Messaging.Messages/SmsMessage.cs b/src/Tizen.Messaging/Tizen.Messaging.Messages/SmsMessage.cs index 76f5b1d8f0f..4cdaf962372 100755 --- a/src/Tizen.Messaging/Tizen.Messaging.Messages/SmsMessage.cs +++ b/src/Tizen.Messaging/Tizen.Messaging.Messages/SmsMessage.cs @@ -23,12 +23,14 @@ namespace Tizen.Messaging.Messages /// This class represents short text messages. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public class SmsMessage : Message { /// /// Creates a short text message. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public SmsMessage() : base(MessageType.Sms) { } @@ -41,6 +43,7 @@ internal SmsMessage(IntPtr messageHandle) : base(messageHandle) /// The collection of normal message recipients. /// /// 3 + [Obsolete("Deprecated since API11. Might be removed in API13.")] public ICollection To { get diff --git a/src/Tizen.Messaging/doc/api/Tizen.Messaging.Email.md b/src/Tizen.Messaging/doc/api/Tizen.Messaging.Email.md index def7ad1a8ca..20585513e2e 100644 --- a/src/Tizen.Messaging/doc/api/Tizen.Messaging.Email.md +++ b/src/Tizen.Messaging/doc/api/Tizen.Messaging.Email.md @@ -15,4 +15,8 @@ uid: Tizen.Messaging.Email summary: The Tizen.Messaging.Email namespace contains classes providing the functionality to send emails. + +> [!NOTE] +> All Email APIs have been deprecated since Tizen 8.0 (API Level 11) which means they are planned to be removed after two releases. + --- diff --git a/src/Tizen.Messaging/doc/api/Tizen.Messaging.Messages.md b/src/Tizen.Messaging/doc/api/Tizen.Messaging.Messages.md index 4036a109c6a..b2d0e619040 100644 --- a/src/Tizen.Messaging/doc/api/Tizen.Messaging.Messages.md +++ b/src/Tizen.Messaging/doc/api/Tizen.Messaging.Messages.md @@ -15,4 +15,7 @@ uid: Tizen.Messaging.Messages summary: The Tizen.Messaging.Messages namespace contains classes providing the functionality to send, receive, and search messages. + + > [!NOTE] + > All Messages APIs have been deprecated since Tizen 8.0 (API Level 11) which means they are planned to be removed after two releases. --- diff --git a/src/Tizen.NUI.Components/Controls/Button.cs b/src/Tizen.NUI.Components/Controls/Button.cs index 6601b2b05c8..a4e0b90d6bd 100755 --- a/src/Tizen.NUI.Components/Controls/Button.cs +++ b/src/Tizen.NUI.Components/Controls/Button.cs @@ -790,7 +790,15 @@ public StringSelector IconURLSelector } private StringSelector InternalIconURLSelector { - get => buttonIcon?.ResourceUrlSelector == null ? null : new StringSelector(buttonIcon.ResourceUrlSelector); + get + { + Selector resourceUrlSelector = buttonIcon?.ResourceUrlSelector; + if(resourceUrlSelector == null) + { + return null; + } + return new StringSelector(resourceUrlSelector); + } set { if (value == null || buttonIcon == null) diff --git a/src/Tizen.NUI.Components/Controls/Control.cs b/src/Tizen.NUI.Components/Controls/Control.cs index 3145db3dc3f..3007d93dcd5 100755 --- a/src/Tizen.NUI.Components/Controls/Control.cs +++ b/src/Tizen.NUI.Components/Controls/Control.cs @@ -72,7 +72,7 @@ static Control() /// This is used to improve theme performance. /// [EditorBrowsable(EditorBrowsableState.Never)] - static public void Preload() + static public new void Preload() { DefaultThemeCreator.Preload(); } diff --git a/src/Tizen.NUI.Components/Controls/TabButton.cs b/src/Tizen.NUI.Components/Controls/TabButton.cs index 9c91b2d3114..e9824982b87 100755 --- a/src/Tizen.NUI.Components/Controls/TabButton.cs +++ b/src/Tizen.NUI.Components/Controls/TabButton.cs @@ -301,10 +301,10 @@ private void UpdateSizeAndSpacing() // Text only if (isEmptyIcon && !isEmptyText) { - if (tabButtonStyle.Size != null) + if (tabButtonStyle.Size is var size && size != null) { - WidthSpecification = (int)tabButtonStyle.Size.Width; - HeightSpecification = (int)tabButtonStyle.Size.Height; + WidthSpecification = (int)size.Width; + HeightSpecification = (int)size.Height; } if ((tabButtonStyle.Text != null) && (tabButtonStyle.Text.PixelSize != null) && (tabButtonStyle.Text.PixelSize.Normal != null)) @@ -335,11 +335,11 @@ private void UpdateSizeAndSpacing() WidthSpecification = (int)tabButtonStyle.SizeWithIcon.Width; HeightSpecification = (int)tabButtonStyle.SizeWithIcon.Height; } - - if ((tabButtonStyle.Icon != null) && (tabButtonStyle.Icon.Size != null)) + var size = tabButtonStyle.Icon?.Size; + if (size != null) { - Icon.WidthSpecification = (int)tabButtonStyle.Icon.Size.Width; - Icon.HeightSpecification = (int)tabButtonStyle.Icon.Size.Height; + Icon.WidthSpecification = (int)size.Width; + Icon.HeightSpecification = (int)size.Height; } TextLabel.PixelSize = tabButtonStyle.TextSizeWithIcon; @@ -347,10 +347,10 @@ private void UpdateSizeAndSpacing() // Nothing else { - if (tabButtonStyle.Size != null) + if (tabButtonStyle.Size is var size && size != null) { - WidthSpecification = (int)tabButtonStyle.Size.Width; - HeightSpecification = (int)tabButtonStyle.Size.Height; + WidthSpecification = (int)size.Width; + HeightSpecification = (int)size.Height; } } } diff --git a/src/Tizen.NUI.Gadget/Tizen.NUI/NUIGadgetManager.cs b/src/Tizen.NUI.Gadget/Tizen.NUI/NUIGadgetManager.cs index 022d975e82b..bd3025cf5cb 100755 --- a/src/Tizen.NUI.Gadget/Tizen.NUI/NUIGadgetManager.cs +++ b/src/Tizen.NUI.Gadget/Tizen.NUI/NUIGadgetManager.cs @@ -346,8 +346,9 @@ public static void SendAppControl(NUIGadget gadget, AppControl appControl) internal static bool HandleAppControl(AppControlReceivedEventArgs args) { - if (!args.ReceivedAppControl.ExtraData.TryGet("__K_GADGET_RES_TYPE", out string resourceType) || - !args.ReceivedAppControl.ExtraData.TryGet("__K_GADGET_CLASS_NAME", out string className)) + var extraData = args.ReceivedAppControl?.ExtraData; + if (extraData == null||!extraData.TryGet("__K_GADGET_RES_TYPE", out string resourceType) || + !extraData.TryGet("__K_GADGET_CLASS_NAME", out string className)) { return false; } diff --git a/src/Tizen.NUI.Gadget/Tizen.NUI/NUIGadgetResourceManager.cs b/src/Tizen.NUI.Gadget/Tizen.NUI/NUIGadgetResourceManager.cs index d9e34708d72..2bb42eb1835 100755 --- a/src/Tizen.NUI.Gadget/Tizen.NUI/NUIGadgetResourceManager.cs +++ b/src/Tizen.NUI.Gadget/Tizen.NUI/NUIGadgetResourceManager.cs @@ -36,8 +36,19 @@ public class NUIGadgetResourceManager private readonly string _resourceClassName; private readonly IDictionary _resourceMap = new Dictionary(); - internal NUIGadgetResourceManager(NUIGadgetInfo info) + /// + /// Initializes the resource manager of the gadget. + /// + /// The information of the gadget. + /// Thrown when failed because of a invalid argument. + /// 11 + public NUIGadgetResourceManager(NUIGadgetInfo info) { + if (info == null) + { + throw new ArgumentNullException(nameof(info)); + } + _resourcePath = info.ResourcePath; _resourceDll = info.ResourceFile; _resourceClassName = info.ResourceClassName; diff --git a/src/Tizen.NUI.Physics2D/Properties/AssemblyInfo.cs b/src/Tizen.NUI.Physics2D/Properties/AssemblyInfo.cs new file mode 100755 index 00000000000..3110dbc1477 --- /dev/null +++ b/src/Tizen.NUI.Physics2D/Properties/AssemblyInfo.cs @@ -0,0 +1,4 @@ +using Tizen.NUI; + +// Xamarin.Forms.Loader.dll Xamarin.Forms.Xaml.XamlLoader.Load(object, string), kzu@microsoft.com +[assembly: XmlnsDefinition("http://tizen.org/Tizen.NUI/2018/XAML", "Tizen.NUI.Physics2D")] diff --git a/src/Tizen.NUI.Physics2D/Tizen.NUI.Physics2D.csproj b/src/Tizen.NUI.Physics2D/Tizen.NUI.Physics2D.csproj new file mode 100755 index 00000000000..0b35f62fe7f --- /dev/null +++ b/src/Tizen.NUI.Physics2D/Tizen.NUI.Physics2D.csproj @@ -0,0 +1,19 @@ + + + + net6.0 + $(NoWarn);CS0618;CA1054;CA1056 + + + + + + + + + + + + + + diff --git a/src/Tizen.NUI.Physics2D/Tizen.NUI.Physics2D.sln b/src/Tizen.NUI.Physics2D/Tizen.NUI.Physics2D.sln new file mode 100755 index 00000000000..f72eb282365 --- /dev/null +++ b/src/Tizen.NUI.Physics2D/Tizen.NUI.Physics2D.sln @@ -0,0 +1,79 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31515.178 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.NUI.Physics2D", "Tizen.NUI.Physics2D.csproj", "{F6CEE887-775A-4623-8BF8-DCA18C363D62}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.NUI", "..\Tizen.NUI\Tizen.NUI.csproj", "{F9DAA9C3-593D-467E-B02C-FFF51F1BC8CD}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Applications.Common", "..\Tizen.Applications.Common\Tizen.Applications.Common.csproj", "{CE90CD24-82F7-45A3-96B2-2E3C97D25C30}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.System.SystemSettings", "..\Tizen.System.SystemSettings\Tizen.System.SystemSettings.csproj", "{D726EEB8-6382-4BA3-BE0C-D9E61B5D8374}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen", "..\Tizen\Tizen.csproj", "{6D5FFD69-6DCC-4953-85E9-C23AC18B190E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.System.Information", "..\Tizen.System.Information\Tizen.System.Information.csproj", "{A951EAFE-D191-4F45-9AEF-7D97C382A747}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Log", "..\Tizen.Log\Tizen.Log.csproj", "{E1E30AEC-AD46-4E53-B9B1-780A68B59963}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Applications.ComponentBased", "..\Tizen.Applications.ComponentBased\Tizen.Applications.ComponentBased.csproj", "{70341AA2-1324-4215-9DB8-BFB13389D932}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Applications.ThemeManager", "..\Tizen.Applications.ThemeManager\Tizen.Applications.ThemeManager.csproj", "{F6A776BF-6743-4C1D-A8AF-F3E9F8CEFA0A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Tracer", "..\Tizen.Tracer\Tizen.Tracer.csproj", "{6DABE78F-1816-4F2E-8966-F909173194C8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F6CEE887-775A-4623-8BF8-DCA18C363D62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F6CEE887-775A-4623-8BF8-DCA18C363D62}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F6CEE887-775A-4623-8BF8-DCA18C363D62}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F6CEE887-775A-4623-8BF8-DCA18C363D62}.Release|Any CPU.Build.0 = Release|Any CPU + {F9DAA9C3-593D-467E-B02C-FFF51F1BC8CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F9DAA9C3-593D-467E-B02C-FFF51F1BC8CD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F9DAA9C3-593D-467E-B02C-FFF51F1BC8CD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F9DAA9C3-593D-467E-B02C-FFF51F1BC8CD}.Release|Any CPU.Build.0 = Release|Any CPU + {CE90CD24-82F7-45A3-96B2-2E3C97D25C30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CE90CD24-82F7-45A3-96B2-2E3C97D25C30}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CE90CD24-82F7-45A3-96B2-2E3C97D25C30}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CE90CD24-82F7-45A3-96B2-2E3C97D25C30}.Release|Any CPU.Build.0 = Release|Any CPU + {D726EEB8-6382-4BA3-BE0C-D9E61B5D8374}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D726EEB8-6382-4BA3-BE0C-D9E61B5D8374}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D726EEB8-6382-4BA3-BE0C-D9E61B5D8374}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D726EEB8-6382-4BA3-BE0C-D9E61B5D8374}.Release|Any CPU.Build.0 = Release|Any CPU + {6D5FFD69-6DCC-4953-85E9-C23AC18B190E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6D5FFD69-6DCC-4953-85E9-C23AC18B190E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6D5FFD69-6DCC-4953-85E9-C23AC18B190E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6D5FFD69-6DCC-4953-85E9-C23AC18B190E}.Release|Any CPU.Build.0 = Release|Any CPU + {A951EAFE-D191-4F45-9AEF-7D97C382A747}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A951EAFE-D191-4F45-9AEF-7D97C382A747}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A951EAFE-D191-4F45-9AEF-7D97C382A747}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A951EAFE-D191-4F45-9AEF-7D97C382A747}.Release|Any CPU.Build.0 = Release|Any CPU + {E1E30AEC-AD46-4E53-B9B1-780A68B59963}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E1E30AEC-AD46-4E53-B9B1-780A68B59963}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E1E30AEC-AD46-4E53-B9B1-780A68B59963}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E1E30AEC-AD46-4E53-B9B1-780A68B59963}.Release|Any CPU.Build.0 = Release|Any CPU + {70341AA2-1324-4215-9DB8-BFB13389D932}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {70341AA2-1324-4215-9DB8-BFB13389D932}.Debug|Any CPU.Build.0 = Debug|Any CPU + {70341AA2-1324-4215-9DB8-BFB13389D932}.Release|Any CPU.ActiveCfg = Release|Any CPU + {70341AA2-1324-4215-9DB8-BFB13389D932}.Release|Any CPU.Build.0 = Release|Any CPU + {F6A776BF-6743-4C1D-A8AF-F3E9F8CEFA0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F6A776BF-6743-4C1D-A8AF-F3E9F8CEFA0A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F6A776BF-6743-4C1D-A8AF-F3E9F8CEFA0A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F6A776BF-6743-4C1D-A8AF-F3E9F8CEFA0A}.Release|Any CPU.Build.0 = Release|Any CPU + {6DABE78F-1816-4F2E-8966-F909173194C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6DABE78F-1816-4F2E-8966-F909173194C8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6DABE78F-1816-4F2E-8966-F909173194C8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6DABE78F-1816-4F2E-8966-F909173194C8}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {83C85CFB-3AB8-403A-9F6D-CC2783C6C559} + EndGlobalSection +EndGlobal diff --git a/src/Tizen.NUI.Physics2D/src/internal/chipmunk/DelegateExtensions.cs b/src/Tizen.NUI.Physics2D/src/internal/chipmunk/DelegateExtensions.cs new file mode 100644 index 00000000000..dc2aed0801c --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/internal/chipmunk/DelegateExtensions.cs @@ -0,0 +1,304 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System; +using System.Runtime.InteropServices; + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// Create a ToFunctionPointer extension method for each delegate type. Unfortunately C# 7.0 + /// can't do something like that (you will need C# 7.3), thus we create one extension method for + /// each delegate public static IntPtr ToFunctionPointer T (this T d) where T : Delegate + /// + static internal class DelegateExtensions + { + public static IntPtr ToFunctionPointer(this BodyArbiterIteratorFunction d) + { + if (d == null) + { + return IntPtr.Zero; + } + + return Marshal.GetFunctionPointerForDelegate(d); + } + + public static IntPtr ToFunctionPointer(this BodyConstraintIteratorFunction d) + { + if (d == null) + { + return IntPtr.Zero; + } + + return Marshal.GetFunctionPointerForDelegate(d); + } + + public static IntPtr ToFunctionPointer(this BodyShapeIteratorFunction d) + { + if (d == null) + { + return IntPtr.Zero; + } + + return Marshal.GetFunctionPointerForDelegate(d); + } + + public static IntPtr ToFunctionPointer(this BodyVelocityFunction d) + { + if (d == null) + { + return IntPtr.Zero; + } + + return Marshal.GetFunctionPointerForDelegate(d); + } + + public static IntPtr ToFunctionPointer(this BodyPositionFunction d) + { + if (d == null) + { + return IntPtr.Zero; + } + + return Marshal.GetFunctionPointerForDelegate(d); + } + + public static IntPtr ToFunctionPointer(this CollisionBeginFunction d) + { + if (d == null) + { + return IntPtr.Zero; + } + + return Marshal.GetFunctionPointerForDelegate(d); + } + + + public static IntPtr ToFunctionPointer(this CollisionPreSolveFunction d) + { + if (d == null) + { + return IntPtr.Zero; + } + + return Marshal.GetFunctionPointerForDelegate(d); + } + + + public static IntPtr ToFunctionPointer(this CollisionPostSolveFunction d) + { + if (d == null) + { + return IntPtr.Zero; + } + + return Marshal.GetFunctionPointerForDelegate(d); + } + + + public static IntPtr ToFunctionPointer(this CollisionSeparateFunction d) + { + if (d == null) + { + return IntPtr.Zero; + } + + return Marshal.GetFunctionPointerForDelegate(d); + } + + + public static IntPtr ToFunctionPointer(this PostStepFunction d) + { + if (d == null) + { + return IntPtr.Zero; + } + + return Marshal.GetFunctionPointerForDelegate(d); + } + + + public static IntPtr ToFunctionPointer(this SpaceSegmentQueryFunction d) + { + if (d == null) + { + return IntPtr.Zero; + } + + return Marshal.GetFunctionPointerForDelegate(d); + } + + public static IntPtr ToFunctionPointer(this SpacePointQueryFunction d) + { + if (d == null) + { + return IntPtr.Zero; + } + + return Marshal.GetFunctionPointerForDelegate(d); + } + + public static IntPtr ToFunctionPointer(this SpaceBBQueryFunction d) + { + if (d == null) + { + return IntPtr.Zero; + } + + return Marshal.GetFunctionPointerForDelegate(d); + } + + + public static IntPtr ToFunctionPointer(this SpaceObjectIteratorFunction d) + { + if (d == null) + { + return IntPtr.Zero; + } + + return Marshal.GetFunctionPointerForDelegate(d); + } + + + public static IntPtr ToFunctionPointer(this SpaceDebugDrawCircleImpl d) + { + if (d == null) + { + return IntPtr.Zero; + } + + return Marshal.GetFunctionPointerForDelegate(d); + } + + + public static IntPtr ToFunctionPointer(this SpaceDebugDrawSegmentImpl d) + { + if (d == null) + { + return IntPtr.Zero; + } + + return Marshal.GetFunctionPointerForDelegate(d); + } + + public static IntPtr ToFunctionPointer(this SpaceDebugDrawFatSegmentImpl d) + { + if (d == null) + { + return IntPtr.Zero; + } + + return Marshal.GetFunctionPointerForDelegate(d); + } + + public static IntPtr ToFunctionPointer(this SpaceDebugDrawPolygonImpl d) + { + if (d == null) + { + return IntPtr.Zero; + } + + return Marshal.GetFunctionPointerForDelegate(d); + } + + public static IntPtr ToFunctionPointer(this SpaceDebugDrawDotImpl d) + { + if (d == null) + { + return IntPtr.Zero; + } + + return Marshal.GetFunctionPointerForDelegate(d); + } + + public static IntPtr ToFunctionPointer(this SpaceDebugDrawColorForShapeImpl d) + { + if (d == null) + { + return IntPtr.Zero; + } + + return Marshal.GetFunctionPointerForDelegate(d); + } + + + public static IntPtr ToFunctionPointer(this ConstraintSolveFunction d) + { + if (d == null) + { + return IntPtr.Zero; + } + + return Marshal.GetFunctionPointerForDelegate(d); + } + + public static IntPtr ToFunctionPointer(this DampedSpringForceFunction d) + { + if (d == null) + { + return IntPtr.Zero; + } + + return Marshal.GetFunctionPointerForDelegate(d); + } + + public static IntPtr ToFunctionPointer(this DampedRotarySpringTorqueFunction d) + { + if (d == null) + { + return IntPtr.Zero; + } + + return Marshal.GetFunctionPointerForDelegate(d); + } + + public static IntPtr ToFunctionPointer(this SpaceShapeQueryFunction d) + { + if (d == null) + { + return IntPtr.Zero; + } + + return Marshal.GetFunctionPointerForDelegate(d); + } + + public static IntPtr ToFunctionPointer(this MarchSegmentFunction d) + { + if (d == null) + { + return IntPtr.Zero; + } + + return Marshal.GetFunctionPointerForDelegate(d); + } + + public static IntPtr ToFunctionPointer(this MarchSampleFunction d) + { + if (d == null) + { + return IntPtr.Zero; + } + + return Marshal.GetFunctionPointerForDelegate(d); + } + } +} diff --git a/src/Tizen.NUI.Physics2D/src/internal/chipmunk/Delegates.cs b/src/Tizen.NUI.Physics2D/src/internal/chipmunk/Delegates.cs new file mode 100644 index 00000000000..8c2d219040b --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/internal/chipmunk/Delegates.cs @@ -0,0 +1,304 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System.Runtime.InteropServices; +using System.Security; +using cpArbiter = System.IntPtr; +using cpBody = System.IntPtr; +using cpBool = System.Byte; +using cpConstraint = System.IntPtr; +using cpContactPointSetPointer = System.IntPtr; +using cpHandle = System.IntPtr; +using cpShape = System.IntPtr; +using cpSpace = System.IntPtr; +using cpVertPointer = System.IntPtr; +using voidptr_t = System.IntPtr; + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +using ObjCRuntime; +#endif + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// Delegate method to iterate over arbiters. + /// + [SuppressUnmanagedCodeSecurity] + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ + [MonoNativeFunctionWrapper] +#endif + internal delegate void BodyArbiterIteratorFunction(cpBody body, cpArbiter arbiter, voidptr_t data); + + [SuppressUnmanagedCodeSecurity] + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ + [MonoNativeFunctionWrapper] +#endif + internal delegate void BodyVelocityFunction(cpBody body, Vect gravity, double damping, double dt); + + /// + /// Rigid body position update function type. + /// + [SuppressUnmanagedCodeSecurity] + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ + [MonoNativeFunctionWrapper] +#endif + internal delegate void BodyPositionFunction(cpBody body, double dt); + + /// + /// Delegate method to iterate over constraints. + /// + [SuppressUnmanagedCodeSecurity] + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ + [MonoNativeFunctionWrapper] +#endif + internal delegate void BodyConstraintIteratorFunction(cpBody body, cpConstraint constraint, voidptr_t data); + + /// + /// Delegate method to iterate over shapes. + /// + [SuppressUnmanagedCodeSecurity] + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ + [MonoNativeFunctionWrapper] +#endif + internal delegate void BodyShapeIteratorFunction(cpBody body, cpShape shape, voidptr_t data); + + /// + /// Collision begin event function callback type. Returning false from a begin callback causes + /// the collision to be ignored until the the separate callback is called when the objects stop + /// colliding. + /// + [SuppressUnmanagedCodeSecurity] + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ + [MonoNativeFunctionWrapper] +#endif + internal delegate void CollisionBeginFunction(cpArbiter arbiter, cpSpace space, voidptr_t userData); + + /// + /// Collision pre-solve event function callback type. Returning false from a pre-step callback + /// causes the collision to be ignored until the next step. + /// + [SuppressUnmanagedCodeSecurity] + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ + [MonoNativeFunctionWrapper] +#endif + internal delegate cpBool CollisionPreSolveFunction(cpArbiter arbiter, cpSpace space, voidptr_t userData); + + /// + /// Collision Post-Solve . + /// + [SuppressUnmanagedCodeSecurity] + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ + [MonoNativeFunctionWrapper] +#endif + internal delegate void CollisionPostSolveFunction(cpArbiter arbiter, cpSpace space, voidptr_t userData); + + /// + /// Collision separate event function callback type. + /// + [SuppressUnmanagedCodeSecurity] + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ + [MonoNativeFunctionWrapper] +#endif + internal delegate void CollisionSeparateFunction(cpArbiter arbiter, cpSpace space, voidptr_t userData); + + /// + /// Post Step callback function type. + /// + [SuppressUnmanagedCodeSecurity] + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ + [MonoNativeFunctionWrapper] +#endif + internal delegate void PostStepFunction(cpSpace space, voidptr_t key, voidptr_t data); + + /// + /// Nearest point query callback function type. + /// + [SuppressUnmanagedCodeSecurity] + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ + [MonoNativeFunctionWrapper] +#endif + internal delegate void SpacePointQueryFunction(cpShape shape, Vect point, double distance, Vect gradient, voidptr_t data); + + /// + /// Segment query callback function type. + /// + [SuppressUnmanagedCodeSecurity] + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ + [MonoNativeFunctionWrapper] +#endif + internal delegate void SpaceSegmentQueryFunction(cpShape shape, Vect point, Vect normal, double alpha, voidptr_t data); + + /// + /// Rectangle Query callback function type. + /// + [SuppressUnmanagedCodeSecurity] + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ + [MonoNativeFunctionWrapper] +#endif + internal delegate void SpaceBBQueryFunction(cpShape shape, voidptr_t data); + + /// + /// Space/object iterator callback function type. + /// + [SuppressUnmanagedCodeSecurity] + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ + [MonoNativeFunctionWrapper] +#endif + internal delegate void SpaceObjectIteratorFunction(cpHandle handle, voidptr_t data); + + /// + /// Callback type for a function that draws a filled, stroked circle. + /// + [SuppressUnmanagedCodeSecurity] + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ + [MonoNativeFunctionWrapper] +#endif + internal delegate void SpaceDebugDrawCircleImpl(Vect pos, double angle, double radius, DebugColor outlineColor, DebugColor fillColor, voidptr_t data); + + /// + /// Callback type for a function that draws a line segment. + /// + [SuppressUnmanagedCodeSecurity] + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ + [MonoNativeFunctionWrapper] +#endif + internal delegate void SpaceDebugDrawSegmentImpl(Vect a, Vect b, DebugColor color, voidptr_t data); + + /// + /// Callback type for a function that draws a thick line segment. + /// + [SuppressUnmanagedCodeSecurity] + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ + [MonoNativeFunctionWrapper] +#endif + internal delegate void SpaceDebugDrawFatSegmentImpl(Vect a, Vect b, double radius, DebugColor outlineColor, DebugColor fillColor, voidptr_t data); + + /// + /// Callback type for a function that draws a convex polygon. + /// + [SuppressUnmanagedCodeSecurity] + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ + [MonoNativeFunctionWrapper] +#endif + internal delegate void SpaceDebugDrawPolygonImpl(int count, cpVertPointer verts, double radius, DebugColor outlineColor, DebugColor fillColor, voidptr_t data); + + /// + /// Callback type for a function that draws a dot. + /// + [SuppressUnmanagedCodeSecurity] + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ + [MonoNativeFunctionWrapper] +#endif + internal delegate void SpaceDebugDrawDotImpl(double size, Vect pos, DebugColor color, voidptr_t data); + + /// + /// Callback type for a function that returns a color for a given shape. This gives you an + /// opportunity to color shapes based on how they are used in your engine. + /// + [SuppressUnmanagedCodeSecurity] + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ + [MonoNativeFunctionWrapper] +#endif + internal delegate DebugColor SpaceDebugDrawColorForShapeImpl(cpShape shape, voidptr_t data); + + /// + /// Callback function type that gets called after/before solving a joint. + /// + [SuppressUnmanagedCodeSecurity] + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ + [MonoNativeFunctionWrapper] +#endif + internal delegate void ConstraintSolveFunction(cpConstraint constraint, cpSpace space); + + /// + /// Function type used for damped spring force callbacks. + /// + [SuppressUnmanagedCodeSecurity] + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ + [MonoNativeFunctionWrapper] +#endif + internal delegate double DampedSpringForceFunction(cpConstraint spring, double dist); + + /// + /// Function type used for damped rotary spring force callbacks + /// + [SuppressUnmanagedCodeSecurity] + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ + [MonoNativeFunctionWrapper] +#endif + internal delegate double DampedRotarySpringTorqueFunction(cpConstraint spring, double relativeAngle); + + /// + /// Shape query callback function type. + /// + [SuppressUnmanagedCodeSecurity] + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ + [MonoNativeFunctionWrapper] +#endif + internal delegate void SpaceShapeQueryFunction(cpShape shape, cpContactPointSetPointer points, voidptr_t data); + + /// + /// Function type used as a callback from the marching squares algorithm to output a line + /// segment. It passes you the two endpoints and your context pointer. + /// + [SuppressUnmanagedCodeSecurity] + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ + [MonoNativeFunctionWrapper] +#endif + internal delegate void MarchSegmentFunction(Vect v0, Vect v1, voidptr_t data); + + /// + /// Function type used as a callback from the marching squares algorithm to sample an image function. + /// It passes you the point to sample and your context pointer, and you return the density. + /// + [SuppressUnmanagedCodeSecurity] + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ + [MonoNativeFunctionWrapper] +#endif + internal delegate double MarchSampleFunction(Vect point, voidptr_t data); +} diff --git a/src/Tizen.NUI.Physics2D/src/internal/chipmunk/NativeInterop.cs b/src/Tizen.NUI.Physics2D/src/internal/chipmunk/NativeInterop.cs new file mode 100644 index 00000000000..a86f6bf4ce6 --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/internal/chipmunk/NativeInterop.cs @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.InteropServices; + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + internal static class NativeInterop + { + public static IntPtr RegisterHandle(object obj) + { + var gcHandle = GCHandle.Alloc(obj); + return GCHandle.ToIntPtr(gcHandle); + } + + public static T FromIntPtr(IntPtr pointer) + { + Debug.Assert(pointer != IntPtr.Zero, "IntPtr parameter should never be Zero"); + + var handle = GCHandle.FromIntPtr(pointer); + + Debug.Assert(handle.IsAllocated, "GCHandle not allocated."); + Debug.Assert(handle.Target is T, "Target is not of type T."); + + return (T)handle.Target; + } + + public static void ReleaseHandle(IntPtr pointer) + { + Debug.Assert(pointer != IntPtr.Zero, "IntPtr parameter should never be Zero"); + + var handle = GCHandle.FromIntPtr(pointer); + + Debug.Assert(handle.IsAllocated, "GCHandle not allocated."); + + handle.Free(); + } + + public static T FromIntPtrAndFree(IntPtr pointer) + { + Debug.Assert(pointer != IntPtr.Zero, "IntPtr parameter should never be Zero"); + + var handle = GCHandle.FromIntPtr(pointer); + + Debug.Assert(handle.IsAllocated, "GCHandle not allocated."); + Debug.Assert(handle.Target is T, "Target is not of type T."); + T obj = (T)handle.Target; + + handle.Free(); + + return obj; + } + + public static int SizeOf() + { + return Marshal.SizeOf(); + } + + public static IntPtr AllocStructure() + { + int size = SizeOf(); + return Marshal.AllocHGlobal(size); + } + + public static void FreeStructure(IntPtr ptr) + { + Marshal.FreeHGlobal(ptr); + } + + public static T PtrToStructure(IntPtr intPtr) + { + return Marshal.PtrToStructure(intPtr); + } + + public static T[] PtrToStructureArray(IntPtr intPtr, int count) + { + var items = new T[count]; + var size = SizeOf(); + + for (var i = 0; i < count; i++) + { + var newPtr = new IntPtr(intPtr.ToInt64() + (i * size)); + items[i] = PtrToStructure(newPtr); + } + + return items; + } + + internal static IntPtr StructureArrayToPtr(IReadOnlyList items) + { + var size = SizeOf(); + int allocBytes = checked(size * items.Count); + Debug.Assert(allocBytes > 0, "The memory to be allocated should be greater than 0"); + + var memory = Marshal.AllocHGlobal(allocBytes); + + for (var i = 0; i < items.Count; i++) + { + var ptr = new IntPtr(memory.ToInt64() + (i * size)); + Marshal.StructureToPtr(items[i], ptr, true); + } + + return memory; + } + } +} diff --git a/src/Tizen.NUI.Physics2D/src/internal/chipmunk/NativeMethods.cs b/src/Tizen.NUI.Physics2D/src/internal/chipmunk/NativeMethods.cs new file mode 100644 index 00000000000..305d4039506 --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/internal/chipmunk/NativeMethods.cs @@ -0,0 +1,1228 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// ReSharper disable IdentifierTypo +using System; +using System.Runtime.InteropServices; +using System.Security; +using cpArbiter = System.IntPtr; +using cpBitmask = System.UInt32; +using cpBody = System.IntPtr; +using cpBodyArbiterIteratorFunc = System.IntPtr; +using cpBodyConstraintIteratorFunc = System.IntPtr; +using cpBodyPositionFunc = System.IntPtr; +using cpBodyShapeIteratorFunc = System.IntPtr; +using cpBodyType = System.Int32; +using cpBodyVelocityFunc = System.IntPtr; +using cpBool = System.Byte; +using cpCollisionHandlerPointer = System.IntPtr; +using cpCollisionType = System.UIntPtr; +using cpConstraint = System.IntPtr; +using cpConstraintPostSolveFunc = System.IntPtr; +using cpConstraintPreSolveFunc = System.IntPtr; +using cpDampedRotarySpringTorqueFunc = System.IntPtr; +using cpDampedSpringForceFunc = System.IntPtr; +using cpDataPointer = System.IntPtr; +using cpFloat = System.Double; +using cpGroup = System.UIntPtr; +using cpMarchSampleFunc = System.IntPtr; +using cpMarchSegmentFunc = System.IntPtr; +using cpPolyline = System.IntPtr; +using cpPolylineSet = System.IntPtr; +using cpPostStepFunc = System.IntPtr; +using cpShape = System.IntPtr; +using cpSpace = System.IntPtr; +using cpSpaceBBQueryFunc = System.IntPtr; +using cpSpaceBodyIteratorFunc = System.IntPtr; +using cpSpaceConstraintIteratorFunc = System.IntPtr; +using cpSpaceDebugDrawOptionsPointer = System.IntPtr; +using cpSpaceHash = System.IntPtr; +using cpSpacePointQueryFunc = System.IntPtr; +using cpSpaceSegmentQueryFunc = System.IntPtr; +using cpSpaceShapeIteratorFunc = System.IntPtr; +using cpSpaceShapeQueryFunc = System.IntPtr; +using cpSpatialIndex = System.IntPtr; +using cpSpatialIndexBBFunc = System.IntPtr; +using cpSpatialIndexQueryFunc = System.IntPtr; +using cpSweep1D = System.IntPtr; +using cpTimestamp = System.UInt32; +using cpVectPointer = System.IntPtr; +using VoidPointer = System.IntPtr; + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + [SuppressUnmanagedCodeSecurity] + internal static class NativeMethods + { + +#pragma warning disable CA1823 // Unused field 'ChipmunkLibraryName' + +#if __MACOS__ + private const string ChipmunkLibraryName = "libchipmunk.dylib"; +#else + private const string ChipmunkLibraryName = "libchipmunk.so"; +#endif + +#pragma warning restore CA1823 // Unused field 'ChipmunkLibraryName' + +#pragma warning disable IDE1006 // Naming Styles + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpArbiterCallWildcardBeginA(cpArbiter arb, cpSpace space); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpArbiterCallWildcardBeginB(cpArbiter arb, cpSpace space); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpArbiterCallWildcardPostSolveA(cpArbiter arb, cpSpace space); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpArbiterCallWildcardPostSolveB(cpArbiter arb, cpSpace space); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpBool cpArbiterCallWildcardPreSolveA(cpArbiter arb, cpSpace space); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpBool cpArbiterCallWildcardPreSolveB(cpArbiter arb, cpSpace space); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpArbiterCallWildcardSeparateA(cpArbiter arb, cpSpace space); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpArbiterCallWildcardSeparateB(cpArbiter arb, cpSpace space); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpArbiterGetBodies(cpArbiter arb, out cpBody a, out cpBody b); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpContactPointSet cpArbiterGetContactPointSet(cpArbiter arb); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern int cpArbiterGetCount(cpArbiter arb); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpArbiterGetDepth(cpArbiter arb, int i); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpArbiterGetFriction(cpArbiter arb); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern Vect cpArbiterGetNormal(cpArbiter arb); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern Vect cpArbiterGetPointA(cpArbiter arb, int i); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern Vect cpArbiterGetPointB(cpArbiter arb, int i); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpArbiterGetRestitution(cpArbiter arb); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpArbiterGetShapes(cpArbiter arb, out cpShape a, out cpShape b); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern Vect cpArbiterGetSurfaceVelocity(cpArbiter arb); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpDataPointer cpArbiterGetUserData(cpArbiter arb); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpBool cpArbiterIgnore(cpArbiter arb); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpBool cpArbiterIsFirstContact(cpArbiter arb); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpBool cpArbiterIsRemoval(cpArbiter arb); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpArbiterSetContactPointSet(cpArbiter arb, ref cpContactPointSet set); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpArbiterSetFriction(cpArbiter arb, cpFloat friction); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpArbiterSetRestitution(cpArbiter arb, cpFloat restitution); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpArbiterSetSurfaceVelocity(cpArbiter arb, Vect vr); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpArbiterSetUserData(cpArbiter arb, cpDataPointer userData); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern Vect cpArbiterTotalImpulse(cpArbiter arb); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpArbiterTotalKE(cpArbiter arb); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpAreaForCircle(cpFloat r1, cpFloat r2); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpAreaForPoly(int count, cpVectPointer verts, cpFloat radius); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpAreaForSegment(Vect a, Vect b, cpFloat radius); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpBBTree cpBBTreeAlloc(); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpSpatialIndex cpBBTreeInit(cpBBTree tree, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex staticIndex); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpSpatialIndex cpBBTreeNew(cpSpatialIndexBBFunc bbfunc, cpSpatialIndex staticIndex); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern void cpBBTreeOptimize(cpSpatialIndex index); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern void cpBBTreeSetVelocityFunc(cpSpatialIndex index, cpBBTreeVelocityFunc func); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpBodyActivate(cpBody body); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpBodyActivateStatic(cpBody body, cpShape filter); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpBody cpBodyAlloc(); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpBodyApplyForceAtLocalPoint(cpBody body, Vect force, Vect point); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpBodyApplyForceAtWorldPoint(cpBody body, Vect force, Vect point); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpBodyApplyTorque(cpBody body, cpFloat torque); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpBodyApplyAngularImpulse(cpBody body, cpFloat impulse); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpBodyApplyImpulseAtLocalPoint(cpBody body, Vect impulse, Vect point); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpBodyApplyImpulseAtWorldPoint(cpBody body, Vect impulse, Vect point); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern void cpBodyDestroy(cpBody body); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpBool cpBodyContactWith(cpBody bodyA, cpBody bodyB); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpBodyEachArbiter(cpBody body, cpBodyArbiterIteratorFunc func, VoidPointer data); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpBodyEachConstraint(cpBody body, cpBodyConstraintIteratorFunc func, VoidPointer data); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpBodyEachShape(cpBody body, cpBodyShapeIteratorFunc func, VoidPointer data); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpBodyFree(cpBody body); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpBodyGetAngle(cpBody body); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpBodyGetAngularVelocity(cpBody body); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern Vect cpBodyGetCenterOfGravity(cpBody body); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern int cpBodyGetContactedBodiesCount(cpBody body); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpBodyGetUserDataContactedBodies(cpBody body, IntPtr userDataArray); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpBodyPositionFunc cpBodyGetDefaultPositionUpdateFunc(); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpBodyVelocityFunc cpBodyGetDefaultVelocityUpdateFunc(); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern Vect cpBodyGetForce(cpBody body); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpBodyGetMass(cpBody body); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpBodyGetMoment(cpBody body); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern Vect cpBodyGetPosition(cpBody body); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern Vect cpBodyGetRotation(cpBody body); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpSpace cpBodyGetSpace(cpBody body); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpBodyGetTransform(cpBody body, out Vect pos, out cpFloat angle); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpBodyGetTorque(cpBody body); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpBodyType cpBodyGetType(cpBody body); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpDataPointer cpBodyGetUserData(cpBody body); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern Vect cpBodyGetVelocity(cpBody body); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern Vect cpBodyGetVelocityAtLocalPoint(cpBody body, Vect point); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern Vect cpBodyGetVelocityAtWorldPoint(cpBody body, Vect point); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpBody cpBodyInit(cpBody body, cpFloat mass, cpFloat moment); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpBool cpBodyIsSleeping(cpBody body); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpBodyKineticEnergy(cpBody body); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern Vect cpBodyLocalToWorld(cpBody body, Vect point); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpBody cpBodyNew(cpFloat mass, cpFloat moment); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpBody cpBodyNewKinematic(); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpBody cpBodyNewStatic(); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpBodySetAngle(cpBody body, cpFloat a); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpBodySetAngularVelocity(cpBody body, cpFloat angularVelocity); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpBodySetCenterOfGravity(cpBody body, Vect cog); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpBodySetForce(cpBody body, Vect force); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpBodySetMass(cpBody body, cpFloat m); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpBodySetMoment(cpBody body, cpFloat i); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpBodySetPosition(cpBody body, Vect pos); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpBodySetPositionUpdateFunc(cpBody body, cpBodyPositionFunc positionFunc); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpBodySetTransform(cpBody body, Vect pos, cpFloat angle); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpBodySetTorque(cpBody body, cpFloat torque); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpBodySetType(cpBody body, cpBodyType type); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpBodySetUserData(cpBody body, cpDataPointer userData); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpBodySetVelocity(cpBody body, Vect velocity); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpBodySetVelocityUpdateFunc(cpBody body, cpBodyVelocityFunc velocityFunc); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpBodySleep(cpBody body); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpBodySleepWithGroup(cpBody body, cpBody group); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpBodyUpdatePosition(cpBody body, cpFloat dt); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpBodyUpdateVelocity(cpBody body, Vect gravity, cpFloat damping, cpFloat dt); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern Vect cpBodyWorldToLocal(cpBody body, Vect point); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpPolyShape cpBoxShapeInit(cpPolyShape poly, cpBody body, cpFloat width, cpFloat height, cpFloat radius); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpPolyShape cpBoxShapeInit2(cpPolyShape poly, cpBody body, BoundingBox box, cpFloat radius); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpShape cpBoxShapeNew(cpBody body, cpFloat width, cpFloat height, cpFloat radius); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpShape cpBoxShapeNew2(cpBody body, BoundingBox box, cpFloat radius); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern Vect cpCentroidForPoly(int count, cpVectPointer verts); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpCircleShape cpCircleShapeAlloc(); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern Vect cpCircleShapeGetOffset(cpShape shape); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpCircleShapeGetRadius(cpShape shape); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpCircleShape cpCircleShapeInit(cpCircleShape circle, cpBody body, cpFloat radius, Vect offset); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpShape cpCircleShapeNew(cpBody body, cpFloat radius, Vect offset); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpCircleShapeSetOffset(cpShape shape, Vect offset); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpCircleShapeSetRadius(cpShape shape, cpFloat radius); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern void cpConstraintDestroy(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpConstraintFree(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpBody cpConstraintGetBodyA(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpBody cpConstraintGetBodyB(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpBool cpConstraintGetCollideBodies(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpConstraintGetErrorBias(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpConstraintGetImpulse(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpConstraintGetMaxBias(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpConstraintGetMaxForce(cpConstraint constraint); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpConstraintPostSolveFunc cpConstraintGetPostSolveFunc(cpConstraint constraint); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpConstraintPreSolveFunc cpConstraintGetPreSolveFunc(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpSpace cpConstraintGetSpace(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpDataPointer cpConstraintGetUserData(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpBool cpConstraintIsDampedRotarySpring(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpBool cpConstraintIsDampedSpring(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpBool cpConstraintIsGearJoint(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpBool cpConstraintIsGrooveJoint(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpBool cpConstraintIsPinJoint(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpBool cpConstraintIsPivotJoint(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpBool cpConstraintIsRatchetJoint(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpBool cpConstraintIsRotaryLimitJoint(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpBool cpConstraintIsSimpleMotor(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpBool cpConstraintIsSlideJoint(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpConstraintSetCollideBodies(cpConstraint constraint, cpBool collideBodies); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpConstraintSetErrorBias(cpConstraint constraint, cpFloat errorBias); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpConstraintSetMaxBias(cpConstraint constraint, cpFloat maxBias); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpConstraintSetMaxForce(cpConstraint constraint, cpFloat maxForce); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpConstraintSetPostSolveFunc(cpConstraint constraint, cpConstraintPostSolveFunc postSolveFunc); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpConstraintSetPreSolveFunc(cpConstraint constraint, cpConstraintPreSolveFunc preSolveFunc); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpConstraintSetUserData(cpConstraint constraint, cpDataPointer userData); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern int cpConvexHull(int count, cpVectPointer verts, cpVectPointer result, IntPtr first, cpFloat tol); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpDampedRotarySpring cpDampedRotarySpringAlloc(); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpDampedRotarySpringGetDamping(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpDampedRotarySpringGetRestAngle(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpDampedRotarySpringTorqueFunc cpDampedRotarySpringGetSpringTorqueFunc(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpDampedRotarySpringGetStiffness(cpConstraint constraint); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpDampedRotarySpring cpDampedRotarySpringInit(cpDampedRotarySpring joint, cpBody a, cpBody b, cpFloat restAngle, cpFloat stiffness, cpFloat damping); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpConstraint cpDampedRotarySpringNew(cpBody a, cpBody b, cpFloat restAngle, cpFloat stiffness, cpFloat damping); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpDampedRotarySpringSetDamping(cpConstraint constraint, cpFloat damping); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpDampedRotarySpringSetRestAngle(cpConstraint constraint, cpFloat restAngle); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpDampedRotarySpringSetSpringTorqueFunc(cpConstraint constraint, cpDampedRotarySpringTorqueFunc springTorqueFunc); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpDampedRotarySpringSetStiffness(cpConstraint constraint, cpFloat stiffness); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpDampedSpring cpDampedSpringAlloc(); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern Vect cpDampedSpringGetAnchorA(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern Vect cpDampedSpringGetAnchorB(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpDampedSpringGetDamping(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpDampedSpringGetRestLength(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpDampedSpringForceFunc cpDampedSpringGetSpringForceFunc(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpDampedSpringGetStiffness(cpConstraint constraint); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpDampedSpring cpDampedSpringInit(cpDampedSpring joint, cpBody a, cpBody b, Vect anchorA, Vect anchorB, cpFloat restLength, cpFloat stiffness, cpFloat damping); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpConstraint cpDampedSpringNew(cpBody a, cpBody b, Vect anchorA, Vect anchorB, cpFloat restLength, cpFloat stiffness, cpFloat damping); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpDampedSpringSetAnchorA(cpConstraint constraint, Vect anchorA); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpDampedSpringSetAnchorB(cpConstraint constraint, Vect anchorB); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpDampedSpringSetDamping(cpConstraint constraint, cpFloat damping); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpDampedSpringSetRestLength(cpConstraint constraint, cpFloat restLength); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpDampedSpringSetSpringForceFunc(cpConstraint constraint, cpDampedSpringForceFunc springForceFunc); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpDampedSpringSetStiffness(cpConstraint constraint, cpFloat stiffness); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpGearJoint cpGearJointAlloc(); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpGearJointGetPhase(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpGearJointGetRatio(cpConstraint constraint); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpGearJoint cpGearJointInit(cpGearJoint joint, cpBody a, cpBody b, cpFloat phase, cpFloat ratio); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpConstraint cpGearJointNew(cpBody a, cpBody b, cpFloat phase, cpFloat ratio); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpGearJointSetPhase(cpConstraint constraint, cpFloat phase); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpGearJointSetRatio(cpConstraint constraint, cpFloat ratio); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpGrooveJoint cpGrooveJointAlloc(); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern Vect cpGrooveJointGetAnchorB(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern Vect cpGrooveJointGetGrooveA(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern Vect cpGrooveJointGetGrooveB(cpConstraint constraint); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpGrooveJoint cpGrooveJointInit(cpGrooveJoint joint, cpBody a, cpBody b, Vect groove_a, Vect groove_b, Vect anchorB); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpConstraint cpGrooveJointNew(cpBody a, cpBody b, Vect groove_a, Vect groove_b, Vect anchorB); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpGrooveJointSetAnchorB(cpConstraint constraint, Vect anchorB); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpGrooveJointSetGrooveA(cpConstraint constraint, Vect grooveA); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpGrooveJointSetGrooveB(cpConstraint constraint, Vect grooveB); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpHastySpaceFree(cpSpace space); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint cpHastySpaceGetThreads(cpSpace space); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpSpace cpHastySpaceNew(); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpHastySpaceSetThreads(cpSpace space, uint threads); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpHastySpaceStep(cpSpace space, cpFloat dt); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpMarchHard( + BoundingBox bb, uint x_samples, uint y_samples, cpFloat threshold, + cpMarchSegmentFunc segment, IntPtr segment_data, + cpMarchSampleFunc sample, IntPtr sample_data + ); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpMarchSoft( + BoundingBox bb, uint x_samples, uint y_samples, cpFloat threshold, + cpMarchSegmentFunc segment, IntPtr segment_data, + cpMarchSampleFunc sample, IntPtr sample_data + ); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpMomentForBox(cpFloat m, cpFloat width, cpFloat height); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpMomentForBox2(cpFloat m, BoundingBox box); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpMomentForCircle(cpFloat m, cpFloat r1, cpFloat r2, Vect offset); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpMomentForPoly(cpFloat m, int count, cpVectPointer verts, Vect offset, cpFloat radius); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpMomentForSegment(cpFloat m, Vect a, Vect b, cpFloat radius); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpPinJoint cpPinJointAlloc(); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern Vect cpPinJointGetAnchorA(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern Vect cpPinJointGetAnchorB(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpPinJointGetDist(cpConstraint constraint); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpPinJoint cpPinJointInit(cpPinJoint joint, cpBody a, cpBody b, Vect anchorA, Vect anchorB); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpConstraint cpPinJointNew(cpBody a, cpBody b, Vect anchorA, Vect anchorB); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpPinJointSetAnchorA(cpConstraint constraint, Vect anchorA); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpPinJointSetAnchorB(cpConstraint constraint, Vect anchorB); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpPinJointSetDist(cpConstraint constraint, cpFloat dist); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpPivotJoint cpPivotJointAlloc(); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern Vect cpPivotJointGetAnchorA(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern Vect cpPivotJointGetAnchorB(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpPivotJoint cpPivotJointInit(cpPivotJoint joint, cpBody a, cpBody b, Vect anchorA, Vect anchorB); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpConstraint cpPivotJointNew(cpBody a, cpBody b, Vect pivot); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpConstraint cpPivotJointNew2(cpBody a, cpBody b, Vect anchorA, Vect anchorB); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpPivotJointSetAnchorA(cpConstraint constraint, Vect anchorA); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpPivotJointSetAnchorB(cpConstraint constraint, Vect anchorB); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpPolyShape cpPolyShapeAlloc(); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern int cpPolyShapeGetCount(cpShape shape); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpPolyShapeGetRadius(cpShape shape); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern Vect cpPolyShapeGetVert(cpShape shape, int index); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpPolyShape cpPolyShapeInit(cpPolyShape poly, cpBody body, int count, cpVectPointer verts, Transform transform, cpFloat radius); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpPolyShape cpPolyShapeInitRaw(cpPolyShape poly, cpBody body, int count, cpVectPointer verts, cpFloat radius); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpShape cpPolyShapeNew(cpBody body, int count, cpVectPointer verts, Transform transform, cpFloat radius); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpShape cpPolyShapeNewRaw(cpBody body, int count, cpVectPointer verts, cpFloat radius); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpPolyShapeSetRadius(cpShape shape, cpFloat radius); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpPolyShapeSetVerts(cpShape shape, int count, cpVectPointer verts, Transform transform); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpPolyShapeSetVertsRaw(cpShape shape, int count, cpVectPointer verts); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpPolylineSet cpPolylineConvexDecomposition(cpPolyline line, cpFloat tol); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpPolylineFree(cpPolyline line); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpPolyline cpPolylineSimplifyCurves(cpPolyline line, cpFloat tol); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpPolylineSet cpPolylineSetAlloc(); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpPolylineSetCollectSegment(Vect v0, Vect v1, cpPolylineSet lines); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern void cpPolylineSetDestroy(cpPolylineSet set, cpBool freePolylines); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpPolylineSetFree(cpPolylineSet set, cpBool freePolylines); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpPolylineSet cpPolylineSetInit(cpPolylineSet set); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpPolylineSet cpPolylineSetNew(); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpPolyline cpPolylineSimplifyVertexes(cpPolyline line, cpFloat tol); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpPolyline cpPolylineToConvexHull(cpPolyline line, cpFloat tol); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpRatchetJoint cpRatchetJointAlloc(); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpRatchetJointGetAngle(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpRatchetJointGetPhase(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpRatchetJointGetRatchet(cpConstraint constraint); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpRatchetJoint cpRatchetJointInit(cpRatchetJoint joint, cpBody a, cpBody b, cpFloat phase, cpFloat ratchet); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpConstraint cpRatchetJointNew(cpBody a, cpBody b, cpFloat phase, cpFloat ratchet); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpRatchetJointSetAngle(cpConstraint constraint, cpFloat angle); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpRatchetJointSetPhase(cpConstraint constraint, cpFloat phase); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpRatchetJointSetRatchet(cpConstraint constraint, cpFloat ratchet); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpRotaryLimitJoint cpRotaryLimitJointAlloc(); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpRotaryLimitJointGetMax(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpRotaryLimitJointGetMin(cpConstraint constraint); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpRotaryLimitJoint cpRotaryLimitJointInit(cpRotaryLimitJoint joint, cpBody a, cpBody b, cpFloat min, cpFloat max); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpConstraint cpRotaryLimitJointNew(cpBody a, cpBody b, cpFloat min, cpFloat max); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpRotaryLimitJointSetMax(cpConstraint constraint, cpFloat max); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpRotaryLimitJointSetMin(cpConstraint constraint, cpFloat min); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpSegmentShape cpSegmentShapeAlloc(); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern Vect cpSegmentShapeGetA(cpShape shape); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern Vect cpSegmentShapeGetB(cpShape shape); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern Vect cpSegmentShapeGetNormal(cpShape shape); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpSegmentShapeGetRadius(cpShape shape); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpSegmentShape cpSegmentShapeInit(cpSegmentShape seg, cpBody body, Vect a, Vect b, cpFloat radius); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpShape cpSegmentShapeNew(cpBody body, Vect a, Vect b, cpFloat radius); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpSegmentShapeSetEndpoints(cpShape shape, Vect a, Vect b); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpSegmentShapeSetNeighbors(cpShape shape, Vect prev, Vect next); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpSegmentShapeSetRadius(cpShape shape, cpFloat radius); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern BoundingBox cpShapeCacheBB(cpShape shape); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern void cpShapeDestroy(cpShape shape); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpShapeFree(cpShape shape); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpShapeGetArea(cpShape shape); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern BoundingBox cpShapeGetBB(cpShape shape); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpBody cpShapeGetBody(cpShape shape); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern Vect cpShapeGetCenterOfGravity(cpShape shape); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpCollisionType cpShapeGetCollisionType(cpShape shape); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpShapeGetDensity(cpShape shape); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpShapeGetElasticity(cpShape shape); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpShapeGetFriction(cpShape shape); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpShapeGetMass(cpShape shape); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpShapeGetMoment(cpShape shape); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpBool cpShapeGetSensor(cpShape shape); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpSpace cpShapeGetSpace(cpShape shape); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern Vect cpShapeGetSurfaceVelocity(cpShape shape); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpDataPointer cpShapeGetUserData(cpShape shape); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern ShapeFilter cpShapeGetFilter(cpShape shape); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpShapePointQuery(cpShape shape, Vect p, ref cpPointQueryInfo output); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpBool cpShapeSegmentQuery(cpShape shape, Vect a, Vect b, cpFloat radius, ref cpSegmentQueryInfo info); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpShapeSetBody(cpShape shape, cpBody body); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpShapeSetCollisionType(cpShape shape, cpCollisionType collisionType); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpShapeSetDensity(cpShape shape, cpFloat density); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpShapeSetElasticity(cpShape shape, cpFloat elasticity); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpShapeSetFriction(cpShape shape, cpFloat friction); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpShapeSetMass(cpShape shape, cpFloat mass); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpShapeSetSensor(cpShape shape, cpBool sensor); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpShapeSetSurfaceVelocity(cpShape shape, Vect surfaceVelocity); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpShapeSetUserData(cpShape shape, cpDataPointer userData); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern Vect cpShapeSetFilter(cpShape shape, ShapeFilter filter); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern BoundingBox cpShapeUpdate(cpShape shape, Transform transform); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpContactPointSet cpShapesCollide(cpShape a, cpShape b); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpSimpleMotor cpSimpleMotorAlloc(); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpSimpleMotorGetRate(cpConstraint constraint); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpSimpleMotor cpSimpleMotorInit(cpSimpleMotor joint, cpBody a, cpBody b, cpFloat rate); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpConstraint cpSimpleMotorNew(cpBody a, cpBody b, cpFloat rate); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpSimpleMotorSetRate(cpConstraint constraint, cpFloat rate); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpSlideJoint cpSlideJointAlloc(); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern Vect cpSlideJointGetAnchorA(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern Vect cpSlideJointGetAnchorB(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpSlideJointGetMax(cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpSlideJointGetMin(cpConstraint constraint); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpSlideJoint cpSlideJointInit(cpSlideJoint joint, cpBody a, cpBody b, Vect anchorA, Vect anchorB, cpFloat min, cpFloat max); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpConstraint cpSlideJointNew(cpBody a, cpBody b, Vect anchorA, Vect anchorB, cpFloat min, cpFloat max); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpSlideJointSetAnchorA(cpConstraint constraint, Vect anchorA); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpSlideJointSetAnchorB(cpConstraint constraint, Vect anchorB); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpSlideJointSetMax(cpConstraint constraint, cpFloat max); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpSlideJointSetMin(cpConstraint constraint, cpFloat min); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpBody cpSpaceAddBody(cpSpace space, cpBody body); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpCollisionHandlerPointer cpSpaceAddCollisionHandler(cpSpace space, cpCollisionType a, cpCollisionType b); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpConstraint cpSpaceAddConstraint(cpSpace space, cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpCollisionHandlerPointer cpSpaceAddDefaultCollisionHandler(cpSpace space); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpBool cpSpaceAddPostStepCallback(cpSpace space, cpPostStepFunc func, IntPtr key, IntPtr data); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpShape cpSpaceAddShape(cpSpace space, cpShape shape); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpCollisionHandlerPointer cpSpaceAddWildcardHandler(cpSpace space, cpCollisionType type); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpSpace cpSpaceAlloc(); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpSpaceBBQuery(cpSpace space, BoundingBox bb, ShapeFilter filter, cpSpaceBBQueryFunc func, IntPtr data); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpBool cpSpaceContainsShape(cpSpace space, cpShape shape); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpBool cpSpaceContainsBody(cpSpace space, cpBody body); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpBool cpSpaceContainsConstraint(cpSpace space, cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpSpaceDebugDraw(cpSpace space, cpSpaceDebugDrawOptionsPointer options); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern void cpSpaceDestroy(cpSpace space); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpSpaceEachBody(cpSpace space, cpSpaceBodyIteratorFunc func, IntPtr data); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpSpaceEachConstraint(cpSpace space, cpSpaceConstraintIteratorFunc func, IntPtr data); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern int cpSpaceGetBodyCount(cpSpace space); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpSpaceGetBodiesUserDataArray(cpSpace space, IntPtr userDataArray); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern int cpSpaceGetDynamicBodyCount(cpSpace space); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpSpaceGetDynamicBodiesUserDataArray(cpSpace space, IntPtr userDataArray); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpSpaceEachShape(cpSpace space, cpSpaceShapeIteratorFunc func, IntPtr data); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpSpaceFree(cpSpace space); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpSpaceGetCollisionBias(cpSpace space); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpTimestamp cpSpaceGetCollisionPersistence(cpSpace space); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpSpaceGetCollisionSlop(cpSpace space); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpSpaceGetCurrentTimeStep(cpSpace space); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpSpaceGetDamping(cpSpace space); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern Vect cpSpaceGetGravity(cpSpace space); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpSpaceGetIdleSpeedThreshold(cpSpace space); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern int cpSpaceGetIterations(cpSpace space); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpFloat cpSpaceGetSleepTimeThreshold(cpSpace space); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpBody cpSpaceGetStaticBody(cpSpace space); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpDataPointer cpSpaceGetUserData(cpSpace space); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpSpaceHash cpSpaceHashAlloc(); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpSpatialIndex cpSpaceHashInit(cpSpaceHash hash, cpFloat celldim, int numcells, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex staticIndex); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpSpatialIndex cpSpaceHashNew(cpFloat celldim, int cells, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex staticIndex); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern void cpSpaceHashResize(cpSpaceHash hash, cpFloat celldim, int numcells); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpSpace cpSpaceInit(cpSpace space); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpBool cpSpaceIsLocked(cpSpace space); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpSpace cpSpaceNew(); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpSpacePointQuery(cpSpace space, Vect point, cpFloat maxDistance, ShapeFilter filter, cpSpacePointQueryFunc func, IntPtr data); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpShape cpSpacePointQueryNearest(cpSpace space, Vect point, cpFloat maxDistance, ShapeFilter filter, ref cpPointQueryInfo output); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpSpaceReindexShape(cpSpace space, cpShape shape); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpSpaceReindexShapesForBody(cpSpace space, cpBody body); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpSpaceReindexStatic(cpSpace space); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpSpaceRemoveBody(cpSpace space, cpBody body); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpSpaceRemoveConstraint(cpSpace space, cpConstraint constraint); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpSpaceRemoveShape(cpSpace space, cpShape shape); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpSpaceSegmentQuery(cpSpace space, Vect start, Vect end, cpFloat radius, ShapeFilter filter, cpSpaceSegmentQueryFunc func, IntPtr data); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpShape cpSpaceSegmentQueryFirst(cpSpace space, Vect start, Vect end, cpFloat radius, ShapeFilter filter, ref cpSegmentQueryInfo output); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpSpaceSetCollisionBias(cpSpace space, cpFloat collisionBias); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpSpaceSetCollisionPersistence(cpSpace space, cpTimestamp collisionPersistence); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpSpaceSetCollisionSlop(cpSpace space, cpFloat collisionSlop); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpSpaceSetDamping(cpSpace space, cpFloat damping); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpSpaceSetGravity(cpSpace space, Vect gravity); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpSpaceSetIdleSpeedThreshold(cpSpace space, cpFloat idleSpeedThreshold); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpSpaceSetIterations(cpSpace space, int iterations); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpSpaceSetSleepTimeThreshold(cpSpace space, cpFloat sleepTimeThreshold); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpSpaceSetUserData(cpSpace space, cpDataPointer userData); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern cpBool cpSpaceShapeQuery(cpSpace space, cpShape shape, cpSpaceShapeQueryFunc func, IntPtr data); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpSpaceStep(cpSpace space, cpFloat dt); + + [DllImport(ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void cpSpaceUseSpatialHash(cpSpace space, cpFloat dim, int count); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern void cpSpatialIndexCollideStatic(cpSpatialIndex dynamicIndex, cpSpatialIndex staticIndex, cpSpatialIndexQueryFunc func, IntPtr data); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern void cpSpatialIndexFree(cpSpatialIndex index); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpSweep1D cpSweep1DAlloc(); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpSpatialIndex cpSweep1DInit(cpSweep1D sweep, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex staticIndex); + + //[DllImport (ChipmunkLibraryName, CallingConvention = CallingConvention.Cdecl)] + //internal static extern cpSpatialIndex cpSweep1DNew(cpSpatialIndexBBFunc bbfunc, cpSpatialIndex staticIndex); + +#pragma warning restore IDE1006 // Naming Styles + + } +} diff --git a/src/Tizen.NUI.Physics2D/src/internal/chipmunk/PostStepCallbackInfo.cs b/src/Tizen.NUI.Physics2D/src/internal/chipmunk/PostStepCallbackInfo.cs new file mode 100644 index 00000000000..05cbdc1eb3c --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/internal/chipmunk/PostStepCallbackInfo.cs @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// This class stores the data for the post-step callback. + /// + internal class PostStepCallbackInfo + { + Action callback; + object data; + + /// + /// Creates an instance of the PostStepCallbackInfo class. + /// + /// The post-step callback. + /// The data for the callback. + public PostStepCallbackInfo(Action c, object d) + { + callback = c; + data = d; + } + + /// + /// The post-step callback. + /// + public Action Callback => callback; + + /// + /// The data for the callback. + /// + public object Data => data; + } +} diff --git a/src/Tizen.NUI.Physics2D/src/internal/chipmunk/cpCollisionHandler.cs b/src/Tizen.NUI.Physics2D/src/internal/chipmunk/cpCollisionHandler.cs new file mode 100644 index 00000000000..22a266e6d8d --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/internal/chipmunk/cpCollisionHandler.cs @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System.Runtime.InteropServices; +using cpCollisionFunction = System.IntPtr; +using cpCollisionHandlerPointer = System.IntPtr; +using cpCollisionType = System.UIntPtr; +using cpDataPointer = System.IntPtr; + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// Struct that holds function callback pointers to configure custom collision handling. + /// Collision handlers have a pair of types; + /// when a collision occurs between two shapes that have these types, the collision handler functions are triggered. + /// + [StructLayout(LayoutKind.Sequential)] + internal struct cpCollisionHandler + { + /// + /// Collision type identifier of the first shape that this handler recognizes. + /// In the collision handler callback, the shape with this type will be the first argument. Read only. + /// + public cpCollisionType typeA; + + /// + /// Collision type identifier of the second shape that this handler recognizes. + /// In the collision handler callback, the shape with this type will be the second argument. Read only. + /// + public cpCollisionType typeB; + + /// + /// This function is called when two shapes with types that match this collision handler begin colliding. + /// + public cpCollisionFunction beginFunction; + + /// + /// This function is called each step when two shapes with types that match this collision handler are colliding. + /// It's called before the collision solver runs so that you can affect a collision's outcome. + /// + public cpCollisionFunction preSolveFunction; + + /// + /// This function is called each step when two shapes with types that match this collision handler are colliding. + /// It's called after the collision solver runs so that you can read back information about the collision to trigger events in your game. + /// + public cpCollisionFunction postSolveFunction; + + /// + /// This function is called when two shapes with types that match this collision handler stop colliding. + /// + public cpCollisionFunction separateFunction; + + /// + /// This is a user definable context pointer that is passed to all of the collision handler functions. + /// + public cpDataPointer userData; + + public static cpCollisionHandler FromHandle(cpCollisionHandlerPointer handle) + { + return Marshal.PtrToStructure(handle); + } + + internal static void ToPointer(cpCollisionHandler handler, cpCollisionFunction handle) + { + Marshal.StructureToPtr(handler, handle, false); + } + } +} diff --git a/src/Tizen.NUI.Physics2D/src/internal/chipmunk/cpContactPoint.cs b/src/Tizen.NUI.Physics2D/src/internal/chipmunk/cpContactPoint.cs new file mode 100644 index 00000000000..ed3f8ef9a81 --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/internal/chipmunk/cpContactPoint.cs @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System.Runtime.InteropServices; + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// The array of contact points. + /// + [StructLayout(LayoutKind.Sequential)] + internal struct cpContactPoint + { + /// + /// The position of the contact on the surface of the first shape. + /// + public Vect pointA; + + /// + /// The position of the contact on the surface of the second shape. + /// + public Vect pointB; + + /// + /// Penetration distance of the two shapes. Overlapping means it will be negative. + /// + public double distance; + } +} diff --git a/src/Tizen.NUI.Physics2D/src/internal/chipmunk/cpContactPointSet.cs b/src/Tizen.NUI.Physics2D/src/internal/chipmunk/cpContactPointSet.cs new file mode 100644 index 00000000000..82c0d8f81cb --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/internal/chipmunk/cpContactPointSet.cs @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System.Runtime.InteropServices; + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// A struct that wraps up the important collision data for an arbiter. + /// + [StructLayout(LayoutKind.Sequential)] + internal struct cpContactPointSet + { + /// + /// The number of contact points in the set. + /// + public int count; + + /// + /// The normal of the collision. + /// + public Vect normal; + + /// + /// The first contact point. + /// + public cpContactPoint points0; + + /// + /// The second contact point. + /// + public cpContactPoint points1; + } +} diff --git a/src/Tizen.NUI.Physics2D/src/internal/chipmunk/cpPointQueryInfo.cs b/src/Tizen.NUI.Physics2D/src/internal/chipmunk/cpPointQueryInfo.cs new file mode 100644 index 00000000000..fc9bfb5ed41 --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/internal/chipmunk/cpPointQueryInfo.cs @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System; +using System.Runtime.InteropServices; + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// Point query info. + /// + [StructLayout(LayoutKind.Sequential)] + internal struct cpPointQueryInfo + { + /// + /// The nearest shape, null if no shape was within range. + /// + public IntPtr shape; + + /// + /// The closest point on the shape's surface. (in world space coordinates) + /// + public Vect point; + + /// + /// The distance to the point. The distance is negative if the point is inside the shape. + /// + public double distance; + + /// + /// The gradient of the signed distance function. + /// + public Vect gradient; + } +} diff --git a/src/Tizen.NUI.Physics2D/src/internal/chipmunk/cpPolyline.cs b/src/Tizen.NUI.Physics2D/src/internal/chipmunk/cpPolyline.cs new file mode 100644 index 00000000000..0278215e8ff --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/internal/chipmunk/cpPolyline.cs @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System; +using System.Runtime.InteropServices; + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// Polylines are just arrays of vertices. + /// They are looped if the first vertex is equal to the last. + /// + [StructLayout(LayoutKind.Sequential)] + internal struct cpPolyline + { + /// + /// The number of vertices. + /// + public int count; + + /// + /// The capacity of the vertex array. + /// + public int capacity; + + /// + /// The vertex array that stores the vertices. + /// + public IntPtr verts; + } +} diff --git a/src/Tizen.NUI.Physics2D/src/internal/chipmunk/cpSegmentQueryInfo.cs b/src/Tizen.NUI.Physics2D/src/internal/chipmunk/cpSegmentQueryInfo.cs new file mode 100644 index 00000000000..2804746c085 --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/internal/chipmunk/cpSegmentQueryInfo.cs @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System; +using System.Runtime.InteropServices; + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// Segment query info + /// + [StructLayout(LayoutKind.Sequential)] + internal struct cpSegmentQueryInfo + { + /// + /// The shape that was hit, or null if no collision occured. + /// + public IntPtr shape; + + /// + /// The point of impact. + /// + public Vect point; + + /// + /// The normal of the surface hit. + /// + public Vect normal; + + /// + /// The normalized distance along the query segment in the range [0, 1]. + /// + public double alpha; + } +} diff --git a/src/Tizen.NUI.Physics2D/src/internal/chipmunk/cpSpaceDebugDrawOptions.cs b/src/Tizen.NUI.Physics2D/src/internal/chipmunk/cpSpaceDebugDrawOptions.cs new file mode 100644 index 00000000000..7b9afef9716 --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/internal/chipmunk/cpSpaceDebugDrawOptions.cs @@ -0,0 +1,231 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System; +using System.Runtime.InteropServices; +using cpDataPointer = System.IntPtr; +using cpShape = System.IntPtr; +using cpSpaceDebugDrawCircleImpl = System.IntPtr; +using cpSpaceDebugDrawColorForShapeImpl = System.IntPtr; +using cpSpaceDebugDrawDotImpl = System.IntPtr; +using cpSpaceDebugDrawFatSegmentImpl = System.IntPtr; +using cpSpaceDebugDrawFlags = System.Int32; +using cpSpaceDebugDrawPolygonImpl = System.IntPtr; +using cpSpaceDebugDrawSegmentImpl = System.IntPtr; +using cpVertPointer = System.IntPtr; +using voidptr_t = System.IntPtr; + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +using ObjCRuntime; +#endif + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// Struct used with Space.DebugDraw() containing drawing callbacks and other drawing settings. + /// + [StructLayout(LayoutKind.Sequential)] + internal struct cpSpaceDebugDrawOptions + { + /// + /// Function that will be invoked to draw circles. + /// + cpSpaceDebugDrawCircleImpl drawCircle; + + /// + /// Function that will be invoked to draw line segments. + /// + cpSpaceDebugDrawSegmentImpl drawSegment; + + /// + /// Function that will be invoked to draw thick line segments. + /// + cpSpaceDebugDrawFatSegmentImpl drawFatSegment; + + /// + /// Function that will be invoked to draw convex polygons. + /// + cpSpaceDebugDrawPolygonImpl drawPolygon; + + /// + /// Function that will be invoked to draw dots. + /// + cpSpaceDebugDrawDotImpl drawDot; + + /// + /// Flags that request which things to draw (collision shapes, constraints, contact points). + /// + cpSpaceDebugDrawFlags flags; + + /// + /// Outline color passed to the drawing function. + /// + DebugColor shapeOutlineColor; + + /// + /// Function that decides what fill color to draw shapes using. + /// + cpSpaceDebugDrawColorForShapeImpl colorForShape; + + /// + /// Color passed to drawing functions for constraints. + /// + DebugColor constraintColor; + + /// + /// Color passed to drawing functions for collision points. + /// + DebugColor collisionPointColor; + + /// + /// User defined context pointer passed to all of the callback functions as the 'data' argument. + /// + cpDataPointer data; + + private IntPtr ToPointer() + { + IntPtr drawOptionsPtr = NativeInterop.AllocStructure(); + if (Marshal.SizeOf(typeof(cpSpaceDebugDrawOptions)) == 0) + { + throw new ArgumentNullException("The size of type cpSpaceDebugDrawOptions should not be 0."); + } + + Marshal.StructureToPtr(this, drawOptionsPtr, false); + + return drawOptionsPtr; + } + + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +#pragma warning disable CA1416 // Validate platform compatibility + [MonoPInvokeCallback(typeof(SpaceDebugDrawCircleImpl))] +#pragma warning restore CA1416 // Validate platform compatibility +#endif + private static void SpaceDebugDrawCircleCallback(Vect pos, double angle, double radius, DebugColor outlineColor, DebugColor fillColor, voidptr_t data) + { + IDebugDraw debugDraw = NativeInterop.FromIntPtr(data); + + debugDraw.DrawCircle(pos, angle, radius, outlineColor, fillColor); + } + + private static SpaceDebugDrawCircleImpl spaceDebugDrawCircleCallback = SpaceDebugDrawCircleCallback; + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +#pragma warning disable CA1416 // Validate platform compatibility + [MonoPInvokeCallback(typeof(SpaceDebugDrawSegmentImpl))] +#pragma warning restore CA1416 // Validate platform compatibility +#endif + private static void SpaceDebugDrawSegmentCallback(Vect a, Vect b, DebugColor color, voidptr_t data) + { + IDebugDraw debugDraw = NativeInterop.FromIntPtr(data); + + debugDraw.DrawSegment(a, b, color); + } + + private static SpaceDebugDrawSegmentImpl spaceDebugDrawSegmentCallback = SpaceDebugDrawSegmentCallback; + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +#pragma warning disable CA1416 // Validate platform compatibility + [MonoPInvokeCallback(typeof(SpaceDebugDrawFatSegmentImpl))] +#pragma warning restore CA1416 // Validate platform compatibility +#endif + private static void SpaceDebugDrawFatSegmentCallback(Vect a, Vect b, double radius, DebugColor outlineColor, DebugColor fillColor, voidptr_t data) + { + IDebugDraw debugDraw = NativeInterop.FromIntPtr(data); + + debugDraw.DrawFatSegment(a, b, radius, outlineColor, fillColor); + } + + private static SpaceDebugDrawFatSegmentImpl spaceDebugDrawFatSegmentCallback = SpaceDebugDrawFatSegmentCallback; + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +#pragma warning disable CA1416 // Validate platform compatibility + [MonoPInvokeCallback(typeof(SpaceDebugDrawPolygonImpl))] +#pragma warning restore CA1416 // Validate platform compatibility +#endif + private static void SpaceDebugDrawPolygonCallback(int count, cpVertPointer verts, double radius, DebugColor outlineColor, DebugColor fillColor, voidptr_t data) + { + IDebugDraw debugDraw = NativeInterop.FromIntPtr(data); + + Vect[] vectors = NativeInterop.PtrToStructureArray(verts, count); + + debugDraw.DrawPolygon(vectors, radius, outlineColor, fillColor); + } + + private static SpaceDebugDrawPolygonImpl spaceDebugDrawPolygonCallback = SpaceDebugDrawPolygonCallback; + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +#pragma warning disable CA1416 // Validate platform compatibility + [MonoPInvokeCallback(typeof(SpaceDebugDrawDotImpl))] +#pragma warning restore CA1416 // Validate platform compatibility +#endif + private static void SpaceDebugDrawDotCallback(double size, Vect pos, DebugColor color, voidptr_t data) + { + IDebugDraw debugDraw = NativeInterop.FromIntPtr(data); + + debugDraw.DrawDot(size, pos, color); + } + + private static SpaceDebugDrawDotImpl spaceDebugDrawDotCallback = SpaceDebugDrawDotCallback; + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +#pragma warning disable CA1416 // Validate platform compatibility + [MonoPInvokeCallback(typeof(SpaceDebugDrawColorForShapeImpl))] +#pragma warning restore CA1416 // Validate platform compatibility +#endif + private static DebugColor SpaceDebugDrawColorForShapeCallback(cpShape handleShape, voidptr_t data) + { + IDebugDraw debugDraw = NativeInterop.FromIntPtr(data); + var shape = Shape.FromHandle(handleShape); + + return debugDraw.ColorForShape(shape); + } + + private static SpaceDebugDrawColorForShapeImpl spaceDebugDrawColorForShapeCallback = SpaceDebugDrawColorForShapeCallback; + + + public IntPtr AcquireDebugDrawOptions(IDebugDraw debugDraw, DebugDrawFlags flags, DebugDrawColors colors) + { + this.flags = (int)flags; + collisionPointColor = colors.CollisionPoint; + constraintColor = colors.Constraint; + shapeOutlineColor = colors.ShapeOutline; + + drawCircle = spaceDebugDrawCircleCallback.ToFunctionPointer(); + drawSegment = spaceDebugDrawSegmentCallback.ToFunctionPointer(); + drawFatSegment = spaceDebugDrawFatSegmentCallback.ToFunctionPointer(); + drawPolygon = spaceDebugDrawPolygonCallback.ToFunctionPointer(); + drawDot = spaceDebugDrawDotCallback.ToFunctionPointer(); + colorForShape = spaceDebugDrawColorForShapeCallback.ToFunctionPointer(); + + data = NativeInterop.RegisterHandle(debugDraw); + + return ToPointer(); + } + + public void ReleaseDebugDrawOptions(IntPtr debugDrawOptionsPointer) + { + NativeInterop.ReleaseHandle(data); + NativeInterop.FreeStructure(debugDrawOptionsPointer); + } + } +} diff --git a/src/Tizen.NUI.Physics2D/src/internal/interop/Interop.Actor.cs b/src/Tizen.NUI.Physics2D/src/internal/interop/Interop.Actor.cs new file mode 100644 index 00000000000..163c8e46e2f --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/internal/interop/Interop.Actor.cs @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; +using Tizen.NUI.Physics2D.Chipmunk; + +namespace Tizen.NUI.Physics2D +{ + internal static partial class Interop + { + internal static class Actor + { + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_PhysicsActor_New")] + internal static extern global::System.IntPtr PhysicsActorNew(HandleRef actor, IntPtr Body, HandleRef adaptor); + + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_new_PhysicsActor__SWIG_0")] + internal static extern global::System.IntPtr NewPhysicsActor(); + + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_new_PhysicsActor__SWIG_1")] + internal static extern global::System.IntPtr NewPhysicsActor(HandleRef rhs); + + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_PhysicsActor_DownCast")] + internal static extern global::System.IntPtr DownCast(HandleRef handle); + + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_delete_PhysicsActor")] + internal static extern void DeletePhysicsActor(HandleRef handle); + + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_PhysicsActor_Assign")] + internal static extern global::System.IntPtr Assign(HandleRef destination, HandleRef source); + + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_PhysicsActor_GetId")] + internal static extern uint GetId(HandleRef handle); + + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_PhysicsActor_GetBody")] + internal static extern global::System.IntPtr GetBody(HandleRef handle); + + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_PhysicsActor_AsyncSetPhysicsPosition")] + internal static extern void AsyncSetPhysicsPosition(HandleRef handle, HandleRef position); + + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_PhysicsActor_AsyncSetPhysicsRotation")] + internal static extern void AsyncSetPhysicsRotation(HandleRef handle, HandleRef rotation); + + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_PhysicsActor_GetPhysicsPosition")] + internal static extern global::System.IntPtr GetPhysicsPosition(HandleRef handle); + + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_PhysicsActor_GetPhysicsRotation")] + internal static extern global::System.IntPtr GetPhysicsRotation(HandleRef handle); + + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_PhysicsActor_GetActorPosition")] + internal static extern global::System.IntPtr GetActorPosition(HandleRef handle); + + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_PhysicsActor_GetActorRotation")] + internal static extern global::System.IntPtr GetActorRotation(HandleRef handle); + } + } +} diff --git a/src/Tizen.NUI.Physics2D/src/internal/interop/Interop.Adaptor.cs b/src/Tizen.NUI.Physics2D/src/internal/interop/Interop.Adaptor.cs new file mode 100644 index 00000000000..b8e1a943c3b --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/internal/interop/Interop.Adaptor.cs @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; +using Tizen.NUI.Physics2D.Chipmunk; + +namespace Tizen.NUI.Physics2D +{ + internal static partial class Interop + { + internal static class Adaptor + { + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_PhysicsAdaptor_New")] + internal static extern global::System.IntPtr PhysicsAdaptorNew(HandleRef matrix, HandleRef size); + + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_new_PhysicsAdaptor__SWIG_0")] + internal static extern global::System.IntPtr NewPhysicsAdaptor(); + + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_new_PhysicsAdaptor__SWIG_1")] + internal static extern global::System.IntPtr NewPhysicsAdaptor(HandleRef rhs); + + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_delete_PhysicsAdaptor")] + internal static extern void DeletePhysicsAdaptor(HandleRef handle); + + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_PhysicsAdaptor_DownCast")] + internal static extern global::System.IntPtr DownCast(HandleRef handle); + + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_PhysicsAdaptor_Assign")] + internal static extern global::System.IntPtr Assign(HandleRef destination, HandleRef source); + + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_PhysicsAdaptor_SetTimestep")] + internal static extern void SetTimestep(HandleRef adaptor, float timestep); + + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_PhysicsAdaptor_GetTimestep")] + internal static extern float GetTimestep(HandleRef adaptor); + + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_PhysicsAdaptor_CreateDebugLayer")] + internal static extern global::System.IntPtr CreateDebugLayer(HandleRef adaptor, HandleRef window); + // Layer + + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_PhysicsAdaptor_TranslateToPhysicsSpace_1")] + internal static extern global::System.IntPtr TranslatePositionToPhysicsSpace(HandleRef adaptor, HandleRef position); + // Vector3 + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_PhysicsAdaptor_TranslateToPhysicsSpace_2")] + internal static extern global::System.IntPtr TranslateRotationToPhysicsSpace(HandleRef adaptor, HandleRef rotation); + // Quaternion + + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_PhysicsAdaptor_TranslateFromPhysicsSpace_1")] + internal static extern global::System.IntPtr TranslatePositionFromPhysicsSpace(HandleRef adaptor, HandleRef position); + // Vector3 + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_PhysicsAdaptor_TranslateFromPhysicsSpace_2")] + internal static extern global::System.IntPtr TranslateRotationFromPhysicsSpace(HandleRef adaptor, HandleRef rotation); + // Quaternion + + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_PhysicsAdaptor_ConvertVectorToPhysicsSpace")] + internal static extern global::System.IntPtr ConvertVectorToPhysicsSpace(HandleRef adaptor, HandleRef vector); + // Vector3 + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_PhysicsAdaptor_ConvertVectorFromPhysicsSpace")] + internal static extern global::System.IntPtr ConvertVectorFromPhysicsSpace(HandleRef adaptor, HandleRef vector); + // Vector3 + + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_PhysicsAdaptor_SetTransformAndSize")] + internal static extern void SetTransformAndSize(HandleRef adaptor, HandleRef transform, HandleRef size); + + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_PhysicsAdaptor_SetIntegrationState")] + internal static extern void SetIntegrationState(HandleRef adaptor, int integrationState); + + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_PhysicsAdaptor_GetIntegrationState")] + internal static extern int GetIntegrationState(HandleRef adaptor); + + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_PhysicsAdaptor_SetDebugState")] + internal static extern void SetDebugState(HandleRef adaptor, int integrationState); + + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_PhysicsAdaptor_GetDebugState")] + internal static extern int GetDebugState(HandleRef adaptor); + + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_PhysicsAdaptor_AddActorBody")] + internal static extern global::System.IntPtr AddActorBody(HandleRef adaptor, HandleRef actor, global::System.IntPtr body); + // PhysicsActor + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_PhysicsAdaptor_RemoveActorBody")] + internal static extern void RemoveActorBody(HandleRef adaptor, HandleRef physicsActor); + + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_PhysicsAdaptor_GetPhysicsActor")] + internal static extern global::System.IntPtr GetPhysicsActor(HandleRef adaptor, global::System.IntPtr body); + // PhysicsActor + + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_PhysicsAdaptor_GetRootActor")] + internal static extern global::System.IntPtr GetRootActor(HandleRef adaptor); + // Actor + + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_PhysicsAdaptor_BuildPickingRay")] + internal static extern void BuildPickingRay(HandleRef adaptor, HandleRef origin, HandleRef direction, + HandleRef rayFromWorld, HandleRef rayToWorld); + + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_PhysicsAdaptor_ProjectPoint")] + internal static extern global::System.IntPtr ProjectPoint(HandleRef adaptor, HandleRef origin, HandleRef direction, float distance); + // Vector3 + + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_PhysicsAdaptor_CreateSyncPoint")] + internal static extern void CreateSyncPoint(HandleRef adaptor); + + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_PhysicsAdaptor_GetPhysicsWorld")] + internal static extern global::System.IntPtr GetPhysicsWorld(HandleRef adaptor); + } + } +} diff --git a/src/Tizen.NUI.Physics2D/src/internal/interop/Interop.Libraries.cs b/src/Tizen.NUI.Physics2D/src/internal/interop/Interop.Libraries.cs new file mode 100644 index 00000000000..b9e984ead31 --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/internal/interop/Interop.Libraries.cs @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Tizen.NUI.Physics2D +{ + internal static partial class Interop + { + internal static partial class Libraries + { +#if __MACOS__ + public const string Physics2D = "libdali2-csharp-binder-physics-2d.dylib"; +#else + public const string Physics2D = "libdali2-csharp-binder-physics-2d.so"; +#endif + } + } +} diff --git a/src/Tizen.NUI.Physics2D/src/internal/interop/Interop.World.cs b/src/Tizen.NUI.Physics2D/src/internal/interop/Interop.World.cs new file mode 100644 index 00000000000..29aea3bb83b --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/internal/interop/Interop.World.cs @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; +using Tizen.NUI.Physics2D.Chipmunk; + +namespace Tizen.NUI.Physics2D +{ + internal static partial class Interop + { + internal static partial class World + { + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_PhysicsWorld_Lock")] + internal static extern void Lock(global::System.IntPtr world); + + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_PhysicsWorld_Unlock")] + internal static extern void Unlock(global::System.IntPtr world); + + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_PhysicsWorld_GetNative")] + internal static extern global::System.IntPtr GetNative(global::System.IntPtr world); + + [DllImport(Libraries.Physics2D, EntryPoint = "CSharp_Dali_PhysicsWorld_HitTest")] + internal static extern global::System.IntPtr HitTest(global::System.IntPtr world, HandleRef rayFromWorld, + HandleRef rayToWorld, Chipmunk.ShapeFilter nativeFilter, + HandleRef localPivot, out float distanceFromCamera); + } + } +} diff --git a/src/Tizen.NUI.Physics2D/src/public/chipmunk/Arbiter.cs b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Arbiter.cs new file mode 100644 index 00000000000..0a7a05a2f1f --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Arbiter.cs @@ -0,0 +1,387 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using cpArbiter = System.IntPtr; + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// The object encapsulates a pair of colliding shapes and all of the data + /// about their collision. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public struct Arbiter : IEquatable + { +#pragma warning disable IDE0032 + readonly cpArbiter arbiter; +#pragma warning restore IDE0032 + + /// + /// Native handle of . + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public cpArbiter Handle => arbiter; + + internal Arbiter(cpArbiter handle) + { + arbiter = handle; + } + + /// + /// The restitution (elasticity) that will be applied to the pair of colliding objects. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Restitution + { + get => NativeMethods.cpArbiterGetRestitution(arbiter); + set => NativeMethods.cpArbiterSetRestitution(arbiter, value); + } + + /// + /// Friction coefficient that will be applied to the pair of colliding objects. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Friction + { + get => NativeMethods.cpArbiterGetFriction(arbiter); + set => NativeMethods.cpArbiterSetFriction(arbiter, value); + } + + /// + /// The relative surface velocity of the two shapes in contact. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect SurfaceVelocity + { + get => NativeMethods.cpArbiterGetSurfaceVelocity(arbiter); + set => NativeMethods.cpArbiterSetSurfaceVelocity(arbiter, value); + } + + /// + /// Calculate the total impulse including the friction that was applied by this arbiter. + /// This function should only be called from a post-solve, post-step or cpBodyEachArbiter + /// callback. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect TotalImpulse => NativeMethods.cpArbiterTotalImpulse(arbiter); + + /// + /// Calculate the amount of energy lost in a collision including static, but not dynamic friction. + /// This function should only be called from a post-solve, post-step or cpBodyEachArbiter callback. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double TotalKE => NativeMethods.cpArbiterTotalKE(arbiter); + + /// + /// Mark a collision pair to be ignored until the two objects separate. Pre-solve and + /// post-solve callbacks will not be called, but the separate callback will be called. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool Ignore() => NativeMethods.cpArbiterIgnore(arbiter) != 0; + + /// + /// Return the colliding shapes involved for this arbiter. The order of their + /// values will match the order set when the collision + /// handler was registered. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void GetShapes(out Shape a, out Shape b) + { + IntPtr ptrA; + IntPtr ptrB; + + NativeMethods.cpArbiterGetShapes(arbiter, out ptrA, out ptrB); + + a = Shape.FromHandle(ptrA); + b = Shape.FromHandle(ptrB); + } + + /// + /// Return the colliding bodies involved for this arbiter. The order of the + /// values the bodies are associated with will match the + /// order set when the collision handler was registered. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void GetBodies(out Body a, out Body b) + { + IntPtr ptrA; + IntPtr ptrB; + + NativeMethods.cpArbiterGetBodies(arbiter, out ptrA, out ptrB); + + a = Body.FromHandle(ptrA); + b = Body.FromHandle(ptrB); + } + + /// + /// The contact point set for an arbiter. This can be a very powerful feature, but use it + /// with caution! + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public ContactPointSet ContactPointSet + { + get + { + cpContactPointSet pointSet = NativeMethods.cpArbiterGetContactPointSet(arbiter); + return ContactPointSet.FromContactPointSet(pointSet); + } + set + { + cpContactPointSet pointSet = value.ToContactPointSet(); + NativeMethods.cpArbiterSetContactPointSet(arbiter, ref pointSet); + } + } + + /// + /// Arbitrary user data. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public object Data + { + get + { + IntPtr handle = NativeMethods.cpArbiterGetUserData(arbiter); + + if (handle == IntPtr.Zero) + { + return null; + } + + return NativeInterop.FromIntPtrAndFree(handle); + } + set + { + var gcHandle = IntPtr.Zero; + + if (value != null) + { + gcHandle = NativeInterop.RegisterHandle(value); + } + + NativeMethods.cpArbiterSetUserData(arbiter, gcHandle); + } + } + + /// + /// Returns true if this is the first step a pair of objects started colliding. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool IsFirstContact => NativeMethods.cpArbiterIsFirstContact(arbiter) != 0; + + /// + /// Returns true if the separate callback is due to a shape being removed from the space. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool IsRemoval => NativeMethods.cpArbiterIsRemoval(arbiter) != 0; + + /// + /// Get the number of contact points for this arbiter. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public int Count => NativeMethods.cpArbiterGetCount(arbiter); + + /// + /// Get the normal of the collision. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect Normal => NativeMethods.cpArbiterGetNormal(arbiter); + + /// + /// Get the position of the th contact point on the surface of the first + /// shape. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect GetPointA(int i) + { + return NativeMethods.cpArbiterGetPointA(arbiter, i); + } + + /// + /// Get the position of the th contact point on the surface of the + /// second shape. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect GetPointB(int i) + { + return NativeMethods.cpArbiterGetPointB(arbiter, i); + } + + /// + /// Get the depth (amount of overlap) of the th contact point. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double GetDepth(int i) + { + return NativeMethods.cpArbiterGetDepth(arbiter, i); + } + + /// + /// If you want a custom callback to invoke the wildcard callback for the first collision + /// type, you must call this function explicitly. You must decide how to handle the + /// wildcard's return value since it may disagree with the other wildcard handler's return + /// value or your own. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void CallWildcardBeginA(Space space) + { + NativeMethods.cpArbiterCallWildcardBeginA(arbiter, space.Handle); + } + + /// + /// If you want a custom callback to invoke the wildcard callback for the second collision + /// type, you must call this function explicitly. You must decide how to handle the + /// wildcard's return value since it may disagree with the other wildcard handler's return + /// value or your own. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void CallWildcardBeginB(Space space) + { + NativeMethods.cpArbiterCallWildcardBeginB(arbiter, space.Handle); + } + + /// + /// If you want a custom callback to invoke the wildcard callback for the first collision + /// type, you must call this function explicitly. You must decide how to handle the + /// wildcard's return value since it may disagree with the other wildcard handler's return + /// value or your own. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool CallWildcardPreSolveA(Space space) + { + return NativeMethods.cpArbiterCallWildcardPreSolveA(arbiter, space.Handle) != 0; + } + + /// + /// If you want a custom callback to invoke the wildcard callback for the second collision + /// type, you must call this function explicitly. You must decide how to handle the + /// wildcard's return value since it may disagree with the other wildcard handler's return + /// value or your own. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool CallWildcardPreSolveB(Space space) + { + return NativeMethods.cpArbiterCallWildcardPreSolveB(arbiter, space.Handle) != 0; + } + + /// + /// If you want a custom callback to invoke the wildcard callback for the first collision + /// type, you must call this function explicitly. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void CallWildcardPostSolveA(Space space) + { + NativeMethods.cpArbiterCallWildcardPostSolveA(arbiter, space.Handle); + } + + /// + /// If you want a custom callback to invoke the wildcard callback for the second collision + /// type, you must call this function explicitly. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void CallWildcardPostSolveB(Space space) + { + NativeMethods.cpArbiterCallWildcardPostSolveB(arbiter, space.Handle); + } + + /// + /// If you want a custom callback to invoke the wildcard callback for the first collision + /// type, you must call this function explicitly. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void CallWildcardSeparateA(Space space) + { + NativeMethods.cpArbiterCallWildcardSeparateA(arbiter, space.Handle); + } + + /// + /// If you want a custom callback to invoke the wildcard callback for the second collision + /// type, you must call this function explicitly. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void CallWildcardSeparateB(Space space) + { + NativeMethods.cpArbiterCallWildcardSeparateB(arbiter, space.Handle); + } + + /// + /// Return true if an arbiter is equal to another. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool Equals(Arbiter other) + { + return arbiter == other.arbiter; + } + + /// + /// Check if an arbiter is equal to the given object. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) + { + var other = obj as Arbiter?; + + if (other == null) + return false; + + return Equals(other.Value); + } + + /// + /// Return the arbiter's handle prefixed by 'Handle: '. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override string ToString() + { + return $"Handle: {arbiter}"; + } + + /// + /// Get the hash code. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() + { + return 932982278 + EqualityComparer.Default.GetHashCode(arbiter); + } + + /// + /// Check if one arbiter is equal to another. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static bool operator ==(Arbiter left, Arbiter right) + { + return left.Equals(right); + } + + /// + /// Check if one arbiter is inequal to another. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static bool operator !=(Arbiter left, Arbiter right) + { + return !(left == right); + } + } +} diff --git a/src/Tizen.NUI.Physics2D/src/public/chipmunk/AutoGeometry.cs b/src/Tizen.NUI.Physics2D/src/public/chipmunk/AutoGeometry.cs new file mode 100644 index 00000000000..2a8ba0b31c5 --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/chipmunk/AutoGeometry.cs @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Runtime.InteropServices; + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +using ObjCRuntime; +#endif + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// This class contains functions for automatic generation of geometry. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + internal static class AutoGeometry + { +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +#pragma warning disable CA1416 // Validate platform compatibility + [MonoPInvokeCallback(typeof(MarchSegmentFunction))] +#pragma warning restore CA1416 // Validate platform compatibility +#endif + private static void MarchSegmentFunctionCallback(Vect v0, Vect v1, IntPtr data) + { + var marchData = (MarchData)GCHandle.FromIntPtr(data).Target; + marchData.SegmentFunction(v0, v1, marchData.SegmentData); + } + + private static MarchSegmentFunction segmentFunctionCallback = MarchSegmentFunctionCallback; + +#if (__IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__) +#pragma warning disable CA1416 // Validate platform compatibility + [MonoPInvokeCallback(typeof(MarchSampleFunction))] +#pragma warning restore CA1416 // Validate platform compatibility +#endif + private static double MarchSampleFunctionCallBack(Vect point, IntPtr data) + { + var marchData = (MarchData)GCHandle.FromIntPtr(data).Target; + return marchData.SampleFunction(point, marchData.SampleData); + } + + private static MarchSampleFunction sampleFunctionCallBack = MarchSampleFunctionCallBack; + + /// + /// Trace an aliased curve of an image along a particular threshold. The given number of + /// samples will be taken and spread across the bounding box area using the sampling + /// function and context. The segment function will be called for each segment detected that + /// lies along the density contour for the threshold. Only the SegmentData and SampleData are + /// optional. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static void MarchHard(MarchData data) + { + var gcHandle = GCHandle.Alloc(data); + IntPtr handlePtr = GCHandle.ToIntPtr(gcHandle); + + NativeMethods.cpMarchHard( + data.BoundingBox, + (uint)data.XSamples, + (uint)data.YSamples, + data.Threshold, + segmentFunctionCallback.ToFunctionPointer(), + handlePtr, + sampleFunctionCallBack.ToFunctionPointer(), + handlePtr); + + gcHandle.Free(); + } + + /// + /// Trace an anti-aliased contour of an image along a particular threshold. The given number + /// of samples will be taken and spread across the bounding box area using the sampling + /// function and context. The segment function will be called for each segment detected that + /// lies along the density contour for the threshold. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static void MarchSoft(MarchData data) + { + var gcHandle = GCHandle.Alloc(data); + IntPtr handlePtr = GCHandle.ToIntPtr(gcHandle); + + NativeMethods.cpMarchSoft( + data.BoundingBox, + (uint)data.XSamples, + (uint)data.YSamples, + data.Threshold, + segmentFunctionCallback.ToFunctionPointer(), + handlePtr, + sampleFunctionCallBack.ToFunctionPointer(), + handlePtr); + + gcHandle.Free(); + } + } +} diff --git a/src/Tizen.NUI.Physics2D/src/public/chipmunk/Body.cs b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Body.cs new file mode 100644 index 00000000000..31362da5afc --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Body.cs @@ -0,0 +1,768 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System; +using System.ComponentModel; +using System.Runtime.InteropServices; +using System.Collections.Generic; + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +using ObjCRuntime; +#endif + +using cpBody = System.IntPtr; +using cpArbiter = System.IntPtr; +using cpConstraint = System.IntPtr; +using cpShape = System.IntPtr; +using cpSpace = System.IntPtr; +using cpDataPointer = System.IntPtr; +using System.Diagnostics; + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// Mass and moment are ignored when is + /// or . Guessing the mass for a body is usually fine, but guessing + /// a moment of inertia can lead to a very poor simulation. It’s recommended to use Chipmunk’s + /// moment-calculating functions to estimate the moment for you. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class Body : IDisposable + { +#pragma warning disable IDE0032 + private readonly cpBody body; +#pragma warning restore IDE0032 + + /// + /// The native handle. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public cpBody Handle => body; + + /// + /// Create a Dynamic Body with no mass and no moment. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Body() + : this(BodyType.Dynamic) + { + } + + internal Body(cpBody handle) + { + body = handle; + RegisterUserData(); + } + + /// + /// Create a of the given . + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Body(BodyType type) + { + body = InitializeBody(type); + RegisterUserData(); + } + + /// + /// Creates a body with the given mass and moment. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Body(double mass, double moment) : this(mass, moment, BodyType.Dynamic) + { + } + + /// + /// Creates a body with the given mass and moment, of the give . + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Body(double mass, double moment, BodyType type) + { + body = InitializeBody(type); + NativeMethods.cpBodySetMass(body, mass); + NativeMethods.cpBodySetMoment(body, moment); + RegisterUserData(); + } + + void RegisterUserData() + { + cpDataPointer pointer = NativeInterop.RegisterHandle(this); + NativeMethods.cpBodySetUserData(body, pointer); + } + + void ReleaseUserData() + { + cpDataPointer pointer = NativeMethods.cpBodyGetUserData(body); + NativeInterop.ReleaseHandle(pointer); + } + + /// + /// Get a object from a native cpBody handle. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static Body FromHandle(cpBody body) + { + cpDataPointer handle = NativeMethods.cpBodyGetUserData(body); + return NativeInterop.FromIntPtr(handle); + } + + /// + /// Get the managed object from the native handle. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static Body FromHandleSafe(cpBody nativeBodyHandle) + { + if (nativeBodyHandle == IntPtr.Zero) + { + return null; + } + + return FromHandle(nativeBodyHandle); + } + + private static cpBody InitializeBody(BodyType type) + { + if (type == BodyType.Kinematic) + { + return NativeMethods.cpBodyNewKinematic(); + } + + if (type == BodyType.Static) + { + return NativeMethods.cpBodyNewStatic(); + } + + return NativeMethods.cpBodyNew(0.0, 0.0); + } + + /// + /// Destroy and free the body. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void Free() + { + var space = Space; + + if (space != null) + space.RemoveBody(this); + + ReleaseUserData(); + NativeMethods.cpBodyFree(body); + } + + /// + /// Dispose the body. + /// + protected virtual void Dispose(bool dispose) + { + if (!dispose) + { + Debug.WriteLine("Disposing body {0} on finalizer... (consider Dispose explicitly)", body); + } + + Free(); + } + + /// + /// Dispose the body. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + // Properties + + /// + /// Arbitrary user data. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public object Data { get; set; } + + /// + /// Rotation of the body in radians. When changing the rotation, you may also want to call + /// to update the collision detection information + /// for the attached shapes if you plan to make any queries against the space. A body + /// rotates around its center of gravity, not its position. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Angle + { + get => NativeMethods.cpBodyGetAngle(body); + set => NativeMethods.cpBodySetAngle(body, value); + } + + /// + /// Set body position and rotation angle (in radians) + /// + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetTransform(Vect position, double angle) + { + NativeMethods.cpBodySetTransform(body, position, angle); + } + + /// + /// Get body position and rotation angle (in radians) + /// + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void GetTransform(out Vect position, out double angle) + { + NativeMethods.cpBodyGetTransform(body, out position, out angle); + } + + /// + /// The way the body behaves in physics simulations. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public BodyType Type + { + get => (BodyType)NativeMethods.cpBodyGetType(body); + set => NativeMethods.cpBodySetType(body, (int)value); + } + + /// + /// Mass of the rigid body. Mass does not have to be expressed in any particular units, but + /// relative masses should be consistent. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Mass + { + get => NativeMethods.cpBodyGetMass(body); + set => NativeMethods.cpBodySetMass(body, value); + } + + /// + /// Moment of inertia of the body. The mass tells you how hard it is to push an object, + /// the MoI tells you how hard it is to spin the object. Don't try to guess the MoI, use the + /// MomentFor*() functions to estimate it, or the physics may behave strangely. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Moment + { + get => NativeMethods.cpBodyGetMoment(body); + set => NativeMethods.cpBodySetMoment(body, value); + } + + /// + /// Get the space this body is associated with, or null if it is not currently associated. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Space Space + { + get + { + cpSpace space = NativeMethods.cpBodyGetSpace(body); + return Space.FromHandleSafe(space); + } + } + + /// + /// Position of the body. When changing the position, you may also want to call + /// to update the collision detection information + /// for the attached shapes if you plan to make any queries against the space. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect Position + { + get => NativeMethods.cpBodyGetPosition(body); + set => NativeMethods.cpBodySetPosition(body, value); + } + + /// + /// Location of the center of gravity in body-local coordinates. The default value is + /// (0, 0), meaning the center of gravity is the same as the position of the body. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect CenterOfGravity + { + get => NativeMethods.cpBodyGetCenterOfGravity(body); + set => NativeMethods.cpBodySetCenterOfGravity(body, value); + } + + /// + /// Linear velocity of the center of gravity of the body. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect Velocity + { + get => NativeMethods.cpBodyGetVelocity(body); + set => NativeMethods.cpBodySetVelocity(body, value); + } + + /// + /// Force applied to the center of gravity of the body. This value is reset for every time + /// step. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect Force + { + get => NativeMethods.cpBodyGetForce(body); + set => NativeMethods.cpBodySetForce(body, value); + } + + /// + /// The angular velocity of the body in radians per second. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double AngularVelocity + { + get => NativeMethods.cpBodyGetAngularVelocity(body); + set => NativeMethods.cpBodySetAngularVelocity(body, value); + } + + /// + /// The torque applied to the body. This value is reset for every time step. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Torque + { + get => NativeMethods.cpBodyGetTorque(body); + set => NativeMethods.cpBodySetTorque(body, value); + } + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +#pragma warning disable CA1416 // Validate platform compatibility + [MonoPInvokeCallback(typeof(BodyArbiterIteratorFunction))] +#pragma warning restore CA1416 // Validate platform compatibility +#endif + private static void AddEachArbiterToArray(cpBody body, cpArbiter arbiter, IntPtr data) + { + var list = (List)GCHandle.FromIntPtr(data).Target; + var a = new Arbiter(arbiter); + list.Add(a); + } + + private static BodyArbiterIteratorFunction eachArbiterFunc = AddEachArbiterToArray; + + /// + /// The rotation vector for the body. Can be used with cpvrotate() or cpvunrotate() to perform fast rotations. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect Rotation => NativeMethods.cpBodyGetRotation(body); + + /// + /// Get the list of body Arbiters + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public IReadOnlyList Arbiters + { + get + { + var list = new List(); + var gcHandle = GCHandle.Alloc(list); + NativeMethods.cpBodyEachArbiter(body, eachArbiterFunc.ToFunctionPointer(), GCHandle.ToIntPtr(gcHandle)); + gcHandle.Free(); + return list; + } + } + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +#pragma warning disable CA1416 // Validate platform compatibility + [MonoPInvokeCallback(typeof(BodyArbiterIteratorFunction))] +#pragma warning restore CA1416 // Validate platform compatibility +#endif + private static void AddEachConstraintToArray(cpBody body, cpConstraint constraint, IntPtr data) + { + var list = (List)GCHandle.FromIntPtr(data).Target; + var c = Constraint.FromHandle(constraint); + list.Add(c); + } + + private static BodyConstraintIteratorFunction eachConstraintFunc = AddEachConstraintToArray; + + /// + /// All constraints attached to the body + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public IReadOnlyList Constraints + { + get + { + var list = new List(); + var gcHandle = GCHandle.Alloc(list); + NativeMethods.cpBodyEachConstraint(body, eachConstraintFunc.ToFunctionPointer(), GCHandle.ToIntPtr(gcHandle)); + gcHandle.Free(); + return list.ToArray(); + } + } + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +#pragma warning disable CA1416 // Validate platform compatibility + [MonoPInvokeCallback(typeof(BodyShapeIteratorFunction))] +#pragma warning restore CA1416 // Validate platform compatibility +#endif + private static void AddEachShapeToArray(cpBody body, cpShape shape, IntPtr data) + { + var list = (List)GCHandle.FromIntPtr(data).Target; + var s = Shape.FromHandle(shape); + list.Add(s); + } + + private static BodyShapeIteratorFunction eachShapeFunc = AddEachShapeToArray; + + /// + /// All shapes attached to the body + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public IReadOnlyList Shapes + { + get + { + var list = new List(); + var gcHandle = GCHandle.Alloc(list); + NativeMethods.cpBodyEachShape(body, eachShapeFunc.ToFunctionPointer(), GCHandle.ToIntPtr(gcHandle)); + gcHandle.Free(); + return list.ToArray(); + } + } + + /// + /// Returns true if body is sleeping. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool IsSleeping => NativeMethods.cpBodyIsSleeping(body) != 0; + + // Actions + + /// + /// Reset the idle timer on a body. + /// If it was sleeping, wake it and any other bodies it was touching. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void Activate() => NativeMethods.cpBodyActivate(body); + + /// + /// Similar in function to Activate(). Activates all bodies touching body. If filter is not NULL, then only bodies touching through filter will be awoken. + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void ActivateStatic(Shape filter) => NativeMethods.cpBodyActivateStatic(body, filter.Handle); + + /// + /// Add the local force force to body as if applied from the body local point. + /// + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void ApplyForceAtLocalPoint(Vect force, Vect point) + { + NativeMethods.cpBodyApplyForceAtLocalPoint(body, force, point); + } + + /// + /// Apply torque. + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void ApplyTorque(double torque) + { + NativeMethods.cpBodyApplyTorque(body, torque); + } + + /// + /// Apply angular impulse. + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void ApplyAngularImpulse(double impulse) + { + NativeMethods.cpBodyApplyAngularImpulse(body, impulse); + } + + /// + /// Add the force force to body as if applied from the world point. + /// People are sometimes confused by the difference between a force and an impulse. + /// An impulse is a very large force applied over a very short period of time. + /// Some examples are a ball hitting a wall or cannon firing. + /// Chipmunk treats impulses as if they occur instantaneously by adding directly to the velocity of an object. + /// Both impulses and forces are affected the mass of an object. + /// Doubling the mass of the object will halve the effect. + /// + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void ApplyForceAtWorldPoint(Vect force, Vect point) + { + NativeMethods.cpBodyApplyForceAtWorldPoint(body, force, point); + } + + /// + /// Apply an impulse to a body. Both the impulse and point are expressed in world coordinates. + /// + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void ApplyImpulseAtWorldPoint(Vect impulse, Vect point) + { + NativeMethods.cpBodyApplyImpulseAtWorldPoint(body, impulse, point); + } + + /// + /// Apply an impulse to a body. Both the impulse and point are expressed in body local coordinates. + /// + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void ApplyImpulseAtLocalPoint(Vect impulse, Vect point) + { + NativeMethods.cpBodyApplyImpulseAtLocalPoint(body, impulse, point); + } + + /// + /// Forces a body to fall asleep immediately even if it’s in midair. Cannot be called from a callback. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void Sleep() + { + NativeMethods.cpBodySleep(body); + } + + /// + /// When objects in Chipmunk sleep, they sleep as a group of all objects that are touching or jointed together. + /// When an object is woken up, all of the objects in its group are woken up. + /// SleepWithGroup() allows you group sleeping objects together. It acts identically to Sleep() if you pass null as + /// group by starting a new group. + /// If you pass a sleeping body for group, body will be awoken when group is awoken. + /// You can use this to initialize levels and start stacks of objects in a pre-sleeping state. + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void SleepWithGroup(Body group) + { + NativeMethods.cpBodySleepWithGroup(body, group != null ? group.Handle : IntPtr.Zero); + } + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +#pragma warning disable CA1416 // Validate platform compatibility + [MonoPInvokeCallback(typeof(BodyVelocityFunction))] +#pragma warning restore CA1416 // Validate platform compatibility +#endif + private static void BodyVelocityFunctionCallback(cpBody bodyHandle, Vect gravity, double damping, double dt) + { + var body = FromHandle(bodyHandle); + + body.velocityUpdateFunction(body, gravity, damping, dt); + } + + private static BodyVelocityFunction BodyVelocityFunctionCallbackDelegate = BodyVelocityFunctionCallback; + + private Action velocityUpdateFunction; + /// + /// Set the callback used to update a body's velocity. + /// Parameters: body, gravity, damping and deltaTime + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Action VelocityUpdateFunction + { + get => velocityUpdateFunction; + set + { + velocityUpdateFunction = value; + + IntPtr callbackPointer; + + if (value == null) + callbackPointer = NativeMethods.cpBodyGetDefaultVelocityUpdateFunc(); + else + callbackPointer = BodyVelocityFunctionCallbackDelegate.ToFunctionPointer(); + + NativeMethods.cpBodySetVelocityUpdateFunc(body, callbackPointer); + } + } + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +#pragma warning disable CA1416 // Validate platform compatibility + [MonoPInvokeCallback(typeof(BodyPositionFunction))] +#pragma warning restore CA1416 // Validate platform compatibility +#endif + private static void BodyPositionFunctionCallback(cpBody bodyHandle, double dt) + { + var body = FromHandle(bodyHandle); + + body.positionUpdateFunction(body, dt); + } + + private static BodyPositionFunction BodyUpdateFunctionCallbackDelegate = BodyPositionFunctionCallback; + + private Action positionUpdateFunction; + + /// + /// Set the callback used to update a body's position. + /// Parameters: body, deltaTime + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Action PositionUpdateFunction + { + get => positionUpdateFunction; + set + { + positionUpdateFunction = value; + + IntPtr callbackPointer; + + if (value == null) + callbackPointer = NativeMethods.cpBodyGetDefaultPositionUpdateFunc(); + else + callbackPointer = BodyUpdateFunctionCallbackDelegate.ToFunctionPointer(); + + NativeMethods.cpBodySetPositionUpdateFunc(body, callbackPointer); + } + } + + /// + /// Default velocity integration function.. + /// + /// + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void UpdateVelocity(Vect gravity, double damping, double dt) + { + NativeMethods.cpBodyUpdateVelocity(body, gravity, damping, dt); + } + + /// + /// Default position integration function. + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void UpdatePosition(double dt) + { + NativeMethods.cpBodyUpdatePosition(body, dt); + } + + /// + /// Convert body relative/local coordinates to absolute/world coordinates. + /// + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect LocalToWorld(Vect point) + { + return NativeMethods.cpBodyLocalToWorld(body, point); + } + + /// + /// Convert body absolute/world coordinates to relative/local coordinates. + /// + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect WorldToLocal(Vect point) + { + return NativeMethods.cpBodyWorldToLocal(body, point); + } + + /// + /// Get the velocity on a body (in world units) at a point on the body in world coordinates. + /// + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect GetVelocityAtWorldPoint(Vect point) + { + return NativeMethods.cpBodyGetVelocityAtWorldPoint(body, point); + } + + /// + /// Get the velocity on a body (in world units) at a point on the body in local coordinates. + /// + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect GetVelocityAtLocalPoint(Vect point) + { + return NativeMethods.cpBodyGetVelocityAtLocalPoint(body, point); + } + + /// + /// Get the kinetic energy of a body. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double KineticEnergy => NativeMethods.cpBodyKineticEnergy(body); + + /// + /// Calculate the moment of inertia for a solid box centered on the body. + /// + /// + /// + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static double MomentForBox(double mass, double width, double height) + { + return NativeMethods.cpMomentForBox(mass, width, height); + } + + /// + /// Get the list of all bodies in contact with this one + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public IReadOnlyList AllContactedBodies + { + get + { + int count = NativeMethods.cpBodyGetContactedBodiesCount(body); + int intptrBytes = checked(IntPtr.Size * count); + + if (intptrBytes == 0) + return Array.Empty(); + + IntPtr ptrBodies = Marshal.AllocHGlobal(intptrBytes); + NativeMethods.cpBodyGetUserDataContactedBodies(body, ptrBodies); + + IntPtr[] userDataArray = new IntPtr[count]; + + Marshal.Copy(ptrBodies, userDataArray, 0, count); + + Marshal.FreeHGlobal(ptrBodies); + + Body[] bodies = new Body[count]; + + for (int i = 0; i < count; i++) + { + Body b = NativeInterop.FromIntPtr(userDataArray[i]); + bodies[i] = b; + } + + return bodies; + } + } + + /// + /// Check if a Body is in contact with another + /// + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool ContactWith(Body other) + { + return NativeMethods.cpBodyContactWith(body, other.body) != 0; + } + } +} diff --git a/src/Tizen.NUI.Physics2D/src/public/chipmunk/BodyType.cs b/src/Tizen.NUI.Physics2D/src/public/chipmunk/BodyType.cs new file mode 100644 index 00000000000..ebf2a9314d9 --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/chipmunk/BodyType.cs @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System.ComponentModel; + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// Chipmunk supports three different types of bodies with unique behavioral and performance + /// characteristics. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public enum BodyType + { + /// + /// Dynamic bodies are the default body type. They react to collisions, are affected by + /// forces and gravity, and have a finite amount of mass. These are the type of bodies that + /// you want the physics engine to simulate for you. Dynamic bodies interact with all types + /// of bodies and can generate collision callbacks. + /// + Dynamic, + + /// + /// Kinematic bodies are bodies that are controlled from your code instead of from the + /// physics engine. They aren't affected by gravity and they have an infinite amount of + /// mass, so they don’t react to collisions or forces with other bodies. Kinematic bodies + /// are controlled by setting their velocity, which will cause them to move. Good examples + /// of kinematic bodies might include things like moving platforms. Objects that are + /// touching or jointed to a kinematic body are never allowed to fall asleep. + /// + Kinematic, + + /// + /// Static bodies are bodies that never (or rarely) move. Using static bodies for things + /// like terrain offers a big performance boost over other body types -- Chipmunk doesn't + /// need to check for collisions between static objects and it never needs to update their + /// collision information. Additionally, because static bodies don’t move, Chipmunk knows + /// it’s safe to let objects that are touching or jointed to them fall asleep. Generally, + /// all of your level geometry will be attached to a static body, except for things like + /// moving platforms or doors. Every space provides a built-in static body for your + /// convenience. Static bodies can be moved, but there is a performance penalty as the + /// collision information is recalculated. There is no penalty for having multiple static + /// bodies, and it can be useful in simplifying your code to allow different parts of your + /// static geometry to be initialized or moved separately. + /// + Static + } +} diff --git a/src/Tizen.NUI.Physics2D/src/public/chipmunk/BoundingBox.cs b/src/Tizen.NUI.Physics2D/src/public/chipmunk/BoundingBox.cs new file mode 100644 index 00000000000..99f50d951d4 --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/chipmunk/BoundingBox.cs @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System; +using System.ComponentModel; +using System.Runtime.InteropServices; + +#pragma warning disable IDE1006 +#pragma warning disable IDE0032 + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// Chipmunk's axis-aligned 2D bounding box type. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + [StructLayout(LayoutKind.Sequential)] + public struct BoundingBox : IEquatable + { + private double left; + private double bottom; + private double right; + private double top; + + /// + /// Create a bounding box with the given coordinates. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public BoundingBox(double left, double bottom, double right, double top) + { + this.left = left; + this.bottom = bottom; + this.right = right; + this.top = top; + } + + /// + /// Left value of bounding box. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Left { get => left; set => left = value; } + + /// + /// Bottom value of bouding box. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Bottom { get => bottom; set => bottom = value; } + + /// + /// Right value of bouding box. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Right { get => right; set => right = value; } + + /// + /// Top value of bouding box. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Top { get => top; set => top = value; } + + /// + /// Return true if the dimensions of both bounding boxes are equal to another (within + /// distance of each other.) + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool Equals(BoundingBox other) + { + return Math.Abs(left - other.left) < float.Epsilon && + Math.Abs(bottom - other.bottom) < float.Epsilon && + Math.Abs(right - other.right) < float.Epsilon && + Math.Abs(top - other.top) < float.Epsilon; + } + + /// + /// Return true if the given object is reference-equal. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) + { + var bb = obj as BoundingBox?; + if (bb == null) + { + return false; + } + + return this == bb.Value; + } + + /// + /// Get the bounding box hash code. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() + { + unchecked + { + var hashCode = -1064806749; + +#pragma warning disable RECS0025 // Non-readonly field referenced in 'GetHashCode()' + hashCode = hashCode * -1521134295 + left.GetHashCode(); + hashCode = hashCode * -1521134295 + bottom.GetHashCode(); + hashCode = hashCode * -1521134295 + right.GetHashCode(); + hashCode = hashCode * -1521134295 + top.GetHashCode(); +#pragma warning restore RECS0025 // Non-readonly field referenced in 'GetHashCode()' + + return hashCode; + } + } + + /// + /// Return a string displaying coordinates formatted like (left, bottom, right, top). + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override string ToString() + { + return $"({left},{bottom},{right},{top})"; + } + + /// + /// Return true if the dimensions of both bounding boxes are within + /// of each other. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static bool operator ==(BoundingBox left, BoundingBox right) + { + return left.Equals(right); + } + + /// + /// Return true if the dimensions of both bounding boxes are not within + /// of each other. + /// + /// + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static bool operator !=(BoundingBox left, BoundingBox right) + { + return !(left == right); + } + } +} + +#pragma warning restore IDE1006 +#pragma warning restore IDE0032 diff --git a/src/Tizen.NUI.Physics2D/src/public/chipmunk/CollisionHandler.cs b/src/Tizen.NUI.Physics2D/src/public/chipmunk/CollisionHandler.cs new file mode 100644 index 00000000000..c325a6a1253 --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/chipmunk/CollisionHandler.cs @@ -0,0 +1,341 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System; +using System.ComponentModel; +using System.Diagnostics; +using cpArbiter = System.IntPtr; +using cpBool = System.Byte; +using cpCollisionHandlerPointer = System.IntPtr; +using cpSpace = System.IntPtr; +using voidptr_t = System.IntPtr; + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +using ObjCRuntime; +#endif + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// A collision handler is a set of 4 function callbacks for the different collision events that + /// Chipmunk recognizes. Collision callbacks are closely associated with + /// objects. You should familiarize yourself with those as well. Note #1: Shapes tagged as + /// sensors ( == true) never generate collisions that get processed, + /// so collisions between sensor shapes and other shapes will never call the post_solve() + /// callback. They still generate begin() and separate() callbacks, and the pre_solve() callback + /// is also called every frame even though there is no collision response. Note #2: pre_solve() + /// callbacks are called before the sleeping algorithm runs. If an object falls asleep, its + /// post_solve() callback won’t be called until it’s re-awoken. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public sealed class CollisionHandler + { + private readonly cpCollisionHandlerPointer handle; + + private static CollisionBeginFunction beginCallback = CollisionBeginFunctionCallback; + private static CollisionPreSolveFunction preSolveCallback = CollisionPreSolveFunctionCallback; + private static CollisionPostSolveFunction postSolveCallback = CollisionPostSolveFunctionCallback; + private static CollisionSeparateFunction separeteCallback = CollisionSeparateFunctionCallback; + + private static IntPtr DefaultBeginFunction; + private static IntPtr DefaultPreSolveFunction; + private static IntPtr DefaultPostSolveFunction; + private static IntPtr DefaultSeparateFunction; + + private CollisionHandler(cpCollisionHandlerPointer collisionHandle, ref cpCollisionHandler handler) + { + handle = collisionHandle; + + IntPtr data = NativeInterop.RegisterHandle(this); + + handler.userData = data; + + long typeA = (long)handler.typeA.ToUInt64(); + long typeB = (long)handler.typeB.ToUInt64(); + + TypeA = unchecked((int)typeA); + TypeB = unchecked((int)typeB); + + cpCollisionHandler.ToPointer(handler, handle); + } + + internal static CollisionHandler GetOrCreate(cpCollisionHandlerPointer collisionHandle) + { + Debug.Assert(collisionHandle != IntPtr.Zero, "CollisionHandle cannot be zero"); + + var handler = cpCollisionHandler.FromHandle(collisionHandle); + + if (handler.userData != IntPtr.Zero) + { + return NativeInterop.FromIntPtr(handler.userData); + } + + EnsureDefaultCallbackValues(handler); + + return new CollisionHandler(collisionHandle, ref handler); + } + + private static void EnsureDefaultCallbackValues(cpCollisionHandler handler) + { + if (DefaultBeginFunction != IntPtr.Zero) + return; + + DefaultBeginFunction = handler.beginFunction; + DefaultPreSolveFunction = handler.preSolveFunction; + DefaultPostSolveFunction = handler.postSolveFunction; + DefaultSeparateFunction = handler.separateFunction; + } + + private Action begin; + + /// + /// This function is called when two shapes with types that match this collision handler begin colliding + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Action Begin + { + set + { + begin = value; + + var handler = cpCollisionHandler.FromHandle(handle); + + IntPtr callbackPointer; + + if (value == null) + { + callbackPointer = DefaultBeginFunction; + } + else + { + callbackPointer = beginCallback.ToFunctionPointer(); + } + + handler.beginFunction = callbackPointer; + + cpCollisionHandler.ToPointer(handler, handle); + } + get => begin; + } + + private Func preSolve; + + /// + /// This function is called each step when two shapes with types that match this collision + /// handler are colliding. It's called before the collision solver runs so that you can + /// affect a collision's outcome. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Func PreSolve + { + set + { + preSolve = value; + var handler = cpCollisionHandler.FromHandle(handle); + IntPtr callbackPointer; + + if (value == null) + { + callbackPointer = DefaultPreSolveFunction; + } + else + { + callbackPointer = preSolveCallback.ToFunctionPointer(); + } + + handler.preSolveFunction = callbackPointer; + cpCollisionHandler.ToPointer(handler, handle); + } + get => preSolve; + } + + private Action postSolve; + + /// + /// This function is called each step when two shapes with types that match this collision + /// handler are colliding. It's called after the collision solver runs so that you can read + /// back information about the collision to trigger events in your game. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Action PostSolve + { + set + { + postSolve = value; + var handler = cpCollisionHandler.FromHandle(handle); + IntPtr callbackPointer; + + if (value == null) + { + callbackPointer = DefaultPostSolveFunction; + } + else + { + callbackPointer = postSolveCallback.ToFunctionPointer(); + } + + handler.postSolveFunction = callbackPointer; + cpCollisionHandler.ToPointer(handler, handle); + } + get => postSolve; + } + + private Action separate; + + /// + /// This function is called when two shapes with types that match this collision handler + /// stop colliding. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Action Separate + { + set + { + separate = value; + var handler = cpCollisionHandler.FromHandle(handle); + IntPtr callbackPointer; + + if (value == null) + { + callbackPointer = DefaultSeparateFunction; + } + else + { + callbackPointer = separeteCallback.ToFunctionPointer(); + } + + handler.separateFunction = callbackPointer; + cpCollisionHandler.ToPointer(handler, handle); + } + get => separate; + } + + /// + /// User definable context pointer that is passed to all of the collision handler functions. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public object Data { get; set; } + + /// + /// In the collision handler callback, the shape with this type will be the first argument. + /// Read only. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public int TypeA { get; } + + /// + /// In the collision handler callback, the shape with this type will be the second argument. + /// Read only. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public int TypeB { get; } + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +#pragma warning disable CA1416 // Validate platform compatibility + [MonoPInvokeCallback(typeof(CollisionBeginFunction))] +#pragma warning restore CA1416 // Validate platform compatibility +#endif + private static void CollisionBeginFunctionCallback(cpArbiter arbiterHandle, cpSpace spaceHandle, voidptr_t userData) + { + var arbiter = new Arbiter(arbiterHandle); + var space = Space.FromHandle(spaceHandle); + + var handler = NativeInterop.FromIntPtr(userData); + var begin = handler.Begin; + + if (begin == null) + { + return; + } + + begin(arbiter, space, handler.Data); + } + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +#pragma warning disable CA1416 // Validate platform compatibility + [MonoPInvokeCallback(typeof(CollisionPreSolveFunction))] +#pragma warning restore CA1416 // Validate platform compatibility +#endif + private static cpBool CollisionPreSolveFunctionCallback(cpArbiter arbiterHandle, cpSpace spaceHandle, voidptr_t userData) + { + var arbiter = new Arbiter(arbiterHandle); + var space = Space.FromHandle(spaceHandle); + + var handler = NativeInterop.FromIntPtr(userData); + var preSolve = handler.PreSolve; + + if (preSolve == null) + { + return 1; + } + + if (preSolve(arbiter, space, handler.Data)) + { + return 1; + } + + return 0; + } + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +#pragma warning disable CA1416 // Validate platform compatibility + [MonoPInvokeCallback(typeof(CollisionPostSolveFunction))] +#pragma warning restore CA1416 // Validate platform compatibility +#endif + private static void CollisionPostSolveFunctionCallback(cpArbiter arbiterHandle, cpSpace spaceHandle, voidptr_t userData) + { + var arbiter = new Arbiter(arbiterHandle); + var space = Space.FromHandle(spaceHandle); + + var handler = NativeInterop.FromIntPtr(userData); + var postSolve = handler.PostSolve; + + if (postSolve == null) + { + return; + } + + postSolve(arbiter, space, handler.Data); + } + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +#pragma warning disable CA1416 // Validate platform compatibility + [MonoPInvokeCallback(typeof(CollisionSeparateFunction))] +#pragma warning restore CA1416 // Validate platform compatibility +#endif + private static void CollisionSeparateFunctionCallback(cpArbiter arbiterHandle, cpSpace spaceHandle, voidptr_t userData) + { + var arbiter = new Arbiter(arbiterHandle); + var space = Space.FromHandle(spaceHandle); + + var handler = NativeInterop.FromIntPtr(userData); + var separate = handler.Separate; + + if (separate == null) + { + return; + } + + separate(arbiter, space, handler.Data); + } + } +} diff --git a/src/Tizen.NUI.Physics2D/src/public/chipmunk/Constraints/Constraint.cs b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Constraints/Constraint.cs new file mode 100644 index 00000000000..bf57b7a341e --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Constraints/Constraint.cs @@ -0,0 +1,301 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System; +using System.Diagnostics; +using System.ComponentModel; +using cpBody = System.IntPtr; +using cpConstraint = System.IntPtr; +using cpDataPointer = System.IntPtr; +using cpSpace = System.IntPtr; + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +using ObjCRuntime; +#endif + + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// Base class of all constraints. + /// You usually don’t want to create instances of this class directly, but instead use one of + /// the specific constraints such as the . + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public abstract class Constraint : IDisposable + { +#pragma warning disable IDE0032 + cpConstraint constraint; +#pragma warning restore IDE0032 + + /// + /// Construct a constraint with the given native handle. + /// + /// + internal protected Constraint(cpConstraint handle) + { + constraint = handle; + RegisterUserData(); + } + + /// + /// Native handle to constraint. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public cpConstraint Handle => constraint; + + /// + /// Register managed object to native user data. + /// + private void RegisterUserData() + { + cpDataPointer pointer = NativeInterop.RegisterHandle(this); + NativeMethods.cpConstraintSetUserData(constraint, pointer); + } + + void ReleaseUserData() + { + cpDataPointer pointer = NativeMethods.cpConstraintGetUserData(constraint); + NativeInterop.ReleaseHandle(pointer); + } + + /// + /// Get a Constraint object from a native handle. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static Constraint FromHandle(cpConstraint constraint) + { + cpDataPointer handle = NativeMethods.cpConstraintGetUserData(constraint); + return NativeInterop.FromIntPtr(handle); + } + + /// + /// Dispose the constraint. + /// + protected virtual void Dispose(bool dispose) + { + if (!dispose) + { + Debug.WriteLine("Disposing constraint {0} on finalizer... (consider Dispose explicitly)", constraint); + } + + Free(); + } + + /// + /// Destroy and free the constraint. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void Free() + { + ReleaseUserData(); + NativeMethods.cpConstraintFree(constraint); + } + + /// + /// Destroy the constraint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// Get the cpSpace this constraint is added to. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Space Space + { + get + { + cpSpace space = NativeMethods.cpConstraintGetSpace(constraint); + return Space.FromHandleSafe(space); + } + } + + /// + /// Get the first body the constraint is attached to. + /// + public Body BodyA + { + get + { + cpBody body = NativeMethods.cpConstraintGetBodyA(constraint); + return Body.FromHandleSafe(body); + } + } + + /// + /// Get the second body the constraint is attached to. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Body BodyB + { + get + { + cpBody body = NativeMethods.cpConstraintGetBodyB(constraint); + return Body.FromHandleSafe(body); + } + } + + /// ; + /// The maximum force that this constraint is allowed to use. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double MaxForce + { + get => NativeMethods.cpConstraintGetMaxForce(constraint); + set => NativeMethods.cpConstraintSetMaxForce(constraint, value); + } + + /// + /// Rate at which joint error is corrected. + /// Defaults to pow(1.0 - 0.1, 60.0) meaning that it will + /// correct 10% of the error every 1/60th of a second. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double ErrorBias + { + get => NativeMethods.cpConstraintGetErrorBias(constraint); + set => NativeMethods.cpConstraintSetErrorBias(constraint, value); + } + + + /// + /// The maximum rate at which joint error is corrected. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double MaxBias + { + get => NativeMethods.cpConstraintGetMaxBias(constraint); + set => NativeMethods.cpConstraintSetMaxBias(constraint, value); + } + + /// + /// Whether the two bodies connected by the constraint are allowed to collide or not. + /// + /// When two bodies collide, Chipmunk ignores the collisions if this property is set to + /// False on any constraint that connects the two bodies. Defaults to True. This can be + /// used to create a chain that self-collides, but adjacent links in the chain do not collide. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool CollideBodies + { + get => NativeMethods.cpConstraintGetCollideBodies(constraint) != 0; + set => NativeMethods.cpConstraintSetCollideBodies(constraint, value ? (byte)1 : (byte)0); + } + + private static ConstraintSolveFunction preSolveFunctionCallback = ConstraintPreSolveFunctionCallback; + private static ConstraintSolveFunction postSolveFunctionCallback = ConstraintPostSolveFunctionCallback; + + private Action preSolve; + private Action postSolve; + + /// + /// Pre-solve function that is called before the solver runs. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Action PreSolve + { + get => preSolve; + set + { + preSolve = value; + + IntPtr callbackPointer; + + if (value == null) + callbackPointer = IntPtr.Zero; + else + callbackPointer = preSolveFunctionCallback.ToFunctionPointer(); + + NativeMethods.cpConstraintSetPreSolveFunc(constraint, callbackPointer); + } + } + + /// + /// Post-solve function that is called after the solver runs. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Action PostSolve + { + get => postSolve; + set + { + postSolve = value; + + IntPtr callbackPointer; + + if (value == null) + callbackPointer = IntPtr.Zero; + else + callbackPointer = postSolveFunctionCallback.ToFunctionPointer(); + + NativeMethods.cpConstraintSetPostSolveFunc(constraint, callbackPointer); + } + } + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +#pragma warning disable CA1416 // Validate platform compatibility + [MonoPInvokeCallback(typeof(ConstraintSolveFunction))] +#pragma warning restore CA1416 // Validate platform compatibility +#endif + private static void ConstraintPreSolveFunctionCallback(cpConstraint constraintHandle, cpSpace spaceHandle) + { + var constraint = Constraint.FromHandle(constraintHandle); + var space = Space.FromHandle(spaceHandle); + + Action preSolve = constraint.PreSolve; + + preSolve(constraint, space); + } + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +#pragma warning disable CA1416 // Validate platform compatibility + [MonoPInvokeCallback(typeof(ConstraintSolveFunction))] +#pragma warning restore CA1416 // Validate platform compatibility +#endif + private static void ConstraintPostSolveFunctionCallback(cpConstraint constraintHandle, cpSpace spaceHandle) + { + var constraint = Constraint.FromHandle(constraintHandle); + var space = Space.FromHandle(spaceHandle); + + Action postSolve = constraint.PostSolve; + + postSolve(constraint, space); + } + + /// + /// The user-definable data pointer for this constraint. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public object Data { get; set; } + + /// + /// Get the last impulse applied by this constraint. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Impulse => NativeMethods.cpConstraintGetImpulse(constraint); + } +} diff --git a/src/Tizen.NUI.Physics2D/src/public/chipmunk/Constraints/DampedRotarySpring.cs b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Constraints/DampedRotarySpring.cs new file mode 100644 index 00000000000..44ad728aaac --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Constraints/DampedRotarySpring.cs @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System; +using System.ComponentModel; + +using cpConstraint = System.IntPtr; + + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +using ObjCRuntime; +#endif + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// DampedRotarySpring works like , but in an angular fashion. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class DampedRotarySpring : Constraint + { + /// + /// Check if a constraint is a . + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static bool IsDampedRotarySpring(Constraint constraint) => NativeMethods.cpConstraintIsDampedRotarySpring(constraint.Handle) != 0; + + /// + /// Create a damped rotary spring. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public DampedRotarySpring( + Body bodyA, + Body bodyB, + double restAngle, + double stiffness, + double damping) + : base( + NativeMethods.cpDampedRotarySpringNew( + bodyA.Handle, + bodyB.Handle, + restAngle, + stiffness, + damping)) + { + originalTorqueCallbackPointer = NativeMethods.cpDampedRotarySpringGetSpringTorqueFunc(Handle); + } + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +#pragma warning disable CA1416 // Validate platform compatibility + [MonoPInvokeCallback(typeof(DampedRotarySpringTorqueFunction))] +#pragma warning restore CA1416 // Validate platform compatibility +#endif + private static double DampedRotarySpringTorqueCallback(cpConstraint springHandle, double relativeAngle) + { + var constraint = (DampedRotarySpring)FromHandle(springHandle); + + Func dampedRotarySpringTorqueFunction = constraint.TorqueFunction; + + return dampedRotarySpringTorqueFunction(constraint, relativeAngle); + } + + private static DampedRotarySpringTorqueFunction DampedRotarySpringForceCallback = DampedRotarySpringTorqueCallback; + + /// + /// The rest angle of the spring. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double RestAngle + { + get => NativeMethods.cpDampedRotarySpringGetRestAngle(Handle); + set => NativeMethods.cpDampedRotarySpringSetRestAngle(Handle, value); + } + + /// + /// The stiffness of the spring in force/distance. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Stiffness + { + get => NativeMethods.cpDampedRotarySpringGetStiffness(Handle); + set => NativeMethods.cpDampedRotarySpringSetStiffness(Handle, value); + } + + /// + /// The damping of the spring. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Damping + { + get => NativeMethods.cpDampedRotarySpringGetDamping(Handle); + set => NativeMethods.cpDampedRotarySpringSetDamping(Handle, value); + } + + private Func torqueFunction; + private IntPtr originalTorqueCallbackPointer; + + /// + /// Damped rotary spring torque custom function callback. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Func TorqueFunction + { + get => torqueFunction; + set + { + torqueFunction = value; + + IntPtr callbackPointer; + + if (value == null) + { + callbackPointer = originalTorqueCallbackPointer; + } + else + { + callbackPointer = DampedRotarySpringForceCallback.ToFunctionPointer(); + } + + NativeMethods.cpDampedRotarySpringSetSpringTorqueFunc(Handle, callbackPointer); + } + } + } +} diff --git a/src/Tizen.NUI.Physics2D/src/public/chipmunk/Constraints/DampedSpring.cs b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Constraints/DampedSpring.cs new file mode 100644 index 00000000000..9ffa3233f7a --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Constraints/DampedSpring.cs @@ -0,0 +1,175 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System; +using System.ComponentModel; + +using cpConstraint = System.IntPtr; + + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +using ObjCRuntime; +#endif + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// is a damped spring. + /// The spring allows you to define the rest length, stiffness and damping. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class DampedSpring : Constraint + { + /// + /// Check if a constraint is a . + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static bool IsDampedSpring(Constraint constraint) => NativeMethods.cpConstraintIsDampedSpring(constraint.Handle) != 0; + + /// + /// Defined much like a slide joint. + /// + /// The first connected body. + /// The second connected body. + /// Anchor point a, relative to body a. + /// Anchor point b, relative to body b. + /// The distance the spring wants to be. + /// The spring constant (Young’s modulus). + /// How soft to make the damping of the spring. + [EditorBrowsable(EditorBrowsableState.Never)] + public DampedSpring( + Body bodyA, + Body bodyB, + Vect anchorA, + Vect anchorB, + double restLength, + double stiffness, + double damping) + : base(NativeMethods.cpDampedSpringNew( + bodyA.Handle, + bodyB.Handle, + anchorA, + anchorB, + restLength, + stiffness, + damping)) + { + originalForceCallbackPointer = NativeMethods.cpDampedSpringGetSpringForceFunc(Handle); + } + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +#pragma warning disable CA1416 // Validate platform compatibility + [MonoPInvokeCallback(typeof(DampedSpringForceFunction))] +#pragma warning restore CA1416 // Validate platform compatibility +#endif + private static double DampedSpringForceCallback(cpConstraint springHandle, double distance) + { + var constraint = (DampedSpring)Constraint.FromHandle(springHandle); + + Func dampedSpringForceFunction = constraint.forceFunction; + + return dampedSpringForceFunction(constraint, distance); + } + + private static DampedSpringForceFunction dampedSpringForceCallback = DampedSpringForceCallback; + + /// + /// The location of the first anchor relative to the first body. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect AnchorA + { + get => NativeMethods.cpDampedSpringGetAnchorA(Handle); + set => NativeMethods.cpDampedSpringSetAnchorA(Handle, value); + } + + /// + /// The location of the second anchor relative to the second body. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect AnchorB + { + get => NativeMethods.cpDampedSpringGetAnchorB(Handle); + set => NativeMethods.cpDampedSpringSetAnchorB(Handle, value); + } + + /// + /// The rest length of the spring. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double RestLength + { + get => NativeMethods.cpDampedSpringGetRestLength(Handle); + set => NativeMethods.cpDampedSpringSetRestLength(Handle, value); + } + + /// + /// The stiffness of the spring in force/distance. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Stiffness + { + get => NativeMethods.cpDampedSpringGetStiffness(Handle); + set => NativeMethods.cpDampedSpringSetStiffness(Handle, value); + } + + /// + /// The damping of the spring. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Damping + { + get => NativeMethods.cpDampedSpringGetDamping(Handle); + set => NativeMethods.cpDampedSpringSetDamping(Handle, value); + } + + private Func forceFunction; + + private IntPtr originalForceCallbackPointer; + + /// + /// Damped spring force custom function callback. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Func ForceFunction + { + get => forceFunction; + set + { + forceFunction = value; + + IntPtr callbackPointer; + + if (value == null) + { + callbackPointer = originalForceCallbackPointer; + } + else + { + callbackPointer = dampedSpringForceCallback.ToFunctionPointer(); + } + + NativeMethods.cpDampedSpringSetSpringForceFunc(Handle, callbackPointer); + } + } + } +} diff --git a/src/Tizen.NUI.Physics2D/src/public/chipmunk/Constraints/GearJoint.cs b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Constraints/GearJoint.cs new file mode 100644 index 00000000000..601342ea6d6 --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Constraints/GearJoint.cs @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System.ComponentModel; + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// keeps the angular velocity ratio of a pair of bodies constant. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class GearJoint : Constraint + { + /// + /// Check if a constraint is a . + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static bool IsGearJoint(Constraint constraint) => NativeMethods.cpConstraintIsGearJoint(constraint.Handle) != 0; + + /// + /// Keeps the angular velocity ratio of a pair of bodies constant. + /// + /// The first connected body. + /// The second connected body. + /// The seconded connected body. + /// + /// Measured in absolute terms. It is currently not possible to set + /// the ratio in relation to a third body’s angular velocity. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public GearJoint(Body bodyA, Body bodyB, double phase, double ratio) : + base(NativeMethods.cpGearJointNew(bodyA.Handle, bodyB.Handle, phase, ratio)) + { + } + + /// + /// The phase offset of the gears. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Phase + { + get => NativeMethods.cpGearJointGetPhase(Handle); + set => NativeMethods.cpGearJointSetPhase(Handle, value); + } + + /// + /// The ratio of a gear joint. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Ratio + { + get => NativeMethods.cpGearJointGetRatio(Handle); + set => NativeMethods.cpGearJointSetRatio(Handle, value); + } + } +} diff --git a/src/Tizen.NUI.Physics2D/src/public/chipmunk/Constraints/GrooveJoint.cs b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Constraints/GrooveJoint.cs new file mode 100644 index 00000000000..e295b31645f --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Constraints/GrooveJoint.cs @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System.ComponentModel; + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// is similar to a , but with a linear slide. + /// One of the anchor points is a line segment that the pivot can slide on instead of being fixed. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class GrooveJoint : Constraint + { + /// + /// Check if a constraint is a . + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static bool IsGrooveJoint(Constraint constraint) => NativeMethods.cpConstraintIsGrooveJoint(constraint.Handle) != 0; + + /// + /// Create an anchor where can rotate similar to a + /// , except it's anchored at , which is a + /// point that can slide between and . + /// + /// The first connected body. + /// The second connected body. + /// + /// The start of the groove on . Coordinates are local to the body. + /// + /// + /// The end of the groove on . Coordinates are local to the body. + /// + /// + /// The location of the pivot on . Coordinates are local to the + /// body. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public GrooveJoint(Body bodyA, Body bodyB, Vect grooveA, Vect grooveB, Vect anchorB) + : base(NativeMethods.cpGrooveJointNew(bodyA.Handle, bodyB.Handle, grooveA, grooveB, anchorB)) + { + } + + /// + /// The first endpoint of the groove relative to the first body. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect GrooveA + { + get => NativeMethods.cpGrooveJointGetGrooveA(Handle); + set => NativeMethods.cpGrooveJointSetGrooveA(Handle, value); + } + + /// + /// The second endpoint of the groove relative to the first body. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect GrooveB + { + get => NativeMethods.cpGrooveJointGetGrooveB(Handle); + set => NativeMethods.cpGrooveJointSetGrooveB(Handle, value); + } + + /// + /// The location of the second anchor relative to the second body. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect AnchorB + { + get => NativeMethods.cpGrooveJointGetAnchorB(Handle); + set => NativeMethods.cpGrooveJointSetAnchorB(Handle, value); + } + } +} diff --git a/src/Tizen.NUI.Physics2D/src/public/chipmunk/Constraints/PinJoint.cs b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Constraints/PinJoint.cs new file mode 100644 index 00000000000..f0f9e943d74 --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Constraints/PinJoint.cs @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System.ComponentModel; + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// links shapes with a solid bar or pin. Keeps the anchor points at a + /// set distance from one another. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class PinJoint : Constraint + { + /// + /// Check if a constraint is a . + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static bool IsPinJoint(Constraint constraint) => NativeMethods.cpConstraintIsPinJoint(constraint.Handle) != 0; + + /// + /// The distance between the two anchor points is measured when the joint is created. If you + /// want to set a specific distance, use the setter function to override it. + /// + /// One of the two bodies to connect. + /// One of the two bodies to connect. + /// The anchor point for . + /// The anchor point for . + [EditorBrowsable(EditorBrowsableState.Never)] + public PinJoint(Body bodyA, Body bodyB, Vect anchorA, Vect anchorB) + : base(NativeMethods.cpPinJointNew(bodyA.Handle, bodyB.Handle, anchorA, anchorB)) + { + } + + /// + /// The location of the first anchor relative to the first body. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect AnchorA + { + get => NativeMethods.cpPinJointGetAnchorA(Handle); + set => NativeMethods.cpPinJointSetAnchorA(Handle, value); + } + + /// + /// The location of the second anchor relative to the second body. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect AnchorB + { + get => NativeMethods.cpPinJointGetAnchorB(Handle); + set => NativeMethods.cpPinJointSetAnchorB(Handle, value); + } + + /// + /// The distance the joint will maintain between the two anchors. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Distance + { + get => NativeMethods.cpPinJointGetDist(Handle); + set => NativeMethods.cpPinJointSetDist(Handle, value); + } + } +} diff --git a/src/Tizen.NUI.Physics2D/src/public/chipmunk/Constraints/PivotJoint.cs b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Constraints/PivotJoint.cs new file mode 100644 index 00000000000..de7a9bdffb1 --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Constraints/PivotJoint.cs @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System.ComponentModel; + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// acts like a swivel, allowing two objects to pivot about a single + /// point. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class PivotJoint : Constraint + { + /// + /// Check if a constraint is a . + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static bool IsPivotJoint(Constraint constraint) => NativeMethods.cpConstraintIsPivotJoint(constraint.Handle) != 0; + + /// + /// Initialize a pivot joint with two anchors. Since the anchors are provided in world + /// coordinates, the bodies must already be correctly positioned. The joint is fixed as soon + /// as the containing space is simulated. + /// + /// One of the two bodies to connect. + /// One of the two bodies to connect. + /// + /// The location of one of the anchors, specified in world coordinates. + /// + /// + /// The location of one of the anchors, specified in world coordinates. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public PivotJoint(Body bodyA, Body bodyB, Vect anchorA, Vect anchorB) + : base(NativeMethods.cpPivotJointNew2(bodyA.Handle, bodyB.Handle, anchorA, anchorB)) + { + } + + /// + /// Initialize a pivot joint with one anchor. Since the pivot is provided in world + /// coordinates, the bodies must already be correctly positioned. + /// + /// One of the two bodies to connect. + /// One of the two bodies to connect. + /// The location of the pivot, specified in world coordinates. + [EditorBrowsable(EditorBrowsableState.Never)] + public PivotJoint(Body bodyA, Body bodyB, Vect anchor) : + base(NativeMethods.cpPivotJointNew(bodyA.Handle, bodyB.Handle, anchor)) + { + + } + + /// + /// The location of the first anchor relative to the first body. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect AnchorA + { + get => NativeMethods.cpPivotJointGetAnchorA(Handle); + set => NativeMethods.cpPivotJointSetAnchorA(Handle, value); + } + + /// + /// The location of the second anchor relative to the second body. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect AnchorB + { + get => NativeMethods.cpPivotJointGetAnchorB(Handle); + set => NativeMethods.cpPivotJointSetAnchorB(Handle, value); + } + + } +} diff --git a/src/Tizen.NUI.Physics2D/src/public/chipmunk/Constraints/RatchetJoint.cs b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Constraints/RatchetJoint.cs new file mode 100644 index 00000000000..4c368ac6114 --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Constraints/RatchetJoint.cs @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System.ComponentModel; + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// is a rotary ratchet, which works like a socket wrench. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class RatchetJoint : Constraint + { + /// + /// Check if a constraint is a . + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static bool IsRatchetJoint(Constraint constraint) => NativeMethods.cpConstraintIsRatchetJoint(constraint.Handle) != 0; + + /// + /// Works like a socket wrench. + /// + /// One of the two bodies to connect. + /// One of the two bodies to connect. + /// + /// The initial offset to use when deciding where the ratchet angles are. + /// + /// + /// The distance between "clicks" (following the socket wrench analogy). + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public RatchetJoint(Body bodyA, Body bodyB, double phase, double ratchet) + : base(NativeMethods.cpRatchetJointNew(bodyA.Handle, bodyB.Handle, phase, ratchet)) + { + } + + /// + /// The angle of the current ratchet tooth. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Angle + { + get => NativeMethods.cpRatchetJointGetAngle(Handle); + set => NativeMethods.cpRatchetJointSetAngle(Handle, value); + } + + /// + /// The phase offset of the ratchet. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Phase + { + get => NativeMethods.cpRatchetJointGetPhase(Handle); + set => NativeMethods.cpRatchetJointSetPhase(Handle, value); + } + + /// + /// The angular distance of each ratchet. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Rachet + { + get => NativeMethods.cpRatchetJointGetRatchet(Handle); + set => NativeMethods.cpRatchetJointSetRatchet(Handle, value); + } + } +} diff --git a/src/Tizen.NUI.Physics2D/src/public/chipmunk/Constraints/RotaryLimitJoint.cs b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Constraints/RotaryLimitJoint.cs new file mode 100644 index 00000000000..16b6fa174e0 --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Constraints/RotaryLimitJoint.cs @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System.ComponentModel; + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// constrains the relative rotations of two bodies. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class RotaryLimitJoint : Constraint + { + /// + /// Check if a constraint is a . + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static bool IsRotaryLimitJoint(Constraint constraint) => NativeMethods.cpConstraintIsRotaryLimitJoint(constraint.Handle) != 0; + + /// + /// Constrains the relative rotations of two bodies. + /// + /// + /// + /// + /// The minimum angular limit in radians. May be greater than 1 backwards revolution. + /// + /// + /// The maximum angular limit in radians. May be greater than 1 revolution. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public RotaryLimitJoint(Body bodyA, Body bodyB, double mininum, double maximum) + : base(NativeMethods.cpRotaryLimitJointNew(bodyA.Handle, bodyB.Handle, mininum, maximum)) + { + } + + /// + /// The minimum distance the joint will maintain between the two anchors. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Minimum + { + get => NativeMethods.cpRotaryLimitJointGetMin(Handle); + set => NativeMethods.cpRotaryLimitJointSetMin(Handle, value); + } + + /// + /// The maximum distance the joint will maintain between the two anchors. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Maximum + { + get => NativeMethods.cpRotaryLimitJointGetMax(Handle); + set => NativeMethods.cpRotaryLimitJointSetMax(Handle, value); + } + } +} diff --git a/src/Tizen.NUI.Physics2D/src/public/chipmunk/Constraints/SimpleMotor.cs b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Constraints/SimpleMotor.cs new file mode 100644 index 00000000000..a8c2d8011d5 --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Constraints/SimpleMotor.cs @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System.ComponentModel; + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// keeps the relative angular velocity constant. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class SimpleMotor : Constraint + { + /// + /// Check if constraint is a . + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static bool IsSimpleMotor(Constraint constraint) => NativeMethods.cpConstraintIsSimpleMotor(constraint.Handle) != 0; + + /// + /// Rotate with a constant relative angular velocity constant between two bodies. + /// + /// One of the two bodies. + /// One of the two bodies. + /// The rate of rotation. + [EditorBrowsable(EditorBrowsableState.Never)] + public SimpleMotor(Body bodyA, Body bodyB, double rate) + : base(NativeMethods.cpSimpleMotorNew(bodyA.Handle, bodyB.Handle, rate)) + { + } + + /// + /// The rate of the motor. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Rate + { + get => NativeMethods.cpSimpleMotorGetRate(Handle); + set => NativeMethods.cpSimpleMotorSetRate(Handle, value); + } + } +} diff --git a/src/Tizen.NUI.Physics2D/src/public/chipmunk/Constraints/SlideJoint.cs b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Constraints/SlideJoint.cs new file mode 100644 index 00000000000..9b4681f0ec6 --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Constraints/SlideJoint.cs @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System.ComponentModel; + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// is like a , but with a minimum and maximum + /// distance. A chain could be modeled using this joint. It keeps the anchor points from getting + /// too far apart, but will allow them to get closer together. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class SlideJoint : Constraint + { + /// + /// Check if a constraint is a . + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static bool IsSlideJoint(Constraint constraint) => NativeMethods.cpConstraintIsSlideJoint(constraint.Handle) != 0; + + /// + /// Create a slide constraint between two bodies. + /// + /// One of the two bodies to connect. + /// One of the two bodies to connect. + /// The anchor point for . + /// The anchor point for . + /// The minimum distance the anchor points can get to each other. + /// The maximum distance the anchor points can be apart. + [EditorBrowsable(EditorBrowsableState.Never)] + public SlideJoint(Body bodyA, Body bodyB, Vect anchorA, Vect anchorB, double min, double max) + : base(NativeMethods.cpSlideJointNew(bodyA.Handle, bodyB.Handle, anchorA, anchorB, min, max)) + { + } + + /// + /// The location of the first anchor relative to the first body. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect AnchorA + { + get => NativeMethods.cpSlideJointGetAnchorA(Handle); + set => NativeMethods.cpSlideJointSetAnchorA(Handle, value); + } + + /// + /// The location of the second anchor relative to the second body. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect AnchorB + { + get => NativeMethods.cpSlideJointGetAnchorB(Handle); + set => NativeMethods.cpSlideJointSetAnchorB(Handle, value); + } + + /// + /// The minimum distance the joint will maintain between the two anchors + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Minimum + { + get => NativeMethods.cpSlideJointGetMin(Handle); + set => NativeMethods.cpSlideJointSetMin(Handle, value); + } + + /// + /// The maximum distance the joint will maintain between the two anchors. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Maximum + { + get => NativeMethods.cpSlideJointGetMax(Handle); + set => NativeMethods.cpSlideJointSetMax(Handle, value); + } + } +} diff --git a/src/Tizen.NUI.Physics2D/src/public/chipmunk/ContactPoint.cs b/src/Tizen.NUI.Physics2D/src/public/chipmunk/ContactPoint.cs new file mode 100644 index 00000000000..dcd5c08f24f --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/chipmunk/ContactPoint.cs @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System; +using System.ComponentModel; + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// Contains information about a contact point. and + /// are the contact positions on the surface of each shape. is the + /// penetration distance of the two, which is a negative value. This value is calculated as + /// dot(point2 - point1), normal) and is ignored when you set the + /// . + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public sealed class ContactPoint : IEquatable + { +#pragma warning disable IDE0032 + private readonly Vect pointA; + private readonly Vect pointB; + private readonly double distance; +#pragma warning restore IDE0032 + + /// + /// Point A in the contact point. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect PointA => pointA; + + /// + /// Point B in the contact point. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect PointB => pointB; + + /// + /// The penetration distance of the two shapes (as a negative value). This value is + /// calculated as dot(point2 - point1), normal) and is ignored when you set the + /// . + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Distance => distance; + + private ContactPoint(Vect pointA, Vect pointB, double distance) + { + this.pointA = pointA; + this.pointB = pointB; + this.distance = distance; + } + + /// + /// Returns true if neither is null and the points are within + /// distance of each other. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool Equals(ContactPoint other) + { + if (ReferenceEquals(other, null)) + { + return false; + } + + return other.pointA.Equals(pointA) + && other.pointB.Equals(pointB) + && Math.Abs(other.distance - distance) < float.Epsilon; + } + + + /// + /// Check if this is equal to an object. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) + { + var other = obj as ContactPoint; + + if (other == null) + { + return false; + } + + return Equals(other); + } + + /// + /// Get the hash set. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() + { + unchecked + { + var hashCode = -1285340573; + + hashCode = hashCode * -1521134295 + pointA.GetHashCode(); + hashCode = hashCode * -1521134295 + pointB.GetHashCode(); + hashCode = hashCode * -1521134295 + distance.GetHashCode(); + + return hashCode; + } + } + + /// + /// Returns a string in the format of "a: {pointA}, b: {pointB}, distance: {distance}". + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override string ToString() + { + return $"a: {pointA}, b: {pointB}, distance: {distance}"; + } + + /// + /// Returns true if both s are the same object or the dimensions + /// are within distance of each other. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static bool operator ==(ContactPoint left, ContactPoint right) + { + if (ReferenceEquals(left, null)) + { + return ReferenceEquals(right, null); + } + + return left.Equals(right); + } + + /// + /// Returns false if both s are the same object or the dimensions + /// are within distance of each other. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static bool operator !=(ContactPoint left, ContactPoint right) + { + return !(left == right); + } + + internal static ContactPoint Empty => new ContactPoint(Vect.Zero, Vect.Zero, 0.0); + + internal static ContactPoint FromCollidePoint(cpContactPoint contactPoint) + { + return new ContactPoint( + contactPoint.pointA, + contactPoint.pointB, + contactPoint.distance); + } + + internal cpContactPoint ToContactPoint() + { + return new cpContactPoint + { + pointA = pointA, + pointB = pointB, + distance = distance + }; + } + } +} diff --git a/src/Tizen.NUI.Physics2D/src/public/chipmunk/ContactPointSet.cs b/src/Tizen.NUI.Physics2D/src/public/chipmunk/ContactPointSet.cs new file mode 100644 index 00000000000..f5697096665 --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/chipmunk/ContactPointSet.cs @@ -0,0 +1,181 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// Contact point sets make getting contact information simpler. There can be at most 2 contact + /// points. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public sealed class ContactPointSet : IEquatable + { +#pragma warning disable IDE0032 + private readonly int count; + private readonly Vect normal; + private readonly ContactPoint[] points; +#pragma warning restore IDE0032 + + private ContactPointSet(int count, Vect normal, ContactPoint[] points) + { + this.count = count; + this.normal = normal; + this.points = points; + } + + /// + /// Get the number of contact points in the contact set (maximum of two). + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public int Count => count; + + /// + /// Get the normal of the collision. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect Normal => normal; + + /// + /// List of points in the contact point set + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public IReadOnlyList Points => points; + + /// + /// Return true if the contact point set is sequence-equal to another. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool Equals(ContactPointSet other) + { + if (ReferenceEquals(other, null) + || count != other.count + || normal != other.normal + || points.Length != other.points.Length) + { + return false; + } + + return points.SequenceEqual(other.points); + } + + /// + /// Get the hash code. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() + { + unchecked + { + var hashCode = -475635172; + + hashCode = hashCode * -1521134295 + count.GetHashCode(); + hashCode = hashCode * -1521134295 + normal.GetHashCode(); + hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(points); + + return hashCode; + } + } + + /// + /// Return true if the is sequence-equal to another. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) + { + var other = obj as ContactPointSet; + + if (other == null) + { + return false; + } + + return Equals(other); + } + + /// + /// Return true if the contact point sets are sequence-equal. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static bool operator ==(ContactPointSet left, ContactPointSet right) + { + if (ReferenceEquals(left, null)) + { + return ReferenceEquals(right, null); + } + + return left.Equals(right); + } + + /// + /// Return true if the contact point sets are sequence-inequal. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static bool operator !=(ContactPointSet left, ContactPointSet right) + { + return !(left == right); + } + + internal static ContactPointSet FromContactPointSet(cpContactPointSet contactPointSet) + { + var points = new ContactPoint[2]; + + if (contactPointSet.count > 0) + { + points[0] = ContactPoint.FromCollidePoint(contactPointSet.points0); + } + else + { + points[0] = ContactPoint.Empty; + } + + if (contactPointSet.count > 1) + { + points[1] = ContactPoint.FromCollidePoint(contactPointSet.points1); + } + else + { + points[1] = ContactPoint.Empty; + } + + return new ContactPointSet( + contactPointSet.count, + contactPointSet.normal, + points); + } + + internal cpContactPointSet ToContactPointSet() + { + return new cpContactPointSet + { + normal = normal, + points0 = points[0].ToContactPoint(), + points1 = points[1].ToContactPoint(), + count = count + }; + } + } +} diff --git a/src/Tizen.NUI.Physics2D/src/public/chipmunk/DebugColor.cs b/src/Tizen.NUI.Physics2D/src/public/chipmunk/DebugColor.cs new file mode 100644 index 00000000000..90ad56fd615 --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/chipmunk/DebugColor.cs @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System; +using System.ComponentModel; +using System.Runtime.InteropServices; + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// RGBA channels as floats used to represent the color for debug drawing. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + [StructLayout(LayoutKind.Sequential)] + public struct DebugColor : IEquatable + { +#pragma warning disable IDE0032 + private readonly float red; + private readonly float green; + private readonly float blue; + private readonly float alpha; +#pragma warning restore IDE0032 + + /// + /// Red component in the RGBA color space. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public float Red => red; + + /// + /// Green component in the RGBA color space. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public float Green => green; + + /// + /// Blue component in the RGBA color space. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public float Blue => blue; + + /// + /// Alpha component in the RGBA color space. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public float Alpha => alpha; + + /// + /// Create a with the given color channel values. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public DebugColor(float red, float green, float blue) + : this(red, green, blue, 1.0f) + { + } + + /// + /// Create a with the given color channel values. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public DebugColor(float red, float green, float blue, float alpha) + { + this.red = red; + this.green = green; + this.blue = blue; + this.alpha = alpha; + } + + /// + /// Check if a is equal to another object. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) + { + var other = obj as DebugColor?; + + if (other == null) + return false; + + return Equals(other.Value); + } + + /// + /// Check if a is reference-equal to the other. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool Equals(DebugColor color) + { + return this == color; + } + + /// + /// Get the hash code. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() + { + unchecked + { + var hashCode = -1813971818; + + hashCode = hashCode * -1521134295 + red.GetHashCode(); + hashCode = hashCode * -1521134295 + green.GetHashCode(); + hashCode = hashCode * -1521134295 + blue.GetHashCode(); + hashCode = hashCode * -1521134295 + alpha.GetHashCode(); + + return hashCode; + } + } + + /// + /// Return a string formatted as "(R, G, B, A)". + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override string ToString() + { + return $"({red},{green},{blue},{alpha})"; + } + + /// + /// Return true if two are reference-equal. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static bool operator ==(DebugColor a, DebugColor b) + { +#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator + return a.red == b.red && + a.green == b.green && + a.blue == b.blue && + a.alpha == b.alpha; +#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator + } + + + /// + /// Return true if two are not reference-equal. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static bool operator !=(DebugColor a, DebugColor b) + { + return !(a == b); + } + } +} diff --git a/src/Tizen.NUI.Physics2D/src/public/chipmunk/DebugDrawColors.cs b/src/Tizen.NUI.Physics2D/src/public/chipmunk/DebugDrawColors.cs new file mode 100644 index 00000000000..a64e7eadcc6 --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/chipmunk/DebugDrawColors.cs @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System.ComponentModel; + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// Default DebugColors for ShapeOutline, Constraint and CollisionPoint + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class DebugDrawColors + { +#pragma warning disable IDE0032 + static readonly DebugDrawColors defaultColors = new DebugDrawColors() + { + ShapeOutline = new DebugColor(1, 1, 1), + Constraint = new DebugColor(0, 1, 0), + CollisionPoint = new DebugColor(1, 0, 1) + }; +#pragma warning restore IDE0032 + + /// + /// Shape outline color. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public DebugColor ShapeOutline { get; set; } + + /// + /// Constraint color. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public DebugColor Constraint { get; set; } + + /// + /// Collision point color. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public DebugColor CollisionPoint { get; set; } + + /// + /// The Default DebugDrawColors. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static DebugDrawColors Default => defaultColors; + + } +} diff --git a/src/Tizen.NUI.Physics2D/src/public/chipmunk/DebugDrawFlags.cs b/src/Tizen.NUI.Physics2D/src/public/chipmunk/DebugDrawFlags.cs new file mode 100644 index 00000000000..31e13c98248 --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/chipmunk/DebugDrawFlags.cs @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System; +using System.ComponentModel; + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// Flags to enable or disable DebugDrawing. + /// + [Flags] + [EditorBrowsable(EditorBrowsableState.Never)] + public enum DebugDrawFlags + { + /// + /// Draw nothing. + /// + None = 0, + + /// + /// Draw Shapes. + /// + Shapes = 1 << 0, + + /// + /// Draw Constraints. + /// + Constraints = 1 << 1, + + /// + /// Draw Collision Points. + /// + CollisionPoints = 1 << 2, + + /// + /// Draw All. + /// + All = Shapes | Constraints | CollisionPoints + } +} diff --git a/src/Tizen.NUI.Physics2D/src/public/chipmunk/HastySpace.cs b/src/Tizen.NUI.Physics2D/src/public/chipmunk/HastySpace.cs new file mode 100644 index 00000000000..5c0e1cea1f9 --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/chipmunk/HastySpace.cs @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System; +using System.ComponentModel; + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// Similar to , but with ARM NEON optimizations in the solver. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public sealed class HastySpace : Space + { + /// + /// On ARM platforms that support NEON, this will enable the vectorized solver. + /// also supports multiple threads, but runs single threaded by + /// default for determinism. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public HastySpace() + : base(NativeMethods.cpHastySpaceNew()) + { + } + + /// + /// The number of threads to use for the solver. Currently Chipmunk is limited to 2 threads + /// as using more generally provides very minimal performance gains. Passing 0 as the thread + /// count on iOS or OS X will cause Chipmunk to automatically detect the number of threads + /// it should use. On other platforms passing 0 for the thread count will set 1 thread. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public int Threads + { + get => (int)NativeMethods.cpHastySpaceGetThreads(Handle); + set => NativeMethods.cpHastySpaceSetThreads(Handle, (uint)value); + } + + /// + /// Step in the hasty space. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public sealed override void Step(double dt) + { + NativeMethods.cpHastySpaceStep(Handle, dt); + } + + /// + /// Destroy and free the hasty space. + /// + protected override void FreeSpace(IntPtr handle) + { + NativeMethods.cpHastySpaceFree(handle); + } + } +} diff --git a/src/Tizen.NUI.Physics2D/src/public/chipmunk/IDebugDraw.cs b/src/Tizen.NUI.Physics2D/src/public/chipmunk/IDebugDraw.cs new file mode 100644 index 00000000000..2ea82a50c74 --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/chipmunk/IDebugDraw.cs @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System.ComponentModel; + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// Interface to draw debug primitives (circle, point, segment). + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public interface IDebugDraw + { + /// + /// Draw stroked circle. + /// + void DrawCircle(Vect pos, double angle, double radius, DebugColor outlineColor, DebugColor fillColor); + + /// + /// Draws a line segment. + /// + void DrawSegment(Vect a, Vect b, DebugColor color); + + /// + /// Draws a thick line segment. + /// + void DrawFatSegment(Vect a, Vect b, double radius, DebugColor outlineColor, DebugColor fillColor); + + /// + /// Draws a convex polygon. + /// + void DrawPolygon(Vect[] vectors, double radius, DebugColor outlineColor, DebugColor fillColor); + + /// + /// Draws a dot. + /// + void DrawDot(double size, Vect pos, DebugColor color); + + /// + /// Returns a color for a given shape. This gives you an opportunity to color shapes based + /// on how they are used in your engine. + /// + DebugColor ColorForShape(Shape shape); + } +} diff --git a/src/Tizen.NUI.Physics2D/src/public/chipmunk/MarchData.cs b/src/Tizen.NUI.Physics2D/src/public/chipmunk/MarchData.cs new file mode 100644 index 00000000000..c5e5d76b5bd --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/chipmunk/MarchData.cs @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System; +using System.ComponentModel; + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// March data used for . + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class MarchData + { + /// + /// The bounding box. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public BoundingBox BoundingBox { get; set; } + + /// + /// The number of horizontal samples. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public int XSamples { get; set; } + + /// + /// The number of vertical samples. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public int YSamples { get; set; } + + /// + /// The threshold. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Threshold { get; set; } + + /// + /// Callback for sampling/ + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Func SampleFunction { get; set; } + + /// + /// Callback for segmentation. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Action SegmentFunction { get; set; } + + /// + /// User sample data. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public object SampleData { get; set; } + + /// + /// User segmentation data. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public object SegmentData { get; set; } + } +} diff --git a/src/Tizen.NUI.Physics2D/src/public/chipmunk/PointQueryInfo.cs b/src/Tizen.NUI.Physics2D/src/public/chipmunk/PointQueryInfo.cs new file mode 100644 index 00000000000..aead09bf103 --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/chipmunk/PointQueryInfo.cs @@ -0,0 +1,162 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System; +using System.ComponentModel; + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// holds the result of a point query made on a + /// or . + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public sealed class PointQueryInfo : IEquatable + { +#pragma warning disable IDE0032 + private readonly Shape shape; + private readonly Vect point; + private readonly double distance; + private readonly Vect gradient; +#pragma warning restore IDE0032 + + /// + /// The nearest shape, None if no shape was within range. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Shape Shape => shape; + + /// + /// The closest point on the shape’s surface (in world space coordinates). + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect Point => point; + + /// + /// The distance to the point. The distance is negative if the point is inside the shape. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Distance => distance; + + /// + /// The gradient of the signed distance function. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect Gradient => gradient; + + /// + /// Create a . + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public PointQueryInfo(Shape s, Vect p, double d, Vect g) + { + shape = s; + point = p; + distance = d; + gradient = g; + } + + /// + /// Return true if this object is reference-equal to the given + /// object. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) + { + var other = obj as PointQueryInfo; + + if (other == null) + { + return false; + } + + return this == other; + } + + /// + /// Get the hash code. + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() + { + return shape.Handle.ToInt32() ^ + point.GetHashCode() ^ + distance.GetHashCode() ^ + (gradient.GetHashCode() << 4); + } + + /// + /// Return true if this object is reference-equal to the given + /// object. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static bool operator ==(PointQueryInfo left, PointQueryInfo right) + { + if (ReferenceEquals(left, null)) + { + return ReferenceEquals(right, null); + } + + return left.Equals(right); + } + + /// + /// Return true if this object is not reference-equal to the + /// given object. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static bool operator !=(PointQueryInfo a, PointQueryInfo b) + { + return !(a == b); + } + + internal static PointQueryInfo FromQueryInfo(cpPointQueryInfo queryInfo) + { + var shape = Shape.FromHandle(queryInfo.shape); + + return new PointQueryInfo( + shape, + queryInfo.point, + queryInfo.distance, + queryInfo.gradient); + } + + /// + /// Return true if this object's distance is within + /// of the other and all other fields are equivalent. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool Equals(PointQueryInfo other) + { + if (ReferenceEquals(other, null) || + shape.Handle != other.shape.Handle || + point != other.point || + gradient != other.gradient) + { + return false; + } + + return Math.Abs(distance - other.distance) < float.Epsilon; + } + } +} diff --git a/src/Tizen.NUI.Physics2D/src/public/chipmunk/SegmentQueryInfo.cs b/src/Tizen.NUI.Physics2D/src/public/chipmunk/SegmentQueryInfo.cs new file mode 100644 index 00000000000..e492336cadb --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/chipmunk/SegmentQueryInfo.cs @@ -0,0 +1,181 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System; +using System.ComponentModel; + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// Segment queries return where a shape was hit and its surface normal at the point of contact. + /// Use == null to test if a shape was hit. Segment queries + /// are like ray casting, but because not all spatial indexes allow processing infinitely long + /// ray queries, it's limited to segments. In practice, this is still very fast and you don’t + /// need to worry too much about the performance as long as you aren’t using extremely long + /// segments for your queries. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public sealed class SegmentQueryInfo : IEquatable + { +#pragma warning disable IDE0032 + private readonly Shape shape; + private readonly Vect point; + private readonly Vect normal; + private readonly double alpha; +#pragma warning restore IDE0032 + + /// + /// Shape that was hit, or None if no collision occured. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Shape Shape => shape; + + /// + /// The point of impact. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect Point => point; + + /// + /// The normal of the surface that was hit. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect Normal => normal; + + /// + /// The normalized distance along the query segment in the range [0, 1] + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Alpha => alpha; + + /// + /// Construct a Segment query info. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public SegmentQueryInfo(Shape s, Vect p, Vect n, double a) + { + shape = s; + point = p; + normal = n; + alpha = a; + } + + /// + /// Return true if the given object is reference-equal to this one. + /// + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) + { + var other = obj as SegmentQueryInfo; + + if (other == null) + { + return false; + } + + return this == other; + } + + /// + /// Return true if both objects are reference-equal to each other. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static bool operator ==(SegmentQueryInfo left, SegmentQueryInfo right) + { + if (ReferenceEquals(left, null)) + { + return ReferenceEquals(right, null); + } + + return left.Equals(right); + } + + /// + /// Return true if both objects are not reference-equal to each other. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static bool operator !=(SegmentQueryInfo a, SegmentQueryInfo b) + { + return !(a == b); + } + + /// + /// Create a SegmentQuery from a native struct cpSegmentQueryInfo. + /// + internal static SegmentQueryInfo FromQueryInfo(cpSegmentQueryInfo queryInfo) + { + Shape shape; + + if (queryInfo.shape == IntPtr.Zero) + { + shape = null; + } + else + { + shape = Shape.FromHandle(queryInfo.shape); + } + + return new SegmentQueryInfo( + shape, + queryInfo.point, + queryInfo.normal, + queryInfo.alpha); + } + + /// + /// Return true if the fields in both objects are equivalent and the + /// field is within of the other's. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool Equals(SegmentQueryInfo other) + { + if (ReferenceEquals(other, null) || + shape?.Handle != other.shape?.Handle || + point != other.point || + normal != other.normal) + { + return false; + } + + return Math.Abs(alpha - other.alpha) < float.Epsilon; + } + + /// + /// Get the hash code. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() + { + unchecked + { + var hashCode = -1275187100; + hashCode = hashCode * -1521134295 + shape.GetHashCode(); + hashCode = hashCode * -1521134295 + point.GetHashCode(); + hashCode = hashCode * -1521134295 + normal.GetHashCode(); + hashCode = hashCode * -1521134295 + alpha.GetHashCode(); + return hashCode; + } + } + } +} diff --git a/src/Tizen.NUI.Physics2D/src/public/chipmunk/ShapeFilter.cs b/src/Tizen.NUI.Physics2D/src/public/chipmunk/ShapeFilter.cs new file mode 100755 index 00000000000..45cb76b7230 --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/chipmunk/ShapeFilter.cs @@ -0,0 +1,117 @@ +/* + * Copyright(c) 2023 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +using System; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// Fast collision filtering type that is used to determine if two objects collide before calling collision or query callbacks. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + [StructLayout(LayoutKind.Sequential)] + public struct ShapeFilter + { + private static readonly UIntPtr no_group = (UIntPtr)0; + private static readonly uint all_categories = (~(uint)0); + + private static readonly ShapeFilter filter_all = new ShapeFilter(no_group, all_categories, all_categories); + private static readonly ShapeFilter filter_none = new ShapeFilter(no_group, ~all_categories, ~all_categories); + + private UIntPtr group; + private uint categories; + private uint mask; + + /// + /// Group value + /// Two objects with the same non-zero group value do not collide. + /// This is generally used to group objects in a composite object together to disable self collisions. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public UIntPtr Group + { + get => group; + set => group = value; + } + + /// + /// Categories value + /// A bitmask of user definable categories that this object belongs to. + /// The category/mask combinations of both objects in a collision must agree for a collision to occur. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public uint Categories + { + get => categories; + set => categories = value; + } + + /// + /// Mask value + /// A bitmask of user definable category types that this object object collides with. + /// The category/mask combinations of both objects in a collision must agree for a collision to occur. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public uint Mask + { + get => mask; + set => mask = value; + } + + /// + /// Create a shape filter. + /// + /// + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public ShapeFilter(UIntPtr group, uint categories, uint mask) + { + this.group = group; + this.categories = categories; + this.mask = mask; + } + + /// + /// Value for signifying that a shape is in no group. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static UIntPtr NO_GROUP => no_group; + + /// + /// Value for signifying that a shape is in every layer. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static uint ALL_CATEGORIES => all_categories; + + /// + /// Collision filter value for a shape that will collide with anything except FILTER_NONE. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static ShapeFilter FILTER_ALL => filter_all; + + /// + /// Collision filter value for a shape that does not collide with anything. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static ShapeFilter FILTER_NONE => filter_none; + } +} diff --git a/src/Tizen.NUI.Physics2D/src/public/chipmunk/Shapes/Box.cs b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Shapes/Box.cs new file mode 100644 index 00000000000..1ffd9a10ee8 --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Shapes/Box.cs @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System.ComponentModel; + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// A retangular shape shape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class Box : Shape + { + /// + /// Create and initialize a box polygon shape. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Box(Body body, double width, double height, double radius) + : base(NativeMethods.cpBoxShapeNew(body.Handle, width, height, radius)) + { + + } + + /// + /// Create and initialize an offset box polygon shape. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Box(Body body, BoundingBox box, double radius) + : base(NativeMethods.cpBoxShapeNew2(body.Handle, box, radius)) + { + + } + + /// + /// Calculate the moment of inertia for a solid box. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static double MomentForBox(double mass, double width, double height) + { + return NativeMethods.cpMomentForBox(mass, width, height); + } + + /// + /// Calculate the moment of inertia for a solid box. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static double MomentForBox(double mass, BoundingBox boundingBox) + { + return NativeMethods.cpMomentForBox2(mass, boundingBox); + } + } +} diff --git a/src/Tizen.NUI.Physics2D/src/public/chipmunk/Shapes/Circle.cs b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Shapes/Circle.cs new file mode 100644 index 00000000000..252cf6718e2 --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Shapes/Circle.cs @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System.ComponentModel; + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// A circle shape defined by a radius + /// This is the fastest and simplest collision shape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class Circle : Shape + { + /// + /// Create and initialize a circle polygon shape. + /// + /// The body to attach the circle to. + /// The radius of the circle. + [EditorBrowsable(EditorBrowsableState.Never)] + public Circle(Body body, double radius) + : this(body, radius, Vect.Zero) + { + } + + /// + /// Create and initialize an offset circle polygon shape. + /// + /// The body to attach the circle to. + /// The radius of the circle. + /// + /// The offset from the body's center of gravity in coordinates local to the body. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Circle(Body body, double radius, Vect offset) + : base(NativeMethods.cpCircleShapeNew(body.Handle, radius, offset)) + { + } + + /// + /// Get the offset of the circle. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect Offset => NativeMethods.cpCircleShapeGetOffset(Handle); + + /// + /// Get the radius of the circle. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Radius => NativeMethods.cpCircleShapeGetRadius(Handle); + + /// + /// Get the calculated area of the circle. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public new double Area => AreaForCircle(0.0, Radius); + + /// + /// Calculate the moment of the circle for the given mass. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double MomentForMass(double mass) + { + return MomentForCircle(mass, Radius, Offset); + } + + /// + /// Calculate the moment of inertia for the circle. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static double MomentForCircle(double mass, double innerRadius, double radius, Vect offset) + { + return NativeMethods.cpMomentForCircle(mass, innerRadius, radius, offset); + } + + /// + /// Calculate the moment of inertia for the circle. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static double MomentForCircle(double mass, double radius, Vect offset) + { + return NativeMethods.cpMomentForCircle(mass, 0.0, radius, offset); + } + + /// + /// Calculate the area of a circle or donut. + /// + /// + /// The radius of the 'donut hole', which defines the area missing. + /// + /// + /// The outer radius of the donut. This should be greater than the + /// . + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static double AreaForCircle(double innerRadius, double radius) + { + return NativeMethods.cpAreaForCircle(innerRadius, radius); + } + } +} diff --git a/src/Tizen.NUI.Physics2D/src/public/chipmunk/Shapes/Polygon.cs b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Shapes/Polygon.cs new file mode 100644 index 00000000000..986f70f9705 --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Shapes/Polygon.cs @@ -0,0 +1,194 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// A polygon shape composed of connected vertices. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class Polygon : Shape + { + /// + /// A convex polygon shape. It's the slowest, but most flexible collision shape. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Polygon(Body body, IReadOnlyList verts, Transform transform, double radius) + : base(CreatePolygonShape(body, verts, transform, radius)) + { + } + + /// + /// Allocate and initialize a polygon shape with rounded corners. + /// The vertexes must be convex with a counter-clockwise winding. + /// + /// + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Polygon(Body body, Vect[] verts, double radius) + : base(CreatePolygonShape(body, verts, radius)) + { + + } + + private static IntPtr CreatePolygonShape(Body body, IReadOnlyList verts, Transform transform, double radius) + { + Debug.Assert(verts.Count > 2); + + IntPtr ptrVectors = NativeInterop.StructureArrayToPtr(verts); + + IntPtr handle = NativeMethods.cpPolyShapeNew(body.Handle, verts.Count, ptrVectors, transform, radius); + + NativeInterop.FreeStructure(ptrVectors); + + return handle; + } + + private static IntPtr CreatePolygonShape(Body body, Vect[] verts, double radius) + { + Debug.Assert(verts.Length > 2); + + IntPtr ptrVectors = NativeInterop.StructureArrayToPtr(verts); + + IntPtr handle = NativeMethods.cpPolyShapeNewRaw(body.Handle, verts.Length, ptrVectors, radius); + + NativeInterop.FreeStructure(ptrVectors); + + return handle; + } + + /// + /// Get the number of vertices in a polygon shape. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public int Count => NativeMethods.cpPolyShapeGetCount(Handle); + + /// + /// Get the th vertex of a polygon shape. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect GetVertex(int i) + { + return NativeMethods.cpPolyShapeGetVert(Handle, i); + } + + /// + /// Get the vertices of the polygon. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public IReadOnlyList Vertices + { + get + { + int count = Count; + if (count == 0) + return Array.Empty(); + + Vect[] vertices = new Vect[count]; + + for (int i = 0; i < count; i++) + { + vertices[i] = GetVertex(i); + } + + return vertices; + } + } + + /// + /// Get the radius of the polygon. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Radius => NativeMethods.cpPolyShapeGetRadius(Handle); + + /// + /// Get and calculate the signed area of this polygon. Vertices specified such that they connect in + /// a clockwise fashion (called winding) give a positive area measurement. This is probably + /// backwards to what you might expect. + /// + + /// + /// Get and calculate the signed area of the polygon. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public new double Area => AreaForPoly(Vertices, Radius); + + /// + /// Get and calculate the centroid of the polygon. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect Centroid => CentroidForPoly(Vertices); + + /// + /// Calculate the moment of inertia for a solid polygon shape assuming its center of gravity + /// is at its centroid. The offset is added to each vertex. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static double MomentForPolygon(double mass, IReadOnlyList vertices, Vect offset, double radius) + { + IntPtr verticesPtr = NativeInterop.StructureArrayToPtr(vertices); + double moment = NativeMethods.cpMomentForPoly(mass, vertices.Count, verticesPtr, offset, radius); + + NativeInterop.FreeStructure(verticesPtr); + + return moment; + } + + /// + /// Calculate the signed area of this polygon. Vertices specified such that they connect in + /// a clockwise fashion (called winding) give a positive area measurement. This is probably + /// backwards to what you might expect. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static double AreaForPoly(IReadOnlyList vertices, double radius) + { + IntPtr verticesPtr = NativeInterop.StructureArrayToPtr(vertices); + + double area = NativeMethods.cpAreaForPoly(vertices.Count, verticesPtr, radius); + + NativeInterop.FreeStructure(verticesPtr); + + return area; + } + + /// + /// Calculate the natural centroid of a polygon. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static Vect CentroidForPoly(IReadOnlyList vertices) + { + IntPtr verticesPtr = NativeInterop.StructureArrayToPtr(vertices); + + Vect centroid = NativeMethods.cpCentroidForPoly(vertices.Count, verticesPtr); + + NativeInterop.FreeStructure(verticesPtr); + + return centroid; + } + } +} diff --git a/src/Tizen.NUI.Physics2D/src/public/chipmunk/Shapes/Segment.cs b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Shapes/Segment.cs new file mode 100644 index 00000000000..66e8a4b24fe --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Shapes/Segment.cs @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System.ComponentModel; + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// A line segment shape between two points, which is mainly useful when it behaves statically, + /// though it can be beveled to give it thickness. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class Segment : Shape + { + /// + /// Create a line segment. + /// + /// The body to attach the segment to. + /// The first endpoint of the segment. + /// The second endpoint of the segment. + /// The thickness of the segment. + [EditorBrowsable(EditorBrowsableState.Never)] + public Segment(Body body, Vect a, Vect b, double radius) + : base(NativeMethods.cpSegmentShapeNew(body.Handle, a, b, radius)) + { + } + + /// + /// Let Chipmunk know about the geometry of adjacent segments to avoid colliding with endcaps. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetNeighbors(Vect prev, Vect next) + { + NativeMethods.cpSegmentShapeSetNeighbors(Handle, prev, next); + } + + /// + /// Get the first endpoint of the segment shape. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect A => NativeMethods.cpSegmentShapeGetA(Handle); + + /// + /// Get the second endpoint of the segment shape. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect B => NativeMethods.cpSegmentShapeGetB(Handle); + + /// + /// Get the normal of the segment shape. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect Normal => NativeMethods.cpSegmentShapeGetNormal(Handle); + + /// + /// Get the segment radius. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Radius => NativeMethods.cpSegmentShapeGetRadius(Handle); + + /// + /// Calculate the area of the segment, assuming a thickness has been provided. The area is + /// calculated assuming the endpoints would be rounded, like a capsule. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public new double Area => AreaForSegment(A, B, Radius); + + /// + /// Calculate the moment of inertia of the segment. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double MomentForMass(double mass) + { + return MomentForSegment(mass, A, B, Radius); + } + + /// + /// Calculate the moment of inertia for the line segment. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static double MomentForSegment(double mass, Vect a, Vect b, double radius) + { + return NativeMethods.cpMomentForSegment(mass, a, b, radius); + } + + /// + /// Calculate the area of a segment, assuming a thickness has been provided. The area is + /// calculated assuming the endpoints would be rounded, like a capsule. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static double AreaForSegment(Vect a, Vect b, double radius) + { + return NativeMethods.cpAreaForSegment(a, b, radius); + } + } +} diff --git a/src/Tizen.NUI.Physics2D/src/public/chipmunk/Shapes/Shape.cs b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Shapes/Shape.cs new file mode 100644 index 00000000000..19259a0dea3 --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Shapes/Shape.cs @@ -0,0 +1,327 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System; +using System.ComponentModel; +using System.Diagnostics; +using System.Runtime.InteropServices; +using cpBody = System.IntPtr; +using cpDataPointer = System.IntPtr; +using cpShape = System.IntPtr; +using cpSpace = System.IntPtr; + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// Abstract Chipmunk Shape + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public abstract class Shape : IDisposable + { +#pragma warning disable IDE0032 + private readonly cpShape shape; +#pragma warning restore IDE0032 + + /// + /// Create a Shape with the given . + /// + /// The native shape handle. + internal protected Shape(cpShape shapeHandle) + { + shape = shapeHandle; + RegisterUserData(); + } + + /// + /// The native handle. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public cpShape Handle => shape; + + /// + /// Register managed object in the native user data. + /// + private void RegisterUserData() + { + cpDataPointer pointer = NativeInterop.RegisterHandle(this); + NativeMethods.cpShapeSetUserData(shape, pointer); + } + + void ReleaseUserData() + { + cpDataPointer pointer = NativeMethods.cpShapeGetUserData(shape); + NativeInterop.ReleaseHandle(pointer); + } + + /// + /// Get a managed Shape from a native handle. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static Shape FromHandle(cpShape shape) + { + cpDataPointer handle = NativeMethods.cpShapeGetUserData(shape); + + return NativeInterop.FromIntPtr(handle); + } + + /// + /// Dispose the shape. + /// + protected virtual void Dispose(bool dispose) + { + if (!dispose) + { + Debug.WriteLine("Disposing shape {0} on finalizer... (consider Dispose explicitly)", shape); + } + + Free(); + } + + /// + /// Destroy and free the shape. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void Free() + { + ReleaseUserData(); + NativeMethods.cpShapeFree(shape); + } + + /// + /// Destroy and free the shape. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + // Shape properties + + /// + /// Arbitrary user data. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public object Data { get; set; } + + /// + /// Gets the space that this shape is registered within. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Space Space + { + get + { + cpSpace space = NativeMethods.cpShapeGetSpace(shape); + return Space.FromHandleSafe(space); + } + } + + /// + /// The body that this shape is associated with. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Body Body + { + get + { + cpBody body = NativeMethods.cpShapeGetBody(shape); + return Body.FromHandleSafe(body); + } + set + { + Debug.Assert(value != null && Space == null, + "Body can't be null and you can only change body if the shape wasn't added to space"); + + NativeMethods.cpShapeSetBody(shape, value.Handle); + } + } + + /// + /// Mass of the shape to have Chipmunk calculate mass properties for you. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Mass + { + get => NativeMethods.cpShapeGetMass(shape); + set => NativeMethods.cpShapeSetMass(shape, value); + } + + /// + /// Density of the shape if you are having Chipmunk calculate mass properties for you. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Density + { + get => NativeMethods.cpShapeGetDensity(shape); + set => NativeMethods.cpShapeSetDensity(shape, value); + } + + /// + /// Get the calculated moment of inertia for the shape. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Moment => NativeMethods.cpShapeGetMoment(shape); + + /// + /// Get the calculated area of the shape. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Area => NativeMethods.cpShapeGetArea(shape); + + /// + /// Get the center of gravity of the shape. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect CenterOfGravity => NativeMethods.cpShapeGetCenterOfGravity(shape); + + /// + /// Get the bounding box that contains the shape, given it's current position and angle. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public BoundingBox BoundingBox => NativeMethods.cpShapeGetBB(shape); + + /// + /// Whether the shape is a sensor. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool Sensor + { + get => NativeMethods.cpShapeGetSensor(shape) != 0; + set => NativeMethods.cpShapeSetSensor(shape, value ? (byte)1 : (byte)0); + } + + /// + /// The elasticity of the shape. A value of 0.0 is perfectly inelastic (no bounce). A + /// value of 1.0 is perfectly elastic. Due to simulation inaccuracy, values of 1.0 or + /// greater are not recommended. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Elasticity + { + get => NativeMethods.cpShapeGetElasticity(shape); + set => NativeMethods.cpShapeSetElasticity(shape, value); + } + + /// + /// The friction coefficient, following the Coulomb friction model. A value of 0.0 is + /// frictionless. https://en.wikipedia.org/wiki/Friction#Coefficient_of_friction + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Friction + { + get => NativeMethods.cpShapeGetFriction(shape); + set => NativeMethods.cpShapeSetFriction(shape, value); + } + + /// + /// The surface velocity of the object. Useful for creating conveyor belts or players that + /// move around. This value is only used when calculating friction, not resolving the + /// collision. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect SurfaceVelocity + { + get => NativeMethods.cpShapeGetSurfaceVelocity(shape); + set => NativeMethods.cpShapeSetSurfaceVelocity(shape, value); + } + + /// + /// An arbitrary value representing the collision type of this shape. Only shapes with like + /// collision types will collide. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public int CollisionType + { + get => (int)(uint)NativeMethods.cpShapeGetCollisionType(shape); + set => NativeMethods.cpShapeSetCollisionType(shape, (UIntPtr)(uint)value); + } + + /// + /// An arbitrary value representing the collision type of this shape. Only shapes with like + /// collision types will collide. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public ShapeFilter Filter + { + get => (ShapeFilter)NativeMethods.cpShapeGetFilter(shape); + set => NativeMethods.cpShapeSetFilter(shape, (ShapeFilter)value); + } + + /// + /// Update, cache and return the bounding box of a shape based on the body it's attached to. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public BoundingBox CacheBB() + { + return NativeMethods.cpShapeCacheBB(shape); + } + + /// + /// Update, cache and return the bounding box of a shape with an explicit transformation. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public BoundingBox Update(Transform transform) + { + return NativeMethods.cpShapeUpdate(shape, transform); + } + + /// + /// Finds the point on the surface of the shape which is closest to the given point. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public PointQueryInfo PointQuery(Vect point) + { + var output = new cpPointQueryInfo(); + NativeMethods.cpShapePointQuery(shape, point, ref output); + + return PointQueryInfo.FromQueryInfo(output); + } + + /// + /// Perform a segment query against a shape. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public SegmentQueryInfo SegmentQuery(Vect a, Vect b, double radius) + { + var queryInfo = new cpSegmentQueryInfo(); + NativeMethods.cpShapeSegmentQuery(shape, a, b, radius, ref queryInfo); + + return SegmentQueryInfo.FromQueryInfo(queryInfo); + } + + /// + /// Get the contact information between two shapes. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public ContactPointSet Collide(Shape other) + { + Debug.Assert(Marshal.SizeOf(typeof(cpContactPointSet)) == 104, + "check Chipmunk sizeof(cpContactPointSet)"); + + cpContactPointSet contactPointSet = NativeMethods.cpShapesCollide(shape, other.Handle); + + return ContactPointSet.FromContactPointSet(contactPointSet); + } + } +} diff --git a/src/Tizen.NUI.Physics2D/src/public/chipmunk/Space.cs b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Space.cs new file mode 100755 index 00000000000..3013687780b --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Space.cs @@ -0,0 +1,859 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.Runtime.InteropServices; +using cpBody = System.IntPtr; +using cpCollisionHandlerPointer = System.IntPtr; +using cpCollisionType = System.UIntPtr; +using cpConstraint = System.IntPtr; +using cpDataPointer = System.IntPtr; +using cpShape = System.IntPtr; +using cpSpace = System.IntPtr; +using voidptr_t = System.IntPtr; + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +using ObjCRuntime; +#endif + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// Spaces in Chipmunk are the basic unit of simulation. You add rigid bodies, shapes, and + /// constraints to the space and then step them all forward through time together. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class Space : IDisposable + { +#pragma warning disable IDE0032 + private readonly cpSpace space; +#pragma warning restore IDE0032 + + /// + /// Native handle cpSpace. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public cpSpace Handle => space; + + /// + /// Create a new Space object. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Space() + { + space = NativeMethods.cpSpaceNew(); + RegisterUserData(); + } + + /// + /// Create a space from a native Handle (used by derived classes). + /// + /// + protected internal Space(cpSpace handle) + { + space = handle; + RegisterUserData(); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + internal static Space NativeSpace(cpSpace handle) + { + return new Space(handle); + } + + /// + /// Destroys and frees. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void Free() + { + ReleaseUserData(); + FreeSpace(space); + } + + /// + /// Destroy and free space. + /// + /// + protected virtual void FreeSpace(cpSpace handle) + { + NativeMethods.cpSpaceFree(handle); + } + + /// + /// Destroy and free space. + /// + protected virtual void Dispose(bool disposing) + { + Free(); + } + /// + /// Disposes the Space object. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + void RegisterUserData() + { + cpDataPointer pointer = NativeInterop.RegisterHandle(this); + NativeMethods.cpSpaceSetUserData(space, pointer); + } + + void ReleaseUserData() + { + cpDataPointer pointer = NativeMethods.cpSpaceGetUserData(space); + NativeInterop.ReleaseHandle(pointer); + } + + /// + /// Get a Space object from native cpSpace handle. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static Space FromHandle(cpSpace space) + { + cpDataPointer handle = NativeMethods.cpSpaceGetUserData(space); + return NativeInterop.FromIntPtr(handle); + } + + /// + /// Get a Space object from native cpSpace handle, but return null if the handle is 0. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static Space FromHandleSafe(cpSpace space) + { + if (space == IntPtr.Zero) + { + return null; + } + + return FromHandle(space); + } + + // Properties + + /// + /// Arbitrary user data. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public object Data { get; set; } + + /// + /// Number of iterations to use in the impulse solver to solve contacts and other + /// constraints. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public int Iterations + { + get => NativeMethods.cpSpaceGetIterations(space); + set => NativeMethods.cpSpaceSetIterations(space, value); + } + + /// + /// Gravity to pass to rigid bodies when integrating velocity. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect Gravity + { + get => NativeMethods.cpSpaceGetGravity(space); + set => NativeMethods.cpSpaceSetGravity(space, value); + } + + /// + /// Damping rate expressed as the fraction of velocity that bodies retain each second. A + /// value of 0.9 would mean that each body's velocity will drop 10% per second. The default + /// value is 1.0, meaning no damping is applied. Note: This damping value is different than + /// those of and . + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Damping + { + get => NativeMethods.cpSpaceGetDamping(space); + set => NativeMethods.cpSpaceSetDamping(space, value); + } + + /// + /// Speed threshold for a body to be considered idle. The default value of 0 means to let + /// the space guess a good threshold based on gravity. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double IdleSpeedThreshold + { + get => NativeMethods.cpSpaceGetIdleSpeedThreshold(space); + set => NativeMethods.cpSpaceSetIdleSpeedThreshold(space, value); + } + + /// + /// Time a group of bodies must remain idle in order to fall asleep. Enabling sleeping also + /// implicitly enables the the contact graph. The default value of infinity disables the + /// sleeping algorithm. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double SleepTimeThreshold + { + get => NativeMethods.cpSpaceGetSleepTimeThreshold(space); + set => NativeMethods.cpSpaceSetSleepTimeThreshold(space, value); + } + + /// + /// Amount of encouraged penetration between colliding shapes. This is used to reduce + /// oscillating contacts and keep the collision cache warm. Defaults to 0.1. If you have + /// poor simulation quality, increase this number as much as possible without allowing + /// visible amounts of overlap. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double CollisionSlop + { + get => NativeMethods.cpSpaceGetCollisionSlop(space); + set => NativeMethods.cpSpaceSetCollisionSlop(space, value); + } + + /// + /// Determines how fast overlapping shapes are pushed apart. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double CollisionBias + { + get => NativeMethods.cpSpaceGetCollisionBias(space); + set => NativeMethods.cpSpaceSetCollisionBias(space, value); + } + + /// + /// Number of frames that contact information should persist. Defaults to 3. There is + /// probably never a reason to change this value. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public int CollisionPersistence + { + get => (int)NativeMethods.cpSpaceGetCollisionPersistence(space); + set => NativeMethods.cpSpaceSetCollisionPersistence(space, (uint)value); + } + + /// + /// The Space provided static body for a given . + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Body StaticBody + { + get + { + cpBody bodyHandle = NativeMethods.cpSpaceGetStaticBody(space); + cpDataPointer gcHandle = NativeMethods.cpBodyGetUserData(bodyHandle); + + if (gcHandle != IntPtr.Zero) + { + return NativeInterop.FromIntPtr(gcHandle); + } + + return new Body(bodyHandle); + } + } + + /// + /// Returns the current (or most recent) time step used with the given space. + /// Useful from callbacks if your time step is not a compile-time global. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double CurrentTimeStep => NativeMethods.cpSpaceGetCurrentTimeStep(space); + + /// + /// Returns true from inside a callback when objects cannot be added/removed. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool IsLocked => NativeMethods.cpSpaceIsLocked(space) != 0; + + + // Collision Handlers + + /// + /// Create or return the existing collision handler that is called for all collisions that are + /// not handled by a more specific collision handler. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public CollisionHandler GetOrCreateDefaultCollisionHandler() + { + cpCollisionHandlerPointer collisionHandle = NativeMethods.cpSpaceAddDefaultCollisionHandler(space); + return CollisionHandler.GetOrCreate(collisionHandle); + } + + + /// + /// Create or return the existing collision handler for the specified pair of collision + /// types. If wildcard handlers are used with either of the collision types, it's the + /// responsibility of the custom handler to invoke the wildcard handlers. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public CollisionHandler GetOrCreateCollisionHandler(int typeA, int typeB) + { + uint utypeA = unchecked((uint)typeA); + uint utypeB = unchecked((uint)typeB); + + cpCollisionType collisionTypeA = new cpCollisionType(utypeA); + cpCollisionType collisionTypeB = new cpCollisionType(utypeB); + + cpCollisionHandlerPointer collisionHandle = NativeMethods.cpSpaceAddCollisionHandler(space, collisionTypeA, collisionTypeB); + return CollisionHandler.GetOrCreate(collisionHandle); + } + + + /// + /// Create or return the existing wildcard collision handler for the specified type. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public CollisionHandler GetOrCreateWildcardHandler(int type) + { + cpCollisionHandlerPointer collisionHandle = NativeMethods.cpSpaceAddWildcardHandler(space, (cpCollisionType)type); + return CollisionHandler.GetOrCreate(collisionHandle); + } + + /// + /// Add a collision shape to the simulation. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void AddShape(Shape shape) + { + NativeMethods.cpSpaceAddShape(space, shape.Handle); + } + + /// + /// Add a rigid body to the simulation. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void AddBody(Body body) + { + NativeMethods.cpSpaceAddBody(space, body.Handle); + } + + /// + /// Add a constraint to the simulation. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void AddConstraint(Constraint constraint) + { + NativeMethods.cpSpaceAddConstraint(space, constraint.Handle); + } + + /// + /// Remove a collision shape from the simulation. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void RemoveShape(Shape shape) + { + NativeMethods.cpSpaceRemoveShape(space, shape.Handle); + } + + /// + /// Remove a rigid body from the simulation. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void RemoveBody(Body body) + { + NativeMethods.cpSpaceRemoveBody(space, body.Handle); + } + + /// + /// Remove a constraint from the simulation. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void RemoveConstraint(Constraint constraint) + { + NativeMethods.cpSpaceRemoveConstraint(space, constraint.Handle); + } + + /// + /// Test if a collision shape has been added to the space. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool Contains(Shape shape) + { + return NativeMethods.cpSpaceContainsShape(space, shape.Handle) != 0; + } + + /// + /// Test if a rigid body has been added to the space. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool Contains(Body body) + { + return NativeMethods.cpSpaceContainsBody(space, body.Handle) != 0; + } + + /// + /// Test if a constraint has been added to the space. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool Contains(Constraint constraint) + { + return NativeMethods.cpSpaceContainsConstraint(space, constraint.Handle) != 0; + } + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +#pragma warning disable CA1416 // Validate platform compatibility + [MonoPInvokeCallback(typeof(PostStepFunction))] +#pragma warning restore CA1416 // Validate platform compatibility +#endif + private static void PostStepCallBack(cpSpace handleSpace, voidptr_t handleKey, voidptr_t handleData) + { + var space = FromHandle(handleSpace); + var key = NativeInterop.FromIntPtr(handleKey); + var data = NativeInterop.FromIntPtr(handleData); + + Action callback = data.Callback; + + callback(space, key, data.Data); + + NativeInterop.ReleaseHandle(handleKey); + NativeInterop.ReleaseHandle(handleData); + } + + private static PostStepFunction postStepCallBack = PostStepCallBack; + + /// + /// Schedule a post-step callback to be called when finishes. You can + /// only register one callback per unique value for . Returns true + /// only if has never been scheduled before. It's possible to pass + /// null for if you only want to mark as + /// being used. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool AddPostStepCallback(Action callback, object key, object data) + { + var info = new PostStepCallbackInfo(callback, data); + + IntPtr dataHandle = NativeInterop.RegisterHandle(info); + IntPtr keyHandle = NativeInterop.RegisterHandle(key); + + return NativeMethods.cpSpaceAddPostStepCallback(space, postStepCallBack.ToFunctionPointer(), keyHandle, dataHandle) != 0; + } + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +#pragma warning disable CA1416 // Validate platform compatibility + [MonoPInvokeCallback(typeof(SpacePointQueryFunction))] +#pragma warning restore CA1416 // Validate platform compatibility +#endif + private static void EachPointQuery(cpShape shapeHandle, Vect point, double distance, Vect gradient, voidptr_t data) + { + var list = (List)GCHandle.FromIntPtr(data).Target; + + var shape = Shape.FromHandle(shapeHandle); + var pointQuery = new PointQueryInfo(shape, point, distance, gradient); + + list.Add(pointQuery); + } + + private static SpacePointQueryFunction eachPointQuery = EachPointQuery; + + /// + /// Get the shapes within a radius of the point location that are part of this space. The + /// filter is applied to the query and follows the same rules as the collision detection. + /// If a maxDistance of 0.0 is used, the point must lie inside a shape. Negative + /// is also allowed meaning that the point must be a under a + /// certain depth within a shape to be considered a match. + /// + /// Where to check for shapes in the space. + /// Match only within this distance. + /// Only pick shapes matching the filter. + [EditorBrowsable(EditorBrowsableState.Never)] + public IReadOnlyList PointQuery(Vect point, double maxDistance, ShapeFilter filter) + { + var list = new List(); + var gcHandle = GCHandle.Alloc(list); + + NativeMethods.cpSpacePointQuery(space, point, maxDistance, filter, eachPointQuery.ToFunctionPointer(), GCHandle.ToIntPtr(gcHandle)); + + gcHandle.Free(); + return list; + } + + /// + /// Get the nearest shape within a radius of a point that is part of this space. The filter + /// is applied to the query and follows the same rules as the collision detection. If a + /// of 0.0 is used, the point must lie inside a shape. + /// Negative is also allowed, meaning that the point must be + /// under a certain depth within a shape to be considered a match. + /// + /// Where to check for collision in the space. + /// Match only within this distance. + /// Only pick shapes matching the filter. + [EditorBrowsable(EditorBrowsableState.Never)] + public PointQueryInfo PointQueryNearest(Vect point, double maxDistance, ShapeFilter filter) + { + var queryInfo = new cpPointQueryInfo(); + + cpShape shape = NativeMethods.cpSpacePointQueryNearest(space, point, maxDistance, filter, ref queryInfo); + if (shape == IntPtr.Zero) + return null; + + return PointQueryInfo.FromQueryInfo(queryInfo); + } + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +#pragma warning disable CA1416 // Validate platform compatibility + [MonoPInvokeCallback(typeof(SpaceSegmentQueryFunction))] +#pragma warning restore CA1416 // Validate platform compatibility +#endif + private static void EachSegmentQuery(cpShape shapeHandle, Vect point, Vect normal, double alpha, voidptr_t data) + { + var list = (List)GCHandle.FromIntPtr(data).Target; + + var shape = Shape.FromHandle(shapeHandle); + var pointQuery = new SegmentQueryInfo(shape, point, normal, alpha); + + list.Add(pointQuery); + } + + private static SpaceSegmentQueryFunction eachSegmentQuery = EachSegmentQuery; + + /// + /// Get the shapes within a capsule-shaped radius of a line segment that is part of this + /// space. The filter is applied to the query and follows the same rules as the collision + /// detection. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public IReadOnlyList SegmentQuery(Vect start, Vect end, double radius, ShapeFilter filter) + { + var list = new List(); + var gcHandle = GCHandle.Alloc(list); + + NativeMethods.cpSpaceSegmentQuery(space, start, end, radius, filter, eachSegmentQuery.ToFunctionPointer(), GCHandle.ToIntPtr(gcHandle)); + + gcHandle.Free(); + return list; + } + + /// + /// Get the first shape within a capsule-shaped radius of a line segment that is part of + /// this space. The filter is applied to the query and follows the same rules as the + /// collision detection. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public SegmentQueryInfo SegmentQueryFirst(Vect start, Vect end, double radius, ShapeFilter filter) + { + var queryInfo = new cpSegmentQueryInfo(); + + cpShape shape = NativeMethods.cpSpaceSegmentQueryFirst(space, start, end, radius, filter, ref queryInfo); + if (shape == IntPtr.Zero) + return null; + + return SegmentQueryInfo.FromQueryInfo(queryInfo); + } + + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +#pragma warning disable CA1416 // Validate platform compatibility + [MonoPInvokeCallback(typeof(SpaceBBQueryFunction))] +#pragma warning restore CA1416 // Validate platform compatibility +#endif + private static void EachBBQuery(cpShape shapeHandle, voidptr_t data) + { + var list = (List)GCHandle.FromIntPtr(data).Target; + + var shape = Shape.FromHandle(shapeHandle); + + list.Add(shape); + } + + private static SpaceBBQueryFunction eachBBQuery = EachBBQuery; + + + /// + /// Get all shapes within the axis-aligned bounding box that are part of this shape. The + /// filter is applied to the query and follows the same rules as the collision detection. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public IReadOnlyList BoundBoxQuery(BoundingBox bb, ShapeFilter filter) + { + var list = new List(); + + var gcHandle = GCHandle.Alloc(list); + + NativeMethods.cpSpaceBBQuery(space, bb, filter, eachBBQuery.ToFunctionPointer(), GCHandle.ToIntPtr(gcHandle)); + + gcHandle.Free(); + return list; + } + + /// + /// Get all bodies in the space. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public IReadOnlyList Bodies + { + get + { + int count = NativeMethods.cpSpaceGetBodyCount(space); + int intptrBytes = checked(IntPtr.Size * count); + + if (intptrBytes == 0) + return Array.Empty(); + + IntPtr ptrBodies = Marshal.AllocHGlobal(intptrBytes); + NativeMethods.cpSpaceGetBodiesUserDataArray(space, ptrBodies); + + IntPtr[] userDataArray = new IntPtr[count]; + + Marshal.Copy(ptrBodies, userDataArray, 0, count); + + Marshal.FreeHGlobal(ptrBodies); + + Body[] bodies = new Body[count]; + + for (int i = 0; i < count; i++) + { + Body b = NativeInterop.FromIntPtr(userDataArray[i]); + bodies[i] = b; + } + + return bodies; + } + } + + /// + /// Get dynamic bodies in the space. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public IReadOnlyList DynamicBodies + { + get + { + int count = NativeMethods.cpSpaceGetDynamicBodyCount(space); + int intptrBytes = checked(IntPtr.Size * count); + + if (intptrBytes == 0) + return Array.Empty(); + + IntPtr ptrBodies = Marshal.AllocHGlobal(intptrBytes); + NativeMethods.cpSpaceGetDynamicBodiesUserDataArray(space, ptrBodies); + + IntPtr[] userDataArray = new IntPtr[count]; + + Marshal.Copy(ptrBodies, userDataArray, 0, count); + + Marshal.FreeHGlobal(ptrBodies); + + Body[] bodies = new Body[count]; + + for (int i = 0; i < count; i++) + { + Body b = NativeInterop.FromIntPtr(userDataArray[i]); + bodies[i] = b; + } + + return bodies; + } + } + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +#pragma warning disable CA1416 // Validate platform compatibility + [MonoPInvokeCallback(typeof(SpaceObjectIteratorFunction))] +#pragma warning restore CA1416 // Validate platform compatibility +#endif + private static void EachShape(cpShape shapeHandle, voidptr_t data) + { + var list = (List)GCHandle.FromIntPtr(data).Target; + + var shape = Shape.FromHandle(shapeHandle); + + list.Add(shape); + } + + private static SpaceObjectIteratorFunction eachShape = EachShape; + + /// + /// Get all shapes in the space. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public IReadOnlyList Shapes + { + get + { + var list = new List(); + + var gcHandle = GCHandle.Alloc(list); + + NativeMethods.cpSpaceEachShape(space, eachShape.ToFunctionPointer(), GCHandle.ToIntPtr(gcHandle)); + + gcHandle.Free(); + + return list; + } + } + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +#pragma warning disable CA1416 // Validate platform compatibility + [MonoPInvokeCallback(typeof(SpaceShapeQueryFunction))] +#pragma warning restore CA1416 // Validate platform compatibility +#endif + private static void ShapeQueryCallback(cpShape shape, IntPtr pointsPointer, voidptr_t data) + { + var list = (List)GCHandle.FromIntPtr(data).Target; + + var pointSet = NativeInterop.PtrToStructure(pointsPointer); + + list.Add(ContactPointSet.FromContactPointSet(pointSet)); + } + + private static SpaceShapeQueryFunction shapeQueryCallback = ShapeQueryCallback; + + /// + /// Get all shapes in the space that are overlapping the given shape. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public IReadOnlyList ShapeQuery(Shape shape) + { + var list = new List(); + var gcHandle = GCHandle.Alloc(list); + + NativeMethods.cpSpaceShapeQuery(space, shape.Handle, shapeQueryCallback.ToFunctionPointer(), GCHandle.ToIntPtr(gcHandle)); + + gcHandle.Free(); + return list; + } + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +#pragma warning disable CA1416 // Validate platform compatibility + [MonoPInvokeCallback(typeof(SpaceObjectIteratorFunction))] +#pragma warning restore CA1416 // Validate platform compatibility +#endif + private static void EachConstraint(cpConstraint constraintHandle, voidptr_t data) + { + var list = (List)GCHandle.FromIntPtr(data).Target; + + var constraint = Constraint.FromHandle(constraintHandle); + + list.Add(constraint); + } + + private static SpaceObjectIteratorFunction eachConstraint = EachConstraint; + + + /// + /// Get all constraints in the space. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public IReadOnlyList Constraints + { + get + { + var list = new List(); + + var gcHandle = GCHandle.Alloc(list); + + NativeMethods.cpSpaceEachConstraint(space, eachConstraint.ToFunctionPointer(), GCHandle.ToIntPtr(gcHandle)); + + gcHandle.Free(); + + return list; + } + } + + /// + /// Update the collision detection info for the static shapes in the space. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void ReindexStatic() + { + NativeMethods.cpSpaceReindexStatic(space); + } + + /// + /// Update the collision detection data for a specific shape in the space. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void ReindexShape(Shape shape) + { + NativeMethods.cpSpaceReindexShape(space, shape.Handle); + } + + /// + /// Update the collision detection data for all shapes attached to a body. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void ReindexShapesForBody(Body body) + { + NativeMethods.cpSpaceReindexShapesForBody(space, body.Handle); + } + + /// + /// Switch the space to use a spatial hash as its spatial index. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void UseSpatialHash(double dim, int count) + { + NativeMethods.cpSpaceUseSpatialHash(space, dim, count); + } + + /// + /// Update the space for the given time step. Using a fixed time step is highly recommended. + /// Doing so will increase the efficiency of the contact persistence, requiring an order of + /// magnitude fewer iterations to resolve the collisions in the usual case. It is not the + /// same to call step 10 times with a dt of 0.1, or 100 times with a dt of 0.01 even if the + /// end result is that the simulation moved forward 100 units. Performing multiple calls + /// with a smaller dt creates a more stable and accurate simulation. Therefore, it sometimes + /// makes sense to have a little for loop around the step call. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual void Step(double dt) + { + NativeMethods.cpSpaceStep(space, dt); + } + + /// + /// Draw all objects in the space for debugging purposes. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void DebugDraw(IDebugDraw debugDraw) + { + DebugDraw(debugDraw, DebugDrawFlags.All, DebugDrawColors.Default); + } + + /// + /// Draw all objects in the space for debugging purposes using flags. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void DebugDraw(IDebugDraw debugDraw, DebugDrawFlags flags) + { + DebugDraw(debugDraw, flags, DebugDrawColors.Default); + } + + /// + /// Draw all objects in the space for debugging purposes using flags and colors. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void DebugDraw(IDebugDraw debugDraw, DebugDrawFlags flags, DebugDrawColors colors) + { + var debugDrawOptions = new cpSpaceDebugDrawOptions(); + IntPtr debugDrawOptionsPointer = debugDrawOptions.AcquireDebugDrawOptions(debugDraw, flags, colors); + + NativeMethods.cpSpaceDebugDraw(space, debugDrawOptionsPointer); + + debugDrawOptions.ReleaseDebugDrawOptions(debugDrawOptionsPointer); + } + + } +} diff --git a/src/Tizen.NUI.Physics2D/src/public/chipmunk/SpaceRef.cs b/src/Tizen.NUI.Physics2D/src/public/chipmunk/SpaceRef.cs new file mode 100644 index 00000000000..926af934ee9 --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/chipmunk/SpaceRef.cs @@ -0,0 +1,778 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.Runtime.InteropServices; +using cpBody = System.IntPtr; +using cpCollisionHandlerPointer = System.IntPtr; +using cpCollisionType = System.UIntPtr; +using cpConstraint = System.IntPtr; +using cpDataPointer = System.IntPtr; +using cpShape = System.IntPtr; +using cpSpace = System.IntPtr; +using voidptr_t = System.IntPtr; + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +using ObjCRuntime; +#endif + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// Weak reference to a Space. + /// Gives access to the Native cpSpace API without enforcing + /// ownership of the space (which may instead be owned by the + /// rendering library) + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class SpaceRef + { +#pragma warning disable IDE0032 + private readonly cpSpace space; +#pragma warning restore IDE0032 + + /// + /// The space reference constructor can only be called from + /// Tizen.NUI.Physics2D.ScopedPhysicsAccessor.GetNative(). + /// It is not intended to be generated by the developer. + /// + /// + internal SpaceRef(cpSpace handle) + { + space = handle; + } + + /// + /// Get a Space object from native cpSpace handle. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + private static Space FromHandle(cpSpace space) + { + cpDataPointer handle = NativeMethods.cpSpaceGetUserData(space); + return NativeInterop.FromIntPtr(handle); + } + + + // Properties + + /// + /// Arbitrary user data. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public object Data { get; set; } + + /// + /// Number of iterations to use in the impulse solver to solve contacts and other + /// constraints. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public int Iterations + { + get => NativeMethods.cpSpaceGetIterations(space); + set => NativeMethods.cpSpaceSetIterations(space, value); + } + + /// + /// Gravity to pass to rigid bodies when integrating velocity. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect Gravity + { + get => NativeMethods.cpSpaceGetGravity(space); + set => NativeMethods.cpSpaceSetGravity(space, value); + } + + /// + /// Damping rate expressed as the fraction of velocity that bodies retain each second. A + /// value of 0.9 would mean that each body's velocity will drop 10% per second. The default + /// value is 1.0, meaning no damping is applied. Note: This damping value is different than + /// those of and . + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Damping + { + get => NativeMethods.cpSpaceGetDamping(space); + set => NativeMethods.cpSpaceSetDamping(space, value); + } + + /// + /// Speed threshold for a body to be considered idle. The default value of 0 means to let + /// the space guess a good threshold based on gravity. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double IdleSpeedThreshold + { + get => NativeMethods.cpSpaceGetIdleSpeedThreshold(space); + set => NativeMethods.cpSpaceSetIdleSpeedThreshold(space, value); + } + + /// + /// Time a group of bodies must remain idle in order to fall asleep. Enabling sleeping also + /// implicitly enables the the contact graph. The default value of infinity disables the + /// sleeping algorithm. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double SleepTimeThreshold + { + get => NativeMethods.cpSpaceGetSleepTimeThreshold(space); + set => NativeMethods.cpSpaceSetSleepTimeThreshold(space, value); + } + + /// + /// Amount of encouraged penetration between colliding shapes. This is used to reduce + /// oscillating contacts and keep the collision cache warm. Defaults to 0.1. If you have + /// poor simulation quality, increase this number as much as possible without allowing + /// visible amounts of overlap. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double CollisionSlop + { + get => NativeMethods.cpSpaceGetCollisionSlop(space); + set => NativeMethods.cpSpaceSetCollisionSlop(space, value); + } + + /// + /// Determines how fast overlapping shapes are pushed apart. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double CollisionBias + { + get => NativeMethods.cpSpaceGetCollisionBias(space); + set => NativeMethods.cpSpaceSetCollisionBias(space, value); + } + + /// + /// Number of frames that contact information should persist. Defaults to 3. There is + /// probably never a reason to change this value. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public int CollisionPersistence + { + get => (int)NativeMethods.cpSpaceGetCollisionPersistence(space); + set => NativeMethods.cpSpaceSetCollisionPersistence(space, (uint)value); + } + + /// + /// The Space provided static body for a given . + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Body StaticBody + { + get + { + cpBody bodyHandle = NativeMethods.cpSpaceGetStaticBody(space); + cpDataPointer gcHandle = NativeMethods.cpBodyGetUserData(bodyHandle); + + if (gcHandle != IntPtr.Zero) + { + return NativeInterop.FromIntPtr(gcHandle); + } + + return new Body(bodyHandle); + } + } + + /// + /// Returns the current (or most recent) time step used with the given space. + /// Useful from callbacks if your time step is not a compile-time global. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double CurrentTimeStep => NativeMethods.cpSpaceGetCurrentTimeStep(space); + + /// + /// Returns true from inside a callback when objects cannot be added/removed. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool IsLocked => NativeMethods.cpSpaceIsLocked(space) != 0; + + + // Collision Handlers + + /// + /// Create or return the existing collision handler that is called for all collisions that are + /// not handled by a more specific collision handler. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public CollisionHandler GetOrCreateDefaultCollisionHandler() + { + cpCollisionHandlerPointer collisionHandle = NativeMethods.cpSpaceAddDefaultCollisionHandler(space); + return CollisionHandler.GetOrCreate(collisionHandle); + } + + /// + /// Create or return the existing collision handler for the specified pair of collision + /// types. If wildcard handlers are used with either of the collision types, it's the + /// responsibility of the custom handler to invoke the wildcard handlers. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public CollisionHandler GetOrCreateCollisionHandler(int typeA, int typeB) + { + uint utypeA = unchecked((uint)typeA); + uint utypeB = unchecked((uint)typeB); + + cpCollisionType collisionTypeA = new cpCollisionType(utypeA); + cpCollisionType collisionTypeB = new cpCollisionType(utypeB); + + cpCollisionHandlerPointer collisionHandle = NativeMethods.cpSpaceAddCollisionHandler(space, collisionTypeA, collisionTypeB); + return CollisionHandler.GetOrCreate(collisionHandle); + } + + + /// + /// Create or return the existing wildcard collision handler for the specified type. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public CollisionHandler GetOrCreateWildcardHandler(int type) + { + cpCollisionHandlerPointer collisionHandle = NativeMethods.cpSpaceAddWildcardHandler(space, (cpCollisionType)type); + return CollisionHandler.GetOrCreate(collisionHandle); + } + + /// + /// Add a collision shape to the simulation. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void AddShape(Shape shape) + { + NativeMethods.cpSpaceAddShape(space, shape.Handle); + } + + /// + /// Add a rigid body to the simulation. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void AddBody(Body body) + { + NativeMethods.cpSpaceAddBody(space, body.Handle); + } + + /// + /// Add a constraint to the simulation. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void AddConstraint(Constraint constraint) + { + NativeMethods.cpSpaceAddConstraint(space, constraint.Handle); + } + + /// + /// Remove a collision shape from the simulation. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void RemoveShape(Shape shape) + { + NativeMethods.cpSpaceRemoveShape(space, shape.Handle); + } + + /// + /// Remove a rigid body from the simulation. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void RemoveBody(Body body) + { + NativeMethods.cpSpaceRemoveBody(space, body.Handle); + } + + /// + /// Remove a constraint from the simulation. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void RemoveConstraint(Constraint constraint) + { + NativeMethods.cpSpaceRemoveConstraint(space, constraint.Handle); + } + + /// + /// Test if a collision shape has been added to the space. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool Contains(Shape shape) + { + return NativeMethods.cpSpaceContainsShape(space, shape.Handle) != 0; + } + + /// + /// Test if a rigid body has been added to the space. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool Contains(Body body) + { + return NativeMethods.cpSpaceContainsBody(space, body.Handle) != 0; + } + + /// + /// Test if a constraint has been added to the space. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool Contains(Constraint constraint) + { + return NativeMethods.cpSpaceContainsConstraint(space, constraint.Handle) != 0; + } + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +#pragma warning disable CA1416 // Validate platform compatibility + [MonoPInvokeCallback(typeof(PostStepFunction))] +#pragma warning restore CA1416 // Validate platform compatibility +#endif + private static void PostStepCallBack(cpSpace handleSpace, voidptr_t handleKey, voidptr_t handleData) + { + var space = FromHandle(handleSpace); + var key = NativeInterop.FromIntPtr(handleKey); + var data = NativeInterop.FromIntPtr(handleData); + + Action callback = data.Callback; + + callback(space, key, data.Data); + + NativeInterop.ReleaseHandle(handleKey); + NativeInterop.ReleaseHandle(handleData); + } + + private static PostStepFunction postStepCallBack = PostStepCallBack; + + /// + /// Schedule a post-step callback to be called when finishes. You can + /// only register one callback per unique value for . Returns true + /// only if has never been scheduled before. It's possible to pass + /// null for if you only want to mark as + /// being used. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool AddPostStepCallback(Action callback, object key, object data) + { + var info = new PostStepCallbackInfo(callback, data); + + IntPtr dataHandle = NativeInterop.RegisterHandle(info); + IntPtr keyHandle = NativeInterop.RegisterHandle(key); + + return NativeMethods.cpSpaceAddPostStepCallback(space, postStepCallBack.ToFunctionPointer(), keyHandle, dataHandle) != 0; + } + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +#pragma warning disable CA1416 // Validate platform compatibility + [MonoPInvokeCallback(typeof(SpacePointQueryFunction))] +#pragma warning restore CA1416 // Validate platform compatibility +#endif + private static void EachPointQuery(cpShape shapeHandle, Vect point, double distance, Vect gradient, voidptr_t data) + { + var list = (List)GCHandle.FromIntPtr(data).Target; + + var shape = Shape.FromHandle(shapeHandle); + var pointQuery = new PointQueryInfo(shape, point, distance, gradient); + + list.Add(pointQuery); + } + + private static SpacePointQueryFunction eachPointQuery = EachPointQuery; + + /// + /// Get the shapes within a radius of the point location that are part of this space. The + /// filter is applied to the query and follows the same rules as the collision detection. + /// If a maxDistance of 0.0 is used, the point must lie inside a shape. Negative + /// is also allowed meaning that the point must be a under a + /// certain depth within a shape to be considered a match. + /// + /// Where to check for shapes in the space. + /// Match only within this distance. + /// Only pick shapes matching the filter. + [EditorBrowsable(EditorBrowsableState.Never)] + public IReadOnlyList PointQuery(Vect point, double maxDistance, ShapeFilter filter) + { + var list = new List(); + var gcHandle = GCHandle.Alloc(list); + + NativeMethods.cpSpacePointQuery(space, point, maxDistance, filter, eachPointQuery.ToFunctionPointer(), GCHandle.ToIntPtr(gcHandle)); + + gcHandle.Free(); + return list; + } + + /// + /// Get the nearest shape within a radius of a point that is part of this space. The filter + /// is applied to the query and follows the same rules as the collision detection. If a + /// of 0.0 is used, the point must lie inside a shape. + /// Negative is also allowed, meaning that the point must be + /// under a certain depth within a shape to be considered a match. + /// + /// Where to check for collision in the space. + /// Match only within this distance. + /// Only pick shapes matching the filter. + [EditorBrowsable(EditorBrowsableState.Never)] + public PointQueryInfo PointQueryNearest(Vect point, double maxDistance, ShapeFilter filter) + { + var queryInfo = new cpPointQueryInfo(); + + cpShape shape = NativeMethods.cpSpacePointQueryNearest(space, point, maxDistance, filter, ref queryInfo); + if (shape == IntPtr.Zero) + return null; + + return PointQueryInfo.FromQueryInfo(queryInfo); + } + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +#pragma warning disable CA1416 // Validate platform compatibility + [MonoPInvokeCallback(typeof(SpaceSegmentQueryFunction))] +#pragma warning restore CA1416 // Validate platform compatibility +#endif + private static void EachSegmentQuery(cpShape shapeHandle, Vect point, Vect normal, double alpha, voidptr_t data) + { + var list = (List)GCHandle.FromIntPtr(data).Target; + + var shape = Shape.FromHandle(shapeHandle); + var pointQuery = new SegmentQueryInfo(shape, point, normal, alpha); + + list.Add(pointQuery); + } + + private static SpaceSegmentQueryFunction eachSegmentQuery = EachSegmentQuery; + + /// + /// Get the shapes within a capsule-shaped radius of a line segment that is part of this + /// space. The filter is applied to the query and follows the same rules as the collision + /// detection. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public IReadOnlyList SegmentQuery(Vect start, Vect end, double radius, ShapeFilter filter) + { + var list = new List(); + var gcHandle = GCHandle.Alloc(list); + + NativeMethods.cpSpaceSegmentQuery(space, start, end, radius, filter, eachSegmentQuery.ToFunctionPointer(), GCHandle.ToIntPtr(gcHandle)); + + gcHandle.Free(); + return list; + } + + /// + /// Get the first shape within a capsule-shaped radius of a line segment that is part of + /// this space. The filter is applied to the query and follows the same rules as the + /// collision detection. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public SegmentQueryInfo SegmentQueryFirst(Vect start, Vect end, double radius, ShapeFilter filter) + { + var queryInfo = new cpSegmentQueryInfo(); + + cpShape shape = NativeMethods.cpSpaceSegmentQueryFirst(space, start, end, radius, filter, ref queryInfo); + if (shape == IntPtr.Zero) + return null; + + return SegmentQueryInfo.FromQueryInfo(queryInfo); + } + + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +#pragma warning disable CA1416 // Validate platform compatibility + [MonoPInvokeCallback(typeof(SpaceBBQueryFunction))] +#pragma warning restore CA1416 // Validate platform compatibility +#endif + private static void EachBBQuery(cpShape shapeHandle, voidptr_t data) + { + var list = (List)GCHandle.FromIntPtr(data).Target; + + var shape = Shape.FromHandle(shapeHandle); + + list.Add(shape); + } + + private static SpaceBBQueryFunction eachBBQuery = EachBBQuery; + + + /// + /// Get all shapes within the axis-aligned bounding box that are part of this shape. The + /// filter is applied to the query and follows the same rules as the collision detection. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public IReadOnlyList BoundBoxQuery(BoundingBox bb, ShapeFilter filter) + { + var list = new List(); + + var gcHandle = GCHandle.Alloc(list); + + NativeMethods.cpSpaceBBQuery(space, bb, filter, eachBBQuery.ToFunctionPointer(), GCHandle.ToIntPtr(gcHandle)); + + gcHandle.Free(); + return list; + } + + /// + /// Get all bodies in the space. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public IReadOnlyList Bodies + { + get + { + int count = NativeMethods.cpSpaceGetBodyCount(space); + int intptrBytes = checked(IntPtr.Size * count); + + if (intptrBytes == 0) + return Array.Empty(); + + IntPtr ptrBodies = Marshal.AllocHGlobal(intptrBytes); + NativeMethods.cpSpaceGetBodiesUserDataArray(space, ptrBodies); + + IntPtr[] userDataArray = new IntPtr[count]; + + Marshal.Copy(ptrBodies, userDataArray, 0, count); + + Marshal.FreeHGlobal(ptrBodies); + + Body[] bodies = new Body[count]; + + for (int i = 0; i < count; i++) + { + Body b = NativeInterop.FromIntPtr(userDataArray[i]); + bodies[i] = b; + } + + return bodies; + } + } + + /// + /// Get dynamic bodies in the space. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public IReadOnlyList DynamicBodies + { + get + { + int count = NativeMethods.cpSpaceGetDynamicBodyCount(space); + int intptrBytes = checked(IntPtr.Size * count); + + if (intptrBytes == 0) + return Array.Empty(); + + IntPtr ptrBodies = Marshal.AllocHGlobal(intptrBytes); + NativeMethods.cpSpaceGetDynamicBodiesUserDataArray(space, ptrBodies); + + IntPtr[] userDataArray = new IntPtr[count]; + + Marshal.Copy(ptrBodies, userDataArray, 0, count); + + Marshal.FreeHGlobal(ptrBodies); + + Body[] bodies = new Body[count]; + + for (int i = 0; i < count; i++) + { + Body b = NativeInterop.FromIntPtr(userDataArray[i]); + bodies[i] = b; + } + + return bodies; + } + } + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +#pragma warning disable CA1416 // Validate platform compatibility + [MonoPInvokeCallback(typeof(SpaceObjectIteratorFunction))] +#pragma warning restore CA1416 // Validate platform compatibility +#endif + private static void EachShape(cpShape shapeHandle, voidptr_t data) + { + var list = (List)GCHandle.FromIntPtr(data).Target; + + var shape = Shape.FromHandle(shapeHandle); + + list.Add(shape); + } + + private static SpaceObjectIteratorFunction eachShape = EachShape; + + /// + /// Get all shapes in the space. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public IReadOnlyList Shapes + { + get + { + var list = new List(); + + var gcHandle = GCHandle.Alloc(list); + + NativeMethods.cpSpaceEachShape(space, eachShape.ToFunctionPointer(), GCHandle.ToIntPtr(gcHandle)); + + gcHandle.Free(); + + return list; + } + } + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +#pragma warning disable CA1416 // Validate platform compatibility + [MonoPInvokeCallback(typeof(SpaceShapeQueryFunction))] +#pragma warning restore CA1416 // Validate platform compatibility +#endif + private static void ShapeQueryCallback(cpShape shape, IntPtr pointsPointer, voidptr_t data) + { + var list = (List)GCHandle.FromIntPtr(data).Target; + + var pointSet = NativeInterop.PtrToStructure(pointsPointer); + + list.Add(ContactPointSet.FromContactPointSet(pointSet)); + } + + private static SpaceShapeQueryFunction shapeQueryCallback = ShapeQueryCallback; + + /// + /// Get all shapes in the space that are overlapping the given shape. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public IReadOnlyList ShapeQuery(Shape shape) + { + var list = new List(); + var gcHandle = GCHandle.Alloc(list); + + NativeMethods.cpSpaceShapeQuery(space, shape.Handle, shapeQueryCallback.ToFunctionPointer(), GCHandle.ToIntPtr(gcHandle)); + + gcHandle.Free(); + return list; + } + +#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ +#pragma warning disable CA1416 // Validate platform compatibility + [MonoPInvokeCallback(typeof(SpaceObjectIteratorFunction))] +#pragma warning restore CA1416 // Validate platform compatibility +#endif + private static void EachConstraint(cpConstraint constraintHandle, voidptr_t data) + { + var list = (List)GCHandle.FromIntPtr(data).Target; + + var constraint = Constraint.FromHandle(constraintHandle); + + list.Add(constraint); + } + + private static SpaceObjectIteratorFunction eachConstraint = EachConstraint; + + + /// + /// Get all constraints in the space. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public IReadOnlyList Constraints + { + get + { + var list = new List(); + + var gcHandle = GCHandle.Alloc(list); + + NativeMethods.cpSpaceEachConstraint(space, eachConstraint.ToFunctionPointer(), GCHandle.ToIntPtr(gcHandle)); + + gcHandle.Free(); + + return list; + } + } + + /// + /// Update the collision detection info for the static shapes in the space. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void ReindexStatic() + { + NativeMethods.cpSpaceReindexStatic(space); + } + + /// + /// Update the collision detection data for a specific shape in the space. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void ReindexShape(Shape shape) + { + NativeMethods.cpSpaceReindexShape(space, shape.Handle); + } + + /// + /// Update the collision detection data for all shapes attached to a body. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void ReindexShapesForBody(Body body) + { + NativeMethods.cpSpaceReindexShapesForBody(space, body.Handle); + } + + /// + /// Switch the space to use a spatial hash as its spatial index. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void UseSpatialHash(double dim, int count) + { + NativeMethods.cpSpaceUseSpatialHash(space, dim, count); + } + + /// + /// Update the space for the given time step. Using a fixed time step is highly recommended. + /// Doing so will increase the efficiency of the contact persistence, requiring an order of + /// magnitude fewer iterations to resolve the collisions in the usual case. It is not the + /// same to call step 10 times with a dt of 0.1, or 100 times with a dt of 0.01 even if the + /// end result is that the simulation moved forward 100 units. Performing multiple calls + /// with a smaller dt creates a more stable and accurate simulation. Therefore, it sometimes + /// makes sense to have a little for loop around the step call. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual void Step(double dt) + { + NativeMethods.cpSpaceStep(space, dt); + } + + /// + /// Draw all objects in the space for debugging purposes. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void DebugDraw(IDebugDraw debugDraw) + { + DebugDraw(debugDraw, DebugDrawFlags.All, DebugDrawColors.Default); + } + + /// + /// Draw all objects in the space for debugging purposes using flags. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void DebugDraw(IDebugDraw debugDraw, DebugDrawFlags flags) + { + DebugDraw(debugDraw, flags, DebugDrawColors.Default); + } + + /// + /// Draw all objects in the space for debugging purposes using flags and colors. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void DebugDraw(IDebugDraw debugDraw, DebugDrawFlags flags, DebugDrawColors colors) + { + var debugDrawOptions = new cpSpaceDebugDrawOptions(); + IntPtr debugDrawOptionsPointer = debugDrawOptions.AcquireDebugDrawOptions(debugDraw, flags, colors); + + NativeMethods.cpSpaceDebugDraw(space, debugDrawOptionsPointer); + + debugDrawOptions.ReleaseDebugDrawOptions(debugDrawOptionsPointer); + } + + } +} diff --git a/src/Tizen.NUI.Physics2D/src/public/chipmunk/Transform.cs b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Transform.cs new file mode 100644 index 00000000000..9eeac762963 --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Transform.cs @@ -0,0 +1,205 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System; +using System.ComponentModel; +using System.Runtime.InteropServices; + +#pragma warning disable IDE1006 +#pragma warning disable IDE0032 + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// Type used for 2x3 affine transforms. See wikipedia for details: + /// http://en.wikipedia.org/wiki/Affine_transformation. The properties map to the matrix in this + /// way: [[a c tx], [b d ty]]. We can't use System.Numerics.Matrix32 since it does't use + /// doubles. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + [StructLayout(LayoutKind.Sequential)] + public struct Transform : IEquatable + { + private static readonly Transform identity = new Transform(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f); + + private double a; + private double b; + private double c; + private double d; + private double tx; + private double ty; + + /// + /// Create a matrix transformation. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Transform(double a, double b, double c, double d, double tx, double ty) : this() + { + this.a = a; + this.b = b; + this.c = c; + this.d = d; + this.tx = tx; + this.ty = ty; + } + + /// + /// Create a transpose matrix. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static Transform CreateTranspose(double a, double c, double tx, double b, double d, double ty) + { + return new Transform(a, b, c, d, tx, ty); + } + + /// + /// Create a translation matrix. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static Transform CreateTranslation(Vect translate) + { + return CreateTranspose(1.0, 0.0, translate.X, 0.0, 1.0, translate.Y); + } + + /// + /// Create an identity matrix. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static Transform Identity => identity; + + /// + /// A + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double A { get => a; set => a = value; } + + /// + /// B + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double B { get => b; set => b = value; } + + /// + /// C + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double C { get => c; set => c = value; } + + /// + /// D + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double D { get => d; set => d = value; } + + /// + /// Tx + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Tx { get => tx; set => tx = value; } + + /// + /// Ty + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Ty { get => ty; set => ty = value; } + + /// + /// Return true if all matrix values are within of each other. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) + { + Transform? transform = obj as Transform?; + + if (transform == null) + return false; + + return Equals(transform.Value); + } + + /// + /// Return true if all matrix values are within of each other. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool Equals(Transform other) + { + return Math.Abs(a - other.a) < double.Epsilon && + Math.Abs(b - other.b) < double.Epsilon && + Math.Abs(c - other.c) < double.Epsilon && + Math.Abs(d - other.d) < double.Epsilon && + Math.Abs(tx - other.tx) < double.Epsilon && + Math.Abs(ty - other.ty) < double.Epsilon; + } + + /// + /// Get the hash code. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() + { + unchecked + { + var hashCode = -884009331; +#pragma warning disable RECS0025 // Non-readonly field referenced in 'GetHashCode()' + hashCode = hashCode * -1521134295 + a.GetHashCode(); + hashCode = hashCode * -1521134295 + b.GetHashCode(); + hashCode = hashCode * -1521134295 + c.GetHashCode(); + hashCode = hashCode * -1521134295 + d.GetHashCode(); + hashCode = hashCode * -1521134295 + tx.GetHashCode(); + hashCode = hashCode * -1521134295 + ty.GetHashCode(); +#pragma warning restore RECS0025 // Non-readonly field referenced in 'GetHashCode()' + return hashCode; + } + } + + /// + /// Return a string formatted like "(a,b|c,d|tx,ty)". + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override string ToString() + { + return $"({a},{b}|{c},{d}|{tx},{ty})"; + } + + /// + /// Return true if all matrix values are within of each other. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static bool operator ==(Transform transform1, Transform transform2) + { + return transform1.Equals(transform2); + } + + /// + /// Return true if all matrix values are not within of each + /// other. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static bool operator !=(Transform transform1, Transform transform2) + { + return !(transform1 == transform2); + } + } +} + +#pragma warning restore IDE1006 +#pragma warning restore IDE0032 diff --git a/src/Tizen.NUI.Physics2D/src/public/chipmunk/Unsafe/CircleExtensions.cs b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Unsafe/CircleExtensions.cs new file mode 100644 index 00000000000..ec8f251b2da --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Unsafe/CircleExtensions.cs @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System.ComponentModel; + +namespace Tizen.NUI.Physics2D.Chipmunk.Unsafe +{ + /// + /// Unsafe extension methods for the shape. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static class CircleExtensions + { + /// + /// Change the radius of the circle shape. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static void SetRadius(this Circle circle, double radius) + { + NativeMethods.cpCircleShapeSetRadius(circle.Handle, radius); + } + + /// + /// Change the offset of the circle shape. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static void SetOffset(this Circle circle, Vect offset) + { + NativeMethods.cpCircleShapeSetOffset(circle.Handle, offset); + } + + } +} diff --git a/src/Tizen.NUI.Physics2D/src/public/chipmunk/Unsafe/PolygonExtensions.cs b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Unsafe/PolygonExtensions.cs new file mode 100644 index 00000000000..61d737da008 --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Unsafe/PolygonExtensions.cs @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System; +using System.ComponentModel; + +namespace Tizen.NUI.Physics2D.Chipmunk.Unsafe +{ + /// + /// Unsafe extension methods for the shape. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static class PolygonExtensions + { + /// + /// Set the vertexes of the polygon. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static void SetVertexes(this Polygon polygon, Vect[] vertexes, Transform transform) + { + IntPtr ptrVectors = NativeInterop.StructureArrayToPtr(vertexes); + NativeMethods.cpPolyShapeSetVerts(polygon.Handle, vertexes.Length, ptrVectors, transform); + NativeInterop.FreeStructure(ptrVectors); + } + + /// + /// Set the vertexes of the polygon. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static void SetVertexes(this Polygon polygon, Vect[] vertexes) + { + IntPtr ptrVectors = NativeInterop.StructureArrayToPtr(vertexes); + NativeMethods.cpPolyShapeSetVertsRaw(polygon.Handle, vertexes.Length, ptrVectors); + NativeInterop.FreeStructure(ptrVectors); + } + + /// + /// Set the radius of a poly shape + /// + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static void SetRadius(this Polygon polygon, double radius) + { + NativeMethods.cpPolyShapeSetRadius(polygon.Handle, radius); + } + } +} diff --git a/src/Tizen.NUI.Physics2D/src/public/chipmunk/Unsafe/SegmentExtensions.cs b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Unsafe/SegmentExtensions.cs new file mode 100644 index 00000000000..80357261102 --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Unsafe/SegmentExtensions.cs @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System.ComponentModel; + +namespace Tizen.NUI.Physics2D.Chipmunk.Unsafe +{ + /// + /// Unsafe extensions methods for the shape. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static class SegmentExtensions + { + /// + /// Set the endpoints of a segment shape. This mutates collision shapes. Chipmunk can't get + /// velocity information on changing shapes, so the results will be unrealistic. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static void SetEndpoints(this Segment segment, Vect a, Vect b) + { + NativeMethods.cpSegmentShapeSetEndpoints(segment.Handle, a, b); + } + + /// + /// Set the radius of a segment shape. This mutates collision shapes. Chipmunk can't get + /// velocity information on changing shapes, so the results will be unrealistic. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static void SetRadius(this Segment segment, double radius) + { + NativeMethods.cpSegmentShapeSetRadius(segment.Handle, radius); + } + } +} diff --git a/src/Tizen.NUI.Physics2D/src/public/chipmunk/Vect.cs b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Vect.cs new file mode 100644 index 00000000000..41049dd76b7 --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/chipmunk/Vect.cs @@ -0,0 +1,437 @@ +/* + * Copyright (c) 2023 Codefoco (codefoco@codefoco.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +using System; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +#pragma warning disable IDE1006 +#pragma warning disable IDE0032 + +// Chipmunk has it own Vector class, +// We can't use System.Numerics.Vector2 since is not blitable with the native Vect from Chipmunk + +namespace Tizen.NUI.Physics2D.Chipmunk +{ + /// + /// 2D Vector struct + /// + [EditorBrowsable(EditorBrowsableState.Never)] + [StructLayout(LayoutKind.Sequential)] + public struct Vect : IEquatable + { + private static readonly Vect zero = new Vect(0, 0); + + private double x; + private double y; + + /// + /// X value + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double X + { + get => x; + set => x = value; + } + + /// + /// Y value + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public double Y + { + get => y; + set => y = value; + } + + /// + /// Create a vector. + /// + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public Vect(double x, double y) + { + this.x = x; + this.y = y; + } + + /// + /// Return true if both objects are within of each other. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) + { + Vect? vect = obj as Vect?; + + if (vect == null) + return false; + + return this == vect.Value; + } + + /// + /// Get the hash code. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() + { +#pragma warning disable RECS0025 // Non-readonly field referenced in 'GetHashCode()' + return (x.GetHashCode() << 16) ^ y.GetHashCode(); +#pragma warning restore RECS0025 // Non-readonly field referenced in 'GetHashCode()' + } + + /// + /// Return true if both objects are within of each other. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool Equals(Vect other) + { + return this == other; + } + + /// + /// Return a string formatted like "(x,y)". + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override string ToString() + { + return $"({x},{y})"; + } + + /// + /// Return true if both objects are within of each other. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static bool operator ==(Vect a, Vect b) + { + return Math.Abs(b.x - a.x) <= double.Epsilon && + Math.Abs(b.y - a.y) <= double.Epsilon; + } + + /// + /// Return true if both objects are not within of each other. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static bool operator !=(Vect a, Vect b) + { + return !(a == b); + } + + /// + /// Add two vectors. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vect operator +(Vect a, Vect b) + { + return new Vect(a.x + b.x, a.y + b.y); + } + + /// + /// Subtract two vectors. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vect operator -(Vect a, Vect b) + { + return new Vect(a.x - b.x, a.y - b.y); + } + + /// + /// Negate a vector. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vect operator -(Vect a) + { + return new Vect(-a.x, -a.y); + } + + /// + /// Scalar multiplication. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vect operator *(Vect a, double s) + { + return new Vect(a.x * s, a.y * s); + } + + /// + /// Scalar division. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vect operator /(Vect a, double s) + { + return new Vect(a.x / s, a.y / s); + } + + /// + /// Scalar multiplication. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vect operator *(double s, Vect a) + { + return new Vect(a.x * s, a.y * s); + } + + /// + /// Scalar division. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vect operator /(double s, Vect a) + { + return new Vect(a.x / s, a.y / s); + } + + /// + /// Vector dot product. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public double Dot(Vect v2) + { + return x * v2.x + y * v2.y; + } + + /// + /// 2D vector cross product analog. The cross product of 2D vectors results in a 3D vector + /// with only a z component. This function returns the magnitude of the z value. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public double Cross(Vect v2) + { + return x * v2.y - y * v2.x; + } + + /// + /// Returns a perpendicular vector (-90 degree rotation). + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect Perpendicurlar => new Vect(-y, x); + + /// + /// Returns the vector projection of v1 onto v2. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public Vect Project(Vect v2) + { + return v2 * Dot(v2) / v2.Dot(v2); + } + + /// + /// Returns the unit length vector for the given angle (in radians). + /// + [EditorBrowsable(EditorBrowsableState.Never)] + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Vect ForAngle(double angle) + { + return new Vect(Math.Cos(angle), Math.Sin(angle)); + } + + /// + /// Returns the angular direction v is pointing in (in radians). + /// + [EditorBrowsable(EditorBrowsableState.Never)] + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public double ToAngle() + { + return Math.Atan2(y, x); + } + + /// + /// Uses complex number multiplication to rotate v1 by v2. Scaling will occur if v1 is not a + /// unit vector. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public Vect Rotate(Vect v2) + { + return new Vect(x * v2.x - y * v2.y, x * v2.y + y * v2.x); + } + + /// + /// Inverse of Rotate(). + /// + [EditorBrowsable(EditorBrowsableState.Never)] + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public Vect Unrotate(Vect v2) + { + return new Vect(x * v2.x + y * v2.y, y * v2.x - x * v2.y); + } + + /// + /// Returns the squared length of v. Faster than when you only need to + /// compare lengths. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public double LengthSquared() => Dot(this); + + /// + /// Returns the length of v. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public double Length() + { + return Math.Sqrt(Dot(this)); + } + + /// + /// Linearly interpolate between this and . + /// + [EditorBrowsable(EditorBrowsableState.Never)] + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public Vect Lerp(Vect v2, double t) + { + return this * (1.0 - t) + v2 * t; + } + + /// + /// Returns a normalized copy. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public Vect Normalize() + { + return this * (1.0 / (Length() + double.Epsilon)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static double Clamp(double value, double min, double max) + { + if (value < min) + { + return min; + } + if (value > max) + { + return max; + } + + return value; + } + + /// + /// Spherical linear interpolation between current position and based + /// on . + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect SLerp(Vect v2, double t) + { + double dot = Normalize().Dot(v2.Normalize()); + double omega = Math.Acos(Clamp(dot, -1.0f, 1.0f)); + + if (omega < 1e-3) + { + // If the angle between two vectors is very small, lerp instead to avoid precision issues. + return Lerp(v2, t); + } + + double denom = 1.0 / Math.Sin(omega); + return (this * Math.Sin((1.0f - t) * omega) * denom) + v2 * Math.Sin(t * omega) * denom; + } + + /// + /// Spherical linear interpolation between current position towards by + /// no more than angle radians. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect SLerpConst(Vect v2, double a) + { + double dot = Normalize().Dot(v2.Normalize()); + double omega = Math.Acos(Clamp(dot, -1.0f, 1.0f)); + + return SLerp(v2, Math.Min(a, omega) / omega); + } + + /// + /// Clamp the magnitude to the given length. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect Clamp(double length) + { + return Dot(this) > length * length ? Normalize() * length : this; + } + + /// + /// Linearly interpolate between the current position towards by + /// distance . + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vect LerpConst(Vect v2, double d) + { + return this + (v2 - this).Clamp(d); + } + + /// + /// Return the distance between this and . + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [EditorBrowsable(EditorBrowsableState.Never)] + public double Distance(Vect v2) + { + return (this - v2).Length(); + } + + /// + /// Return the squared distance between current position and . Faster + /// than when you only need to compare distances. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [EditorBrowsable(EditorBrowsableState.Never)] + public double DistanceSquare(Vect v2) + { + return (this - v2).LengthSquared(); + } + + /// + /// Return true if the distance between current position and is less + /// than . + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool Near(Vect v2, double distance) + { + return DistanceSquare(v2) < distance * distance; + } + + /// + /// (0, 0) Vector. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static Vect Zero => zero; + } +} + +#pragma warning restore IDE1006 +#pragma warning restore IDE0032 diff --git a/src/Tizen.NUI.Physics2D/src/public/wrapper/PhysicsActor.cs b/src/Tizen.NUI.Physics2D/src/public/wrapper/PhysicsActor.cs new file mode 100644 index 00000000000..2c2684b77c8 --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/wrapper/PhysicsActor.cs @@ -0,0 +1,199 @@ +/* + * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.ComponentModel; +using System.Runtime.InteropServices; +using Tizen.NUI.BaseComponents; + +namespace Tizen.NUI.Physics2D +{ + /// + /// Class to associate a physics body (such as btRigidBody*) with a View + /// for rendering. + /// + /// This object offers methods to modify basic physics properties + /// asynchronously, that is, on the Update thread. + /// + /// Currently, using the Physics API directly should be done after + /// blocking the physics integration step, by getting a ScopedAccessor from + /// the PhysicsAdaptor. Once the ScopedAccessor is disposed, then the + /// physics integration will run again. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class PhysicsActor : BaseHandle + { +#pragma warning disable IDE0032 + private readonly View _view; +#pragma warning restore IDE0032 + + /// + /// View is the view used for rendering the associated physics body. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public NUI.BaseComponents.View View => _view; + + /// + /// Binds the actor to the given body. This should be a body that has + /// been added to the physics world, and has physical postion and + /// rotation in that space. The Actor is used to render that object in + /// DALi space. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public PhysicsActor(View view, Chipmunk.Body body, PhysicsAdaptor adaptor) + : this(Interop.Actor.PhysicsActorNew(View.getCPtr(view), body.Handle, PhysicsAdaptor.getCPtr(adaptor)), true) + { + this._view = view; + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Copy Constructor + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public PhysicsActor(PhysicsActor adaptor) : this( Interop.Actor.NewPhysicsActor(PhysicsActor.getCPtr(adaptor)), true) + { + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Assignment "operator" + /// + internal PhysicsActor Assign(PhysicsActor rhs) + { + PhysicsActor adaptor = new PhysicsActor(Interop.Actor.Assign(SwigCPtr, PhysicsActor.getCPtr(rhs)), false); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return adaptor; + } + + internal PhysicsActor(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn) + { + } + + /// + /// Dispose the physics actor + /// This will release the View, but it's up to the caller to release the Body. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + protected override void Dispose(DisposeTypes type) + { + if(disposed) + { + return; + } + if(type == DisposeTypes.Explicit) + { + // Called by user + // Release managed resources + } + // Release unmanaged resources + + base.Dispose(type); + } + + /** + */ + [EditorBrowsable(EditorBrowsableState.Never)] + protected override void ReleaseSwigCPtr(global::System.Runtime.InteropServices.HandleRef swigCPtr) + { + Interop.Actor.DeletePhysicsActor(swigCPtr); + } + + /// + /// Get the physics body associated with this physics actor + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Chipmunk.Body GetBody() + { + IntPtr cPtr = Interop.Actor.GetBody(SwigCPtr); + if(NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return new Chipmunk.Body(cPtr); + } + + /// + /// Queue a method to set the position on the associated physics body + /// in the update thread before the next integration. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void AsyncSetPhysicsPosition(Vector3 position) + { + Interop.Actor.AsyncSetPhysicsPosition(SwigCPtr, Vector3.getCPtr(position)); + if(NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Queue a method to set the rotation of the associated physics body + /// in the update thread before the next integration. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void AsyncSetPhysicsRotation(Rotation position) + { + Interop.Actor.AsyncSetPhysicsRotation(SwigCPtr, Rotation.getCPtr(position)); + if(NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Get the current position of the physics body in Physics space. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vector3 GetPhysicsPosition() + { + IntPtr cPtr = Interop.Actor.GetPhysicsPosition(SwigCPtr); + if(NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return new Vector3(cPtr, true); + } + + /// + /// Get the current rotation of the physics body in Physics space. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Rotation GetPhysicsRotation() + { + IntPtr cPtr = Interop.Actor.GetPhysicsRotation(SwigCPtr); + if(NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return new Rotation(cPtr, true); + } + + /// + /// Get the current position of the View in world space + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vector3 GetActorPosition() + { + IntPtr cPtr = Interop.Actor.GetActorPosition(SwigCPtr); + if(NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return new Vector3(cPtr, true); + } + + /// + /// Get the current rotation of the View in world space + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Rotation GetActorRotation() + { + IntPtr cPtr = Interop.Actor.GetActorRotation(SwigCPtr); + if(NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return new Rotation(cPtr, true); + } + } +} diff --git a/src/Tizen.NUI.Physics2D/src/public/wrapper/PhysicsAdaptor.cs b/src/Tizen.NUI.Physics2D/src/public/wrapper/PhysicsAdaptor.cs new file mode 100644 index 00000000000..3dd72f2d709 --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/wrapper/PhysicsAdaptor.cs @@ -0,0 +1,439 @@ +/* + * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +using System.ComponentModel; +using System.Runtime.InteropServices; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Binding; +using Tizen.NUI; + +namespace Tizen.NUI.Physics2D +{ + /// + /// Enumeration to turn the integration step on or off. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public enum IntegrationState + { + /// + ///Integration state is turned off - physics stops running + /// + Off, + + /// + ///Integration state is turned on - physics runs in Update thread + /// + On + }; + + /// + /// Enumeration to turn the debug layer on or off. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public enum DebugState + { + /// + ///Debug state is turned off - no debug is drawn + /// + Off, + + /// + ///Debug state is turned on - if there is a Debug layer, then + ///the physics debug is drawn over the top of the root layer + /// + On + }; + + /// + /// Adaptor to manage access to the physics world and pairing actors and physics + /// bodies, plus some translation methods to/from the physics space and dali space. + /// + /// Also manages a debug renderer that may utilize the physics engine debug. + /// It is up to the developer to retrieve the root actor and parent it into the scene. + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class PhysicsAdaptor : NUI.BaseHandle + { + /// + /// Initialize the physics system. + /// Transformation matrix from NUI space to the Physics Space + /// Size of the root layer that the adaptor creates + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public PhysicsAdaptor(NUI.Matrix transform, NUI.Vector2 size) + : this(Interop.Adaptor.PhysicsAdaptorNew(NUI.Matrix.getCPtr(transform), NUI.Vector2.getCPtr(size)), true) + { + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Copy Constructor + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public PhysicsAdaptor(PhysicsAdaptor adaptor) : this( Interop.Adaptor.NewPhysicsAdaptor(PhysicsAdaptor.getCPtr(adaptor)), true) + { + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + internal PhysicsAdaptor Assign(PhysicsAdaptor rhs) + { + PhysicsAdaptor adaptor = new PhysicsAdaptor(Interop.Adaptor.Assign(SwigCPtr, PhysicsAdaptor.getCPtr(rhs)), false); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return adaptor; + } + + internal PhysicsAdaptor(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn) + { + } + + /// + /// Dispose the PhysicsAdaptor + /// + [EditorBrowsable(EditorBrowsableState.Never)] + protected override void Dispose(DisposeTypes type) + { + if(disposed) + { + return; + } + if(type == DisposeTypes.Explicit) + { + // Called by user + // Release managed resources + } + // Release unmanaged resources + + base.Dispose(type); + } + + /// This will not be publicly opened + [EditorBrowsable(EditorBrowsableState.Never)] + protected override void ReleaseSwigCPtr(global::System.Runtime.InteropServices.HandleRef swigCPtr) + { + Interop.Adaptor.DeletePhysicsAdaptor(swigCPtr); + } + + /// + /// The time that the integration step notionally takes. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public float Timestep + { + get + { + return GetTimestep(); + } + set + { + SetTimestep(value); + } + } + + internal float GetTimestep() + { + float timestep = Interop.Adaptor.GetTimestep(SwigCPtr); + if(NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return timestep; + } + internal void SetTimestep(float timestep) + { + Interop.Adaptor.SetTimestep(SwigCPtr, timestep); + if(NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Property to handle the IntegrationState of the adaptor + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public IntegrationState IntegrationState + { + get + { + return GetIntegrationState(); + } + set + { + SetIntegrationState(value); + } + } + internal IntegrationState GetIntegrationState() + { + int state = Interop.Adaptor.GetIntegrationState(SwigCPtr); + if(NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return (IntegrationState)state; + } + internal void SetIntegrationState(IntegrationState state) + { + Interop.Adaptor.SetIntegrationState(SwigCPtr, (int)state); + if(NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Property to handle the debug state of the adaptor + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Physics2D.DebugState DebugState + { + get + { + return GetDebugState(); + } + set + { + SetDebugState(value); + } + } + internal DebugState GetDebugState() + { + int state = Interop.Adaptor.GetDebugState(SwigCPtr); + if(NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return (DebugState)state; + } + internal void SetDebugState(DebugState state) + { + Interop.Adaptor.SetDebugState(SwigCPtr, (int)state); + if(NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + + /// + /// Change the transform matrix or the size of the root view + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetTransformAndSize(Matrix transform, Vector2 size) + { + Interop.Adaptor.SetTransformAndSize(SwigCPtr, Matrix.getCPtr(transform), Vector2.getCPtr(size)); + if(NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Return an accessor to the physics world. + /// Internally, this locks a mutex to prevent the integration step from running, + /// this will also block the Update thread. It is important that this accessor + /// is disposed of when not needed to restart the update thread. (Suggest use of + /// "using" block). + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public ScopedPhysicsAccessor GetAccessor() + { + global::System.IntPtr worldCPtr = Interop.Adaptor.GetPhysicsWorld(SwigCPtr); + if(NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return new ScopedPhysicsAccessor(worldCPtr); + } + + /// + /// Add a view to the body. The view will be used to render the body. It is parented onto the root layer. + /// The physics body should be added to the physics space by the user. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public PhysicsActor AddViewToBody(View view, Chipmunk.Body body) + { + // @todo Converting a View to an Actor internally _should_ be OK?! + global::System.IntPtr cPtr = Interop.Adaptor.AddActorBody(SwigCPtr, View.getCPtr(view), body.Handle); + if(NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return new PhysicsActor(cPtr, false); + } + + /// + /// This will unparent the View from the root layer, and dis-associate it + /// from the physics body. It is the responsibility of the user to remove + /// the physics body from the world. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void RemoveViewFromBody(PhysicsActor actor) + { + Interop.Adaptor.RemoveActorBody(SwigCPtr, PhysicsActor.getCPtr(actor)); + if(NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Retrieve a PhysicsActor given a physics body. + /// If there is no associated PhysicsActor, this will return null. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public PhysicsActor GetPhysicsActor(Chipmunk.Body body) + { + global::System.IntPtr cPtr = Interop.Adaptor.GetPhysicsActor(SwigCPtr, body.Handle); + if(NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + + // @todo This creates a new PhysicsActor on native side, but it's + // not registered with native or c# registries. Do we need to add functionality? + if(cPtr != global::System.IntPtr.Zero) + { + return new PhysicsActor(cPtr, false); + } + else + { + return null; + } + } + + /// + /// + /// + //public Layer GetRootLayer()... it's needed for 2 things - touch and finding actors. + // Provide a PhysisActor api to get View back + [EditorBrowsable(EditorBrowsableState.Never)] + public Layer GetRootLayer() + { + global::System.IntPtr cPtr = Interop.Adaptor.GetRootActor(SwigCPtr); + if(NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + + // @todo Test against registry? + Layer layer = new Layer(cPtr, false); + if(NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return layer; + } + + /// + /// Convert a touch point into a picking ray in the Physics space. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void BuildPickingRay(Vector3 origin, Vector3 direction, /*out*/ Vector3 rayFromWorld, /*out*/ Vector3 rayToWorld) + { + Interop.Adaptor.BuildPickingRay(SwigCPtr, Vector3.getCPtr(origin), Vector3.getCPtr(direction), + Vector3.getCPtr(rayFromWorld), Vector3.getCPtr(rayToWorld)); + if(NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Project a point from the origin (in NUI space) a distance along the direction + /// vector (in NUI space) and returns the projected point in physics space. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vector3 ProjectPoint(Vector3 origin, Vector3 direction, float distance) + { + global::System.IntPtr cPtr = Interop.Adaptor.ProjectPoint(SwigCPtr, Vector3.getCPtr(origin), Vector3.getCPtr(direction), distance); + if(NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return new Vector3(cPtr, true); + } + + /// + /// Transforms a position from NUI space to physics space + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vector3 TransformPositionToPhysicsSpace(Vector3 position) + { + global::System.IntPtr cPtr = Interop.Adaptor.TranslatePositionToPhysicsSpace(SwigCPtr, Vector3.getCPtr(position)); + if(NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return new Vector3(cPtr, true); + } + + /// + /// Transform a rotation from NUI to physics space + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Rotation TransformRotationToPhysicsSpace(Rotation rotation) + { + global::System.IntPtr cPtr = Interop.Adaptor.TranslateRotationToPhysicsSpace(SwigCPtr, Rotation.getCPtr(rotation)); + if(NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return new Rotation(cPtr, true); + } + + /// + /// Transform a position in Physics space to NUI space + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vector3 TransformPositionFromPhysicsSpace(Vector3 position) + { + global::System.IntPtr cPtr = Interop.Adaptor.TranslatePositionFromPhysicsSpace(SwigCPtr, Vector3.getCPtr(position)); + if(NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return new Vector3(cPtr, true); + } + + /// + /// Convert a rotation in physics space into NUI space + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Rotation TransformRotationFromPhysicsSpace(Rotation rotation) + { + global::System.IntPtr cPtr = Interop.Adaptor.TranslateRotationFromPhysicsSpace(SwigCPtr, Rotation.getCPtr(rotation)); + if(NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return new Rotation(cPtr, true); + } + + /// + /// Converts a vector (not a point) in NUI space to Physics space + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vector3 ConvertVectorToPhysicsSpace(Vector3 vector) + { + global::System.IntPtr cPtr = Interop.Adaptor.ConvertVectorToPhysicsSpace(SwigCPtr, Vector3.getCPtr(vector)); + if(NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return new Vector3(cPtr, true); + } + + /// + /// Converts a vector (not a point) in physics space to NUI space. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vector3 ConvertVectorFromPhysicsSpace(Vector3 vector) + { + global::System.IntPtr cPtr = Interop.Adaptor.ConvertVectorFromPhysicsSpace(SwigCPtr, Vector3.getCPtr(vector)); + if(NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return new Vector3(cPtr, true); + } + + /// + /// The debug layer uses a drawable actor and the debug features of the native physics engine + /// to render any debug graphics for the physics bodies. + /// This layer needs to be created before setting the DebugState has any effect. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Layer CreateDebugLayer(Window window) + { + global::System.IntPtr cPtr = Interop.Adaptor.CreateDebugLayer(SwigCPtr, Window.getCPtr(window)); + if(NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return new Layer(cPtr, false); + } + + /// + /// A sync point is necessary to synchronize Async calls in the update thread. + /// Any use of the PhysicsActor.AsyncNNN calls will require this API to be called. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void CreateSyncPoint() + { + Interop.Adaptor.CreateSyncPoint(SwigCPtr); + if(NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + // @todo Define interface for Queue that can accept cdecls. + } +} diff --git a/src/Tizen.NUI.Physics2D/src/public/wrapper/ScopedPhysicsAccessor.cs b/src/Tizen.NUI.Physics2D/src/public/wrapper/ScopedPhysicsAccessor.cs new file mode 100644 index 00000000000..2af0dc3214f --- /dev/null +++ b/src/Tizen.NUI.Physics2D/src/public/wrapper/ScopedPhysicsAccessor.cs @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.ComponentModel; +using System.Runtime.InteropServices; +using System.Collections.Generic; + +using Tizen.NUI; +using Tizen.NUI.BaseComponents; + +namespace Tizen.NUI.Physics2D +{ + /// + /// Scoped accessor to the physics world. + /// + /// Automatically locks the physics world with a mutex to prevent the + /// integration step from running whilst the developer is accessing + /// the world, e.g. to add/remove bodies or constraints, or to + /// perform hit-test. + /// + /// When it is disposed, the mutex is unlocked, and the integration step + /// can resume. + /// + /// Suggest that this is created with a "using" block: + /// + /// using(accessor=physicsAdaptor.GetAccessor()) + /// { + /// var space = accessor.GetNative(); + /// // Perform operations on space or bodies. + /// } // automatically disposed. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class ScopedPhysicsAccessor : IDisposable + { + private IntPtr worldCPtr; + + // Can only be constructed by PhysicsAdaptor + internal ScopedPhysicsAccessor(IntPtr worldCPtr) + { + this.worldCPtr = worldCPtr; + Interop.World.Lock(worldCPtr); + if(NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Get a weak handle to the native physics space. Disposing of + /// this handle does not destroy the space. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Chipmunk.SpaceRef GetNative() + { + IntPtr spaceCPtr = Interop.World.GetNative(worldCPtr); + if(NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return new Chipmunk.SpaceRef(spaceCPtr); + } + + /// + /// Perform a hit test on the given physics world ray, with a possible filter. + /// The ray can be created with PhysicsAdaptor.BuildPickingRay(). + /// Returns a body if hit, along with the local pivot coordinates and the distance from the ray origin (usually camera) + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Chipmunk.Body HitTest( NUI.Vector3 rayFromWorld, NUI.Vector3 rayToWorld, Chipmunk.ShapeFilter filter, /*out*/ NUI.Vector3 localPivot, out float distanceFromCamera) + { + IntPtr cPtr = Interop.World.HitTest(worldCPtr, NUI.Vector3.getCPtr(rayFromWorld), NUI.Vector3.getCPtr(rayToWorld), filter, NUI.Vector3.getCPtr(localPivot), out distanceFromCamera); + if(NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + if(cPtr != global::System.IntPtr.Zero) + { + return new Chipmunk.Body(cPtr); + } + return null; + } + + /// + /// Dispose of this object. + /// This ensures that the integration step is resumed + /// + protected virtual void Dispose(bool disposing) + { + Interop.World.Unlock(worldCPtr); + if(NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Disposes the Space object. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + } + +} diff --git a/src/Tizen.NUI.Scene3D/src/internal/Interop/Interop.MotionIndex.cs b/src/Tizen.NUI.Scene3D/src/internal/Interop/Interop.MotionIndex.cs index b0ae286f9e2..78086c3b2e6 100755 --- a/src/Tizen.NUI.Scene3D/src/internal/Interop/Interop.MotionIndex.cs +++ b/src/Tizen.NUI.Scene3D/src/internal/Interop/Interop.MotionIndex.cs @@ -95,13 +95,13 @@ internal static partial class MotionIndex [global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_MotionPropertyIndex_Assign")] public static extern global::System.IntPtr MotionPropertyIndexAssign(global::System.Runtime.InteropServices.HandleRef motionPropertyIndex, global::System.Runtime.InteropServices.HandleRef sourceMotionPropertyIndex); - [global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_MotionTransformIndex_DownCast")] + [global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_MotionPropertyIndex_DownCast")] public static extern global::System.IntPtr MotionPropertyIndexDownCast(global::System.Runtime.InteropServices.HandleRef motionPropertyIndex); - [global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_MotionTransformIndex_SetTransformType")] + [global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_MotionPropertyIndex_SetPropertyId")] public static extern void SetPropertyId(global::System.Runtime.InteropServices.HandleRef motionPropertyIndex, global::System.Runtime.InteropServices.HandleRef propertyKey); - [global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_MotionTransformIndex_GetTransformType")] + [global::System.Runtime.InteropServices.DllImport(Libraries.Scene3D, EntryPoint = "CSharp_Dali_MotionPropertyIndex_GetPropertyId")] public static extern global::System.IntPtr GetPropertyId(global::System.Runtime.InteropServices.HandleRef motionPropertyIndex); #endregion diff --git a/src/Tizen.NUI.Scene3D/src/public/Controls/Model.cs b/src/Tizen.NUI.Scene3D/src/public/Controls/Model.cs index 484a7dde87f..b778cbece0b 100755 --- a/src/Tizen.NUI.Scene3D/src/public/Controls/Model.cs +++ b/src/Tizen.NUI.Scene3D/src/public/Controls/Model.cs @@ -95,7 +95,7 @@ internal Model(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemory public Model(string modelUrl, string resourceDirectoryUrl = "") : this(Interop.Model.ModelNew(modelUrl, resourceDirectoryUrl), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - this.PositionUsesAnchorPoint = true; + this.PositionUsesPivotPoint = true; } /// @@ -106,7 +106,7 @@ public Model(string modelUrl, string resourceDirectoryUrl = "") : this(Interop.M public Model() : this(Interop.Model.ModelNew(), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - this.PositionUsesAnchorPoint = true; + this.PositionUsesPivotPoint = true; } /// @@ -117,6 +117,7 @@ public Model() : this(Interop.Model.ModelNew(), true) public Model(Model model) : this(Interop.Model.NewModel(Model.getCPtr(model)), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + this.PositionUsesPivotPoint = model.PositionUsesPivotPoint; } /// @@ -128,6 +129,7 @@ internal Model Assign(Model model) { Model ret = new Model(Interop.Model.ModelAssign(SwigCPtr, Model.getCPtr(model)), false); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + ret.PositionUsesPivotPoint = model.PositionUsesPivotPoint; return ret; } @@ -199,8 +201,14 @@ public ModelNode FindChildModelNodeByName(string nodeName) ModelNode ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as ModelNode; if (ret == null) { + // Store the value of PositionUsesAnchorPoint from dali object (Since View object automatically change PositionUsesPivotPoint value as false, we need to keep value.) + HandleRef handle = new HandleRef(this, cPtr); + bool originalPositionUsesAnchorPoint = Object.InternalGetPropertyBool(handle, View.Property.PositionUsesAnchorPoint); + handle = new HandleRef(null, IntPtr.Zero); + // Register new animatable into Registry. ret = new ModelNode(cPtr, true); + ret.PositionUsesPivotPoint = originalPositionUsesAnchorPoint; } else { @@ -569,8 +577,14 @@ private ModelNode GetModelRoot() ModelNode ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as ModelNode; if (ret == null) { + // Store the value of PositionUsesAnchorPoint from dali object (Since View object automatically change PositionUsesPivotPoint value as false, we need to keep value.) + HandleRef handle = new HandleRef(this, cPtr); + bool originalPositionUsesAnchorPoint = Object.InternalGetPropertyBool(handle, View.Property.PositionUsesAnchorPoint); + handle = new HandleRef(null, IntPtr.Zero); + // Register new animatable into Registry. ret = new ModelNode(cPtr, true); + ret.PositionUsesPivotPoint = originalPositionUsesAnchorPoint; } else { diff --git a/src/Tizen.NUI.Scene3D/src/public/ModelComponents/ModelNode.cs b/src/Tizen.NUI.Scene3D/src/public/ModelComponents/ModelNode.cs index 8974205c164..1f23f10aa20 100755 --- a/src/Tizen.NUI.Scene3D/src/public/ModelComponents/ModelNode.cs +++ b/src/Tizen.NUI.Scene3D/src/public/ModelComponents/ModelNode.cs @@ -58,7 +58,7 @@ internal ModelNode(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMe public ModelNode() : this(Interop.ModelNode.ModelNodeNew(), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - this.PositionUsesAnchorPoint = true; + this.PositionUsesPivotPoint = true; } /// @@ -80,6 +80,7 @@ internal ModelNode Assign(ModelNode modelNode) { ModelNode ret = new ModelNode(Interop.ModelNode.ModelNodeAssign(SwigCPtr, ModelNode.getCPtr(modelNode)), false); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + ret.PositionUsesPivotPoint = modelNode.PositionUsesPivotPoint; return ret; } @@ -172,8 +173,14 @@ public ModelNode FindChildModelNodeByName(string nodeName) ModelNode ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as ModelNode; if (ret == null) { + // Store the value of PositionUsesAnchorPoint from dali object (Since View object automatically change PositionUsesPivotPoint value as false, we need to keep value.) + HandleRef handle = new HandleRef(this, cPtr); + bool originalPositionUsesAnchorPoint = Object.InternalGetPropertyBool(handle, View.Property.PositionUsesAnchorPoint); + handle = new HandleRef(null, IntPtr.Zero); + // Register new animatable into Registry. ret = new ModelNode(cPtr, true); + ret.PositionUsesPivotPoint = originalPositionUsesAnchorPoint; } else { diff --git a/src/Tizen.NUI.Wearable/src/public/CircularPagination.cs b/src/Tizen.NUI.Wearable/src/public/CircularPagination.cs index 70183d20456..3258e8e3b9a 100755 --- a/src/Tizen.NUI.Wearable/src/public/CircularPagination.cs +++ b/src/Tizen.NUI.Wearable/src/public/CircularPagination.cs @@ -47,8 +47,6 @@ public class CircularPagination : Control private bool isCurrentIndicatorCentered = false; // When the current indicator is the center one, this variable becomes true. private bool isOddNumber = true; private bool uninitializedLeftIndicator = true; // Need it when the indicators are asymmetry and the right indicator count is set earlier than left one. - private Animation selectAnimation = null; - private bool isNeedAnimation = false; // TODO : Animation will support using override function later. Position2D[] oddArray = new Position2D[] { new Position2D(36, 74), new Position2D(47, 60), new Position2D(60, 47), new Position2D(74, 36), new Position2D(89, 26), new Position2D(105, 18), new Position2D(122, 11), new Position2D(139, 7), @@ -203,7 +201,6 @@ public bool IsSymmetrical } } - /// /// Gets or sets the number of the pages/indicators. /// @@ -516,14 +513,6 @@ public virtual void SetIndicatorPosition(int index, Position position) UpdateVisual(); } - private void CreateSelectAnimation() - { - if (selectAnimation == null) - { - selectAnimation = new Animation(250); - } - } - /// /// You can override it to do your select out operation. /// @@ -593,16 +582,6 @@ protected override void Dispose(DisposeTypes type) if (type == DisposeTypes.Explicit) { - if (selectAnimation != null) - { - if (selectAnimation.State == Animation.States.Playing) - { - selectAnimation.Stop(); - } - selectAnimation.Dispose(); - selectAnimation = null; - } - container.RemoveAll(); indicatorList.Clear(); diff --git a/src/Tizen.NUI.Wearable/src/public/RecyclerView/RecyclerView.cs b/src/Tizen.NUI.Wearable/src/public/RecyclerView/RecyclerView.cs index 94e2c2d497d..a311455d2f1 100755 --- a/src/Tizen.NUI.Wearable/src/public/RecyclerView/RecyclerView.cs +++ b/src/Tizen.NUI.Wearable/src/public/RecyclerView/RecyclerView.cs @@ -76,6 +76,11 @@ private void OnItemSizeChanged(object source, PropertyNotification.NotifyEventAr layoutManager.Layout(ScrollingDirection == Direction.Horizontal ? ContentContainer.CurrentPosition.X : ContentContainer.CurrentPosition.Y); } + /// + /// Gets / Sets total number of items. + /// + /// This may be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API + [EditorBrowsable(EditorBrowsableState.Never)] public int TotalItemCount { get @@ -127,7 +132,11 @@ private void InitializeItems() } } - + /// + /// Scrolling direction mode for RecyclerView. . + /// + /// This may be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API + [EditorBrowsable(EditorBrowsableState.Never)] public new Direction ScrollingDirection { get @@ -253,6 +262,8 @@ protected override float AdjustTargetPositionOfScrollAnimation(float position) private View focusedView; private int prevFocusedDataIndex = 0; + /// + [EditorBrowsable(EditorBrowsableState.Never)] public override View GetNextFocusableView(View currentFocusedView, View.FocusDirection direction, bool loopEnabled) { View nextFocusedView = null; diff --git a/src/Tizen.NUI.Wearable/src/public/WearableList.cs b/src/Tizen.NUI.Wearable/src/public/WearableList.cs index a7f4c3293b8..9df4a1661b6 100755 --- a/src/Tizen.NUI.Wearable/src/public/WearableList.cs +++ b/src/Tizen.NUI.Wearable/src/public/WearableList.cs @@ -57,6 +57,8 @@ public class WearableList : RecyclerView DecelerationRate = 0.991f; } + /// + [EditorBrowsable(EditorBrowsableState.Never)] protected override void SetScrollbar() { if(LayoutManager != null) @@ -65,6 +67,8 @@ protected override void SetScrollbar() } } + /// + [EditorBrowsable(EditorBrowsableState.Never)] public new RecycleAdapter Adapter { get diff --git a/src/Tizen.NUI.WindowSystem/src/internal/Interop/Interop.InputGenerator.cs b/src/Tizen.NUI.WindowSystem/src/internal/Interop/Interop.InputGenerator.cs new file mode 100644 index 00000000000..d9bbd03c0fa --- /dev/null +++ b/src/Tizen.NUI.WindowSystem/src/internal/Interop/Interop.InputGenerator.cs @@ -0,0 +1,89 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tizen.NUI.WindowSystem +{ + internal static partial class Interop + { + internal static partial class InputGenerator + { + const string lib = "libcapi-ui-efl-util.so.0"; + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "efl_util_input_initialize_generator")] + internal static extern IntPtr Init(int devType); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "efl_util_input_initialize_generator_with_name")] + internal static extern IntPtr InitWithName(int devType, string devName); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "efl_util_input_initialize_generator_with_sync")] + internal static extern IntPtr SyncInit(int devType, string devName); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "efl_util_input_deinitialize_generator")] + internal static extern ErrorCode Deinit(IntPtr inputGenHandler); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "efl_util_input_generate_key")] + internal static extern ErrorCode GenerateKey(IntPtr inputGenHandler, string keyName, int pressed); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "efl_util_input_generate_pointer")] + internal static extern ErrorCode GeneratePointer(IntPtr inputGenHandler, int buttons, int pointerType, int x, int y); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "efl_util_input_generate_wheel")] + internal static extern ErrorCode GenerateWheel(IntPtr inputGenHandler, int wheelType, int value); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "efl_util_input_generate_touch")] + internal static extern ErrorCode GenerateTouch(IntPtr inputGenHandler, int idx, int touchType, int x, int y); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "efl_util_input_generate_touch_axis")] + internal static extern ErrorCode GenerateTouchAxis(IntPtr inputGenHandler, int idx, int touchType, int x, int y, double radius_x, double radius_y, double pressure, double angle, double palm); + + // Enumeration of input device types. + // The device type may be used overlapped. + internal enum DeviceType + { + None = 0x0, + Touchscreen = (1 << 0), + Keyboard = (1 << 1), + Pointer = (1 << 2), + All = Touchscreen | Keyboard, // Keyboard and Touchscreen + } + + // Enumeration of touch event types + internal enum TouchType + { + None, + Begin, + Update, + End, + } + + // Enumeration of pointer event types + internal enum PointerType + { + Down, + Up, + Move, + } + + // Enumeration of pointer wheel event types + internal enum PointerWheelType + { + Vertical, + Horizontal, + } + + private const int ErrorTzsh = -0x02860000; + + internal enum ErrorCode + { + None = Tizen.Internals.Errors.ErrorCode.None, // Successful + OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory, // Out of memory + InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter, // Invalid parameter + InvalidOperation = Tizen.Internals.Errors.ErrorCode.InvalidOperation, // Invalid operation + PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied, // Permission denied + NotSupported = Tizen.Internals.Errors.ErrorCode.NotSupported, // NOT supported + NoService = ErrorTzsh | 0x01, // Service does not exist + } + } + } +} diff --git a/src/Tizen.NUI.WindowSystem/src/internal/Interop/Interop.KVMService.cs b/src/Tizen.NUI.WindowSystem/src/internal/Interop/Interop.KVMService.cs index 52ee625b431..4fc52fdd9c4 100644 --- a/src/Tizen.NUI.WindowSystem/src/internal/Interop/Interop.KVMService.cs +++ b/src/Tizen.NUI.WindowSystem/src/internal/Interop/Interop.KVMService.cs @@ -19,6 +19,12 @@ internal static partial class KVMService [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_kvm_service_perform_drop")] internal static extern int PerformDrop(IntPtr kvmService); + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_kvm_service_cancel_drag")] + internal static extern int CancelDrag(IntPtr kvmService); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_kvm_service_receive_drag_data")] + internal static extern int ReceiveDragData(IntPtr kvmService, string mimeType); + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_kvm_service_secondary_selection_set")] internal static extern int SetSecondarySelection(IntPtr kvmService); diff --git a/src/Tizen.NUI.WindowSystem/src/public/InputGenerator.cs b/src/Tizen.NUI.WindowSystem/src/public/InputGenerator.cs new file mode 100644 index 00000000000..a9ccf0afa24 --- /dev/null +++ b/src/Tizen.NUI.WindowSystem/src/public/InputGenerator.cs @@ -0,0 +1,290 @@ +/* + * Copyright(c) 2023 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +using System; +using System.ComponentModel; + +namespace Tizen.NUI.WindowSystem +{ + /// + /// Class for the Tizen Input Generator. + /// + /// + /// http://tizen.org/privilege/inputgenerator + /// + /// This class is need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public class InputGenerator : IDisposable + { + private IntPtr _handler; + private bool disposed = false; + private bool isDisposeQueued = false; + + /// + /// Enumeration of input device types. + /// + public enum DeviceType + { + /// + /// None. + /// + None = Interop.InputGenerator.DeviceType.None, + + /// + /// Touchscreen device. + /// + Touchscreen = Interop.InputGenerator.DeviceType.Touchscreen, + + /// + /// Keyboard device. + /// + Keyboard = Interop.InputGenerator.DeviceType.Keyboard, + + /// + /// Pointer device. + /// + Pointer = Interop.InputGenerator.DeviceType.Pointer, + + /// + /// Keyboard and Touchscreen device. + /// + All = Interop.InputGenerator.DeviceType.All, + } + + /// + /// Enumeration of touch event types. + /// + public enum TouchType + { + /// + /// None. + /// + None = Interop.InputGenerator.TouchType.None, + + /// + /// Touch begin. + /// + Begin = Interop.InputGenerator.TouchType.Begin, + + /// + /// Touch move. + /// + Update = Interop.InputGenerator.TouchType.Update, + + /// + /// Touch end. + /// + End = Interop.InputGenerator.TouchType.End, + } + + /// + /// Enumeration of pointer event types. + /// + public enum PointerType + { + /// + /// Pointer down. + /// + Down = Interop.InputGenerator.PointerType.Down, + + /// + /// Pointer up. + /// + Up = Interop.InputGenerator.PointerType.Up, + + /// + /// Pointer move. + /// + Move = Interop.InputGenerator.PointerType.Move, + } + + /// + /// Enumeration of pointer wheel event types. + /// + public enum PointerWheelType + { + /// + /// Vertical wheel. + /// + Vertical = Interop.InputGenerator.PointerWheelType.Vertical, + + /// + /// Horizontal wheel. + /// + Horizontal = Interop.InputGenerator.PointerWheelType.Horizontal, + } + + internal void ErrorCodeThrow(Interop.InputGenerator.ErrorCode error) + { + switch (error) + { + case Interop.InputGenerator.ErrorCode.None : + return; + case Interop.InputGenerator.ErrorCode.OutOfMemory : + throw new Tizen.Applications.Exceptions.OutOfMemoryException("Out of Memory"); + case Interop.InputGenerator.ErrorCode.InvalidParameter : + throw new ArgumentException("Invalid Parameter"); + case Interop.InputGenerator.ErrorCode.PermissionDenied : + throw new Tizen.Applications.Exceptions.PermissionDeniedException("Permission denied"); + case Interop.InputGenerator.ErrorCode.NotSupported : + throw new NotSupportedException("Not Supported"); + case Interop.InputGenerator.ErrorCode.NoService : + throw new InvalidOperationException("No Service"); + default : + throw new InvalidOperationException("Unknown Error"); + } + } + + /// + /// Creates a new InputGenerator. + /// + /// The Device type of the new input generator. + /// Thrown when failed of invalid argument. + /// Thrown when a argument is null. + public InputGenerator(DeviceType devType) + { + if (devType == DeviceType.None) + { + throw new ArgumentException("Invalid device type"); + } + + _handler = Interop.InputGenerator.Init((int)devType); + } + + public InputGenerator(DeviceType devType, string name, bool sync = false) + { + if (devType == DeviceType.None) + { + throw new ArgumentException("Invalid device type"); + } + + if (sync) + _handler = Interop.InputGenerator.SyncInit((int)devType, name); + else + _handler = Interop.InputGenerator.InitWithName((int)devType, name); + } + + /// + /// Destructor. + /// + ~InputGenerator() + { + if (!isDisposeQueued) + { + isDisposeQueued = true; + DisposeQueue.Instance.Add(this); + } + } + + /// + /// Dispose. + /// + public void Dispose() + { + if (isDisposeQueued) + { + Dispose(DisposeTypes.Implicit); + } + else + { + Dispose(DisposeTypes.Explicit); + GC.SuppressFinalize(this); + } + } + + /// + protected virtual void Dispose(DisposeTypes type) + { + if (!disposed) + { + if (_handler != IntPtr.Zero) + { + Interop.InputGenerator.ErrorCode res = Interop.InputGenerator.Deinit(_handler); + ErrorCodeThrow(res); + _handler = IntPtr.Zero; + } + disposed = true; + } + } + + /// + /// Generate given key. + /// + /// The key name to generate. + /// Set the key is pressed or released. + public void GenerateKey(string keyName, int pressed) + { + Interop.InputGenerator.ErrorCode res = Interop.InputGenerator.GenerateKey(_handler, keyName, pressed); + ErrorCodeThrow(res); + } + + /// + /// Generate given pointer. + /// + /// The pointer button to generate. + /// The type of the pointer. + /// X coordinate of the pointer. + /// Y coordinate of the pointer. + public void GeneratePointer(int buttons, PointerType pointerType, int x, int y) + { + Interop.InputGenerator.ErrorCode res = Interop.InputGenerator.GeneratePointer(_handler, buttons, (int)pointerType, x, y); + ErrorCodeThrow(res); + } + + /// + /// Generate given wheel. + /// + /// The wheel type to generate. + /// The value of the wheel. + public void GenerateWheel(PointerWheelType wheelType, int value) + { + Interop.InputGenerator.ErrorCode res = Interop.InputGenerator.GenerateWheel(_handler, (int)wheelType, value); + ErrorCodeThrow(res); + } + + /// + /// Generate given touch. + /// + /// The touch index to generate. + /// The touch type to generate. + /// X coordinate of the touch. + /// Y coordinate of the touch. + public void GenerateTouch(int idx, TouchType touchType, int x, int y) + { + Interop.InputGenerator.ErrorCode res = Interop.InputGenerator.GenerateTouch(_handler, idx, (int) touchType, x, y); + ErrorCodeThrow(res); + } + + /// + /// Generate given touch with axis. + /// + /// The touch index to generate. + /// The touch type to generate. + /// X coordinate of the touch. + /// Y coordinate of the touch. + /// radius_x of the touch. + /// radius_y of the touch. + /// pressure of the touch. + /// angle of the touch. + /// palm of the touch. + public void GenerateTouchAxis(int idx, TouchType touchType, int x, int y, double radius_x, double radius_y, double pressure, double angle, double palm) + { + Interop.InputGenerator.ErrorCode res = Interop.InputGenerator.GenerateTouchAxis(_handler, idx, (int) touchType, x, y, radius_x, radius_y, pressure, angle, palm); + ErrorCodeThrow(res); + } + } +} diff --git a/src/Tizen.NUI.WindowSystem/src/public/KVMService.cs b/src/Tizen.NUI.WindowSystem/src/public/KVMService.cs index febc47350e9..78f8ac4bca2 100644 --- a/src/Tizen.NUI.WindowSystem/src/public/KVMService.cs +++ b/src/Tizen.NUI.WindowSystem/src/public/KVMService.cs @@ -187,6 +187,27 @@ public void PerformDrop() _tzsh.ErrorCodeThrow(res); } + /// + /// Requests to cancel current drag. + /// + /// Thrown when failed of invalid argument. + public void CancelDrag() + { + int res = Interop.KVMService.CancelDrag(_kvmService); + _tzsh.ErrorCodeThrow(res); + } + + /// + /// Requests to receive the current drag data. + /// the drag data will be received by the DragEvent of the window. + /// + /// Thrown when failed of invalid argument. + public void ReceiveDragData(string mimeType) + { + int res = Interop.KVMService.ReceiveDragData(_kvmService, mimeType); + _tzsh.ErrorCodeThrow(res); + } + /// /// Requests to set KVM window as secondary selection window. /// diff --git a/src/Tizen.NUI/src/internal/Application/Application.cs b/src/Tizen.NUI/src/internal/Application/Application.cs index ec28235ef6b..d66cd5320d3 100755 --- a/src/Tizen.NUI/src/internal/Application/Application.cs +++ b/src/Tizen.NUI/src/internal/Application/Application.cs @@ -1553,13 +1553,13 @@ public static Application NewApplication(string[] args, string stylesheet, NUIAp return instance; } - public static Application NewApplication(string stylesheet, NUIApplication.WindowMode windowMode, WindowType type) + public static Application NewApplication(string[] args, string stylesheet, NUIApplication.WindowMode windowMode, WindowType type) { if (instance != null) { return instance; } - Application ret = New(1, stylesheet, windowMode, type); + Application ret = New(args, stylesheet, windowMode, type); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); instance = ret; @@ -1700,12 +1700,27 @@ public static Application New(string[] args, string stylesheet, NUIApplication.W return ret; } - public static Application New(int argc, string stylesheet, NUIApplication.WindowMode windowMode, WindowType type) + public static Application New(string[] args, string stylesheet, NUIApplication.WindowMode windowMode, WindowType type) { + int argc = 0; + string argvStr = ""; + try + { + argc = args.Length; + argvStr = string.Join(" ", args); + } + catch (Exception exception) + { + Tizen.Log.Fatal("NUI", "[Error] got exception during Application New(), this should not occur, message : " + exception.Message); + Tizen.Log.Fatal("NUI", "[Error] error line number : " + new StackTrace(exception, true).GetFrame(0).GetFileLineNumber()); + Tizen.Log.Fatal("NUI", "[Error] Stack Trace : " + exception.StackTrace); + throw; + } + // It will be removed until dali APIs are prepared. Rectangle initRectangle = new Rectangle(0, 0, 0, 0); - Application ret = new Application(Interop.Application.New(argc, stylesheet, (int)windowMode, Rectangle.getCPtr(initRectangle), (int)type), true); + Application ret = new Application(Interop.Application.New(argc, argvStr, stylesheet, (int)windowMode, Rectangle.getCPtr(initRectangle), (int)type), true); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } diff --git a/src/Tizen.NUI/src/internal/Application/NUICoreBackend.cs b/src/Tizen.NUI/src/internal/Application/NUICoreBackend.cs index f3472315018..37696d40e25 100755 --- a/src/Tizen.NUI/src/internal/Application/NUICoreBackend.cs +++ b/src/Tizen.NUI/src/internal/Application/NUICoreBackend.cs @@ -186,7 +186,7 @@ public void Run(string[] args) } else if (defaultWindowType != WindowType.Normal) { - application = Application.NewApplication(stylesheet, windowMode, defaultWindowType); + application = Application.NewApplication(args, stylesheet, windowMode, defaultWindowType); } else { diff --git a/src/Tizen.NUI/src/internal/Common/DaliEnumConstants.cs b/src/Tizen.NUI/src/internal/Common/DaliEnumConstants.cs index b97b81eceed..c24f9e1184f 100755 --- a/src/Tizen.NUI/src/internal/Common/DaliEnumConstants.cs +++ b/src/Tizen.NUI/src/internal/Common/DaliEnumConstants.cs @@ -251,7 +251,7 @@ public static void ErrorBacktrace(string msg, for (int i = 0; i < st.FrameCount; i++) { global::System.Diagnostics.StackFrame sf = st.GetFrame(i); - Tizen.Log.Error("NUI", " Method " + sf.GetMethod()); + Tizen.Log.Error("NUI", " Method " + sf.GetMethod() + ":" + sf.GetFileName() + ":" + sf.GetFileLineNumber()); } } } diff --git a/src/Tizen.NUI/src/internal/Common/Disposable.cs b/src/Tizen.NUI/src/internal/Common/Disposable.cs index 7884c303e28..72d1dc8ef47 100644 --- a/src/Tizen.NUI/src/internal/Common/Disposable.cs +++ b/src/Tizen.NUI/src/internal/Common/Disposable.cs @@ -25,6 +25,11 @@ namespace Tizen.NUI /// 6 public class Disposable : global::System.IDisposable { + static internal void Preload() + { + // Do nothing. Just call for load static values. + } + /// /// The flag to check if it is already disposed of. /// diff --git a/src/Tizen.NUI/src/internal/Common/FriendAssembly.cs b/src/Tizen.NUI/src/internal/Common/FriendAssembly.cs index e53710f52cb..54301f4b80a 100755 --- a/src/Tizen.NUI/src/internal/Common/FriendAssembly.cs +++ b/src/Tizen.NUI/src/internal/Common/FriendAssembly.cs @@ -27,6 +27,7 @@ [assembly: InternalsVisibleTo("Tizen.NUI.Components, " + Tizen.NUI.PublicKey.TizenFX)] [assembly: InternalsVisibleTo("Tizen.NUI.Extension, " + Tizen.NUI.PublicKey.TizenFX)] [assembly: InternalsVisibleTo("Tizen.NUI.Scene3D, " + Tizen.NUI.PublicKey.TizenFX)] +[assembly: InternalsVisibleTo("Tizen.NUI.Physics2D, " + Tizen.NUI.PublicKey.TizenFX)] [assembly: InternalsVisibleTo("Tizen.TV.NUI, " + Tizen.NUI.PublicKey.TizenTV)] [assembly: InternalsVisibleTo("Tizen.TV.NUI.Component, " + Tizen.NUI.PublicKey.TizenTV)] diff --git a/src/Tizen.NUI/src/internal/Common/Registry.cs b/src/Tizen.NUI/src/internal/Common/Registry.cs index ecceb81c050..7b2d732fd32 100755 --- a/src/Tizen.NUI/src/internal/Common/Registry.cs +++ b/src/Tizen.NUI/src/internal/Common/Registry.cs @@ -58,9 +58,48 @@ internal static void Register(BaseHandle baseHandle) RegistryCurrentThreadCheck(); - if (Instance._controlMap.TryAdd(refCptr, new WeakReference(baseHandle, false)) != true) + if (Instance._controlMap.TryAdd(refCptr, new WeakReference(baseHandle, true)) != true) { - NUILog.Debug("refCptr is already exist! OR something wrong!"); + WeakReference weakReference; + if(Instance._controlMap.TryGetValue(refCptr, out weakReference)) + { + if (weakReference == null) + { + Tizen.Log.Error("NUI", $"Something Wrong! weakReference is null\n"); + throw new System.InvalidOperationException("Error! NUI Registry weakReference should not be NULL!"); + } + var target = weakReference.Target; + + BaseHandle ret = target as BaseHandle; + if (ret != null) + { + Tizen.Log.Error("NUI", $"refCptr is already exist! input type:{baseHandle.GetType()}, registed type:{ret.GetType()}, refCptr:{refCptr.ToString("X8")}\n"); + throw new System.InvalidOperationException("refCptr is already exist!"); + } + else if(target == null) + { + // Special case. If WeakReference.Target is null, it might be disposed by GC. just Add forcely. + if (Instance._controlMap.TryRemove(refCptr, out weakReference) != true) + { + Tizen.Log.Error("NUI", $"Something Wrong when we try to remove null target\n"); + } + if (Instance._controlMap.TryAdd(refCptr, new WeakReference(baseHandle, false)) != true) + { + Tizen.Log.Error("NUI", $"Something Wrong when we try to replace null target\n"); + throw new System.InvalidOperationException("refCptr register failed"); + } + } + else + { + Tizen.Log.Error("NUI", $"Something Wrong!! target is not BaseHandle! target.GetType() : {target?.GetType()}\n"); + throw new System.InvalidOperationException("refCptr is already exist, but not a BaseHandle!"); + } + } + else + { + Tizen.Log.Error("NUI", $"refCptr is already exist! OR something Wrong!!!\n"); + throw new System.InvalidOperationException("refCptr is already exist, but fail to get handle!"); + } } NUILog.Debug($"[Registry] Register! type:{baseHandle.GetType()} count:{Instance._controlMap.Count} copyNativeHandle:{baseHandle.GetBaseHandleCPtrHandleRef.Handle.ToString("X8")}"); diff --git a/src/Tizen.NUI/src/internal/Common/RenderTaskList.cs b/src/Tizen.NUI/src/internal/Common/RenderTaskList.cs index 987e8408834..f47c59a52fd 100755 --- a/src/Tizen.NUI/src/internal/Common/RenderTaskList.cs +++ b/src/Tizen.NUI/src/internal/Common/RenderTaskList.cs @@ -17,6 +17,7 @@ using System; using System.ComponentModel; +using System.Runtime.InteropServices; namespace Tizen.NUI { @@ -95,7 +96,20 @@ public uint GetTaskCount() [EditorBrowsable(EditorBrowsableState.Never)] public RenderTask GetTask(uint index) { - RenderTask ret = new RenderTask(Interop.RenderTask.RenderTaskListGetTask(SwigCPtr, index), true); + global::System.IntPtr cPtr = Interop.RenderTask.RenderTaskListGetTask(SwigCPtr, index); + + RenderTask ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as RenderTask; + if (ret != null) + { + HandleRef CPtr = new HandleRef(this, cPtr); + Interop.BaseHandle.DeleteBaseHandle(CPtr); + CPtr = new HandleRef(null, global::System.IntPtr.Zero); + } + else + { + ret = new RenderTask(cPtr, true); + } + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } diff --git a/src/Tizen.NUI/src/internal/Common/ViewWrapperImpl.cs b/src/Tizen.NUI/src/internal/Common/ViewWrapperImpl.cs index 63314650c5c..fcb85a1d76f 100755 --- a/src/Tizen.NUI/src/internal/Common/ViewWrapperImpl.cs +++ b/src/Tizen.NUI/src/internal/Common/ViewWrapperImpl.cs @@ -389,11 +389,30 @@ private void DirectorOnSizeSet(global::System.IntPtr targetSize) private void DirectorOnSizeAnimation(global::System.IntPtr animation, global::System.IntPtr targetSize) { - var ani = new Animation(animation, true); + bool useRegisterAnimation = false; + + var ani = Registry.GetManagedBaseHandleFromNativePtr(animation) as Animation; + if (ani != null) + { + HandleRef CPtr = new HandleRef(this, animation); + Interop.BaseHandle.DeleteBaseHandle(CPtr); + CPtr = new HandleRef(null, global::System.IntPtr.Zero); + + useRegisterAnimation = true; + } + else + { + ani = new Animation(animation, true); + } var vector3 = new Vector3(targetSize, false); OnSizeAnimation?.Invoke(ani, vector3); - ani.Dispose(); vector3.Dispose(); + + // Dispose only if we create new Animation here. + if (!useRegisterAnimation) + { + ani.Dispose(); + } } private bool DirectorOnKey(global::System.IntPtr arg0) @@ -469,9 +488,28 @@ private void DirectorOnInitialize() private void DirectorOnStyleChange(global::System.IntPtr styleManager, int change) { - var styleManger = new StyleManager(styleManager, true); - OnStyleChange?.Invoke(styleManger, (StyleChangeType)change); - styleManger.Dispose(); + bool useRegisterStyleManager = false; + + var nuiStyleManger = Registry.GetManagedBaseHandleFromNativePtr(styleManager) as StyleManager; + if (nuiStyleManger != null) + { + HandleRef CPtr = new HandleRef(this, styleManager); + Interop.BaseHandle.DeleteBaseHandle(CPtr); + CPtr = new HandleRef(null, global::System.IntPtr.Zero); + + useRegisterStyleManager = true; + } + else + { + nuiStyleManger = new StyleManager(styleManager, true); + } + OnStyleChange?.Invoke(nuiStyleManger, (StyleChangeType)change); + + // Dispose only if we create new StyleManager here. + if (!useRegisterStyleManager) + { + nuiStyleManger.Dispose(); + } } private bool DirectorOnAccessibilityActivated() @@ -481,7 +519,8 @@ private bool DirectorOnAccessibilityActivated() private bool DirectorOnAccessibilityPan(global::System.IntPtr gesture) { - var panGesture = new PanGesture(gesture, true); + // Take memory ownership, but do not register into Registry. + var panGesture = new PanGesture(gesture, true, false); var ret = OnAccessibilityPan?.Invoke(panGesture) ?? false; panGesture.Dispose(); return ret; diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.Accessibility.cs b/src/Tizen.NUI/src/internal/Interop/Interop.Accessibility.cs index f296e1fca5a..4ef8e470807 100755 --- a/src/Tizen.NUI/src/internal/Interop/Interop.Accessibility.cs +++ b/src/Tizen.NUI/src/internal/Interop/Interop.Accessibility.cs @@ -24,9 +24,11 @@ internal static partial class Interop { internal static partial class Accessibility { + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate void SayCallback(string status); + [DllImport(NDalicPINVOKE.Lib, EntryPoint = "csharp_dali_accessibility_say")] - [return: MarshalAs(UnmanagedType.U1)] - public static extern bool Say(string jarg1, bool jarg2, IntPtr jarg3); + public static extern void Say(string arg1_text, bool arg2_discardable, SayCallback arg3_callback); [DllImport(NDalicPINVOKE.Lib, EntryPoint = "csharp_dali_accessibility_pause_resume")] public static extern void PauseResume(bool jarg1); diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.ActorProperty.cs b/src/Tizen.NUI/src/internal/Interop/Interop.ActorProperty.cs index 96b89c203e2..1491d1a9169 100755 --- a/src/Tizen.NUI/src/internal/Interop/Interop.ActorProperty.cs +++ b/src/Tizen.NUI/src/internal/Interop/Interop.ActorProperty.cs @@ -221,6 +221,12 @@ internal static partial class ActorProperty [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Actor_Property_UPDATE_AREA_HINT_get")] public static extern int UpdateAreaHintGet(); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Actor_Property_DISPATCH_TOUCH_MOTION_get")] + public static extern int DispatchTouchMotionGet(); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Actor_Property_DISPATCH_HOVER_MOTION_get")] + public static extern int DispatchHoverMotionGet(); } } } diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.Application.cs b/src/Tizen.NUI/src/internal/Interop/Interop.Application.cs index d453dba39ac..b17b6dda3ac 100755 --- a/src/Tizen.NUI/src/internal/Interop/Interop.Application.cs +++ b/src/Tizen.NUI/src/internal/Interop/Interop.Application.cs @@ -90,7 +90,7 @@ internal static partial class Application public static extern global::System.IntPtr New(int jarg1, string jarg3, int jarg4, global::System.Runtime.InteropServices.HandleRef jarg5); [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Application_New__SWIG_5")] - public static extern global::System.IntPtr New(int jarg1, string jarg3, int jarg4, global::System.Runtime.InteropServices.HandleRef jarg5, int jarg6); + public static extern global::System.IntPtr New(int argc, string argv, string styleSheet, int windowMode, global::System.Runtime.InteropServices.HandleRef initRectangle, int windowType); [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Application_New__SWIG_6")] public static extern global::System.IntPtr New(int argc, string argv, string jarg3, int jarg4, global::System.Runtime.InteropServices.HandleRef jarg5, bool jarg7); diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.DragAndDrop.cs b/src/Tizen.NUI/src/internal/Interop/Interop.DragAndDrop.cs index 4d498b084e6..1acf55699be 100755 --- a/src/Tizen.NUI/src/internal/Interop/Interop.DragAndDrop.cs +++ b/src/Tizen.NUI/src/internal/Interop/Interop.DragAndDrop.cs @@ -1,5 +1,5 @@ /* - * Copyright(c) 2022 Samsung Electronics Co., Ltd. + * Copyright(c) 2023 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,11 +36,21 @@ internal enum DragType public static extern bool StartDragAndDrop(global::System.Runtime.InteropServices.HandleRef dragAndDrop, global::System.Runtime.InteropServices.HandleRef sourceView, global::System.Runtime.InteropServices.HandleRef shadow, string mimeType, string data, global::System.Runtime.InteropServices.HandleRef callback); [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_DragAndDrop_AddListener")] + [return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)] public static extern bool AddListener(global::System.Runtime.InteropServices.HandleRef dragAndDrop, global::System.Runtime.InteropServices.HandleRef targetView, global::System.Runtime.InteropServices.HandleRef callback); [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_DragAndDrop_RemoveListener")] + [return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)] public static extern bool RemoveListener(global::System.Runtime.InteropServices.HandleRef dragAndDrop, global::System.Runtime.InteropServices.HandleRef targetView, global::System.Runtime.InteropServices.HandleRef callback); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_DragAndDrop_Window_AddListener")] + [return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)] + public static extern bool WindowAddListener(global::System.Runtime.InteropServices.HandleRef dragAndDrop, global::System.Runtime.InteropServices.HandleRef targetWindow, global::System.Runtime.InteropServices.HandleRef callback); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_DragAndDrop_Window_RemoveListener")] + [return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)] + public static extern bool WindowRemoveListener(global::System.Runtime.InteropServices.HandleRef dragAndDrop, global::System.Runtime.InteropServices.HandleRef targetWindow, global::System.Runtime.InteropServices.HandleRef callback); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_DragEvent_GetAction")] public static extern int GetAction(global::System.IntPtr dragAndDrop); diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.Key.cs b/src/Tizen.NUI/src/internal/Interop/Interop.Key.cs index fdce0aa2fea..18a7e6a1c9c 100755 --- a/src/Tizen.NUI/src/internal/Interop/Interop.Key.cs +++ b/src/Tizen.NUI/src/internal/Interop/Interop.Key.cs @@ -33,6 +33,9 @@ internal static partial class Key [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Key_New")] public static extern global::System.IntPtr New(string jarg1, string jarg2, int jarg3, int jarg4, uint jarg5, int jarg6); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Key_New__SWIG_1")] + public static extern global::System.IntPtr New(); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_delete_Key")] public static extern void DeleteKey(global::System.Runtime.InteropServices.HandleRef jarg1); diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.LottieAnimationView.cs b/src/Tizen.NUI/src/internal/Interop/Interop.LottieAnimationView.cs index 89c0a505713..f249c1aa52a 100755 --- a/src/Tizen.NUI/src/internal/Interop/Interop.LottieAnimationView.cs +++ b/src/Tizen.NUI/src/internal/Interop/Interop.LottieAnimationView.cs @@ -33,7 +33,10 @@ internal static partial class LottieAnimationView public static extern int AnimatedVectorImageVisualActionJumpToGet(); [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_AnimatedVectorImageVisual_Actions_SET_DYNAMIC_PROPERTY_get")] - public static extern int AnimatedVectorImageVisualActionSetDynamicProperty(); + public static extern int AnimatedVectorImageVisualActionSetDynamicPropertyGet(); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_AnimatedVectorImageVisual_Actions_FLUSH_get")] + public static extern int AnimatedVectorImageVisualActionFlushGet(); } } } diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.Particle.cs b/src/Tizen.NUI/src/internal/Interop/Interop.Particle.cs new file mode 100644 index 00000000000..6c8817f1c57 --- /dev/null +++ b/src/Tizen.NUI/src/internal/Interop/Interop.Particle.cs @@ -0,0 +1,53 @@ +/* + * Copyright(c) 2023 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +using System; +using global::System.Runtime.InteropServices; + +namespace Tizen.NUI.ParticleSystem +{ + internal static partial class Interop + { + internal static partial class Particle + { + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Particle_ReadFloat")] + internal static extern float ReadFloat(global::System.Runtime.InteropServices.HandleRef jarg1, uint streamIndex, uint particleIndex); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Particle_ReadVector2")] + internal static extern global::System.IntPtr ReadVector2(global::System.Runtime.InteropServices.HandleRef jarg1, uint streamIndex, uint particleIndex); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Particle_ReadVector3")] + internal static extern global::System.IntPtr ReadVector3(global::System.Runtime.InteropServices.HandleRef jarg1, uint streamIndex, uint particleIndex); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Particle_ReadVector4")] + internal static extern global::System.IntPtr ReadVector4(global::System.Runtime.InteropServices.HandleRef jarg1, uint streamIndex, uint particleIndex); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Particle_WriteFloat")] + internal static extern void WriteFloat(global::System.Runtime.InteropServices.HandleRef jarg1, uint streamIndex, uint particleIndex, float value); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Particle_WriteVector2")] + internal static extern void WriteVector2(global::System.Runtime.InteropServices.HandleRef jarg1, uint streamIndex, uint particleIndex, HandleRef value); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Particle_WriteVector3")] + internal static extern void WriteVector3(global::System.Runtime.InteropServices.HandleRef jarg1, uint streamIndex, uint particleIndex, HandleRef value); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Particle_WriteVector4")] + internal static extern void WriteVector4(global::System.Runtime.InteropServices.HandleRef jarg1, uint streamIndex, uint particleIndex, HandleRef value); + } + } +} + diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.ParticleEmitter.cs b/src/Tizen.NUI/src/internal/Interop/Interop.ParticleEmitter.cs new file mode 100644 index 00000000000..de22393aeab --- /dev/null +++ b/src/Tizen.NUI/src/internal/Interop/Interop.ParticleEmitter.cs @@ -0,0 +1,136 @@ +/* + * Copyright(c) 2023 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +using global::System.Runtime.InteropServices; + +namespace Tizen.NUI.ParticleSystem +{ + internal static partial class Interop + { + internal static partial class ParticleEmitter + { + [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ParticleEmitter_New_SWIG_0")] + internal static extern global::System.IntPtr New(HandleRef view); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_delete_ParticleEmitter")] + internal static extern void DeleteParticleEmitter(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ParticleEmitter_Assign")] + internal static extern global::System.IntPtr Assign(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ParticleEmitter_DownCast")] + internal static extern global::System.IntPtr DownCast(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ParticleEmitter_SetSource")] + internal static extern void SetSource(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ParticleEmitter_SetDomain")] + internal static extern void SetDomain(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ParticleEmitter_SetRenderer")] + internal static extern void SetRenderer(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ParticleEmitter_AddModifier")] + internal static extern void AddModifier(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ParticleEmitter_SetParticleCount")] + internal static extern void SetParticleCount(global::System.Runtime.InteropServices.HandleRef jarg1, uint count); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ParticleEmitter_GetParticleCount")] + internal static extern uint GetParticleCount(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ParticleEmitter_SetEmissionRate")] + internal static extern void SetEmissionRate(global::System.Runtime.InteropServices.HandleRef jarg1, uint count); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ParticleEmitter_SetInitialParticleCount")] + internal static extern void SetInitialParticleCount(global::System.Runtime.InteropServices.HandleRef jarg1, uint count); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ParticleEmitter_SetActiveParticlesLimit")] + internal static extern void SetActiveParticlesLimit(global::System.Runtime.InteropServices.HandleRef jarg1, uint count); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ParticleEmitter_GetActiveParticlesLimit")] + internal static extern uint GetActiveParticlesLimit(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ParticleEmitter_Start")] + internal static extern void Start(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ParticleEmitter_Stop")] + internal static extern void Stop(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ParticleEmitter_RemoveModifierAt")] + internal static extern void RemoveModifierAt(global::System.Runtime.InteropServices.HandleRef jarg1, uint index); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ParticleEmitter_GetModifierAt")] + internal static extern global::System.IntPtr GetModifierAt(global::System.Runtime.InteropServices.HandleRef jarg1, uint index); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ParticleEmitter_GetParticleList")] + internal static extern global::System.IntPtr GetParticleList(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ParticleEmitter_GetSource")] + internal static extern global::System.IntPtr GetSource(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ParticleEmitter_GetDomain")] + internal static extern global::System.IntPtr GetDomain(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ParticleEmitter_GetRenderer")] + internal static extern global::System.IntPtr GetRenderer(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ParticleEmitter_GetEmissionRate")] + internal static extern uint GetEmissionRate(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ParticleEmitter_GetInitialParticleCount")] + internal static extern uint GetInitialParticleCount(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ParticleEmitter_GetActiveParticleLimit")] + internal static extern uint GetActiveParticleLimit(global::System.Runtime.InteropServices.HandleRef jarg1); + + // ParticleRenderer + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ParticleRenderer_SetTexture")] + internal static extern void SetTexture(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ParticleRenderer_SetBlendingMode")] + internal static extern void SetBlendingMode(global::System.Runtime.InteropServices.HandleRef jarg1, ParticleBlendingMode mode); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ParticleRenderer_GetBlendingMode")] + internal static extern int GetBlendingMode(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ParticleEmitter_NewParticle")] + internal static extern int NewParticle(global::System.IntPtr emitter, float lifetime); + + // ParticleList + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ParticleList_AddLocalStreamiInt")] + internal static extern uint AddLocalStreamInt(global::System.Runtime.InteropServices.HandleRef jarg1, int defaultValue); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ParticleList_AddLocalStreamFloat")] + internal static extern uint AddLocalStreamFloat(global::System.Runtime.InteropServices.HandleRef jarg1, float defaultValue); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ParticleList_AddLocalStreamVector2")] + internal static extern uint AddLocalStreamVector2(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.IntPtr defaultValue); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ParticleList_AddLocalStreamVector3")] + internal static extern uint AddLocalStreamVector3(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.IntPtr defaultValue); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ParticleList_AddLocalStreamVector4")] + internal static extern uint AddLocalStreamVector4(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.IntPtr defaultValue); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ParticleList_GetDefaultStreamIndex")] + internal static extern int GetDefaultStreamIndex(global::System.Runtime.InteropServices.HandleRef jarg1, uint builtInStream ); + + } + } +} + diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.ParticleModifier.cs b/src/Tizen.NUI/src/internal/Interop/Interop.ParticleModifier.cs new file mode 100644 index 00000000000..d110894a2b4 --- /dev/null +++ b/src/Tizen.NUI/src/internal/Interop/Interop.ParticleModifier.cs @@ -0,0 +1,34 @@ +/* + * Copyright(c) 2023 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +using global::System.Runtime.InteropServices; +using System.Reflection; +using System; + +namespace Tizen.NUI.ParticleSystem +{ + internal static partial class Interop + { + internal static partial class ParticleModifier + { + internal delegate void ParticleModifierUpdateInvokerType(IntPtr ptr, IntPtr particleListPtr, uint first, uint count); + + [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ParticleModifier_New_SWIG_0")] + public static extern global::System.IntPtr New(ParticleModifierUpdateInvokerType updateInvoker, out IntPtr basePtr); + } + } +} \ No newline at end of file diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.ParticleSource.cs b/src/Tizen.NUI/src/internal/Interop/Interop.ParticleSource.cs new file mode 100644 index 00000000000..10c0ca246f3 --- /dev/null +++ b/src/Tizen.NUI/src/internal/Interop/Interop.ParticleSource.cs @@ -0,0 +1,35 @@ +/* + * Copyright(c) 2023 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +using global::System.Runtime.InteropServices; +using System.Reflection; +using System; + +namespace Tizen.NUI.ParticleSystem +{ + internal static partial class Interop + { + internal static partial class ParticleSource + { + internal delegate void ParticleSourceInitInvokerType(IntPtr ptr); + internal delegate uint ParticleSourceUpdateInvokerType(IntPtr ptr, uint count); + + [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ParticleSource_New_SWIG_0")] + internal static extern global::System.IntPtr New(ParticleSourceInitInvokerType initInvoker, ParticleSourceUpdateInvokerType updateInvoker, out IntPtr refObject); + } + } +} \ No newline at end of file diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.TextLabel.cs b/src/Tizen.NUI/src/internal/Interop/Interop.TextLabel.cs index 23ebfe0496a..205cc46ef40 100755 --- a/src/Tizen.NUI/src/internal/Interop/Interop.TextLabel.cs +++ b/src/Tizen.NUI/src/internal/Interop/Interop.TextLabel.cs @@ -1,5 +1,5 @@ /* - * Copyright(c) 2021 Samsung Electronics Co., Ltd. + * Copyright(c) 2023 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -165,6 +165,12 @@ internal static partial class TextLabel [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_TextLabel_GetTextPosition")] public static extern global::System.IntPtr GetTextPosition(global::System.Runtime.InteropServices.HandleRef textLabelRef, uint start, uint end); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_TextLabel_SetTextFitArray")] + public static extern void SetTextFitArray(global::System.Runtime.InteropServices.HandleRef textLabel, bool enable, uint arraySize, float[] pointSizeArray, float[] minLineSizeArray); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_TextLabel_GetTextFitArray")] + public static extern global::System.IntPtr GetTextFitArray(global::System.Runtime.InteropServices.HandleRef textLabel); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_TextLabel_AnchorClickedSignal")] public static extern global::System.IntPtr AnchorClickedSignal(global::System.Runtime.InteropServices.HandleRef jarg1); diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.VisualFactory.cs b/src/Tizen.NUI/src/internal/Interop/Interop.VisualFactory.cs index b7262adba84..a9a3a08b019 100755 --- a/src/Tizen.NUI/src/internal/Interop/Interop.VisualFactory.cs +++ b/src/Tizen.NUI/src/internal/Interop/Interop.VisualFactory.cs @@ -44,6 +44,9 @@ internal static partial class VisualFactory [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_VisualFactory_CreateVisual__SWIG_2")] public static extern global::System.IntPtr CreateVisual(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2, global::System.Runtime.InteropServices.HandleRef jarg3); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_VisualFactory_UsePreCompiledShader")] + public static extern void UsePreCompiledShader(global::System.Runtime.InteropServices.HandleRef jarg1); } } } diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.Window.cs b/src/Tizen.NUI/src/internal/Interop/Interop.Window.cs index 558e41fb20f..84427a9d14a 100755 --- a/src/Tizen.NUI/src/internal/Interop/Interop.Window.cs +++ b/src/Tizen.NUI/src/internal/Interop/Interop.Window.cs @@ -344,12 +344,18 @@ internal static partial class Window [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_GetLastTouchEvent")] public static extern global::System.IntPtr GetLastTouchEvent(global::System.Runtime.InteropServices.HandleRef window); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_GetLastHoverEvent")] + public static extern global::System.IntPtr GetLastHoverEvent(global::System.Runtime.InteropServices.HandleRef window); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_InternalRetrievingLastKeyEvent")] public static extern void InternalRetrievingLastKeyEvent(global::System.Runtime.InteropServices.HandleRef window, global::System.Runtime.InteropServices.HandleRef key); [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_InternalRetrievingLastTouchEvent")] public static extern void InternalRetrievingLastTouchEvent(global::System.Runtime.InteropServices.HandleRef window, global::System.Runtime.InteropServices.HandleRef touch); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_InternalRetrievingLastHoverEvent")] + public static extern void InternalRetrievingLastHoverEvent(global::System.Runtime.InteropServices.HandleRef window, global::System.Runtime.InteropServices.HandleRef hover); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_SetNeedsRotationCompletedAcknowledgement")] public static extern void SetNeedsRotationCompletedAcknowledgement(global::System.Runtime.InteropServices.HandleRef window, bool needAcknowledgement); @@ -387,6 +393,13 @@ internal static partial class Window [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_KeyboardUnGrab")] [return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)] public static extern bool KeyboardUnGrab(global::System.Runtime.InteropServices.HandleRef window); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_SetFullScreen")] + public static extern void SetFullScreen(global::System.Runtime.InteropServices.HandleRef window, bool fullscreen); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_GetFullScreen")] + [return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)] + public static extern bool GetFullScreen(global::System.Runtime.InteropServices.HandleRef window); } } } diff --git a/src/Tizen.NUI/src/internal/Interop/NDalicPINVOKE.cs b/src/Tizen.NUI/src/internal/Interop/NDalicPINVOKE.cs index a55f6227534..560684c28b5 100755 --- a/src/Tizen.NUI/src/internal/Interop/NDalicPINVOKE.cs +++ b/src/Tizen.NUI/src/internal/Interop/NDalicPINVOKE.cs @@ -245,6 +245,14 @@ static NDalicPINVOKE() { } + static internal void Preload() + { + // Do nothing. Just call for load static values. + var temporalSwigExceptionHelper = swigExceptionHelper; + var temporalSwigStringHelper = swigStringHelper; + ThrowExceptionIfExists(); + } + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_delete_BaseHandle")] public static extern void DeleteBaseHandle(global::System.Runtime.InteropServices.HandleRef jarg1); diff --git a/src/Tizen.NUI/src/internal/Xaml/CreateValuesVisitor.cs b/src/Tizen.NUI/src/internal/Xaml/CreateValuesVisitor.cs index 266e0b4603e..a7b98c68939 100755 --- a/src/Tizen.NUI/src/internal/Xaml/CreateValuesVisitor.cs +++ b/src/Tizen.NUI/src/internal/Xaml/CreateValuesVisitor.cs @@ -202,9 +202,9 @@ public void Visit(ElementNode node, INode parentNode) Values[node] = value; } - - if (value != null && value is BindableObject) - NameScope.SetNameScope(value as BindableObject, node.Namescope); + var bindableObject = value as BindableObject; + if (bindableObject != null) + NameScope.SetNameScope(bindableObject, node.Namescope); } public void Visit(RootNode node, INode parentNode) diff --git a/src/Tizen.NUI/src/public/Accessibility/Accessibility.cs b/src/Tizen.NUI/src/public/Accessibility/Accessibility.cs index 77ac71117af..a8ef2c92127 100755 --- a/src/Tizen.NUI/src/public/Accessibility/Accessibility.cs +++ b/src/Tizen.NUI/src/public/Accessibility/Accessibility.cs @@ -16,10 +16,11 @@ */ using System; +using System.Collections.Generic; using System.ComponentModel; +using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; using Tizen.NUI.BaseComponents; -using System.Diagnostics.CodeAnalysis; namespace Tizen.NUI.Accessibility { @@ -105,12 +106,10 @@ public static bool IsScreenReaderEnabled /// // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) [EditorBrowsable(EditorBrowsableState.Never)] - public static bool Say(string sentence, bool discardable) + public static void Say(string sentence, bool discardable) { - bool ret = Interop.Accessibility.Say(sentence, discardable, Marshal.GetFunctionPointerForDelegate(callback)); - + Interop.Accessibility.Say(sentence, discardable, SayFinishedEventCallback); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; } /// @@ -314,12 +313,6 @@ public enum SayFinishedState #endregion Event, Enum, Struct, ETC #region Private - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate void SayFinishedEventCallbackType(int result); - - private static SayFinishedEventCallbackType callback = SayFinishedEventCallback; - private static Interop.Accessibility.EnabledDisabledSignalHandler enabledSignalHandler = null; private static Interop.Accessibility.EnabledDisabledSignalHandler disabledSignalHandler = null; @@ -328,9 +321,24 @@ public enum SayFinishedState private static Interop.Accessibility.EnabledDisabledSignalHandler screenReaderDisabledSignalHandler = null; - private static void SayFinishedEventCallback(int result) + private static readonly IReadOnlyDictionary sayFinishedStateDictionary = new Dictionary + { + ["ReadingCancelled"] = SayFinishedState.Cancelled, + ["ReadingStopped"] = SayFinishedState.Stopped, + ["ReadingSkipped"] = SayFinishedState.Skipped, + ["ReadingPaused"] = SayFinishedState.Paused, + ["ReadingResumed"] = SayFinishedState.Resumed, + }; + + private static void SayFinishedEventCallback(string status) { + SayFinishedState result; + if (!sayFinishedStateDictionary.TryGetValue(status, out result)) + { + result = SayFinishedState.Invalid; + } NUILog.Debug($"sayFinishedEventCallback(res={result}) called!"); + SayFinished?.Invoke(typeof(Accessibility), new SayFinishedEventArgs(result)); } @@ -357,9 +365,9 @@ public Accessibility.SayFinishedState State get; } - internal SayFinishedEventArgs(int result) + internal SayFinishedEventArgs(Accessibility.SayFinishedState state) { - State = (Accessibility.SayFinishedState)(result); + State = state; NUILog.Debug($"SayFinishedEventArgs Constructor! State={State}"); } } diff --git a/src/Tizen.NUI/src/public/Accessibility/IAtspiSelection.cs b/src/Tizen.NUI/src/public/Accessibility/IAtspiSelection.cs index 38f1a66dcb6..0ee0b18e0cd 100644 --- a/src/Tizen.NUI/src/public/Accessibility/IAtspiSelection.cs +++ b/src/Tizen.NUI/src/public/Accessibility/IAtspiSelection.cs @@ -65,7 +65,7 @@ public interface IAtspiSelection /// Checks whether a child is selected. /// /// The index of the child - /// < True if given child is selected, false otherwise /returns> + /// True if given child is selected, false otherwise [EditorBrowsable(EditorBrowsableState.Never)] bool AccessibilityIsChildSelected(int childIndex); diff --git a/src/Tizen.NUI/src/public/Animation/Animatable.cs b/src/Tizen.NUI/src/public/Animation/Animatable.cs index 91233e65d70..b587488e575 100755 --- a/src/Tizen.NUI/src/public/Animation/Animatable.cs +++ b/src/Tizen.NUI/src/public/Animation/Animatable.cs @@ -26,6 +26,11 @@ namespace Tizen.NUI /// 3 public class Animatable : BaseHandle { + static internal new void Preload() + { + BaseHandle.Preload(); + // Do nothing. Just call for load static values. + } /// /// Create an instance of animatable. diff --git a/src/Tizen.NUI/src/public/Application/NUIApplication.cs b/src/Tizen.NUI/src/public/Application/NUIApplication.cs index 457b5916e09..eabcdef9ef4 100755 --- a/src/Tizen.NUI/src/public/Application/NUIApplication.cs +++ b/src/Tizen.NUI/src/public/Application/NUIApplication.cs @@ -640,6 +640,22 @@ protected override void OnCreate() static public void Preload() { Interop.Application.PreInitialize(); + + // Initialize some static utility + var disposalbeQueue = DisposeQueue.Instance; + var registry = Registry.Instance; + + // Initialize some BaseComponent static variables now + BaseComponents.View.Preload(); + BaseComponents.ImageView.Preload(); + BaseComponents.TextLabel.Preload(); + BaseComponents.TextEditor.Preload(); + BaseComponents.TextField.Preload(); + Disposable.Preload(); + + // Initialize exception tasks. It must be called end of Preload() + NDalicPINVOKE.Preload(); + IsPreload = true; } diff --git a/src/Tizen.NUI/src/public/BaseComponents/DirectRenderingGLView.cs b/src/Tizen.NUI/src/public/BaseComponents/DirectRenderingGLView.cs index b2bf0d90560..2946cb4ebba 100644 --- a/src/Tizen.NUI/src/public/BaseComponents/DirectRenderingGLView.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/DirectRenderingGLView.cs @@ -183,18 +183,23 @@ public void BindTextureResources(List textures) { unsafe { - if (textures != null && sizeof(IntPtr) * textures.Count > 0) + + if (textures != null) { - IntPtr unmanagedPointer = Marshal.AllocHGlobal(checked(sizeof(IntPtr) * textures.Count)); - IntPtr[] texturesArray = new IntPtr[textures.Count]; - for (int i = 0; i < textures.Count; i++) + int intptrBytes = checked(sizeof(IntPtr) * textures.Count); + if (intptrBytes>0) { - texturesArray[i] = HandleRef.ToIntPtr(Texture.getCPtr(textures[i])); - } - System.Runtime.InteropServices.Marshal.Copy(texturesArray, 0, unmanagedPointer, textures.Count); + IntPtr unmanagedPointer = Marshal.AllocHGlobal(intptrBytes); + IntPtr[] texturesArray = new IntPtr[textures.Count]; + for (int i = 0; i < textures.Count; i++) + { + texturesArray[i] = HandleRef.ToIntPtr(Texture.getCPtr(textures[i])); + } + System.Runtime.InteropServices.Marshal.Copy(texturesArray, 0, unmanagedPointer, textures.Count); - Interop.GLView.GlViewBindTextureResources(SwigCPtr, unmanagedPointer, textures.Count); - Marshal.FreeHGlobal(unmanagedPointer); + Interop.GLView.GlViewBindTextureResources(SwigCPtr, unmanagedPointer, textures.Count); + Marshal.FreeHGlobal(unmanagedPointer); + } } } } diff --git a/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs b/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs index 7bdc3c1738a..407d042d46b 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs @@ -32,6 +32,15 @@ public partial class ImageView : View { static ImageView() { } + static internal new void Preload() + { + // Do not call View.Preload(), since we already call it + + Property.Preload(); + // Do nothing. Just call for load static values. + var temporalCachedImagePropertyKeyList = cachedImagePropertyKeyList; + } + private EventHandler _resourceReadyEventHandler; private ResourceReadyEventCallbackType _resourceReadyEventCallback; private EventHandler _resourceLoadedEventHandler; @@ -67,6 +76,7 @@ private static string ConvertResourceUrl(ref string value) ImageVisualProperty.WrapModeV, ImageVisualProperty.SynchronousLoading, Visual.Property.MixColor, + Visual.Property.Opacity, Visual.Property.PremultipliedAlpha, ImageVisualProperty.OrientationCorrection, ImageVisualProperty.FastTrackUploading, @@ -1881,6 +1891,11 @@ public ResourceLoadingStatusType Status internal static readonly int PixelArea = Interop.ImageView.PixelAreaGet(); internal static readonly int PlaceHolderUrl = Interop.ImageView.PlaceHolderImageGet(); internal static readonly int TransitionEffect = Interop.ImageView.TransitionEffectGet(); + + internal static void Preload() + { + // Do nothing. Just call for load static values. + } } private enum ImageType diff --git a/src/Tizen.NUI/src/public/BaseComponents/ImageViewBindableProperty.cs b/src/Tizen.NUI/src/public/BaseComponents/ImageViewBindableProperty.cs index 5ea4767eb17..f8b861331ac 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ImageViewBindableProperty.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ImageViewBindableProperty.cs @@ -589,6 +589,7 @@ public partial class ImageView var imageView = (ImageView)bindable; if (newValue != null) { + imageView.UpdateImage(Visual.Property.Opacity, new PropertyValue(((Color)newValue).A), false); imageView.UpdateImage(Visual.Property.MixColor, new PropertyValue((Color)newValue)); } }, diff --git a/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs b/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs index 91ec9121c84..a4447f2adb9 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs @@ -970,7 +970,8 @@ public enum VectorProperty internal static readonly int ActionJumpTo = Interop.LottieAnimationView.AnimatedVectorImageVisualActionJumpToGet(); // This is used for internal purpose. - internal static readonly int ActionSetDynamicProperty = Interop.LottieAnimationView.AnimatedVectorImageVisualActionSetDynamicProperty(); + internal static readonly int ActionSetDynamicProperty = Interop.LottieAnimationView.AnimatedVectorImageVisualActionSetDynamicPropertyGet(); + internal static readonly int ActionFlush = Interop.LottieAnimationView.AnimatedVectorImageVisualActionFlushGet(); internal class VisualEventSignalArgs : EventArgs { @@ -1110,6 +1111,13 @@ static internal void RootCallback(int id, int returnType, uint frameNumber, ref } ret?.Dispose(); } + + internal void FlushLottieMessages() + { + NUILog.Debug($"<[{GetId()}]FLUSH>"); + + Interop.View.DoActionWithEmptyAttributes(this.SwigCPtr, ImageView.Property.IMAGE, ActionFlush); + } #endregion Internal diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextConstants.cs b/src/Tizen.NUI/src/public/BaseComponents/TextConstants.cs index b141b0a680b..85b0b0d0c3d 100644 --- a/src/Tizen.NUI/src/public/BaseComponents/TextConstants.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextConstants.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Samsung Electronics Co., Ltd. +// Copyright (c) 2023 Samsung Electronics Co., Ltd. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -13,6 +13,7 @@ // limitations under the License. using System; +using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics.CodeAnalysis; @@ -546,6 +547,77 @@ public bool Equals(TextFit other) => Enable == other.Enable && MinSize == other. public override int GetHashCode() => (Enable, MinSize, MaxSize, StepSize, FontSizeType, FontSize).GetHashCode(); } + /// + /// A struct to pass data of TextFitArray's OptionList. + /// + /// + /// The TextFitArrayOption struct is used as an item to TextFitArray's OptionList.
+ /// See . + ///
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1815: Override equals and operator equals on value types")] + [EditorBrowsable(EditorBrowsableState.Never)] + public struct TextFitArrayOption + { + /// + /// Constructor. + /// + /// The PointSize for TextFitArrayOption + [EditorBrowsable(EditorBrowsableState.Never)] + public TextFitArrayOption(float pointSize) + { + PointSize = pointSize; + MinLineSize = null; + } + + /// + /// Constructor. + /// + /// The PointSize for TextFitArrayOption + /// The MinLineSize for TextFitArrayOption + [EditorBrowsable(EditorBrowsableState.Never)] + public TextFitArrayOption(float pointSize, float? minLineSize) + { + PointSize = pointSize; + MinLineSize = minLineSize; + } + + /// + /// Point size for text fit array. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public float PointSize { get; set; } + + /// + /// Min line size for text fit array. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public float? MinLineSize { get; set; } + } + + /// + /// A struct to pass data of SetTextFitArray and GetTextFitArray methods. + /// + /// + /// The TextFitArray struct is used as an argument to SetTextFitArray and GetTextFitArray methods.
+ /// See and . + ///
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1815: Override equals and operator equals on value types")] + [EditorBrowsable(EditorBrowsableState.Never)] + public struct TextFitArray + { + /// + /// True to enable the text fit array or false to disable (the default value is false). + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool Enable { get; set; } + + /// + /// A List of TextFitArrayOptions. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public List OptionList { get; set; } + } + /// /// A struct to pass data of Placeholder PropertyMap.
///
diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs b/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs index 85f6d988080..61b41598341 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs @@ -57,6 +57,14 @@ public partial class TextEditor : View static TextEditor() { } + static internal new void Preload() + { + // Do not call View.Preload(), since we already call it + + Property.Preload(); + // Do nothing. Just call for load static values. + } + /// /// Creates the TextEditor control. /// @@ -2767,6 +2775,11 @@ private void TextEditorTextChanged(object sender, TextChangedEventArgs e) internal static readonly int InputFilter = Interop.TextEditor.InputFilterGet(); internal static readonly int Strikethrough = Interop.TextEditor.StrikethroughGet(); internal static readonly int CharacterSpacing = Interop.TextEditor.CharacterSpacingGet(); + + internal static void Preload() + { + // Do nothing. Just call for load static values. + } } internal class InputStyle diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextField.cs b/src/Tizen.NUI/src/public/BaseComponents/TextField.cs index 36f50b05b27..e2506a78f7a 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextField.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextField.cs @@ -57,6 +57,14 @@ public partial class TextField : View static TextField() { } + static internal new void Preload() + { + // Do not call View.Preload(), since we already call it + + Property.Preload(); + // Do nothing. Just call for load static values. + } + /// /// Creates the TextField control. /// @@ -2765,6 +2773,11 @@ private void TextFieldTextChanged(object sender, TextChangedEventArgs e) internal static readonly int InputFilter = Interop.TextField.InputFilterGet(); internal static readonly int Strikethrough = Interop.TextField.StrikethroughGet(); internal static readonly int CharacterSpacing = Interop.TextField.CharacterSpacingGet(); + + internal static void Preload() + { + // Do nothing. Just call for load static values. + } } internal class InputStyle diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs b/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs index 91e36592140..98474f4e8a7 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs @@ -1,5 +1,5 @@ /* - * Copyright(c) 2021 Samsung Electronics Co., Ltd. + * Copyright(c) 2023 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -84,6 +84,14 @@ protected override void OnMeasure(MeasureSpecification widthMeasureSpec, Measure static TextLabel() { } + static internal new void Preload() + { + // Do not call View.Preload(), since we already call it + + Property.Preload(); + // Do nothing. Just call for load static values. + } + private static SystemFontTypeChanged systemFontTypeChanged = new SystemFontTypeChanged(); private static SystemLocaleLanguageChanged systemLocaleLanguageChanged = new SystemLocaleLanguageChanged(); static private string defaultStyleName = "Tizen.NUI.BaseComponents.TextLabel"; @@ -1404,6 +1412,105 @@ public TextFit GetTextFit() return textFit; } + /// + /// Set TextFitArray to TextLabel.
+ /// TextFitArray finds and applies the largest PointSize that fits among OptionList. + ///
+ /// The TextFitArray + /// + /// TextFitArray tries binary search by default.
+ /// The precondition for TextFitArray to perform binary search is sorting in ascending order of MinLineSize.
+ /// Because if MinLineSize is not sorted in ascending order,
+ /// binary search cannot guarantee that it will always find the best value.
+ /// In this case, the search sequentially starts from the largest PointSize.
+ /// If TextFitArrayOption's MinLineSize is set to null or 0,
+ /// TextFitArray is calculated without applying MinLineSize.
+ /// If TextFitArray is enabled, TextLabel's MinLineSize property is ignored.
+ /// See and . + ///
+ /// + /// The following example demonstrates how to use the SetTextFitArray method.
+ /// + /// var textFitArray = new Tizen.NUI.Text.TextFitArray(); + /// textFitArray.Enable = true; + /// textFitArray.OptionList = new List<Tizen.NUI.Text.TextFitArrayOption>() + /// { + /// new Tizen.NUI.Text.TextFitArrayOption(12, 18), + /// new Tizen.NUI.Text.TextFitArrayOption(24, 40), + /// new Tizen.NUI.Text.TextFitArrayOption(28, 48), + /// new Tizen.NUI.Text.TextFitArrayOption(32, 56), + /// new Tizen.NUI.Text.TextFitArrayOption(50, 72), + /// }; + /// label.SetTextFitArray(textFitArray); + /// + ///
+ /// The table below shows cases where binary search is possible and where it is not possible.
+ /// + /// [Binary search possible] + /// | | List index | 0 | 1 | 2 | 3 | + /// | OptionList | PointSize | 24 | 28 | 32 | 48 | + /// | | MinLineSize | 40 | 48 | 48 | 62 | << MinLineSize sorted in ascending order + /// ^ ^ + /// same values ​are not a problem + /// + /// [Binary search not possible] + /// | | List index | 0 | 1 | 2 | 3 | + /// | OptionList | PointSize | 24 | 28 | 32 | 48 | + /// | | MinLineSize | 40 | 48 | 38 | 62 | << MinLineSize is not sorted in ascending order + /// ^ + /// + ///
+ [EditorBrowsable(EditorBrowsableState.Never)] + public void SetTextFitArray(TextFitArray textFitArray) + { + bool enable = textFitArray.Enable; + int optionListSize = textFitArray.OptionList?.Count ?? 0; + + float[] pointSizeArray = new float[optionListSize]; + float[] minLineSizeArray = new float[optionListSize]; + + for (int i = 0 ; i < optionListSize ; i ++) + { + TextFitArrayOption option = textFitArray.OptionList[i]; + pointSizeArray[i] = option.PointSize; + minLineSizeArray[i] = option.MinLineSize ?? 0; + } + + Interop.TextLabel.SetTextFitArray(SwigCPtr, enable, (uint)optionListSize, pointSizeArray, minLineSizeArray); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Get TextFitArray from TextLabel. + /// + /// The TextFitArray + /// + /// See and . + /// + /// + /// The following example demonstrates how to use the GetTextFitArray method.
+ /// + /// Tizen.NUI.Text.TextFitArray textFitArray = label.GetTextFitArray(); + /// bool enable = textFitArray.Enable; + /// var optionList = textFitArray.OptionList; + /// foreach(Tizen.NUI.Text.TextFitArrayOption option in optionList) + /// { + /// float pointSize = option.PointSize; + /// float minLinesize = option.MinLineSize; + /// } + /// + ///
+ [EditorBrowsable(EditorBrowsableState.Never)] + public TextFitArray GetTextFitArray() + { + using PropertyMap textFitArrayMap = new PropertyMap(Interop.TextLabel.GetTextFitArray(SwigCPtr), true); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + + TextFitArray textFitArray; + textFitArray = TextUtils.GetMapToTextFitArray(textFitArrayMap); + return textFitArray; + } + /// /// The MinLineSize property.
/// The height of the line in points.
@@ -1748,6 +1855,11 @@ private void RequestLayout() internal static readonly int EllipsisPosition = Interop.TextLabel.EllipsisPositionGet(); internal static readonly int Strikethrough = Interop.TextLabel.StrikethroughGet(); internal static readonly int CharacterSpacing = Interop.TextLabel.CharacterSpacingGet(); + + internal static void Preload() + { + // Do nothing. Just call for load static values. + } } private void OnShadowColorChanged(float x, float y, float z, float w) diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextMapHelper.cs b/src/Tizen.NUI/src/public/BaseComponents/TextMapHelper.cs index d90ce64441f..cf0454940f1 100644 --- a/src/Tizen.NUI/src/public/BaseComponents/TextMapHelper.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextMapHelper.cs @@ -1,5 +1,5 @@ /* - * Copyright(c) 2021 Samsung Electronics Co., Ltd. + * Copyright(c) 2023 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -737,6 +737,16 @@ internal static PropertyMap GetMapFromMap(PropertyMap map, int key) return value; } + internal static PropertyArray GetArrayFromMap(PropertyMap map, string key) + { + PropertyArray value = new PropertyArray(); + using (var propertyValue = map.Find(0, key)) + { + if (null != propertyValue) propertyValue.Get(value); + } + return value; + } + internal static int? GetNullableIntFromMap(PropertyMap map, int key) { using (var propertyValue = map.Find(key)) diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextUtils.cs b/src/Tizen.NUI/src/public/BaseComponents/TextUtils.cs index 93edc25bdd9..b1255b01418 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextUtils.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextUtils.cs @@ -1,5 +1,5 @@ /* - * Copyright(c) 2020 Samsung Electronics Co., Ltd. + * Copyright(c) 2023 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -1122,6 +1122,40 @@ public static List GetFontInfoList(PropertyArray fontArray) return fontList; } + /// + /// This method converts a TextFitArray property map to a TextFitArray and returns it. + /// The TextFitArray PropertyMap. + /// A TextFitArray struct. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static TextFitArray GetMapToTextFitArray(PropertyMap textFitArrayMap) + { + var textFitArray = new TextFitArray(); + if (textFitArrayMap != null) + { + textFitArray.Enable = TextMapHelper.GetBoolFromMap(textFitArrayMap, "enable", false); + textFitArray.OptionList = new List(); + + var pointSizeArray = TextMapHelper.GetArrayFromMap(textFitArrayMap, "pointSizeArray"); + var minLineSizeArray = TextMapHelper.GetArrayFromMap(textFitArrayMap, "minLineSizeArray"); + + if (pointSizeArray != null && minLineSizeArray != null && pointSizeArray.Count() == minLineSizeArray.Count()) + { + for (uint i = 0 ; i < pointSizeArray.Count() ; i ++) + { + using (var pointSizeValue = pointSizeArray[i]) + using (var minLineSizeValue = minLineSizeArray[i]) + { + minLineSizeValue.Get(out float minLineSize); + pointSizeValue.Get(out float pointSize); + textFitArray.OptionList.Add(new TextFitArrayOption(pointSize, minLineSize)); + } + } + } + } + return textFitArray; + } + #if PROFILE_TV private const float FontSizeScaleSmall = 0.8f; private const float FontSizeScaleNormal = 1.0f; diff --git a/src/Tizen.NUI/src/public/BaseComponents/VectorGraphics/Shape.cs b/src/Tizen.NUI/src/public/BaseComponents/VectorGraphics/Shape.cs index 903563fcf96..56f9941621a 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/VectorGraphics/Shape.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/VectorGraphics/Shape.cs @@ -20,6 +20,7 @@ using System.Collections.ObjectModel; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices; namespace Tizen.NUI.BaseComponents.VectorGraphics { @@ -73,7 +74,18 @@ public Gradient FillGradient get { global::System.IntPtr cPtr = Interop.Shape.GetFillGradient(BaseHandle.getCPtr(this)); - Gradient ret = new Gradient(cPtr, true); + + Gradient ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Gradient; + if (ret != null) + { + HandleRef CPtr = new HandleRef(this, cPtr); + Interop.BaseHandle.DeleteBaseHandle(CPtr); + CPtr = new HandleRef(null, global::System.IntPtr.Zero); + } + else + { + ret = new Gradient(cPtr, true); + } return ret; } set @@ -149,7 +161,18 @@ public Gradient StrokeGradient get { global::System.IntPtr cPtr = Interop.Shape.GetStrokeGradient(BaseHandle.getCPtr(this)); - Gradient ret = new Gradient(cPtr, true); + + Gradient ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Gradient; + if (ret != null) + { + HandleRef CPtr = new HandleRef(this, cPtr); + Interop.BaseHandle.DeleteBaseHandle(CPtr); + CPtr = new HandleRef(null, global::System.IntPtr.Zero); + } + else + { + ret = new Gradient(cPtr, true); + } return ret; } set diff --git a/src/Tizen.NUI/src/public/BaseComponents/View.cs b/src/Tizen.NUI/src/public/BaseComponents/View.cs index 059284387b0..0876bf7ff02 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/View.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/View.cs @@ -105,6 +105,16 @@ static View() RegisterAccessibilityDelegate(); } + static internal new void Preload() + { + Container.Preload(); + + // Do nothing. Just call for load static values. + var temporalPositionPropertyGroup = positionPropertyGroup; + var temporalSizePropertyGroup = sizePropertyGroup; + var temporalScalePropertyGroup = scalePropertyGroup; + } + /// /// Accessibility mode for controlling View's Accessible implementation. /// It is only relevant when deriving custom controls from View directly, @@ -856,12 +866,24 @@ private string InternalTooltipText { using (var propertyValue = GetProperty(Property.TOOLTIP)) { - if (propertyValue != null && propertyValue.Get(out string retrivedValue)) + using var propertyMap = new PropertyMap(); + if (propertyValue != null && propertyValue.Get(propertyMap)) { - return retrivedValue; + using var retrivedContentValue = propertyMap?.Find(NDalic.TooltipContent); + if (retrivedContentValue != null) + { + using var contextPropertyMap = new PropertyMap(); + if (retrivedContentValue.Get(contextPropertyMap)) + { + using var retrivedTextValue = contextPropertyMap?.Find(NDalic.TextVisualText); + if (retrivedTextValue != null && retrivedTextValue.Get(out string retrivedValue)) + { + return retrivedValue; + } + } + } } - NUILog.Error($"[ERROR] Fail to get TooltipText! Return error MSG (error to get TooltipText)!"); - return "error to get TooltipText"; + return ""; } } set diff --git a/src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs b/src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs index 708ae8e6750..6afade18e13 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs @@ -2582,6 +2582,42 @@ public partial class View return instance.InternalTouchAreaOffset; }); + /// + /// DispatchTouchMotionProperty + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static readonly BindableProperty DispatchTouchMotionProperty = BindableProperty.Create(nameof(DispatchTouchMotion), typeof(bool), typeof(View), false, propertyChanged: (bindable, oldValue, newValue) => + { + var instance = (Tizen.NUI.BaseComponents.View)bindable; + if (newValue != null) + { + instance.InternalDispatchTouchMotion = (bool)newValue; + } + }, + defaultValueCreator: (bindable) => + { + var instance = (Tizen.NUI.BaseComponents.View)bindable; + return instance.InternalDispatchTouchMotion; + }); + + /// + /// DispatchHoverMotionProperty + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static readonly BindableProperty DispatchHoverMotionProperty = BindableProperty.Create(nameof(DispatchHoverMotion), typeof(bool), typeof(View), false, propertyChanged: (bindable, oldValue, newValue) => + { + var instance = (Tizen.NUI.BaseComponents.View)bindable; + if (newValue != null) + { + instance.InternalDispatchHoverMotion = (bool)newValue; + } + }, + defaultValueCreator: (bindable) => + { + var instance = (Tizen.NUI.BaseComponents.View)bindable; + return instance.InternalDispatchHoverMotion; + }); + /// /// Gets View's Size2D set by user. /// diff --git a/src/Tizen.NUI/src/public/BaseComponents/ViewEnum.cs b/src/Tizen.NUI/src/public/BaseComponents/ViewEnum.cs index 639bd542523..c7bc20d6663 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ViewEnum.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ViewEnum.cs @@ -264,6 +264,8 @@ internal class Property internal static readonly int AccessibilityHidden = Interop.ViewProperty.AccessibilityHiddenGet(); internal static readonly int AutomationId = Interop.ViewProperty.AutomationIdGet(); internal static readonly int UpdateAreaHint = Interop.ActorProperty.UpdateAreaHintGet(); + internal static readonly int DispatchTouchMotion = Interop.ActorProperty.DispatchTouchMotionGet(); + internal static readonly int DispatchHoverMotion = Interop.ActorProperty.DispatchHoverMotionGet(); } } } diff --git a/src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs b/src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs index f7951915372..702e81d7ea9 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs @@ -104,8 +104,6 @@ public partial class View private bool dispatchParentHoverEvents = true; private bool dispatchGestureEvents = true; private bool dispatchParentGestureEvents = true; - private bool dispatchTouchMotion = true; - private bool dispatchHoverMotion = true; /// @@ -842,12 +840,6 @@ private bool OnInterceptTouch(IntPtr view, IntPtr touchData) TouchEventArgs e = new TouchEventArgs(); e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData); - // If DispatchTouchMotion is false, Motion event is not dispatched. - if (DispatchTouchMotion == false && e.Touch.GetState(0) == PointStateType.Motion) - { - return true; - } - bool consumed = false; if (interceptTouchDataEventHandler != null) @@ -876,13 +868,6 @@ private bool OnTouch(IntPtr view, IntPtr touchData) TouchEventArgs e = new TouchEventArgs(); e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData); - // If DispatchTouchMotion is false, Motion event is not dispatched. - if (DispatchTouchMotion == false && e.Touch.GetState(0) == PointStateType.Motion) - { - return true; - } - - bool consumed = false; if (touchDataEventHandler != null) @@ -922,12 +907,6 @@ private bool OnHoverEvent(IntPtr view, IntPtr hoverEvent) HoverEventArgs e = new HoverEventArgs(); e.Hover = Tizen.NUI.Hover.GetHoverFromPtr(hoverEvent); - // If DispatchHoverMotion is false, Motion event is not dispatched. - if (DispatchHoverMotion == false && e.Hover.GetState(0) == PointStateType.Motion) - { - return true; - } - bool consumed = false; if (hoverEventHandler != null) @@ -1677,11 +1656,24 @@ public bool DispatchTouchMotion { get { - return dispatchTouchMotion; + return (bool)GetValue(DispatchTouchMotionProperty); + } + set + { + SetValue(DispatchTouchMotionProperty, value); + } + } + + private bool InternalDispatchTouchMotion + { + get + { + return Object.InternalGetPropertyBool(SwigCPtr, View.Property.DispatchTouchMotion); } set { - dispatchTouchMotion = value; + Object.InternalSetPropertyBool(SwigCPtr, View.Property.DispatchTouchMotion, value); + NotifyPropertyChanged(); } } @@ -1694,13 +1686,25 @@ public bool DispatchHoverMotion { get { - return dispatchHoverMotion; + return (bool)GetValue(DispatchHoverMotionProperty); } set { - dispatchHoverMotion = value; + SetValue(DispatchHoverMotionProperty, value); } } + private bool InternalDispatchHoverMotion + { + get + { + return Object.InternalGetPropertyBool(SwigCPtr, View.Property.DispatchHoverMotion); + } + set + { + Object.InternalSetPropertyBool(SwigCPtr, View.Property.DispatchHoverMotion, value); + NotifyPropertyChanged(); + } + } } } diff --git a/src/Tizen.NUI/src/public/Common/BaseHandle.cs b/src/Tizen.NUI/src/public/Common/BaseHandle.cs index cca7f46e57d..b8e7eb3ce76 100755 --- a/src/Tizen.NUI/src/public/Common/BaseHandle.cs +++ b/src/Tizen.NUI/src/public/Common/BaseHandle.cs @@ -28,6 +28,11 @@ namespace Tizen.NUI /// 3 public class BaseHandle : Element, global::System.IDisposable { + static internal void Preload() + { + // Do nothing. Just call for load static values. + } + /// /// swigCMemOwn /// @@ -69,6 +74,29 @@ public BaseHandle(BaseHandle handle) : this(Interop.BaseHandle.NewBaseHandle(Bas if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } + internal BaseHandle(global::System.IntPtr cPtr, bool cMemoryOwn, bool cRegister) + { + //to catch derived classes dali native exceptions + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + + DebugFileLogging.Instance.WriteLog($"BaseHandle.contructor with cMemeryOwn:{cMemoryOwn} and cRegister:{cRegister} START"); + + registerMe = cRegister; + swigCMemOwn = cMemoryOwn; + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + + if (registerMe) + { + // Register this instance of BaseHandle in the registry. + Registry.Register(this); + } + + disposeDebuggingCtor(); + DebugFileLogging.Instance.WriteLog($" BaseHandle.contructor with cMemeryOwn and cRegister END"); + DebugFileLogging.Instance.WriteLog($"============================="); + } + internal BaseHandle(global::System.IntPtr cPtr, bool cMemoryOwn) { //to catch derived classes dali native exceptions @@ -511,6 +539,15 @@ internal void NotifyPropertyChanged([CallerMemberName] String propertyName = "") PropertySet?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } + internal void UnregisterFromRegistry() + { + if (registerMe) + { + Registry.Unregister(this); + registerMe = false; + } + } + /// /// Dispose. /// @@ -537,10 +574,7 @@ protected virtual void Dispose(DisposeTypes type) //because the execution order of Finalizes is non-deterministic. //Unreference this instance from Registry. - if (registerMe) - { - Registry.Unregister(this); - } + UnregisterFromRegistry(); disposeDebuggingDispose(type); @@ -617,7 +651,7 @@ public class FocusRequestArgs : EventArgs for (int i = 0; i < st.FrameCount; i++) { global::System.Diagnostics.StackFrame sf = st.GetFrame(i); - Tizen.Log.Fatal("NUI", " Method " + sf.GetMethod()); + Tizen.Log.Fatal("NUI", " Method " + sf.GetMethod() + ":" + sf.GetFileName() + ":" + sf.GetFileLineNumber()); } Tizen.Log.Fatal("NUI", "Error! just return here with null swigCPtr! this can cause unknown error or crash in next step"); @@ -665,7 +699,7 @@ private void disposeDebuggingCtor() for (int i = 0; i < st.FrameCount; i++) { global::System.Diagnostics.StackFrame sf = st.GetFrame(i); - DebugFileLogging.Instance.WriteLog($"[{i}] {sf.GetMethod()}"); + DebugFileLogging.Instance.WriteLog($"[{i}] {sf.GetMethod()}:{sf.GetFileName()}:{sf.GetFileLineNumber()}"); } } } diff --git a/src/Tizen.NUI/src/public/Common/Container.cs b/src/Tizen.NUI/src/public/Common/Container.cs index 13577bf0c79..fdfbf2c9c81 100755 --- a/src/Tizen.NUI/src/public/Common/Container.cs +++ b/src/Tizen.NUI/src/public/Common/Container.cs @@ -41,6 +41,14 @@ public abstract class Container : Animatable, IResourcesProvider ResourceDictionary _resources; bool IResourcesProvider.IsResourcesCreated => _resources != null; + static internal new void Preload() + { + Animatable.Preload(); + + // Do nothing. Just call for load static values. + var temporalXamlStyleProperty = XamlStyleProperty; + } + internal Container(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn) { // No un-managed data hence no need to store a native ptr diff --git a/src/Tizen.NUI/src/public/DragAndDrop/DragAndDrop.cs b/src/Tizen.NUI/src/public/DragAndDrop/DragAndDrop.cs index 0a2601cd34b..52b0c9eb33d 100755 --- a/src/Tizen.NUI/src/public/DragAndDrop/DragAndDrop.cs +++ b/src/Tizen.NUI/src/public/DragAndDrop/DragAndDrop.cs @@ -1,5 +1,5 @@ /* - * Copyright(c) 2022 Samsung Electronics Co., Ltd. + * Copyright(c) 2023 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,13 +33,18 @@ public class DragAndDrop : BaseHandle public delegate void SourceEventHandler(DragSourceEventType sourceEventType); private delegate void InternalSourceEventHandler(int sourceEventType); public delegate void DragAndDropEventHandler(View targetView, DragEvent dragEvent); + [EditorBrowsable(EditorBrowsableState.Never)] + public delegate void DragAndDropWindowEventHandler(Window targetWindow, DragEvent dragEvent); private delegate void InternalDragAndDropEventHandler(global::System.IntPtr dragEvent); private InternalSourceEventHandler sourceEventCb; private Dictionary targetEventDictionary = new Dictionary(); + private Dictionary targetWindowEventDictionary = new Dictionary(); private View mShadowView; private Window mDragWindow; private int shadowWidth; private int shadowHeight; + private int dragWindowOffsetX = 0; + private int dragWindowOffsetY = 0; private bool initDrag = false; @@ -120,7 +125,7 @@ public void StartDragAndDrop(View sourceView, View shadowView, DragData dragData shadowHeight = MinDragWindowHeight; } - mDragWindow = new Window("DragWindow", new Rectangle(-shadowWidth, -shadowHeight, shadowWidth, shadowHeight), true) + mDragWindow = new Window("DragWindow", new Rectangle(dragWindowOffsetX, dragWindowOffsetY, shadowWidth, shadowHeight), true) { BackgroundColor = Color.Transparent, }; @@ -215,7 +220,7 @@ public void AddListener(View targetView, DragAndDropEventHandler callback) if (!Interop.DragAndDrop.AddListener(SwigCPtr, View.getCPtr(targetView), new global::System.Runtime.InteropServices.HandleRef(this, Marshal.GetFunctionPointerForDelegate(cb)))) { - throw new InvalidOperationException("Fail to AddListener"); + throw new InvalidOperationException("Fail to AddListener for View"); } } @@ -229,7 +234,7 @@ public void RemoveListener(View targetView, DragAndDropEventHandler callback) { if (!targetEventDictionary.ContainsKey(targetView)) { - throw new InvalidOperationException("Fail to RemoveListener"); + throw new InvalidOperationException("Fail to RemoveListener for View"); } InternalDragAndDropEventHandler cb = targetEventDictionary[targetView]; @@ -237,8 +242,90 @@ public void RemoveListener(View targetView, DragAndDropEventHandler callback) if (!Interop.DragAndDrop.RemoveListener(SwigCPtr, View.getCPtr(targetView), new global::System.Runtime.InteropServices.HandleRef(this, Marshal.GetFunctionPointerForDelegate(cb)))) { - throw new InvalidOperationException("Fail to RemoveListener"); + throw new InvalidOperationException("Fail to RemoveListener for View"); } } + + /// + /// Adds listener for drop targets + /// + /// The target Window + /// The callback function to get drag event when the drag source enters, moves, leaves and drops on the drop target + [EditorBrowsable(EditorBrowsableState.Never)] + public void AddListener(Window targetWindow, DragAndDropWindowEventHandler callback) + { + InternalDragAndDropEventHandler cb = (dragEvent) => + { + DragType type = (DragType)Interop.DragAndDrop.GetAction(dragEvent); + DragEvent ev = new DragEvent(); + global::System.IntPtr cPtr = Interop.DragAndDrop.GetPosition(dragEvent); + ev.Position = (cPtr == global::System.IntPtr.Zero) ? null : new Position(cPtr, false); + + if (type == DragType.Enter) + { + ev.DragType = type; + callback(targetWindow, ev); + } + else if (type == DragType.Leave) + { + ev.DragType = type; + callback(targetWindow, ev); + } + else if (type == DragType.Move) + { + ev.DragType = type; + callback(targetWindow, ev); + } + else if (type == DragType.Drop) + { + ev.DragType = type; + ev.MimeType = Interop.DragAndDrop.GetMimeType(dragEvent); + ev.Data = Interop.DragAndDrop.GetData(dragEvent); + callback(targetWindow, ev); + } + }; + + targetWindowEventDictionary.Add(targetWindow, cb); + + if (!Interop.DragAndDrop.WindowAddListener(SwigCPtr, Window.getCPtr(targetWindow), + new global::System.Runtime.InteropServices.HandleRef(this, Marshal.GetFunctionPointerForDelegate(cb)))) + { + throw new InvalidOperationException("Fail to AddListener for Window"); + } + } + + /// + /// Removes listener for drop targets + /// + /// The target window + /// The callback function to remove + [EditorBrowsable(EditorBrowsableState.Never)] + public void RemoveListener(Window targetWindow, DragAndDropWindowEventHandler callback) + { + if (!targetWindowEventDictionary.ContainsKey(targetWindow)) + { + throw new InvalidOperationException("Fail to RemoveListener for Window"); + } + + InternalDragAndDropEventHandler cb = targetWindowEventDictionary[targetWindow]; + targetWindowEventDictionary.Remove(targetWindow); + if (!Interop.DragAndDrop.WindowRemoveListener(SwigCPtr, Window.getCPtr(targetWindow), + new global::System.Runtime.InteropServices.HandleRef(this, Marshal.GetFunctionPointerForDelegate(cb)))) + { + throw new InvalidOperationException("Fail to RemoveListener for Window"); + } + } + + /// + /// Sets drag window offset + /// + /// The x direction offset + /// The y direction offset + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetDragWindowOffset(int x, int y) + { + dragWindowOffsetX = x; + dragWindowOffsetY = y; + } } } diff --git a/src/Tizen.NUI/src/public/Events/Gesture.cs b/src/Tizen.NUI/src/public/Events/Gesture.cs index 9eb8b6fc67b..87f015e86b4 100755 --- a/src/Tizen.NUI/src/public/Events/Gesture.cs +++ b/src/Tizen.NUI/src/public/Events/Gesture.cs @@ -37,7 +37,11 @@ public Gesture(Gesture rhs) : this(Interop.Gesture.NewGesture(Gesture.getCPtr(rh if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } - internal Gesture(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn) + internal Gesture(global::System.IntPtr cPtr, bool cMemoryOwn) : this(cPtr, cMemoryOwn, cMemoryOwn) + { + } + + internal Gesture(global::System.IntPtr cPtr, bool cMemoryOwn, bool cRegister) : base(cPtr, cMemoryOwn, cRegister) { } diff --git a/src/Tizen.NUI/src/public/Events/Hover.cs b/src/Tizen.NUI/src/public/Events/Hover.cs index 20f0e6d1883..2f216d2fc4c 100755 --- a/src/Tizen.NUI/src/public/Events/Hover.cs +++ b/src/Tizen.NUI/src/public/Events/Hover.cs @@ -52,7 +52,11 @@ internal Hover(Hover other) : this(Interop.Hover.NewHover(Hover.getCPtr(other)), if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } - internal Hover(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn) + internal Hover(global::System.IntPtr cPtr, bool cMemoryOwn) : this(cPtr, cMemoryOwn, cMemoryOwn) + { + } + + internal Hover(global::System.IntPtr cPtr, bool cMemoryOwn, bool cRegister) : base(cPtr, cMemoryOwn, cRegister) { } diff --git a/src/Tizen.NUI/src/public/Events/LongPressGesture.cs b/src/Tizen.NUI/src/public/Events/LongPressGesture.cs index ff21038d631..14e63ff0688 100755 --- a/src/Tizen.NUI/src/public/Events/LongPressGesture.cs +++ b/src/Tizen.NUI/src/public/Events/LongPressGesture.cs @@ -35,7 +35,11 @@ public LongPressGesture(Gesture.StateType state) : this(Interop.LongPressGesture if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } - internal LongPressGesture(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn) + internal LongPressGesture(global::System.IntPtr cPtr, bool cMemoryOwn) : this(cPtr, cMemoryOwn, cMemoryOwn) + { + } + + internal LongPressGesture(global::System.IntPtr cPtr, bool cMemoryOwn, bool cRegister) : base(cPtr, cMemoryOwn, cRegister) { } diff --git a/src/Tizen.NUI/src/public/Events/PanGesture.cs b/src/Tizen.NUI/src/public/Events/PanGesture.cs index 7e4fadf6647..8587a69af1b 100755 --- a/src/Tizen.NUI/src/public/Events/PanGesture.cs +++ b/src/Tizen.NUI/src/public/Events/PanGesture.cs @@ -49,7 +49,11 @@ internal PanGesture(Gesture.StateType state) : this(Interop.PanGestureDetector.P if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } - internal PanGesture(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.PanGestureDetector.PanGestureUpcast(cPtr), cMemoryOwn) + internal PanGesture(global::System.IntPtr cPtr, bool cMemoryOwn) : this(Interop.PanGestureDetector.PanGestureUpcast(cPtr), cMemoryOwn, cMemoryOwn) + { + } + + internal PanGesture(global::System.IntPtr cPtr, bool cMemoryOwn, bool cRegister) : base(Interop.PanGestureDetector.PanGestureUpcast(cPtr), cMemoryOwn, cRegister) { } diff --git a/src/Tizen.NUI/src/public/Events/PinchGesture.cs b/src/Tizen.NUI/src/public/Events/PinchGesture.cs index 10394b2529e..25be2635bca 100755 --- a/src/Tizen.NUI/src/public/Events/PinchGesture.cs +++ b/src/Tizen.NUI/src/public/Events/PinchGesture.cs @@ -25,7 +25,11 @@ namespace Tizen.NUI /// 3 public class PinchGesture : Gesture { - internal PinchGesture(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn) + internal PinchGesture(global::System.IntPtr cPtr, bool cMemoryOwn) : this(cPtr, cMemoryOwn, cMemoryOwn) + { + } + + internal PinchGesture(global::System.IntPtr cPtr, bool cMemoryOwn, bool cRegister) : base(cPtr, cMemoryOwn, cRegister) { } diff --git a/src/Tizen.NUI/src/public/Events/RotationGesture.cs b/src/Tizen.NUI/src/public/Events/RotationGesture.cs index 7057c713cfc..a5658328901 100755 --- a/src/Tizen.NUI/src/public/Events/RotationGesture.cs +++ b/src/Tizen.NUI/src/public/Events/RotationGesture.cs @@ -26,8 +26,11 @@ namespace Tizen.NUI [EditorBrowsable(EditorBrowsableState.Never)] public class RotationGesture : Gesture { + internal RotationGesture(global::System.IntPtr cPtr, bool cMemoryOwn) : this(cPtr, cMemoryOwn, cMemoryOwn) + { + } - internal RotationGesture(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn) + internal RotationGesture(global::System.IntPtr cPtr, bool cMemoryOwn, bool cRegister) : base(cPtr, cMemoryOwn, cRegister) { } diff --git a/src/Tizen.NUI/src/public/Events/TapGesture.cs b/src/Tizen.NUI/src/public/Events/TapGesture.cs index 71045114d89..f9fe9818147 100755 --- a/src/Tizen.NUI/src/public/Events/TapGesture.cs +++ b/src/Tizen.NUI/src/public/Events/TapGesture.cs @@ -36,7 +36,11 @@ public TapGesture() : this(Interop.TapGesture.New(0), true) if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } - internal TapGesture(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn) + internal TapGesture(global::System.IntPtr cPtr, bool cMemoryOwn) : this(cPtr, cMemoryOwn, cMemoryOwn) + { + } + + internal TapGesture(global::System.IntPtr cPtr, bool cMemoryOwn, bool cRegister) : base(cPtr, cMemoryOwn, cRegister) { } diff --git a/src/Tizen.NUI/src/public/Events/Touch.cs b/src/Tizen.NUI/src/public/Events/Touch.cs index cc0111eac40..1028422ff87 100755 --- a/src/Tizen.NUI/src/public/Events/Touch.cs +++ b/src/Tizen.NUI/src/public/Events/Touch.cs @@ -42,7 +42,11 @@ internal Touch(Touch other) : this(Interop.Touch.NewTouch(Touch.getCPtr(other)), if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } - internal Touch(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.Touch.Upcast(cPtr), cMemoryOwn) + internal Touch(global::System.IntPtr cPtr, bool cMemoryOwn) : this(cPtr, cMemoryOwn, cMemoryOwn) + { + } + + internal Touch(global::System.IntPtr cPtr, bool cMemoryOwn, bool cRegister) : base(cPtr, cMemoryOwn, cRegister) { } diff --git a/src/Tizen.NUI/src/public/Events/Wheel.cs b/src/Tizen.NUI/src/public/Events/Wheel.cs index 368da455ae1..ab2d3be73d4 100755 --- a/src/Tizen.NUI/src/public/Events/Wheel.cs +++ b/src/Tizen.NUI/src/public/Events/Wheel.cs @@ -53,7 +53,11 @@ public Wheel(Wheel.WheelType type, int direction, uint modifiers, Vector2 point, if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } - internal Wheel(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn) + internal Wheel(global::System.IntPtr cPtr, bool cMemoryOwn) : this(cPtr, cMemoryOwn, cMemoryOwn) + { + } + + internal Wheel(global::System.IntPtr cPtr, bool cMemoryOwn, bool cRegister) : base(cPtr, cMemoryOwn, cRegister) { } diff --git a/src/Tizen.NUI/src/public/Images/PixelBuffer.cs b/src/Tizen.NUI/src/public/Images/PixelBuffer.cs index efb90df1974..79c74d09296 100755 --- a/src/Tizen.NUI/src/public/Images/PixelBuffer.cs +++ b/src/Tizen.NUI/src/public/Images/PixelBuffer.cs @@ -56,7 +56,12 @@ internal PixelBuffer(PixelBuffer handle) : this(Interop.PixelBuffer.NewPixelBuff if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } - internal PixelBuffer(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn) + internal PixelBuffer(global::System.IntPtr cPtr, bool cMemoryOwn) : this(cPtr, cMemoryOwn, false) + { + // Note : PixelBuffer don't need to be register in Registry default. So we can create this class from worker thread. + } + + internal PixelBuffer(global::System.IntPtr cPtr, bool cMemoryOwn, bool cRegister) : base(cPtr, cMemoryOwn, cRegister) { } diff --git a/src/Tizen.NUI/src/public/Images/PixelData.cs b/src/Tizen.NUI/src/public/Images/PixelData.cs index b488f5ea7ab..9f915ad4b2a 100755 --- a/src/Tizen.NUI/src/public/Images/PixelData.cs +++ b/src/Tizen.NUI/src/public/Images/PixelData.cs @@ -72,7 +72,12 @@ public PixelData(byte[] buffer, uint bufferSize, uint width, uint height, PixelF } - internal PixelData(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn) + internal PixelData(global::System.IntPtr cPtr, bool cMemoryOwn) : this(cPtr, cMemoryOwn, false) + { + // Note : PixelData don't need to be register in Registry default. So we can create this class from worker thread. + } + + internal PixelData(global::System.IntPtr cPtr, bool cMemoryOwn, bool cRegister) : base(cPtr, cMemoryOwn, cRegister) { } diff --git a/src/Tizen.NUI/src/public/Input/Key.cs b/src/Tizen.NUI/src/public/Input/Key.cs index c17c2995056..ab703231200 100755 --- a/src/Tizen.NUI/src/public/Input/Key.cs +++ b/src/Tizen.NUI/src/public/Input/Key.cs @@ -30,7 +30,7 @@ public class Key : BaseHandle /// The default constructor. /// /// 3 - public Key() : this(Interop.Key.New("", "", 0, 0, 0u, 0), true) + public Key() : this(Interop.Key.New("","",0,0,0u,0), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } @@ -49,7 +49,11 @@ internal Key(string keyName, string keyString, int keyCode, int keyModifier, uin if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } - internal Key(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn) + internal Key(global::System.IntPtr cPtr, bool cMemoryOwn) : this(cPtr, cMemoryOwn, cMemoryOwn) + { + } + + internal Key(global::System.IntPtr cPtr, bool cMemoryOwn, bool cRegister) : base(cPtr, cMemoryOwn, cRegister) { } diff --git a/src/Tizen.NUI/src/public/ParticleSystem/Particle.cs b/src/Tizen.NUI/src/public/ParticleSystem/Particle.cs new file mode 100644 index 00000000000..667c4383f58 --- /dev/null +++ b/src/Tizen.NUI/src/public/ParticleSystem/Particle.cs @@ -0,0 +1,496 @@ +/* + * Copyright(c) 2023 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +using System; +using System.IO; +using System.Runtime.InteropServices; +using System.ComponentModel; +using System.Reflection; + +namespace Tizen.NUI.ParticleSystem +{ + using Tizen.NUI.BaseComponents; + + /// + /// Declares types of default streams + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public enum ParticleStream + { + Position = 1 << 0, // Vector3, Position of particle + Rotation = 1 << 1, // Vector4, Rotation of particle (quaternion) + Scale = 1 << 2, // Vector3, Scale of particle + Size = 1 << 3, // Vector3, size of particle + Color = 1 << 4, // Vector4/Color - Color of particle, (RGBA) + Opacity = 1 << 5, // float, opacity (0.0-1.0) + Velocity = 1 << 6, // Vector3, vector of velocity + Lifetime = 1 << 7, // float, remaining lifetime + Lifetime_Base = 1 << 8, // float, initial lifetime + } + + /// + /// Particle class provides interface to particle data streams + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class Particle + { + /// + /// StreamView provides functionality allowing particle + /// data manipulation (read/write). + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class StreamView + { + internal StreamView(HandleRef list, uint particleIndex, uint streamIndex) + { + mParticleIndex = particleIndex; + mStreamIndex = (int)streamIndex; + mEmitterRef = list; + } + + internal StreamView(HandleRef list, uint particleIndex, ParticleStream builtInStream) + { + mEmitterRef = list; + mParticleIndex = particleIndex; + mStreamIndex = Interop.ParticleEmitter.GetDefaultStreamIndex(mEmitterRef, (uint)(builtInStream)); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + private struct Value + { + internal float valueFloat; + internal Vector2 valueVector2; + internal Vector3 valueVector3; + internal Vector4 valueVector4; + } + + internal StreamView(float f) + { + value.valueFloat = f; + type = typeof(float); + } + + internal StreamView(Vector2 f) + { + value.valueVector2 = f; + type = typeof(Vector2); + } + + internal StreamView(Vector3 f) + { + value.valueVector3 = f; + type = typeof(Vector3); + } + + internal StreamView(Vector4 f) + { + value.valueVector4 = f; + type = typeof(Vector4); + } + + /// + /// Conversion operator to float value + /// + /// StreamView object + /// Converted value + [EditorBrowsable(EditorBrowsableState.Never)] + public static implicit operator float(StreamView sv) + { + var ret = sv.mStreamIndex >= 0 ? Interop.Particle.ReadFloat(sv.mEmitterRef, (uint)sv.mStreamIndex, sv.mParticleIndex) : 0.0f; + if (NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + /// + /// Conversion operator to Vector2 value + /// + /// StreamView object + /// Converted value + [EditorBrowsable(EditorBrowsableState.Never)] + public static implicit operator Vector2(StreamView sv) { + var ret = sv.mStreamIndex >= 0 ? new Vector2(Interop.Particle.ReadVector2(sv.mEmitterRef, (uint)sv.mStreamIndex, sv.mParticleIndex), true) : Vector2.Zero; + if (NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + /// + /// Conversion operator to Vector3 value + /// + /// StreamView object + /// Converted value + [EditorBrowsable(EditorBrowsableState.Never)] + public static implicit operator Vector3(StreamView sv) { + var ret = sv.mStreamIndex >= 0 ? new Vector3(Interop.Particle.ReadVector3(sv.mEmitterRef, (uint)sv.mStreamIndex, sv.mParticleIndex), true) : Vector3.Zero; + if (NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + /// + /// Conversion operator to Vecto4 value + /// + /// StreamView object + /// Converted value + [EditorBrowsable(EditorBrowsableState.Never)] + public static implicit operator Vector4(StreamView sv) { + + var ret = sv.mStreamIndex >= 0 ? new Vector4(Interop.Particle.ReadVector4(sv.mEmitterRef, (uint)sv.mStreamIndex, sv.mParticleIndex), true) : Vector4.Zero; + if (NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + private int mStreamIndex; + private uint mParticleIndex; + private HandleRef mEmitterRef; + private Value value; + private System.Type type; + } + + /// + /// Create an initialized Particle. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + internal Particle(HandleRef emitter, uint index) + { + mIndex = index; + mEmitterRef = emitter; + } + + /// + /// Returns value from specified data stream (default/custom) + /// + /// Index of stream to get value from + /// StreamView object + [EditorBrowsable(EditorBrowsableState.Never)] + public StreamView GetStreamValue(uint streamIndex) + { + return new StreamView(mEmitterRef, mIndex, streamIndex); + } + + /// + /// Returns value from specified default streamIndex + /// + /// Index of stream to get value from + /// StreamView object + [EditorBrowsable(EditorBrowsableState.Never)] + public StreamView GetStreamValue(ParticleStream streamIndex) + { + return new StreamView(mEmitterRef, mIndex, streamIndex); + } + + /// + /// Sets value on the specified data stream + /// + /// Value to set + /// Index of stream to get value from + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetStreamValue(float value, uint streamIndex) + { + Interop.Particle.WriteFloat(mEmitterRef, streamIndex, mIndex, value); + if (NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Sets value on the specified data stream + /// + /// Value to set + /// Index of stream to get value from + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetStreamValue(Vector2 value, uint streamIndex) + { + Interop.Particle.WriteVector2(mEmitterRef, streamIndex, mIndex, value.SwigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Sets value on the specified data stream + /// + /// Value to set + /// Index of stream to get value from + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetStreamValue(Vector3 value, uint streamIndex) + { + Interop.Particle.WriteVector3(mEmitterRef, streamIndex, mIndex, value.SwigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Sets value on the specified data stream + /// + /// Value to set + /// Index of stream to get value from + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetStreamValue(Vector4 value, uint streamIndex) + { + Interop.Particle.WriteVector4(mEmitterRef, streamIndex, mIndex, value.SwigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Sets value on the specified data stream + /// + /// Value to set + /// Stream to get value from + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetStreamValue(float value, ParticleStream particleStream) + { + uint streamIndex = (uint)(Interop.ParticleEmitter.GetDefaultStreamIndex(mEmitterRef, (uint)(particleStream))); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + + Interop.Particle.WriteFloat(mEmitterRef, streamIndex, mIndex, value); + if (NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Sets value on the specified data stream + /// + /// Value to set + /// Stream to get value from + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetStreamValue(Vector2 value, ParticleStream particleStream) + { + uint streamIndex = (uint)(Interop.ParticleEmitter.GetDefaultStreamIndex(mEmitterRef, (uint)(particleStream))); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + + Interop.Particle.WriteVector2(mEmitterRef, streamIndex, mIndex, value.SwigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Sets value on the specified data stream + /// + /// Value to set + /// Stream to get value from + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetStreamValue(Vector3 value, ParticleStream particleStream) + { + uint streamIndex = (uint)(Interop.ParticleEmitter.GetDefaultStreamIndex(mEmitterRef, (uint)(particleStream))); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + + Interop.Particle.WriteVector3(mEmitterRef, streamIndex, mIndex, value.SwigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Sets value on the specified data stream + /// + /// Value to set + /// Stream to get value from + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetStreamValue(Vector4 value, ParticleStream particleStream) + { + uint streamIndex = (uint)(Interop.ParticleEmitter.GetDefaultStreamIndex(mEmitterRef, (uint)(particleStream))); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + + Interop.Particle.WriteVector4(mEmitterRef, streamIndex, mIndex, value.SwigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + + /// + /// Returns index of one of default streams. + /// + /// Stream to get index + /// Index of stream within emitter + [EditorBrowsable(EditorBrowsableState.Never)] + private uint GetStreamIndex(ParticleStream streamBit) + { + uint streamIndex = (uint)(Interop.ParticleEmitter.GetDefaultStreamIndex(mEmitterRef, (uint)(streamBit))); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return streamIndex; + } + + /// + /// Position of the Particle. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vector3 Position + { + get + { + var streamIndex = GetStreamIndex(ParticleStream.Position); + var ret = new Vector3(Interop.Particle.ReadVector3(mEmitterRef, (uint)streamIndex, mIndex), true); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + set + { + SetStreamValue( value, ParticleStream.Position); + } + } + + /// + /// Color of the Particle. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vector4 Color + { + get + { + var streamIndex = GetStreamIndex(ParticleStream.Color); + var ret = new Vector4(Interop.Particle.ReadVector4(mEmitterRef, (uint)streamIndex, mIndex), true); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + set + { + SetStreamValue( value, ParticleStream.Color); + } + } + + /// + /// Velocity of the Particle. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vector3 Velocity + { + get + { + var streamIndex = GetStreamIndex(ParticleStream.Velocity); + var ret = new Vector3(Interop.Particle.ReadVector3(mEmitterRef, (uint)streamIndex, mIndex), true); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + set + { + SetStreamValue( value, ParticleStream.Velocity); + } + } + + /// + /// Scale of the Particle. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vector3 Scale + { + get + { + var streamIndex = GetStreamIndex(ParticleStream.Scale); + var ret = new Vector3(Interop.Particle.ReadVector3(mEmitterRef, (uint)streamIndex, mIndex), true); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + set + { + SetStreamValue( value, ParticleStream.Scale); + } + } + + /// + /// Rotation of the Particle. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vector4 Rotation + { + get + { + var streamIndex = GetStreamIndex(ParticleStream.Rotation); + var ret = new Vector4(Interop.Particle.ReadVector4(mEmitterRef, (uint)streamIndex, mIndex), true); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + set + { + SetStreamValue( value, ParticleStream.Rotation); + } + } + + /// + /// Opacity of the Particle. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public float Opacity + { + get + { + var streamIndex = GetStreamIndex(ParticleStream.Opacity); + var ret = Interop.Particle.ReadFloat(mEmitterRef, (uint)streamIndex, mIndex); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + set + { + SetStreamValue( value, ParticleStream.Opacity); + } + } + + /// + /// Lifetime of the Particle. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public float Lifetime + { + get + { + var streamIndex = GetStreamIndex(ParticleStream.Lifetime); + var ret = Interop.Particle.ReadFloat(mEmitterRef, (uint)streamIndex, mIndex); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + set + { + SetStreamValue( value, ParticleStream.Lifetime); + } + } + + /// + /// Initial lifetime of the Particle. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public float LifetimeBase + { + get + { + var streamIndex = GetStreamIndex(ParticleStream.Lifetime_Base); + var ret = Interop.Particle.ReadFloat(mEmitterRef, (uint)streamIndex, mIndex); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + set + { + SetStreamValue( value, ParticleStream.Lifetime_Base); + } + } + + /// + /// Index of the Particle. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + internal uint Index + { + get => mIndex; + set + { + mIndex = value; + } + } + + private uint mIndex; + private readonly HandleRef mEmitterRef; + } +} diff --git a/src/Tizen.NUI/src/public/ParticleSystem/ParticleEmitter.cs b/src/Tizen.NUI/src/public/ParticleSystem/ParticleEmitter.cs new file mode 100644 index 00000000000..761c49181de --- /dev/null +++ b/src/Tizen.NUI/src/public/ParticleSystem/ParticleEmitter.cs @@ -0,0 +1,586 @@ +/* + * Copyright(c) 2023 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.ComponentModel; + +namespace Tizen.NUI.ParticleSystem +{ + using Tizen.NUI.BaseComponents; + + /// + /// Enum defining blending options when rendering the particles. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public enum ParticleBlendingMode + { + Additive = 0, + Screen = 1, + Default = Additive + } + + /// + /// Class ParticleEmitter creates a single emitter attached to a specified + /// View. ParticleEmitter is responsible for spawning and updating particles. + /// + /// Emitter must contain: + /// ParticleSource - responsible for spawning new particles + /// ParticleModifier(s) - responsible for updating particles in the system + /// + /// ParticleSource and ParticleModifier callback interfaces should not be accessing + /// Event side (NUI) objects. Both callbacks are executed on Update thread. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class ParticleEmitter : BaseHandle + { + internal ParticleEmitter(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn) + { + } + + /// + /// Create an initialized ParticleEmitter. + /// + /// View to attach the particle emitter. + [EditorBrowsable(EditorBrowsableState.Never)] + public ParticleEmitter(View view) : this(Interop.ParticleEmitter.New(view.SwigCPtr), true) + { + mProxy = new ParticleEmitterProxy(this); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Copy constructor. + /// + /// Source object to copy. + [EditorBrowsable(EditorBrowsableState.Never)] + public ParticleEmitter( ParticleEmitter particleEmitter) : this(Interop. ParticleEmitter.New( ParticleEmitter.getCPtr(particleEmitter)), true) + { + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Dispose. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + protected override void Dispose(DisposeTypes type) + { + if (Disposed) + { + return; + } + + base.Dispose(type); + } + + /// + /// Assignment operator. + /// + /// Source object to be assigned. + /// Reference to this. + internal ParticleEmitter Assign( ParticleEmitter particleEmitter) + { + ParticleEmitter ret = new ParticleEmitter(Interop.ParticleEmitter.Assign(SwigCPtr, ParticleEmitter.getCPtr(particleEmitter)), false); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + /// + /// Raises the window to the top of the window stack. + /// + /// Source object to copy. + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetSource(ParticleSource source) where T : ParticleSourceInterface, new() + { + // update interface + source.SetEmitter(this); + + // Set native source + Interop.ParticleEmitter.SetSource(SwigCPtr, source.SwigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Maximum particle count + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public uint ParticleCount + { + get + { + var value = Interop.ParticleEmitter.GetParticleCount(SwigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + + return value; + } + set + { + Interop.ParticleEmitter.SetParticleCount(SwigCPtr, value); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + } + + /// + /// Rate of emission per second + /// + /// + /// EmissionRate defines number of particles emitted per second. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public uint EmissionRate + { + get + { + var value = Interop.ParticleEmitter.GetEmissionRate(SwigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return value; + } + set + { + Interop.ParticleEmitter.SetEmissionRate(SwigCPtr, value); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + } + + /// + /// Initial particle count + /// + /// + /// Initial number of particles to be emitted immediately after emitter starts. It allows + /// initial burst emission. By default it's set to 0. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public uint InitialParticleCount + { + get + { + var value = Interop.ParticleEmitter.GetInitialParticleCount(SwigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return value; + } + set + { + Interop.ParticleEmitter.SetInitialParticleCount(SwigCPtr, value); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + } + + /// + /// Limit of active particles in the system + /// + /// + /// Active particles in the system can be limited without changing . + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public uint ActiveParticleLimit + { + get{ + var value = Interop.ParticleEmitter.GetActiveParticlesLimit(SwigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return value; + } + set + { + Interop.ParticleEmitter.SetActiveParticlesLimit(SwigCPtr, value); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + } + + /// + /// Gets/sets blending mode for particle renderer + /// + /// + /// Currently two blending modes are supported: Additive and Screen (advanced blending mode). + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public ParticleBlendingMode RendererBlendingMode + { + get + { + var value = Interop.ParticleEmitter.GetBlendingMode(SwigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return (ParticleBlendingMode)value; + } + set + { + Interop.ParticleEmitter.SetBlendingMode(SwigCPtr, value); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + } + + /// + /// Sets texture to be used by the renderer + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public string TextureResourceUrl + { + set + { + var pixelBuffer = ImageLoader.LoadImageFromFile(value); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + + Texture tex = new Texture(TextureType.TEXTURE_2D, PixelFormat.RGBA8888, pixelBuffer.GetWidth(), + pixelBuffer.GetHeight()); + tex.Upload(pixelBuffer.CreatePixelData()); + + Interop.ParticleEmitter.SetTexture(SwigCPtr, tex.SwigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + } + + /// + /// Adds ParticleModifier to the stack + /// + /// + /// ParticleEmitter implements a stack of modifiers which are responsible for + /// updating particles in the system. The stack is processed such as result of + /// previous modifier is an input for next modifier. + /// + /// Valid modifier object + [EditorBrowsable(EditorBrowsableState.Never)] + public void AddModifier(ParticleModifier modifier) where T : ParticleModifierInterface, new() + { + // update interface + modifier.SetEmitter(this); + + Interop.ParticleEmitter.AddModifier(SwigCPtr, modifier.SwigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Returns associated ParticleSource object + /// + /// Valid ParticleSource object or null + [EditorBrowsable(EditorBrowsableState.Never)] + public ParticleSource GetSource() where T : ParticleSourceInterface, new() + { + IntPtr cPtr = Interop.ParticleEmitter.GetSource(SwigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + ParticleSource ret = (cPtr == IntPtr.Zero) ? null : Registry.GetManagedBaseHandleFromNativePtr(cPtr) as ParticleSource; + return ret; + } + + /// + /// Returns modifier at specified index + /// + /// Index within modifier stack + /// Valid ParticleModifier object or null + [EditorBrowsable(EditorBrowsableState.Never)] + public ParticleModifier GetModifierAt(uint index) + { + IntPtr cPtr = Interop.ParticleEmitter.GetModifierAt(SwigCPtr, index); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + ParticleModifier ret = (cPtr == IntPtr.Zero) ? null : Registry.GetManagedBaseHandleFromNativePtr(cPtr) as ParticleModifier; + return ret; + } + + /// + /// Starts emission of particles. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void Start() + { + Interop.ParticleEmitter.Start(SwigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Stops emission of particles. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void Stop() + { + Interop.ParticleEmitter.Stop(SwigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Adds local (not used by shader) data stream to the particle emitter + /// + /// + /// Adds new stream of float type. + /// + /// Default value to fill the stream with + /// Index of newly created data stream + [EditorBrowsable(EditorBrowsableState.Never)] + public uint AddLocalStreamFloat(float defaultValue) + { + var result = Interop.ParticleEmitter.AddLocalStreamFloat(SwigCPtr, defaultValue); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return result; + } + + /// + /// Adds local (not used by shader) data stream to the particle emitter + /// + /// + /// Adds new stream of Vector2 type. + /// + /// Default value to fill the stream with + /// Index of newly created data stream + [EditorBrowsable(EditorBrowsableState.Never)] + public uint AddLocalStreamVector2(Vector2 defaultValue) + { + var result = Interop.ParticleEmitter.AddLocalStreamVector2(SwigCPtr, defaultValue.SwigCPtr.Handle); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return result; + } + + /// + /// Adds local (not used by shader) data stream to the particle emitter + /// + /// + /// Adds new stream of Vector3 type. + /// + /// Default value to fill the stream with + /// Index of newly created data stream + [EditorBrowsable(EditorBrowsableState.Never)] + public uint AddLocalStreamVector3(Vector3 defaultValue) + { + var result = Interop.ParticleEmitter.AddLocalStreamVector3(SwigCPtr, defaultValue.SwigCPtr.Handle); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return result; + } + + /// + /// Adds local (not used by shader) data stream to the particle emitter + /// + /// + /// Adds new stream of Vector4 type. + /// + /// Default value to fill the stream with + /// Index of newly created data stream + [EditorBrowsable(EditorBrowsableState.Never)] + public uint AddLocalStreamVector4(Vector4 defaultValue) + { + var result = Interop.ParticleEmitter.AddLocalStreamVector4(SwigCPtr, defaultValue.SwigCPtr.Handle); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return result; + } + + // Internal proxy object to be used on the update thread + internal ParticleEmitterProxy EmitterProxy => mProxy; + private ParticleEmitterProxy mProxy = null; + } + + /// + /// This class provides functionality that can be used inside the Source/Modifier callbacks. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class ParticleEmitterProxy + { + internal ParticleEmitterProxy(ParticleEmitter emitter) + { + mEmitterBasePtr = emitter.SwigCPtr.Handle; + mEmitter = emitter; + } + + /// + /// Creates new particle + /// + /// + /// Function may fail and return null if current number of particles exceeds limits of emitter. + /// Particle is valid only inside the callback and must not be stored and used anywhere else. Otherwise + /// the behaviour is undefined. + /// + /// Lifetime of the particle in seconds + /// New Particle object or null + [EditorBrowsable(EditorBrowsableState.Never)] + public Particle NewParticle( float lifetime ) + { + var result = Interop.ParticleEmitter.NewParticle(mEmitterBasePtr, lifetime); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + if (result >= 0) + { + // TODO: new particles should be coming form cached queue + return new Particle(mEmitter.SwigCPtr, (uint)result); + } + return null; + } + + /// + /// Acquires list of Particles of specified length + /// + /// + /// The function should be use internally only. Native side passes list of indices of particles (int[]). + /// Before calling the callback the indices must be marshalled and converted into the Particle objects. + /// + /// Internal Particle cache is used to speed up acquiring new Particle. + /// + /// Native pointer to the list of indices (int32) + /// Number of elements + /// List of Particle objects + [EditorBrowsable(EditorBrowsableState.Never)] + internal List AcquireParticleList(IntPtr nativePtr, uint count) + { + // Populate enough particles into cache + while(mParticleCache.Count < count) + { + mParticleCache.Push(new Particle(mEmitter.SwigCPtr, 0)); + } + + List retval = new List(); + for (var i = 0; i < count; ++i) + { + var particleIndex = Marshal.ReadInt32(nativePtr, i * 4); + Particle p = mParticleCache.Pop(); + p.Index = (uint)particleIndex; + retval.Add(p); + } + + return retval; + } + + /// + /// Releases list of Particles back into the pool + /// + /// + /// Acquired particles come from internal pool and must be returned so then they can + /// be recycled. + /// + /// List of particles to be returned + [EditorBrowsable(EditorBrowsableState.Never)] + internal void ReleaseParticleList(List particles) + { + // return particles back into the pull + for(var i = 0; i < particles.Count; ++i) + { + mParticleCache.Push(particles[i]); + } + + // clear the list (probably not needed?) + particles.Clear(); + } + + /// + /// Adds local particle data stream of float values + /// + /// Default value + /// Index of new stream + [EditorBrowsable(EditorBrowsableState.Never)] + public uint AddLocalStreamFloat(float defaultValue) + { + return mEmitter.AddLocalStreamFloat(defaultValue); + } + + /// + /// Adds local particle data stream of Vector2 values + /// + /// Default value + /// Index of new stream + [EditorBrowsable(EditorBrowsableState.Never)] + public uint AddLocalStreamVector2(Vector2 defaultValue) + { + return mEmitter.AddLocalStreamVector2(defaultValue); + } + + /// + /// Adds local particle data stream of Vector3 values + /// + /// Default value + /// Index of new stream + [EditorBrowsable(EditorBrowsableState.Never)] + public uint AddLocalStreamVector3(Vector3 defaultValue) + { + return mEmitter.AddLocalStreamVector3(defaultValue); + } + + /// + /// Adds local particle data stream of Vector4 values + /// + /// Default value + /// Index of new stream + [EditorBrowsable(EditorBrowsableState.Never)] + public uint AddLocalStreamVector4(Vector4 defaultValue) + { + return mEmitter.AddLocalStreamVector4(defaultValue); + } + + // Stack of cached particles + private Stack mParticleCache = new Stack(); + + private IntPtr mEmitterBasePtr; + private ParticleEmitter mEmitter; + + } + + /// + /// Register binding Source/Modifier interface to the pointer of a native counterpart + /// + /// Class type of objects to be stored in the register + internal class ParticleInterfaceRegister where T : class + { + internal void Register(IntPtr cPtr, T iface) + { + lock (mBasePtr) + { + mBasePtr.Add(cPtr); + mInterfaces.Add(iface); + } + } + + internal bool Remove(IntPtr cPtr) + { + lock (mBasePtr) + { + var result = mBasePtr.FindIndex(0, x => x == cPtr); + if (result >= 0) + { + mBasePtr.RemoveAt(result); + mInterfaces.RemoveAt(result); + } + + return result >= 0; + } + } + + internal bool Remove(T iface) + { + lock (mBasePtr) + { + var result = mInterfaces.FindIndex(0, x => x.Equals(iface)); + if (result >= 0) + { + mBasePtr.RemoveAt(result); + mInterfaces.RemoveAt(result); + } + + return result >= 0; + } + } + + internal T Get(IntPtr cPtr) + { + lock (mBasePtr) + { + var result = mBasePtr.FindIndex(0, x => x == cPtr); + if (result >= 0) + { + return mInterfaces[result]; + } + + return null; + } + } + + private List mBasePtr = new List(); + private List mInterfaces = new List(); + } +} diff --git a/src/Tizen.NUI/src/public/ParticleSystem/ParticleModifier.cs b/src/Tizen.NUI/src/public/ParticleSystem/ParticleModifier.cs new file mode 100644 index 00000000000..d835c2dd870 --- /dev/null +++ b/src/Tizen.NUI/src/public/ParticleSystem/ParticleModifier.cs @@ -0,0 +1,175 @@ +/* + * Copyright(c) 2023 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +using System.Reflection; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace Tizen.NUI.ParticleSystem +{ + /// + /// ParticleModifierInterface provides callbacks in order to define + /// how particles in the system should be modified + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class ParticleModifierInterface + { + /// + /// Constructor + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public ParticleModifierInterface() + { + } + + /// + /// Second constructor + /// + /// + /// Second constructor should be overriden by the implementation. + /// It allows passing variable number of arguments for processing. + /// It is called immediately following the class constructor. + /// + /// List of arguments + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual void Construct(params object[] list) + { + } + + /// + /// Updates the ParticleModifier. + /// + /// + /// This callback is responsible for updating particles in the system. + /// + /// This callback runs on the Update thread! It should avoid using NUI objects. + /// + /// + /// Proxy to the ParticleEmitter object + /// List of particles to be updated by the modifier + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual void Update(ParticleEmitterProxy emitterProxy, List particleList) + { + } + + /// + /// ParticleEmitter proxy that can be accessed by the user implementation + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public ParticleEmitterProxy Emitter; + } + + + /// + /// Class represents particle modifier + /// + /// + /// ParticleModifier modifies existing particles in the system. + /// Modifiers can be stacked (more than one can be added to the ParticleEmitter). + /// Output of one modifier becomes input for next modifier. + /// + /// Modifier calls into the implementation of class. + /// + /// + /// Class of interface that derives from + [EditorBrowsable(EditorBrowsableState.Never)] + public partial class ParticleModifier : BaseHandle where T : ParticleModifierInterface, new() + { + // static cache for modifiers (binding between native side and interfaces) + static ParticleInterfaceRegister gModifierInterfaceRegister = new ParticleInterfaceRegister(); + + /// + /// Dispose. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + protected override void Dispose(DisposeTypes type) + { + if (Disposed) + { + return; + } + + if (HasBody()) + { + gModifierInterfaceRegister.Remove(mInterface); + } + base.Dispose(type); + } + + /// + /// Invoker for ParticleModifierInterface.Update() + /// + /// Native pointer of ParticleModifier base object + /// C-style array of integers + /// First particle to be modified (now always 0) + /// Number of particles to be modified + [EditorBrowsable(EditorBrowsableState.Never)] + static void OnUpdateInvoker(IntPtr cPtr, IntPtr listPtr, uint first, uint count) + { + if (count > 0) + { + T modifier = (cPtr == IntPtr.Zero) ? null : gModifierInterfaceRegister.Get(cPtr) as T; + var list = modifier?.Emitter.AcquireParticleList(listPtr, count); + modifier?.Update(modifier.Emitter, list); + modifier?.Emitter.ReleaseParticleList(list); + } + } + + + internal ParticleModifier(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn) + { + } + + + /// + /// Constructor of ParticleModifier + /// + /// + /// ParticleModifier is a generic type that will call back into the given ParticleModifierInterface + /// instance. + /// The instance of T (derived from ParticleModifierInterface) is created internally and own by the + /// ParticleModifier. + /// The constructor takes variable number of arguments which is processed when called ParticleModifierInterface.Construct() + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public ParticleModifier(params object[] list) : this(Interop.ParticleModifier.New(mOnUpdateInvoker, out gRefObjectPtr), true) + { + // Create interface on the C# side (no direct connection with C++) + mInterface = new T(); + mInterface.Construct(list); + + // Register interface using base ptr + gModifierInterfaceRegister.Register(gRefObjectPtr, mInterface); + + // Initialise native side for this interface + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + internal void SetEmitter(ParticleEmitter emitter) + { + mInterface.Emitter = new ParticleEmitterProxy(emitter); + } + + private static Interop.ParticleModifier.ParticleModifierUpdateInvokerType mOnUpdateInvoker = OnUpdateInvoker; + private ParticleModifierInterface mInterface = null; + private static IntPtr gRefObjectPtr; + } +} diff --git a/src/Tizen.NUI/src/public/ParticleSystem/ParticleSource.cs b/src/Tizen.NUI/src/public/ParticleSystem/ParticleSource.cs new file mode 100644 index 00000000000..2257ea0b2b6 --- /dev/null +++ b/src/Tizen.NUI/src/public/ParticleSystem/ParticleSource.cs @@ -0,0 +1,215 @@ +/* + * Copyright(c) 2023 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +using System; +using System.ComponentModel; + +namespace Tizen.NUI.ParticleSystem +{ + using Tizen.NUI.BaseComponents; + + /// + /// ParticleSourceInterface provides callbacks in order to define + /// how new particles are emitted. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class ParticleSourceInterface + { + /// + /// Constructor + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public ParticleSourceInterface() + { + } + + /// + /// Second constructor + /// + /// + /// Second constructor should be overriden by the implementation. + /// It allows passing variable number of arguments for processing. + /// It is called immediately following the class constructor. + /// + /// List of arguments + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual void Construct(params object[] list) + { + } + + /// + /// Updates the ParticleSource. + /// + /// + /// This callback is responsible for spawning new particles. To spawn new particle, + /// emitter.NewParticle() must be call. Number of particles to emit is given as 'count'. + /// + /// This callback runs on the Update thread! It should avoid using NUI objects. + /// + /// + /// Proxy to the ParticleEmitter object + /// Number of particles emitter expects to be spawned during call + /// Number of spawned particles + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual uint Update(ParticleEmitterProxy emitterProxy, uint count) + { + return 0; + } + + /// + /// Initializes ParticleSource + /// + /// + /// This callback should be overriden in order to initialise the ParticleSource. + /// It is called after ParticleEmitter.SetSource() and runs on the Event thread. + /// It is the only place where ParticleSource may use NUI objects. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual void Init() + { + + } + + /// + /// ParticleEmitter proxy that can be accessed by the user implementation + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public ParticleEmitterProxy Emitter; + } + + /// + /// Class represents the particle source + /// + /// + /// ParticleSource is responsible for emission of particles. + /// It calls the implementation of class. + /// The callback runs on update thread. + /// + /// Class of interface that derives from + [EditorBrowsable(EditorBrowsableState.Never)] + public partial class ParticleSource : BaseHandle where T : ParticleSourceInterface, new() + { + // static cache for sources (binding between native side and interfaces) + private static ParticleInterfaceRegister gSourceInterfaceRegister = new ParticleInterfaceRegister(); + + /// + /// Dispose. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + protected override void Dispose(DisposeTypes type) + { + if (Disposed) + { + return; + } + + if (HasBody()) + { + gSourceInterfaceRegister.Remove(mInterface); + } + base.Dispose(type); + } + + /// + /// Invoker for ParticleSourceInterface.Init() + /// + /// + /// Function is called from the native side + /// + /// Native pointer of ParticleSource base object + [EditorBrowsable(EditorBrowsableState.Never)] + static void OnInitInvoker(IntPtr cPtr) + { + // This function runs on Event thread + T source = gSourceInterfaceRegister.Get(cPtr) as T; + source?.Init(); + } + + /// + /// Invoker for ParticleSourceInterface.Update() + /// + /// + /// Function is called from the native side + /// + /// Native pointer of ParticleSource base object + /// Number of particles to emit + /// Number of emitted particles + [EditorBrowsable(EditorBrowsableState.Never)] + static uint OnUpdateInvoker(IntPtr cPtr, uint count) + { + T source = gSourceInterfaceRegister.Get(cPtr) as T; + var retval= source?.Update(source.Emitter, count); + return retval.HasValue ? retval.Value : 0; + } + + internal ParticleSource(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn) + { + } + + /// + /// Constructor of ParticleSource + /// + /// + /// ParticleSource is a generic type that will call back into the given ParticleSourceInterface + /// instance. + /// The instance of T (derived from ParticleSourceInterface) is created internally and own by the + /// ParticleSource. + /// The constructor takes variable number of arguments which is processed when called ParticleSourceInterface.Construct() + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public ParticleSource(params object[] list) : this(Interop.ParticleSource.New( mOnInitInvoker, mOnUpdateInvoker, out gRefObjectPtr ), true) + { + // Create interface on the C# side (no direct connection with C++) + mInterface = new T(); + mInterface.Construct(list); + + // Register interface using base ptr + gSourceInterfaceRegister.Register(gRefObjectPtr, mInterface); + + // Initialise native side for this interface + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Returns associated source callback interface + /// + /// Source callback interface + [EditorBrowsable(EditorBrowsableState.Never)] + private T GetCallbackInterface() + { + return mInterface as T; + } + + /// + /// Returns associated source callback interface + /// + /// Source callback interface + [EditorBrowsable(EditorBrowsableState.Never)] + public T Callback => GetCallbackInterface(); + + internal void SetEmitter(ParticleEmitter emitter) + { + mInterface.Emitter = new ParticleEmitterProxy(emitter); + } + + // private fields + private static Interop.ParticleSource.ParticleSourceInitInvokerType mOnInitInvoker = OnInitInvoker; + private static Interop.ParticleSource.ParticleSourceUpdateInvokerType mOnUpdateInvoker = OnUpdateInvoker; + private ParticleSourceInterface mInterface = null; + private static IntPtr gRefObjectPtr; + } +} diff --git a/src/Tizen.NUI/src/public/Utility/Timer.cs b/src/Tizen.NUI/src/public/Utility/Timer.cs index 0bb293dc0eb..b17c72c71c4 100755 --- a/src/Tizen.NUI/src/public/Utility/Timer.cs +++ b/src/Tizen.NUI/src/public/Utility/Timer.cs @@ -136,7 +136,7 @@ public void Start() for (int i = 0; i < st.FrameCount; i++) { StackFrame sf = st.GetFrame(i); - Tizen.Log.Error("NUI", " Method " + sf.GetMethod()); + Tizen.Log.Error("NUI", " Method " + sf.GetMethod() + ":" + sf.GetFileName() + ":" + sf.GetFileLineNumber()); } } @@ -166,7 +166,7 @@ public void Stop() for (int i = 0; i < st.FrameCount; i++) { StackFrame sf = st.GetFrame(i); - Tizen.Log.Error("NUI", " Method " + sf.GetMethod()); + Tizen.Log.Error("NUI", " Method " + sf.GetMethod() + ":" + sf.GetFileName() + ":" + sf.GetFileLineNumber()); } } @@ -197,7 +197,7 @@ public bool IsRunning() for (int i = 0; i < st.FrameCount; i++) { StackFrame sf = st.GetFrame(i); - Tizen.Log.Error("NUI", " Method " + sf.GetMethod()); + Tizen.Log.Error("NUI", " Method " + sf.GetMethod() + ":" + sf.GetFileName() + ":" + sf.GetFileLineNumber()); } } diff --git a/src/Tizen.NUI/src/public/Visuals/VisualFactory.cs b/src/Tizen.NUI/src/public/Visuals/VisualFactory.cs index 73bbfcece04..ab2a33a102e 100755 --- a/src/Tizen.NUI/src/public/Visuals/VisualFactory.cs +++ b/src/Tizen.NUI/src/public/Visuals/VisualFactory.cs @@ -84,5 +84,22 @@ public VisualBase CreateVisual(PropertyMap propertyMap) if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } + + /// + /// Compile the visual shader in advance. Afterwards, + /// when a visual using a new shader is requested, the pre-compiled shader is used. + /// + /// It is recommended that this method be called at the top of the application code. + /// + /// Using precompiled shaders is helpful when the application is complex and uses + /// many different styles of visual options. On the other hand,if most visuals are the same + /// and the application is simple, it may use memory unnecessarily or slow down the application launching speed. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void UsePreCompiledShader() + { + Interop.VisualFactory.UsePreCompiledShader(SwigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } } } diff --git a/src/Tizen.NUI/src/public/Widget/Widget.cs b/src/Tizen.NUI/src/public/Widget/Widget.cs index a10d2387d34..ce65cb5cf79 100755 --- a/src/Tizen.NUI/src/public/Widget/Widget.cs +++ b/src/Tizen.NUI/src/public/Widget/Widget.cs @@ -46,6 +46,8 @@ internal Widget(WidgetImpl widgetImpl, bool swigCMemOwn) : this(Interop.Widget.N widgetImpl.WidgetInstanceResumed += OnWidgetInstanceResumed; widgetImpl.WidgetInstanceResized += OnWidgetInstanceResized; widgetImpl.WidgetInstanceUpdated += OnWidgetInstanceUpdated; + + (WidgetApplication.Instance as WidgetApplication)?.AddWidgetInstance(this); } internal Widget(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn) diff --git a/src/Tizen.NUI/src/public/Window/Window.cs b/src/Tizen.NUI/src/public/Window/Window.cs index 3956b86f823..6df4dd112cf 100755 --- a/src/Tizen.NUI/src/public/Window/Window.cs +++ b/src/Tizen.NUI/src/public/Window/Window.cs @@ -43,6 +43,7 @@ public partial class Window : BaseHandle private LayoutController localController; private Key internalLastKeyEvent; private Touch internalLastTouchEvent; + private Hover internalLastHoverEvent; private Timer internalHoverTimer; static internal bool IsSupportedMultiWindow() @@ -1268,13 +1269,13 @@ internal void FeedHover(TouchPoint touchPoint = null) { if (touchPoint == null) { - using Touch touch = GetLastTouchEvent(); - if (touch == null || touch.GetPointCount() < 1) + Hover hover = GetLastHoverEvent(); + if (hover == null || hover.GetPointCount() < 1) { return; } - using Vector2 screenPosition = touch.GetScreenPosition(0); - touchPoint = new TouchPoint(touch.GetDeviceId(0), TouchPoint.StateType.Motion, screenPosition.X, screenPosition.Y); + using Vector2 screenPosition = hover.GetScreenPosition(0); + touchPoint = new TouchPoint(hover.GetDeviceId(0), TouchPoint.StateType.Motion, screenPosition.X, screenPosition.Y); } Interop.Window.FeedHoverEvent(SwigCPtr, TouchPoint.getCPtr(touchPoint)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); @@ -1553,7 +1554,20 @@ internal Vector2 GetSize() [EditorBrowsable(EditorBrowsableState.Never)] public RenderTaskList GetRenderTaskList() { - RenderTaskList ret = new RenderTaskList(Interop.Stage.GetRenderTaskList(stageCPtr), true); + global::System.IntPtr cPtr = Interop.Stage.GetRenderTaskList(stageCPtr); + + RenderTaskList ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as RenderTaskList; + if (ret != null) + { + HandleRef CPtr = new HandleRef(this, cPtr); + Interop.BaseHandle.DeleteBaseHandle(CPtr); + CPtr = new HandleRef(null, global::System.IntPtr.Zero); + } + else + { + ret = new RenderTaskList(cPtr, true); + } + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } @@ -2107,13 +2121,18 @@ public bool IsWindowRotating() /// /// Gets the last key event the window gets. /// + /// + /// We will use weak reference of last key events. + /// Return value will be invalidated if last key event changed internally. + /// /// The last key event the window gets. [EditorBrowsable(EditorBrowsableState.Never)] public Key GetLastKeyEvent() { - if(internalLastKeyEvent == null) + if (internalLastKeyEvent == null) { - internalLastKeyEvent = new Key(); + // Create empty event handle without register. + internalLastKeyEvent = new Key(Interop.Key.New(), true, false); } Interop.Window.InternalRetrievingLastKeyEvent(SwigCPtr, internalLastKeyEvent.SwigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); @@ -2123,19 +2142,45 @@ public Key GetLastKeyEvent() /// /// Gets the last touch event the window gets. /// + /// + /// We will use weak reference of last touch events. + /// Return value will be invalidated if last touch event changed internally. + /// /// The last touch event the window gets. [EditorBrowsable(EditorBrowsableState.Never)] public Touch GetLastTouchEvent() { - if(internalLastTouchEvent == null) + if (internalLastTouchEvent == null) { - internalLastTouchEvent = new Touch(); + // Create empty event handle without register. + internalLastTouchEvent = new Touch(Interop.Touch.NewTouch(), true, false); } Interop.Window.InternalRetrievingLastTouchEvent(SwigCPtr, internalLastTouchEvent.SwigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return internalLastTouchEvent; } + /// + /// Gets the last hover event the window gets. + /// + /// + /// We will use weak reference of last hover events. + /// Return value will be invalidated if last hover event changed internally. + /// + /// The last hover event the window gets. + [EditorBrowsable(EditorBrowsableState.Never)] + public Hover GetLastHoverEvent() + { + if (internalLastHoverEvent == null) + { + // Create empty event handle without register. + internalLastHoverEvent = new Hover(Interop.Hover.New(0u), true, false); + } + Interop.Window.InternalRetrievingLastHoverEvent(SwigCPtr, internalLastHoverEvent.SwigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return internalLastHoverEvent; + } + /// /// Sets the necessary for window rotation Acknowledgement. /// After this function called, SendRotationCompletedAcknowledgement() should be called to complete window rotation. @@ -2173,6 +2218,19 @@ public void AddFrameUpdateCallback(FrameUpdateCallbackInterface frameUpdateCallb frameUpdateCallback?.AddFrameUpdateCallback(stageCPtr, Layer.getCPtr(GetRootLayer())); } + /// + /// Add FrameUpdateCallback with root view. + /// FrameUpdateCallbackInterface can only detach Views under given view. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void AddFrameUpdateCallback(FrameUpdateCallbackInterface frameUpdateCallback, View rootView) + { + if(rootView != null) + { + frameUpdateCallback?.AddFrameUpdateCallback(stageCPtr, View.getCPtr(rootView)); + } + } + /// /// Remove FrameUpdateCallback /// @@ -2222,6 +2280,8 @@ protected override void Dispose(DisposeTypes type) internalLastKeyEvent = null; internalLastTouchEvent?.Dispose(); internalLastTouchEvent = null; + internalLastHoverEvent?.Dispose(); + internalLastHoverEvent = null; internalHoverTimer?.Stop(); internalHoverTimer?.Dispose(); @@ -2363,6 +2423,32 @@ public Layer FindLayerByID(uint id) return ret; } + /// + /// Sets to resize window with full screen. + /// If full screen size is set for the window, + /// window will be resized with full screen. + /// In addition, the full screen sized window's z-order is the highest. + /// + /// If fullscreen is true, set fullscreen or unset. + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetFullScreen(bool fullscreen) + { + Interop.Window.SetFullScreen(SwigCPtr, fullscreen); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Gets whether the full screen sized window or not. + /// + /// Returns true if the full screen sized window is. + [EditorBrowsable(EditorBrowsableState.Never)] + public bool GetFullScreen() + { + bool ret = Interop.Window.GetFullScreen(SwigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + /// /// Get Native Window handle. /// diff --git a/src/Tizen.NUI/src/public/Window/WindowEvent.cs b/src/Tizen.NUI/src/public/Window/WindowEvent.cs index b278409e347..36e7b8427f0 100755 --- a/src/Tizen.NUI/src/public/Window/WindowEvent.cs +++ b/src/Tizen.NUI/src/public/Window/WindowEvent.cs @@ -57,6 +57,7 @@ public partial class Window private ResizeCompletedEventCallbackType resizeCompletedEventCallback; private InsetsChangedEventCallbackType insetsChangedEventCallback; private WindowPointerConstraintsEventCallback windowPointerConstraintsEventCallback; + private RootLayerHoverDataCallbackType rootLayerHoverDataCallback; [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void WindowFocusChangedEventCallbackType(IntPtr window, bool focusGained); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] @@ -91,6 +92,8 @@ public partial class Window private delegate void InsetsChangedEventCallbackType(int partType, int partState, IntPtr extents); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void WindowPointerConstraintsEventCallback(IntPtr window, IntPtr constraintsEvent); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate bool RootLayerHoverDataCallbackType(IntPtr view, IntPtr hoverData); /// @@ -152,6 +155,7 @@ public event EventHandler TouchEvent } } + /// /// An event for the touched signal which can be used to subscribe or unsubscribe the event handler provided by the user.
/// The touched signal is emitted when the touch input is received.
@@ -344,6 +348,35 @@ public event EventHandler Resized } } + /// + /// An event for the hovered signal which can be used to subscribe or unsubscribe the event handler provided by the user.
+ /// The hovered signal is emitted when the hover input is received.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)] + public event EventHandler HoverEvent + { + add + { + if (rootLayerHoverDataEventHandler == null) + { + rootLayerHoverDataCallback = OnWindowHover; + Interop.ActorSignal.HoveredConnect(Layer.getCPtr(GetRootLayer()), rootLayerHoverDataCallback.ToHandleRef(this)); + NDalicPINVOKE.ThrowExceptionIfExists(); + } + rootLayerHoverDataEventHandler += value; + } + remove + { + rootLayerHoverDataEventHandler -= value; + if (rootLayerHoverDataEventHandler == null && rootLayerHoverDataCallback != null) + { + Interop.ActorSignal.HoveredDisconnect(Layer.getCPtr(GetRootLayer()), rootLayerHoverDataCallback.ToHandleRef(this)); + NDalicPINVOKE.ThrowExceptionIfExists(); + rootLayerHoverDataCallback = null; + } + } + } + /// /// Do not use this, that will be deprecated. Use 'FocusChanged' event instead. /// @@ -630,12 +663,48 @@ public event EventHandler PointerConstraintsEvent if (windowPointerConstraintsEventHandler == null && windowPointerConstraintsEventCallback != null) { using WindowPointerConstraintsSignal signal = new WindowPointerConstraintsSignal(Interop.WindowPointerConstraintsSignal.GetSignal(SwigCPtr), false); - signal?.Disconnect(windowMouseRelativeEventCallback); + signal?.Disconnect(windowPointerConstraintsEventCallback); windowPointerConstraintsEventCallback = null; } } } + /// + /// Gets or sets the status of whether motion event of Touch can be dispatched. + /// If a Window's DispatchTouchMotion is set to false, then it's can not will receive motion event of TouchEvent. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool DispatchTouchMotion + { + get + { + return Object.InternalGetPropertyBool(Layer.getCPtr(GetRootLayer()), View.Property.DispatchTouchMotion); + } + set + { + Object.InternalSetPropertyBool(Layer.getCPtr(GetRootLayer()), View.Property.DispatchTouchMotion, value); + NotifyPropertyChanged(); + } + } + + /// + /// Gets or sets the status of whether motion event of Hover can be dispatched. + /// If a Window's DispatchHoverMotion is set to false, then it's can not will receive motion event of HoverEvent. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool DispatchHoverMotion + { + get + { + return Object.InternalGetPropertyBool(Layer.getCPtr(GetRootLayer()), View.Property.DispatchHoverMotion); + } + set + { + Object.InternalSetPropertyBool(Layer.getCPtr(GetRootLayer()), View.Property.DispatchHoverMotion, value); + NotifyPropertyChanged(); + } + } + private event EventHandler windowFocusChangedEventHandler; private event EventHandler rootLayerTouchDataEventHandler; private ReturnTypeEventHandler rootLayerInterceptTouchDataEventHandler; @@ -657,6 +726,7 @@ public event EventHandler PointerConstraintsEvent private event EventHandler resizeCompletedHandler; private event EventHandler insetsChangedEventHandler; private event EventHandler windowPointerConstraintsEventHandler; + private event EventHandler rootLayerHoverDataEventHandler; internal event EventHandler EventProcessingFinished @@ -955,6 +1025,13 @@ internal void DisconnectNativeSignals() signal?.Disconnect(windowPointerConstraintsEventCallback); windowPointerConstraintsEventCallback = null; } + + if (rootLayerHoverDataCallback != null) + { + Interop.ActorSignal.HoveredDisconnect(Layer.getCPtr(GetRootLayer()), rootLayerHoverDataCallback.ToHandleRef(this)); + NDalicPINVOKE.ThrowExceptionIfExists(); + rootLayerHoverDataCallback = null; + } } private void OnWindowFocusedChanged(IntPtr window, bool focusGained) @@ -1265,6 +1342,23 @@ private void OnWindowPointerConstraintsEvent(IntPtr view, IntPtr constraintsEven } } + private bool OnWindowHover(IntPtr view, IntPtr hoverData) + { + if (hoverData == global::System.IntPtr.Zero) + { + NUILog.Error("hoverData should not be null!"); + return false; + } + + if (rootLayerHoverDataEventHandler != null) + { + HoverEventArgs e = new HoverEventArgs(); + e.Hover = Tizen.NUI.Hover.GetHoverFromPtr(hoverData); + rootLayerHoverDataEventHandler(this, e); + } + return false; + } + /// /// The focus changed event argument. /// @@ -1459,6 +1553,31 @@ public PointerConstraints PointerConstraints } } + /// + /// Event arguments that passed via the hover signal. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class HoverEventArgs : EventArgs + { + private Hover hover; + + /// + /// Hover - contains touch points that represent the points that are currently being hovered or the points where a hover has stopped. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Hover Hover + { + get + { + return hover; + } + set + { + hover = value; + } + } + } + /// /// Do not use this, that will be deprecated. /// diff --git a/src/Tizen.NUI/src/public/XamlBinding/BindableObject.cs b/src/Tizen.NUI/src/public/XamlBinding/BindableObject.cs index 2beb056fe4f..b5390fa7791 100755 --- a/src/Tizen.NUI/src/public/XamlBinding/BindableObject.cs +++ b/src/Tizen.NUI/src/public/XamlBinding/BindableObject.cs @@ -62,10 +62,7 @@ public object BindingContext [EditorBrowsable(EditorBrowsableState.Never)] public int LinePosition { get; set; } = -1; - void IDynamicResourceHandler.SetDynamicResource(BindableProperty property, string key) - { - SetDynamicResource(property, key, false); - } + void IDynamicResourceHandler.SetDynamicResource(BindableProperty property, string key) => SetDynamicResource(property, key, false); /// /// Raised when a property has changed. @@ -136,10 +133,7 @@ public void CopyBindingRelationShip(BindableObject other) [EditorBrowsable(EditorBrowsableState.Never)] public event EventHandler BindingContextChanged; - internal void ClearValue(BindableProperty property, bool fromStyle) - { - ClearValue(property, fromStyle: fromStyle, checkAccess: true); - } + internal void ClearValue(BindableProperty property, bool fromStyle) => ClearValue(property, fromStyle: fromStyle, checkAccess: true); /// /// Clears any value set by Tizen.NUI.Xaml.BindableObject.SetValue. @@ -213,7 +207,8 @@ public object GetValue(BindableProperty property) /// Removes a previously set binding. /// /// The BindableProperty from which to remove bindings. - internal void RemoveBinding(BindableProperty property) + [EditorBrowsable(EditorBrowsableState.Never)] + public void RemoveBinding(BindableProperty property) { if (property == null) throw new ArgumentNullException(nameof(property)); @@ -232,10 +227,7 @@ internal void RemoveBinding(BindableProperty property) /// The binding to set. /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public void SetBinding(BindableProperty targetProperty, BindingBase binding) - { - SetBinding(targetProperty, binding, false); - } + public void SetBinding(BindableProperty targetProperty, BindingBase binding) => SetBinding(targetProperty, binding, false); /// Internal used, will never changed to not hidden. [EditorBrowsable(EditorBrowsableState.Never)] @@ -326,6 +318,7 @@ internal void InternalSetValue(BindableProperty property, object value) context.Value = value; } + property.PropertyChanging?.Invoke(this, oldvalue, value); property.PropertyChanged?.Invoke(this, oldvalue, value); OnPropertyChanged(property.PropertyName); @@ -423,10 +416,7 @@ public static void RegisterPropertyGroup(BindableProperty property, HashSet /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - protected void ApplyBindings() - { - ApplyBindings(skipBindingContext: false, fromBindingContextChanged: false); - } + protected void ApplyBindings() => ApplyBindings(skipBindingContext: false, fromBindingContextChanged: false); /// /// Override this method to execute an action when the BindingContext changes. @@ -650,10 +640,7 @@ bool CanBeSetFromStyle(BindableProperty property) return false; } - internal void SetDynamicResource(BindableProperty property, string key) - { - SetDynamicResource(property, key, false); - } + internal void SetDynamicResource(BindableProperty property, string key) => SetDynamicResource(property, key, false); internal void SetDynamicResource(BindableProperty property, string key, bool fromStyle) { @@ -675,10 +662,7 @@ internal void SetDynamicResource(BindableProperty property, string key, bool fro OnSetDynamicResource(property, key); } - internal void SetValue(BindableProperty property, object value, bool fromStyle) - { - SetValue(property, value, fromStyle, true); - } + internal void SetValue(BindableProperty property, object value, bool fromStyle) => SetValue(property, value, fromStyle, true); internal void SetValueCore(BindablePropertyKey propertyKey, object value, SetValueFlags attributes = SetValueFlags.None) { @@ -692,10 +676,7 @@ internal void SetValueCore(BindablePropertyKey propertyKey, object value, SetVal /// The value to set /// The set value flag [EditorBrowsable(EditorBrowsableState.Never)] - internal void SetValueCore(BindableProperty property, object value, SetValueFlags attributes = SetValueFlags.None) - { - SetValueCore(property, value, attributes, SetValuePrivateFlags.Default); - } + internal void SetValueCore(BindableProperty property, object value, SetValueFlags attributes = SetValueFlags.None) => SetValueCore(property, value, attributes, SetValuePrivateFlags.Default); internal void SetValueCore(BindableProperty property, object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes) { @@ -1115,7 +1096,11 @@ internal void ReplaceBindingElement(Dictionary oldNameScope, Dic } } - internal void ClearBinding() + /// + /// Unapplies all previously set bindings. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void ClearBinding() { foreach (var property in properties) { diff --git a/src/Tizen.Network.Bluetooth/Interop/Interop.Glib.cs b/src/Tizen.Network.Bluetooth/Interop/Interop.Glib.cs index 576a6e287cf..ee7a1e1cd98 100644 --- a/src/Tizen.Network.Bluetooth/Interop/Interop.Glib.cs +++ b/src/Tizen.Network.Bluetooth/Interop/Interop.Glib.cs @@ -26,5 +26,8 @@ internal static partial class Glib [DllImport(Libraries.Glib, EntryPoint = "g_idle_add", CallingConvention = CallingConvention.Cdecl)] internal static extern uint IdleAdd(GSourceFunc d, IntPtr data); + + [DllImport(Libraries.Glib, EntryPoint = "g_free", CallingConvention = CallingConvention.Cdecl)] + internal static extern void Gfree(IntPtr ptr); } } diff --git a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothAdapterImpl.cs b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothAdapterImpl.cs index 99a856d1f5f..d74b045fa0f 100644 --- a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothAdapterImpl.cs +++ b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothAdapterImpl.cs @@ -534,14 +534,14 @@ internal BluetoothOobData GetLocalOobData() byte[] hashArr = new byte[hashLength]; Marshal.Copy(hash, hashArr, 0, hashLength); oobData.HashValue = hashArr; - Interop.Libc.Free(hash); + Interop.Glib.Gfree(hash); } if (randomizerLength > 0) { byte[] randomizerArr = new byte[randomizerLength]; Marshal.Copy(randomizer, randomizerArr, 0, randomizerLength); oobData.RandomizerValue = randomizerArr; - Interop.Libc.Free(randomizer); + Interop.Glib.Gfree(randomizer); } return oobData; diff --git a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothLeAdapterImpl.cs b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothLeAdapterImpl.cs index 890c80e3e4a..4cd0a805106 100644 --- a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothLeAdapterImpl.cs +++ b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothLeAdapterImpl.cs @@ -187,10 +187,10 @@ internal IList GetLeScanResultServiceUuids(BluetoothLeScanData scanData, foreach (IntPtr uuids in uuidList) { list.Add(Marshal.PtrToStringAnsi(uuids)); - Interop.Libc.Free(uuids); + Interop.Glib.Gfree(uuids); } - Interop.Libc.Free(uuidListArray); + Interop.Glib.Gfree(uuidListArray); Marshal.FreeHGlobal(scanDataStruct.AdvData); Marshal.FreeHGlobal(scanDataStruct.ScanData); return list; @@ -295,10 +295,10 @@ internal IList GetScanResultSvcSolicitationUuids(BluetoothLeScanData sca foreach (IntPtr uuids in uuidList) { list.Add(Marshal.PtrToStringAnsi(uuids)); - Interop.Libc.Free(uuids); + Interop.Glib.Gfree(uuids); } - Interop.Libc.Free(uuidListArray); + Interop.Glib.Gfree(uuidListArray); Marshal.FreeHGlobal(scanDataStruct.AdvData); Marshal.FreeHGlobal(scanDataStruct.ScanData); return list; @@ -417,7 +417,7 @@ internal ManufacturerData GetScanResultManufacturerData(BluetoothLeScanData scan Marshal.Copy(manufData, data.Data, 0, data.DataLength); } - Interop.Libc.Free(manufData); + Interop.Glib.Gfree(manufData); Marshal.FreeHGlobal(scanDataStruct.AdvData); Marshal.FreeHGlobal(scanDataStruct.ScanData); return data; diff --git a/src/Tizen.Content.MimeType/Interop/Interop.Libc.cs b/src/Tizen.Network.Connection/Interop/Interop.Glib.cs old mode 100755 new mode 100644 similarity index 78% rename from src/Tizen.Content.MimeType/Interop/Interop.Libc.cs rename to src/Tizen.Network.Connection/Interop/Interop.Glib.cs index 825599e274e..a4961a70064 --- a/src/Tizen.Content.MimeType/Interop/Interop.Libc.cs +++ b/src/Tizen.Network.Connection/Interop/Interop.Glib.cs @@ -19,9 +19,9 @@ internal static partial class Interop { - internal static partial class Libc + internal static partial class Glib { - [DllImport(Libraries.Libc, EntryPoint = "free", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Free(IntPtr ptr); + [DllImport(Libraries.Glib, EntryPoint = "g_free", CallingConvention = CallingConvention.Cdecl)] + internal static extern uint Free(IntPtr data); } } diff --git a/src/Tizen.Network.Connection/Interop/Interop.Libraries.cs b/src/Tizen.Network.Connection/Interop/Interop.Libraries.cs index e4c53178bc3..4963b1752eb 100644 --- a/src/Tizen.Network.Connection/Interop/Interop.Libraries.cs +++ b/src/Tizen.Network.Connection/Interop/Interop.Libraries.cs @@ -20,5 +20,6 @@ internal static partial class Libraries { public const string Connection = "libcapi-network-connection.so.1"; public const string Libc = "libc.so.6"; + public const string Glib = "libglib-2.0.so.0"; } } diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection/CellularProfile.cs b/src/Tizen.Network.Connection/Tizen.Network.Connection/CellularProfile.cs index 91503be50de..7969f7ff6eb 100755 --- a/src/Tizen.Network.Connection/Tizen.Network.Connection/CellularProfile.cs +++ b/src/Tizen.Network.Connection/Tizen.Network.Connection/CellularProfile.cs @@ -63,7 +63,7 @@ public string Apn Log.Error(Globals.LogTag, "It failed to get apn, " + (ConnectionError)ret); } string result = Marshal.PtrToStringAnsi(Value); - Interop.Libc.Free(Value); + Interop.Glib.Free(Value); return result; } @@ -112,7 +112,7 @@ public string HomeUri Log.Error(Globals.LogTag, "It failed to get home url, " + (ConnectionError)ret); } string result = Marshal.PtrToStringAnsi(Value); - Interop.Libc.Free(Value); + Interop.Glib.Free(Value); return result; } diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionInternalManager.cs b/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionInternalManager.cs index a622a282278..637f3c0a52e 100644 --- a/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionInternalManager.cs +++ b/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionInternalManager.cs @@ -479,7 +479,7 @@ internal System.Net.IPAddress GetIPAddress(AddressFamily family) } string result = Marshal.PtrToStringAnsi(ip); - Interop.Libc.Free(ip); + Interop.Glib.Free(ip); Log.Info(Globals.LogTag, "IPAddress " + result + " (" + result.Length + ")"); if (result.Length == 0) { @@ -535,7 +535,7 @@ internal string GetProxy(AddressFamily family) } string result = Marshal.PtrToStringAnsi(ip); - Interop.Libc.Free(ip); + Interop.Glib.Free(ip); return result; } @@ -553,7 +553,7 @@ internal string GetMacAddress(ConnectionType type) } string result = Marshal.PtrToStringAnsi(mac); - Interop.Libc.Free(mac); + Interop.Glib.Free(mac); return result; } diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfile.cs b/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfile.cs index df518f9d2fd..362e10f57a1 100755 --- a/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfile.cs +++ b/src/Tizen.Network.Connection/Tizen.Network.Connection/ConnectionProfile.cs @@ -196,7 +196,7 @@ public string Id Log.Error(Globals.LogTag, "It failed to get id of connection profile, " + (ConnectionError)ret); } string result = Marshal.PtrToStringAnsi(Value); - Interop.Libc.Free(Value); + Interop.Glib.Free(Value); return result; } } @@ -217,7 +217,7 @@ public string Name Log.Error(Globals.LogTag, "It failed to get name of connection profile, " + (ConnectionError)ret); } string result = Marshal.PtrToStringAnsi(Value); - Interop.Libc.Free(Value); + Interop.Glib.Free(Value); return result; } } @@ -257,7 +257,7 @@ public string InterfaceName Log.Error(Globals.LogTag, "It failed to get network interface name, " + (ConnectionError)ret); } string result = Marshal.PtrToStringAnsi(Value); - Interop.Libc.Free(Value); + Interop.Glib.Free(Value); return result; } } @@ -391,7 +391,7 @@ public string ProxyAddress Log.Error(Globals.LogTag, "It failed to get proxy address, " + (ConnectionError)ret); } string result = Marshal.PtrToStringAnsi(Value); - Interop.Libc.Free(Value); + Interop.Glib.Free(Value); return result; } diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection/IAddressInformation.cs b/src/Tizen.Network.Connection/Tizen.Network.Connection/IAddressInformation.cs index ec3ec8f0321..d9d50c22b63 100755 --- a/src/Tizen.Network.Connection/Tizen.Network.Connection/IAddressInformation.cs +++ b/src/Tizen.Network.Connection/Tizen.Network.Connection/IAddressInformation.cs @@ -353,7 +353,7 @@ private System.Net.IPAddress ParseIPAddress(int ret, IntPtr addrPtr) string addr = Marshal.PtrToStringAnsi(addrPtr); if (addr == null || addr.Length == 0) return DefaultIPAddress(); - Interop.Libc.Free(addrPtr); + Interop.Glib.Free(addrPtr); return System.Net.IPAddress.Parse(addr); } diff --git a/src/Tizen.Network.Connection/Tizen.Network.Connection/WiFiProfile.cs b/src/Tizen.Network.Connection/Tizen.Network.Connection/WiFiProfile.cs index 6cfbc3337db..df370be5296 100755 --- a/src/Tizen.Network.Connection/Tizen.Network.Connection/WiFiProfile.cs +++ b/src/Tizen.Network.Connection/Tizen.Network.Connection/WiFiProfile.cs @@ -55,7 +55,7 @@ public string Essid Log.Error(Globals.LogTag, "It failed to create profile handle, " + (ConnectionError)ret); } string result = Marshal.PtrToStringAnsi(value); - Interop.Libc.Free(value); + Interop.Glib.Free(value); return result; } } @@ -76,7 +76,7 @@ public string Bssid Log.Error(Globals.LogTag, "It failed to get bssid, " + (ConnectionError)ret); } string result = Marshal.PtrToStringAnsi(value); - Interop.Libc.Free(value); + Interop.Glib.Free(value); return result; } } diff --git a/src/Tizen.Network.Nsd/Interop/Interop.Nsd.cs b/src/Tizen.Network.Nsd/Interop/Interop.Nsd.cs index 87697b2e7d6..5e6bebbf391 100755 --- a/src/Tizen.Network.Nsd/Interop/Interop.Nsd.cs +++ b/src/Tizen.Network.Nsd/Interop/Interop.Nsd.cs @@ -119,4 +119,10 @@ internal static partial class Libc [DllImport(Libraries.Libc, EntryPoint = "free")] public static extern void Free(IntPtr userData); } + + internal static partial class Glib + { + [DllImport(Libraries.Glib, EntryPoint = "g_free", CallingConvention = CallingConvention.Cdecl)] + public static extern void Free(IntPtr userData); + } } diff --git a/src/Tizen.Network.Nsd/Tizen.Network.Nsd/DnssdService.cs b/src/Tizen.Network.Nsd/Tizen.Network.Nsd/DnssdService.cs index 494a726c8d0..19049b3ce73 100755 --- a/src/Tizen.Network.Nsd/Tizen.Network.Nsd/DnssdService.cs +++ b/src/Tizen.Network.Nsd/Tizen.Network.Nsd/DnssdService.cs @@ -241,7 +241,7 @@ public byte[] GetRawTXTRecords() { value = new byte[length]; Marshal.Copy(data, value, 0, length); - Interop.Libc.Free(data); + Interop.Glib.Free(data); } return value; } diff --git a/src/Tizen.Network.WiFi/Interop/Interop.Libraries.cs b/src/Tizen.Network.WiFi/Interop/Interop.Libraries.cs index d966df68f4a..1dbe019ec1b 100755 --- a/src/Tizen.Network.WiFi/Interop/Interop.Libraries.cs +++ b/src/Tizen.Network.WiFi/Interop/Interop.Libraries.cs @@ -20,6 +20,5 @@ internal static partial class Libraries { public const string WiFi = "libcapi-network-wifi-manager.so.1"; public const string Glib = "libglib-2.0.so.0"; - public const string Libc = "libc.so.6"; } } diff --git a/src/Tizen.Network.WiFi/Interop/Interop.WiFi.cs b/src/Tizen.Network.WiFi/Interop/Interop.WiFi.cs index 70458db3891..2f46431eb2e 100755 --- a/src/Tizen.Network.WiFi/Interop/Interop.WiFi.cs +++ b/src/Tizen.Network.WiFi/Interop/Interop.WiFi.cs @@ -353,9 +353,9 @@ protected override bool ReleaseHandle() } - internal static partial class Libc + internal static partial class Glib { - [DllImport(Libraries.Libc, EntryPoint = "free")] + [DllImport(Libraries.Glib, EntryPoint = "g_free", CallingConvention = CallingConvention.Cdecl)] public static extern void Free(IntPtr userData); } } diff --git a/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiAddressInformation.cs b/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiAddressInformation.cs index 5b43e3064e8..8d69e7e894e 100755 --- a/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiAddressInformation.cs +++ b/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiAddressInformation.cs @@ -252,7 +252,7 @@ private System.Net.IPAddress ParseIPAddress(int ret, IntPtr addrPtr) string addr = Marshal.PtrToStringAnsi(addrPtr); if (addr == null || addr.Length == 0) return DefaultIPAddress(); - Interop.Libc.Free(addrPtr); + Interop.Glib.Free(addrPtr); return System.Net.IPAddress.Parse(addr); } diff --git a/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiNetwork.cs b/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiNetwork.cs index 4bb8fa0792e..ede4e4de684 100755 --- a/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiNetwork.cs +++ b/src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiNetwork.cs @@ -54,7 +54,7 @@ public string Essid else { _essid = Marshal.PtrToStringAnsi(strPtr); - Interop.Libc.Free(strPtr); + Interop.Glib.Free(strPtr); } } return _essid; @@ -83,7 +83,7 @@ public byte[] RawSsid { rawSsid = new byte[length]; Marshal.Copy(ptr, rawSsid, 0, length); - Interop.Libc.Free(ptr); + Interop.Glib.Free(ptr); } return rawSsid; } @@ -364,7 +364,7 @@ public string CountryCode else { code = Marshal.PtrToStringAnsi(strPtr); - Interop.Libc.Free(strPtr); + Marshal.FreeHGlobal(strPtr); } return code; } diff --git a/src/Tizen.System.Feedback/Feedback/Feedback.cs b/src/Tizen.System.Feedback/Feedback/Feedback.cs index c9b253103f9..daaf66ba0e6 100755 --- a/src/Tizen.System.Feedback/Feedback/Feedback.cs +++ b/src/Tizen.System.Feedback/Feedback/Feedback.cs @@ -85,6 +85,10 @@ public class Feedback { {"Tap", 0}, {"SoftInputPanel", 1}, + {"SipBackspace", 2}, + {"SipFunction", 3}, + {"SipFjkey", 4}, + {"MaxCharacter", 5}, {"Key0", 6}, {"Key1", 7}, {"Key2", 8}, @@ -99,29 +103,242 @@ public class Feedback {"KeySharp", 17}, {"KeyBack", 18}, {"Hold", 19}, + {"MultiTap", 20}, {"HardwareKeyPressed", 21}, {"HardwareKeyHold", 22}, {"Message", 23}, + {"MessageOnCall", 24}, {"Email", 25}, + {"EmailOnCall", 26}, {"WakeUp", 27}, + {"WakeUpOnCall", 28}, {"Schedule", 29}, + {"ScheduleOnCall", 30}, {"Timer", 31}, + {"TimerOnCall", 32}, {"General", 33}, + {"GeneralOnCall", 34}, + {"SmartAlert", 35}, {"PowerOn", 36}, {"PowerOff", 37}, {"ChargerConnected", 38}, + {"ChargerconnOnCall", 39}, {"ChargingError", 40}, + {"ChargingErrorOnCall", 41}, {"FullyCharged", 42}, + {"FullchargedOnCall", 43}, {"LowBattery", 44}, + {"LowBattOnCall", 45}, {"Lock", 46}, {"UnLock", 47}, + {"GeometricLock", 50}, + {"Callconnect", 51}, + {"Discallconnect", 52}, + {"OutgoingCall", 53}, + {"Minuteminder", 54}, {"VibrationModeAbled", 55}, {"SilentModeDisabled", 56}, {"BluetoothDeviceConnected", 57}, {"BluetoothDeviceDisconnected", 58}, + {"BtPairing", 59}, + {"BtWaiting", 60}, + {"ScreenCapture", 61}, {"ListReorder", 62}, {"ListSlider", 63}, {"VolumeKeyPressed", 64}, + {"UvProcessing", 95}, + {"ShealthStart", 96}, + {"ShealthPause", 97}, + {"ShealthStop", 98}, + {"3rdApplication", 99}, + {"Tick", 100}, + {"TransitionCircular", 101}, + {"TransitionPop", 102}, + {"Process", 103}, + {"MoveList", 104}, + {"Dismiss", 105}, + {"ClockSecondHand", 106}, + {"SystemShort", 107}, + {"SystemError", 108}, + {"SpiralDown", 109}, + {"MoveList2", 110}, + {"SpiralUp", 111}, + {"SystemLong", 112}, + {"SystemMid", 113}, + {"Silence", 114}, + {"InactiveTension", 115}, + {"InactiveFine", 116}, + {"EndEffect", 117}, + {"ShealthNotice", 118}, + {"ShealthGentleAlert", 119}, + {"EndEffectFine", 120}, + {"ClickValue", 121}, + {"ClickFineTrain1", 122}, + {"ClickFine", 123}, + {"ClickSlider", 124}, + {"ClickMedium", 125}, + {"ClickStrong", 126}, + {"TurnRight", 127}, + {"TurnLeft", 128}, + {"Function", 129}, + {"VoiceStart", 130}, + {"VoiceStop", 131}, + {"Communication", 132}, + {"MessageStrongBuzz", 133}, + {"EmailStrongBuzz", 134}, + {"GeneralStrongBuzz", 135}, + {"CommunicationStrongBuzz", 136}, + {"ScheduleStrongBuzz", 137}, + {"WakeupStrongBuzz", 138}, + {"TimerStrongBuzz", 139}, + {"RingerStrongBuzz", 140}, + {"Heartbeat", 141}, + {"HeartbeatFast", 142}, + {"SettingOn", 143}, + {"SettingOff", 144}, + {"Connect", 145}, + {"Disconnect", 146}, + {"FindMyGear", 147}, + {"Notification1", 148}, + {"Notification1StrongBuzz", 149}, + {"Notification2", 150}, + {"Notification2StrongBuzz", 151}, + {"Notification3", 152}, + {"Notification3StrongBuzz", 153}, + {"Notification4", 154}, + {"Notification4StrongBuzz", 155}, + {"Notification5", 156}, + {"Notification5StrongBuzz", 157}, + {"Notification6", 158}, + {"Notification6StrongBuzz", 159}, + {"Notification7", 160}, + {"Notification7StrongBuzz", 161}, + {"Notification8", 162}, + {"Notification8StrongBuzz", 163}, + {"Notification9", 164}, + {"Notification9StrongBuzz", 165}, + {"Notification10", 166}, + {"Notification10StrongBuzz", 167}, + {"Ring1", 168}, + {"Ring1StrongBuzz", 169}, + {"Ring2", 170}, + {"Ring2StrongBuzz", 171}, + {"Ring3", 172}, + {"Ring3StrongBuzz", 173}, + {"Ring4", 174}, + {"Ring4StrongBuzz", 175}, + {"Ring5", 176}, + {"Ring5StrongBuzz", 177}, + {"Ring6", 178}, + {"Ring6StrongBuzz", 179}, + {"Ring7", 180}, + {"Ring7StrongBuzz", 181}, + {"Ring8", 182}, + {"Ring8StrongBuzz", 183}, + {"Ring9", 184}, + {"Ring9StrongBuzz", 185}, + {"Ring10", 186}, + {"Ring10StrongBuzz", 187}, + {"Alarm1", 188}, + {"Alarm1StrongBuzz", 189}, + {"Alarm2", 190}, + {"Alarm2StrongBuzz", 191}, + {"Alarm3", 192}, + {"Alarm3StrongBuzz", 193}, + {"Alarm4", 194}, + {"Alarm4StrongBuzz", 195}, + {"Alarm5", 196}, + {"Alarm5StrongBuzz", 197}, + {"Alarm6", 198}, + {"Alarm6StrongBuzz", 199}, + {"Alarm7", 200}, + {"Alarm7StrongBuzz", 201}, + {"Alarm8", 202}, + {"Alarm8StrongBuzz", 203}, + {"Alarm9", 204}, + {"Alarm9StrongBuzz", 205}, + {"Alarm10", 206}, + {"Alarm10StrongBuzz", 207}, + {"Picker", 208}, + {"PickerFinish", 209}, + {"OnOffSwitch", 210}, + {"Reorder", 211}, + {"CursorMove", 212}, + {"Mms", 10000}, + {"HourlyAlert", 10001}, + {"SafetyAlert", 10002}, + {"AccidentDetect", 10003}, + {"SendSosMessage", 10004}, + {"EndSosMessage", 10005}, + {"EmergencyBuzzer", 10006}, + {"SafetyLowPower", 10007}, + {"Cmas", 10008}, + {"Ringer", 10009}, + {"Notification", 10010}, + {"Info", 10011}, + {"Warning", 10012}, + {"Error", 10013}, + {"Emergency", 10014}, + {"InternalWakeup", 10015}, + {"InternalTimer", 10016}, + {"TemperatureWarning", 10017}, + {"CooldownWarning1", 10018}, + {"CooldownWarning2", 10019}, + {"SpeedUp", 10020}, + {"SlowDown", 10021}, + {"KeepThisPace", 10022}, + {"GoalAchieved", 10023}, + {"ExerciseCount", 10024}, + {"StartCue", 10025}, + {"HealthPace", 10026}, + {"InactiveTime", 10027}, + {"CmasCa", 10028}, + {"NfcSuccess", 10029}, + {"MeasuringSuccess", 10030}, + {"MeasuringFailure", 10031}, + {"Meditation", 10032}, + {"MeditationInternal", 10033}, + {"FallDetection1", 10034}, + {"FallDetection2", 10035}, + {"SmartGesture", 10036}, + {"BreathingExhale", 12000}, + {"Bos", 12001}, + {"Eos", 12002}, + {"Uds", 12003}, + {"Basic", 40001}, + {"ToggleOn", 40002}, + {"ToggleOff", 40003}, + {"LongPressOn", 40004}, + {"LongPressOff", 40005}, + {"Invalid", 40006}, + {"Confirm", 40007}, + {"PopUp", 40008}, + {"PreheatEnding", 40009}, + {"TaskEnding", 40010}, + {"Scroll", 40011}, + {"PageTurn", 40012}, + {"OpStart", 40013}, + {"OpPause", 40014}, + {"OpStop", 40015}, + {"Default", 40016}, + {"DefaultLevel1", 40017}, + {"Level1", 40018}, + {"Level2", 40019}, + {"Level3", 40020}, + {"Level4", 40021}, + {"Level5", 40022}, + {"Level6", 40023}, + {"Level7", 40024}, + {"Level8", 40025}, + {"Level9", 40026}, + {"Level10", 40027}, + {"TimerEnding", 40028}, + {"BurnerDetected", 40029}, + {"BurnerMoved", 40030}, + {"Connected", 40031}, + {"Disconnected", 40032}, + {"Welcome", 40033}, + {"AutoDoorOpen", 40034}, }; /// @@ -335,6 +552,7 @@ public void Stop() /// /// /// Now this internal API works for FeedbackType.Sound only, FeedbackType.Vibration is not supported. + /// Counts of theme range will be 1 ~ N according to conf file. /// /// 10 /// The feedback type. @@ -381,6 +599,7 @@ public uint GetCountOfThemeInternal(FeedbackType type) /// /// /// Now this internal API works for FeedbackType.Sound only, FeedbackType.Vibration is not supported. + /// Index of theme range will be 1 ~ N according to conf file. /// /// 10 /// The feedback type. @@ -425,6 +644,7 @@ public uint GetThemeIndexInternal(FeedbackType type) /// /// Now this internal API works for FeedbackType.Sound only, FeedbackType.Vibration is not supported. /// To set the index of theme for Sound type, the application should have http://tizen.org/privilege/systemsettings.admin privilege. + /// Index of theme range is 1 ~ N according to conf file. If you put the wrong index, operation cannot be guaranteed. /// /// 10 /// The feedback type. @@ -436,7 +656,7 @@ public uint GetThemeIndexInternal(FeedbackType type) /// /// /// Feedback feedback = new Feedback(); - /// uint indexOfTheme = 0; + /// uint indexOfTheme = 1; /// feedback.SetThemeIndexInternal(FeedbackType.Sound, indexOfTheme); /// /// @@ -464,5 +684,52 @@ public void SetThemeIndexInternal(FeedbackType type, uint indexOfTheme) } } } + + /// + /// Stops the current feedback playing by feedback type + /// + /// + /// To stop vibration, the application should have http://tizen.org/privilege/haptic privilege. + /// + /// 10 + /// The feedback type. + /// Thrown when failed because the feedback is not initialized. + /// Thrown when failed because of an invalid argument + /// Thrown when failed because the device (haptic, sound) or a specific pattern is not supported. + /// Thrown when failed because the access is not granted (No privilege). + /// Thrown when failed because of a system error. + /// + /// + /// Feedback Feedback = new Feedback(); + /// feedback.StopTypeInternal(FeedbackType.Sound); + /// feedback.StopTypeInternal(FeedbackType.Vibration); + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void StopTypeInternal(FeedbackType type) + { + Interop.Feedback.FeedbackError res; + + res = (Interop.Feedback.FeedbackError)Interop.Feedback.StopTypeInternal((Interop.Feedback.FeedbackType)type); + + if (res != Interop.Feedback.FeedbackError.None) + { + Log.Warn(LogTag, string.Format("Failed to Stop feedback by feedback type internal. err = {0}", res)); + switch (res) + { + case Interop.Feedback.FeedbackError.NotInitialized: + throw new Exception("Not initialized"); + case Interop.Feedback.FeedbackError.InvalidParameter: + throw new ArgumentException("Invalid Arguments"); + case Interop.Feedback.FeedbackError.NotSupported: + throw new NotSupportedException("Not supported"); + case Interop.Feedback.FeedbackError.PermissionDenied: + throw new UnauthorizedAccessException("Access is not granted"); + case Interop.Feedback.FeedbackError.OperationFailed: + default: + throw new InvalidOperationException("Failed to stop pattern by feedback type"); + } + } + } } } diff --git a/src/Tizen.System.Feedback/Interop/Interop.Feedback.cs b/src/Tizen.System.Feedback/Interop/Interop.Feedback.cs index 359f9b296c2..4cc34fd52b1 100644 --- a/src/Tizen.System.Feedback/Interop/Interop.Feedback.cs +++ b/src/Tizen.System.Feedback/Interop/Interop.Feedback.cs @@ -64,5 +64,8 @@ internal enum FeedbackType [DllImport(Libraries.Feedback, EntryPoint = "feedback_set_theme_index_internal")] internal static extern int SetThemeIndexInternal(FeedbackType type, uint indexOfTheme); + + [DllImport(Libraries.Feedback, EntryPoint = "feedback_stop_type_internal")] + internal static extern int StopTypeInternal(FeedbackType type); } } diff --git a/src/Tizen.System.Information/Interop/Interop.Libc.cs b/src/Tizen.System.Information/Interop/Interop.Libc.cs deleted file mode 100755 index ef021f18f31..00000000000 --- a/src/Tizen.System.Information/Interop/Interop.Libc.cs +++ /dev/null @@ -1,27 +0,0 @@ -/* -* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved -* -* Licensed under the Apache License, Version 2.0 (the License); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an AS IS BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using System; -using System.Runtime.InteropServices; - -internal static partial class Interop -{ - internal static partial class Libc - { - [DllImport(Libraries.Libc, EntryPoint = "free")] - public static extern void Free(IntPtr ptr); - } -} diff --git a/src/Tizen.System.Information/Interop/Interop.Libraries.cs b/src/Tizen.System.Information/Interop/Interop.Libraries.cs index 60ae7217fcd..ddb18845f92 100755 --- a/src/Tizen.System.Information/Interop/Interop.Libraries.cs +++ b/src/Tizen.System.Information/Interop/Interop.Libraries.cs @@ -20,6 +20,5 @@ internal static partial class Libraries { internal const string RuntimeInfo = "libcapi-system-runtime-info.so.0"; internal const string SystemInfo = "libcapi-system-info.so.0"; - internal const string Libc = "libc.so.6"; } } diff --git a/src/Tizen.System.Information/Usage/ProcessMemoryUsage.cs b/src/Tizen.System.Information/Usage/ProcessMemoryUsage.cs index 9583f818452..0c4a2a393fe 100755 --- a/src/Tizen.System.Information/Usage/ProcessMemoryUsage.cs +++ b/src/Tizen.System.Information/Usage/ProcessMemoryUsage.cs @@ -280,7 +280,7 @@ private int[] GetProcessMemoryValueInt(Interop.RuntimeInfo.ProcessMemoryInfoKey } finally { - Interop.Libc.Free(ptr); + Marshal.FreeHGlobal(ptr); } } @@ -319,7 +319,7 @@ public void Update(IEnumerable pid) } finally { - Interop.Libc.Free(ptr); + Marshal.FreeHGlobal(ptr); } Gpus = GetProcessMemoryValueInt(Interop.RuntimeInfo.ProcessMemoryInfoKey.Gpu, pid); diff --git a/src/Tizen.Uix.Tts/Tizen.Uix.Tts/SynthesizedPcmEventArgs.cs b/src/Tizen.Uix.Tts/Tizen.Uix.Tts/SynthesizedPcmEventArgs.cs index 566957035a5..33c7332774c 100644 --- a/src/Tizen.Uix.Tts/Tizen.Uix.Tts/SynthesizedPcmEventArgs.cs +++ b/src/Tizen.Uix.Tts/Tizen.Uix.Tts/SynthesizedPcmEventArgs.cs @@ -15,13 +15,15 @@ */ +using System; + namespace Tizen.Uix.Tts { /// /// This class holds information related to the TTS SynthesizedPcm event. /// /// 11 - public class SynthesizedPcmEventArgs + public class SynthesizedPcmEventArgs : EventArgs { internal SynthesizedPcmEventArgs(int utteranceId, SynthesizedPcmEvent synthesizedPcmEvent, byte[] data, AudioType audioType, int sampleRate) { diff --git a/test/NUIDnDSource/NUIDnDSource.cs b/test/NUIDnDSource/NUIDnDSource.cs index 660db6c3489..7bceebef55c 100644 --- a/test/NUIDnDSource/NUIDnDSource.cs +++ b/test/NUIDnDSource/NUIDnDSource.cs @@ -24,6 +24,7 @@ void Initialize() { // Create DnD Instance dnd = DragAndDrop.Instance; + dnd.SetDragWindowOffset(-75, -75); Window.Instance.KeyEvent += OnKeyEvent; Window.Instance.WindowSize = new Size(900, 1080); diff --git a/test/NUITizenGallery/NUITizenGallery.csproj b/test/NUITizenGallery/NUITizenGallery.csproj index 31dd075b268..a99dc198270 100755 --- a/test/NUITizenGallery/NUITizenGallery.csproj +++ b/test/NUITizenGallery/NUITizenGallery.csproj @@ -33,6 +33,6 @@ - + diff --git a/test/NUIWindowKVMSample/NUIWindowKVMSample.cs b/test/NUIWindowKVMSample/NUIWindowKVMSample.cs index 3fcc072f94c..0c266d39d7e 100644 --- a/test/NUIWindowKVMSample/NUIWindowKVMSample.cs +++ b/test/NUIWindowKVMSample/NUIWindowKVMSample.cs @@ -112,7 +112,9 @@ public KVMServiceWindow(Rectangle winGeometry) : windowView.BackgroundColor = Color.Yellow; this.Add(windowView); - dnd.AddListener(windowView, OnDnDEvent); + // The First argument of listener should be window, not view. + // The listener of view couldn't catch receive data from ReceiveDragData of KVMService + dnd.AddListener(this, OnDnDEvent); tzShell = new Tizen.NUI.WindowSystem.Shell.TizenShell(); kvmService = new Tizen.NUI.WindowSystem.Shell.KVMService(tzShell, this); @@ -126,7 +128,15 @@ private void OnDnDEvent(object sender, DragEvent e) if (e.DragType == DragType.Enter) { Log.Debug("KVMSample", "Target(KVM) App DRagEvnetType: Enter"); - kvmService.PerformDrop(); + // PerformDrop is drop into the KVM window and finish the current drag. + // If you want to get the current drag data without end the drag, + // use ReceiveDragData(mimetype) instead of PerformDrop(). + //kvmService.PerformDrop(); + + // The drag data will be received by ReceiveDragData of OnDragStarted callback and DragEvent of the OnDnDEvent callback. + // and the drag will be ended by enter the KVM window as UX of the app. + // If you want to end the drag without receive drag data, use CancelDrag(). + kvmService.CancelDrag(); } if (e.DragType == DragType.Drop) { @@ -137,6 +147,10 @@ private void OnDnDEvent(object sender, DragEvent e) private void OnDragStarted(object sender, EventArgs e) { Log.Debug("KVMSample", "Tizen KVM: Drag started"); + + // Request the drag data to the Display server. + // The drag data can get at DnD Listener (OnDnDEvent function) + kvmService.ReceiveDragData("text/plain"); } private void OnDragEnded(object sender, EventArgs e) diff --git a/test/Tizen.NUI.Devel.Tests.Ubuntu/Tizen.NUI.Devel.Tests/testcase/public/TSView.cs b/test/Tizen.NUI.Devel.Tests.Ubuntu/Tizen.NUI.Devel.Tests/testcase/public/TSView.cs index b350ca8e481..3a2ecb63dbb 100644 --- a/test/Tizen.NUI.Devel.Tests.Ubuntu/Tizen.NUI.Devel.Tests/testcase/public/TSView.cs +++ b/test/Tizen.NUI.Devel.Tests.Ubuntu/Tizen.NUI.Devel.Tests/testcase/public/TSView.cs @@ -207,5 +207,24 @@ public void ColorBlue_GET_SET_VALUE() testView.Dispose(); } + + + [Test] + [Category("P1")] + [Description("Get value test for View.ToolTipText")] + [Property("SPEC", "Tizen.NUI.BaseComponents.View.ToolTipText")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRW")] + [Property("AUTHOR", "eunkiki.hong@samsung.com")] + public void ToolTipText_GET_SET_VALUE() + { + /* TEST CODE */ + View testView = new View(); + + testView.TooltipText = "tooltipText"; + Assert.AreEqual("tooltipText", testView.TooltipText, "Should get equal string value what we set before"); + + testView.Dispose(); + } } } diff --git a/test/Tizen.NUI.ParticleSystem.Sample/ParticleSystemSample.cs b/test/Tizen.NUI.ParticleSystem.Sample/ParticleSystemSample.cs new file mode 100644 index 00000000000..462ffe5465d --- /dev/null +++ b/test/Tizen.NUI.ParticleSystem.Sample/ParticleSystemSample.cs @@ -0,0 +1,196 @@ +using System; +using System.Collections.Generic; +using System.Threading; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Components; +using Tizen.NUI.ParticleSystem; + +namespace Tizen.NUI.ParticleSystem.Sample +{ + // SparkleEffectSource spawns particle from the middle of the + // window. + class SparkleEffectSource : ParticleSourceInterface + { + public override void Construct(params object[] list) + { + base.Construct(list); + mRadius = new Vector2(list[0] as Vector2); + } + + public override uint Update(ParticleEmitterProxy emitterProxy, uint count) + { + if(mStreamBasePos == 0 || mStreamBaseAngle == 0) // streams must exist + { + return 0u; + } + + while(count > 0) + { + // Create new particle (lifetime 5 seconds of each) + var particle = emitterProxy.NewParticle(5.0f); + if(particle == null) + { + return 0u; + } + + UpdateParticle(ref particle); + + count--; + } + return 0; + } + + public override void Init() + { + // Add local stream of Vector3 type + mStreamBasePos = Emitter.AddLocalStreamVector3(Vector3.Zero); + + // Add local stream of float type + mStreamBaseAngle = Emitter.AddLocalStreamFloat(0.0f); + } + + void UpdateParticle(ref Particle p) + { + float posRadians = ((mRandom.Next() % 360) * (float)Math.PI) / 180.0f; + p.Position = new Vector3(mRadius.X * (float)Math.Sin(posRadians), mRadius.Y * (float)Math.Cos(posRadians), 0.0f); + p.SetStreamValue(p.Position, mStreamBasePos); + p.Color = Vector4.One; + p.SetStreamValue(mAngle, mStreamBaseAngle); + mAngle = ((mAngle+5)%360); + float rad = ((mRandom.Next() % 360) * (float)Math.PI) / 180.0f; + float speed = ((mRandom.Next() % 5) + 5); + p.Velocity = new Vector3((float)Math.Sin(rad) * speed, (float)Math.Cos(rad) * speed, 0); + + // Random initial scale + float initialScale = (float)(mRandom.Next() % 32) + 32; + p.Scale = new Vector3(initialScale, initialScale, 1.0f); + } + + private static float mAngle = 0; + private Random mRandom = new Random(); + public uint mStreamBasePos = 0; + public uint mStreamBaseAngle = 0; + private Vector2 mRadius; + } + + // SparkleEffectModifier spawns particle from the middle of the + // window. + class SparkleEffectModifier : ParticleModifierInterface + { + public override void Construct(params object[] list) + { + base.Construct(list); + mSource = list[0] as SparkleEffectSource; + } + + public override void Update(ParticleEmitterProxy proxy, List particles) + { + if (particles.Count == 0) + { + return; + } + + if (mStreamBasePos == 0) + { + mStreamBasePos = mSource.mStreamBasePos; + } + + if (mStreamBaseAngle == 0) + { + mStreamBaseAngle = mSource.mStreamBaseAngle; + } + + if (mStreamBasePos == 0) + { + return; + } + + for (uint i = 0; i < particles.Count; ++i) + { + var p = particles[(int)i]; + + float angle = p.GetStreamValue(mStreamBaseAngle); + Vector3 basePos = p.GetStreamValue(mStreamBaseAngle); + float radians = (float)((angle * Math.PI)/180.0f); + float lifetime = p.Lifetime; + Vector3 pos = p.Position; + var vel = p.Velocity; + p.Position = new Vector3(pos.X + vel.X * (float)Math.Cos(radians),pos.Y + vel.Y * (float)Math.Sin(radians), + pos.Z); + + p.Velocity = (vel * 0.990f); + float normalizedTime = (lifetime / p.LifetimeBase); + + var color = new Vector4( 1, 1, 1, normalizedTime); + p.Color = color; + p.Scale = new Vector3(64.0f*(normalizedTime * normalizedTime * normalizedTime * normalizedTime), 64.0f*(normalizedTime * normalizedTime * normalizedTime * normalizedTime), 1.0f); + + } + } + + private uint mStreamBasePos = 0; + private uint mStreamBaseAngle = 0; + private SparkleEffectSource mSource; + + } + + class ParticleSystemSample : NUIApplication + { + static string IMAGE_DIR = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "image/"; + + private Window mWindow; + + private ParticleEmitter mEmitter; + private ParticleSource mSource; + private ParticleModifier mModifier; + + public void Activate() + { + mWindow = Window.Instance; + mWindow.BackgroundColor = Color.Black; + + var view = new View(); + view.BackgroundColor = Color.Wheat; + view.Size = new Size(mWindow.Size.Width, mWindow.Size.Height); + view.PivotPoint = PivotPoint.Center; + view.ParentOrigin = ParentOrigin.TopLeft; + view.Position2D = new Position2D(0, 0); + mWindow.Add(view); + // Attach emitter to view + mEmitter = new ParticleEmitter(view) + { + ParticleCount = 10000, + EmissionRate = 500, + InitialParticleCount = 0, + RendererBlendingMode = ParticleBlendingMode.Screen + }; + + mSource = new ParticleSource(new Vector2(50, 50)); + mModifier = new ParticleModifier(mSource.Callback); + + mEmitter.SetSource(mSource); + mEmitter.AddModifier(mModifier); + + // Load texture + mEmitter.TextureResourceUrl = IMAGE_DIR + "/blue-part2.png"; + mEmitter.Start(); + } + + protected override void OnCreate() + { + // Up call to the Base class first + base.OnCreate(); + Activate(); + } + + /// + /// The main entry point for the application. + /// + [STAThread] // Forces app to use one thread to access NUI + static void Main(string[] args) + { + ParticleSystemSample example = new ParticleSystemSample(); + example.Run(args); + } + } +} diff --git a/test/Tizen.NUI.ParticleSystem.Sample/Tizen.NUI.ParticleSystem.Sample.csproj b/test/Tizen.NUI.ParticleSystem.Sample/Tizen.NUI.ParticleSystem.Sample.csproj new file mode 100644 index 00000000000..8dcd2b34a2c --- /dev/null +++ b/test/Tizen.NUI.ParticleSystem.Sample/Tizen.NUI.ParticleSystem.Sample.csproj @@ -0,0 +1,24 @@ + + + + Exe + net6.0 + + + + true + + + + + + + + + PreserveNewest + + + + True + + diff --git a/test/Tizen.NUI.ParticleSystem.Sample/res/image/blue-part2.png b/test/Tizen.NUI.ParticleSystem.Sample/res/image/blue-part2.png new file mode 100644 index 00000000000..3f41b4379a0 Binary files /dev/null and b/test/Tizen.NUI.ParticleSystem.Sample/res/image/blue-part2.png differ diff --git a/test/Tizen.NUI.Physics2D.Sample/Physics2DSample.cs b/test/Tizen.NUI.Physics2D.Sample/Physics2DSample.cs new file mode 100644 index 00000000000..93b6b70aa2a --- /dev/null +++ b/test/Tizen.NUI.Physics2D.Sample/Physics2DSample.cs @@ -0,0 +1,138 @@ +/* +* Copyright (c) 2023 Samsung Electronics Co., Ltd. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +using System; +using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; +using System.Text; +using System.Linq; +using Tizen.NUI; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Constants; +using Tizen.NUI.Physics2D; +using Tizen.NUI.Physics2D.Chipmunk; + + + +// Tests the basic functionality of the Chipmunk2D physics engine without the need of any rendering. +// It sets up a 2D physics simulation with a dynamic circle dropping to the top of two static segments +// representing the ground and bouncing back. The simulation is run for a fixed number of time steps, +// and the position of the circle body is printed at each step to verify the correctness of the physics +// simulation. + +class Physics2DSample : NUIApplication +{ + static string IMAGE_DIR = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "images/"; + + Window mWindow; + Vector2 mWindowSize; + Matrix mTransform; + PhysicsAdaptor mPhysicsAdaptor; + + protected override void OnCreate() + { + // Up call to the Base class first + base.OnCreate(); + + mWindow = Window.Instance; + mWindow.BackgroundColor = Color.DarkOrchid; + mWindowSize = mWindow.WindowSize; + + mTransform = new Matrix(); + mTransform.SetIdentityAndScale(new Vector3(1.0f, -1.0f, 1.0f)); + mTransform.SetTranslation(new Vector3(mWindowSize.Width * 0.5f, mWindowSize.Height * 0.5f, 0.0f)); + + // Create a space for physics simulation + mPhysicsAdaptor = new PhysicsAdaptor(mTransform, mWindowSize); + mWindow.AddLayer(mPhysicsAdaptor.GetRootLayer()); + + using (var accessor = mPhysicsAdaptor.GetAccessor()) + { + var space = accessor.GetNative(); + + // Set up gravity along the Y-axis (negative value for downward) + var gravity = new Vect(0, -100); + space.Gravity = gravity; + + // Create two static bodies (static bodies do not move) with shapes (segments) to form the ground + var groundBody1 = new Body(BodyType.Static); + var groundBody2 = new Body(BodyType.Static); + + // Add the body to the space + space.AddBody(groundBody1); + space.AddBody(groundBody2); + + var groundStart = new Vect(-1000.0f, 0.0f); // Start point of the ground + var groundEnd = new Vect(1000.0f, 0.0f); // End point of the ground + + var groundShape1 = new Segment(groundBody1, groundStart, groundEnd, 0); + var groundShape2 = new Segment(groundBody2, groundStart, groundEnd, 0); + + groundShape1.CollisionType = 0; + groundShape2.CollisionType = 1; + + groundShape1.Elasticity = 0.85f; + groundShape2.Elasticity = 0.85f; + + // Add the shapes to the space + space.AddShape(groundShape1); + space.AddShape(groundShape2); + + // Create a dynamic body with a circle shape + var radius = 13.0; + var mass = 1.0; + var moment = Circle.MomentForCircle(mass, 0, radius, Vect.Zero); + + // Set initial position for the circle + var circleBody = new Body(mass, moment); + circleBody.Position = new Vect(0, 50); + + // Add the body to the space + space.AddBody(circleBody); + + // Create a circle shape + var circleShape = new Circle(circleBody, radius, Vect.Zero); + circleShape.CollisionType = 2; + circleShape.Elasticity = 0.85f; + + // Add the circle shape to the space + space.AddShape(circleShape); + + View ball; + ball = new ImageView(IMAGE_DIR + "blocks-ball.png") + { + Name = "ball", + Size = new Size(26, 26) + }; + + var physicsBall = mPhysicsAdaptor.AddViewToBody(ball, circleBody); + physicsBall.AsyncSetPhysicsPosition(new Vector3(0.0f, 100.0f, 0.0f)); + // Auto dispose of accessor + } + mPhysicsAdaptor.CreateSyncPoint(); + } + + /// + /// The main entry point for the application. + /// + [STAThread] // Forces app to use one thread to access NUI + static void Main(string[] args) + { + Physics2DSample example = new Physics2DSample(); + example.Run(args); + } +} diff --git a/test/Tizen.NUI.Physics2D.Sample/Tizen.NUI.Physics2D.Sample.csproj b/test/Tizen.NUI.Physics2D.Sample/Tizen.NUI.Physics2D.Sample.csproj new file mode 100644 index 00000000000..b3cedf09f76 --- /dev/null +++ b/test/Tizen.NUI.Physics2D.Sample/Tizen.NUI.Physics2D.Sample.csproj @@ -0,0 +1,22 @@ + + + net6.0 + Exe + Physics2DSample + + + portable + + + None + + + + + + + + + True + + diff --git a/test/Tizen.NUI.Physics2D.Sample/res/images/blocks-ball.png b/test/Tizen.NUI.Physics2D.Sample/res/images/blocks-ball.png new file mode 100644 index 00000000000..81e97d63287 Binary files /dev/null and b/test/Tizen.NUI.Physics2D.Sample/res/images/blocks-ball.png differ diff --git a/test/Tizen.NUI.Physics2D.Sample/tizen-manifest.xml b/test/Tizen.NUI.Physics2D.Sample/tizen-manifest.xml new file mode 100644 index 00000000000..ce556b8aeb3 --- /dev/null +++ b/test/Tizen.NUI.Physics2D.Sample/tizen-manifest.xml @@ -0,0 +1,13 @@ + + + + + + NUI.png + + + + + + + diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/FrameUpdateCallbackTest.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/FrameUpdateCallbackTest.cs index fe02d9ae05b..80751c103dc 100644 --- a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/FrameUpdateCallbackTest.cs +++ b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/FrameUpdateCallbackTest.cs @@ -540,7 +540,8 @@ private void SetFrameUpdateCallback(float position) // Add frame callback on window. // OnUpdate callback of frameUpdateCallback will be called before every render frame. - window.AddFrameUpdateCallback(frameUpdateCallback); + // We can set root view what given frameUpdateCallback used + window.AddFrameUpdateCallback(frameUpdateCallback, controlView); // compute limit position the container could go. leftDirectionLimit = (float)window.Size.Width - (totalSize + (float)(INITIAL_POSITION)); diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/TextFitChangedSample.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/TextFitChangedSample.cs index dc6d731488b..a2116aff02e 100755 --- a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/TextFitChangedSample.cs +++ b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/TextFitChangedSample.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using Tizen.NUI; using Tizen.NUI.BaseComponents; using Tizen.NUI.Components; @@ -8,10 +9,13 @@ namespace Tizen.NUI.Samples public class TextFitChangedSample : IExample { private TextLabel label; + private TextLabel labelFitArray; public void Activate() { Window window = NUIApplication.GetDefaultWindow(); + + // TextFit var fit = new TextFit(); fit.Enable = true; fit.MinSize = 5.0f; @@ -34,6 +38,39 @@ public void Activate() TextFit textfit = label.GetTextFit(); Tizen.Log.Error("NUI", $"FontSize : {textfit.FontSize}\n"); }; + + // TextFitArray + labelFitArray = new TextLabel() + { + Text = "ABCDE", + Size = new Size(300, 100), + PointSize = 10, + Position = new Position(100, 250), + BackgroundColor = Color.Yellow, + }; + window.Add(labelFitArray); + + var textFitArray = new Tizen.NUI.Text.TextFitArray(); + textFitArray.Enable = true; + textFitArray.OptionList = new List() + { + new Tizen.NUI.Text.TextFitArrayOption(5, 10), + new Tizen.NUI.Text.TextFitArrayOption(10, 15), + new Tizen.NUI.Text.TextFitArrayOption(15, 15), + new Tizen.NUI.Text.TextFitArrayOption(20, 25), + new Tizen.NUI.Text.TextFitArrayOption(50, 70), + new Tizen.NUI.Text.TextFitArrayOption(60, 70), + new Tizen.NUI.Text.TextFitArrayOption(70, 70), + }; + labelFitArray.SetTextFitArray(textFitArray); + + var getFitArray = labelFitArray.GetTextFitArray(); + + Tizen.Log.Error("NUI", $"GetTextFitArray:enable:[{getFitArray.Enable}] \n"); + for (int i = 0 ; i < getFitArray.OptionList.Count ; i ++) + { + Tizen.Log.Error("NUI", $"GetTextFitArray:option:[{getFitArray.OptionList[i].PointSize}, {getFitArray.OptionList[i].MinLineSize}] \n"); + } } public void Deactivate() diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/WindowTest.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/WindowTest.cs index f3fe59be6e8..ccdb093cdd2 100644 --- a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/WindowTest.cs +++ b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/WindowTest.cs @@ -2,6 +2,7 @@ using global::System; using Tizen.NUI; using Tizen.NUI.BaseComponents; +using Tizen.NUI.Components; using Tizen.System; using System.Collections.Generic; using NUnit.Framework; @@ -20,6 +21,7 @@ public class WindowTest : IExample Timer tm; bool manualRotation; int rotationCount; + private Window subWindow = null; private const string KEY_NUM_1 = "1"; private const string KEY_NUM_2 = "2"; @@ -32,6 +34,260 @@ public class WindowTest : IExample private const string KEY_NUM_9 = "9"; private const string KEY_NUM_0 = "0"; + private static readonly string ImagePath = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "/images/Dali/CubeTransitionEffect/"; + + class CustomBorder : DefaultBorder + { + private static readonly string ResourcePath = Tizen.Applications.Application.Current.DirectoryInfo.Resource; + private static readonly string MinimalizeIcon = ResourcePath + "/images/minimalize.png"; + private static readonly string MaximalizeIcon = ResourcePath + "/images/maximalize.png"; + private static readonly string RestoreIcon = ResourcePath + "/images/smallwindow.png"; + private static readonly string CloseIcon = ResourcePath + "/images/close.png"; + private static readonly string LeftCornerIcon = ResourcePath + "/images/leftCorner.png"; + private static readonly string RightCornerIcon = ResourcePath + "/images/rightCorner.png"; + + private int width = 500; + private bool hide = false; + private View borderView; + private TextLabel title; + + private ImageView minimalizeIcon; + private ImageView maximalizeIcon; + private ImageView closeIcon; + private ImageView leftCornerIcon; + private ImageView rightCornerIcon; + + private Rectangle preWinPositonSize; + + public CustomBorder() : base() + { + BorderHeight = 50; + OverlayMode = true; + BorderLineThickness = 0; + } + + public override bool CreateTopBorderView(View topView) + { + if (topView == null) + { + return false; + } + topView.Layout = new LinearLayout() + { + LinearOrientation = LinearLayout.Orientation.Horizontal, + VerticalAlignment = VerticalAlignment.Center, + CellPadding = new Size2D(20, 20), + }; + title = new TextLabel() + { + Text = "CustomBorder", + }; + + var button = new Button() + { + Text = "AlwaysOnTop", + }; + button.Clicked += (s, e) => + { + BorderWindow.EnableFloatingMode(true); + }; + topView.Add(title); + topView.Add(button); + return true; + } + + public override bool CreateBottomBorderView(View bottomView) + { + if (bottomView == null) + { + return false; + } + bottomView.Layout = new RelativeLayout(); + + minimalizeIcon = new ImageView() + { + ResourceUrl = MinimalizeIcon, + AccessibilityHighlightable = true, + }; + + maximalizeIcon = new ImageView() + { + ResourceUrl = MaximalizeIcon, + AccessibilityHighlightable = true, + }; + + closeIcon = new ImageView() + { + ResourceUrl = CloseIcon, + AccessibilityHighlightable = true, + }; + + leftCornerIcon = new ImageView() + { + ResourceUrl = LeftCornerIcon, + AccessibilityHighlightable = true, + }; + + rightCornerIcon = new ImageView() + { + ResourceUrl = RightCornerIcon, + AccessibilityHighlightable = true, + }; + + RelativeLayout.SetRightTarget(minimalizeIcon, maximalizeIcon); + RelativeLayout.SetRightRelativeOffset(minimalizeIcon, 0.0f); + RelativeLayout.SetHorizontalAlignment(minimalizeIcon, RelativeLayout.Alignment.End); + RelativeLayout.SetRightTarget(maximalizeIcon, closeIcon); + RelativeLayout.SetRightRelativeOffset(maximalizeIcon, 0.0f); + RelativeLayout.SetHorizontalAlignment(maximalizeIcon, RelativeLayout.Alignment.End); + RelativeLayout.SetRightTarget(closeIcon, rightCornerIcon); + RelativeLayout.SetRightRelativeOffset(closeIcon, 0.0f); + RelativeLayout.SetHorizontalAlignment(closeIcon, RelativeLayout.Alignment.End); + RelativeLayout.SetRightRelativeOffset(rightCornerIcon, 1.0f); + RelativeLayout.SetHorizontalAlignment(rightCornerIcon, RelativeLayout.Alignment.End); + bottomView.Add(leftCornerIcon); + bottomView.Add(minimalizeIcon); + bottomView.Add(maximalizeIcon); + bottomView.Add(closeIcon); + bottomView.Add(rightCornerIcon); + + + minimalizeIcon.TouchEvent += OnMinimizeIconTouched; + maximalizeIcon.TouchEvent += OnMaximizeIconTouched; + closeIcon.TouchEvent += OnCloseIconTouched; + leftCornerIcon.TouchEvent += OnLeftBottomCornerIconTouched; + rightCornerIcon.TouchEvent += OnRightBottomCornerIconTouched; + + minimalizeIcon.AccessibilityActivated += (s, e) => + { + MinimizeBorderWindow(); + }; + maximalizeIcon.AccessibilityActivated += (s, e) => + { + MaximizeBorderWindow(); + }; + closeIcon.AccessibilityActivated += (s, e) => + { + CloseBorderWindow(); + }; + + minimalizeIcon.AccessibilityNameRequested += (s, e) => + { + e.Name = "Minimize"; + }; + maximalizeIcon.AccessibilityNameRequested += (s, e) => + { + e.Name = "Maximize"; + }; + closeIcon.AccessibilityNameRequested += (s, e) => + { + e.Name = "Close"; + }; + leftCornerIcon.AccessibilityNameRequested += (s, e) => + { + e.Name = "Resize"; + }; + rightCornerIcon.AccessibilityNameRequested += (s, e) => + { + e.Name = "Resize"; + }; + + minimalizeIcon.SetAccessibilityReadingInfoTypes(Tizen.NUI.BaseComponents.AccessibilityReadingInfoTypes.Name); + maximalizeIcon.SetAccessibilityReadingInfoTypes(Tizen.NUI.BaseComponents.AccessibilityReadingInfoTypes.Name); + closeIcon.SetAccessibilityReadingInfoTypes(Tizen.NUI.BaseComponents.AccessibilityReadingInfoTypes.Name); + leftCornerIcon.SetAccessibilityReadingInfoTypes(Tizen.NUI.BaseComponents.AccessibilityReadingInfoTypes.Name); + rightCornerIcon.SetAccessibilityReadingInfoTypes(Tizen.NUI.BaseComponents.AccessibilityReadingInfoTypes.Name); + + return true; + } + + public override void CreateBorderView(View borderView) + { + this.borderView = borderView; + borderView.CornerRadius = new Vector4(0.03f, 0.03f, 0.03f, 0.03f); + borderView.CornerRadiusPolicy = VisualTransformPolicyType.Relative; + borderView.BackgroundColor = new Color(1, 1, 1, 0.3f); + } + + public override void OnCreated(View borderView) + { + base.OnCreated(borderView); + UpdateIcons(); + } + + public override bool OnCloseIconTouched(object sender, View.TouchEventArgs e) + { + base.OnCloseIconTouched(sender, e); + return true; + } + + public override bool OnMinimizeIconTouched(object sender, View.TouchEventArgs e) + { + if (e.Touch.GetState(0) == PointStateType.Up) + { + if (BorderWindow.IsMaximized() == true) + { + BorderWindow.Maximize(false); + } + preWinPositonSize = BorderWindow.WindowPositionSize; + BorderWindow.WindowPositionSize = new Rectangle(preWinPositonSize.X, preWinPositonSize.Y, 500, 0); + } + return true; + } + + public override void OnRequestResize() + { + if (borderView != null) + { + borderView.BackgroundColor = new Color(0, 1, 0, 0.3f); // 보더의 배경을 변경할 수 있습니다. + } + } + + public override void OnResized(int width, int height) + { + if (borderView != null) + { + if (this.width > width && hide == false) + { + title.Hide(); + hide = true; + } + else if (this.width < width && hide == true) + { + title.Show(); + hide = false; + } + borderView.BackgroundColor = new Color(1, 1, 1, 0.3f); // 리사이즈가 끝나면 보더의 색깔은 원래대로 돌려놓습니다. + base.OnResized(width, height); + UpdateIcons(); + } + } + + private void UpdateIcons() + { + if (BorderWindow != null && borderView != null) + { + if (BorderWindow.IsMaximized() == true) + { + if (maximalizeIcon != null) + { + maximalizeIcon.ResourceUrl = RestoreIcon; + } + } + else + { + if (maximalizeIcon != null) + { + maximalizeIcon.ResourceUrl = MaximalizeIcon; + } + } + } + } + + } + + + void Initialize() { @@ -43,7 +299,7 @@ void Initialize() Information.TryGetValue("http://tizen.org/feature/screen.width", out screenWidth); Information.TryGetValue("http://tizen.org/feature/screen.height", out screenHeight); log.Fatal(tag, $"Initialize= screenWidth {screenWidth}, screenHeight {screenHeight} "); - Rectangle inputRegion = new Rectangle(0,0,screenWidth,screenHeight/2); + Rectangle inputRegion = new Rectangle(0, 0, screenWidth, screenHeight / 2); mainWin.IncludeInputRegion(inputRegion); addingInput = 0; @@ -75,24 +331,20 @@ void Initialize() manualRotation = false; rotationCount = 0; - - tm = new Timer(100); - tm.Tick += Tm_Tick; - tm.Start(); } private bool Tm_Tick(object source, Timer.TickEventArgs e) { bool rotating = mainWin.IsWindowRotating(); log.Fatal(tag, $"window is Rotating: {rotating}"); - if(rotating && manualRotation) + if (rotating && manualRotation) { rotationCount++; - if(rotationCount > 100) + if (rotationCount > 100) { - log.Fatal(tag, $"call SendRotationCompletedAcknowledgement"); - mainWin.SendRotationCompletedAcknowledgement(); - rotationCount = 0; + log.Fatal(tag, $"call SendRotationCompletedAcknowledgement"); + mainWin.SendRotationCompletedAcknowledgement(); + rotationCount = 0; } } return true; @@ -105,23 +357,23 @@ private void WinTouchEvent(object sender, Window.TouchEventArgs e) Vector2 touchpoint = e.Touch.GetScreenPosition(0); log.Fatal(tag, $"WinTouchEvent={touchpoint.X}, {touchpoint.Y}"); int xPosition = 0; - if(addingInput == 0) + if (addingInput == 0) { - if(touchpoint.Y > (screenHeight/2 - 50)) + if (touchpoint.Y > (screenHeight / 2 - 50)) { - int yPostion = screenHeight/2 + 1; - int height = screenHeight/2; + int yPostion = screenHeight / 2 + 1; + int height = screenHeight / 2; log.Fatal(tag, $"WinTouchEvent= Include {xPosition},{yPostion} {screenWidth}x{height} "); - mainWin.IncludeInputRegion(new Rectangle(xPosition,yPostion,screenWidth,height)); + mainWin.IncludeInputRegion(new Rectangle(xPosition, yPostion, screenWidth, height)); addingInput = 1; } } else { - if(touchpoint.Y > (screenHeight - 50)) + if (touchpoint.Y > (screenHeight - 50)) { - int yPostion = screenHeight/2 + 1; - int height = screenHeight/2; + int yPostion = screenHeight / 2 + 1; + int height = screenHeight / 2; log.Fatal(tag, $"WinTouchEvent= Exclude {xPosition},{yPostion} {screenWidth}x{height} "); mainWin.ExcludeInputRegion(new Rectangle(xPosition, yPostion, screenWidth, height)); addingInput = 0; @@ -143,30 +395,47 @@ public void OnKeyEvent(object sender, Window.KeyEventArgs e) //Exit(); break; - case KEY_NUM_1: - log.Fatal(tag, $"pressed Key Num 1!"); + case KEY_NUM_0: + CreateSubWindow(); break; - case KEY_NUM_2: - mainWin.Maximize(true); + case KEY_NUM_1: + log.Fatal(tag, $"SetClass test"); + mainWin.SetClass("windowTitle", "windowClass"); break; - case KEY_NUM_3: - if(mainWin.IsMaximized()) + case KEY_NUM_2: + log.Fatal(tag, $"Maximize test"); + if (mainWin.IsMaximized()) { + log.Fatal(tag, $"Unset Maximize"); mainWin.Maximize(false); } + else + { + log.Fatal(tag, $"Set Maximize"); + mainWin.Maximize(true); + } break; - case KEY_NUM_4: + + case KEY_NUM_3: + log.Fatal(tag, $"Set MaximumSize test"); mainWin.SetMaximumSize(new Size2D(700, 700)); break; - case KEY_NUM_5: + + case KEY_NUM_4: + log.Fatal(tag, $"Set MimimumSize test"); mainWin.SetMimimumSize(new Size2D(100, 100)); break; - case KEY_NUM_6: - if(manualRotation == false) + + case KEY_NUM_5: + log.Fatal(tag, $"manual rotation test"); + if (manualRotation == false) { manualRotation = true; + tm = new Timer(100); + tm.Tick += Tm_Tick; + tm.Start(); log.Fatal(tag, $"Enable manual rotation"); } else @@ -176,8 +445,32 @@ public void OnKeyEvent(object sender, Window.KeyEventArgs e) } mainWin.SetNeedsRotationCompletedAcknowledgement(manualRotation); break; + + case KEY_NUM_6: + log.Fatal(tag, $"Fullscreen Test"); + if (mainWin.GetFullScreen() == false) + { + mainWin.SetFullScreen(true); + } + else + { + mainWin.SetFullScreen(false); + } + break; + case KEY_NUM_7: - mainWin.SetMimimumSize(new Size2D(100, 100)); + log.Fatal(tag, $"Raise Test"); + mainWin.Raise(); + break; + + case KEY_NUM_8: + log.Fatal(tag, $"Lower Test"); + mainWin.Lower(); + break; + + case KEY_NUM_9: + log.Fatal(tag, $"Activate Test"); + mainWin.Activate(); break; default: @@ -187,7 +480,214 @@ public void OnKeyEvent(object sender, Window.KeyEventArgs e) } } - public void Activate() { Initialize(); } - public void Deactivate() { } + void CreateSubWindow() + { + if (subWindow == null) + { + CustomBorder customBorder = new CustomBorder(); + subWindow = new Window("subwin", customBorder, new Rectangle(60, 20, 800, 800), false); + subWindow.InterceptTouchEvent += (s, e) => + { + Tizen.Log.Error("NUI", $"subWindow.InterceptTouchEvent\n"); + if (e.Touch.GetState(0) == PointStateType.Down) + { + customBorder.OverlayBorderShow(); + } + return false; + }; + + var root = new View() + { + Layout = new LinearLayout() + { + HorizontalAlignment = HorizontalAlignment.Center, + }, + WidthResizePolicy = ResizePolicyType.FillToParent, + HeightResizePolicy = ResizePolicyType.FillToParent, + BackgroundColor = Color.Brown, + }; + + var image = new ImageView() + { + Size = new Size(300, 300), + ResourceUrl = ImagePath + "gallery-large-5.jpg", + CornerRadius = new Vector4(0.03f, 0.03f, 0, 0), + CornerRadiusPolicy = VisualTransformPolicyType.Relative, + }; + root.Add(image); + subWindow.GetDefaultLayer().Add(root); + + List list = new List(); + + list.Add(Window.WindowOrientation.Landscape); + list.Add(Window.WindowOrientation.LandscapeInverse); + list.Add(Window.WindowOrientation.NoOrientationPreference); + list.Add(Window.WindowOrientation.Portrait); + list.Add(Window.WindowOrientation.PortraitInverse); + + subWindow.SetAvailableOrientations(list); + + subWindow.Moved += OnSubWindowMoved; + subWindow.KeyEvent += OnSubWindowKeyEvent; + subWindow.MoveCompleted += OnSubWindowMoveCompleted; + subWindow.ResizeCompleted += OnSubWindowResizeCompleted; + } + else + { + subWindow.Minimize(false); + } + } + + private void OnSubWindowMoved(object sender, WindowMovedEventArgs e) + { + Position2D position = e.WindowPosition; + log.Fatal(tag, $"OnSubWindowMoved() called!, x:{position.X}, y:{position.Y}"); + } + + private void OnSubWindowMoveCompleted(object sender, WindowMoveCompletedEventArgs e) + { + Position2D position = e.WindowCompletedPosition; + log.Fatal(tag, $"OnSubWindowMoveCompleted() called!, x:{position.X}, y:{position.Y}"); + } + + private void OnSubWindowResizeCompleted(object sender, WindowResizeCompletedEventArgs e) + { + Size2D size = e.WindowCompletedSize; + log.Fatal(tag, $"OnSubWindowResizeCompleted() called!, width:{size.Width}, height:{size.Height}"); + } + + + public void OnSubWindowKeyEvent(object sender, Window.KeyEventArgs e) + { + if (e.Key.State == Key.StateType.Down) + { + log.Fatal(tag, $"key down! key={e.Key.KeyPressedName}"); + + switch (e.Key.KeyPressedName) + { + case "XF86Back": + case "Escape": + log.Fatal(tag, $"sub window dispose test!!!"); + subWindow.Dispose(); + break; + + case KEY_NUM_0: + log.Fatal(tag, $"Remove Available Orientation test"); + subWindow.RemoveAvailableOrientation(Window.WindowOrientation.Portrait); + break; + + case KEY_NUM_1: + log.Fatal(tag, $"Set/Get Orientation test"); + subWindow.SetPreferredOrientation(Window.WindowOrientation.Portrait); + Window.WindowOrientation currentPreferredOrientation = subWindow.GetPreferredOrientation(); + log.Fatal(tag, $"current Preferred Orientation: {currentPreferredOrientation}"); + Window.WindowOrientation currentOrientation = subWindow.GetCurrentOrientation(); + log.Fatal(tag, $"current Orientation: {currentOrientation}"); + break; + + case KEY_NUM_2: + log.Fatal(tag, $"Set Accept Focus test"); + subWindow.SetAcceptFocus(true); + if (subWindow.IsFocusAcceptable()) + { + log.Fatal(tag, $"focus is acceptable"); + } + else + { + log.Fatal(tag, $"focus is not acceptable"); + } + break; + + case KEY_NUM_3: + log.Fatal(tag, $"visible/show/hide test"); + if (subWindow.IsVisible()) + { + log.Fatal(tag, $"subwindow is hideing"); + subWindow.Hide(); + } + else + { + log.Fatal(tag, $"subwindow is showing"); + subWindow.Show(); + } + break; + + case KEY_NUM_4: + log.Fatal(tag, $"Get/Set, Notification Level test"); + if (subWindow.Type != WindowType.Notification) + { + log.Fatal(tag, $"Set notification window type"); + subWindow.Type = WindowType.Notification; + log.Fatal(tag, $"Set notification level with high"); + subWindow.SetNotificationLevel(NotificationLevel.High); + if (subWindow.GetNotificationLevel() == NotificationLevel.High) + { + log.Fatal(tag, $"Current notificaiton level is high"); + } + else + { + log.Fatal(tag, $"Current notificaiton level is not high"); + } + } + break; + + case KEY_NUM_5: + log.Fatal(tag, $"opaque test"); + if (subWindow.IsOpaqueState()) + { + log.Fatal(tag, $"Set opaque state with false"); + subWindow.SetOpaqueState(false); + } + else + { + log.Fatal(tag, $"Set opaque state with true"); + subWindow.SetOpaqueState(true); + } + break; + + case KEY_NUM_6: + log.Fatal(tag, $"Set/Get ScreenOffMode test"); + if (subWindow.GetScreenOffMode() == ScreenOffMode.Timout) + { + log.Fatal(tag, $"SetScreenOffMode with ScreenOffMode.Never"); + subWindow.SetScreenOffMode(ScreenOffMode.Never); + } + else + { + log.Fatal(tag, $"SetScreenOffMode with ScreenOffMode.Timout"); + subWindow.SetScreenOffMode(ScreenOffMode.Timout); + } + + break; + + case KEY_NUM_7: + log.Fatal(tag, $"Set/Get Brightness test"); + subWindow.SetBrightness(95); + int currentBrightness = subWindow.GetBrightness(); + log.Fatal(tag, $"Current Brightness: {currentBrightness}"); + break; + + case KEY_NUM_8: + log.Fatal(tag, $"Get/Set WindowPosition Test"); + subWindow.WindowPosition = new Position2D(10, 10); + log.Fatal(tag, $"subWindow x: {subWindow.WindowPosition.X}, y: {subWindow.WindowPosition.Y}"); + //log.Fatal(tag, $"WindowPosition : " + subWindow.WindowPosition); + break; + + case KEY_NUM_9: + log.Fatal(tag, $"Get/Set WindowPositionSize Test"); + Rectangle rec = new Rectangle(20, 10, 100, 200); + subWindow.WindowPositionSize = rec; + log.Fatal(tag, $"WindowPositionSize : " + subWindow.WindowPositionSize); + break; + + default: + log.Fatal(tag, $"no test!"); + break; + } + } + } + public void Activate() { Initialize(); } + public void Deactivate() { } } } diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/WindowTest1.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/WindowTest1.cs new file mode 100644 index 00000000000..6325880f4e4 --- /dev/null +++ b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/WindowTest1.cs @@ -0,0 +1,562 @@ + +using global::System; +using Tizen.NUI; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Components; +using Tizen.System; +using System.Collections.Generic; +using NUnit.Framework; + +namespace Tizen.NUI.Samples +{ + using log = Tizen.Log; + public class WindowTest1 : IExample + { + string tag = "NUITEST"; + Window mainWin; + int screenWidth; + int screenHeight; + + int addingInput; + private Window subWindow = null; + + private const string KEY_NUM_1 = "1"; + private const string KEY_NUM_2 = "2"; + private const string KEY_NUM_3 = "3"; + private const string KEY_NUM_4 = "4"; + private const string KEY_NUM_5 = "5"; + private const string KEY_NUM_6 = "6"; + private const string KEY_NUM_7 = "7"; + private const string KEY_NUM_8 = "8"; + private const string KEY_NUM_9 = "9"; + private const string KEY_NUM_0 = "0"; + + private static readonly string ImagePath = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "/images/Dali/CubeTransitionEffect/"; + + class CustomBorder : DefaultBorder + { + private static readonly string ResourcePath = Tizen.Applications.Application.Current.DirectoryInfo.Resource; + private static readonly string MinimalizeIcon = ResourcePath + "/images/minimalize.png"; + private static readonly string MaximalizeIcon = ResourcePath + "/images/maximalize.png"; + private static readonly string RestoreIcon = ResourcePath + "/images/smallwindow.png"; + private static readonly string CloseIcon = ResourcePath + "/images/close.png"; + private static readonly string LeftCornerIcon = ResourcePath + "/images/leftCorner.png"; + private static readonly string RightCornerIcon = ResourcePath + "/images/rightCorner.png"; + + private int width = 500; + private bool hide = false; + private View borderView; + private TextLabel title; + + private ImageView minimalizeIcon; + private ImageView maximalizeIcon; + private ImageView closeIcon; + private ImageView leftCornerIcon; + private ImageView rightCornerIcon; + + private Rectangle preWinPositonSize; + + public CustomBorder() : base() + { + BorderHeight = 50; + OverlayMode = true; + BorderLineThickness = 0; + } + + public override bool CreateTopBorderView(View topView) + { + if (topView == null) + { + return false; + } + topView.Layout = new LinearLayout() + { + LinearOrientation = LinearLayout.Orientation.Horizontal, + VerticalAlignment = VerticalAlignment.Center, + CellPadding = new Size2D(20, 20), + }; + title = new TextLabel() + { + Text = "CustomBorder", + }; + + var button = new Button() + { + Text = "AlwaysOnTop", + }; + button.Clicked += (s, e) => + { + BorderWindow.EnableFloatingMode(true); + }; + topView.Add(title); + topView.Add(button); + return true; + } + + public override bool CreateBottomBorderView(View bottomView) + { + if (bottomView == null) + { + return false; + } + bottomView.Layout = new RelativeLayout(); + + minimalizeIcon = new ImageView() + { + ResourceUrl = MinimalizeIcon, + AccessibilityHighlightable = true, + }; + + maximalizeIcon = new ImageView() + { + ResourceUrl = MaximalizeIcon, + AccessibilityHighlightable = true, + }; + + closeIcon = new ImageView() + { + ResourceUrl = CloseIcon, + AccessibilityHighlightable = true, + }; + + leftCornerIcon = new ImageView() + { + ResourceUrl = LeftCornerIcon, + AccessibilityHighlightable = true, + }; + + rightCornerIcon = new ImageView() + { + ResourceUrl = RightCornerIcon, + AccessibilityHighlightable = true, + }; + + RelativeLayout.SetRightTarget(minimalizeIcon, maximalizeIcon); + RelativeLayout.SetRightRelativeOffset(minimalizeIcon, 0.0f); + RelativeLayout.SetHorizontalAlignment(minimalizeIcon, RelativeLayout.Alignment.End); + RelativeLayout.SetRightTarget(maximalizeIcon, closeIcon); + RelativeLayout.SetRightRelativeOffset(maximalizeIcon, 0.0f); + RelativeLayout.SetHorizontalAlignment(maximalizeIcon, RelativeLayout.Alignment.End); + RelativeLayout.SetRightTarget(closeIcon, rightCornerIcon); + RelativeLayout.SetRightRelativeOffset(closeIcon, 0.0f); + RelativeLayout.SetHorizontalAlignment(closeIcon, RelativeLayout.Alignment.End); + RelativeLayout.SetRightRelativeOffset(rightCornerIcon, 1.0f); + RelativeLayout.SetHorizontalAlignment(rightCornerIcon, RelativeLayout.Alignment.End); + bottomView.Add(leftCornerIcon); + bottomView.Add(minimalizeIcon); + bottomView.Add(maximalizeIcon); + bottomView.Add(closeIcon); + bottomView.Add(rightCornerIcon); + + + minimalizeIcon.TouchEvent += OnMinimizeIconTouched; + maximalizeIcon.TouchEvent += OnMaximizeIconTouched; + closeIcon.TouchEvent += OnCloseIconTouched; + leftCornerIcon.TouchEvent += OnLeftBottomCornerIconTouched; + rightCornerIcon.TouchEvent += OnRightBottomCornerIconTouched; + + minimalizeIcon.AccessibilityActivated += (s, e) => + { + MinimizeBorderWindow(); + }; + maximalizeIcon.AccessibilityActivated += (s, e) => + { + MaximizeBorderWindow(); + }; + closeIcon.AccessibilityActivated += (s, e) => + { + CloseBorderWindow(); + }; + + minimalizeIcon.AccessibilityNameRequested += (s, e) => + { + e.Name = "Minimize"; + }; + maximalizeIcon.AccessibilityNameRequested += (s, e) => + { + e.Name = "Maximize"; + }; + closeIcon.AccessibilityNameRequested += (s, e) => + { + e.Name = "Close"; + }; + leftCornerIcon.AccessibilityNameRequested += (s, e) => + { + e.Name = "Resize"; + }; + rightCornerIcon.AccessibilityNameRequested += (s, e) => + { + e.Name = "Resize"; + }; + + minimalizeIcon.SetAccessibilityReadingInfoTypes(Tizen.NUI.BaseComponents.AccessibilityReadingInfoTypes.Name); + maximalizeIcon.SetAccessibilityReadingInfoTypes(Tizen.NUI.BaseComponents.AccessibilityReadingInfoTypes.Name); + closeIcon.SetAccessibilityReadingInfoTypes(Tizen.NUI.BaseComponents.AccessibilityReadingInfoTypes.Name); + leftCornerIcon.SetAccessibilityReadingInfoTypes(Tizen.NUI.BaseComponents.AccessibilityReadingInfoTypes.Name); + rightCornerIcon.SetAccessibilityReadingInfoTypes(Tizen.NUI.BaseComponents.AccessibilityReadingInfoTypes.Name); + + return true; + } + + public override void CreateBorderView(View borderView) + { + this.borderView = borderView; + borderView.CornerRadius = new Vector4(0.03f, 0.03f, 0.03f, 0.03f); + borderView.CornerRadiusPolicy = VisualTransformPolicyType.Relative; + borderView.BackgroundColor = new Color(1, 1, 1, 0.3f); + } + + public override void OnCreated(View borderView) + { + base.OnCreated(borderView); + UpdateIcons(); + } + + public override bool OnCloseIconTouched(object sender, View.TouchEventArgs e) + { + base.OnCloseIconTouched(sender, e); + return true; + } + + public override bool OnMinimizeIconTouched(object sender, View.TouchEventArgs e) + { + if (e.Touch.GetState(0) == PointStateType.Up) + { + if (BorderWindow.IsMaximized() == true) + { + BorderWindow.Maximize(false); + } + preWinPositonSize = BorderWindow.WindowPositionSize; + BorderWindow.WindowPositionSize = new Rectangle(preWinPositonSize.X, preWinPositonSize.Y, 500, 0); + } + return true; + } + + public override void OnRequestResize() + { + if (borderView != null) + { + borderView.BackgroundColor = new Color(0, 1, 0, 0.3f); // 보더의 배경을 변경할 수 있습니다. + } + } + + public override void OnResized(int width, int height) + { + if (borderView != null) + { + if (this.width > width && hide == false) + { + title.Hide(); + hide = true; + } + else if (this.width < width && hide == true) + { + title.Show(); + hide = false; + } + borderView.BackgroundColor = new Color(1, 1, 1, 0.3f); // 리사이즈가 끝나면 보더의 색깔은 원래대로 돌려놓습니다. + base.OnResized(width, height); + UpdateIcons(); + } + } + + private void UpdateIcons() + { + if (BorderWindow != null && borderView != null) + { + if (BorderWindow.IsMaximized() == true) + { + if (maximalizeIcon != null) + { + maximalizeIcon.ResourceUrl = RestoreIcon; + } + } + else + { + if (maximalizeIcon != null) + { + maximalizeIcon.ResourceUrl = MaximalizeIcon; + } + } + } + } + + } + + + void Initialize() + { + mainWin = NUIApplication.GetDefaultWindow(); + mainWin.KeyEvent += OnKeyEvent; + mainWin.TouchEvent += WinTouchEvent; + mainWin.BackgroundColor = Color.Cyan; + + Information.TryGetValue("http://tizen.org/feature/screen.width", out screenWidth); + Information.TryGetValue("http://tizen.org/feature/screen.height", out screenHeight); + log.Fatal(tag, $"Initialize= screenWidth {screenWidth}, screenHeight {screenHeight} "); + + addingInput = 0; + + TextLabel text = new TextLabel("NUI Window Test1"); + text.HorizontalAlignment = HorizontalAlignment.Center; + text.VerticalAlignment = VerticalAlignment.Center; + text.TextColor = Color.Blue; + text.PointSize = 12.0f; + text.HeightResizePolicy = ResizePolicyType.FillToParent; + text.WidthResizePolicy = ResizePolicyType.FillToParent; + mainWin.Add(text); + + List list = new List(); + + list.Add(Window.WindowOrientation.Landscape); + list.Add(Window.WindowOrientation.LandscapeInverse); + list.Add(Window.WindowOrientation.NoOrientationPreference); + list.Add(Window.WindowOrientation.Portrait); + list.Add(Window.WindowOrientation.PortraitInverse); + + mainWin.SetAvailableOrientations(list); + + Animation animation = new Animation(2000); + animation.AnimateTo(text, "Orientation", new Rotation(new Radian(new Degree(180.0f)), PositionAxis.X), 0, 500); + animation.AnimateTo(text, "Orientation", new Rotation(new Radian(new Degree(0.0f)), PositionAxis.X), 500, 1000); + animation.Looping = true; + animation.Play(); + } + + private void WinTouchEvent(object sender, Window.TouchEventArgs e) + { + if (e.Touch.GetState(0) == PointStateType.Down) + { + } + } + + public void OnKeyEvent(object sender, Window.KeyEventArgs e) + { + if (e.Key.State == Key.StateType.Down) + { + log.Fatal(tag, $"key down! key={e.Key.KeyPressedName}"); + + switch (e.Key.KeyPressedName) + { + case "XF86Back": + case "Escape": + //Exit(); + break; + + case KEY_NUM_0: + CreateSubWindow(); + break; + + case KEY_NUM_1: + log.Fatal(tag, $"GetOverlayLayer test"); + Layer layer = mainWin.GetOverlayLayer(); + break; + + case KEY_NUM_2: + log.Fatal(tag, $"Get Native ID test"); + int nativeID = mainWin.GetNativeId(); + log.Fatal(tag, $"Get Native ID {nativeID}"); + break; + + case KEY_NUM_3: + log.Fatal(tag, $"Partial update test"); + if (mainWin.PartialUpdate) + { + log.Fatal(tag, $"upset partial update"); + mainWin.PartialUpdate = false; + } + else + { + log.Fatal(tag, $"set partial update"); + mainWin.PartialUpdate = true; + } + break; + + case KEY_NUM_4: + log.Fatal(tag, $"Keep Rendering test"); + mainWin.KeepRendering(3000); + break; + + case KEY_NUM_5: + break; + + case KEY_NUM_6: + break; + + case KEY_NUM_7: + break; + + case KEY_NUM_8: + break; + + case KEY_NUM_9: + + break; + + default: + log.Fatal(tag, $"no test!"); + break; + } + } + } + + void CreateSubWindow() + { + if (subWindow == null) + { + CustomBorder customBorder = new CustomBorder(); + subWindow = new Window("subwin", customBorder, new Rectangle(60, 20, 800, 800), false); + subWindow.InterceptTouchEvent += (s, e) => + { + Tizen.Log.Error("NUI", $"subWindow.InterceptTouchEvent\n"); + if (e.Touch.GetState(0) == PointStateType.Down) + { + customBorder.OverlayBorderShow(); + } + return false; + }; + + var root = new View() + { + Layout = new LinearLayout() + { + HorizontalAlignment = HorizontalAlignment.Center, + }, + WidthResizePolicy = ResizePolicyType.FillToParent, + HeightResizePolicy = ResizePolicyType.FillToParent, + BackgroundColor = Color.Brown, + }; + + var image = new ImageView() + { + Size = new Size(300, 300), + ResourceUrl = ImagePath + "gallery-large-5.jpg", + CornerRadius = new Vector4(0.03f, 0.03f, 0, 0), + CornerRadiusPolicy = VisualTransformPolicyType.Relative, + }; + root.Add(image); + subWindow.GetDefaultLayer().Add(root); + + List list = new List(); + + list.Add(Window.WindowOrientation.Landscape); + list.Add(Window.WindowOrientation.LandscapeInverse); + list.Add(Window.WindowOrientation.NoOrientationPreference); + list.Add(Window.WindowOrientation.Portrait); + list.Add(Window.WindowOrientation.PortraitInverse); + + subWindow.SetAvailableOrientations(list); + + subWindow.Moved += OnSubWindowMoved; + subWindow.KeyEvent += OnSubWindowKeyEvent; + subWindow.MoveCompleted += OnSubWindowMoveCompleted; + subWindow.ResizeCompleted += OnSubWindowResizeCompleted; + } + else + { + subWindow.Minimize(false); + } + } + + private void OnSubWindowMoved(object sender, WindowMovedEventArgs e) + { + Position2D position = e.WindowPosition; + log.Fatal(tag, $"OnSubWindowMoved() called!, x:{position.X}, y:{position.Y}"); + } + + private void OnSubWindowMoveCompleted(object sender, WindowMoveCompletedEventArgs e) + { + Position2D position = e.WindowCompletedPosition; + log.Fatal(tag, $"OnSubWindowMoveCompleted() called!, x:{position.X}, y:{position.Y}"); + } + + private void OnSubWindowResizeCompleted(object sender, WindowResizeCompletedEventArgs e) + { + Size2D size = e.WindowCompletedSize; + log.Fatal(tag, $"OnSubWindowResizeCompleted() called!, width:{size.Width}, height:{size.Height}"); + } + + + public void OnSubWindowKeyEvent(object sender, Window.KeyEventArgs e) + { + if (e.Key.State == Key.StateType.Down) + { + log.Fatal(tag, $"key down! key={e.Key.KeyPressedName}"); + + switch (e.Key.KeyPressedName) + { + case "XF86Back": + case "Escape": + log.Fatal(tag, $"sub window dispose test!!!"); + subWindow.Dispose(); + break; + + case KEY_NUM_0: + log.Fatal(tag, $"Get/Set Size Test"); + subWindow.WindowSize = new Size2D(200, 500); + log.Fatal(tag, $"WindowSize : " + subWindow.WindowSize); + break; + + case KEY_NUM_1: + log.Fatal(tag, $"set Transparancy"); + subWindow.SetTransparency(true); + break; + + case KEY_NUM_2: + log.Fatal(tag, $"Get/Set BackgroundColor test"); + subWindow.BackgroundColor = Color.Black; + if (subWindow.BackgroundColor == Color.Black) + { + subWindow.BackgroundColor = Color.White; + } + break; + + case KEY_NUM_3: + log.Fatal(tag, $"Get/Set Parent test"); + subWindow.SetParent(mainWin); + if (subWindow.GetParent() == mainWin) + { + subWindow.Unparent(); + subWindow.SetParent(mainWin, true); + if (subWindow.GetParent() == mainWin) + { + log.Fatal(tag, $"success to test Set Parent"); + subWindow.Unparent(); + } + } + break; + + case KEY_NUM_4: + log.Fatal(tag, $"inputRegion test"); + Rectangle inputRegion = new Rectangle(0, 0, 200, 500); + subWindow.IncludeInputRegion(inputRegion); + break; + + case KEY_NUM_5: + log.Fatal(tag, $"excludeInputRegion test"); + Rectangle excludeInputRegion = new Rectangle(10, 10, 100, 200); + subWindow.ExcludeInputRegion(excludeInputRegion); + break; + + case KEY_NUM_6: + break; + + case KEY_NUM_7: + break; + + case KEY_NUM_8: + break; + + case KEY_NUM_9: + break; + + default: + log.Fatal(tag, $"no test!"); + break; + } + } + } + public void Activate() { Initialize(); } + public void Deactivate() { } + } +} diff --git a/test/Tizen.NUI.Tests/Tizen.NUI.Devel.Tests/testcase/public/Window/TSWindow.cs b/test/Tizen.NUI.Tests/Tizen.NUI.Devel.Tests/testcase/public/Window/TSWindow.cs index 0e5955f1ab3..e4e814a7518 100755 --- a/test/Tizen.NUI.Tests/Tizen.NUI.Devel.Tests/testcase/public/Window/TSWindow.cs +++ b/test/Tizen.NUI.Tests/Tizen.NUI.Devel.Tests/testcase/public/Window/TSWindow.cs @@ -1625,5 +1625,29 @@ public void WindowRequestResizeToServer() tlog.Debug(tag, $"WindowRequestResizeToServer END (OK)"); } + + [Test] + [Category("P1")] + [Description("Window SetFullScreen")] + [Property("SPEC", "Tizen.NUI.Window.SetFullScreen M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + public void SetFullScreen() + { + tlog.Debug(tag, $"SetFullScreen START"); + + try + { + win.SetFullScreen(true); + Assert.IsTrue(win.GetFullScreen()); + } + catch (Exception e) + { + tlog.Debug(tag, e.Message.ToString()); + Assert.Fail("Caught Exception : Failed!"); + } + + tlog.Debug(tag, $"SetFullScreen END (OK)"); + } } } diff --git a/test/Tizen.NUI.WindowSystem.InputGenerator/Tizen.NUI.WindowSystem.InputGenerator.cs b/test/Tizen.NUI.WindowSystem.InputGenerator/Tizen.NUI.WindowSystem.InputGenerator.cs new file mode 100644 index 00000000000..e61ac3af2bb --- /dev/null +++ b/test/Tizen.NUI.WindowSystem.InputGenerator/Tizen.NUI.WindowSystem.InputGenerator.cs @@ -0,0 +1,98 @@ +/* + * Copyright(c) 2023 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +using System; +using Tizen; +using Tizen.NUI; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.WindowSystem; +using System.Collections.Generic; + +namespace Tizen.NUI.WindowSystem +{ + class Program : NUIApplication + { + protected override void OnCreate() + { + base.OnCreate(); + Initialize(); + } + + void Initialize() + { + Window win = Window.Instance; + inputGen = new InputGenerator(InputGenerator.DeviceType.All, null); + + win.WindowSize = new Size2D(500, 500); + win.KeyEvent += OnKeyEvent; + win.BackgroundColor = Color.White; + + View windowView = new View(); + windowView.Size2D = new Size2D(500, 500); + windowView.BackgroundColor = Color.White; + windowView.TouchEvent += OnTouchEvent; + win.Add(windowView); + + centerLabel = new TextLabel("InputGenerator Sample, Click to generate Return Key."); + centerLabel.HorizontalAlignment = HorizontalAlignment.Center; + centerLabel.VerticalAlignment = VerticalAlignment.Center; + centerLabel.TextColor = Color.Black; + centerLabel.PointSize = 12.0f; + centerLabel.HeightResizePolicy = ResizePolicyType.FillToParent; + centerLabel.WidthResizePolicy = ResizePolicyType.FillToParent; + windowView.Add(centerLabel); + + repeatCounter = 0; + } + + private void OnKeyEvent(object sender, Window.KeyEventArgs e) + { + if (e.Key.State == Key.StateType.Down && (e.Key.KeyPressedName == "XF86Back" || e.Key.KeyPressedName == "Escape")) + { + Exit(); + } + if (e.Key.State == Key.StateType.Down && e.Key.KeyPressedName == "Return") + { + repeatCounter++; + centerLabel.Text = "Return Key Pressed, counter: " + repeatCounter.ToString(); + } + } + + private bool OnTouchEvent(object sender, View.TouchEventArgs e) + { + if (e.Touch.GetState(0) == PointStateType.Down) + { + inputGen.GenerateKey("Return", 1); + inputGen.GenerateKey("Return", 0); + + return true; + } + + return false; + } + + static void Main(string[] args) + { + var app = new Program(); + app.Run(args); + } + + private InputGenerator inputGen; + private TextLabel centerLabel; + int repeatCounter = 0; + } +} diff --git a/test/Tizen.NUI.WindowSystem.InputGenerator/Tizen.NUI.WindowSystem.InputGenerator.csproj b/test/Tizen.NUI.WindowSystem.InputGenerator/Tizen.NUI.WindowSystem.InputGenerator.csproj new file mode 100644 index 00000000000..b0bb521cc41 --- /dev/null +++ b/test/Tizen.NUI.WindowSystem.InputGenerator/Tizen.NUI.WindowSystem.InputGenerator.csproj @@ -0,0 +1,27 @@ + + + + Exe + net6.0 + + + + portable + + + None + + + + + + + + + + + + True + + + diff --git a/test/Tizen.NUI.WindowSystem.InputGenerator/shared/res/Tizen.NUI.WindowSystem.InputGenerator.png b/test/Tizen.NUI.WindowSystem.InputGenerator/shared/res/Tizen.NUI.WindowSystem.InputGenerator.png new file mode 100644 index 00000000000..9f3cb986081 Binary files /dev/null and b/test/Tizen.NUI.WindowSystem.InputGenerator/shared/res/Tizen.NUI.WindowSystem.InputGenerator.png differ diff --git a/test/Tizen.NUI.WindowSystem.InputGenerator/tizen-manifest.xml b/test/Tizen.NUI.WindowSystem.InputGenerator/tizen-manifest.xml new file mode 100644 index 00000000000..b9b9b08bed8 --- /dev/null +++ b/test/Tizen.NUI.WindowSystem.InputGenerator/tizen-manifest.xml @@ -0,0 +1,16 @@ + + + + + + Tizen.NUI.WindowSystem.InputGenerator.png + + + diff --git a/test/Tizen.NUI.WindowSystem.InputGenerator/tizen_dotnet_project.yaml b/test/Tizen.NUI.WindowSystem.InputGenerator/tizen_dotnet_project.yaml new file mode 100644 index 00000000000..01c7a15174b --- /dev/null +++ b/test/Tizen.NUI.WindowSystem.InputGenerator/tizen_dotnet_project.yaml @@ -0,0 +1,9 @@ +# csproj file path +csproj_file: Tizen.NUI.WindowSystem.InputGenerator.csproj + +# files monitored for dirty/modified status +files: + - Tizen.NUI.WindowSystem.InputGenerator.csproj + - Tizen.NUI.WindowSystem.InputGenerator.cs + - tizen-manifest.xml + - shared/res/Tizen.NUI.WindowSystem.InputGenerator.png \ No newline at end of file