Browse Source

Remember section inspector states, update transform widget, number array attribute updates

Josh Engebretson 10 years ago
parent
commit
4fa5f707a6

+ 24 - 4
Script/AtomicEditor/ui/frames/inspector/AttributeInfoEdit.ts

@@ -472,6 +472,10 @@ class NumberArrayAttributeEdit extends AttributeInfoEdit {
             select.layoutParams = lp;
             layout.addChild(select);
 
+            select["_edit"] = select.getWidget("edit");
+            select["_dec"] = select.getWidget("dec");
+            select["_inc"] = select.getWidget("inc");
+
             select.subscribeToEvent(select, "WidgetEvent", (ev) => this.handleWidgetEvent(ev));
             select.subscribeToEvent(select, "UIWidgetEditComplete", (ev) => this.handleUIWidgetEditCompleteEvent(ev));
         }
@@ -485,7 +489,8 @@ class NumberArrayAttributeEdit extends AttributeInfoEdit {
         for (var i in this.selects) {
 
             var select = this.selects[i];
-            var edit = select.getWidget("edit");
+            if (select["_edit"].focus || select["_dec"].captured || select["_inc"].captured)
+                continue;
 
             var uniform = this.editType.getUniformValue(this.attrInfo, i);
 
@@ -502,7 +507,7 @@ class NumberArrayAttributeEdit extends AttributeInfoEdit {
 
             } else {
 
-                edit.text = "--";
+                select["_edit"].text = "--";
 
             }
 
@@ -523,9 +528,24 @@ class NumberArrayAttributeEdit extends AttributeInfoEdit {
 
         if (ev.type == Atomic.UI_EVENT_TYPE_CHANGED) {
 
-            var index = Number(ev.target.id) - 1;
-            this.editType.onAttributeInfoEdited(this.attrInfo, ev.target.value, index, false);
+            var captured = false;
+            for (var i in this.selects) {
+                var select = this.selects[i];
+                if (select["_dec"].captured || select["_inc"].captured) {
+
+                    captured = true;
+                    break;
+
+                }
+            }
+
+            if (captured) {
 
+              var index = Number(ev.target.id) - 1;
+              this.editType.onAttributeInfoEdited(this.attrInfo, ev.target.value, index, false);
+
+            }
+            
             return true;
         }
 

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

@@ -5,11 +5,16 @@ import EditorEvents = require("editor/EditorEvents");
 import SerializableEditType = require("./SerializableEditType");
 import SelectionSection = require("./SelectionSection");
 import SelectionPrefabWidget = require("./SelectionPrefabWidget");
+import AttributeInfoEdit = require("./AttributeInfoEdit");
 
 class NodeSection extends SelectionSection {
 
     prefabWidget: SelectionPrefabWidget;
 
+    transformEdits: AttributeInfoEdit[] = [];
+
+    updateDelta: number = 0.0;
+
     constructor(editType: SerializableEditType) {
 
         super(editType);
@@ -17,8 +22,36 @@ class NodeSection extends SelectionSection {
         this.prefabWidget = new SelectionPrefabWidget();
         this.attrLayout.addChild(this.prefabWidget);
 
+        this.transformEdits.push(this.attrEdits["Position"]);
+        this.transformEdits.push(this.attrEdits["Rotation"]);
+        this.transformEdits.push(this.attrEdits["Scale"]);
+
+        this.subscribeToEvent("Update", (ev) => this.handleUpdate(ev));
+
+    }
+
+    handleUpdate(ev) {
+
+        this.updateDelta -= ev.timeStep;
+
+        if (this.updateDelta < 0.0) {
+
+            this.updateDelta = 0.1;
+
+            Atomic.ui.blockChangedEvents = true;
+
+            for (var i in this.transformEdits) {
+                this.transformEdits[i].refresh();
+            }
+
+            Atomic.ui.blockChangedEvents = false;
+
+        }
+
+
     }
 
+
 }
 
 class ComponentSection extends SelectionSection {
@@ -184,6 +217,7 @@ class SelectionInspector extends ScriptWidget {
 
         }
 
+        section.value = SelectionInspector.sectionStates[editType.typeName] ? 1 : 0;
 
         this.mainLayout.removeChild(this.createComponentButton, false);
 
@@ -198,6 +232,8 @@ class SelectionInspector extends ScriptWidget {
 
     removeSection(section: SelectionSection) {
 
+        SelectionInspector.sectionStates[section.editType.typeName] = section.value ? true : false;        
+
         var index = this.sections.indexOf(section);
         this.sections.splice(index, 1);
         this.mainLayout.removeChild(section);
@@ -406,7 +442,7 @@ class SelectionInspector extends ScriptWidget {
         var node = this.nodes[0];
         this.removeNode(node);
         this.addNode(node);
-        
+
     }
 
     handleSelectionPrefabBreak() {
@@ -495,7 +531,15 @@ class SelectionInspector extends ScriptWidget {
 
     }
 
+    private static sectionStates: { [typeName: string]: boolean } = {};
     private static _editTypes: { [typeName: string]: typeof SerializableEditType } = {};
+
+    private static Ctor = (() => {
+
+          SelectionInspector.sectionStates["Node"] = true;
+
+    })();
+
 }
 
 export = SelectionInspector;

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

@@ -21,7 +21,6 @@ abstract class SelectionSection extends Atomic.UISection {
         this.editType = editType;
 
         this.text = editType.typeName;
-        this.value = 1;
 
         this.createUI();