diff --git a/editor/js/Editor.js b/editor/js/Editor.js index 585f5a956fe9bb3ae321ebeb498d6eb6f020bc98..3a951b6adce533c86346e570c27487c2f3d65014 100644 --- a/editor/js/Editor.js +++ b/editor/js/Editor.js @@ -10,6 +10,8 @@ var Editor = function () { // notifications + themeChanged: new SIGNALS.Signal(), + transformModeChanged: new SIGNALS.Signal(), snapChanged: new SIGNALS.Signal(), spaceChanged: new SIGNALS.Signal(), @@ -52,6 +54,14 @@ var Editor = function () { Editor.prototype = { + setTheme: function ( value ) { + + document.getElementById( 'theme' ).href = value; + + this.signals.themeChanged.dispatch( value ); + + }, + setScene: function ( scene ) { this.scene.name = scene.name; diff --git a/editor/js/Menubar.View.js b/editor/js/Menubar.View.js index 8d88f2aea60a456924e32f23814cd09c009c0c87..6d1a614df6b219a3a75d9ee708a2d0867fa4be11 100644 --- a/editor/js/Menubar.View.js +++ b/editor/js/Menubar.View.js @@ -21,14 +21,12 @@ Menubar.View = function ( editor ) { // themes - var themeLink = document.getElementById( 'theme' ); - var option = new UI.Panel(); option.setClass( 'option' ); option.setTextContent( 'Light theme' ); option.onClick( function () { - themeLink.href = 'css/light.css'; + editor.setTheme( 'css/light.css' ); } ); options.add( option ); @@ -40,7 +38,7 @@ Menubar.View = function ( editor ) { option.setTextContent( 'Dark theme' ); option.onClick( function () { - themeLink.href = 'css/dark.css'; + editor.setTheme( 'css/dark.css' ); } ); options.add( option ); diff --git a/editor/js/Viewport.js b/editor/js/Viewport.js index 12b0086f39a14cb473605e44aa76955faa1f7c73..6734408cbf00a4f0ef048668b7c615c7ede975d6 100644 --- a/editor/js/Viewport.js +++ b/editor/js/Viewport.js @@ -179,6 +179,19 @@ var Viewport = function ( editor ) { // signals + signals.themeChanged.add( function ( value ) { + + switch ( value ) { + + case 'css/light.css': grid.setColors( 0x444444, 0x888888 ); break; + case 'css/dark.css': grid.setColors( 0xbbbbbb, 0x888888 ); break; + + } + + render(); + + } ); + signals.transformModeChanged.add( function ( mode ) { transformControls.setMode( mode );