From 4f46850b376b2d428a3d9415b1dc69b36b875a2c Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 16 May 2012 13:06:34 -0700 Subject: Automatically add scrollbars when moving content to negative space. Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/3D/draw-utils.js | 41 ++++++++++++++++++++++++++++++++------ js/stage/stage.reel/stage.js | 31 ++++++++++++++++++++++++++-- 2 files changed, 64 insertions(+), 8 deletions(-) diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index b53ac4ad..b268b8f0 100755 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js @@ -245,16 +245,45 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { } var els = event.detail.data.els; if(els && this._shouldUpdatePlanes(event.detail.data.prop)) { - var len = els.length; + var len = els.length, + stage = this.application.ninja.stage, + minLeft = stage.userPaddingLeft, + minTop = stage.userPaddingTop, + docLeft = stage.documentOffsetLeft, + docTop = stage.documentOffsetTop, + l, + t, + plane, + changed = false; for(var i=0; i < len; i++) { - if(els[i].elementModel.props3D.elementPlane) { - els[i].elementModel.props3D.elementPlane.init(); + plane = els[i].elementModel.props3D.elementPlane; + if(plane) { + plane.init(); + l = plane._rect.m_left - docLeft; + t = plane._rect.m_top - docTop; + if(l < minLeft) { + minLeft = l; + } + if(t < minTop) { + minTop = t; + } } } - this.application.ninja.stage.layout.draw(); - this.drawWorkingPlane(); - this.draw3DCompass(); + if(minLeft !== stage.userPaddingLeft) { + stage.userPaddingLeft = minLeft; + changed = true; + } + if(minTop !== stage.userPaddingTop) { + stage.userPaddingTop = minTop; + changed = true; + } + + if(!changed) { + stage.layout.draw(); + this.drawWorkingPlane(); + this.draw3DCompass(); + } } } }, diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 125155d8..05376527 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -187,6 +187,33 @@ exports.Stage = Montage.create(Component, { enumerable : false }, + _userPaddingLeft: { value: 0 }, + _userPaddingTop: { value: 0 }, + + userPaddingLeft: { + get: function() { return this._userPaddingLeft; }, + set: function(value) { + this._userPaddingLeft = value; + this._documentOffsetLeft = -value; + this.application.ninja.stylesController.setElementStyle(this._documentRoot.ownerDocument.getElementsByTagName("HTML")[0], + "padding-left", -value + "px", true); + this.userContentLeft = this._documentOffsetLeft; + this.updatedStage = true; + } + }, + + userPaddingTop: { + get: function() { return this._userPaddingTop; }, + set: function(value) { + this._userPaddingTop = value; + this._documentOffsetTop = -value; + this.application.ninja.stylesController.setElementStyle(this._documentRoot.ownerDocument.getElementsByTagName("HTML")[0], + "padding-top", -value + "px", true); + this.userContentTop = this._documentOffsetTop; + this.updatedStage = true; + } + }, + willDraw: { value: function() { if(this.resizeCanvases) { @@ -490,8 +517,8 @@ exports.Stage = Montage.create(Component, { this._scrollLeft = this.application.ninja.currentDocument.model.views.design.document.body.scrollLeft; this._scrollTop = this.application.ninja.currentDocument.model.views.design.document.body.scrollTop; - this.userContentLeft = -this._scrollLeft; - this.userContentTop = -this._scrollTop; + this.userContentLeft = this._documentOffsetLeft - this._scrollLeft; + this.userContentTop = this._documentOffsetTop - this._scrollTop; // TODO - scroll events are not dependable. We may need to use a timer to simulate // scrollBegin and scrollEnd. For now, the Pan Tool will keep track of the stage's scroll values -- cgit v1.2.3 From 96c92ab93bdb6eb2dd42ef275b84d83aef8254bf Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 16 May 2012 14:36:47 -0700 Subject: Fixing selection bugs in new templates. Signed-off-by: Nivesh Rajbhandari --- js/document/document-html.js | 2 +- js/stage/stage.reel/stage.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/js/document/document-html.js b/js/document/document-html.js index 87c776d5..a26b74d5 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js @@ -41,7 +41,7 @@ exports.HtmlDocument = Montage.create(Component, { //////////////////////////////////////////////////////////////////// // exclusionList: { - value: ["HTML", "BODY"] //TODO: Update to correct list + value: ["HTML", "BODY", "NINJA-CONTENT"] //TODO: Update to correct list }, //////////////////////////////////////////////////////////////////// // diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 05376527..854b5a2d 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -609,7 +609,7 @@ exports.Stage = Montage.create(Component, { var point, element, docView = this.application.ninja.currentDocument.model.views.design; - point = webkitConvertPointFromPageToNode(this.canvas, new WebKitPoint(position.pageX - docView.iframe.contentWindow.pageXOffset, position.pageY - docView.iframe.contentWindow.pageYOffset)); + point = webkitConvertPointFromPageToNode(this.canvas, new WebKitPoint(position.pageX - docView.iframe.contentWindow.pageXOffset + this.documentOffsetLeft, position.pageY - docView.iframe.contentWindow.pageYOffset + this.documentOffsetTop)); element = this.application.ninja.currentDocument.model.views.design.getElementFromPoint(point.x - this.userContentLeft,point.y - this.userContentTop); if(!element) debugger; -- cgit v1.2.3 From 727ad95f6828821f0682aa98104783e4bbda78b4 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 16 May 2012 15:56:54 -0700 Subject: Inline style for html's padding for content in negative space to guarantee highest specificity. Also, set up scrollbars when opening files with content in negative space. Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/3D/draw-utils.js | 35 ++++++++++++++++++++++++++++++----- js/stage/stage.reel/stage.js | 16 ++++++++++------ 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index b268b8f0..a6d2d899 100755 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js @@ -119,19 +119,43 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { initializeFromDocument:{ value:function(){ - var documentRootChildren = null, i; + var documentRootChildren = null, i, stage = this.application.ninja.stage; //initialize with current document this._eltArray = []; this._planesArray = []; - this.setDrawingSurfaceElement(this.application.ninja.stage.canvas); - this.setSourceSpaceElement( this.application.ninja.stage.stageDeps.currentStage ); + this.setDrawingSurfaceElement(stage.canvas); + this.setSourceSpaceElement( stage.stageDeps.currentStage ); this.setWorkingPlane( [0,0,1,0] ); //Loop through all the top-level children of the current document and call drawUtils.addElement on them if(this.application.ninja.currentDocument._liveNodeList.length > 0){ documentRootChildren = this.application.ninja.currentDocument._liveNodeList; - for(i=0;i