Browse Source

Auto-expand created component section, removing old component/node inspectors, and data bindings

Josh Engebretson 10 years ago
parent
commit
cd1c214e89

+ 0 - 624
Script/AtomicEditor/ui/frames/inspector/ComponentInspector.ts

@@ -1,624 +0,0 @@
-//
-// Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
-// LICENSE: Atomic Game Engine Editor and Tools EULA
-// Please see LICENSE_ATOMIC_EDITOR_AND_TOOLS.md in repository root for
-// license information: https://github.com/AtomicGameEngine/AtomicGameEngine
-//
-
-import ScriptWidget = require("ui/ScriptWidget");
-import DataBinding = require("./DataBinding");
-import InspectorUtils = require("./InspectorUtils");
-import EditorUI = require("ui/EditorUI");
-import CSComponentClassSelector = require("./CSComponentClassSelector");
-
-class ComponentInspector extends Atomic.UISection {
-
-    constructor() {
-
-        super();
-
-        this.subscribeToEvent("WidgetEvent", (data) => this.handleWidgetEvent(data));
-    }
-
-    handleWidgetEvent(ev: Atomic.UIWidgetEvent) {
-
-        var handled = false;
-
-        for (var i = 0; i < this.bindings.length; i++) {
-
-            if (this.bindings[i].handleWidgetEvent(ev)) {
-
-                handled = true;
-
-            }
-
-        }
-
-        // return if handled
-        return handled;
-
-    }
-
-    addAttr(attr: Atomic.AttributeInfo, before: Atomic.UIWidget = null, after: Atomic.UIWidget = null): Atomic.UILayout {
-
-        if (attr.mode & Atomic.AM_NOEDIT)
-            return null;
-
-        var binding = DataBinding.createBinding(this.component, attr);
-
-        if (!binding)
-            return null;
-
-        var attrLayout = new Atomic.UILayout();
-
-        attrLayout.layoutDistribution = Atomic.UI_LAYOUT_DISTRIBUTION_GRAVITY;
-
-        var name = new Atomic.UITextField();
-        name.textAlign = Atomic.UI_TEXT_ALIGN_LEFT;
-        name.skinBg = "InspectorTextAttrName";
-        name.layoutParams = this.atlp;
-
-        if (attr.type == Atomic.VAR_VECTOR3 || attr.type == Atomic.VAR_COLOR ||
-            attr.type == Atomic.VAR_QUATERNION) {
-            attrLayout.axis = Atomic.UI_AXIS_Y;
-            attrLayout.layoutPosition = Atomic.UI_LAYOUT_POSITION_LEFT_TOP;
-            attrLayout.skinBg = "InspectorVectorAttrLayout";
-        }
-
-        var bname = attr.name;
-
-        if (bname == "Is Enabled")
-            bname = "Enabled";
-
-        name.text = bname;
-        name.fontDescription = this.fd;
-
-        attrLayout.addChild(name);
-
-        attrLayout.addChild(binding.widget);
-
-        if (before)
-            this.attrsVerticalLayout.addChildBefore(attrLayout, before);
-        else if (after)
-            this.attrsVerticalLayout.addChildAfter(attrLayout, after);
-        else
-            this.attrsVerticalLayout.addChild(attrLayout);
-
-
-        this.bindings.push(binding);
-
-        return attrLayout;
-    }
-
-    inspect(component: Atomic.Component) {
-
-        this.component = component;
-
-        this.text = component.typeName;
-
-        this.subscribeToEvent(component, "SceneEditStateChange", (data) => this.handleSceneEditStateChangeEvent(data));
-
-        // For JSComponents append the filename
-        if (component.typeName == "JSComponent") {
-
-            var jsc = <Atomic.JSComponent>component;
-
-            if (jsc.componentFile) {
-                var pathInfo = Atomic.splitPath(jsc.componentFile.name);
-                this.text = "JS - " + pathInfo.fileName;
-            }
-
-        }
-
-        // For CSComponents append the classname
-        if (component.typeName == "CSComponent") {
-
-            var csc = <AtomicNET.CSComponent>component;
-
-            if (csc.componentClassName) {
-                this.text = "CS - " + csc.componentClassName;
-            }
-        }
-
-        // don't expand by default
-        this.value = 0;
-
-        var fd = this.fd = new Atomic.UIFontDescription();
-        fd.id = "Vera";
-        fd.size = 11;
-
-        var nlp = this.nlp = new Atomic.UILayoutParams();
-        nlp.width = 304;
-
-        // atttribute name layout param
-        var atlp = this.atlp = new Atomic.UILayoutParams();
-        atlp.width = 100;
-
-
-        var attrsVerticalLayout = this.attrsVerticalLayout = new Atomic.UILayout(Atomic.UI_AXIS_Y);
-        attrsVerticalLayout.spacing = 3;
-        attrsVerticalLayout.layoutPosition = Atomic.UI_LAYOUT_POSITION_LEFT_TOP;
-        attrsVerticalLayout.layoutSize = Atomic.UI_LAYOUT_SIZE_AVAILABLE;
-
-        this.contentRoot.addChild(attrsVerticalLayout);
-
-        var attrs = component.getAttributes();
-
-        for (var i in attrs) {
-            this.addAttr(attrs[i]);
-        }
-
-        // custom component UI
-        if (component.typeName == "PrefabComponent") {
-            this.addPrefabUI(attrsVerticalLayout);
-        }
-
-        if (component.typeName == "Light") {
-            this.addLightCascadeParametersUI(attrsVerticalLayout);
-        }
-
-        if (component.typeName == "CollisionShape") {
-            this.addCollisionShapeUI(attrsVerticalLayout);
-        }
-
-
-        if (component.typeName == "JSComponent") {
-            // auto expand JSComponents
-            this.value = 1;
-        }
-
-        if (component.typeName == "CSComponent") {
-            // auto expand CSComponents
-            this.value = 1;
-            this.addCSComponentUI(attrsVerticalLayout);
-
-            var csc = <AtomicNET.CSComponent>this.component;
-            var currentClassName = csc.componentClassName;
-
-            this.subscribeToEvent(component, "CSComponentClassChanged", (ev: AtomicNET.CSComponentClassChangedEvent) => {
-
-                if (currentClassName != ev.classname) {
-                    //console.log("CSComponent Class Name Changed ", currentClassName, " ", ev.classname);
-                    this.text = "CS - " + ev.classname;
-                    currentClassName = ev.classname;
-                    this.updateDataBindings();
-                }
-
-            });
-        }
-
-
-        if (component.typeName == "TileMap2D") {
-            this.addTilemap2DUI(attrsVerticalLayout);
-        }
-
-
-        if (component.typeName == "StaticModel" || component.typeName == "AnimatedModel" || component.typeName == "Skybox") {
-            this.addModelUI(attrsVerticalLayout, component.typeName);
-        }
-
-        if (component.typeName == "StaticSprite2D" || component.typeName == "AnimatedSprite2D") {
-            this.addSpriteUI(attrsVerticalLayout, component.typeName);
-        }
-
-
-        var deleteButton = this.deleteButton = new Atomic.UIButton();
-        deleteButton.text = "Delete Component";
-        deleteButton.fontDescription = fd;
-
-        deleteButton.onClick = () => {
-
-            var node = this.component.node;
-            this.component.remove();
-
-            this.visibility = Atomic.UI_WIDGET_VISIBILITY_GONE;
-
-            return true;
-
-        }
-
-        attrsVerticalLayout.addChild(deleteButton);
-
-        for (var i in this.bindings) {
-            this.bindings[i].setWidgetValueFromObject();
-            this.bindings[i].objectLocked = false;
-        }
-
-    }
-
-    updateDataBindings() {
-
-        var newBindings: Array<DataBinding> = new Array();
-        var foundAttr: Array<Atomic.AttributeInfo> = new Array();
-
-        var attrs = this.component.getAttributes();
-
-        // run through current attr bindings looking for ones to preserve
-        for (var i in this.bindings) {
-
-            var binding = this.bindings[i];
-
-            for (var j in attrs) {
-
-                var attr = <Atomic.AttributeInfo>attrs[j];
-
-                if (attr.name == binding.attrInfo.name && attr.type == binding.attrInfo.type) {
-
-                    newBindings.push(binding);
-                    foundAttr.push(attr);
-                    break;
-
-                }
-
-            }
-
-        }
-
-        // remove bindings that no longer exist
-        for (var i in this.bindings) {
-
-            var binding = this.bindings[i];
-
-            if (newBindings.indexOf(binding) == -1) {
-
-                binding.widget.parent.remove();
-
-            }
-
-        }
-
-        // set new bindings, additional bindings may be added below
-        this.bindings = newBindings;
-
-        // add new attr
-        var curAttrLayout:Atomic.UILayout = null;
-        for (var i in attrs) {
-
-            var attr = attrs[i];
-
-            if (foundAttr.indexOf(attr) == -1) {
-
-                if (!curAttrLayout)
-                  curAttrLayout = this.addAttr(attr, this.deleteButton);
-                else
-                  curAttrLayout = this.addAttr(attr, null, curAttrLayout);
-
-            }
-
-        }
-
-        for (var i in this.bindings) {
-            this.bindings[i].setWidgetValueFromObject();
-            this.bindings[i].objectLocked = false;
-        }
-
-    }
-
-    updateWidgetValues() {
-
-      for (var i in this.bindings) {
-          this.bindings[i].objectLocked = true;
-          this.bindings[i].setWidgetValueFromObject();
-          this.bindings[i].objectLocked = false;
-      }
-
-    }
-
-    handleSceneEditStateChangeEvent(ev) {
-
-      this.updateWidgetValues();
-
-    }
-
-    // Move these to a mixing class
-
-    addPrefabUI(layout: Atomic.UILayout) {
-
-    }
-
-    acceptAssetDrag(importerTypeName: string, ev: Atomic.DragEndedEvent): ToolCore.AssetImporter {
-
-        var dragObject = ev.dragObject;
-
-        if (dragObject.object && dragObject.object.typeName == "Asset") {
-
-            var asset = <ToolCore.Asset>dragObject.object;
-
-            if (asset.importerTypeName == importerTypeName) {
-                return asset.importer;
-            }
-
-        }
-
-        return null;
-
-    }
-
-    createMaterialClosure(layout: Atomic.UILayout, staticModel: Atomic.StaticModel, index: number) {
-
-        var o = InspectorUtils.createAttrEditFieldWithSelectButton("Material " + index, layout);
-        var materialField = o.editField;
-        materialField.readOnly = true;
-
-        var select = o.selectButton;
-
-        select.onClick = () => {
-
-            EditorUI.getModelOps().showResourceSelection("Select Material", "MaterialImporter", function(asset: ToolCore.Asset) {
-
-                staticModel.setMaterialIndex(index, <Atomic.Material>Atomic.cache.getResource("Material", asset.path));
-
-                if (staticModel.getMaterial())
-                    materialField.text = staticModel.getMaterial().name;
-                else
-                    materialField.text = "";
-
-            });
-
-        }
-
-        var material = staticModel.getMaterial();
-
-        if (material) {
-
-            materialField.text = material.name;
-
-        }
-
-        // handle dropping of material on field
-        materialField.subscribeToEvent(materialField, "DragEnded", (ev: Atomic.DragEndedEvent) => {
-
-            if (ev.target == materialField) {
-
-                var importer = this.acceptAssetDrag("MaterialImporter", ev);
-
-                if (importer) {
-
-                    var materialImporter = <ToolCore.MaterialImporter>importer;
-                    var asset = materialImporter.asset;
-
-                    var material = <Atomic.Material>Atomic.cache.getResource("Material", asset.path);
-
-                    if (material) {
-
-                        staticModel.setMaterialIndex(index, material);
-                        ev.target.text = material.name;
-
-                    }
-                }
-            }
-
-        });
-
-
-    }
-
-    addModelUI(layout: Atomic.UILayout, typeName: string) {
-
-        var staticModel = <Atomic.StaticModel>this.component;
-
-        var numGeometries = staticModel.numGeometries;
-        if (typeName == "Skybox") {
-            numGeometries = 1;
-        }
-
-        for (var x = 0; x < numGeometries; x++) {
-
-            this.createMaterialClosure(layout, staticModel, x);
-
-        }
-
-
-    }
-
-
-    addSpriteUI(layout: Atomic.UILayout, typeName: string) {
-
-        var spriteComponent = <Atomic.StaticSprite2D>this.component;
-
-        var o = InspectorUtils.createAttrEditFieldWithSelectButton("Sprite", layout);
-        var field = o.editField;
-        field.readOnly = true;
-        field.text = spriteComponent.sprite ? spriteComponent.sprite.name : "";
-
-        var select = o.selectButton;
-
-        select.onClick = () => {
-
-            // this should allow selecting of sprite sheets as well
-            EditorUI.getModelOps().showResourceSelection("Select Sprite", "TextureImporter", function(asset: ToolCore.Asset) {
-
-                spriteComponent.sprite = <Atomic.Sprite2D>Atomic.cache.getResource("Sprite2D", asset.path);
-                if (spriteComponent.sprite)
-                    field.text = spriteComponent.sprite.name;
-
-            });
-
-        }
-
-        // handle dropping of component on field
-        field.subscribeToEvent(field, "DragEnded", (ev: Atomic.DragEndedEvent) => {
-
-            if (ev.target == field) {
-
-                var importer = this.acceptAssetDrag("TextureImporter", ev);
-
-                if (importer) {
-
-                    spriteComponent.sprite = <Atomic.Sprite2D>Atomic.cache.getResource("Sprite2D", importer.asset.path);
-                    if (spriteComponent.sprite)
-                        field.text = spriteComponent.sprite.name;
-
-                }
-            }
-
-        });
-
-
-    }
-
-    addTilemap2DUI(layout: Atomic.UILayout) {
-
-        var tilemap = <Atomic.TileMap2D>this.component;
-
-        var o = InspectorUtils.createAttrEditFieldWithSelectButton("TMX File", layout);
-        var field = o.editField;
-        field.readOnly = true;
-        field.text = tilemap.tmxFile ? tilemap.tmxFile.name : "";
-
-        var select = o.selectButton;
-
-        select.onClick = () => {
-
-            // this should allow selecting of sprite sheets as well
-            EditorUI.getModelOps().showResourceSelection("Select TMX File", "TMXImporter", function(asset: ToolCore.Asset) {
-
-                tilemap.tmxFile = <Atomic.TmxFile2D>Atomic.cache.getResource("TmxFile2D", asset.path);
-                if (tilemap.tmxFile)
-                    field.text = tilemap.tmxFile.name;
-            });
-
-        }
-
-        // handle dropping of component on field
-        field.subscribeToEvent(field, "DragEnded", (ev: Atomic.DragEndedEvent) => {
-
-            if (ev.target == field) {
-
-                var importer = this.acceptAssetDrag("TextureImporter", ev);
-
-                if (importer) {
-
-                    tilemap.tmxFile = <Atomic.TmxFile2D>Atomic.cache.getResource("TmxFile2D", importer.asset.path);
-                    if (tilemap.tmxFile)
-                        field.text = tilemap.tmxFile.name;
-
-                }
-            }
-
-        });
-
-    }
-
-    addLightCascadeParametersUI(layout: Atomic.UILayout) {
-
-        var light = <Atomic.Light>this.component;
-
-        var cascadeInfo = light.getShadowCascade();
-
-        var container = InspectorUtils.createContainer();
-        container.gravity = Atomic.UI_GRAVITY_ALL;
-        layout.addChild(container);
-
-        var panel = new Atomic.UILayout();
-        panel.axis = Atomic.UI_AXIS_Y;
-        panel.layoutSize = Atomic.UI_LAYOUT_SIZE_PREFERRED;
-        panel.layoutPosition = Atomic.UI_LAYOUT_POSITION_LEFT_TOP;
-        container.addChild(panel);
-
-        var label = InspectorUtils.createAttrName("CSM Splits:");
-        panel.addChild(label);
-
-        function createHandler(index, light, field) {
-
-            return function(data: Atomic.UIWidgetEvent) {
-
-                if (data.type == Atomic.UI_EVENT_TYPE_CHANGED) {
-
-                    this.light.setShadowCascadeParameter(this.index, Number(this.field.text));
-
-                }
-
-            }.bind({ index: index, light: light, field: field });
-
-        }
-
-        var field = InspectorUtils.createAttrEditField("Split 0", panel);
-        field.text = cascadeInfo[0].toString();
-        field.subscribeToEvent(field, "WidgetEvent", createHandler(0, light, field));
-
-        field = InspectorUtils.createAttrEditField("Split 1", panel);
-        field.text = cascadeInfo[1].toString();
-        field.subscribeToEvent(field, "WidgetEvent", createHandler(1, light, field));
-
-        field = InspectorUtils.createAttrEditField("Split 2", panel);
-        field.text = cascadeInfo[2].toString();
-        field.subscribeToEvent(field, "WidgetEvent", createHandler(2, light, field));
-
-        field = InspectorUtils.createAttrEditField("Split 3", panel);
-        field.text = cascadeInfo[3].toString();
-        field.subscribeToEvent(field, "WidgetEvent", createHandler(3, light, field));
-
-    }
-
-
-    addCollisionShapeUI(layout: Atomic.UILayout) {
-
-        var shape = <Atomic.CollisionShape>this.component;
-
-        var button = new Atomic.UIButton();
-        button.fontDescription = InspectorUtils.attrFontDesc;
-        button.gravity = Atomic.UI_GRAVITY_RIGHT;
-        button.text = "Set from Model";
-
-        button.onClick = () => {
-
-            var model = <Atomic.Drawable>shape.node.getComponent("StaticModel");
-            if (model) {
-                var box = model.boundingBox;
-                shape.setBox([box[3] - box[0], box[4] - box[1], box[5] - box[2]]);
-            }
-
-        };
-
-        layout.addChild(button);
-
-    }
-
-    addCSComponentUI(layout: Atomic.UILayout) {
-
-        for (var i in this.bindings) {
-
-            var binding = this.bindings[i];
-
-            // replace the Class widget with a editfield + select button
-            if (binding.attrInfo.name == "Class") {
-
-                var parent = binding.widget.parent;
-                var text = binding.widget.text;
-                binding.widget.parent.removeChild(binding.widget);
-                var o = InspectorUtils.createAttrEditFieldWithSelectButton("", parent);
-                o.editField.text = text;
-                binding.widget = o.editField;
-
-                o.selectButton.onClick = () => {
-
-                    var cscomponent = <AtomicNET.CSComponent>this.component;
-                    if (cscomponent.assemblyFile) {
-                        var selector = new CSComponentClassSelector(o.editField, cscomponent);
-                    }
-                }
-
-                break;
-            }
-        }
-    }
-
-    component: Atomic.Component;
-    bindings: Array<DataBinding> = new Array();
-
-    fd: Atomic.UIFontDescription;
-
-    nlp: Atomic.UILayoutParams;
-
-    // atttribute name layout param
-    atlp: Atomic.UILayoutParams;
-
-    attrsVerticalLayout: Atomic.UILayout;
-
-    deleteButton: Atomic.UIButton;
-
-
-}
-
-export = ComponentInspector;

