Browse Source

directx custom cursor support

Nicolas Cannasse 8 years ago
parent
commit
31383f4474
3 changed files with 13 additions and 12 deletions
  1. 9 6
      hxd/Cursor.hx
  2. 2 2
      hxd/System.hl.hx
  3. 2 4
      samples/Cursor.hx

+ 9 - 6
hxd/Cursor.hx

@@ -24,6 +24,8 @@ class CustomCursor {
 	static var UID = 0;
 	var name : String;
 	var alloc : flash.ui.MouseCursorData;
+	#else
+	var alloc : Dynamic;
 	#end
 
 	public function new( frames, speed, offsetX, offsetY ) {
@@ -40,17 +42,18 @@ class CustomCursor {
 		for( f in frames )
 			f.dispose();
 		frames = [];
-		#if hlsdl
 		if( alloc != null ) {
+			#if hlsdl
 			alloc.free();
-			alloc = null;
-		}
-		#elseif flash
-		if( alloc != null ) {
+			#elseif flash
 			flash.ui.Mouse.unregisterCursor(name);
+			#elseif hldx
+			alloc.destroy();
+			#else
+			throw "TODO";
+			#end
 			alloc = null;
 		}
-		#end
 	}
 
 }

+ 2 - 2
hxd/System.hl.hx

@@ -105,7 +105,7 @@ class System {
 		case Button:
 			cur = Cursor.createSystem(Hand);
 		case Move:
-			throw "Cursor not supported";
+			cur = Cursor.createSystem(SizeALL);
 		case TextInput:
 			cur = Cursor.createSystem(IBeam);
 		case Hide:
@@ -120,7 +120,7 @@ class System {
 				c.alloc = sdl.Cursor.create(surf, c.offsetX, c.offsetY);
 				surf.free();
 				#elseif hldx
-				throw "TODO";
+				c.alloc = dx.Cursor.createCursor(pixels.width, pixels.height, pixels.bytes, c.offsetX, c.offsetY);
 				#end
 				pixels.dispose();
 			}

+ 2 - 4
samples/Cursor.hx

@@ -11,7 +11,7 @@ class Cursor extends hxd.App {
 		bmp.line(0, 31, 31, 31, 0xFFFF0000);
 		bmp.line(31, 0, 31, 31, 0xFF00FF00);
 
-		var cursors : Array<hxd.System.Cursor> = [Default,Button,Move,TextInput,Hide,Custom(new hxd.System.CustomCursor([bmp],0.,16,16))];
+		var cursors : Array<hxd.Cursor> = [Default,Button,Move,TextInput,Hide,Custom(new hxd.Cursor.CustomCursor([bmp],0.,16,16))];
 		var pos = 0;
 		for( c in cursors ) {
 			var i = new h2d.Interactive(100, 20, s2d);
@@ -24,9 +24,7 @@ class Cursor extends hxd.App {
 			i.backgroundColor = Std.random(0x1000000) | 0xFF000000;
 
 			var supported = true;
-			#if hl
-			if( c == Move ) supported = false;
-			#elseif js
+			#if js
 			if( c.match(Custom(_)) ) supported = false;
 			#end