2
0
Эх сурвалжийг харах

more renames + started on panel events

Nicolas Cannasse 9 жил өмнө
parent
commit
c0dcace1fc

+ 8 - 8
hxd/inspect/SceneInspector.hx → hxd/inspect/Inspector.hx

@@ -3,7 +3,7 @@ import cdb.jq.JQuery;
 import hxd.inspect.Property;
 
 private class DrawEvent implements h3d.IDrawable {
-	var i : SceneInspector;
+	var i : Inspector;
 	public function new(i) {
 		this.i = i;
 	}
@@ -43,15 +43,15 @@ class Tool {
 	}
 }
 
-class SceneInspector {
+class Inspector {
 
 	static var CSS = hxd.res.Embed.getFileContent("hxd/inspect/inspect.css");
-	static var current : SceneInspector;
+	static var current : Inspector;
 
 	public var scene(default, set) : h3d.scene.Scene;
 	public var connected(get, never): Bool;
 
-	var inspect : PropInspector;
+	var inspect : PropManager;
 	var jroot : JQuery;
 	var event : DrawEvent;
 	var oldLog : Dynamic -> haxe.PosInfos -> Void;
@@ -75,8 +75,8 @@ class SceneInspector {
 		savedFile = "sceneProps.js";
 		state = new Map();
 		oldLog = haxe.Log.trace;
-		//haxe.Log.trace = onTrace;
-		inspect = new PropInspector(host, port);
+		haxe.Log.trace = onTrace;
+		inspect = new PropManager(host, port);
 		inspect.resolveProps = resolveProps;
 		inspect.onChange = onChange;
 		inspect.handleKey = onKey;
@@ -162,7 +162,7 @@ class SceneInspector {
 				vstr = [for( v in pos.customParams ) Std.string(v)].join(",");
 			} else
 				vstr = Std.string(v);
-			J("<pre>").addClass("line").text(pos.fileName+"(" + pos.lineNumber + ") : " + vstr).appendTo(J("#log"));
+			J("<pre>").addClass("line").text(pos.fileName+"(" + pos.lineNumber + ") : " + vstr).appendTo(logPanel.content);
 		}
 	}
 
@@ -301,7 +301,7 @@ class SceneInspector {
 		}
 	}
 
