Merge branch 'develop' of https://github.com/ShaharMS/lime into develop

This commit is contained in:
Shahar Marcus
2022-09-13 16:44:26 +03:00
17 changed files with 88 additions and 36 deletions

View File

@@ -1,4 +1,4 @@
8.0.0 (??/??/2022)
8.0.0 (08/30/2022)
------------------
* Updated HashLink to version 1.12

View File

@@ -30,6 +30,7 @@ namespace lime {
int windowID;
double x;
double y;
int clickCount;
static ValuePointer* callback;
static ValuePointer* eventObject;

View File

@@ -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:

View File

@@ -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,11 @@ namespace lime {
if (event->type != MOUSE_WHEEL) {
alloc_field (object, id_button, alloc_int (event->button));
}
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));
@@ -70,6 +77,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;

View File

@@ -76,6 +76,8 @@ class HTML5Window
private var textInputRect:Rectangle;
private var unusedTouchesPool = new List<Touch>();
private var __focusPending:Bool;
public function new(parent:Window)
{
this.parent = parent;
@@ -340,6 +342,19 @@ class HTML5Window
public function focus():Void {}
private function focusTextInput():Void
{
// Avoid changing focus multiple times per frame.
if (__focusPending) return;
__focusPending = true;
Timer.delay(function()
{
__focusPending = false;
if (textInputEnabled) textInput.focus();
}, 20);
}
public function getCursor():MouseCursor
{
return cursor;
@@ -462,10 +477,7 @@ class HTML5Window
{
if (event.relatedTarget == null || isDescendent(cast event.relatedTarget))
{
Timer.delay(function()
{
if (textInputEnabled) textInput.focus();
}, 20);
focusTextInput();
}
}
}
@@ -930,6 +942,10 @@ class HTML5Window
{
Browser.document.execCommand("copy");
}
if (textInputEnabled)
{
focusTextInput();
}
}
public function setCursor(value:MouseCursor):MouseCursor

View File

@@ -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

View File

@@ -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);
}
}

View File

@@ -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;
}

View File

@@ -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

View File

@@ -52,10 +52,22 @@ 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
// 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
return _text;

View File

@@ -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

View File

@@ -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)

View File

@@ -67,10 +67,10 @@ class Window
public var onLeave(default, null) = new Event<Void->Void>();
public var onMaximize(default, null) = new Event<Void->Void>();
public var onMinimize(default, null) = new Event<Void->Void>();
public var onMouseDown(default, null) = new Event<Float->Float->MouseButton->Void>();
public var onMouseDown(default, null) = new Event<Float->Float->MouseButton->Int->Void>();
public var onMouseMove(default, null) = new Event<Float->Float->Void>();
public var onMouseMoveRelative(default, null) = new Event<Float->Float->Void>();
public var onMouseUp(default, null) = new Event<Float->Float->Int->Void>();
public var onMouseUp(default, null) = new Event<Float->Float->Int->Int->Void>();
public var onMouseWheel(default, null) = new Event<Float->Float->MouseWheelMode->Void>();
public var onMove(default, null) = new Event<Float->Float->Void>();
public var onRender(default, null) = new Event<RenderContext->Void>();

View File

@@ -334,10 +334,12 @@ class AssetLibrary
return true;
}
var requestedType = type != null ? cast(type, AssetType) : null;
return switch (requestedType)
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);
@@ -347,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
}

View File

@@ -241,11 +241,10 @@ import flash.media.Sound;
}
else
{
var basePath = rootPath;
if (basePath == null) basePath = "";
if (basePath != "" && !StringTools.endsWith(basePath, "/")) basePath += "/";
var basePath = rootPath == null || rootPath == "" ? "" : Path.addTrailingSlash(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);

View File

@@ -1,6 +1,6 @@
#include <stdio.h>
#ifdef HX_WINDOWS
#if defined(HX_WINDOWS) && !defined(HXCPP_DEBUG)
#include <windows.h>
#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;
}
}

View File

@@ -44,6 +44,12 @@ import sys.FileSystem;
rootPath = Reflect.field (config, "rootPath");
if(!StringTools.endsWith (rootPath, "/")) {
rootPath += "/";
}
}
if (rootPath == null) {
@@ -84,9 +90,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::