mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-06 16:33:15 +01:00
commands window
This commit is contained in:
parent
8c4a903351
commit
7e5e01c8cc
3 changed files with 48 additions and 7 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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 = $('<span>', {class: 'dock-btn'});
|
||||
btn.append(TCAD.App2D.faBtn(icon));
|
||||
btn.append($('<span>', {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 = $('<span>', {class: 'dock-btn'});
|
||||
view.switch.append(TCAD.App2D.faBtn(viewDef.icon));
|
||||
view.switch.append($('<span>', {class: 'txt'}).text(viewDef.name));
|
||||
view.switch = TCAD.ui.dockBtn(viewDef.name, viewDef.icon);
|
||||
bindClick(this, view.switch, viewDef.name);
|
||||
switcherEl.append(view.switch);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -119,7 +119,13 @@
|
|||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="commands" class="win" style="display: none; height: 300px; width: 500px;">
|
||||
<div class="tool-caption" >COMMANDS</div>
|
||||
<div class="content panel scroll" style="padding: 0;">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--<div id="log" style="position:absolute; width: 500px; height: 300px; top:500px; pxleft:0; overflow: scroll;background-color: salmon;">-->
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in a new issue