+ 0 - 2
Script/AtomicEditor/ui/frames/inspector/CreateComponentButton.ts

@@ -5,8 +5,6 @@
 // license information: https://github.com/AtomicGameEngine/AtomicGameEngine
 //
 
-import ComponentInspector = require("./ComponentInspector");
-
 var audioCreateSource = new Atomic.UIMenuItemSource();
 
 audioCreateSource.addItem(new Atomic.UIMenuItem("SoundListener", "SoundListener"));

+ 0 - 541
Script/AtomicEditor/ui/frames/inspector/DataBinding.ts

@@ -1,541 +0,0 @@
-//
-// Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
-// LICENSE: Atomic Game Engine Editor and Tools EULA
-// Please see LICENSE_ATOMIC_EDITOR_AND_TOOLS.md in repository root for
-// license information: https://github.com/AtomicGameEngine/AtomicGameEngine
-//
-
-import InspectorUtils = require("./InspectorUtils");
-import EditorUI = require("ui/EditorUI");
-
-class DataBinding {
-
-    constructor(object: Atomic.Serializable, attrInfo: Atomic.AttributeInfo, widget: Atomic.UIWidget) {
-
-        this.object = object;
-        this.attrInfo = attrInfo;
-        this.widget = widget;
-
-    }
-
-    static createBinding(object: Atomic.Serializable, attrInfo: Atomic.AttributeInfo): DataBinding {
-
-        var widget: Atomic.UIWidget = null;
-
-        var fd = new Atomic.UIFontDescription();
-        fd.id = "Vera";
-        fd.size = 11;
-
-        var editWidgets: Array<Atomic.UIWidget> = [];
-
-        var enumSource = null;
-
-        if (attrInfo.type == Atomic.VAR_BOOL) {
-
-            var box = new Atomic.UICheckBox();
-            box.skinBg = "TBGreyCheckBox";
-            widget = box;
-        }
-        else if (attrInfo.type == Atomic.VAR_INT) {
-
-            if (attrInfo.enumNames.length) {
-
-                enumSource = new Atomic.UISelectItemSource();
-
-                for (var i in attrInfo.enumNames) {
-
-                    enumSource.addItem(new Atomic.UISelectItem(attrInfo.enumNames[i], (Number(i) + 1).toString()));
-
-                }
-
-                var button = new Atomic.UIButton();
-                button.fontDescription = fd;
-                button.text = "Enum Value!";
-                var lp = new Atomic.UILayoutParams();
-                lp.width = 140;
-                button.layoutParams = lp;
-
-                widget = button;
-
-            } else {
-
-                var field = new Atomic.UIEditField();
-                field.textAlign = Atomic.UI_TEXT_ALIGN_CENTER;
-                field.fontDescription = fd;
-                field.skinBg = "TBAttrEditorField";
-
-                var lp = new Atomic.UILayoutParams();
-                lp.width = 140;
-                field.layoutParams = lp;
-                editWidgets.push(field);
-                widget = field;
-            }
-
-        } else if (attrInfo.type == Atomic.VAR_FLOAT) {
-
-            var field = new Atomic.UIEditField();
-            field.textAlign = Atomic.UI_TEXT_ALIGN_CENTER;
-            field.fontDescription = fd;
-            field.skinBg = "TBAttrEditorField";
-
-            var lp = new Atomic.UILayoutParams();
-            lp.width = 140;
-            field.layoutParams = lp;
-            editWidgets.push(field);
-
-            widget = field;
-
-        }
-        else if (attrInfo.type == Atomic.VAR_STRING) {
-
-            var field = new Atomic.UIEditField();
-            field.textAlign = Atomic.UI_TEXT_ALIGN_LEFT;
-            field.skinBg = "TBAttrEditorField";;
-            field.fontDescription = fd;
-            var lp = new Atomic.UILayoutParams();
-            lp.width = 140;
-            field.layoutParams = lp;
-            editWidgets.push(field);
-            widget = field;
-        }
-        else if (attrInfo.type == Atomic.VAR_VECTOR3 || attrInfo.type == Atomic.VAR_QUATERNION) {
-            var layout = new Atomic.UILayout();
-            widget = layout;
-            layout.spacing = 0;
-
-            var lp = new Atomic.UILayoutParams();
-            lp.width = 100;
-
-            for (var i: any = 0; i < 3; i++) {
-                var select = new Atomic.UIInlineSelect();
-                editWidgets.push(select);
-                select.id = String(i + 1);
-                select.fontDescription = fd;
-                select.skinBg = "InspectorVectorAttrName";
-                select.setLimits(-10000000, 10000000);
-                var editlp = new Atomic.UILayoutParams();
-                editlp.minWidth = 60;
-                select.editFieldLayoutParams = editlp;
-                select.layoutParams = lp;
-                layout.addChild(select);
-            }
-
-        } else if (attrInfo.type == Atomic.VAR_COLOR) {
-            var layout = new Atomic.UILayout();
-            widget = layout;
-            layout.spacing = 0;
-
-            var lp = new Atomic.UILayoutParams();
-            lp.width = 70;
-
-            for (var i: any = 0; i < 4; i++) {
-
-                var select = new Atomic.UIInlineSelect();
-                editWidgets.push(select);
-                select.id = String(i + 1);
-                select.fontDescription = fd;
-                select.setLimits(-10000000, 10000000);
-                select.layoutParams = lp;
-                layout.addChild(select);
-            }
-
-        } else if (attrInfo.type == Atomic.VAR_VECTOR2) {
-            var layout = new Atomic.UILayout();
-            widget = layout;
-            layout.spacing = 0;
-
-            var lp = new Atomic.UILayoutParams();
-            lp.width = 100;
-
-            for (var i: any = 0; i < 2; i++) {
-                var select = new Atomic.UIInlineSelect();
-                editWidgets.push(select);
-                select.id = String(i + 1);
-                select.fontDescription = fd;
-                select.skinBg = "InspectorVectorAttrName";
-                select.setLimits(-10000000, 10000000);
-                var editlp = new Atomic.UILayoutParams();
-                editlp.minWidth = 60;
-                select.editFieldLayoutParams = editlp;
-                select.layoutParams = lp;
-                layout.addChild(select);
-            }
-
-        } else if (attrInfo.type == Atomic.VAR_RESOURCEREF && attrInfo.resourceTypeName) {
-
-            var importerName = ToolCore.assetDatabase.getResourceImporterName(attrInfo.resourceTypeName);
-
-            if (importerName) {
-
-                var parent = new Atomic.UILayout();
-                var o = InspectorUtils.createAttrEditFieldWithSelectButton("", parent);
-
-                parent.layoutSize = Atomic.UI_LAYOUT_SIZE_AVAILABLE;
-                parent.gravity = Atomic.UI_GRAVITY_LEFT_RIGHT;
-                parent.layoutDistribution = Atomic.UI_LAYOUT_DISTRIBUTION_GRAVITY;
-
-
-                var lp = new Atomic.UILayoutParams();
-                lp.width = 140;
-                o.editField.layoutParams = lp;
-                o.editField.readOnly = true;
-
-                // stuff editfield in so can be reference
-                parent["editField"] = o.editField;
-
-                var selectButton = o.selectButton;
-
-                selectButton.onClick = () => {
-
-                    EditorUI.getModelOps().showResourceSelection("Select " + attrInfo.resourceTypeName + " Resource", importerName, function(asset: ToolCore.Asset) {
-
-                        var resource = asset.getResource(attrInfo.resourceTypeName);
-
-                        object.setAttribute(attrInfo.name, resource);
-
-                        if (resource) {
-
-                            // use the asset name instead of the cache name
-                            if (asset.importer.requiresCacheFile())
-                                o.editField.text = asset.name;
-                            else
-                                o.editField.text = resource.name;
-                        }
-                        else
-                            o.editField.text = "";
-
-
-                    });
-
-                }
-
-                // handle dropping of component on field
-                o.editField.subscribeToEvent(o.editField, "DragEnded", (ev: Atomic.DragEndedEvent) => {
-
-                    if (ev.target == o.editField) {
-
-                        var dragObject = ev.dragObject;
-
-                        var importer;
-
-                        if (dragObject.object && dragObject.object.typeName == "Asset") {
-
-                            var asset = <ToolCore.Asset>dragObject.object;
-
-                            if (asset.importerTypeName == importerName) {
-                                importer = asset.importer;
-                            }
-
-                        }
-
-                        if (importer) {
-
-                            var resource = asset.getResource(attrInfo.resourceTypeName);
-                            object.setAttribute(attrInfo.name, resource);
-                            if (resource) {
-                                // use the asset name instead of the cache name
-                                if (asset.importer.requiresCacheFile())
-                                    o.editField.text = asset.name;
-                                else
-                                    o.editField.text = resource.name;
-                            }
-                            else
-                                o.editField.text = "";
-
-                        }
-                    }
-
-                });
-
-                widget = parent;
-            }
-
-        }
-
-        if (widget) {
-
-            var binding = new DataBinding(object, attrInfo, widget);
-            binding.enumSource = enumSource;
-
-            for (var i in editWidgets) {
-                editWidgets[i].subscribeToEvent(editWidgets[i], "UIWidgetEditComplete", (ev) => binding.handleUIWidgetEditCompleteEvent(ev));
-            }
-
-            return binding;
-
-        }
-
-        return null;
-
-    }
-
-    setWidgetValueFromObject() {
-        if (this.widgetLocked)
-            return;
-
-        this.widgetLocked = true;
-
-        Atomic.ui.blockChangedEvents = true;
-
-        var attrInfo = this.attrInfo;
-        var object = this.object;
-        var widget = this.widget;
-
-        if (attrInfo.type == Atomic.VAR_BOOL) {
-            var value = object.getAttribute(attrInfo.name);
-            widget.value = (value ? 1 : 0);
-        }
-        else if (attrInfo.type == Atomic.VAR_VECTOR3) {
-
-            var value = object.getAttribute(attrInfo.name);
-
-            for (var i = 0; i < 3; i++) {
-
-                var select = widget.getWidget((i + 1).toString());
-                if (select)
-                    select.value = value[i];
-            }
-
-        }
-        else if (attrInfo.type == Atomic.VAR_VECTOR2) {
-
-            var value = object.getAttribute(attrInfo.name);
-
-            for (var i = 0; i < 2; i++) {
-
-                var select = widget.getWidget((i + 1).toString());
-                if (select)
-                    select.value = value[i];
-            }
-
-        }
-        else if (attrInfo.type == Atomic.VAR_QUATERNION) {
-
-            var value = object.getAttribute(attrInfo.name);
-
-            for (var i = 0; i < 3; i++) {
-
-                var select = widget.getWidget((i + 1).toString());
-                if (select)
-                    select.value = value[i];
-            }
-
-        }
-        else if (attrInfo.type == Atomic.VAR_STRING) {
-            var value = object.getAttribute(attrInfo.name);
-            widget.text = value;
-        }
-        else if (attrInfo.type == Atomic.VAR_FLOAT) {
-            var value = object.getAttribute(attrInfo.name);
-            widget.text = parseFloat(value.toFixed(5)).toString();
-        }
-        else if (attrInfo.type == Atomic.VAR_INT) {
-            var value = object.getAttribute(attrInfo.name);
-
-            if (attrInfo.enumNames.length) {
-                widget.text = attrInfo.enumNames[value];
-            }
-            else {
-                widget.text = value.toString();
-            }
-        }
-        else if (attrInfo.type == Atomic.VAR_COLOR) {
-
-            var value = object.getAttribute(attrInfo.name);
-
-            for (var i = 0; i < 4; i++) {
-
-                var select = widget.getWidget((i + 1).toString());
-                if (select)
-                    select.value = value[i];
-            }
-
-        } else if (attrInfo.type == Atomic.VAR_RESOURCEREF && attrInfo.resourceTypeName) {
-
-            // for cached resources, use the asset name, otherwise use the resource path name
-            var resource = <Atomic.Resource>object.getAttribute(attrInfo.name);
-            var text = "";
-            if (resource) {
-                text = resource.name;
-                var asset = ToolCore.assetDatabase.getAssetByCachePath(resource.name);
-                if (asset)
-                    text = asset.name;
-            }
-
-            widget["editField"].text = text;
-
-        }
-
-        Atomic.ui.blockChangedEvents = false;
-        this.widgetLocked = false;
-
-    }
-
-    setObjectValueFromWidget(srcWidget: Atomic.UIWidget) {
-
-        if (this.objectLocked)
-            return;
-
-        this.objectLocked = true;
-
-        var widget = this.widget;
-        var object = this.object;
-        var attrInfo = this.attrInfo;
-        var type = attrInfo.type;
-
-        if (type == Atomic.VAR_BOOL) {
-
-            object.setAttribute(attrInfo.name, widget.value ? true : false);
-
-        } else if (type == Atomic.VAR_INT) {
-
-            object.setAttribute(attrInfo.name, Number(widget.text));
-
-        }
-        else if (type == Atomic.VAR_FLOAT) {
-
-            object.setAttribute(attrInfo.name, Number(widget.text));
-
-        }
-        else if (type == Atomic.VAR_STRING) {
-
-            object.setAttribute(attrInfo.name, widget.text);
-
-        } else if (type == Atomic.VAR_VECTOR3 && srcWidget) {
-
-            var value = object.getAttribute(attrInfo.name);
-
-            if (srcWidget.id == "1")
-                value[0] = srcWidget.value;
-            else if (srcWidget.id == "2")
-                value[1] = srcWidget.value;
-            else if (srcWidget.id == "3")
-                value[2] = srcWidget.value;
-
-            object.setAttribute(attrInfo.name, value);
-
-        } else if (type == Atomic.VAR_VECTOR2 && srcWidget) {
-
-            var value = object.getAttribute(attrInfo.name);
-
-            if (srcWidget.id == "1")
-                value[0] = srcWidget.value;
-            else if (srcWidget.id == "2")
-                value[1] = srcWidget.value;
-
-            object.setAttribute(attrInfo.name, value);
-
-        }
-        else if (type == Atomic.VAR_QUATERNION && srcWidget) {
-
-            var value = object.getAttribute(attrInfo.name);
-
-            if (srcWidget.id == "1")
-                value[0] = srcWidget.value;
-            else if (srcWidget.id == "2")
-                value[1] = srcWidget.value;
-            else if (srcWidget.id == "3")
-                value[2] = srcWidget.value;
-
-            object.setAttribute(attrInfo.name, value);
-
-        } else if (type == Atomic.VAR_COLOR && srcWidget) {
-
-            var value = object.getAttribute(attrInfo.name);
-
-            if (srcWidget.id == "1")
-                value[0] = srcWidget.value;
-            else if (srcWidget.id == "2")
-                value[1] = srcWidget.value;
-            else if (srcWidget.id == "3")
-                value[2] = srcWidget.value;
-            else if (srcWidget.id == "4")
-                value[3] = srcWidget.value;
-
-            object.setAttribute(attrInfo.name, value);
-        }
-
-        this.objectLocked = false;
-
-    }
-
-    handleUIWidgetEditCompleteEvent(ev) {
-
-      // TODO: once new base class stuff is in, should be able to check for type
-      var scene = this.object["scene"];
-
-      if (!scene)
-          return;
-
-      scene.sendEvent("SceneEditEnd");
-
-    }
-
-    handleWidgetEvent(ev: Atomic.UIWidgetEvent): boolean {
-
-        if (this.objectLocked)
-            return false;
-
-        if (ev.type == Atomic.UI_EVENT_TYPE_CLICK) {
-
-            var id = this.attrInfo.name + " enum popup";
-
-            if (ev.target.id == id) {
-
-                this.object.setAttribute(this.attrInfo.name, Number(ev.refid) - 1);
-                this.setWidgetValueFromObject();
-                // TODO: once new base class stuff is in, should be able to check for type
-                if (this.object["scene"])
-                    this.object["scene"].sendEvent("SceneEditEnd");
-
-
-            }
-
-            else if (this.widget == ev.target && this.attrInfo.enumNames.length) {
-
-
-                if (this.enumSource) {
-                    var menu = new Atomic.UIMenuWindow(ev.target, id);
-                    menu.show(this.enumSource);
-                }
-
-                return true;
-
-            }
-
-
-        }
-
-        if (ev.type == Atomic.UI_EVENT_TYPE_CHANGED) {
-
-            if (this.widget == ev.target || this.widget.isAncestorOf(ev.target)) {
-
-                this.setObjectValueFromWidget(ev.target);
-
-                // UIEditField and UIInline select changes are handled by edit complete event
-                // Otherwise, we would get multiple edit snapshots
-                if (ev.target.getTypeName() != "UIEditField" && ev.target.getTypeName() != "UIInlineSelect") {
-
-                    // TODO: once new base class stuff is in, should be able to check for type
-                    if (this.object["scene"])
-                        this.object["scene"].sendEvent("SceneEditEnd");
-                }
-
-                return true;
-            }
-        }
-
-        return false;
-
-    }
-
-    object: Atomic.Serializable;
-    objectLocked: boolean = true;
-    widgetLocked: boolean = false;
-    attrInfo: Atomic.AttributeInfo;
-    widget: Atomic.UIWidget;
-    enumSource: Atomic.UISelectItemSource;
-
-}
-
-export = DataBinding;

