Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions editor/css/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,20 @@ select {
background-color: rgba(21,60,94,1);
}

.TabbedPanel .Tabs {
background-color: #1b1b1b;
border-top: 1px solid #222;
}

.TabbedPanel .Tab {
color: #555;
border-right: 1px solid #222;
}

.TabbedPanel .Tab.selected {
color: #888;
background-color: #111;
}
/* */

@media all and ( max-width: 600px ) {
Expand Down
15 changes: 15 additions & 0 deletions editor/css/light.css
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,21 @@ select {
background-color: rgba(0,0,0,0.04);
}


.TabbedPanel .Tabs {
background-color: #ddd;
border-top: 1px solid #ccc;
}

.TabbedPanel .Tab {
color: #aaa;
border-right: 1px solid #ccc;
}

.TabbedPanel .Tab.selected {
color: #888;
background-color: #eee;
}
/* */

@media all and ( max-width: 600px ) {
Expand Down
31 changes: 31 additions & 0 deletions editor/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,37 @@ textarea, input { outline: none; } /* osx */
user-select: none;
}

.TabbedPanel {
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;

/* No support for these yet */
-o-user-select: none;
user-select: none;
position: relative;
display: block;
width: 100%;
}

.TabbedPanel .Tabs {
position: relative;
display: block;
width: 100%;
}

.TabbedPanel .Tabs .Tab {
padding: 10px;
vertical-align: middle;
}

.TabbedPanel .Tabs .Panels {
position: relative;
display: block;
width: 100%;
height: 100%;
}

/* CodeMirror */

.CodeMirror {
Expand Down
68 changes: 5 additions & 63 deletions editor/js/Sidebar.Properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,72 +4,14 @@

Sidebar.Properties = function ( editor ) {

var signals = editor.signals;
var strings = editor.strings;

var container = new UI.Span();
var container = new UI.TabbedPanel();
container.setId( 'properties' );

var objectTab = new UI.Text( strings.getKey( 'sidebar/properties/object' ) ).setTextTransform( 'uppercase' );
objectTab.onClick( function () { select( 'OBJECT' ) } );

var geometryTab = new UI.Text( strings.getKey( 'sidebar/properties/geometry' ) ).setTextTransform( 'uppercase' );
geometryTab.onClick( function () { select( 'GEOMETRY' ) } );

var materialTab = new UI.Text( strings.getKey( 'sidebar/properties/material' ) ).setTextTransform( 'uppercase' );
materialTab.onClick( function () { select( 'MATERIAL' ) } );

var tabs = new UI.Div();
tabs.setId( 'tabs' );
tabs.add( objectTab, geometryTab, materialTab );
container.add( tabs );

//

var object = new UI.Span().add(
new Sidebar.Object( editor )
);
container.add( object );

var geometry = new UI.Span().add(
new Sidebar.Geometry( editor )
);
container.add( geometry );

var material = new UI.Span().add(
new Sidebar.Material( editor )
);
container.add( material );

//

function select( section ) {

objectTab.setClass( '' );
geometryTab.setClass( '' );
materialTab.setClass( '' );

object.setDisplay( 'none' );
geometry.setDisplay( 'none' );
material.setDisplay( 'none' );

switch ( section ) {
case 'OBJECT':
objectTab.setClass( 'selected' );
object.setDisplay( '' );
break;
case 'GEOMETRY':
geometryTab.setClass( 'selected' );
geometry.setDisplay( '' );
break;
case 'MATERIAL':
materialTab.setClass( 'selected' );
material.setDisplay( '' );
break;
}

}

select( 'OBJECT' );
container.addTab( 'object', strings.getKey( 'sidebar/properties/object' ), new Sidebar.Object( editor ) );
container.addTab( 'geometry', strings.getKey( 'sidebar/properties/geometry' ), new Sidebar.Geometry( editor ) );
container.addTab( 'material', strings.getKey( 'sidebar/properties/material' ), new Sidebar.Material( editor ) );

return container;

Expand Down
60 changes: 4 additions & 56 deletions editor/js/Sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,76 +6,24 @@ var Sidebar = function ( editor ) {

var strings = editor.strings;

var container = new UI.Panel();
var container = new UI.TabbedPanel();
container.setId( 'sidebar' );

//

var sceneTab = new UI.Text( strings.getKey( 'sidebar/scene' ) ).setTextTransform( 'uppercase' );
sceneTab.onClick( function () { select( 'SCENE' ) } );

var projectTab = new UI.Text( strings.getKey( 'sidebar/project' ) ).setTextTransform( 'uppercase' );
projectTab.onClick( function () { select( 'PROJECT' ) } );

var settingsTab = new UI.Text( strings.getKey( 'sidebar/settings' ) ).setTextTransform( 'uppercase' );
settingsTab.onClick( function () { select( 'SETTINGS' ) } );

var tabs = new UI.Div();
tabs.setId( 'tabs' );
tabs.add( sceneTab, projectTab, settingsTab );
container.add( tabs );

//

var scene = new UI.Span().add(
new Sidebar.Scene( editor ),
new Sidebar.Properties( editor ),
new Sidebar.Animation( editor ),
new Sidebar.Script( editor )
);
container.add( scene );

var project = new UI.Span().add(
new Sidebar.Project( editor )
);
container.add( project );

var settings = new UI.Span().add(
new Sidebar.Settings( editor ),
new Sidebar.History( editor )
);
container.add( settings );

//

function select( section ) {

sceneTab.setClass( '' );
projectTab.setClass( '' );
settingsTab.setClass( '' );

scene.setDisplay( 'none' );
project.setDisplay( 'none' );
settings.setDisplay( 'none' );

switch ( section ) {
case 'SCENE':
sceneTab.setClass( 'selected' );
scene.setDisplay( '' );
break;
case 'PROJECT':
projectTab.setClass( 'selected' );
project.setDisplay( '' );
break;
case 'SETTINGS':
settingsTab.setClass( 'selected' );
settings.setDisplay( '' );
break;
}

}

select( 'SCENE' );
container.addTab( 'scene', strings.getKey( 'sidebar/scene' ), scene );
container.addTab( 'project', strings.getKey( 'sidebar/project' ), new Sidebar.Project( editor ) );
container.addTab( 'settings', strings.getKey( 'sidebar/settings' ), settings );

return container;

Expand Down
135 changes: 135 additions & 0 deletions editor/js/libs/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,22 @@ UI.Element.prototype = {

},

addClass: function ( name ) {

this.dom.classList.add( name );

return this;

},

removeClass: function ( name ) {

this.dom.classList.remove( name );

return this;

},

setStyle: function ( style, array ) {

for ( var i = 0; i < array.length; i ++ ) {
Expand Down Expand Up @@ -995,3 +1011,122 @@ UI.Button.prototype.setLabel = function ( value ) {
return this;

};


// TabbedPanel

UI.TabbedPanel = function ( ) {

UI.Element.call( this );

var dom = document.createElement('div');

this.dom = dom;

this.setClass( 'TabbedPanel' );

this.tabs = [];
this.panels = [];

this.tabsDiv = new UI.Div();
this.tabsDiv.setClass( 'Tabs' );

this.panelsDiv = new UI.Div();
this.panelsDiv.setClass( 'Panels' );

this.add( this.tabsDiv );
this.add( this.panelsDiv );

this.selected = '';

return this;

}

UI.TabbedPanel.prototype = Object.create( UI.Element.prototype );
UI.TabbedPanel.prototype.constructor = UI.TabbedPanel;

UI.TabbedPanel.prototype.select = function ( id ) {

var tab;
var panel;
var scope = this;

// Deselect current selection
if ( this.selected && this.selected.length ) {
tab = this.tabs.find( function ( item ) { return item.dom.id === scope.selected } );
panel = this.panels.find( function ( item ) { return item.dom.id === scope.selected } );

if ( tab ) {

tab.removeClass( 'selected' );

}

if( panel ) {

panel.setDisplay( 'none' );

}

}

tab = this.tabs.find( function ( item ) { return item.dom.id === id } );
panel = this.panels.find( function ( item ) { return item.dom.id === id } );

if ( tab ) {

tab.addClass( 'selected' );

}

if( panel ) {

panel.setDisplay( '' );

}

this.selected = id;

return this;

}

UI.TabbedPanel.prototype.addTab = function ( id, label, items ) {

var tab = new UI.TabbedPanel.Tab( label, this );
tab.setId( id );
this.tabs.push( tab );
this.tabsDiv.add( tab );

var panel = new UI.Div();
panel.setId( id );
panel.add( items );
panel.setDisplay( 'none' );
this.panels.push( panel );
this.panelsDiv.add( panel );

this.select( id );

}

UI.TabbedPanel.Tab = function ( text, parent ) {

UI.Text.call( this, text );
this.parent = parent;

this.setClass( 'Tab' );

var scope = this;
this.dom.addEventListener( 'click', function ( event ) {

scope.parent.select( scope.dom.id );

} )

return this;

}

UI.TabbedPanel.Tab.prototype = Object.create( UI.Text.prototype );
UI.TabbedPanel.Tab.prototype.constructor = UI.TabbedPanel.Tab;