diff --git a/stitchcode/gui.js b/stitchcode/gui.js index 9d3b36bf..308a9a1c 100644 --- a/stitchcode/gui.js +++ b/stitchcode/gui.js @@ -16,7 +16,9 @@ IDE_Morph.prototype.init = function(isAutoFill) { 'Embroidery tools' ); // this.isAnimating = false; - this.cloud = new BeetleCloud('/api'); + this.paletteWidth = 250; // initially same as logo width + //MorphicPreferences.globalFontFamily = 'Sans, Helvetica, Arial'; + this.cloud = new BeetleCloud('/api'); }; // change logo @@ -138,7 +140,7 @@ IDE_Morph.prototype.buildPanes = function () { this.createStatusDisplay(); this.createStageHandle(); this.createPaletteHandle(); - + }; StageHandleMorph.prototype.init = function (target) { @@ -149,6 +151,7 @@ StageHandleMorph.prototype.init = function (target) { this.isDraggable = false; this.noticesTransparentClick = true; this.setExtent(new Point(12, 50)); + }; IDE_Morph.prototype.origSetStageExtent = IDE_Morph.prototype.setStageExtent; @@ -222,7 +225,7 @@ IDE_Morph.prototype.createControlBar = function () { } this.controlBar = new Morph(); - this.controlBar.color = this.frameColor; + //this.controlBar.color = this.frameColor; this.controlBar.color = new Color(250, 250, 250); this.controlBar.setHeight(this.logo.height()); // height is fixed this.controlBar.mouseClickLeft = function () { @@ -596,7 +599,7 @@ IDE_Morph.prototype.toggleAppMode = function (appMode) { this.controlBar.steppingButton, //this.controlBar.largeStageSizeButton, this.spriteEditor, - //this.paletteHandle, + this.paletteHandle, this.stageHandle, this.palette, this.statusDisplay, @@ -617,9 +620,12 @@ IDE_Morph.prototype.toggleAppMode = function (appMode) { morph.hide(); } }); + this.stage.add(this.controlBar); + this.controlBar.alpha = 0; } else { - this.setColor(this.backgroundColor); - this.controlBar.setColor(this.frameColor); + this.controlBar.setColor(this.controlBar.color); + this.add(this.controlBar); + elements.forEach(function (e) { e.show(); }); @@ -916,16 +922,16 @@ IDE_Morph.prototype.createStatusDisplay = function () { elements.push(zoomOutButton); - var resetCameraButton = new PushButtonMorph( + var fitScreenButton = new PushButtonMorph( null, - function () { stage.camera.reset(); }, - 'Reset View' + function () { stage.camera.fitScene(); }, + 'Zoom to Fit' ); - resetCameraButton.columns = 4; - resetCameraButton.newColumn = 2; - elements.push(resetCameraButton); - - var toggleTurboButton = new ToggleMorph( + elements.push(fitScreenButton); + fitScreenButton.columns = 4; + fitScreenButton.newColumn = 2; + + var toggleTurboButton = new ToggleMorph( 'checkbox', null, function () { @@ -951,8 +957,16 @@ IDE_Morph.prototype.createStatusDisplay = function () { function () { return !stage.turtleShepherd.isMetric(); }); - toggleUnitButton.newLines = 3; - elements.push(toggleUnitButton); + toggleUnitButton.newLines = 2; + elements.push(toggleUnitButton); + + var resetCameraButton = new PushButtonMorph( + null, + function () { stage.camera.reset(); }, + 'Reset View' + ); + elements.push(resetCameraButton); + resetCameraButton.newLines = 3; var downloadSVGButton = new PushButtonMorph( null, @@ -1016,7 +1030,7 @@ IDE_Morph.prototype.fixLayout = function (situation) { // categories this.categories.setLeft(this.logo.left()); - this.categories.setTop(this.logo.bottom()); + this.categories.setTop(this.logo.bottom()+1); this.categories.setWidth(this.paletteWidth); } @@ -1029,11 +1043,13 @@ IDE_Morph.prototype.fixLayout = function (situation) { if (situation !== 'refreshPalette') { // stage if (this.isAppMode) { - this.stage.setScale(Math.floor(Math.min( - (this.width() - padding * 2) / this.stage.dimensions.x, - (this.height() - this.controlBar.height() * 2 - padding * 2) / - this.stage.dimensions.y ) * 10) / 10); + this.stage.setScale(this.width() / this.stage.dimensions.x); + //this.stage.setScale(3); this.stage.setCenter(this.center()); + //this.stage.setTop(this.controlBar.bottom()); + //this.stage.setLeft(0); + this.controlBar.setTop(0); + this.controlBar.setRight(this.width() - padding); } else { this.stage.setScale(this.isSmallStage ? this.stageRatio : 1); this.stage.setTop(this.logo.bottom() + padding); @@ -2262,9 +2278,6 @@ DialogBoxMorph.prototype.informWithLink = function ( }; -IDE_Morph.prototype.toggleStageSize = function (isSmall, forcedRatio) { - -}; ProjectDialogMorph.prototype.installCloudProjectList = function (pl) { var myself = this; diff --git a/stitchcode/objects.js b/stitchcode/objects.js index e5487ef4..057b9f51 100644 --- a/stitchcode/objects.js +++ b/stitchcode/objects.js @@ -130,7 +130,7 @@ SpriteMorph.prototype.addStitch = function(x1, y1, x2, y2) { //console.log(w, x2, y2); //console.log(this.cache); } - + this.reRender(); this.lastJumped = false; }; @@ -152,6 +152,7 @@ SpriteMorph.prototype.addJumpLine = function(x1, y1, x2, y2) { stage.myJumpLines.add(line); this.lastJumped = true; + this.reRender(); }; SpriteMorph.prototype.addStitchPoint = function(x2, y2) { @@ -188,6 +189,8 @@ SpriteMorph.prototype.addStitchPoint = function(x2, y2) { line.visible = stage.renderer.showingStitchPoints; stage.myStitchPoints.add(line); + this.reRender(); + }; SpriteMorph.prototype.addDensityPoint = function(x1, y1) { @@ -212,6 +215,7 @@ SpriteMorph.prototype.addDensityPoint = function(x1, y1) { circle.translateZ(0.03); circle.visible = true; stage.myDensityPoints.add(circle); + this.reRender(); }; @@ -579,7 +583,7 @@ SpriteMorph.prototype.clear = function () { }; SpriteMorph.prototype.reRender = function () { - + this.parentThatIsA(StageMorph).renderer.changed = true ; //this.hide(); this.changed(); }; @@ -941,11 +945,10 @@ StageMorph.prototype.initCamera = function () { this.zoomFactor = 1.7; this.applyZoom(); this.position.set(0,0,10); - //myself.controls.rotateLeft(radians(90)); } else { this.position.set(0,0,10); } - + myself.controls.update(); myself.reRender(); }; @@ -957,13 +960,15 @@ StageMorph.prototype.initCamera = function () { center = boundingSphere.center, distance = boundingSphere.radius; - this.reset(); - - this.position.set(center.x, center.y, center.z); - this.translateZ(distance * 1.2); - - myself.controls.center.set(center.x, center.y, center.z); - myself.controls.dollyOut(1.2); + var width = Math.max(myself.width(), 480), + height = Math.max(myself.height(), 360); + + this.zoomFactor = Math.max(width / distance, height / distance); + this.applyZoom(); + + this.position.set(center.x, center.y, 10); + myself.controls.center.set(center.x, center.y, 10); + myself.controls.update(); myself.reRender(); }; @@ -1041,12 +1046,16 @@ StageMorph.prototype.rotateTurtle = function(h) { StageMorph.prototype.originalStep = StageMorph.prototype.step; StageMorph.prototype.step = function () { this.originalStep(); + if (!(this.isFastTracked && this.threads.processes.length)) { this.renderCycle(); - } else if (this.stepcounter % 12 == 0) { - this.renderCycle(); + } else { + if (this.stepcounter % 12 == 0) { + this.renderCycle(); + } }; - + + this.stepcounter++; };