瀏覽代碼

SceneEditor: custom tree styles

trethaller 7 年之前
父節點
當前提交
f7a099300d
共有 3 個文件被更改,包括 25 次插入19 次删除
  1. 3 0
      bin/defaultProps.json
  2. 8 0
      hide/comp/IconTree.hx
  3. 14 19
      hide/view/l3d/Level3D.hx

+ 3 - 0
bin/defaultProps.json

@@ -73,6 +73,9 @@
 	"l3d.colors": {
 		"zones": "#ff0000"
 	},
+	"l3d.treeStyles": {
+		"settings": {"color": "#ffffff", "font-weight": "bold"}
+	},
 
 	// FX editor
 	"fx.shaders": [

+ 8 - 0
hide/comp/IconTree.hx

@@ -12,6 +12,7 @@ typedef IconTreeItem<T> = {
 		@:optional var loaded : Bool;
 	};
 	@:optional var li_attr : Dynamic;
+	@:optional var a_attr : Dynamic;
 	@:optional @:noCompletion var id : String; // internal usage
 	@:optional @:noCompletion var absKey : String; // internal usage
 }
@@ -87,6 +88,7 @@ class IconTree<T:{}> extends Component {
 	public function init() {
 		(element:Dynamic).jstree({
 			core : {
+				animation: 50,
 				themes: {
 					name: "default-dark",
 					dots: true,
@@ -153,6 +155,12 @@ class IconTree<T:{}> extends Component {
 				applyStyle(item, el);
 			}
 		});
+		element.on("before_open.jstree", function(event, node) {
+			var lis = new Element(event.target).find("li");
+			for(li in lis) {
+				applyStyle(map.get(li.id).value, new Element(li));
+			}
+		});
 	}
 
 	function getRev( o : T ) {

+ 14 - 19
hide/view/l3d/Level3D.hx

@@ -590,25 +590,20 @@ class Level3D extends FileView {
 
 
 	function updateTreeStyle(p: PrefabElement, el: Element) {
-		// var layer = p.to(hide.prefab.l3d.Layer);
-		// if(layer != null) {
-		// 	var color = "#" + StringTools.hex(layer.color & 0xffffff, 6);
-		// 	el.find("i.jstree-themeicon").first().css("color", color);
-		// 	el.find("a").first().toggleClass("locked", layer.locked);
-		// 	refreshLayerIcon(layer);
-		// }
-
-		var dispColor = getDisplayColor(p);
-		var colorStr = dispColor != null ? "#" + StringTools.hex(dispColor & 0xffffff, 6) : "";
-		el.find("a").first().css("color", colorStr);
-		// var type = getCdbTypeId(p);
-		// if(type != null) {
-		// 	var colors = ide.currentProps.get("l3d.colors");
-		// 	var color = Reflect.field(colors, type);
-		// 	if(color != null) {
-		// 		el.find("a").first().css("color", color);
-		// 	}
-		// }
+		var styles = ide.currentProps.get("l3d.treeStyles");
+		var style: Dynamic = null;
+		var typeId = getCdbTypeId(p);
+		if(typeId != null) {
+			style = Reflect.field(styles, typeId);
+		}
+		if(style == null) {
+			style = Reflect.field(styles, p.name);
+		}
+		var a = el.find("a").first();
+		if(style == null)
+			a.removeAttr("style");
+		else
+			a.css(style);
 	}
 
 	function onPrefabChange(p: PrefabElement, ?pname: String) {