From d2fcc5547d74b9d2af926c60bc9fe30e5889cb88 Mon Sep 17 00:00:00 2001 From: Kostas Chatzikokolakis Date: Wed, 27 Jan 2021 13:34:49 +0200 Subject: [PATCH 01/23] PackedAssetLibrary: use Path.join for rootPath --- src/lime/utils/PackedAssetLibrary.hx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/lime/utils/PackedAssetLibrary.hx b/src/lime/utils/PackedAssetLibrary.hx index 01076a74b..7b5e3e772 100644 --- a/src/lime/utils/PackedAssetLibrary.hx +++ b/src/lime/utils/PackedAssetLibrary.hx @@ -241,11 +241,10 @@ import flash.media.Sound; } else { - var basePath = rootPath; - if (basePath == null) basePath = ""; - if (basePath != "") basePath += "/"; + var basePath = (rootPath == null ? "" : rootPath); + var libPath = (paths.exists(id) ? paths.get(id) : id); - var path = basePath + (paths.exists(id) ? paths.get(id) : id); + var path = Path.join([basePath, libPath]); path = __cacheBreak(path); Bytes.loadFromFile(path).onError(promise.error).onComplete(packedData_onComplete); From 7ac8d0c27e52d55745f8cf4fd5a22f17f1b0c4d1 Mon Sep 17 00:00:00 2001 From: Kostas Chatzikokolakis Date: Wed, 27 Jan 2021 13:35:56 +0200 Subject: [PATCH 02/23] ManifestResources: append "/" to rootPath if missing --- templates/haxe/ManifestResources.hx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/templates/haxe/ManifestResources.hx b/templates/haxe/ManifestResources.hx index ca5a3583b..dd38e2fd1 100644 --- a/templates/haxe/ManifestResources.hx +++ b/templates/haxe/ManifestResources.hx @@ -33,6 +33,12 @@ import sys.FileSystem; rootPath = Reflect.field (config, "rootPath"); + if(!StringTools.endsWith(rootPath, "/")) { + + rootPath += "/"; + + } + } if (rootPath == null) { From fd89a87dfb3370531944c78f65bc48114ed6a120 Mon Sep 17 00:00:00 2001 From: player-03 Date: Mon, 29 Mar 2021 05:25:00 -0400 Subject: [PATCH 03/23] Standardize formatting This file isn't entirely consistent with the rest of Lime, but it is self-consistent and I think we should keep it that way. (I fixed a few unrelated lines while I was at it. I know it makes the pull request less tidy, but I wanted to confine simple formatting changes to a single commit.) --- templates/haxe/ManifestResources.hx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/haxe/ManifestResources.hx b/templates/haxe/ManifestResources.hx index dd38e2fd1..a31b99ae1 100644 --- a/templates/haxe/ManifestResources.hx +++ b/templates/haxe/ManifestResources.hx @@ -33,7 +33,7 @@ import sys.FileSystem; rootPath = Reflect.field (config, "rootPath"); - if(!StringTools.endsWith(rootPath, "/")) { + if(!StringTools.endsWith (rootPath, "/")) { rootPath += "/"; @@ -79,9 +79,9 @@ import sys.FileSystem; Assets.registerLibrary ("::library::", library); ::else::Assets.libraryPaths["::library::"] = rootPath + "::resourceName::"; ::end::::end::::if (type == "bundle")::::if (embed):: - bundle = AssetBundle.fromBytes(#if flash Bytes.ofData(new __ASSET__::flatName::() #else new __ASSET__::flatName::() #end)); - library = AssetLibrary.fromBundle(bundle); - Assets.registerLibrary("::library::", library); + bundle = AssetBundle.fromBytes (#if flash Bytes.ofData (new __ASSET__::flatName:: () #else new __ASSET__::flatName:: () #end)); + library = AssetLibrary.fromBundle (bundle); + Assets.registerLibrary ("::library::", library); ::else::Assets.bundlePaths["::library::"] = rootPath + "::resourceName::"; ::end::::end::::end::::end:: From c845859bc0f30ecd3212991f5316b4d852fc6edb Mon Sep 17 00:00:00 2001 From: Junsred <63877982+Junsred@users.noreply.github.com> Date: Thu, 28 Apr 2022 15:40:36 +0300 Subject: [PATCH 04/23] focus back to textInput after setting clipBoard --- src/lime/_internal/backend/html5/HTML5Window.hx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lime/_internal/backend/html5/HTML5Window.hx b/src/lime/_internal/backend/html5/HTML5Window.hx index 850b13b06..29e39d602 100644 --- a/src/lime/_internal/backend/html5/HTML5Window.hx +++ b/src/lime/_internal/backend/html5/HTML5Window.hx @@ -925,6 +925,10 @@ class HTML5Window { Browser.document.execCommand("copy"); } + Timer.delay(function() + { + if (textInputEnabled) textInput.focus(); + }, 20); } public function setCursor(value:MouseCursor):MouseCursor From b3af18c3524ba5ee55a7cc648890bb4199f22554 Mon Sep 17 00:00:00 2001 From: Junsred <63877982+Junsred@users.noreply.github.com> Date: Fri, 29 Apr 2022 00:27:16 +0300 Subject: [PATCH 05/23] avoid duplicate code --- src/lime/_internal/backend/html5/HTML5Window.hx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/lime/_internal/backend/html5/HTML5Window.hx b/src/lime/_internal/backend/html5/HTML5Window.hx index 29e39d602..15cb7eb43 100644 --- a/src/lime/_internal/backend/html5/HTML5Window.hx +++ b/src/lime/_internal/backend/html5/HTML5Window.hx @@ -339,6 +339,13 @@ class HTML5Window public function focus():Void {} + public function focusTextInputWithDelay():Void { + Timer.delay(function() + { + if (textInputEnabled) textInput.focus(); + }, 20); + } + public function getCursor():MouseCursor { return cursor; @@ -457,10 +464,7 @@ class HTML5Window { if (event.relatedTarget == null || isDescendent(cast event.relatedTarget)) { - Timer.delay(function() - { - if (textInputEnabled) textInput.focus(); - }, 20); + focusTextInputWithDelay(); } } } @@ -925,10 +929,7 @@ class HTML5Window { Browser.document.execCommand("copy"); } - Timer.delay(function() - { - if (textInputEnabled) textInput.focus(); - }, 20); + focusTextInputWithDelay(); } public function setCursor(value:MouseCursor):MouseCursor From 4ce66f8d9493204065bd419dbed00069864f4960 Mon Sep 17 00:00:00 2001 From: Junsred <63877982+Junsred@users.noreply.github.com> Date: Fri, 29 Apr 2022 05:03:07 +0300 Subject: [PATCH 06/23] rename and check focus pending --- src/lime/_internal/backend/html5/HTML5Window.hx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/lime/_internal/backend/html5/HTML5Window.hx b/src/lime/_internal/backend/html5/HTML5Window.hx index 15cb7eb43..b01f0b9a9 100644 --- a/src/lime/_internal/backend/html5/HTML5Window.hx +++ b/src/lime/_internal/backend/html5/HTML5Window.hx @@ -75,6 +75,8 @@ class HTML5Window private var textInputEnabled:Bool; private var unusedTouchesPool = new List(); + private var __focusPending:Bool; + public function new(parent:Window) { this.parent = parent; @@ -339,9 +341,14 @@ class HTML5Window public function focus():Void {} - public function focusTextInputWithDelay():Void { + private function focusTextInput():Void + { + if (__focusPending) return; + __focusPending = true; + Timer.delay(function() { + __focusPending = false; if (textInputEnabled) textInput.focus(); }, 20); } @@ -464,7 +471,7 @@ class HTML5Window { if (event.relatedTarget == null || isDescendent(cast event.relatedTarget)) { - focusTextInputWithDelay(); + focusTextInput(); } } } @@ -929,7 +936,10 @@ class HTML5Window { Browser.document.execCommand("copy"); } - focusTextInputWithDelay(); + if (textInputEnabled) + { + focusTextInput(); + } } public function setCursor(value:MouseCursor):MouseCursor From 3c4ddbab17e1c3a95f3a9e0e931a0f687e601a96 Mon Sep 17 00:00:00 2001 From: arm32x Date: Wed, 4 May 2022 13:10:13 -0400 Subject: [PATCH 07/23] Fix Main.cpp template for -static -debug builds When building a Lime application in debug mode on Windows, the console subsystem is used and Windows looks for a 'main' function. However, the Main.cpp file used when linking statically always defines a 'WinMain' function regardless of whether the application is being built in debug mode. This commit adds an additional check in the Main.cpp that defines a 'main' function instead of 'WinMain' when building in debug mode. --- templates/cpp/static/Main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/cpp/static/Main.cpp b/templates/cpp/static/Main.cpp index dc71655b3..290d63baa 100644 --- a/templates/cpp/static/Main.cpp +++ b/templates/cpp/static/Main.cpp @@ -1,6 +1,6 @@ #include -#ifdef HX_WINDOWS +#if defined(HX_WINDOWS) && !defined(HXCPP_DEBUG) #include #endif @@ -14,7 +14,7 @@ extern "C" int lime_openal_register_prims (); extern "C" int ::nameSafe::_register_prims ();::end::::end:: -#ifdef HX_WINDOWS +#if defined(HX_WINDOWS) && !defined(HXCPP_DEBUG) int __stdcall WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { #else extern "C" int main(int argc, char *argv[]) { @@ -40,4 +40,4 @@ extern "C" int main(int argc, char *argv[]) { return 0; -} \ No newline at end of file +} From 6652a6f7ab993c7cbfd6c8de0fd094890239ec6b Mon Sep 17 00:00:00 2001 From: Joseph Cloutier Date: Mon, 6 Jun 2022 23:00:01 -0400 Subject: [PATCH 08/23] Simplify switch statement. `cast` can handle `null`; no need for a ternary operator. --- src/lime/utils/AssetLibrary.hx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/lime/utils/AssetLibrary.hx b/src/lime/utils/AssetLibrary.hx index 263081c45..aaa48370a 100644 --- a/src/lime/utils/AssetLibrary.hx +++ b/src/lime/utils/AssetLibrary.hx @@ -334,9 +334,7 @@ class AssetLibrary return true; } - var requestedType = type != null ? cast(type, AssetType) : null; - - return switch (requestedType) + return switch (cast(type, AssetType)) { case IMAGE: cachedImages.exists(id); From c13f02ef9c50ab0a1b15ae7d34de87da593f88fe Mon Sep 17 00:00:00 2001 From: Joseph Cloutier Date: Mon, 6 Jun 2022 23:07:03 -0400 Subject: [PATCH 09/23] Check all asset types if `type == null`. According to OpenFL's documentation, `type` is "The asset type to match, or null to match any type." --- src/lime/utils/AssetLibrary.hx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lime/utils/AssetLibrary.hx b/src/lime/utils/AssetLibrary.hx index aaa48370a..673b0d476 100644 --- a/src/lime/utils/AssetLibrary.hx +++ b/src/lime/utils/AssetLibrary.hx @@ -336,6 +336,10 @@ class AssetLibrary return switch (cast(type, AssetType)) { + case null: + cachedBytes.exists(id) || cachedText.exists(id) || cachedImages.exists(id) + || cachedAudioBuffers.exists(id) || cachedFonts.exists(id); + case IMAGE: cachedImages.exists(id); @@ -345,7 +349,8 @@ class AssetLibrary case FONT: cachedFonts.exists(id); - default: cachedBytes.exists(id) || cachedText.exists(id); + default: + cachedBytes.exists(id) || cachedText.exists(id); } #end } From f14dfc8462325e57604c4e0767b5a4d6a91776cc Mon Sep 17 00:00:00 2001 From: Joseph Cloutier Date: Tue, 7 Jun 2022 13:36:35 -0400 Subject: [PATCH 10/23] Work around unreliable clipboard on Linux. Most likely SDL_waylandvideo.c is to blame, but I don't know enough to rule out SDL_x11video.c. --- src/lime/system/Clipboard.hx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lime/system/Clipboard.hx b/src/lime/system/Clipboard.hx index cb66fc2ee..0d8013c55 100644 --- a/src/lime/system/Clipboard.hx +++ b/src/lime/system/Clipboard.hx @@ -56,6 +56,14 @@ class Clipboard #if (flash || js || html5) __update(); + #elseif linux + // Hack: SDL won't start calling __update until set_text() + // is called once. + if (_text == null) + { + __update(); + set_text(_text); + } #end return _text; From b4110480c1a3e3897988981da774619c0ba02c41 Mon Sep 17 00:00:00 2001 From: Justin Espedal Date: Sun, 3 Jul 2022 16:56:51 +0900 Subject: [PATCH 11/23] Don't set AL.BYTE_OFFSET immediately after calling AL.sourcePlay The sourcePlay call in NativeAudioSource.play is removed, since setCurrentTime will always do that itself. Additionally, within setCurrentTime, sourcePlay was happening before setting the byte offset for non-streamed sounds. This appears to fix the problem of sounds playing the first part multiple times, described here: https://community.openfl.org/t/sounds-play-twice-on-ios/12163 --- src/lime/_internal/backend/native/NativeAudioSource.hx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/lime/_internal/backend/native/NativeAudioSource.hx b/src/lime/_internal/backend/native/NativeAudioSource.hx index ee3cc8031..c67631c29 100644 --- a/src/lime/_internal/backend/native/NativeAudioSource.hx +++ b/src/lime/_internal/backend/native/NativeAudioSource.hx @@ -187,8 +187,6 @@ class NativeAudioSource { var time = completed ? 0 : getCurrentTime(); - AL.sourcePlay(handle); - setCurrentTime(time); } } @@ -417,7 +415,7 @@ class NativeAudioSource else if (parent.buffer != null) { AL.sourceRewind(handle); - if (playing) AL.sourcePlay(handle); + // AL.sourcef (handle, AL.SEC_OFFSET, (value + parent.offset) / 1000); var secondOffset = (value + parent.offset) / 1000; @@ -430,6 +428,7 @@ class NativeAudioSource var totalOffset = Std.int(dataLength * ratio); AL.sourcei(handle, AL.BYTE_OFFSET, totalOffset); + if (playing) AL.sourcePlay(handle); } } From d5bac69ff7dd0e6b0acfa59216827f2a77ca9587 Mon Sep 17 00:00:00 2001 From: Shahar Marcus <88977041+ShaharMS@users.noreply.github.com> Date: Tue, 30 Aug 2022 10:08:45 +0300 Subject: [PATCH 12/23] Update FileDialog.hx FileDialog.browse fixed for OPEN_FILE, OPEN_DIRECTORY. I changed formatting of the null check on SAVE to match the formatting in the file. --- src/lime/ui/FileDialog.hx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/lime/ui/FileDialog.hx b/src/lime/ui/FileDialog.hx index 559cc912c..d1ac15372 100644 --- a/src/lime/ui/FileDialog.hx +++ b/src/lime/ui/FileDialog.hx @@ -112,7 +112,10 @@ class FileDialog var path = null; #if hl var bytes = NativeCFFI.lime_file_dialog_open_file(title, filter, defaultPath); - path = @:privateAccess String.fromUTF8(cast bytes); + if (bytes != null) + { + path = @:privateAccess String.fromUTF8(cast bytes); + } #else path = NativeCFFI.lime_file_dialog_open_file(title, filter, defaultPath); #end @@ -149,7 +152,10 @@ class FileDialog var path = null; #if hl var bytes = NativeCFFI.lime_file_dialog_open_directory(title, filter, defaultPath); - path = @:privateAccess String.fromUTF8(cast bytes); + if (bytes != null) + { + path = @:privateAccess String.fromUTF8(cast bytes); + } #else path = NativeCFFI.lime_file_dialog_open_directory(title, filter, defaultPath); #end @@ -164,7 +170,10 @@ class FileDialog var path = null; #if hl var bytes = NativeCFFI.lime_file_dialog_save_file(title, filter, defaultPath); - if (bytes != null) path = @:privateAccess String.fromUTF8(cast bytes); + if (bytes != null) + { + path = @:privateAccess String.fromUTF8(cast bytes); + } #else path = NativeCFFI.lime_file_dialog_save_file(title, filter, defaultPath); #end From 3b985979acdc67cf49c4a5ba9e17d95537f65f19 Mon Sep 17 00:00:00 2001 From: Josh Tynjala Date: Tue, 30 Aug 2022 13:46:16 -0700 Subject: [PATCH 13/23] release date --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5be762d9a..306b4da79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -8.0.0 (??/??/2022) +8.0.0 (08/30/2022) ------------------ * Updated HashLink to version 1.12 From f177e62edfd97ecbe5c2d900eef98c1957c3ae5b Mon Sep 17 00:00:00 2001 From: player-03 Date: Thu, 1 Sep 2022 03:36:22 -0400 Subject: [PATCH 14/23] Don't prioritize SVG icons. Instead, assume that any icon without a specified size can scale freely. This will typically still include SVGs. --- src/lime/tools/IconHelper.hx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lime/tools/IconHelper.hx b/src/lime/tools/IconHelper.hx index 1b862dd67..7db1dfdb1 100644 --- a/src/lime/tools/IconHelper.hx +++ b/src/lime/tools/IconHelper.hx @@ -298,9 +298,11 @@ class IconHelper for (icon in icons) { var iconDifference = icon.width - width + icon.height - height; - if (Path.extension(icon.path) == "svg") + + // If size is unspecified, accept it as an almost-perfect match + if (icon.width == 0 && icon.height == 0) { - iconDifference = 0; + iconDifference = 1; } if (iconDifference < 0 && !acceptSmaller) From 31918f61cf2e624cbec8ce4b0890ae1eab80bb17 Mon Sep 17 00:00:00 2001 From: Chris Speciale Date: Thu, 1 Sep 2022 09:51:49 -0400 Subject: [PATCH 15/23] NativeHTTPRequest: Fix buffer management for neko --- src/lime/_internal/backend/native/NativeHTTPRequest.hx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lime/_internal/backend/native/NativeHTTPRequest.hx b/src/lime/_internal/backend/native/NativeHTTPRequest.hx index f5e3934c9..9c79bdcd9 100644 --- a/src/lime/_internal/backend/native/NativeHTTPRequest.hx +++ b/src/lime/_internal/backend/native/NativeHTTPRequest.hx @@ -393,8 +393,9 @@ class NativeHTTPRequest } private function curl_onWrite(curl:CURL, output:Bytes):Int - { - buffer.add(output); + { + buffer.addBytes(output, 0, output.length) + return output.length; } From d4bcb31d062bd54a134e70e1591ed730ede76543 Mon Sep 17 00:00:00 2001 From: Chris Speciale Date: Thu, 1 Sep 2022 14:00:42 -0400 Subject: [PATCH 16/23] Fix typo --- src/lime/_internal/backend/native/NativeHTTPRequest.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lime/_internal/backend/native/NativeHTTPRequest.hx b/src/lime/_internal/backend/native/NativeHTTPRequest.hx index 9c79bdcd9..9f7c65186 100644 --- a/src/lime/_internal/backend/native/NativeHTTPRequest.hx +++ b/src/lime/_internal/backend/native/NativeHTTPRequest.hx @@ -394,7 +394,7 @@ class NativeHTTPRequest private function curl_onWrite(curl:CURL, output:Bytes):Int { - buffer.addBytes(output, 0, output.length) + buffer.addBytes(output, 0, output.length); return output.length; } From 4b04674ea43d63bedc032f9e32c79307532bae62 Mon Sep 17 00:00:00 2001 From: Josh Tynjala Date: Thu, 1 Sep 2022 18:15:41 -0700 Subject: [PATCH 17/23] JNI: use doc_gen instead of lime_doc_gen to allow OpenFL API docs to build --- src/lime/system/JNI.hx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lime/system/JNI.hx b/src/lime/system/JNI.hx index ad2577f71..fea483491 100644 --- a/src/lime/system/JNI.hx +++ b/src/lime/system/JNI.hx @@ -367,7 +367,7 @@ class JNIMethod ``` **/ // Haxe 3 can't parse "target.threaded" inside parentheses. -#if !lime_doc_gen +#if !doc_gen #if target.threaded @:autoBuild(lime.system.JNI.JNISafetyTools.build()) #elseif (cpp || neko) @@ -376,7 +376,7 @@ class JNIMethod #end interface JNISafety {} -#if !lime_doc_gen +#if !doc_gen class JNISafetyTools { #if target.threaded From 52bc8e40c94b2c39c0cf91dc43cfc5595db8c598 Mon Sep 17 00:00:00 2001 From: player-03 Date: Sat, 3 Sep 2022 15:41:18 -0400 Subject: [PATCH 18/23] Add explanatory comment. --- src/lime/_internal/backend/html5/HTML5Window.hx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lime/_internal/backend/html5/HTML5Window.hx b/src/lime/_internal/backend/html5/HTML5Window.hx index b01f0b9a9..37ee40767 100644 --- a/src/lime/_internal/backend/html5/HTML5Window.hx +++ b/src/lime/_internal/backend/html5/HTML5Window.hx @@ -343,6 +343,7 @@ class HTML5Window private function focusTextInput():Void { + // Avoid changing focus multiple times per frame. if (__focusPending) return; __focusPending = true; From 214b5a526a8948ea95c465dfbc7f61046a8ff4b0 Mon Sep 17 00:00:00 2001 From: Joseph Cloutier Date: Mon, 5 Sep 2022 22:25:13 -0400 Subject: [PATCH 19/23] Improve clipboard documentation. I managed to track down the relevant lines of code, and they're actually in SDL_x11clipboard.c rather than either of the files I suspected. --- src/lime/system/Clipboard.hx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/lime/system/Clipboard.hx b/src/lime/system/Clipboard.hx index 0d8013c55..6e7f71557 100644 --- a/src/lime/system/Clipboard.hx +++ b/src/lime/system/Clipboard.hx @@ -52,16 +52,20 @@ class Clipboard // Get & Set Methods private static function get_text():String { - // Native clipboard calls __update when clipboard changes + // Native clipboard (except Xorg) calls __update when clipboard changes. #if (flash || js || html5) __update(); #elseif linux - // Hack: SDL won't start calling __update until set_text() - // is called once. + // Xorg won't call __update until we call set_text at least once. + // Details: SDL_x11clipboard.c calls X11_XSetSelectionOwner, + // registering this app to receive clipboard events. if (_text == null) { __update(); + + // Call set_text while changing as little as possible. (Rich text + // formatting will unavoidably be lost.) set_text(_text); } #end From f9827cf47e84d650ebfd89e480d7fb1750ba4c95 Mon Sep 17 00:00:00 2001 From: player-03 Date: Wed, 7 Sep 2022 15:57:53 -0400 Subject: [PATCH 20/23] Standardize formatting. --- src/lime/_internal/backend/native/NativeAudioSource.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lime/_internal/backend/native/NativeAudioSource.hx b/src/lime/_internal/backend/native/NativeAudioSource.hx index c67631c29..d44f6a26a 100644 --- a/src/lime/_internal/backend/native/NativeAudioSource.hx +++ b/src/lime/_internal/backend/native/NativeAudioSource.hx @@ -415,7 +415,7 @@ class NativeAudioSource else if (parent.buffer != null) { AL.sourceRewind(handle); - + // AL.sourcef (handle, AL.SEC_OFFSET, (value + parent.offset) / 1000); var secondOffset = (value + parent.offset) / 1000; From 17e8b1c0657e1d1bbbaa03e3dabc46bdd09dfae1 Mon Sep 17 00:00:00 2001 From: ShaharMS Date: Tue, 13 Sep 2022 12:52:40 +0300 Subject: [PATCH 21/23] added clickCount to MouseEvent files --- project/include/ui/MouseEvent.h | 1 + project/src/ui/MouseEvent.cpp | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/project/include/ui/MouseEvent.h b/project/include/ui/MouseEvent.h index 72da59a18..c3f86aa9a 100644 --- a/project/include/ui/MouseEvent.h +++ b/project/include/ui/MouseEvent.h @@ -30,6 +30,7 @@ namespace lime { int windowID; double x; double y; + int clickCount; static ValuePointer* callback; static ValuePointer* eventObject; diff --git a/project/src/ui/MouseEvent.cpp b/project/src/ui/MouseEvent.cpp index 4bb5cbf67..acdca044e 100644 --- a/project/src/ui/MouseEvent.cpp +++ b/project/src/ui/MouseEvent.cpp @@ -15,6 +15,7 @@ namespace lime { static int id_windowID; static int id_x; static int id_y; + static int id_clickCount; static bool init = false; @@ -27,6 +28,7 @@ namespace lime { y = 0.0; movementX = 0.0; movementY = 0.0; + clickCount = 0; } @@ -46,6 +48,7 @@ namespace lime { id_windowID = val_id ("windowID"); id_x = val_id ("x"); id_y = val_id ("y"); + id_clickCount = val_id ("clickCount"); init = true; } @@ -55,7 +58,7 @@ namespace lime { if (event->type != MOUSE_WHEEL) { alloc_field (object, id_button, alloc_int (event->button)); - + alloc_field (object, id_clickCount, alloc_int (event->clickCount)) } alloc_field (object, id_movementX, alloc_float (event->movementX)); @@ -70,6 +73,7 @@ namespace lime { MouseEvent* eventObject = (MouseEvent*)MouseEvent::eventObject->Get (); eventObject->button = event->button; + eventObject->clickCount = event->clickCount; eventObject->movementX = event->movementX; eventObject->movementY = event->movementY; eventObject->type = event->type; From 5a18ed4f1ae8e8097bdabe074fc48b1a533e32b1 Mon Sep 17 00:00:00 2001 From: ShaharMS Date: Tue, 13 Sep 2022 13:05:25 +0300 Subject: [PATCH 22/23] implementation in SDLApplication, fix in MouseEvent.cpp --- project/src/backend/sdl/SDLApplication.cpp | 2 ++ project/src/ui/MouseEvent.cpp | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/project/src/backend/sdl/SDLApplication.cpp b/project/src/backend/sdl/SDLApplication.cpp index 07b7e81fd..7948d769d 100644 --- a/project/src/backend/sdl/SDLApplication.cpp +++ b/project/src/backend/sdl/SDLApplication.cpp @@ -622,6 +622,7 @@ namespace lime { mouseEvent.button = event->button.button - 1; mouseEvent.x = event->button.x; mouseEvent.y = event->button.y; + mouseEvent.clickCount = event->button.clicks; break; case SDL_MOUSEBUTTONUP: @@ -632,6 +633,7 @@ namespace lime { mouseEvent.button = event->button.button - 1; mouseEvent.x = event->button.x; mouseEvent.y = event->button.y; + mouseEvent.clickCount = event->button.clicks; break; case SDL_MOUSEWHEEL: diff --git a/project/src/ui/MouseEvent.cpp b/project/src/ui/MouseEvent.cpp index acdca044e..e28100d61 100644 --- a/project/src/ui/MouseEvent.cpp +++ b/project/src/ui/MouseEvent.cpp @@ -58,7 +58,11 @@ namespace lime { if (event->type != MOUSE_WHEEL) { alloc_field (object, id_button, alloc_int (event->button)); - alloc_field (object, id_clickCount, alloc_int (event->clickCount)) + } + + if (event->type != MOUSE_WHEEL && event->type != MOUSE_MOVE) { + + alloc_field (object, id_clickCount, alloc_int (event->clickCount)); } alloc_field (object, id_movementX, alloc_float (event->movementX)); From dd3117adc12d5a759d40261e1860b2c4e6e25ae0 Mon Sep 17 00:00:00 2001 From: ShaharMS Date: Tue, 13 Sep 2022 13:23:06 +0300 Subject: [PATCH 23/23] added clickCount to lime's haxe files cffi binding are uneeded because they pass dynamics, added the information for NativeApplication, Window, Application --- src/lime/_internal/backend/native/NativeApplication.hx | 9 ++++++--- src/lime/app/Application.hx | 4 ++-- src/lime/ui/Window.hx | 4 ++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/lime/_internal/backend/native/NativeApplication.hx b/src/lime/_internal/backend/native/NativeApplication.hx index af2f38d29..55bbc602a 100644 --- a/src/lime/_internal/backend/native/NativeApplication.hx +++ b/src/lime/_internal/backend/native/NativeApplication.hx @@ -1,5 +1,6 @@ package lime._internal.backend.native; +import haxe.Int64; import haxe.Timer; import lime._internal.backend.native.NativeCFFI; import lime.app.Application; @@ -335,10 +336,10 @@ class NativeApplication switch (mouseEventInfo.type) { case MOUSE_DOWN: - window.onMouseDown.dispatch(mouseEventInfo.x, mouseEventInfo.y, mouseEventInfo.button); + window.onMouseDown.dispatch(mouseEventInfo.x, mouseEventInfo.y, mouseEventInfo.button, mouseEventInfo.clickCount); case MOUSE_UP: - window.onMouseUp.dispatch(mouseEventInfo.x, mouseEventInfo.y, mouseEventInfo.button); + window.onMouseUp.dispatch(mouseEventInfo.x, mouseEventInfo.y, mouseEventInfo.button, mouseEventInfo.clickCount); case MOUSE_MOVE: window.onMouseMove.dispatch(mouseEventInfo.x, mouseEventInfo.y); @@ -779,6 +780,7 @@ class NativeApplication @:keep /*private*/ class MouseEventInfo { public var button:Int; + public var clickCount:Int; public var movementX:Float; public var movementY:Float; public var type:MouseEventType; @@ -786,7 +788,7 @@ class NativeApplication public var x:Float; public var y:Float; - public function new(type:MouseEventType = null, windowID:Int = 0, x:Float = 0, y:Float = 0, button:Int = 0, movementX:Float = 0, movementY:Float = 0) + public function new(type:MouseEventType = null, windowID:Int = 0, x:Float = 0, y:Float = 0, button:Int = 0, movementX:Float = 0, movementY:Float = 0, clickCount:Int = 0) { this.type = type; this.windowID = 0; @@ -795,6 +797,7 @@ class NativeApplication this.button = button; this.movementX = movementX; this.movementY = movementY; + this.clickCount = clickCount; } public function clone():MouseEventInfo diff --git a/src/lime/app/Application.hx b/src/lime/app/Application.hx index 0cdf4d3e7..6905d380b 100644 --- a/src/lime/app/Application.hx +++ b/src/lime/app/Application.hx @@ -260,7 +260,7 @@ class Application extends Module @param y The current y coordinate of the mouse @param button The ID of the mouse button that was pressed **/ - public function onMouseDown(x:Float, y:Float, button:MouseButton):Void {} + public function onMouseDown(x:Float, y:Float, button:MouseButton, clickCount:Int):Void {} /** Called when a mouse move event is fired on the primary window @@ -282,7 +282,7 @@ class Application extends Module @param y The current y coordinate of the mouse @param button The ID of the button that was released **/ - public function onMouseUp(x:Float, y:Float, button:MouseButton):Void {} + public function onMouseUp(x:Float, y:Float, button:MouseButton, clickCount:Int):Void {} /** Called when a mouse wheel event is fired on the primary window diff --git a/src/lime/ui/Window.hx b/src/lime/ui/Window.hx index 1cdc8dd73..c430a30f6 100644 --- a/src/lime/ui/Window.hx +++ b/src/lime/ui/Window.hx @@ -67,10 +67,10 @@ class Window public var onLeave(default, null) = new EventVoid>(); public var onMaximize(default, null) = new EventVoid>(); public var onMinimize(default, null) = new EventVoid>(); - public var onMouseDown(default, null) = new EventFloat->MouseButton->Void>(); + public var onMouseDown(default, null) = new EventFloat->MouseButton->Int->Void>(); public var onMouseMove(default, null) = new EventFloat->Void>(); public var onMouseMoveRelative(default, null) = new EventFloat->Void>(); - public var onMouseUp(default, null) = new EventFloat->Int->Void>(); + public var onMouseUp(default, null) = new EventFloat->Int->Int->Void>(); public var onMouseWheel(default, null) = new EventFloat->MouseWheelMode->Void>(); public var onMove(default, null) = new EventFloat->Void>(); public var onRender(default, null) = new EventVoid>();