2
0
Nicolas Cannasse 8 жил өмнө
parent
commit
47ad1763e0

+ 23 - 3
hide/ui/View.hx

@@ -17,6 +17,7 @@ class View<T> extends hide.comp.Component {
 	var keys(get,null) : Keys;
 	var keys(get,null) : Keys;
 	var props(get,null) : Props;
 	var props(get,null) : Props;
 	var undo = new hide.ui.UndoHistory();
 	var undo = new hide.ui.UndoHistory();
+	public var viewClass(get, never) : String;
 	public var defaultOptions(get,never) : ViewOptions;
 	public var defaultOptions(get,never) : ViewOptions;
 
 
 	var contentWidth(get,never) : Int;
 	var contentWidth(get,never) : Int;
@@ -40,14 +41,33 @@ class View<T> extends hide.comp.Component {
 	}
 	}
 
 
 	public function getTitle() {
 	public function getTitle() {
-		var name = Type.getClassName(Type.getClass(this));
-		return name.split(".").pop();
+		return viewClass.split(".").pop();
 	}
 	}
 
 
 	public function onBeforeClose() {
 	public function onBeforeClose() {
 		return true;
 		return true;
 	}
 	}
 
 
+	function get_viewClass() {
+		return Type.getClassName(Type.getClass(this));
+	}
+
+	public function setClipboard( v : Dynamic, ?type : String ) {
+		nw.Clipboard.get().set(ide.toJSON({ type : type == null ? viewClass : type, value : v }));
+	}
+
+	public function hasClipboard( ?type : String ) {
+		if( type == null ) type = viewClass;
+		var v : Dynamic = try haxe.Json.parse(nw.Clipboard.get().get()) catch( e : Dynamic ) null;
+		return v != null && v.type == type;
+	}
+
+	public function getClipboard( ?type : String ) : Dynamic {
+		if( type == null ) type = viewClass;
+		var v : Dynamic = try haxe.Json.parse(nw.Clipboard.get().get()) catch( e : Dynamic ) null;
+		return v == null || v.type != type ? null : v.value;
+	}
+
 	function syncTitle() {
 	function syncTitle() {
 		container.setTitle(getTitle());
 		container.setTitle(getTitle());
 	}
 	}
@@ -82,7 +102,7 @@ class View<T> extends hide.comp.Component {
 	}
 	}
 
 
 	public function onDisplay() {
 	public function onDisplay() {
-		root.text(Type.getClassName(Type.getClass(this))+(state == null ? "" : " "+state));
+		root.text(viewClass+(state == null ? "" : " "+state));
 	}
 	}
 
 
 	public function onResize() {
 	public function onResize() {

+ 11 - 0
hide/view/Particles3D.hx

@@ -140,6 +140,17 @@ class Particles3D extends FileView {
 			}
 			}
 			new hide.comp.ContextMenu([
 			new hide.comp.ContextMenu([
 				{ label : "Enable", checked : g.enable, click : function() { g.enable = !g.enable; e.find("[field=enable]").prop("checked", g.enable); } },
 				{ label : "Enable", checked : g.enable, click : function() { g.enable = !g.enable; e.find("[field=enable]").prop("checked", g.enable); } },
+				{ label : "Copy", click : function() setClipboard(g.save()) },
+				{ label : "Paste", enabled : hasClipboard(), click : function() {
+					var prev = g.save();
+					var next = getClipboard();
+					g.load(@:privateAccess h3d.parts.GpuParticles.VERSION, next);
+					undo.change(Custom(function(undo) {
+						g.load(@:privateAccess h3d.parts.GpuParticles.VERSION, undo ? prev : next);
+						initProperties();
+					}));
+					initProperties();
+				} },
 				{ label : "MoveUp", enabled : index > 0, click : function() moveIndex(-1) },
 				{ label : "MoveUp", enabled : index > 0, click : function() moveIndex(-1) },
 				{ label : "MoveDown", enabled : index < groups.length - 1, click : function() moveIndex(1) },
 				{ label : "MoveDown", enabled : index < groups.length - 1, click : function() moveIndex(1) },
 				{ label : "Delete", click : function() {
 				{ label : "Delete", click : function() {

+ 20 - 0
libs/nw/Clipboard.hx

@@ -0,0 +1,20 @@
+package nw;
+
+@:enum abstract ClipboardType(String) {
+	var Text = "text";
+	var Png = "png";
+	var Jpeg = "jpeg";
+	var Html = "html";
+	var Rtf = "rtf";
+}
+
+extern class Clipboard {
+
+	function set( data : String, ?type : ClipboardType, ?raw : Bool ) : Void;
+	function get( ?type : ClipboardType, ?raw : Bool ) : String;
+	function readAvailableTypes() : Array<ClipboardType>;
+	function clear() : Void;
+
+	static function get() : Clipboard;
+
+}