提交 c9362b3d 编写于 作者: A aaron

Editor - Add CollapsiblePanel

上级 423df055
......@@ -55,6 +55,28 @@ button {
user-select: none;
}
.CollapsiblePanel .CollapsiblePanelButton {
float: left;
margin-right: 4px;
width: 0px;
height: 0px;
border: 6px solid transparent;
}
.CollapsiblePanel.collapsed .CollapsiblePanelButton {
margin-top: 2px;
border-left-color: #bbb;
}
.CollapsiblePanel:not(.collapsed) .CollapsiblePanelButton {
margin-top: 6px;
border-top-color: #bbb;
}
.CollapsiblePanel.collapsed .CollapsibleContent {
display: none;
}
.FancySelect {
background: #222;
border: 1px solid #3C3C3C;
......
......@@ -28,6 +28,28 @@ button {
user-select: none;
}
.CollapsiblePanel .CollapsiblePanelButton {
float: left;
margin-right: 4px;
width: 0px;
height: 0px;
border: 6px solid transparent;
}
.CollapsiblePanel.collapsed .CollapsiblePanelButton {
margin-top: 2px;
border-left-color: #333;
}
.CollapsiblePanel:not(.collapsed) .CollapsiblePanelButton {
margin-top: 6px;
border-top-color: #333;
}
.CollapsiblePanel.collapsed .CollapsibleContent {
display: none;
}
.FancySelect {
background: #fff;
border: 1px solid #ccc;
......
......@@ -2,11 +2,11 @@ Sidebar.Geometry = function ( editor ) {
var signals = editor.signals;
var container = new UI.Panel();
var container = new UI.CollapsiblePanel();
container.setDisplay( 'none' );
container.add( new UI.Text().setValue( 'GEOMETRY' ) );
container.add( new UI.Break(), new UI.Break() );
container.addStatic( new UI.Text().setValue( 'GEOMETRY' ) );
container.add( new UI.Break() );
// uuid
......
......@@ -20,12 +20,12 @@ Sidebar.Material = function ( editor ) {
};
var container = new UI.Panel();
var container = new UI.CollapsiblePanel();
container.setDisplay( 'none' );
container.dom.classList.add( 'Material' );
container.add( new UI.Text().setValue( 'MATERIAL' ) );
container.add( new UI.Break(), new UI.Break() );
container.addStatic( new UI.Text().setValue( 'MATERIAL' ) );
container.add( new UI.Break() );
// uuid
......
......@@ -2,12 +2,12 @@ Sidebar.Object3D = function ( editor ) {
var signals = editor.signals;
var container = new UI.Panel();
var container = new UI.CollapsiblePanel();
container.setDisplay( 'none' );
var objectType = new UI.Text().setTextTransform( 'uppercase' );
container.add( objectType );
container.add( new UI.Break(), new UI.Break() );
container.addStatic( objectType );
container.add( new UI.Break() );
// uuid
......
......@@ -13,10 +13,10 @@ Sidebar.Renderer = function ( editor ) {
};
var container = new UI.Panel();
var container = new UI.CollapsiblePanel();
container.add( new UI.Text( 'RENDERER' ) );
container.add( new UI.Break(), new UI.Break() );
container.addStatic( new UI.Text( 'RENDERER' ) );
container.add( new UI.Break() );
// class
......
......@@ -2,10 +2,10 @@ Sidebar.Scene = function ( editor ) {
var signals = editor.signals;
var container = new UI.Panel();
var container = new UI.CollapsiblePanel();
container.add( new UI.Text( 'SCENE' ) );
container.add( new UI.Break(), new UI.Break() );
container.addStatic( new UI.Text( 'SCENE' ) );
container.add( new UI.Break() );
var outliner = new UI.FancySelect().setId( 'outliner' );
outliner.onChange( function () {
......
......@@ -137,6 +137,133 @@ UI.Panel.prototype.clear = function () {
};
// Collapsible Panel
UI.CollapsiblePanel = function () {
UI.Panel.call( this );
this.dom.className = 'Panel CollapsiblePanel';
this.button = document.createElement( 'div' );
this.button.className = 'CollapsiblePanelButton';
this.dom.appendChild( this.button );
var scope = this;
this.button.addEventListener( 'click', function ( event ) {
scope.toggle();
}, false );
this.content = document.createElement( 'div' );
this.content.className = 'CollapsibleContent';
this.dom.appendChild( this.content );
this.isCollapsed = false;
return this;
};
UI.CollapsiblePanel.prototype = Object.create( UI.Panel.prototype );
UI.CollapsiblePanel.prototype.addStatic = function () {
for ( var i = 0; i < arguments.length; i ++ ) {
this.dom.insertBefore( arguments[ i ].dom, this.content );
}
return this;
};
UI.CollapsiblePanel.prototype.removeStatic = UI.Panel.prototype.remove;
UI.CollapsiblePanel.prototype.clearStatic = function () {
this.dom.childNodes.forEach( function ( child ) {
if ( child !== this.content ) {
this.dom.removeChild( child );
}
});
};
UI.CollapsiblePanel.prototype.add = function () {
for ( var i = 0; i < arguments.length; i ++ ) {
this.content.appendChild( arguments[ i ].dom );
}
return this;
};
UI.CollapsiblePanel.prototype.remove = function () {
for ( var i = 0; i < arguments.length; i ++ ) {
this.content.removeChild( arguments[ i ].dom );
}
return this;
};
UI.CollapsiblePanel.prototype.clear = function () {
while ( this.content.children.length ) {
this.content.removeChild( this.content.lastChild );
}
};
UI.CollapsiblePanel.prototype.toggle = function() {
this.setCollapsed( !this.isCollapsed );
};
UI.CollapsiblePanel.prototype.collapse = function() {
this.setCollapsed( true );
};
UI.CollapsiblePanel.prototype.expand = function() {
this.setCollapsed( false );
};
UI.CollapsiblePanel.prototype.setCollapsed = function( setCollapsed ) {
if ( setCollapsed ) {
this.dom.classList.add('collapsed');
} else {
this.dom.classList.remove('collapsed');
}
this.isCollapsed = setCollapsed;
};
// Text
UI.Text = function ( text ) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册