-	function fillProps( n : TreeNode ) {
+	public function editProps( n : Node ) {
 		var t = inspect.makeProps(n.getFullPath(), n.props());
 		propsPanel.j.text("");
 		propsPanel.parent = n;

+ 1 - 1
hxd/inspect/Node.hx

@@ -16,7 +16,7 @@ class Node {
 	}
 
 	function getJRoot() {
-		return @:privateAccess SceneInspector.current.jroot;
+		return @:privateAccess Inspector.current.jroot;
 	}
 
 	function initContent() {

+ 13 - 4
hxd/inspect/Panel.hx

@@ -2,7 +2,7 @@ package hxd.inspect;
 
 class Panel extends Node {
 
-	var inspect : SceneInspector;
+	var inspect : Inspector;
 	public var visible(default, null) : Bool;
 	public var caption(default, set) : String;
 	public var content : cdb.jq.JQuery;
@@ -11,7 +11,7 @@ class Panel extends Node {
 		super(name, panelGroup);
 		this.caption = caption;
 		@:privateAccess {
-			inspect = SceneInspector.current;
+			inspect = Inspector.current;
 			inspect.panels.push(this);
 			inspect.rootNodes.push(this);
 		}
@@ -20,6 +20,7 @@ class Panel extends Node {
 
 	public function dock( to : cdb.jq.JQuery, align : cdb.jq.Message.DockDirection, ?size : Float ) {
 		j.dock(to.get(), align, size);
+		j.bind("panelclose", function(_) onClose());
 		visible = true;
 	}
 
@@ -28,9 +29,16 @@ class Panel extends Node {
 		return caption = c;
 	}
 
+	override function getJRoot() {
+		if( j == null ) return super.getJRoot();
+		return j;
+	}
+
 	override function initContent() {
-		j = getJRoot().query('<div>');
+		var root = getJRoot();
+		j = root.query('<div>');
 		j.addClass("panel");
+		content = j;
 	}
 
 	override function addChild(n:Node)	{
@@ -54,10 +62,11 @@ class Panel extends Node {
 
 	public dynamic function onClose() {
 		visible = false;
+		trace("TODO:UNDOCK");
 	}
 
 	public function show() {
-		trace("TODO");
+		trace("TODO:REDOCK");
 		visible = true;
 	}
 

+ 2 - 2
hxd/inspect/PropInspector.hx → hxd/inspect/PropManager.hx

@@ -4,7 +4,7 @@ import hxd.inspect.Property;
 
 private typedef History = { path : String, oldV : Dynamic, newV : Dynamic };
 
-class PropInspector extends cdb.jq.Client {
+class PropManager extends cdb.jq.Client {
 
 	public var host : String = "127.0.0.1";
 	public var port = 6669;
@@ -184,7 +184,7 @@ class PropInspector extends cdb.jq.Client {
 
 	public function makeProps( basePath : String, props : Array<Property>, expandLevel = 1 ) {
 		var t = J("<table>");
-		t.addClass("props");
+		t.addClass("iprops");
 		refreshProps = function() {
 			t.text("");
 			for( p in props )

+ 3 - 3
hxd/inspect/ScenePanel.hx

@@ -24,7 +24,7 @@ private class SceneObject extends TreeNode {
 		var idx = Lambda.indexOf(@:privateAccess o.parent.childs, o);
 		var count = 0;
 		for( i in 0...idx )
-			if( objectName(o) == name )
+			if( objectName(o.parent.getChildAt(i)) == name )
 				count++;
 		if( count > 0 )
 			name += "@" + count;
@@ -82,7 +82,7 @@ class ScenePanel extends Panel {
 		n.icon = icon;
 		n.props = getProps;
 		if( getProps != null )
-			n.onSelect = function() @:privateAccess SceneInspector.current.fillProps(n);
+			n.onSelect = function() inspect.editProps(n);
 		return n;
 	}
 
@@ -126,7 +126,7 @@ class ScenePanel extends Panel {
 			var icon = getObjectIcon(o);
 			so.icon = icon == null ? "circle-o" : getObjectIcon(o);
 			so.props = function() return getObjectProps(o);
-			so.onSelect = function() @:privateAccess SceneInspector.current.fillProps(so);
+			so.onSelect = function() inspect.editProps(so);
 		}
 
 		if( so.parent != p ) so.parent = p;

+ 17 - 13
hxd/inspect/StatsPanel.hx

@@ -32,7 +32,7 @@ class StatsPanel extends Panel {
 				<tr>
 					<th>
 						<span>Total</span>
-						<div id="totMemCount"></div>
+						<span id="totMemCount"></span>
 					</th>
 					<td id="totMem"></td>
 				</tr>
@@ -40,7 +40,7 @@ class StatsPanel extends Panel {
 					<th class="button hidden">
 						<i class="fa fa-arrow-right"/>
 						<span id="bufMemTitle">Buffers</span>
-						<div id="bufMemCount"></div>
+						<span id="bufMemCount"></span>
 					</th>
 					<td id="bufMem"></td>
 				</tr>
@@ -48,7 +48,7 @@ class StatsPanel extends Panel {
 					<th class="button hidden">
 						<i class="fa fa-arrow-right"/>
 						<span id="texMemTitle">Textures</span>
-						<div id="texMemCount"></div>
+						<span id="texMemCount"></span>
 					</th>
 					<td id="texMem"></td>
 				</tr>
@@ -119,17 +119,21 @@ class StatsPanel extends Panel {
 				var elements = [for( k in m ) k];
 				elements.sort(function(e1, e2) return e1.mem - e2.mem);
 				for( e in elements) {
-					e.mem >>= 10;
 					var newElement = j.query("<tr>");
 					newElement.addClass("subMem");
 					newElement.addClass("detail_" + id);
-					newElement.html("<th>" + e.name + "<div>[" + e.count + "]</div></th><td>" + (e.mem > 1024 ? Math.fmt(e.mem / 1024) + " MB" : e.mem + " KB") + "</td>");
+					newElement.html("<th>" + e.name + "<span>[" + e.count + "]</span></th><td>" + fmtSize(e.mem) + "</td>");
 					newElement.insertAfter(button.parent());
 				}
 			}
 		#end
 	}
 
+	function fmtSize( size : Float ) {
+		size /= 1024;
+		return size > 1024 ? Math.fmt(size / 1024) + " MB" : Math.ceil(size) + " KB";
+	}
+
 	inline function numberFormat(v : Int) {
 		var tmp = Std.string(v);
 		var n = Math.ceil(tmp.length / 3);
@@ -161,14 +165,14 @@ class StatsPanel extends Panel {
 
 		var stats = engine.mem.stats();
 		var idx = (stats.totalMemory - (stats.textureMemory + stats.managedMemory));
-		var sum : Float = (idx + stats.managedMemory) >> 10;
-		var freeMem : Float = stats.freeManagedMemory >> 10;
-		var totTex : Float = stats.textureMemory >> 10;
-		var totalMem : Float = stats.totalMemory >> 10;
-
-		bufMem.text((sum > 1024 ?  Math.fmt(sum / 1024) + " MB" : totTex + " KB") + " (" + (freeMem > 1024 ?  Math.fmt(freeMem / 1024) + " MB" : freeMem + " KB") + " free)");
-		texMem.text(totTex > 1024 ?  Math.fmt(totTex / 1024) + " MB" : totTex + " KB");
-		totMem.text(totalMem > 1024 ?  Math.fmt(totalMem / 1024) + " MB" : totTex + " KB");
+		var sum : Float = idx + stats.managedMemory;
+		var freeMem : Float = stats.freeManagedMemory;
+		var totTex : Float = stats.textureMemory;
+		var totalMem : Float = stats.totalMemory;
+
+		bufMem.text(fmtSize(sum) + " (" + fmtSize(freeMem) + " free)");
+		texMem.text(fmtSize(totTex));
+		totMem.text(fmtSize(totalMem));
 		bufMemTitle.text("Buffers");
 		bufMemCount.text("[" + Std.string(stats.bufferCount) + "]");
 		texMemTitle.text("Textures");

+ 9 - 9
hxd/inspect/inspect.css

@@ -123,10 +123,10 @@
 .jqpage .panel.scene>ul.elt, .dialog-floating .panel.scene>ul.elt {
 	padding : 5px;
 }
-.jqpage table.props tr.pgroup, .dialog-floating table.props tr.pgroup {
+.jqpage table.iprops tr.pgroup, .dialog-floating table.iprops tr.pgroup {
 	cursor : pointer;
 }
-.jqpage table.props tr.pgroup th, .dialog-floating table.props tr.pgroup th {
+.jqpage table.iprops tr.pgroup th, .dialog-floating table.iprops tr.pgroup th {
 	text-align : left;
 	background-color : #555;
 	color : #bbb;
@@ -134,33 +134,33 @@
 	padding : 2px 4px;
 	cursor : pointer;
 }
-.jqpage table.props tr.disable, .dialog-floating table.props tr.disable {
+.jqpage table.iprops tr.disable, .dialog-floating table.iprops tr.disable {
 	opacity : 0.5;
 	filter : alpha(opacity=50);
 	zoom : 1;
 }
-.jqpage table.props td, .dialog-floating table.props td {
+.jqpage table.iprops td, .dialog-floating table.iprops td {
 	height : 24px;
 }
-.jqpage table.props td input, .jqpage table.props td select, .dialog-floating table.props td input, .dialog-floating table.props td select {
+.jqpage table.iprops td input, .jqpage table.iprops td select, .dialog-floating table.iprops td input, .dialog-floating table.iprops td select {
 	padding-left : 0px;
 	height : 18px;
 	border : 1px solid #888;
 	width : 100%;
 }
-.jqpage table.props tr.active td, .dialog-floating table.props tr.active td {
+.jqpage table.iprops tr.active td, .dialog-floating table.iprops tr.active td {
 	font-weight : bold;
 }
-.jqpage table.props tr.ptexture img, .dialog-floating table.props tr.ptexture img {
+.jqpage table.iprops tr.ptexture img, .dialog-floating table.iprops tr.ptexture img {
 	max-width : 128px;
 	max-height : 128px;
 }
-.jqpage table.props tr.pcolor td .modal, .dialog-floating table.props tr.pcolor td .modal {
+.jqpage table.iprops tr.pcolor td .modal, .dialog-floating table.iprops tr.pcolor td .modal {
 	opacity : 0;
 	filter : alpha(opacity=0);
 	zoom : 1;
 }
-.jqpage table.props tr.pcolor td .color, .dialog-floating table.props tr.pcolor td .color {
+.jqpage table.iprops tr.pcolor td .color, .dialog-floating table.iprops tr.pcolor td .color {
 	display : inline-block;
 	zoom : 1;
 	*display : inline;

+ 2 - 1
hxd/inspect/inspect.hss

@@ -128,7 +128,8 @@
 		padding : 5px;
 	}
 
-	table.props {
+	table.iprops {
+
 		tr.pgroup {
 			cursor : pointer;
 			th {

+ 6 - 5
samples/skin/Main.hx

@@ -33,7 +33,7 @@ class Main extends hxd.App {
 		// this is an example for connecting to scene inspector
 		// and enable extra properties
 		// this requires to compile with -lib castle and run CDB
-		var i = new hxd.net.SceneInspector(s3d);
+		var i = new hxd.inspect.Inspector(s3d);
 
 		var delta = s3d.camera.pos.sub(s3d.camera.target);
 		delta.z = 0;
@@ -41,7 +41,7 @@ class Main extends hxd.App {
 		var dist = delta.length();
 
 		// add node to scene graph
-		var n = i.addNode("Rotation", "repeat", function() {
+		var n = i.scenePanel.addNode("Rotation", "repeat", function() {
 			return [
 				PFloat("v", function() return angle, function(v) {
 					angle = v;
@@ -52,14 +52,15 @@ class Main extends hxd.App {
 					var j = i.J("<button>");
 					j.text("Click Me!");
 					j.click(function(_) {
-						var j = i.createPanel("New Panel");
-						j.text("Nothing to see there.");
+						var j = new hxd.inspect.Panel(null,"New Panel");
+						j.content.text("Nothing to see there.");
+						j.show();
 					});
 					return j;
 				})
 			];
 		});
-		i.addNode("Test", "", n);
+		i.scenePanel.addNode("Test", "", n);
 		i.addTool("Exit", "bomb", function() {
 			hxd.System.exit();
 		});