Merge remote-tracking branch 'upstream/master'
This commit is contained in:
16
CHANGELOG.md
16
CHANGELOG.md
@@ -1,3 +1,19 @@
|
||||
2.4.0 (05/12/2015)
|
||||
------------------
|
||||
|
||||
* Added Cairo render context and bindings
|
||||
* Added support for software windows, using Cairo not OpenGL
|
||||
* Added text input/edit events
|
||||
* Added onEnter/onLeave events for Window mouse focus
|
||||
* Added Image getColorBoundsRect
|
||||
* Added build support for ANGLE
|
||||
* Removed prevent default for HTML5 arrow and space keys
|
||||
* Improved Image copyPixels with merge alpha
|
||||
* Fixed static build support
|
||||
* Fixed a case where fonts might not be embedded
|
||||
* Fixed occasional crash with OpenAL on Neko
|
||||
|
||||
|
||||
2.3.3 (04/21/2015)
|
||||
------------------
|
||||
|
||||
|
||||
@@ -25,6 +25,9 @@ THE SOFTWARE.
|
||||
|
||||
-------
|
||||
|
||||
This product bundles cairo 1.14.2, which is available under an
|
||||
"MPL 1.1" license. For details, see [project/lib/cairo/](project/lib).
|
||||
|
||||
This product bundles libcurl 7.37.1, which is available under an
|
||||
"MIT/X derivate" license. For details, see [project/lib/curl/](project/lib).
|
||||
|
||||
@@ -47,6 +50,9 @@ an OpenAL-Soft derivative for Android under [project/lib/openal-android/](projec
|
||||
_OpenAL-Soft is only included in dynamically-linked builds, it is excluded
|
||||
from Lime static builds in order to preserve Lime's permissive nature._
|
||||
|
||||
This product bundles pixman 0.32.6, which is available under an
|
||||
"MIT" license. For details, see [project/lib/pixman/](project/lib).
|
||||
|
||||
This product bundles libpng 1.6.12, which is available under a
|
||||
"zlib" (BSD-style) license. For details, see [project/lib/png/](project/lib).
|
||||
|
||||
|
||||
@@ -36,6 +36,40 @@ enum StackItem {
|
||||
Get informations about the call stack.
|
||||
**/
|
||||
class CallStack {
|
||||
#if js
|
||||
static var lastException:js.Error;
|
||||
|
||||
static function getStack(e:js.Error):Array<StackItem> {
|
||||
if (e == null) return [];
|
||||
// https://code.google.com/p/v8/wiki/JavaScriptStackTraceApi
|
||||
var oldValue = (untyped Error).prepareStackTrace;
|
||||
(untyped Error).prepareStackTrace = function (error, callsites :Array<Dynamic>) {
|
||||
var stack = [];
|
||||
for (site in callsites) {
|
||||
if (wrapCallSite != null) site = wrapCallSite(site);
|
||||
var method = null;
|
||||
var fullName :String = site.getFunctionName();
|
||||
if (fullName != null) {
|
||||
var idx = fullName.lastIndexOf(".");
|
||||
if (idx >= 0) {
|
||||
var className = fullName.substr(0, idx);
|
||||
var methodName = fullName.substr(idx+1);
|
||||
method = Method(className, methodName);
|
||||
}
|
||||
}
|
||||
stack.push(FilePos(method, site.getFileName(), site.getLineNumber()));
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
var a = makeStack(e.stack);
|
||||
(untyped Error).prepareStackTrace = oldValue;
|
||||
return a;
|
||||
}
|
||||
|
||||
// support for source-map-support module
|
||||
@:noCompletion
|
||||
public static var wrapCallSite:Dynamic->Dynamic;
|
||||
#end
|
||||
|
||||
/**
|
||||
Return the call stack elements, or an empty array if not available.
|
||||
@@ -45,45 +79,24 @@ class CallStack {
|
||||
var a = makeStack(untyped __dollar__callstack());
|
||||
a.shift(); // remove Stack.callStack()
|
||||
return a;
|
||||
#elseif flash9
|
||||
#elseif flash
|
||||
var a = makeStack( new flash.errors.Error().getStackTrace() );
|
||||
a.shift(); // remove Stack.callStack()
|
||||
return a;
|
||||
#elseif flash
|
||||
return makeStack("$s");
|
||||
#elseif php
|
||||
return makeStack("%s");
|
||||
#elseif cpp
|
||||
var s:Array<String> = untyped __global__.__hxcpp_get_call_stack(true);
|
||||
return makeStack(s);
|
||||
#elseif js
|
||||
// https://code.google.com/p/v8/wiki/JavaScriptStackTraceApi
|
||||
var oldValue = (untyped Error).prepareStackTrace;
|
||||
(untyped Error).prepareStackTrace = function (error, callsites :Array<Dynamic>) {
|
||||
var stack = [];
|
||||
for (site in callsites) {
|
||||
var method = null;
|
||||
var fullName :String = site.getFunctionName();
|
||||
if (fullName != null) {
|
||||
var idx = fullName.lastIndexOf(".");
|
||||
if (idx >= 0) {
|
||||
var className = fullName.substr(0, idx);
|
||||
var methodName = fullName.substr(idx+1);
|
||||
method = Method(className, methodName);
|
||||
}
|
||||
}
|
||||
stack.push(FilePos(method, site.getFileName(), site.getLineNumber()));
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
try {
|
||||
throw untyped __new__("Error");
|
||||
throw new js.Error();
|
||||
} catch( e : Dynamic ) {
|
||||
var a = makeStack(e.stack);
|
||||
if( a != null ) a.shift(); // remove Stack.callStack()
|
||||
(untyped Error).prepareStackTrace = oldValue;
|
||||
var a = getStack(e);
|
||||
a.shift(); // remove Stack.callStack()
|
||||
return a;
|
||||
}
|
||||
|
||||
#elseif java
|
||||
var stack = [];
|
||||
for ( el in java.lang.Thread.currentThread().getStackTrace() ) {
|
||||
@@ -129,7 +142,7 @@ class CallStack {
|
||||
return makeStack(untyped __dollar__excstack());
|
||||
#elseif as3
|
||||
return new Array();
|
||||
#elseif flash9
|
||||
#elseif flash
|
||||
var err : flash.errors.Error = untyped flash.Boot.lastError;
|
||||
if( err == null ) return new Array();
|
||||
var a = makeStack( err.getStackTrace() );
|
||||
@@ -143,8 +156,6 @@ class CallStack {
|
||||
i--;
|
||||
}
|
||||
return a;
|
||||
#elseif flash
|
||||
return makeStack("$e");
|
||||
#elseif php
|
||||
return makeStack("%e");
|
||||
#elseif cpp
|
||||
@@ -182,6 +193,8 @@ class CallStack {
|
||||
stack.push(FilePos(null, elem._1, elem._2));
|
||||
}
|
||||
return stack;
|
||||
#elseif js
|
||||
return untyped __define_feature__("haxe.CallStack.exceptionStack", getStack(lastException));
|
||||
#else
|
||||
return []; // Unsupported
|
||||
#end
|
||||
@@ -245,7 +258,7 @@ class CallStack {
|
||||
a.unshift(FilePos(null,new String(untyped x[0]),untyped x[1]));
|
||||
}
|
||||
return a;
|
||||
#elseif flash9
|
||||
#elseif flash
|
||||
var a = new Array();
|
||||
var r = ~/at ([^\/]+?)\$?(\/[^\(]+)?\(\)(\[(.*?):([0-9]+)\])?/;
|
||||
var rlambda = ~/^MethodInfo-([0-9]+)$/g;
|
||||
@@ -266,14 +279,6 @@ class CallStack {
|
||||
s = r.matchedRight();
|
||||
}
|
||||
return a;
|
||||
#elseif flash
|
||||
var a : Array<String> = untyped __eval__(s);
|
||||
var m = new Array();
|
||||
for( i in 0...a.length - if(s == "$s") 2 else 0 ) {
|
||||
var d = a[i].split("::");
|
||||
m.unshift(Method(d[0],d[1]));
|
||||
}
|
||||
return m;
|
||||
#elseif php
|
||||
if (!untyped __call__("isset", __var__("GLOBALS", s)))
|
||||
return [];
|
||||
@@ -298,10 +303,12 @@ class CallStack {
|
||||
}
|
||||
return m;
|
||||
#elseif js
|
||||
if ((untyped __js__("typeof"))(s) == "string") {
|
||||
if (s == null) {
|
||||
return [];
|
||||
} else if ((untyped __js__("typeof"))(s) == "string") {
|
||||
// Return the raw lines in browsers that don't support prepareStackTrace
|
||||
var stack : Array<String> = s.split("\n");
|
||||
if( stack[0] == "Error" ) stack.shift();
|
||||
if( stack[0] == "Error" ) stack.shift();
|
||||
var m = [];
|
||||
var rie10 = ~/^ at ([A-Za-z0-9_. ]+) \(([^)]+):([0-9]+):([0-9]+)\)$/;
|
||||
for( line in stack ) {
|
||||
@@ -312,7 +319,7 @@ class CallStack {
|
||||
var line = Std.parseInt(rie10.matched(3));
|
||||
m.push(FilePos( meth == "Anonymous function" ? LocalFunction() : meth == "Global code" ? null : Method(path.join("."),meth), file, line ));
|
||||
} else
|
||||
m.push(Module(line)); // A little weird, but better than nothing
|
||||
m.push(Module(StringTools.trim(line))); // A little weird, but better than nothing
|
||||
}
|
||||
return m;
|
||||
} else {
|
||||
|
||||
@@ -62,12 +62,9 @@ class Timer {
|
||||
The accuracy of this may be platform-dependent.
|
||||
**/
|
||||
public function new( time_ms : Int ){
|
||||
#if flash9
|
||||
#if flash
|
||||
var me = this;
|
||||
id = untyped __global__["flash.utils.setInterval"](function() { me.run(); },time_ms);
|
||||
#elseif flash
|
||||
var me = this;
|
||||
id = untyped _global["setInterval"](function() { me.run(); },time_ms);
|
||||
#elseif js
|
||||
var me = this;
|
||||
id = untyped setInterval(function() me.run(),time_ms);
|
||||
@@ -89,10 +86,8 @@ class Timer {
|
||||
#if (flash || js)
|
||||
if( id == null )
|
||||
return;
|
||||
#if flash9
|
||||
#if flash
|
||||
untyped __global__["flash.utils.clearInterval"](id);
|
||||
#elseif flash
|
||||
untyped _global["clearInterval"](id);
|
||||
#elseif js
|
||||
untyped clearInterval(id);
|
||||
#end
|
||||
|
||||
@@ -21,12 +21,18 @@
|
||||
*/
|
||||
package haxe.crypto;
|
||||
|
||||
/**
|
||||
Hash methods for Hmac calculation.
|
||||
*/
|
||||
enum HashMethod {
|
||||
MD5;
|
||||
SHA1;
|
||||
SHA256;
|
||||
}
|
||||
|
||||
/**
|
||||
Calculates a Hmac of the given Bytes using a HashMethod.
|
||||
*/
|
||||
class Hmac {
|
||||
|
||||
var method : HashMethod;
|
||||
@@ -82,4 +88,4 @@ class Hmac {
|
||||
return doHash(Ko.getBytes());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
*/
|
||||
package haxe.crypto;
|
||||
|
||||
/**
|
||||
Creates a Sha256 of a String.
|
||||
*/
|
||||
class Sha256 {
|
||||
|
||||
public static function encode( s:String ) : String {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"license": "MIT",
|
||||
"tags": [],
|
||||
"description": "A flexible lightweight layer for Haxe cross-platform developers",
|
||||
"version": "2.3.3",
|
||||
"releasenote": "AudioSource improvements, other fixes",
|
||||
"version": "2.4.0",
|
||||
"releasenote": "Added Cairo, text input and mouse focus events, other improvements",
|
||||
"contributors": [ "singmajesty" ]
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
<ndll name="std" haxelib="hxcpp" if="cpp" />
|
||||
<ndll name="regexp" haxelib="hxcpp" if="cpp" />
|
||||
<ndll name="zlib" haxelib="hxcpp" if="cpp" unless="emscripten || ios" />
|
||||
<ndll name="zlib" haxelib="hxcpp" if="cpp" unless="emscripten || ios || static_link" />
|
||||
|
||||
<ndll name="lime" if="included" />
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
|
||||
<architecture name="armv7" if="android" />
|
||||
|
||||
<haxedef name="lime-cairo" if="lime-cairo" unless="flash || html5" />
|
||||
<haxedef name="lime-cairo" unless="flash || html5" />
|
||||
<haxedef name="lime-curl" unless="lime-console || emscripten || flash || html5" />
|
||||
<haxedef name="lime-opengl" unless="lime-console || flash" />
|
||||
<haxedef name="lime-openal" unless="lime-console || static_link || flash || html5" />
|
||||
|
||||
16
js/Boot.hx
16
js/Boot.hx
@@ -24,11 +24,12 @@ package js;
|
||||
private class HaxeError extends js.Error {
|
||||
|
||||
var val:Dynamic;
|
||||
|
||||
public function new(val:Dynamic) {
|
||||
|
||||
public function new(val:Dynamic) untyped {
|
||||
super();
|
||||
this.val = untyped __define_feature__("js.Boot.HaxeError", val);
|
||||
untyped if (js.Error.captureStackTrace) js.Error.captureStackTrace(this, HaxeError);
|
||||
this.val = __define_feature__("js.Boot.HaxeError", val);
|
||||
this.message = String(val);
|
||||
if (js.Error.captureStackTrace) js.Error.captureStackTrace(this, HaxeError);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,12 +246,9 @@ class Boot {
|
||||
return __nativeClassName(o) != null;
|
||||
}
|
||||
|
||||
// resolve native JS class (with window or global):
|
||||
// resolve native JS class in the global scope:
|
||||
static function __resolveNativeClass(name:String) untyped {
|
||||
if (__js__("typeof window") != "undefined")
|
||||
return window[name];
|
||||
else
|
||||
return global[name];
|
||||
return untyped Function('return typeof $name != "undefined" ? $name : null')();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -163,6 +163,12 @@ class FlashApplication {
|
||||
|
||||
parent.window.onKeyDown.dispatch (keyCode, modifier);
|
||||
|
||||
if (parent.window.enableTextEvents) {
|
||||
|
||||
parent.window.onTextInput.dispatch (String.fromCharCode (event.charCode));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
parent.window.onKeyUp.dispatch (keyCode, modifier);
|
||||
|
||||
@@ -12,6 +12,7 @@ import lime.ui.Window;
|
||||
class FlashWindow {
|
||||
|
||||
|
||||
private var enableTextEvents:Bool;
|
||||
private var parent:Window;
|
||||
|
||||
|
||||
@@ -37,6 +38,13 @@ class FlashWindow {
|
||||
}
|
||||
|
||||
|
||||
public function getEnableTextEvents ():Bool {
|
||||
|
||||
return enableTextEvents;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function move (x:Int, y:Int):Void {
|
||||
|
||||
|
||||
@@ -51,6 +59,13 @@ class FlashWindow {
|
||||
}
|
||||
|
||||
|
||||
public function setEnableTextEvents (value:Bool):Bool {
|
||||
|
||||
return enableTextEvents = value;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function setFullscreen (value:Bool):Bool {
|
||||
|
||||
return value;
|
||||
|
||||
@@ -169,6 +169,12 @@ class HTML5Application {
|
||||
|
||||
parent.window.onKeyDown.dispatch (keyCode, modifier);
|
||||
|
||||
if (parent.window.enableTextEvents) {
|
||||
|
||||
parent.window.onTextInput.dispatch (String.fromCharCode (event.keyCode));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
parent.window.onKeyUp.dispatch (keyCode, modifier);
|
||||
|
||||
@@ -26,6 +26,7 @@ class HTML5Window {
|
||||
public var stats:Dynamic;
|
||||
#end
|
||||
|
||||
private var enableTextEvents:Bool;
|
||||
private var parent:Window;
|
||||
private var setHeight:Int;
|
||||
private var setWidth:Int;
|
||||
@@ -166,6 +167,13 @@ class HTML5Window {
|
||||
}
|
||||
|
||||
|
||||
public function getEnableTextEvents ():Bool {
|
||||
|
||||
return enableTextEvents;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function handleMouseEvent (event:MouseEvent):Void {
|
||||
|
||||
var x = 0.0;
|
||||
@@ -380,6 +388,13 @@ class HTML5Window {
|
||||
}
|
||||
|
||||
|
||||
public function setEnableTextEvents (value:Bool):Bool {
|
||||
|
||||
return enableTextEvents = value;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function setFullscreen (value:Bool):Bool {
|
||||
|
||||
return false;
|
||||
|
||||
@@ -27,6 +27,7 @@ class NativeApplication {
|
||||
private var keyEventInfo = new KeyEventInfo ();
|
||||
private var mouseEventInfo = new MouseEventInfo ();
|
||||
private var renderEventInfo = new RenderEventInfo (RENDER);
|
||||
private var textEventInfo = new TextEventInfo ();
|
||||
private var touchEventInfo = new TouchEventInfo ();
|
||||
private var updateEventInfo = new UpdateEventInfo ();
|
||||
private var windowEventInfo = new WindowEventInfo ();
|
||||
@@ -70,6 +71,7 @@ class NativeApplication {
|
||||
lime_key_event_manager_register (handleKeyEvent, keyEventInfo);
|
||||
lime_mouse_event_manager_register (handleMouseEvent, mouseEventInfo);
|
||||
lime_render_event_manager_register (handleRenderEvent, renderEventInfo);
|
||||
lime_text_event_manager_register (handleTextEvent, textEventInfo);
|
||||
lime_touch_event_manager_register (handleTouchEvent, touchEventInfo);
|
||||
lime_update_event_manager_register (handleUpdateEvent, updateEventInfo);
|
||||
lime_window_event_manager_register (handleWindowEvent, windowEventInfo);
|
||||
@@ -239,6 +241,25 @@ class NativeApplication {
|
||||
}
|
||||
|
||||
|
||||
private function handleTextEvent ():Void {
|
||||
|
||||
switch (textEventInfo.type) {
|
||||
|
||||
case TEXT_INPUT:
|
||||
|
||||
parent.window.onTextInput.dispatch (textEventInfo.text);
|
||||
|
||||
case TEXT_EDIT:
|
||||
|
||||
parent.window.onTextEdit.dispatch (textEventInfo.text, textEventInfo.start, textEventInfo.length);
|
||||
|
||||
default:
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function handleTouchEvent ():Void {
|
||||
|
||||
if (parent.window != null) {
|
||||
@@ -394,6 +415,7 @@ class NativeApplication {
|
||||
private static var lime_key_event_manager_register = System.load ("lime", "lime_key_event_manager_register", 2);
|
||||
private static var lime_mouse_event_manager_register = System.load ("lime", "lime_mouse_event_manager_register", 2);
|
||||
private static var lime_render_event_manager_register = System.load ("lime", "lime_render_event_manager_register", 2);
|
||||
private static var lime_text_event_manager_register = System.load ("lime", "lime_text_event_manager_register", 2);
|
||||
private static var lime_touch_event_manager_register = System.load ("lime", "lime_touch_event_manager_register", 2);
|
||||
private static var lime_update_event_manager_register = System.load ("lime", "lime_update_event_manager_register", 2);
|
||||
private static var lime_window_event_manager_register = System.load ("lime", "lime_window_event_manager_register", 2);
|
||||
@@ -557,6 +579,44 @@ private class RenderEventInfo {
|
||||
}
|
||||
|
||||
|
||||
private class TextEventInfo {
|
||||
|
||||
|
||||
public var id:Int;
|
||||
public var length:Int;
|
||||
public var start:Int;
|
||||
public var text:String;
|
||||
public var type:TextEventType;
|
||||
|
||||
|
||||
public function new (type:TextEventType = null, text:String = "", start:Int = 0, length:Int = 0) {
|
||||
|
||||
this.type = type;
|
||||
this.text = text;
|
||||
this.start = start;
|
||||
this.length = length;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function clone ():TextEventInfo {
|
||||
|
||||
return new TextEventInfo (type, text, start, length);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@:enum private abstract TextEventType(Int) {
|
||||
|
||||
var TEXT_INPUT = 0;
|
||||
var TEXT_EDIT = 1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private class TouchEventInfo {
|
||||
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ class NativeRenderer {
|
||||
private var useHardware:Bool;
|
||||
|
||||
#if lime_cairo
|
||||
private var cacheLock:Dynamic;
|
||||
private var cairo:Cairo;
|
||||
private var primarySurface:CairoSurface;
|
||||
#end
|
||||
@@ -68,7 +69,6 @@ class NativeRenderer {
|
||||
|
||||
if (!useHardware) {
|
||||
|
||||
lime_renderer_unlock (handle);
|
||||
#if lime_cairo
|
||||
if (cairo != null) {
|
||||
|
||||
@@ -76,6 +76,7 @@ class NativeRenderer {
|
||||
|
||||
}
|
||||
#end
|
||||
lime_renderer_unlock (handle);
|
||||
|
||||
}
|
||||
|
||||
@@ -89,17 +90,24 @@ class NativeRenderer {
|
||||
if (!useHardware) {
|
||||
|
||||
#if lime_cairo
|
||||
if (cairo != null) {
|
||||
var lock = lime_renderer_lock (handle);
|
||||
|
||||
if (cacheLock == null || cacheLock.pixels != lock.pixels || cacheLock.width != lock.width || cacheLock.height != lock.height) {
|
||||
|
||||
cairo.destroy ();
|
||||
primarySurface.destroy ();
|
||||
if (cairo != null) {
|
||||
|
||||
cairo.destroy ();
|
||||
primarySurface.destroy ();
|
||||
|
||||
}
|
||||
|
||||
primarySurface = CairoSurface.createForData (lock.pixels, CairoFormat.ARGB32, lock.width, lock.height, lock.pitch);
|
||||
cairo = new Cairo (primarySurface);
|
||||
parent.context = CAIRO (cairo);
|
||||
|
||||
}
|
||||
|
||||
var lock = lime_renderer_lock (handle);
|
||||
primarySurface = CairoSurface.createForData (lock.pixels, CairoFormat.ARGB32, lock.width, lock.height, lock.pitch);
|
||||
cairo = new Cairo (primarySurface);
|
||||
parent.context = CAIRO (cairo);
|
||||
cacheLock = lock;
|
||||
#else
|
||||
parent.context = NONE;
|
||||
#end
|
||||
|
||||
@@ -89,6 +89,19 @@ class NativeWindow {
|
||||
}
|
||||
|
||||
|
||||
public function getEnableTextEvents ():Bool {
|
||||
|
||||
if (handle != null) {
|
||||
|
||||
return lime_window_get_enable_text_events (handle);
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function move (x:Int, y:Int):Void {
|
||||
|
||||
if (handle != null) {
|
||||
@@ -111,6 +124,19 @@ class NativeWindow {
|
||||
}
|
||||
|
||||
|
||||
public function setEnableTextEvents (value:Bool):Bool {
|
||||
|
||||
if (handle != null) {
|
||||
|
||||
return lime_window_set_enable_text_events (handle, value);
|
||||
|
||||
}
|
||||
|
||||
return value;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function setFullscreen (value:Bool):Bool {
|
||||
|
||||
if (handle != null) {
|
||||
@@ -156,12 +182,14 @@ class NativeWindow {
|
||||
|
||||
private static var lime_window_close = System.load ("lime", "lime_window_close", 1);
|
||||
private static var lime_window_create = System.load ("lime", "lime_window_create", 5);
|
||||
private static var lime_window_get_enable_text_events = System.load ("lime", "lime_window_get_enable_text_events", 1);
|
||||
private static var lime_window_get_height = System.load ("lime", "lime_window_get_height", 1);
|
||||
private static var lime_window_get_width = System.load ("lime", "lime_window_get_width", 1);
|
||||
private static var lime_window_get_x = System.load ("lime", "lime_window_get_x", 1);
|
||||
private static var lime_window_get_y = System.load ("lime", "lime_window_get_y", 1);
|
||||
private static var lime_window_move = System.load ("lime", "lime_window_move", 3);
|
||||
private static var lime_window_resize = System.load ("lime", "lime_window_resize", 3);
|
||||
private static var lime_window_set_enable_text_events = System.load ("lime", "lime_window_set_enable_text_events", 2);
|
||||
private static var lime_window_set_fullscreen = System.load ("lime", "lime_window_set_fullscreen", 2);
|
||||
private static var lime_window_set_icon = System.load ("lime", "lime_window_set_icon", 2);
|
||||
private static var lime_window_set_minimized = System.load ("lime", "lime_window_set_minimized", 2);
|
||||
|
||||
@@ -113,6 +113,8 @@ class Application extends Module {
|
||||
window.onMouseMoveRelative.add (onMouseMoveRelative);
|
||||
window.onMouseUp.add (onMouseUp);
|
||||
window.onMouseWheel.add (onMouseWheel);
|
||||
window.onTextEdit.add (onTextEdit);
|
||||
window.onTextInput.add (onTextInput);
|
||||
window.onTouchStart.add (onTouchStart);
|
||||
window.onTouchMove.add (onTouchMove);
|
||||
window.onTouchEnd.add (onTouchEnd);
|
||||
@@ -329,6 +331,28 @@ class Application extends Module {
|
||||
}
|
||||
|
||||
|
||||
public override function onTextEdit (text:String, start:Int, length:Int):Void {
|
||||
|
||||
for (module in modules) {
|
||||
|
||||
module.onTextEdit (text, start, length);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public override function onTextInput (text:String):Void {
|
||||
|
||||
for (module in modules) {
|
||||
|
||||
module.onTextInput (text);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public override function onTouchEnd (x:Float, y:Float, id:Int):Void {
|
||||
|
||||
for (module in modules) {
|
||||
|
||||
@@ -133,6 +133,22 @@ interface IModule {
|
||||
public function onRenderContextRestored (context:RenderContext):Void;
|
||||
|
||||
|
||||
/**
|
||||
* Called when a text edit event is fired
|
||||
* @param text The current replacement text
|
||||
* @param start The starting index for the edit
|
||||
* @param length The length of the edit
|
||||
*/
|
||||
public function onTextEdit (text:String, start:Int, length:Int):Void;
|
||||
|
||||
|
||||
/**
|
||||
* Called when a text input event is fired
|
||||
* @param text The current input text
|
||||
*/
|
||||
public function onTextInput (text:String):Void;
|
||||
|
||||
|
||||
/**
|
||||
* Called when a touch end event is fired
|
||||
* @param x The current x coordinate of the touch point
|
||||
|
||||
@@ -108,6 +108,22 @@ class Module implements IModule {
|
||||
public function onRenderContextRestored (context:RenderContext):Void { }
|
||||
|
||||
|
||||
/**
|
||||
* Called when a text edit event is fired
|
||||
* @param text The current replacement text
|
||||
* @param start The starting index for the edit
|
||||
* @param length The length of the edit
|
||||
*/
|
||||
public function onTextEdit (text:String, start:Int, length:Int):Void { }
|
||||
|
||||
|
||||
/**
|
||||
* Called when a text input event is fired
|
||||
* @param text The current input text
|
||||
*/
|
||||
public function onTextInput (text:String):Void { }
|
||||
|
||||
|
||||
/**
|
||||
* Called when a touch end event is fired
|
||||
* @param x The current x coordinate of the touch point
|
||||
|
||||
@@ -63,6 +63,25 @@ class AudioSource {
|
||||
}
|
||||
|
||||
|
||||
public function dispose ():Void {
|
||||
|
||||
switch (AudioManager.context) {
|
||||
|
||||
case OPENAL (alc, al):
|
||||
|
||||
if (id != 0) {
|
||||
|
||||
al.deleteSource (id);
|
||||
|
||||
}
|
||||
|
||||
default:
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function init ():Void {
|
||||
|
||||
switch (AudioManager.context) {
|
||||
|
||||
@@ -62,6 +62,7 @@ class Image {
|
||||
public var buffer:ImageBuffer;
|
||||
public var data (get, set):UInt8Array;
|
||||
public var dirty:Bool;
|
||||
public var format (get, set):PixelFormat;
|
||||
public var height:Int;
|
||||
public var offsetX:Int;
|
||||
public var offsetY:Int;
|
||||
@@ -1198,6 +1199,34 @@ class Image {
|
||||
}
|
||||
|
||||
|
||||
private function get_format ():PixelFormat {
|
||||
|
||||
return buffer.format;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function set_format (value:PixelFormat):PixelFormat {
|
||||
|
||||
if (buffer.format != value) {
|
||||
|
||||
switch (type) {
|
||||
|
||||
case DATA:
|
||||
|
||||
ImageDataUtil.setFormat (this, value);
|
||||
|
||||
default:
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return buffer.format = value;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function get_powerOfTwo ():Bool {
|
||||
|
||||
return ((buffer.width != 0) && ((buffer.width & (~buffer.width + 1)) == buffer.width)) && ((buffer.height != 0) && ((buffer.height & (~buffer.height + 1)) == buffer.height));
|
||||
|
||||
@@ -2,6 +2,7 @@ package lime.graphics;
|
||||
|
||||
|
||||
import haxe.io.Bytes;
|
||||
import lime.graphics.cairo.CairoSurface;
|
||||
import lime.utils.ByteArray;
|
||||
import lime.utils.UInt8Array;
|
||||
|
||||
@@ -24,9 +25,11 @@ class ImageBuffer {
|
||||
|
||||
public var bitsPerPixel:Int;
|
||||
public var data:UInt8Array;
|
||||
public var format:PixelFormat;
|
||||
public var height:Int;
|
||||
public var premultiplied:Bool;
|
||||
public var src (get, set):Dynamic;
|
||||
public var stride (get, never):Int;
|
||||
public var transparent:Bool;
|
||||
public var width:Int;
|
||||
|
||||
@@ -38,12 +41,13 @@ class ImageBuffer {
|
||||
@:noCompletion private var __srcImageData:#if (js && html5) ImageData #else Dynamic #end;
|
||||
|
||||
|
||||
public function new (data:UInt8Array = null, width:Int = 0, height:Int = 0, bitsPerPixel:Int = 4) {
|
||||
public function new (data:UInt8Array = null, width:Int = 0, height:Int = 0, bitsPerPixel:Int = 4, format:PixelFormat = null) {
|
||||
|
||||
this.data = data;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.bitsPerPixel = bitsPerPixel;
|
||||
this.format = (format == null ? RGBA : format);
|
||||
transparent = true;
|
||||
|
||||
}
|
||||
@@ -169,4 +173,11 @@ class ImageBuffer {
|
||||
}
|
||||
|
||||
|
||||
private function get_stride ():Int {
|
||||
|
||||
return width * 4;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
package lime.graphics;
|
||||
|
||||
|
||||
enum PixelFormat {
|
||||
@:enum abstract PixelFormat(Int) from Int to Int {
|
||||
|
||||
RGBA;
|
||||
ARGB;
|
||||
public var RGBA = 0;
|
||||
public var ARGB = 1;
|
||||
public var BGRA = 2;
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package lime.graphics.cairo;
|
||||
|
||||
|
||||
import lime.math.Matrix3;
|
||||
import lime.math.Vector2;
|
||||
import lime.system.System;
|
||||
|
||||
|
||||
@@ -11,13 +12,24 @@ class Cairo {
|
||||
public static var version (get, null):Int;
|
||||
public static var versionString (get, null):String;
|
||||
|
||||
public var antialias (get, set):CairoAntialias;
|
||||
public var currentPoint (get, never):Vector2;
|
||||
public var dash (get, set):Array<Float>;
|
||||
public var dashCount (get, never):Int;
|
||||
public var fillRule (get, set):CairoFillRule;
|
||||
public var groupTarget (get, never):CairoSurface;
|
||||
public var hasCurrentPoint (get, never):Bool;
|
||||
public var lineCap (get, set):CairoLineCap;
|
||||
public var lineJoin (get, set):CairoLineJoin;
|
||||
public var lineWidth (get, set):Float;
|
||||
public var matrix (get, set):Matrix3;
|
||||
public var miterLimit (get, set):Float;
|
||||
public var operator (get, set):CairoOperator;
|
||||
public var referenceCount (get, never):Int;
|
||||
public var source (get, set):CairoPattern;
|
||||
public var target (get, null):CairoSurface;
|
||||
public var tolerance (get, set):Float;
|
||||
public var userData:Dynamic;
|
||||
|
||||
private var handle:Dynamic;
|
||||
|
||||
@@ -44,6 +56,15 @@ class Cairo {
|
||||
}
|
||||
|
||||
|
||||
public function arcNegative (xc:Float, yc:Float, radius:Float, angle1:Float, angle2:Float):Void {
|
||||
|
||||
#if lime_cairo
|
||||
lime_cairo_arc_negative (handle, xc, yc, radius, angle1, angle2);
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function clip ():Void {
|
||||
|
||||
#if lime_cairo
|
||||
@@ -53,6 +74,24 @@ class Cairo {
|
||||
}
|
||||
|
||||
|
||||
public function clipExtents (x1:Float, y1:Float, x2:Float, y2:Float):Void {
|
||||
|
||||
#if lime_cairo
|
||||
lime_cairo_clip_extents (handle, x1, y1, x2, y2);
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function clipPreserve ():Void {
|
||||
|
||||
#if lime_cairo
|
||||
lime_cairo_clip_preserve (handle);
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function closePath ():Void {
|
||||
|
||||
#if lime_cairo
|
||||
@@ -62,6 +101,24 @@ class Cairo {
|
||||
}
|
||||
|
||||
|
||||
public function copyPage ():Void {
|
||||
|
||||
#if lime_cairo
|
||||
lime_cairo_copy_page (handle);
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function curveTo (x1:Float, y1:Float, x2:Float, y2:Float, x3:Float, y3:Float):Void {
|
||||
|
||||
#if lime_cairo
|
||||
lime_cairo_curve_to (handle, x1, y1, x2, y2, x3, y3);
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function destroy ():Void {
|
||||
|
||||
#if lime_cairo
|
||||
@@ -80,6 +137,15 @@ class Cairo {
|
||||
}
|
||||
|
||||
|
||||
public function fillExtents (x1:Float, y1:Float, x2:Float, y2:Float):Void {
|
||||
|
||||
#if lime_cairo
|
||||
lime_cairo_fill_extents (x1, y1, x2, y2);
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function fillPreserve ():Void {
|
||||
|
||||
#if lime_cairo
|
||||
@@ -89,6 +155,48 @@ class Cairo {
|
||||
}
|
||||
|
||||
|
||||
public function identityMatrix ():Void {
|
||||
|
||||
#if lime_cairo
|
||||
lime_cairo_identity_matrix (handle);
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function inClip (x:Float, y:Float):Bool {
|
||||
|
||||
#if lime_cairo
|
||||
return lime_cairo_in_clip (x, y);
|
||||
#else
|
||||
return false;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function inFill (x:Float, y:Float):Bool {
|
||||
|
||||
#if lime_cairo
|
||||
return lime_cairo_in_fill (x, y);
|
||||
#else
|
||||
return false;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function inStroke (x:Float, y:Float):Bool {
|
||||
|
||||
#if lime_cairo
|
||||
return lime_cairo_in_stroke (x, y);
|
||||
#else
|
||||
return false;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function lineTo (x:Float, y:Float):Void {
|
||||
|
||||
#if lime_cairo
|
||||
@@ -116,6 +224,15 @@ class Cairo {
|
||||
}
|
||||
|
||||
|
||||
public function maskSurface (surface:CairoSurface, x:Float, y:Float):Void {
|
||||
|
||||
#if lime_cairo
|
||||
lime_cairo_mask_surface (surface, x, y);
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function newPath ():Void {
|
||||
|
||||
#if lime_cairo
|
||||
@@ -190,6 +307,42 @@ class Cairo {
|
||||
}
|
||||
|
||||
|
||||
public function reference ():Void {
|
||||
|
||||
#if lime_cairo
|
||||
lime_cairo_reference (handle);
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function relCurveTo (dx1:Float, dy1:Float, dx2:Float, dy2:Float, dx3:Float, dy3:Float):Void {
|
||||
|
||||
#if lime_cairo
|
||||
lime_cairo_rel_curve_to (handle, dx1, dy1, dx2, dy2, dx3, dy3);
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function relLineTo (dx:Float, dy:Float):Void {
|
||||
|
||||
#if lime_cairo
|
||||
lime_cairo_rel_line_to (handle, dx, dy);
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function relMoveTo (dx:Float, dy:Float):Void {
|
||||
|
||||
#if lime_cairo
|
||||
lime_cairo_rel_move_to (handle, dx, dy);
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function resetClip ():Void {
|
||||
|
||||
#if lime_cairo
|
||||
@@ -244,6 +397,26 @@ class Cairo {
|
||||
}
|
||||
|
||||
|
||||
public function showPage ():Void {
|
||||
|
||||
#if lime_cairo
|
||||
lime_cairo_show_page (handle);
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function status ():CairoStatus {
|
||||
|
||||
#if lime_cairo
|
||||
return lime_cairo_status (handle);
|
||||
#else
|
||||
return cast 0;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function stroke ():Void {
|
||||
|
||||
#if lime_cairo
|
||||
@@ -253,6 +426,15 @@ class Cairo {
|
||||
}
|
||||
|
||||
|
||||
public function strokeExtents (x1:Float, y1:Float, x2:Float, y2:Float):Void {
|
||||
|
||||
#if lime_cairo
|
||||
lime_cairo_stroke_extents (handle, x1, y1, x2, y2);
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function strokePreserve ():Void {
|
||||
|
||||
#if lime_cairo
|
||||
@@ -271,6 +453,15 @@ class Cairo {
|
||||
}
|
||||
|
||||
|
||||
public function translate (x:Float, y:Float):Void {
|
||||
|
||||
#if lime_cairo
|
||||
lime_cairo_translate (handle, x, y);
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Get & Set Methods
|
||||
@@ -278,6 +469,117 @@ class Cairo {
|
||||
|
||||
|
||||
|
||||
private function get_antialias ():CairoAntialias {
|
||||
|
||||
#if lime_cairo
|
||||
return lime_cairo_get_antialias (handle);
|
||||
#end
|
||||
|
||||
return cast 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function set_antialias (value:CairoAntialias):CairoAntialias {
|
||||
|
||||
#if lime_cairo
|
||||
lime_cairo_set_antialias (handle, value);
|
||||
#end
|
||||
|
||||
return value;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function get_currentPoint ():Vector2 {
|
||||
|
||||
#if lime_cairo
|
||||
var vec = lime_cairo_get_current_point (handle);
|
||||
return new Vector2 (vec.x, vec.y);
|
||||
#end
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function get_dash ():Array<Float> {
|
||||
|
||||
#if lime_cairo
|
||||
return lime_cairo_get_dash (handle);
|
||||
#end
|
||||
|
||||
return [];
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function set_dash (value:Array<Float>):Array<Float> {
|
||||
|
||||
#if lime_cairo
|
||||
lime_cairo_set_dash (handle, value);
|
||||
#end
|
||||
|
||||
return value;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function get_dashCount ():Int {
|
||||
|
||||
#if lime_cairo
|
||||
return lime_cairo_get_dash_count (handle);
|
||||
#end
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function get_fillRule ():CairoFillRule {
|
||||
|
||||
#if lime_cairo
|
||||
return lime_cairo_get_fill_rule (handle);
|
||||
#end
|
||||
|
||||
return cast 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function set_fillRule (value:CairoFillRule):CairoFillRule {
|
||||
|
||||
#if lime_cairo
|
||||
lime_cairo_set_fill_rule (handle, value);
|
||||
#end
|
||||
|
||||
return value;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function get_groupTarget ():CairoSurface {
|
||||
|
||||
#if lime_cairo
|
||||
return lime_cairo_get_group_target (handle);
|
||||
#else
|
||||
return cast 0;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function get_hasCurrentPoint ():Bool {
|
||||
|
||||
#if lime_cairo
|
||||
return lime_cairo_has_current_point (handle);
|
||||
#end
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function get_lineCap ():CairoLineCap {
|
||||
|
||||
#if lime_cairo
|
||||
@@ -411,6 +713,17 @@ class Cairo {
|
||||
}
|
||||
|
||||
|
||||
private function get_referenceCount ():Int {
|
||||
|
||||
#if lime_cairo
|
||||
return lime_cairo_get_reference_count ();
|
||||
#else
|
||||
return 0;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function get_source ():CairoPattern {
|
||||
|
||||
#if lime_cairo
|
||||
@@ -433,6 +746,39 @@ class Cairo {
|
||||
}
|
||||
|
||||
|
||||
private function get_target ():CairoSurface {
|
||||
|
||||
#if lime_cairo
|
||||
return lime_cairo_get_target (handle);
|
||||
#else
|
||||
return cast 0;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function get_tolerance ():Float {
|
||||
|
||||
#if lime_cairo
|
||||
return lime_cairo_get_tolerance ();
|
||||
#else
|
||||
return 0;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function set_tolerance (value:Float):Float {
|
||||
|
||||
#if lime_cairo
|
||||
lime_cairo_set_tolerance (value);
|
||||
#end
|
||||
|
||||
return value;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static function get_version ():Int {
|
||||
|
||||
#if lime_cairo
|
||||
@@ -464,21 +810,42 @@ class Cairo {
|
||||
|
||||
#if lime_cairo
|
||||
private static var lime_cairo_arc = System.load ("lime", "lime_cairo_arc", -1);
|
||||
private static var lime_cairo_arc_negative = System.load ("lime", "lime_cairo_arc_negative", -1);
|
||||
private static var lime_cairo_clip = System.load ("lime", "lime_cairo_clip", 1);
|
||||
private static var lime_cairo_clip_preserve = System.load ("lime", "lime_cairo_clip_preserve", 1);
|
||||
private static var lime_cairo_clip_extents = System.load ("lime", "lime_cairo_clip_extents", 5);
|
||||
private static var lime_cairo_close_path = System.load ("lime", "lime_cairo_close_path", 1);
|
||||
private static var lime_cairo_copy_page = System.load ("lime", "lime_cairo_copy_page", 1);
|
||||
private static var lime_cairo_create = System.load ("lime", "lime_cairo_create", 1);
|
||||
private static var lime_cairo_curve_to = System.load ("lime", "lime_cairo_curve_to", -1);
|
||||
private static var lime_cairo_destroy = System.load ("lime", "lime_cairo_destroy", 1);
|
||||
private static var lime_cairo_fill = System.load ("lime", "lime_cairo_fill", 1);
|
||||
private static var lime_cairo_fill_extents = System.load ("lime", "lime_cairo_fill_extents", 5);
|
||||
private static var lime_cairo_fill_preserve = System.load ("lime", "lime_cairo_fill_preserve", 1);
|
||||
private static var lime_cairo_get_antialias = System.load ("lime", "lime_cairo_get_antialias", 1);
|
||||
private static var lime_cairo_get_current_point = System.load ("lime", "lime_cairo_get_current_point", 1);
|
||||
private static var lime_cairo_get_dash = System.load ("lime", "lime_cairo_get_dash", 1);
|
||||
private static var lime_cairo_get_dash_count = System.load ("lime", "lime_cairo_get_dash_count", 1);
|
||||
private static var lime_cairo_get_fill_rule = System.load ("lime", "lime_cairo_get_fill_rule", 1);
|
||||
private static var lime_cairo_get_group_target = System.load ("lime", "lime_cairo_get_group_target", 1);
|
||||
private static var lime_cairo_get_line_cap = System.load ("lime", "lime_cairo_get_line_cap", 1);
|
||||
private static var lime_cairo_get_line_join = System.load ("lime", "lime_cairo_get_line_join", 1);
|
||||
private static var lime_cairo_get_line_width = System.load ("lime", "lime_cairo_get_line_width", 1);
|
||||
private static var lime_cairo_get_matrix = System.load ("lime", "lime_cairo_get_matrix", 1);
|
||||
private static var lime_cairo_get_miter_limit = System.load ("lime", "lime_cairo_get_miter_limit", 1);
|
||||
private static var lime_cairo_get_operator = System.load ("lime", "lime_cairo_get_operator", 1);
|
||||
private static var lime_cairo_get_reference_count = System.load ("lime", "lime_cairo_get_reference_count", 1);
|
||||
private static var lime_cairo_get_source = System.load ("lime", "lime_cairo_get_source", 1);
|
||||
private static var lime_cairo_get_target = System.load ("lime", "lime_cairo_get_target", 1);
|
||||
private static var lime_cairo_get_tolerance = System.load ("lime", "lime_cairo_get_tolerance", 1);
|
||||
private static var lime_cairo_has_current_point = System.load ("lime", "lime_cairo_has_current_point", 1);
|
||||
private static var lime_cairo_identity_matrix = System.load ("lime", "lime_cairo_identity_matrix", 1);
|
||||
private static var lime_cairo_in_clip = System.load ("lime", "lime_cairo_in_clip", 3);
|
||||
private static var lime_cairo_in_fill = System.load ("lime", "lime_cairo_in_fill", 3);
|
||||
private static var lime_cairo_in_stroke = System.load ("lime", "lime_cairo_in_stroke", 3);
|
||||
private static var lime_cairo_line_to = System.load ("lime", "lime_cairo_line_to", 3);
|
||||
private static var lime_cairo_mask = System.load ("lime", "lime_cairo_mask", 2);
|
||||
private static var lime_cairo_mask_surface = System.load ("lime", "lime_cairo_mask_surface", 4);
|
||||
private static var lime_cairo_move_to = System.load ("lime", "lime_cairo_move_to", 3);
|
||||
private static var lime_cairo_new_path = System.load ("lime", "lime_cairo_new_path", 1);
|
||||
private static var lime_cairo_paint = System.load ("lime", "lime_cairo_paint", 1);
|
||||
@@ -488,9 +855,16 @@ class Cairo {
|
||||
private static var lime_cairo_push_group = System.load ("lime", "lime_cairo_push_group", 1);
|
||||
private static var lime_cairo_push_group_with_content = System.load ("lime", "lime_cairo_push_group_with_content", 2);
|
||||
private static var lime_cairo_rectangle = System.load ("lime", "lime_cairo_rectangle", 5);
|
||||
private static var lime_cairo_reference = System.load ("lime", "lime_cairo_reference", 1);
|
||||
private static var lime_cairo_rel_curve_to = System.load ("lime", "lime_cairo_rel_curve_to", -1);
|
||||
private static var lime_cairo_rel_line_to = System.load ("lime", "lime_cairo_rel_line_to", 3);
|
||||
private static var lime_cairo_rel_move_to = System.load ("lime", "lime_cairo_rel_move_to", 3);
|
||||
private static var lime_cairo_reset_clip = System.load ("lime", "lime_cairo_reset_clip", 1);
|
||||
private static var lime_cairo_restore = System.load ("lime", "lime_cairo_restore", 1);
|
||||
private static var lime_cairo_save = System.load ("lime", "lime_cairo_save", 1);
|
||||
private static var lime_cairo_set_antialias = System.load ("lime", "lime_cairo_set_antialias", 2);
|
||||
private static var lime_cairo_set_dash = System.load ("lime", "lime_cairo_set_dash", 2);
|
||||
private static var lime_cairo_set_fill_rule = System.load ("lime", "lime_cairo_set_fill_rule", 2);
|
||||
private static var lime_cairo_set_line_cap = System.load ("lime", "lime_cairo_set_line_cap", 2);
|
||||
private static var lime_cairo_set_line_join = System.load ("lime", "lime_cairo_set_line_join", 2);
|
||||
private static var lime_cairo_set_line_width = System.load ("lime", "lime_cairo_set_line_width", 2);
|
||||
@@ -501,9 +875,14 @@ class Cairo {
|
||||
private static var lime_cairo_set_source_rgb = System.load ("lime", "lime_cairo_set_source_rgb", 4);
|
||||
private static var lime_cairo_set_source_rgba = System.load ("lime", "lime_cairo_set_source_rgba", 5);
|
||||
private static var lime_cairo_set_source_surface = System.load ("lime", "lime_cairo_set_source_surface", 4);
|
||||
private static var lime_cairo_set_tolerance = System.load ("lime", "lime_cairo_set_tolerance", 2);
|
||||
private static var lime_cairo_show_page = System.load ("lime", "lime_cairo_show_page", 1);
|
||||
private static var lime_cairo_status = System.load ("lime", "lime_cairo_status", 1);
|
||||
private static var lime_cairo_stroke = System.load ("lime", "lime_cairo_stroke", 1);
|
||||
private static var lime_cairo_stroke_extents = System.load ("lime", "lime_cairo_stroke_extents", 5);
|
||||
private static var lime_cairo_stroke_preserve = System.load ("lime", "lime_cairo_stroke_preserve", 1);
|
||||
private static var lime_cairo_transform = System.load ("lime", "lime_cairo_transform", 2);
|
||||
private static var lime_cairo_translate = System.load ("lime", "lime_cairo_translate", 3);
|
||||
private static var lime_cairo_version = System.load ("lime", "lime_cairo_version", 0);
|
||||
private static var lime_cairo_version_string = System.load ("lime", "lime_cairo_version_string", 0);
|
||||
#end
|
||||
|
||||
14
lime/graphics/cairo/CairoAntialias.hx
Normal file
14
lime/graphics/cairo/CairoAntialias.hx
Normal file
@@ -0,0 +1,14 @@
|
||||
package lime.graphics.cairo;
|
||||
|
||||
|
||||
@:enum abstract CairoAntialias(Int) from Int to Int {
|
||||
|
||||
public var DEFAULT = 0;
|
||||
public var NONE = 1;
|
||||
public var GRAY = 2;
|
||||
public var SUBPIXEL = 3;
|
||||
public var FAST = 4;
|
||||
public var GOOD = 5;
|
||||
public var BEST = 6;
|
||||
|
||||
}
|
||||
9
lime/graphics/cairo/CairoFillRule.hx
Normal file
9
lime/graphics/cairo/CairoFillRule.hx
Normal file
@@ -0,0 +1,9 @@
|
||||
package lime.graphics.cairo;
|
||||
|
||||
|
||||
@:enum abstract CairoFillRule(Int) from Int to Int {
|
||||
|
||||
public var WINDING = 0;
|
||||
public var EVEN_ODD = 1;
|
||||
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import lime.system.System;
|
||||
abstract CairoPattern(Dynamic) {
|
||||
|
||||
|
||||
public var colorStopCount (get, never):Int;
|
||||
public var extend (get, set):CairoExtend;
|
||||
public var filter (get, set):CairoFilter;
|
||||
public var matrix (get, set):Matrix3;
|
||||
@@ -20,6 +21,24 @@ abstract CairoPattern(Dynamic) {
|
||||
}
|
||||
|
||||
|
||||
public function addColorStopRGB (offset:Float, r:Float, g:Float, b:Float):Void {
|
||||
|
||||
#if lime_cairo
|
||||
lime_cairo_pattern_add_color_stop_rgb (this, offset, r, g, b);
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function addColorStopRGBA (offset:Float, r:Float, g:Float, b:Float, a:Float):Void {
|
||||
|
||||
#if lime_cairo
|
||||
lime_cairo_pattern_add_color_stop_rgba (this, offset, r, g, b, a);
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function createForSurface (surface:CairoSurface):CairoPattern {
|
||||
|
||||
#if lime_cairo
|
||||
@@ -31,6 +50,50 @@ abstract CairoPattern(Dynamic) {
|
||||
}
|
||||
|
||||
|
||||
public static function createLinear (x0:Float, y0:Float, x1:Float, y1:Float):CairoPattern {
|
||||
|
||||
#if lime_cairo
|
||||
return lime_cairo_pattern_create_linear (x0, y0, x1, y1);
|
||||
#else
|
||||
return cast 0;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function createRadial (cx0:Float, cy0:Float, radius0:Float, cx1:Float, cy1:Float, radius1:Float):CairoPattern {
|
||||
|
||||
#if lime_cairo
|
||||
return lime_cairo_pattern_create_radial (cx0, cy0, radius0, cx1, cy1, radius1);
|
||||
#else
|
||||
return cast 0;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function createRGB (r:Float, g:Float, b:Float):CairoPattern {
|
||||
|
||||
#if lime_cairo
|
||||
return lime_cairo_pattern_create_rgb (r, g, b);
|
||||
#else
|
||||
return cast 0;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function createRGBA (r:Float, g:Float, b:Float, a:Float):CairoPattern {
|
||||
|
||||
#if lime_cairo
|
||||
return lime_cairo_pattern_create_rgba (r, g, b, a);
|
||||
#else
|
||||
return cast 0;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function destroy ():Void {
|
||||
|
||||
#if lime_cairo
|
||||
@@ -47,6 +110,17 @@ abstract CairoPattern(Dynamic) {
|
||||
|
||||
|
||||
|
||||
public function get_colorStopCount ():Int {
|
||||
|
||||
#if lime_cairo
|
||||
return lime_cairo_pattern_get_color_stop_count (this);
|
||||
#else
|
||||
return 0;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function get_extend ():CairoExtend {
|
||||
|
||||
#if lime_cairo
|
||||
@@ -122,8 +196,15 @@ abstract CairoPattern(Dynamic) {
|
||||
|
||||
|
||||
#if lime_cairo
|
||||
private static var lime_cairo_pattern_add_color_stop_rgb = System.load ("lime", "lime_cairo_pattern_add_color_stop_rgb", 5);
|
||||
private static var lime_cairo_pattern_add_color_stop_rgba = System.load ("lime", "lime_cairo_pattern_add_color_stop_rgba", -1);
|
||||
private static var lime_cairo_pattern_create_for_surface = System.load ("lime", "lime_cairo_pattern_create_for_surface", 1);
|
||||
private static var lime_cairo_pattern_create_linear = System.load ("lime", "lime_cairo_pattern_create_linear", 4);
|
||||
private static var lime_cairo_pattern_create_radial = System.load ("lime", "lime_cairo_pattern_create_radial", -1);
|
||||
private static var lime_cairo_pattern_create_rgb = System.load ("lime", "lime_cairo_pattern_create_rgb", 3);
|
||||
private static var lime_cairo_pattern_create_rgba = System.load ("lime", "lime_cairo_pattern_create_rgba", 4);
|
||||
private static var lime_cairo_pattern_destroy = System.load ("lime", "lime_cairo_pattern_destroy", 1);
|
||||
private static var lime_cairo_pattern_get_color_stop_count = System.load ("lime", "lime_cairo_pattern_get_color_stop_count", 1);
|
||||
private static var lime_cairo_pattern_get_extend = System.load ("lime", "lime_cairo_pattern_get_extend", 1);
|
||||
private static var lime_cairo_pattern_get_filter = System.load ("lime", "lime_cairo_pattern_get_filter", 1);
|
||||
private static var lime_cairo_pattern_get_matrix = System.load ("lime", "lime_cairo_pattern_get_matrix", 1);
|
||||
|
||||
46
lime/graphics/cairo/CairoStatus.hx
Normal file
46
lime/graphics/cairo/CairoStatus.hx
Normal file
@@ -0,0 +1,46 @@
|
||||
package lime.graphics.cairo;
|
||||
|
||||
|
||||
@:enum abstract CairoStatus(Int) from Int to Int {
|
||||
|
||||
public var SUCCESS = 0;
|
||||
public var NO_MEMORY = 1;
|
||||
public var INVALID_RESTORE = 2;
|
||||
public var INVALID_POP_GROUP = 3;
|
||||
public var NO_CURRENT_POINT = 4;
|
||||
public var INVALID_MATRIX = 5;
|
||||
public var INVALID_STATUS = 6;
|
||||
public var NULL_POINTER = 7;
|
||||
public var INVALID_STRING = 8;
|
||||
public var INVALID_PATH_DATA = 9;
|
||||
public var READ_ERROR = 10;
|
||||
public var WRITE_ERROR = 11;
|
||||
public var SURFACE_FINISHED = 12;
|
||||
public var SURFACE_TYPE_MISMATCH = 13;
|
||||
public var PATTERN_TYPE_MISMATCH = 14;
|
||||
public var INVALID_CONTENT = 15;
|
||||
public var INVALID_FORMAT = 16;
|
||||
public var INVALID_VISUAL = 17;
|
||||
public var FILE_NOT_FOUND = 18;
|
||||
public var INVALID_DASH = 19;
|
||||
public var INVALID_DSC_COMMENT = 20;
|
||||
public var INVALID_INDEX = 21;
|
||||
public var CLIP_NOT_REPRESENTABLE = 22;
|
||||
public var TEMP_FILE_ERROR = 23;
|
||||
public var INVALID_STRIDE = 24;
|
||||
public var FONT_TYPE_MISMATCH = 25;
|
||||
public var USER_FONT_IMMUTABLE = 26;
|
||||
public var USER_FONT_ERROR = 27;
|
||||
public var NEGATIVE_COUNT = 28;
|
||||
public var INVALID_CLUSTERS = 29;
|
||||
public var INVALID_SLANT = 30;
|
||||
public var INVALID_WEIGHT = 31;
|
||||
public var INVALID_SIZE = 32;
|
||||
public var USER_FONT_NOT_IMPLEMENTED = 33;
|
||||
public var DEVICE_TYPE_MISMATCH = 34;
|
||||
public var DEVICE_ERROR = 35;
|
||||
public var INVALID_MESH_CONSTRUCTION = 36;
|
||||
public var DEVICE_FINISHED = 37;
|
||||
public var JBIG2_GLOBAL_MISSING = 38;
|
||||
|
||||
}
|
||||
@@ -1,12 +1,19 @@
|
||||
package lime.graphics.cairo;
|
||||
package lime.graphics.cairo; #if !macro
|
||||
|
||||
|
||||
import lime.graphics.Image;
|
||||
import lime.system.System;
|
||||
|
||||
@:access(haxe.io.Bytes)
|
||||
|
||||
|
||||
abstract CairoSurface(Dynamic) {
|
||||
|
||||
|
||||
public var height (get, never):Int;
|
||||
public var width (get, never):Int;
|
||||
|
||||
|
||||
public function new (format:CairoFormat, width:Int, height:Int):CairoSurface {
|
||||
|
||||
#if lime_cairo
|
||||
@@ -47,6 +54,46 @@ abstract CairoSurface(Dynamic) {
|
||||
}
|
||||
|
||||
|
||||
public static function fromImage (image:Image):CairoSurface {
|
||||
|
||||
#if lime_cairo
|
||||
return createForData (image.data.buffer.__getNativePointer (), CairoFormat.ARGB32, image.width, image.height, image.buffer.stride);
|
||||
#else
|
||||
return null;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Get & Set Methods
|
||||
|
||||
|
||||
|
||||
|
||||
private function get_height ():Int {
|
||||
|
||||
#if lime_cairo
|
||||
return lime_cairo_image_surface_get_height (this);
|
||||
#else
|
||||
return 0;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function get_width ():Int {
|
||||
|
||||
#if lime_cairo
|
||||
return lime_cairo_image_surface_get_width (this);
|
||||
#else
|
||||
return 0;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Native Methods
|
||||
@@ -57,9 +104,14 @@ abstract CairoSurface(Dynamic) {
|
||||
#if lime_cairo
|
||||
private static var lime_cairo_image_surface_create = System.load ("lime", "lime_cairo_image_surface_create", 3);
|
||||
private static var lime_cairo_image_surface_create_for_data = System.load ("lime", "lime_cairo_image_surface_create_for_data", 5);
|
||||
private static var lime_cairo_image_surface_get_height = System.load ("lime", "lime_cairo_image_surface_get_height", 1);
|
||||
private static var lime_cairo_image_surface_get_width = System.load ("lime", "lime_cairo_image_surface_get_width", 1);
|
||||
private static var lime_cairo_surface_destroy = System.load ("lime", "lime_cairo_surface_destroy", 1);
|
||||
private static var lime_cairo_surface_flush = System.load ("lime", "lime_cairo_surface_flush", 1);
|
||||
#end
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#end
|
||||
@@ -4,6 +4,7 @@ package lime.graphics.utils;
|
||||
import haxe.ds.Vector;
|
||||
import lime.graphics.Image;
|
||||
import lime.graphics.ImageBuffer;
|
||||
import lime.graphics.PixelFormat;
|
||||
import lime.math.ColorMatrix;
|
||||
import lime.math.Rectangle;
|
||||
import lime.math.Vector2;
|
||||
@@ -675,7 +676,7 @@ class ImageDataUtil {
|
||||
#end
|
||||
|
||||
#if ((cpp || neko) && !disable_cffi)
|
||||
if (!System.disableCFFI) byteArray = lime_image_data_util_get_pixels (image, rect, format == ARGB ? 1 : 0); else
|
||||
if (!System.disableCFFI) byteArray = lime_image_data_util_get_pixels (image, rect, format); else
|
||||
#end
|
||||
{
|
||||
|
||||
@@ -935,11 +936,100 @@ class ImageDataUtil {
|
||||
}
|
||||
|
||||
|
||||
public static function setFormat (image:Image, format:PixelFormat):Void {
|
||||
|
||||
var data = image.buffer.data;
|
||||
if (data == null) return;
|
||||
|
||||
#if ((cpp || neko) && !disable_cffi)
|
||||
if (!System.disableCFFI) lime_image_data_util_set_format (image, format); else
|
||||
#end
|
||||
{
|
||||
|
||||
var index, a16;
|
||||
var length = Std.int (data.length / 4);
|
||||
var r1, g1, b1, a1, r2, g2, b2, a2;
|
||||
var r, g, b, a;
|
||||
|
||||
switch (image.format) {
|
||||
|
||||
case RGBA:
|
||||
|
||||
r1 = 0;
|
||||
g1 = 1;
|
||||
b1 = 2;
|
||||
a1 = 3;
|
||||
|
||||
case ARGB:
|
||||
|
||||
r1 = 1;
|
||||
g1 = 2;
|
||||
b1 = 3;
|
||||
a1 = 0;
|
||||
|
||||
case BGRA:
|
||||
|
||||
r1 = 2;
|
||||
g1 = 1;
|
||||
b1 = 0;
|
||||
a1 = 3;
|
||||
|
||||
}
|
||||
|
||||
switch (format) {
|
||||
|
||||
case RGBA:
|
||||
|
||||
r2 = 0;
|
||||
g2 = 1;
|
||||
b2 = 2;
|
||||
a2 = 3;
|
||||
|
||||
case ARGB:
|
||||
|
||||
r2 = 1;
|
||||
g2 = 2;
|
||||
b2 = 3;
|
||||
a2 = 0;
|
||||
|
||||
case BGRA:
|
||||
|
||||
r2 = 2;
|
||||
g2 = 1;
|
||||
b2 = 0;
|
||||
a2 = 3;
|
||||
|
||||
}
|
||||
|
||||
for (i in 0...length) {
|
||||
|
||||
index = i * 4;
|
||||
|
||||
r = data[index + r1];
|
||||
g = data[index + g1];
|
||||
b = data[index + b1];
|
||||
a = data[index + a1];
|
||||
|
||||
data[index + r2] = r;
|
||||
data[index + g2] = g;
|
||||
data[index + b2] = b;
|
||||
data[index + a2] = a;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
image.buffer.format = format;
|
||||
image.dirty = true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function setPixel (image:Image, x:Int, y:Int, color:Int, format:PixelFormat):Void {
|
||||
|
||||
var data = image.buffer.data;
|
||||
var offset = (4 * (y + image.offsetY) * image.buffer.width + (x + image.offsetX) * 4);
|
||||
if (format == null || format == RGBA) color = color >> 8;
|
||||
if (format == RGBA) color = color >> 8;
|
||||
|
||||
data[offset] = (color & 0xFF0000) >>> 16;
|
||||
data[offset + 1] = (color & 0x00FF00) >>> 8;
|
||||
@@ -1000,7 +1090,7 @@ class ImageDataUtil {
|
||||
if (image.buffer.data == null) return;
|
||||
|
||||
#if ((cpp || neko) && !disable_cffi)
|
||||
if (!System.disableCFFI) lime_image_data_util_set_pixels (image, rect, byteArray, format == ARGB ? 1 : 0); else
|
||||
if (!System.disableCFFI) lime_image_data_util_set_pixels (image, rect, byteArray, format); else
|
||||
#end
|
||||
{
|
||||
|
||||
@@ -1127,6 +1217,7 @@ class ImageDataUtil {
|
||||
private static var lime_image_data_util_merge = System.load ("lime", "lime_image_data_util_merge", -1);
|
||||
private static var lime_image_data_util_multiply_alpha = System.load ("lime", "lime_image_data_util_multiply_alpha", 1);
|
||||
private static var lime_image_data_util_resize = System.load ("lime", "lime_image_data_util_resize", 4);
|
||||
private static var lime_image_data_util_set_format = System.load ("lime", "lime_image_data_util_set_format", 2);
|
||||
private static var lime_image_data_util_set_pixels = System.load ("lime", "lime_image_data_util_set_pixels", 4);
|
||||
private static var lime_image_data_util_unmultiply_alpha = System.load ("lime", "lime_image_data_util_unmultiply_alpha", 1);
|
||||
#end
|
||||
|
||||
@@ -199,17 +199,24 @@ class IconHelper {
|
||||
|
||||
if (image != null) {
|
||||
|
||||
var data = null;
|
||||
|
||||
if (size < 256) {
|
||||
|
||||
imageData.push (BMP.encode (image, ICO));
|
||||
data = BMP.encode (image, ICO);
|
||||
|
||||
} else {
|
||||
|
||||
imageData.push (image.encode ("png"));
|
||||
data = image.encode ("png");
|
||||
|
||||
}
|
||||
|
||||
images.push (image);
|
||||
if (data != null) {
|
||||
|
||||
imageData.push (data);
|
||||
images.push (image);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class ImageHelper {
|
||||
|
||||
// try using Lime "legacy" to rasterize SVG first, since it is much faster
|
||||
|
||||
ProcessHelper.runCommand ("", "neko", [ PathHelper.getHaxelib (new Haxelib ("lime")) + "/svg.n", "process", path, Std.string (width), Std.string (height), temp ], true, true);
|
||||
ProcessHelper.runCommand ("", "neko", [ PathHelper.combine (PathHelper.getHaxelib (new Haxelib ("lime")), "svg.n"), "process", path, Std.string (width), Std.string (height), temp ], true, true);
|
||||
|
||||
if (FileSystem.exists (temp)) {
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ class WindowsPlatform extends PlatformTarget {
|
||||
|
||||
targetDirectory = project.app.path + "/windows/" + targetType;
|
||||
applicationDirectory = targetDirectory + "/bin/";
|
||||
executablePath = applicationDirectory + "/" + project.app.file + ".exe";
|
||||
executablePath = applicationDirectory + project.app.file + ".exe";
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ class Window {
|
||||
|
||||
public var currentRenderer:Renderer;
|
||||
public var config:Config;
|
||||
public var enableTextEvents (get, set):Bool;
|
||||
public var fullscreen (get, set):Bool;
|
||||
public var height (get, set):Int;
|
||||
public var minimized (get, set):Bool;
|
||||
@@ -28,6 +29,8 @@ class Window {
|
||||
public var onMouseMoveRelative = new Event<Float->Float->Void> ();
|
||||
public var onMouseUp = new Event<Float->Float->Int->Void> ();
|
||||
public var onMouseWheel = new Event<Float->Float->Void> ();
|
||||
public var onTextEdit = new Event<String->Int->Int->Void> ();
|
||||
public var onTextInput = new Event<String->Void> ();
|
||||
public var onTouchEnd = new Event<Float->Float->Int->Void> ();
|
||||
public var onTouchMove = new Event<Float->Float->Int->Void> ();
|
||||
public var onTouchStart = new Event<Float->Float->Int->Void> ();
|
||||
@@ -141,6 +144,20 @@ class Window {
|
||||
|
||||
|
||||
|
||||
@:noCompletion private inline function get_enableTextEvents ():Bool {
|
||||
|
||||
return backend.getEnableTextEvents ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@:noCompletion private inline function set_enableTextEvents (value:Bool):Bool {
|
||||
|
||||
return backend.setEnableTextEvents (value);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@:noCompletion private inline function get_fullscreen ():Bool {
|
||||
|
||||
return __fullscreen;
|
||||
|
||||
@@ -1002,6 +1002,15 @@ class ByteArray #if !js extends Bytes implements ArrayAccess<Int> implements IDa
|
||||
#end
|
||||
|
||||
|
||||
#if (cpp || neko || nodejs)
|
||||
public function __getNativePointer ():Dynamic {
|
||||
|
||||
return lime_byte_array_get_native_pointer (this);
|
||||
|
||||
}
|
||||
#end
|
||||
|
||||
|
||||
#if js
|
||||
private function __getUTFBytesCount (value:String):Int {
|
||||
|
||||
@@ -1154,6 +1163,7 @@ class ByteArray #if !js extends Bytes implements ArrayAccess<Int> implements IDa
|
||||
|
||||
|
||||
|
||||
private static var lime_byte_array_get_native_pointer = System.load ("lime", "lime_byte_array_get_native_pointer", 1);
|
||||
private static var lime_byte_array_overwrite_file = System.load ("lime", "lime_byte_array_overwrite_file", 2);
|
||||
private static var lime_byte_array_read_file = System.load ("lime", "lime_byte_array_read_file", 1);
|
||||
private static var lime_lzma_decode = System.load ("lime", "lime_lzma_decode", 1);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<set name="lime-legacy" value="1" if="legacy || lime_legacy" />
|
||||
<set name="ios" value="1" if="iphone" />
|
||||
|
||||
<set name="LIME_CAIRO" value="1" if="LIME_CAIRO" />
|
||||
<set name="LIME_CAIRO" value="1" />
|
||||
<set name="LIME_CURL" value="1" unless="emscripten" />
|
||||
<set name="LIME_JPEG" value="1" />
|
||||
<set name="LIME_FREETYPE" value="1" />
|
||||
@@ -18,7 +18,7 @@
|
||||
<set name="LIME_OGG" value="1" />
|
||||
<set name="LIME_OPENAL" value="1" />
|
||||
<set name="LIME_OPENGL" value="1" />
|
||||
<set name="LIME_PIXMAN" value="1" if="LIME_CAIRO || LIME_PIXMAN" />
|
||||
<set name="LIME_PIXMAN" value="1" />
|
||||
<set name="LIME_PNG" value="1" />
|
||||
<set name="LIME_SDL" value="1" />
|
||||
<set name="LIME_VORBIS" value="1" />
|
||||
@@ -42,6 +42,11 @@
|
||||
<section if="LIME_CAIRO">
|
||||
|
||||
<compilerflag value="-I${NATIVE_TOOLKIT_PATH}/cairo/include" />
|
||||
<compilerflag value="-I${NATIVE_TOOLKIT_PATH}/cairo/include/configs/default/" unless="windows || mac || linux"/>
|
||||
<compilerflag value="-I${NATIVE_TOOLKIT_PATH}/cairo/include/configs/linux/" if="linux"/>
|
||||
<compilerflag value="-I${NATIVE_TOOLKIT_PATH}/cairo/include/configs/windows/" if="windows"/>
|
||||
<compilerflag value="-I${NATIVE_TOOLKIT_PATH}/cairo/include/configs/mac/" if="mac"/>
|
||||
<compilerflag value="-DHAVE_CONFIG_H" />
|
||||
<compilerflag value="-DCAIRO_WIN32_STATIC_BUILD" if="windows" />
|
||||
|
||||
<file name="src/graphics/cairo/CairoBindings.cpp" />
|
||||
@@ -171,7 +176,7 @@
|
||||
|
||||
<compilerflag value="-DSTATIC_LINK" if="emscripten" />
|
||||
|
||||
<file name="${HXCPP}/project/libs/zlib/ZLib.cpp" if="emscripten || ios" />
|
||||
<file name="${HXCPP}/project/libs/zlib/ZLib.cpp" if="emscripten || ios || static_link" />
|
||||
|
||||
</section>
|
||||
|
||||
@@ -189,6 +194,7 @@
|
||||
<file name="src/ui/GamepadEvent.cpp" />
|
||||
<file name="src/ui/KeyEvent.cpp" />
|
||||
<file name="src/ui/MouseEvent.cpp" />
|
||||
<file name="src/ui/TextEvent.cpp" />
|
||||
<file name="src/ui/TouchEvent.cpp" />
|
||||
<file name="src/ui/WindowEvent.cpp" />
|
||||
<file name="src/utils/ByteArray.cpp" />
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
|
||||
#include <hx/CFFI.h>
|
||||
#include <graphics/PixelFormat.h>
|
||||
#include <utils/ByteArray.h>
|
||||
|
||||
|
||||
@@ -24,6 +25,7 @@ namespace lime {
|
||||
|
||||
int bpp;
|
||||
ByteArray *data;
|
||||
PixelFormat format;
|
||||
int height;
|
||||
int width;
|
||||
bool transparent;
|
||||
|
||||
@@ -8,7 +8,8 @@ namespace lime {
|
||||
enum PixelFormat {
|
||||
|
||||
RGBA,
|
||||
ARGB
|
||||
ARGB,
|
||||
BGRA
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ namespace lime {
|
||||
static void Merge (Image* image, Image* sourceImage, Rectangle* sourceRect, Vector2* destPoint, int redMultiplier, int greenMultiplier, int blueMultiplier, int alphaMultiplier);
|
||||
static void MultiplyAlpha (Image* image);
|
||||
static void Resize (Image* image, ImageBuffer* buffer, int width, int height);
|
||||
static void SetFormat (Image* image, PixelFormat format);
|
||||
static void SetPixels (Image* image, Rectangle* rect, ByteArray* bytes, PixelFormat format);
|
||||
static void UnmultiplyAlpha (Image* image);
|
||||
|
||||
|
||||
@@ -14,8 +14,11 @@ namespace lime {
|
||||
public:
|
||||
|
||||
Vector2 ();
|
||||
Vector2 (double x, double y);
|
||||
Vector2 (value vec);
|
||||
|
||||
value Value ();
|
||||
|
||||
double x;
|
||||
double y;
|
||||
|
||||
|
||||
41
project/include/ui/TextEvent.h
Normal file
41
project/include/ui/TextEvent.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#ifndef LIME_UI_TEXT_EVENT_H
|
||||
#define LIME_UI_TEXT_EVENT_H
|
||||
|
||||
|
||||
#include <hx/CFFI.h>
|
||||
|
||||
|
||||
namespace lime {
|
||||
|
||||
|
||||
enum TextEventType {
|
||||
|
||||
TEXT_INPUT,
|
||||
TEXT_EDIT
|
||||
|
||||
};
|
||||
|
||||
|
||||
class TextEvent {
|
||||
|
||||
public:
|
||||
|
||||
static AutoGCRoot* callback;
|
||||
static AutoGCRoot* eventObject;
|
||||
|
||||
TextEvent ();
|
||||
|
||||
static void Dispatch (TextEvent* event);
|
||||
|
||||
long length;
|
||||
long start;
|
||||
char text[32];
|
||||
TextEventType type;
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -19,12 +19,14 @@ namespace lime {
|
||||
public:
|
||||
|
||||
virtual void Close () = 0;
|
||||
virtual bool GetEnableTextEvents () = 0;
|
||||
virtual int GetHeight () = 0;
|
||||
virtual int GetWidth () = 0;
|
||||
virtual int GetX () = 0;
|
||||
virtual int GetY () = 0;
|
||||
virtual void Move (int x, int y) = 0;
|
||||
virtual void Resize (int width, int height) = 0;
|
||||
virtual void SetEnableTextEvents (bool enable) = 0;
|
||||
virtual bool SetFullscreen (bool fullscreen) = 0;
|
||||
virtual void SetIcon (ImageBuffer *imageBuffer) = 0;
|
||||
virtual bool SetMinimized (bool minimized) = 0;
|
||||
|
||||
Submodule project/lib/cairo updated: 83548b9227...eb462ba875
Submodule project/lib/harfbuzz updated: e98c90105d...395599e253
Submodule project/lib/pixman updated: 65dced727a...d42fc0b903
@@ -29,6 +29,7 @@
|
||||
#include <ui/Mouse.h>
|
||||
#include <ui/MouseCursor.h>
|
||||
#include <ui/MouseEvent.h>
|
||||
#include <ui/TextEvent.h>
|
||||
#include <ui/TouchEvent.h>
|
||||
#include <ui/Window.h>
|
||||
#include <ui/WindowEvent.h>
|
||||
@@ -489,7 +490,7 @@ namespace lime {
|
||||
value lime_image_data_util_fill_rect (value image, value rect, value color) {
|
||||
|
||||
Image _image = Image (image);
|
||||
Rectangle _rect = Rectangle (rect);
|
||||
Rectangle _rect = Rectangle (rect);
|
||||
ImageDataUtil::FillRect (&_image, &_rect, val_number (color));
|
||||
return alloc_null ();
|
||||
|
||||
@@ -550,6 +551,16 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
value lime_image_data_util_set_format (value image, value format) {
|
||||
|
||||
Image _image = Image (image);
|
||||
PixelFormat _format = (PixelFormat)val_int (format);
|
||||
ImageDataUtil::SetFormat (&_image, _format);
|
||||
return alloc_null ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_image_data_util_set_pixels (value image, value rect, value bytes, value format) {
|
||||
|
||||
Image _image = Image (image);
|
||||
@@ -754,6 +765,15 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
value lime_text_event_manager_register (value callback, value eventObject) {
|
||||
|
||||
TextEvent::callback = new AutoGCRoot (callback);
|
||||
TextEvent::eventObject = new AutoGCRoot (eventObject);
|
||||
return alloc_null ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void lime_text_layout_destroy (value textHandle) {
|
||||
|
||||
#ifdef LIME_HARFBUZZ
|
||||
@@ -876,6 +896,14 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
value lime_window_get_enable_text_events (value window) {
|
||||
|
||||
Window* targetWindow = (Window*)(intptr_t)val_float (window);
|
||||
return alloc_bool (targetWindow->GetEnableTextEvents ());
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_window_get_height (value window) {
|
||||
|
||||
Window* targetWindow = (Window*)(intptr_t)val_float (window);
|
||||
@@ -926,6 +954,15 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
value lime_window_set_enable_text_events (value window, value enabled) {
|
||||
|
||||
Window* targetWindow = (Window*)(intptr_t)val_float (window);
|
||||
targetWindow->SetEnableTextEvents (val_bool (enabled));
|
||||
return alloc_null ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_window_set_fullscreen (value window, value fullscreen) {
|
||||
|
||||
Window* targetWindow = (Window*)(intptr_t)val_float (window);
|
||||
@@ -986,6 +1023,7 @@ namespace lime {
|
||||
DEFINE_PRIM_MULT (lime_image_data_util_merge);
|
||||
DEFINE_PRIM (lime_image_data_util_multiply_alpha, 1);
|
||||
DEFINE_PRIM (lime_image_data_util_resize, 4);
|
||||
DEFINE_PRIM (lime_image_data_util_set_format, 2);
|
||||
DEFINE_PRIM (lime_image_data_util_set_pixels, 4);
|
||||
DEFINE_PRIM (lime_image_data_util_unmultiply_alpha, 1);
|
||||
DEFINE_PRIM (lime_image_encode, 3);
|
||||
@@ -1008,6 +1046,7 @@ namespace lime {
|
||||
DEFINE_PRIM (lime_render_event_manager_register, 2);
|
||||
DEFINE_PRIM (lime_system_get_directory, 3);
|
||||
DEFINE_PRIM (lime_system_get_timer, 0);
|
||||
DEFINE_PRIM (lime_text_event_manager_register, 2);
|
||||
DEFINE_PRIM (lime_text_layout_create, 3);
|
||||
DEFINE_PRIM (lime_text_layout_position, 5);
|
||||
DEFINE_PRIM (lime_text_layout_set_direction, 2);
|
||||
@@ -1018,12 +1057,14 @@ namespace lime {
|
||||
DEFINE_PRIM (lime_window_close, 1);
|
||||
DEFINE_PRIM (lime_window_create, 5);
|
||||
DEFINE_PRIM (lime_window_event_manager_register, 2);
|
||||
DEFINE_PRIM (lime_window_get_enable_text_events, 1);
|
||||
DEFINE_PRIM (lime_window_get_height, 1);
|
||||
DEFINE_PRIM (lime_window_get_width, 1);
|
||||
DEFINE_PRIM (lime_window_get_x, 1);
|
||||
DEFINE_PRIM (lime_window_get_y, 1);
|
||||
DEFINE_PRIM (lime_window_move, 3);
|
||||
DEFINE_PRIM (lime_window_resize, 3);
|
||||
DEFINE_PRIM (lime_window_set_enable_text_events, 2);
|
||||
DEFINE_PRIM (lime_window_set_fullscreen, 2);
|
||||
DEFINE_PRIM (lime_window_set_icon, 2);
|
||||
DEFINE_PRIM (lime_window_set_minimized, 2);
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace lime {
|
||||
|
||||
value lime_al_buffer3f (value buffer, value param, value value1, value value2, value value3) {
|
||||
|
||||
alBuffer3f (val_int (buffer), val_int (param), val_float (value1), val_float (value2), val_float (value3));
|
||||
alBuffer3f (val_int (buffer), val_int (param), val_number (value1), val_number (value2), val_number (value3));
|
||||
return alloc_null ();
|
||||
|
||||
}
|
||||
@@ -45,7 +45,7 @@ namespace lime {
|
||||
|
||||
value lime_al_bufferf (value buffer, value param, value value) {
|
||||
|
||||
alBufferf (val_int (buffer), val_int (param), val_float (value));
|
||||
alBufferf (val_int (buffer), val_int (param), val_number (value));
|
||||
return alloc_null ();
|
||||
|
||||
}
|
||||
@@ -169,7 +169,7 @@ namespace lime {
|
||||
|
||||
value lime_al_distance_model (value distanceModel) {
|
||||
|
||||
alDistanceModel (val_float (distanceModel));
|
||||
alDistanceModel (val_number (distanceModel));
|
||||
return alloc_null ();
|
||||
|
||||
}
|
||||
@@ -177,7 +177,7 @@ namespace lime {
|
||||
|
||||
value lime_al_doppler_factor (value factor) {
|
||||
|
||||
alDopplerFactor (val_float (factor));
|
||||
alDopplerFactor (val_number (factor));
|
||||
return alloc_null ();
|
||||
|
||||
}
|
||||
@@ -185,7 +185,7 @@ namespace lime {
|
||||
|
||||
value lime_al_doppler_velocity (value velocity) {
|
||||
|
||||
alDopplerVelocity (val_float (velocity));
|
||||
alDopplerVelocity (val_number (velocity));
|
||||
return alloc_null ();
|
||||
|
||||
}
|
||||
@@ -688,7 +688,7 @@ namespace lime {
|
||||
|
||||
value lime_al_listener3f (value param, value value1, value value2, value value3) {
|
||||
|
||||
alListener3f (val_int (param), val_float (value1), val_float (value2), val_float (value3));
|
||||
alListener3f (val_int (param), val_number (value1), val_number (value2), val_number (value3));
|
||||
return alloc_null ();
|
||||
|
||||
}
|
||||
@@ -704,7 +704,7 @@ namespace lime {
|
||||
|
||||
value lime_al_listenerf (value param, value value1) {
|
||||
|
||||
alListenerf (val_int (param), val_float (value1));
|
||||
alListenerf (val_int (param), val_number (value1));
|
||||
return alloc_null ();
|
||||
|
||||
}
|
||||
@@ -878,7 +878,7 @@ namespace lime {
|
||||
|
||||
value lime_al_source3f (value source, value param, value value1, value value2, value value3) {
|
||||
|
||||
alSource3f (val_int (source), val_int (param), val_float (value1), val_float (value2), val_float (value3));
|
||||
alSource3f (val_int (source), val_int (param), val_number (value1), val_number (value2), val_number (value3));
|
||||
return alloc_null ();
|
||||
|
||||
}
|
||||
@@ -894,7 +894,7 @@ namespace lime {
|
||||
|
||||
value lime_al_sourcef (value source, value param, value value) {
|
||||
|
||||
alSourcef (val_int (source), val_int (param), val_float (value));
|
||||
alSourcef (val_int (source), val_int (param), val_number (value));
|
||||
return alloc_null ();
|
||||
|
||||
}
|
||||
@@ -940,7 +940,7 @@ namespace lime {
|
||||
|
||||
value lime_al_speed_of_sound (value speed) {
|
||||
|
||||
alSpeedOfSound (val_float (speed));
|
||||
alSpeedOfSound (val_number (speed));
|
||||
return alloc_null ();
|
||||
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ namespace lime {
|
||||
KeyEvent keyEvent;
|
||||
MouseEvent mouseEvent;
|
||||
RenderEvent renderEvent;
|
||||
TextEvent textEvent;
|
||||
TouchEvent touchEvent;
|
||||
UpdateEvent updateEvent;
|
||||
WindowEvent windowEvent;
|
||||
@@ -145,6 +146,12 @@ namespace lime {
|
||||
ProcessMouseEvent (event);
|
||||
break;
|
||||
|
||||
case SDL_TEXTINPUT:
|
||||
case SDL_TEXTEDITING:
|
||||
|
||||
ProcessTextEvent (event);
|
||||
break;
|
||||
|
||||
case SDL_WINDOWEVENT:
|
||||
|
||||
switch (event->window.event) {
|
||||
@@ -337,6 +344,35 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
void SDLApplication::ProcessTextEvent (SDL_Event* event) {
|
||||
|
||||
if (TextEvent::callback) {
|
||||
|
||||
switch (event->type) {
|
||||
|
||||
case SDL_TEXTINPUT:
|
||||
|
||||
textEvent.type = TEXT_INPUT;
|
||||
break;
|
||||
|
||||
case SDL_TEXTEDITING:
|
||||
|
||||
textEvent.type = TEXT_EDIT;
|
||||
textEvent.start = event->edit.start;
|
||||
textEvent.length = event->edit.length;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
strcpy (textEvent.text, event->text.text);
|
||||
|
||||
TextEvent::Dispatch (&textEvent);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void SDLApplication::ProcessTouchEvent (SDL_Event* event) {
|
||||
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <ui/GamepadEvent.h>
|
||||
#include <ui/KeyEvent.h>
|
||||
#include <ui/MouseEvent.h>
|
||||
#include <ui/TextEvent.h>
|
||||
#include <ui/TouchEvent.h>
|
||||
#include <ui/WindowEvent.h>
|
||||
#include "SDLWindow.h"
|
||||
@@ -37,6 +38,7 @@ namespace lime {
|
||||
void ProcessGamepadEvent (SDL_Event* event);
|
||||
void ProcessKeyEvent (SDL_Event* event);
|
||||
void ProcessMouseEvent (SDL_Event* event);
|
||||
void ProcessTextEvent (SDL_Event* event);
|
||||
void ProcessTouchEvent (SDL_Event* event);
|
||||
void ProcessWindowEvent (SDL_Event* event);
|
||||
|
||||
@@ -54,6 +56,7 @@ namespace lime {
|
||||
MouseEvent mouseEvent;
|
||||
double nextUpdate;
|
||||
RenderEvent renderEvent;
|
||||
TextEvent textEvent;
|
||||
TouchEvent touchEvent;
|
||||
UpdateEvent updateEvent;
|
||||
WindowEvent windowEvent;
|
||||
|
||||
@@ -115,6 +115,13 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
bool SDLWindow::GetEnableTextEvents () {
|
||||
|
||||
return SDL_IsTextInputActive ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
int SDLWindow::GetHeight () {
|
||||
|
||||
int width;
|
||||
@@ -177,6 +184,21 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
void SDLWindow::SetEnableTextEvents (bool enabled) {
|
||||
|
||||
if (enabled) {
|
||||
|
||||
SDL_StartTextInput ();
|
||||
|
||||
} else {
|
||||
|
||||
SDL_StopTextInput ();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool SDLWindow::SetFullscreen (bool fullscreen) {
|
||||
|
||||
if (fullscreen) {
|
||||
|
||||
@@ -18,12 +18,14 @@ namespace lime {
|
||||
~SDLWindow ();
|
||||
|
||||
virtual void Close ();
|
||||
virtual bool GetEnableTextEvents ();
|
||||
virtual int GetHeight ();
|
||||
virtual int GetWidth ();
|
||||
virtual int GetX ();
|
||||
virtual int GetY ();
|
||||
virtual void Move (int x, int y);
|
||||
virtual void Resize (int width, int height);
|
||||
virtual void SetEnableTextEvents (bool enabled);
|
||||
virtual bool SetFullscreen (bool fullscreen);
|
||||
virtual void SetIcon (ImageBuffer *imageBuffer);
|
||||
virtual bool SetMinimized (bool minimized);
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace lime {
|
||||
static int id_bpp;
|
||||
static int id_buffer;
|
||||
static int id_data;
|
||||
static int id_format;
|
||||
static int id_height;
|
||||
static int id_width;
|
||||
static int id_transparent;
|
||||
@@ -19,6 +20,7 @@ namespace lime {
|
||||
width = 0;
|
||||
height = 0;
|
||||
bpp = 4;
|
||||
format = RGBA;
|
||||
data = 0;
|
||||
transparent = false;
|
||||
|
||||
@@ -36,6 +38,7 @@ namespace lime {
|
||||
id_width = val_id ("width");
|
||||
id_height = val_id ("height");
|
||||
id_data = val_id ("data");
|
||||
id_format = val_id ("format");
|
||||
init = true;
|
||||
|
||||
}
|
||||
@@ -43,6 +46,7 @@ namespace lime {
|
||||
width = val_int (val_field (imageBuffer, id_width));
|
||||
height = val_int (val_field (imageBuffer, id_height));
|
||||
bpp = val_int (val_field (imageBuffer, id_bitsPerPixel));
|
||||
format = (PixelFormat)val_int (val_field (imageBuffer, id_format));
|
||||
transparent = val_bool (val_field (imageBuffer, id_transparent));
|
||||
value data_value = val_field (imageBuffer, id_data);
|
||||
value buffer_value = val_field (data_value, id_buffer);
|
||||
@@ -103,6 +107,7 @@ namespace lime {
|
||||
id_width = val_id ("width");
|
||||
id_height = val_id ("height");
|
||||
id_data = val_id ("data");
|
||||
id_format = val_id ("format");
|
||||
init = true;
|
||||
|
||||
}
|
||||
@@ -113,6 +118,7 @@ namespace lime {
|
||||
alloc_field (mValue, id_bpp, alloc_int (bpp));
|
||||
alloc_field (mValue, id_transparent, alloc_bool (transparent));
|
||||
alloc_field (mValue, id_data, data->mValue);
|
||||
alloc_field (mValue, id_format, alloc_int (format));
|
||||
return mValue;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <cairo.h>
|
||||
#include <math/Matrix3.h>
|
||||
#include <math/Vector2.h>
|
||||
#include <hx/CFFI.h>
|
||||
|
||||
|
||||
@@ -14,6 +15,14 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_arc_negative (value *arg, int argCount) {
|
||||
|
||||
cairo_arc_negative ((cairo_t*)(intptr_t)val_float (arg[0]), val_number (arg[1]), val_number (arg[2]), val_number (arg[3]), val_number (arg[4]), val_number (arg[5]));
|
||||
return alloc_null ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_clip (value handle) {
|
||||
|
||||
cairo_clip ((cairo_t*)(intptr_t)val_float (handle));
|
||||
@@ -22,6 +31,27 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_clip_extents (value handle, value x1, value y1, value x2, value y2) {
|
||||
|
||||
double _x1 = val_number (x1);
|
||||
double _y1 = val_number (y1);
|
||||
double _x2 = val_number (x2);
|
||||
double _y2 = val_number (y2);
|
||||
|
||||
cairo_clip_extents ((cairo_t*)(intptr_t)val_float (handle), &_x1, &_y1, &_x2, &_y2);
|
||||
return alloc_null ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_clip_preserve (value handle) {
|
||||
|
||||
cairo_clip_preserve ((cairo_t*)(intptr_t)val_float (handle));
|
||||
return alloc_null ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_close_path (value handle) {
|
||||
|
||||
cairo_close_path ((cairo_t*)(intptr_t)val_float (handle));
|
||||
@@ -30,6 +60,14 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_copy_page (value handle) {
|
||||
|
||||
cairo_copy_page ((cairo_t*)(intptr_t)val_float (handle));
|
||||
return alloc_null ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_create (value surface) {
|
||||
|
||||
return alloc_float ((intptr_t)cairo_create ((cairo_surface_t*)(intptr_t)val_float (surface)));
|
||||
@@ -37,6 +75,14 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_curve_to (value *arg, int argCount) {
|
||||
|
||||
cairo_curve_to ((cairo_t*)(intptr_t)val_float (arg[0]), val_number (arg[1]), val_number (arg[2]), val_number (arg[3]), val_number (arg[4]), val_number (arg[5]), val_number (arg[6]));
|
||||
return alloc_null ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_destroy (value handle) {
|
||||
|
||||
cairo_destroy ((cairo_t*)(intptr_t)val_float (handle));
|
||||
@@ -53,6 +99,19 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_fill_extents (value handle, value x1, value y1, value x2, value y2) {
|
||||
|
||||
double _x1 = val_number (x1);
|
||||
double _y1 = val_number (y1);
|
||||
double _x2 = val_number (x2);
|
||||
double _y2 = val_number (y2);
|
||||
|
||||
cairo_fill_extents ((cairo_t*)(intptr_t)val_float (handle), &_x1, &_y1, &_x2, &_y2);
|
||||
return alloc_null ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_fill_preserve (value handle) {
|
||||
|
||||
cairo_fill_preserve ((cairo_t*)(intptr_t)val_float (handle));
|
||||
@@ -61,6 +120,67 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_get_antialias (value handle) {
|
||||
|
||||
return alloc_int (cairo_get_antialias ((cairo_t*)(intptr_t)val_float (handle)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_get_current_point (value handle) {
|
||||
|
||||
double x, y;
|
||||
cairo_get_current_point ((cairo_t*)(intptr_t)val_float (handle), &x, &y);
|
||||
Vector2 vec2 = Vector2 (x, y);
|
||||
return vec2.Value ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_get_dash (value handle) {
|
||||
|
||||
int length = cairo_get_dash_count ((cairo_t*)(intptr_t)val_float (handle));
|
||||
|
||||
double* dashes = new double[length];
|
||||
double offset;
|
||||
|
||||
cairo_get_dash ((cairo_t*)(intptr_t)val_float (handle), dashes, &offset);
|
||||
|
||||
value result = alloc_array (length);
|
||||
|
||||
for (int i = 0; i < length; i++) {
|
||||
|
||||
val_array_set_i (result, i, alloc_float (dashes[i]));
|
||||
|
||||
}
|
||||
|
||||
delete dashes;
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_get_dash_count (value handle) {
|
||||
|
||||
return alloc_int (cairo_get_dash_count ((cairo_t*)(intptr_t)val_float (handle)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_get_fill_rule (value handle) {
|
||||
|
||||
return alloc_int (cairo_get_fill_rule ((cairo_t*)(intptr_t)val_float (handle)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_get_group_target (value handle) {
|
||||
|
||||
return alloc_float ((intptr_t)cairo_get_group_target ((cairo_t*)(intptr_t)val_float (handle)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_get_line_cap (value handle) {
|
||||
|
||||
return alloc_int (cairo_get_line_cap ((cairo_t*)(intptr_t)val_float (handle)));
|
||||
@@ -106,6 +226,13 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_get_reference_count (value handle) {
|
||||
|
||||
return alloc_int (cairo_get_reference_count ((cairo_t*)(intptr_t)val_float (handle)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_get_source (value handle) {
|
||||
|
||||
return alloc_float ((intptr_t)cairo_get_source ((cairo_t*)(intptr_t)val_float (handle)));
|
||||
@@ -113,6 +240,35 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_get_target (value handle) {
|
||||
|
||||
return alloc_float ((intptr_t)cairo_get_target ((cairo_t*)(intptr_t)val_float (handle)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_get_tolerance (value handle) {
|
||||
|
||||
return alloc_float (cairo_get_tolerance ((cairo_t*)(intptr_t)val_float (handle)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_has_current_point (value handle) {
|
||||
|
||||
return alloc_bool (cairo_has_current_point ((cairo_t*)(intptr_t)val_float (handle)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_identity_matrix (value handle) {
|
||||
|
||||
cairo_identity_matrix ((cairo_t*)(intptr_t)val_float (handle));
|
||||
return alloc_null ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_image_surface_create (value format, value width, value height) {
|
||||
|
||||
return alloc_float ((intptr_t)cairo_image_surface_create ((cairo_format_t)val_int (format), val_int (width), val_int (height)));
|
||||
@@ -127,6 +283,41 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_image_surface_get_height (value handle) {
|
||||
|
||||
return alloc_int ((intptr_t)cairo_image_surface_get_height ((cairo_surface_t*)(intptr_t)val_float (handle)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_image_surface_get_width (value handle) {
|
||||
|
||||
return alloc_int ((intptr_t)cairo_image_surface_get_width ((cairo_surface_t*)(intptr_t)val_float (handle)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_in_clip (value handle, value x, value y) {
|
||||
|
||||
return alloc_bool (cairo_in_clip ((cairo_t*)(intptr_t)val_float (handle), val_number (x), val_number (y)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_in_fill (value handle, value x, value y) {
|
||||
|
||||
return alloc_bool (cairo_in_fill ((cairo_t*)(intptr_t)val_float (handle), val_number (x), val_number (y)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_in_stroke (value handle, value x, value y) {
|
||||
|
||||
return alloc_bool (cairo_in_stroke ((cairo_t*)(intptr_t)val_float (handle), val_number (x), val_number (y)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_line_to (value handle, value x, value y) {
|
||||
|
||||
cairo_line_to ((cairo_t*)(intptr_t)val_float (handle), val_number (x), val_number (y));
|
||||
@@ -143,6 +334,14 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_mask_surface (value handle, value surface, value x, value y) {
|
||||
|
||||
cairo_mask_surface ((cairo_t*)(intptr_t)val_float (handle), (cairo_surface_t*)(intptr_t)val_float (surface), val_number (x), val_number (y));
|
||||
return alloc_null ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_move_to (value handle, value x, value y) {
|
||||
|
||||
cairo_move_to ((cairo_t*)(intptr_t)val_float (handle), val_number (x), val_number (y));
|
||||
@@ -175,6 +374,22 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_pattern_add_color_stop_rgb (value handle, value offset, value red, value green, value blue) {
|
||||
|
||||
cairo_pattern_add_color_stop_rgb ((cairo_pattern_t*)(intptr_t)val_float (handle), val_number (offset), val_number (red), val_number (green), val_number (blue));
|
||||
return alloc_null ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_pattern_add_color_stop_rgba (value *arg, int argCount) {
|
||||
|
||||
cairo_pattern_add_color_stop_rgba ((cairo_pattern_t*)(intptr_t)val_float (arg[0]), val_number (arg[1]), val_number (arg[2]), val_number (arg[3]), val_number (arg[4]), val_number (arg[5]));
|
||||
return alloc_null ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_pattern_create_for_surface (value surface) {
|
||||
|
||||
return alloc_float ((intptr_t)cairo_pattern_create_for_surface ((cairo_surface_t*)(intptr_t)val_float (surface)));
|
||||
@@ -182,6 +397,34 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_pattern_create_linear (value x0, value y0, value x1, value y1) {
|
||||
|
||||
return alloc_float ((intptr_t)cairo_pattern_create_linear (val_number (x0), val_number (y0), val_number (x1), val_number (y1)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_pattern_create_radial (value *arg, int argCount) {
|
||||
|
||||
return alloc_float ((intptr_t)cairo_pattern_create_radial (val_number (arg[0]), val_number (arg[1]), val_number (arg[2]), val_number (arg[3]), val_number (arg[4]), val_number (arg[5])));
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_pattern_create_rgb (value r, value g, value b) {
|
||||
|
||||
return alloc_float ((intptr_t)cairo_pattern_create_rgb (val_number (r), val_number (g), val_number (b)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_pattern_create_rgba (value r, value g, value b, value a) {
|
||||
|
||||
return alloc_float ((intptr_t)cairo_pattern_create_rgba (val_number (r), val_number (g), val_number (b), val_number (a)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_pattern_destroy (value handle) {
|
||||
|
||||
cairo_pattern_destroy ((cairo_pattern_t*)(intptr_t)val_float (handle));
|
||||
@@ -190,6 +433,15 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_pattern_get_color_stop_count (value handle) {
|
||||
|
||||
int count;
|
||||
cairo_pattern_get_color_stop_count ((cairo_pattern_t*)(intptr_t)val_float (handle), &count);
|
||||
return alloc_int (count);
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_pattern_get_extend (value handle) {
|
||||
|
||||
return alloc_int (cairo_pattern_get_extend ((cairo_pattern_t*)(intptr_t)val_float (handle)));
|
||||
@@ -282,6 +534,38 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_reference (value handle) {
|
||||
|
||||
cairo_reference ((cairo_t*)(intptr_t)val_float (handle));
|
||||
return alloc_null ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_rel_curve_to (value *arg, int argCount) {
|
||||
|
||||
cairo_rel_curve_to ((cairo_t*)(intptr_t)val_float (arg[0]), val_number (arg[1]), val_number (arg[2]), val_number (arg[3]), val_number (arg[4]), val_number (arg[5]), val_number (arg[6]));
|
||||
return alloc_null ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_rel_line_to (value handle, value dx, value dy) {
|
||||
|
||||
cairo_rel_line_to ((cairo_t*)(intptr_t)val_float (handle), val_number (dx), val_number (dy));
|
||||
return alloc_null ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_rel_move_to (value handle, value dx, value dy) {
|
||||
|
||||
cairo_rel_move_to ((cairo_t*)(intptr_t)val_float (handle), val_number (dx), val_number (dy));
|
||||
return alloc_null ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_reset_clip (value handle) {
|
||||
|
||||
cairo_reset_clip ((cairo_t*)(intptr_t)val_float (handle));
|
||||
@@ -306,6 +590,41 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_set_antialias (value handle, value cap) {
|
||||
|
||||
cairo_set_antialias ((cairo_t*)(intptr_t)val_float (handle), (cairo_antialias_t)val_int (cap));
|
||||
return alloc_null ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_set_dash (value handle, value dash) {
|
||||
|
||||
int length = val_array_size (dash);
|
||||
|
||||
double* dashPattern = new double[length];
|
||||
|
||||
for (int i = 0; i < length; i++) {
|
||||
|
||||
dashPattern[i] = val_number (val_array_i (dash, i));
|
||||
|
||||
}
|
||||
|
||||
cairo_set_dash ((cairo_t*)(intptr_t)val_float (handle), dashPattern, length, 0);
|
||||
delete dashPattern;
|
||||
return alloc_null ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_set_fill_rule (value handle, value cap) {
|
||||
|
||||
cairo_set_fill_rule ((cairo_t*)(intptr_t)val_float (handle), (cairo_fill_rule_t)val_int (cap));
|
||||
return alloc_null ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_set_line_cap (value handle, value cap) {
|
||||
|
||||
cairo_set_line_cap ((cairo_t*)(intptr_t)val_float (handle), (cairo_line_cap_t)val_int (cap));
|
||||
@@ -391,6 +710,29 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_set_tolerance (value handle, value tolerance) {
|
||||
|
||||
cairo_set_tolerance ((cairo_t*)(intptr_t)val_float (handle), val_number (tolerance));
|
||||
return alloc_null ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_show_page (value handle) {
|
||||
|
||||
cairo_show_page ((cairo_t*)(intptr_t)val_float (handle));
|
||||
return alloc_null ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_status (value handle) {
|
||||
|
||||
return alloc_int (cairo_status ((cairo_t*)(intptr_t)val_float (handle)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_stroke (value handle) {
|
||||
|
||||
cairo_stroke ((cairo_t*)(intptr_t)val_float (handle));
|
||||
@@ -399,6 +741,19 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_stroke_extents (value handle, value x1, value y1, value x2, value y2) {
|
||||
|
||||
double _x1 = val_number (x1);
|
||||
double _y1 = val_number (y1);
|
||||
double _x2 = val_number (x2);
|
||||
double _y2 = val_number (y2);
|
||||
|
||||
cairo_stroke_extents ((cairo_t*)(intptr_t)val_float (handle), &_x1, &_y1, &_x2, &_y2);
|
||||
return alloc_null ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_stroke_preserve (value handle) {
|
||||
|
||||
cairo_stroke_preserve ((cairo_t*)(intptr_t)val_float (handle));
|
||||
@@ -436,6 +791,14 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_translate (value handle, value x, value y) {
|
||||
|
||||
cairo_translate ((cairo_t*)(intptr_t)val_float (handle), val_number (x), val_number (y));
|
||||
return alloc_null ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_cairo_version () {
|
||||
|
||||
return alloc_int (cairo_version ());
|
||||
@@ -451,29 +814,59 @@ namespace lime {
|
||||
|
||||
|
||||
DEFINE_PRIM_MULT (lime_cairo_arc);
|
||||
DEFINE_PRIM_MULT (lime_cairo_arc_negative);
|
||||
DEFINE_PRIM (lime_cairo_clip, 1);
|
||||
DEFINE_PRIM (lime_cairo_clip_extents, 5);
|
||||
DEFINE_PRIM (lime_cairo_clip_preserve, 1);
|
||||
DEFINE_PRIM (lime_cairo_close_path, 1);
|
||||
DEFINE_PRIM (lime_cairo_copy_page, 1);
|
||||
DEFINE_PRIM (lime_cairo_create, 1);
|
||||
DEFINE_PRIM_MULT (lime_cairo_curve_to);
|
||||
DEFINE_PRIM (lime_cairo_destroy, 1);
|
||||
DEFINE_PRIM (lime_cairo_fill, 1);
|
||||
DEFINE_PRIM (lime_cairo_fill_extents, 5);
|
||||
DEFINE_PRIM (lime_cairo_fill_preserve, 1);
|
||||
DEFINE_PRIM (lime_cairo_get_antialias, 1);
|
||||
DEFINE_PRIM (lime_cairo_get_current_point, 1);
|
||||
DEFINE_PRIM (lime_cairo_get_dash, 1);
|
||||
DEFINE_PRIM (lime_cairo_get_dash_count, 1);
|
||||
DEFINE_PRIM (lime_cairo_get_fill_rule, 1);
|
||||
DEFINE_PRIM (lime_cairo_get_group_target, 1);
|
||||
DEFINE_PRIM (lime_cairo_get_line_cap, 1);
|
||||
DEFINE_PRIM (lime_cairo_get_line_join, 1);
|
||||
DEFINE_PRIM (lime_cairo_get_line_width, 1);
|
||||
DEFINE_PRIM (lime_cairo_get_matrix, 1);
|
||||
DEFINE_PRIM (lime_cairo_get_miter_limit, 1);
|
||||
DEFINE_PRIM (lime_cairo_get_operator, 1);
|
||||
DEFINE_PRIM (lime_cairo_get_reference_count, 1);
|
||||
DEFINE_PRIM (lime_cairo_get_source, 1);
|
||||
DEFINE_PRIM (lime_cairo_get_target, 1);
|
||||
DEFINE_PRIM (lime_cairo_get_tolerance, 1);
|
||||
DEFINE_PRIM (lime_cairo_has_current_point, 1);
|
||||
DEFINE_PRIM (lime_cairo_identity_matrix, 1);
|
||||
DEFINE_PRIM (lime_cairo_image_surface_create, 3);
|
||||
DEFINE_PRIM (lime_cairo_image_surface_create_for_data, 5);
|
||||
DEFINE_PRIM (lime_cairo_image_surface_get_height, 1);
|
||||
DEFINE_PRIM (lime_cairo_image_surface_get_width, 1);
|
||||
DEFINE_PRIM (lime_cairo_in_clip, 3);
|
||||
DEFINE_PRIM (lime_cairo_in_fill, 3);
|
||||
DEFINE_PRIM (lime_cairo_in_stroke, 3);
|
||||
DEFINE_PRIM (lime_cairo_line_to, 3);
|
||||
DEFINE_PRIM (lime_cairo_mask, 2);
|
||||
DEFINE_PRIM (lime_cairo_mask_surface, 4);
|
||||
DEFINE_PRIM (lime_cairo_move_to, 3);
|
||||
DEFINE_PRIM (lime_cairo_new_path, 1);
|
||||
DEFINE_PRIM (lime_cairo_paint, 1);
|
||||
DEFINE_PRIM (lime_cairo_paint_with_alpha, 2);
|
||||
DEFINE_PRIM (lime_cairo_pattern_add_color_stop_rgb, 5);
|
||||
DEFINE_PRIM_MULT (lime_cairo_pattern_add_color_stop_rgba);
|
||||
DEFINE_PRIM (lime_cairo_pattern_create_for_surface, 1);
|
||||
DEFINE_PRIM (lime_cairo_pattern_create_linear, 4);
|
||||
DEFINE_PRIM_MULT (lime_cairo_pattern_create_radial);
|
||||
DEFINE_PRIM (lime_cairo_pattern_create_rgb, 3);
|
||||
DEFINE_PRIM (lime_cairo_pattern_create_rgba, 4);
|
||||
DEFINE_PRIM (lime_cairo_pattern_destroy, 1);
|
||||
DEFINE_PRIM (lime_cairo_pattern_get_color_stop_count, 1);
|
||||
DEFINE_PRIM (lime_cairo_pattern_get_extend, 1);
|
||||
DEFINE_PRIM (lime_cairo_pattern_get_filter, 1);
|
||||
DEFINE_PRIM (lime_cairo_pattern_get_matrix, 1);
|
||||
@@ -485,9 +878,16 @@ namespace lime {
|
||||
DEFINE_PRIM (lime_cairo_push_group, 1);
|
||||
DEFINE_PRIM (lime_cairo_push_group_with_content, 2);
|
||||
DEFINE_PRIM (lime_cairo_rectangle, 5);
|
||||
DEFINE_PRIM (lime_cairo_reference, 1);
|
||||
DEFINE_PRIM_MULT (lime_cairo_rel_curve_to);
|
||||
DEFINE_PRIM (lime_cairo_rel_line_to, 3);
|
||||
DEFINE_PRIM (lime_cairo_rel_move_to, 3);
|
||||
DEFINE_PRIM (lime_cairo_reset_clip, 1);
|
||||
DEFINE_PRIM (lime_cairo_restore, 1);
|
||||
DEFINE_PRIM (lime_cairo_save, 1);
|
||||
DEFINE_PRIM (lime_cairo_set_antialias, 2);
|
||||
DEFINE_PRIM (lime_cairo_set_dash, 2);
|
||||
DEFINE_PRIM (lime_cairo_set_fill_rule, 2);
|
||||
DEFINE_PRIM (lime_cairo_set_line_cap, 2);
|
||||
DEFINE_PRIM (lime_cairo_set_line_join, 2);
|
||||
DEFINE_PRIM (lime_cairo_set_line_width, 2);
|
||||
@@ -498,11 +898,16 @@ namespace lime {
|
||||
DEFINE_PRIM (lime_cairo_set_source_rgb, 4);
|
||||
DEFINE_PRIM (lime_cairo_set_source_rgba, 5);
|
||||
DEFINE_PRIM (lime_cairo_set_source_surface, 4);
|
||||
DEFINE_PRIM (lime_cairo_set_tolerance, 2);
|
||||
DEFINE_PRIM (lime_cairo_show_page, 1);
|
||||
DEFINE_PRIM (lime_cairo_status, 1);
|
||||
DEFINE_PRIM (lime_cairo_stroke, 1);
|
||||
DEFINE_PRIM (lime_cairo_stroke_extents, 5);
|
||||
DEFINE_PRIM (lime_cairo_stroke_preserve, 1);
|
||||
DEFINE_PRIM (lime_cairo_surface_destroy, 1);
|
||||
DEFINE_PRIM (lime_cairo_surface_flush, 1);
|
||||
DEFINE_PRIM (lime_cairo_transform, 2);
|
||||
DEFINE_PRIM (lime_cairo_translate, 3);
|
||||
DEFINE_PRIM (lime_cairo_version, 0);
|
||||
DEFINE_PRIM (lime_cairo_version_string, 0);
|
||||
|
||||
|
||||
@@ -478,6 +478,90 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
void ImageDataUtil::SetFormat (Image* image, PixelFormat format) {
|
||||
|
||||
int index, a16;
|
||||
int length = image->buffer->data->Size () / 4;
|
||||
int r1, g1, b1, a1, r2, g2, b2, a2;
|
||||
int r, g, b, a;
|
||||
|
||||
switch (image->buffer->format) {
|
||||
|
||||
case RGBA:
|
||||
|
||||
r1 = 0;
|
||||
g1 = 1;
|
||||
b1 = 2;
|
||||
a1 = 3;
|
||||
break;
|
||||
|
||||
case ARGB:
|
||||
|
||||
r1 = 1;
|
||||
g1 = 2;
|
||||
b1 = 3;
|
||||
a1 = 0;
|
||||
break;
|
||||
|
||||
case BGRA:
|
||||
|
||||
r1 = 2;
|
||||
g1 = 1;
|
||||
b1 = 0;
|
||||
a1 = 3;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
switch (format) {
|
||||
|
||||
case RGBA:
|
||||
|
||||
r2 = 0;
|
||||
g2 = 1;
|
||||
b2 = 2;
|
||||
a2 = 3;
|
||||
break;
|
||||
|
||||
case ARGB:
|
||||
|
||||
r2 = 1;
|
||||
g2 = 2;
|
||||
b2 = 3;
|
||||
a2 = 0;
|
||||
break;
|
||||
|
||||
case BGRA:
|
||||
|
||||
r2 = 2;
|
||||
g2 = 1;
|
||||
b2 = 0;
|
||||
a2 = 3;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
unsigned char* data = image->buffer->data->Bytes ();
|
||||
|
||||
for (int i = 0; i < length; i++) {
|
||||
|
||||
index = i * 4;
|
||||
|
||||
r = data[index + r1];
|
||||
g = data[index + g1];
|
||||
b = data[index + b1];
|
||||
a = data[index + a1];
|
||||
|
||||
data[index + r2] = r;
|
||||
data[index + g2] = g;
|
||||
data[index + b2] = b;
|
||||
data[index + a2] = a;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ImageDataUtil::SetPixels (Image* image, Rectangle* rect, ByteArray* bytes, PixelFormat format) {
|
||||
|
||||
if (format == RGBA && rect->width == image->buffer->width && rect->height == image->buffer->height && rect->x == 0 && rect->y == 0) {
|
||||
|
||||
@@ -17,6 +17,14 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
Vector2::Vector2 (double x, double y) {
|
||||
|
||||
this->x = x;
|
||||
this->y = y;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Vector2::Vector2 (value vec) {
|
||||
|
||||
if (!init) {
|
||||
@@ -33,4 +41,22 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
value Vector2::Value () {
|
||||
|
||||
if (!init) {
|
||||
|
||||
id_x = val_id ("x");
|
||||
id_y = val_id ("y");
|
||||
init = true;
|
||||
|
||||
}
|
||||
|
||||
value result = alloc_empty_object ();
|
||||
alloc_field (result, id_x, alloc_float (x));
|
||||
alloc_field (result, id_y, alloc_float (y));
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
59
project/src/ui/TextEvent.cpp
Normal file
59
project/src/ui/TextEvent.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
#include <hx/CFFI.h>
|
||||
#include <ui/TextEvent.h>
|
||||
|
||||
|
||||
namespace lime {
|
||||
|
||||
|
||||
AutoGCRoot* TextEvent::callback = 0;
|
||||
AutoGCRoot* TextEvent::eventObject = 0;
|
||||
|
||||
static int id_length;
|
||||
static int id_start;
|
||||
static int id_text;
|
||||
static int id_type;
|
||||
static bool init = false;
|
||||
|
||||
|
||||
TextEvent::TextEvent () {
|
||||
|
||||
length = 0;
|
||||
start = 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void TextEvent::Dispatch (TextEvent* event) {
|
||||
|
||||
if (TextEvent::callback) {
|
||||
|
||||
if (!init) {
|
||||
|
||||
id_length = val_id ("length");
|
||||
id_start = val_id ("start");
|
||||
id_text = val_id ("text");
|
||||
id_type = val_id ("type");
|
||||
init = true;
|
||||
|
||||
}
|
||||
|
||||
value object = (TextEvent::eventObject ? TextEvent::eventObject->get () : alloc_empty_object ());
|
||||
|
||||
if (event->type != TEXT_INPUT) {
|
||||
|
||||
alloc_field (object, id_length, alloc_int (event->length));
|
||||
alloc_field (object, id_start, alloc_int (event->start));
|
||||
|
||||
}
|
||||
|
||||
alloc_field (object, id_text, alloc_string (event->text));
|
||||
alloc_field (object, id_type, alloc_int (event->type));
|
||||
|
||||
val_call0 (TextEvent::callback->get ());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -138,7 +138,7 @@ namespace lime {
|
||||
|
||||
if (!val_is_null (bytes.mValue)) {
|
||||
|
||||
return alloc_int ((intptr_t)bytes.Bytes ());
|
||||
return alloc_float ((intptr_t)bytes.Bytes ());
|
||||
|
||||
}
|
||||
|
||||
@@ -146,6 +146,7 @@ namespace lime {
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_byte_array_init (value inFactory, value inLen, value inResize, value inBytes) {
|
||||
|
||||
gByteArrayCreate = new AutoGCRoot (inFactory);
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
|
||||
</section>
|
||||
|
||||
<lib name="ApplicationMain${DBG}${LIBEXT}" />
|
||||
<lib name="libApplicationMain${DBG}${LIBEXT}" />
|
||||
|
||||
</target>
|
||||
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
extern "C" const char *hxRunLibrary ();
|
||||
extern "C" void hxcpp_set_top_of_stack ();
|
||||
|
||||
extern "C" int zlib_register_prims ();
|
||||
extern "C" int lime_cairo_register_prims ();
|
||||
extern "C" int lime_openal_register_prims ();
|
||||
::foreach ndlls::::if (registerStatics)::
|
||||
extern "C" int ::nameSafe::_register_prims ();::end::::end::
|
||||
|
||||
@@ -19,6 +22,9 @@ extern "C" int main(int argc, char *argv[]) {
|
||||
|
||||
hxcpp_set_top_of_stack ();
|
||||
|
||||
zlib_register_prims ();
|
||||
lime_cairo_register_prims ();
|
||||
lime_openal_register_prims ();
|
||||
::foreach ndlls::::if (registerStatics)::
|
||||
::nameSafe::_register_prims ();::end::::end::
|
||||
|
||||
|
||||
Reference in New Issue
Block a user