diff --git a/web/app/sketcher/main2d.js b/web/app/sketcher/main2d.js index 129150f0..e70b8c8d 100644 --- a/web/app/sketcher/main2d.js +++ b/web/app/sketcher/main2d.js @@ -19,9 +19,17 @@ TCAD.App2D = function() { this._actionsOrder = []; var dockEl = $('#dock'); - this.dock = new TCAD.ui.Dock(dockEl, $('#status'), TCAD.App2D.views); + var statusEl = $('#status'); + this.dock = new TCAD.ui.Dock(dockEl, statusEl, TCAD.App2D.views); this.dock.show('Constraints'); - + + var consoleBtn = TCAD.ui.dockBtn('Commands', 'list'); + statusEl.append(consoleBtn); + var commandsWin = new TCAD.ui.Window($('#commands'), this.winManager); + consoleBtn.click(function() { + commandsWin.toggle(); + }); + this.winManager.registerResize(dockEl, TCAD.ui.DIRECTIONS.EAST, function() {$('body').trigger('layout'); }); $('body').on('layout', this.viewer.onWindowResize); diff --git a/web/app/ui.js b/web/app/ui.js index 4bec387f..93845cd4 100644 --- a/web/app/ui.js +++ b/web/app/ui.js @@ -3,6 +3,8 @@ TCAD.ui = {}; /** @constructor */ TCAD.ui.Window = function(el, winManager) { this.root = el; + this.neverOpened = !this.root.is(':visible'); + this.tileUpRelative = $('body'); var root = this.root; var caption = this.root.find('.tool-caption'); caption.each(function() { @@ -17,6 +19,27 @@ TCAD.ui.Window = function(el, winManager) { winManager.registerDrag(this.root, caption); }; +TCAD.ui.Window.prototype.toggle = function() { + if (!this.root.is(':visible')) { + this.tileUpPolicy(this.neverOpened, this.tileUpRelative); + } + this.neverOpened = false ; + this.root.toggle(); +}; + +TCAD.ui.Window.prototype.tileUpPolicy = function(firstTime, relativeEl) { + var span = 100; + var relOff = relativeEl.offset(); + if (firstTime) { + this.root.offset( { + //left : relOff.left + relativeEl.width() - this.root.width() - span, + //top : relOff.top + relativeEl.height() - this.root.height() - span + left : relOff.left, + top : relOff.top + }); + } +}; + TCAD.ui.WinManager = function() { this.moveHandler = null; var wm = this; @@ -243,6 +266,13 @@ TCAD.ui.List.prototype.refresh = function() { } }; +TCAD.ui.dockBtn = function(name, icon) { + var btn = $('', {class: 'dock-btn'}); + btn.append(TCAD.App2D.faBtn(icon)); + btn.append($('', {class: 'txt'}).text(name)); + return btn; +}; + TCAD.ui.Dock = function(dockEl, switcherEl, viewDefinitions) { this.views = {}; this.dockEl = dockEl; @@ -266,10 +296,7 @@ TCAD.ui.Dock = function(dockEl, switcherEl, viewDefinitions) { view.node.append(caption); view.node.hide(); this.dockEl.append(view.node); - - view.switch = $('', {class: 'dock-btn'}); - view.switch.append(TCAD.App2D.faBtn(viewDef.icon)); - view.switch.append($('', {class: 'txt'}).text(viewDef.name)); + view.switch = TCAD.ui.dockBtn(viewDef.name, viewDef.icon); bindClick(this, view.switch, viewDef.name); switcherEl.append(view.switch); } diff --git a/web/sketcher.html b/web/sketcher.html index 550f6ec0..7cc36a44 100644 --- a/web/sketcher.html +++ b/web/sketcher.html @@ -119,7 +119,13 @@ - + + + \ No newline at end of file