+ 0 - 1
Script/AtomicEditor/ui/frames/inspector/InspectorFrame.ts

@@ -7,7 +7,6 @@
 
 import EditorEvents = require("editor/EditorEvents");
 import ScriptWidget = require("ui/ScriptWidget");
-import DataBinding = require("./DataBinding");
 
 // inspectors
 

+ 0 - 471
Script/AtomicEditor/ui/frames/inspector/NodeInspector.ts

@@ -1,471 +0,0 @@
-//
-// Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
-// LICENSE: Atomic Game Engine Editor and Tools EULA
-// Please see LICENSE_ATOMIC_EDITOR_AND_TOOLS.md in repository root for
-// license information: https://github.com/AtomicGameEngine/AtomicGameEngine
-//
-
-import ScriptWidget = require("ui/ScriptWidget");
-import ComponentInspector = require("./ComponentInspector");
-import DataBinding = require("./DataBinding");
-import CreateComponentButton = require("./CreateComponentButton");
-import EditorEvents = require("editor/EditorEvents");
-
-interface ComponentState {
-
-    expanded: boolean;
-
-}
-
-interface NodeState {
-
-    expanded: boolean;
-    componentStates: { [id: number]: ComponentState };
-
-}
-
-class NodeInspector extends ScriptWidget {
-
-    constructor() {
-
-        super();
-
-        this.subscribeToEvent(this, "WidgetEvent", (ev) => this.handleWidgetEvent(ev));
-        this.subscribeToEvent("GizmoMoved", (ev) => this.handleGizmoModed(ev));
-        this.subscribeToEvent("Update", (ev) => this.handleUpdate(ev));
-
-    }
-
-    handleUpdate(ev) {
-
-        // to keep from spamming UI update we have a little delta on the gizmo updates
-        if (!this.node) {
-            this.gizmoMoved = false;
-            return;
-        }
-
-        if (this.gizmoMoved) {
-
-            if (this.updateDelta > 1.0) {
-
-                this.updateDelta = 0.0;
-
-            }
-            else {
-
-                this.updateDelta -= ev.timeStep;
-
-            }
-
-            if (this.updateDelta <= 0) {
-
-                for (var i in this.bindings) {
-
-                    this.bindings[i].setWidgetValueFromObject();
-
-                }
-
-                this.gizmoMoved = false;
-                this.updateDelta = 0;
-
-            }
-
-
-        }
-
-    }
-
-
-    handleGizmoModed(ev) {
-
-        if (!this.node) return;
-
-        this.gizmoMoved = true;
-
-        this.updateDelta += .3;
-
-    }
-
-    handleWidgetEvent(ev: Atomic.UIWidgetEvent) {
-
-        var handled = false;
-
-        for (var i = 0; i < this.bindings.length; i++) {
-
-            if (this.bindings[i].handleWidgetEvent(ev)) {
-
-                handled = true;
-
-            }
-
-        }
-
-        // return handled
-        return handled;
-
-    }
-
-    getPrefabComponent(node: Atomic.Node): Atomic.PrefabComponent {
-
-        if (node.getComponent("PrefabComponent"))
-            return <Atomic.PrefabComponent>node.getComponent("PrefabComponent");
-
-        if (node.parent)
-            return this.getPrefabComponent(node.parent);
-
-        return null;
-
-    }
-
-    detectPrefab(node: Atomic.Node): boolean {
-
-        if (node.getComponent("PrefabComponent"))
-            return true;
-
-        if (node.parent)
-            return this.detectPrefab(node.parent);
-
-        return false;
-
-    }
-
-    inspect(node: Atomic.Node) {
-
-        this.bindings = new Array();
-
-        this.node = node;
-
-        return;
-
-        /*
-        this.subscribeToEvent(node, "SceneEditStateChange", (data) => this.handleSceneEditStateChangeEvent(data));
-
-        this.isPrefab = this.detectPrefab(node);
-
-        var fd = new Atomic.UIFontDescription();
-        fd.id = "Vera";
-        fd.size = 11;
-
-        var nlp = new Atomic.UILayoutParams();
-        nlp.width = 304;
-
-        var nodeLayout = this.nodeLayout = new Atomic.UILayout();
-        nodeLayout.spacing = 4;
-
-        nodeLayout.layoutDistribution = Atomic.UI_LAYOUT_DISTRIBUTION_GRAVITY;
-        nodeLayout.layoutPosition = Atomic.UI_LAYOUT_POSITION_LEFT_TOP;
-        nodeLayout.layoutParams = nlp;
-        nodeLayout.axis = Atomic.UI_AXIS_Y;
-
-        // node attr layout
-
-        var nodeSection = new Atomic.UISection();
-        nodeSection.id = "node_section";
-        nodeSection.text = "Node";
-        nodeSection.value = 1;
-        nodeLayout.addChild(nodeSection);
-
-        var attrsVerticalLayout = new Atomic.UILayout(Atomic.UI_AXIS_Y);
-        attrsVerticalLayout.spacing = 3;
-        attrsVerticalLayout.layoutPosition = Atomic.UI_LAYOUT_POSITION_LEFT_TOP;
-        attrsVerticalLayout.layoutSize = Atomic.UI_LAYOUT_SIZE_AVAILABLE;
-
-        nodeSection.contentRoot.addChild(attrsVerticalLayout);
-
-        var attrs = node.getAttributes();
-
-        for (var i in attrs) {
-
-            var attr = <Atomic.AttributeInfo>attrs[i];
-
-            if (attr.mode & Atomic.AM_NOEDIT)
-                continue;
-
-            var binding = DataBinding.createBinding(node, attr);
-
-            if (!binding)
-                continue;
-
-            var attrLayout = new Atomic.UILayout();
-
-            attrLayout.layoutDistribution = Atomic.UI_LAYOUT_DISTRIBUTION_GRAVITY;
-
-            var name = new Atomic.UITextField();
-            name.textAlign = Atomic.UI_TEXT_ALIGN_LEFT;
-            name.skinBg = "InspectorTextAttrName";
-
-            if (attr.type == Atomic.VAR_VECTOR3 || attr.type == Atomic.VAR_COLOR ||
-                attr.type == Atomic.VAR_QUATERNION) {
-                attrLayout.axis = Atomic.UI_AXIS_Y;
-                attrLayout.layoutPosition = Atomic.UI_LAYOUT_POSITION_LEFT_TOP;
-                attrLayout.skinBg = "InspectorVectorAttrLayout";
-            }
-
-
-            var bname = attr.name;
-
-            if (bname == "Is Enabled")
-                bname = "Enabled";
-
-            name.text = bname;
-            name.fontDescription = fd;
-
-            attrLayout.addChild(name);
-
-            attrLayout.addChild(binding.widget);
-
-            attrsVerticalLayout.addChild(attrLayout);
-
-            this.bindings.push(binding);
-
-        }
-
-        // PREFAB
-
-        if (this.isPrefab) {
-
-            var name = new Atomic.UITextField();
-            name.textAlign = Atomic.UI_TEXT_ALIGN_LEFT;
-            name.skinBg = "InspectorTextAttrName";
-            name.text = "Prefab"
-            name.fontDescription = fd;
-
-            var prefabLayout = new Atomic.UILayout();
-            prefabLayout.layoutDistribution = Atomic.UI_LAYOUT_DISTRIBUTION_GRAVITY;
-
-            var saveButton = new Atomic.UIButton();
-            saveButton.text = "Save";
-            saveButton.fontDescription = fd;
-
-            saveButton.onClick = () => {
-
-                var prefabComponent = this.getPrefabComponent(this.node);
-
-                if (prefabComponent) {
-
-                    prefabComponent.savePrefab();
-
-                    return true;
-
-                }
-
-            }
-
-            var undoButton = new Atomic.UIButton();
-            undoButton.text = "Undo";
-            undoButton.fontDescription = fd;
-
-            undoButton.onClick = () => {
-
-                var prefabComponent = this.getPrefabComponent(this.node);
-
-                if (prefabComponent) {
-
-                    prefabComponent.undoPrefab();
-
-                    // our components are now recreated
-                    // need to handle this
-
-                    return true;
-
-                }
-
-            }
-
-            var breakButton = new Atomic.UIButton();
-            breakButton.text = "Break";
-            breakButton.fontDescription = fd;
-
-            breakButton.onClick = () => {
-
-                var prefabComponent = this.getPrefabComponent(this.node);
-
-                if (prefabComponent) {
-
-                    prefabComponent.breakPrefab();
-
-                    prefabLayout.visibility = Atomic.UI_WIDGET_VISIBILITY_GONE;
-
-                    return true;
-
-                }
-
-            }
-
-
-            prefabLayout.addChild(name);
-            prefabLayout.addChild(saveButton);
-            prefabLayout.addChild(undoButton);
-            prefabLayout.addChild(breakButton);
-
-            attrsVerticalLayout.addChild(prefabLayout);
-
-        }
-
-        // COMPONENTS
-
-        var components = node.getComponents();
-
-        for (var i in components) {
-
-            var component = components[i];
-
-            //if (component.isTemporary())
-            //  continue;
-
-            var ci = new ComponentInspector();
-            this.componentInspectors.push(ci);
-            ci.id = "component_section_" + component.id;
-
-            ci.inspect(component);
-
-            nodeLayout.addChild(ci);
-
-        }
-
-        this.addChild(nodeLayout);
-
-        var button = new CreateComponentButton(node);
-
-        nodeLayout.addChild(button);
-
-        for (var i in this.bindings) {
-            this.bindings[i].setWidgetValueFromObject();
-            this.bindings[i].objectLocked = false;
-        }
-
-        this.loadState();
-        */
-
-    }
-
-    updateWidgetValues(components: boolean = false) {
-
-        for (var i in this.bindings) {
-            this.bindings[i].objectLocked = true;
-            this.bindings[i].setWidgetValueFromObject();
-            this.bindings[i].objectLocked = false;
-        }
-
-        if (components) {
-
-            for (var i in this.componentInspectors) {
-
-                this.componentInspectors[i].updateWidgetValues();
-
-            }
-
-        }
-
-    }
-
-    handleSceneEditStateChangeEvent(ev) {
-
-        this.updateWidgetValues();
-
-    }
-
-    saveState() {
-
-        var node = this.node;
-
-        if (!node.scene)
-            return;
-
-        var nodeStates = NodeInspector.nodeStates[node.scene.id];
-
-        if (!nodeStates)
-            return;
-
-        var state = nodeStates[node.id];
-
-        if (!state) {
-
-            state = nodeStates[node.id] = { expanded: true, componentStates: {} };
-
-        }
-
-        var section: Atomic.UISection = <Atomic.UISection>this.nodeLayout.getWidget("node_section");
-
-        state.expanded = section.value ? true : false;
-
-        var components = node.getComponents();
-
-        for (var i in components) {
-
-            var component = components[i];
-            var cstate = state.componentStates[component.id];
-
-            if (!cstate) {
-                cstate = state.componentStates[component.id] = { expanded: false };
-            }
-
-            section = <Atomic.UISection>this.nodeLayout.getWidget("component_section_" + component.id);
-
-            if (section)
-                cstate.expanded = section.value ? true : false;
-
-        }
-
-    }
-
-    loadState() {
-
-        var node = this.node;
-
-        // lookup in node states via scene id
-        var nodeStates = NodeInspector.nodeStates[node.scene.id];
-
-        if (!nodeStates) {
-            nodeStates = NodeInspector.nodeStates[node.scene.id] = {};
-        }
-
-        // lookup by node id
-        var state = nodeStates[node.id];
-
-        if (!state) {
-
-            // we don't have a state, so save default state
-            this.saveState();
-
-        } else {
-
-            var section: Atomic.UISection = <Atomic.UISection>this.nodeLayout.getWidget("node_section");
-
-            section.value = state.expanded ? 1 : 0;
-
-            var components = node.getComponents();
-
-            for (var i in components) {
-
-                var component = components[i];
-
-                var cstate = state.componentStates[component.id];
-                section = <Atomic.UISection>this.nodeLayout.getWidget("component_section_" + component.id);
-
-                if (cstate && section) {
-
-                    section.value = cstate.expanded ? 1 : 0;
-
-                }
-
-            }
-
-        }
-
-    }
-
-
-    isPrefab: boolean;
-    node: Atomic.Node;
-    nodeLayout: Atomic.UILayout;
-    bindings: Array<DataBinding>;
-    gizmoMoved = false;
-    updateDelta = 0;
-    componentInspectors: Array<ComponentInspector> = [];
-
-    static nodeStates: { [sceneID: number]: { [nodeId: number]: NodeState } } = {};
-
-}
-
-export = NodeInspector;

+ 9 - 1
Script/AtomicEditor/ui/frames/inspector/SelectionInspector.ts

@@ -417,7 +417,7 @@ class SelectionInspector extends ScriptWidget {
 
                 if (this.filterComponent(components[i]))
                     continue;
-                    
+
                 var editType = this.addSerializable(components[i]);
                 editType.addNode(node);
             }
@@ -560,6 +560,14 @@ class SelectionInspector extends ScriptWidget {
             var editType = this.addSerializable(c);
             editType.addNode(node);
 
+            for (var i in this.sections) {
+                if (this.sections[i].editType == editType) {
+                    this.sections[i].value = 1;
+                    break;
+                }
+
+            }
+
         }
 
         this.refresh();