Browse Source

Editor: Added UI.TextArea and User data row in Object3D panel..

Mr.doob 12 years ago
parent
commit
f9a69c6811
2 changed files with 77 additions and 11 deletions
  1. 55 0
      editor/js/UI.js
  2. 22 11
      editor/js/ui/Sidebar.Object3D.js

+ 55 - 0
editor/js/UI.js

@@ -186,6 +186,61 @@ UI.Input.prototype.onChange = function ( callback ) {
 };
 
 
+// TextArea
+
+UI.TextArea = function ( position ) {
+
+	UI.Element.call( this );
+
+	var scope = this;
+
+	var dom = document.createElement( 'textarea' );
+	dom.className = 'TextArea';
+	dom.style.position = position || 'relative';
+	dom.style.padding = '2px';
+	dom.style.marginTop = '-2px';
+	dom.style.marginLeft = '-2px';
+	dom.style.border = '1px solid #ccc';
+
+	this.dom = dom;
+
+	this.onChangeCallback = null;
+
+	this.dom.addEventListener( 'change', function ( event ) {
+
+		if ( scope.onChangeCallback ) scope.onChangeCallback();
+
+	}, false );
+
+	return this;
+
+};
+
+UI.TextArea.prototype = Object.create( UI.Element.prototype );
+
+UI.TextArea.prototype.getValue = function () {
+
+	return this.dom.value;
+
+};
+
+UI.TextArea.prototype.setValue = function ( value ) {
+
+	this.dom.value = value;
+
+	return this;
+
+};
+
+UI.TextArea.prototype.onChange = function ( callback ) {
+
+	this.onChangeCallback = callback;
+
+	return this;
+
+};
+
+
 // Select
 
 UI.Select = function ( position ) {

+ 22 - 11
editor/js/ui/Sidebar.Object3D.js

@@ -70,17 +70,6 @@ Sidebar.Object3D = function ( signals ) {
 
 	container.add( objectScaleRow );
 
-
-	// visible
-
-	var objectVisibleRow = new UI.Panel();
-	var objectVisible = new UI.Checkbox( 'absolute' ).setLeft( '100px' ).onChange( update );
-
-	objectVisibleRow.add( new UI.Text().setValue( 'Visible' ).setColor( '#666' ) );
-	objectVisibleRow.add( objectVisible );
-
-	container.add( objectVisibleRow );
-
 	// fov
 
 	var objectFovRow = new UI.Panel();
@@ -171,6 +160,27 @@ Sidebar.Object3D = function ( signals ) {
 
 	container.add( objectExponentRow );
 
+	// visible
+
+	var objectVisibleRow = new UI.Panel();
+	var objectVisible = new UI.Checkbox( 'absolute' ).setLeft( '100px' ).onChange( update );
+
+	objectVisibleRow.add( new UI.Text().setValue( 'Visible' ).setColor( '#666' ) );
+	objectVisibleRow.add( objectVisible );
+
+	container.add( objectVisibleRow );
+
+	// user data
+
+	var objectUserDataRow = new UI.Panel();
+	objectUserDataRow.add( new UI.Text().setValue( 'User data' ).setColor( '#666' ) );
+
+	var objectUserData = new UI.TextArea( 'absolute' ).setLeft( '100px' ).setWidth( '150px' ).setColor( '#444' ).setFontSize( '12px' );
+	objectUserDataRow.add( objectUserData );
+
+	container.add( objectUserDataRow );
+
+
 	//
 
 	var selected = null;
@@ -435,6 +445,7 @@ Sidebar.Object3D = function ( signals ) {
 			}
 
 			objectVisible.setValue( object.visible );
+			objectUserData.setValue( JSON.stringify( object.userData ) );
 
 			updateRows();
 			updateTransformRows();