From 4e2bfdec206598317f4145e2cb23a9c9fc453bfb Mon Sep 17 00:00:00 2001 From: jmoenig Date: Tue, 11 Feb 2014 17:38:35 +0100 Subject: New Feature: Set stage dimensions arbitrarily new entries to set stage width and height in the settings menu when holding the shift key --- gui.js | 100 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- history.txt | 4 +++ objects.js | 2 +- paint.js | 4 +-- 4 files changed, 106 insertions(+), 4 deletions(-) diff --git a/gui.js b/gui.js index 7640393..86a4db1 100644 --- a/gui.js +++ b/gui.js @@ -68,7 +68,7 @@ sb, CommentMorph, CommandBlockMorph, BlockLabelPlaceHolderMorph, Audio*/ // Global stuff //////////////////////////////////////////////////////// -modules.gui = '2014-February-04'; +modules.gui = '2014-February-11'; // Declarations @@ -2061,6 +2061,20 @@ IDE_Morph.prototype.settingsMenu = function () { 'Zoom blocks...', 'userSetBlocksScale' ); + if (shiftClicked) { + menu.addItem( + 'Stage width...', + 'userSetStageWidth', + null, + new Color(100, 0, 0) + ); + menu.addItem( + 'Stage height...', + 'userSetStageHeight', + null, + new Color(100, 0, 0) + ); + } menu.addLine(); addPreference( 'Blurred shadows', @@ -2695,6 +2709,7 @@ IDE_Morph.prototype.newProject = function () { this.globalVariables = new VariableFrame(); this.currentSprite = new SpriteMorph(this.globalVariables); this.sprites = new List([this.currentSprite]); + StageMorph.prototype.dimensions = new Point(480, 360); StageMorph.prototype.hiddenPrimitives = {}; StageMorph.prototype.codeMappings = {}; StageMorph.prototype.codeHeaders = {}; @@ -3464,6 +3479,89 @@ IDE_Morph.prototype.setBlocksScale = function (num) { this.saveSetting('zoom', num); }; +// IDE_Morph stage size manipulation + +IDE_Morph.prototype.userSetStageWidth = function () { + new DialogBoxMorph( + this, + this.setStageWidth, + this + ).prompt( + "Stage width", + StageMorph.prototype.dimensions.x.toString(), + this.world(), + null, // pic + null, // choices + null, // read only + true // numeric + ); +}; + +IDE_Morph.prototype.userSetStageHeight = function () { + new DialogBoxMorph( + this, + this.setStageHeight, + this + ).prompt( + "Stage height", + StageMorph.prototype.dimensions.y.toString(), + this.world(), + null, // pic + null, // choices + null, // read only + true // numeric + ); +}; + +IDE_Morph.prototype.setStageWidth = function (num) { + this.setStageExtent(new Point( + Math.max(num, 240), + (StageMorph.prototype.dimensions.y) + )); +}; + +IDE_Morph.prototype.setStageHeight = function (num) { + this.setStageExtent(new Point( + (StageMorph.prototype.dimensions.x), + Math.max(num, 180) + )); +}; + +IDE_Morph.prototype.setStageExtent = function (aPoint) { + var myself = this; + + function zoom() { + myself.step = function () { + var delta = aPoint.subtract( + StageMorph.prototype.dimensions + ).divideBy(2); + if (delta.abs().lt(new Point(5, 5))) { + StageMorph.prototype.dimensions = aPoint; + delete myself.step; + } else { + StageMorph.prototype.dimensions = + StageMorph.prototype.dimensions.add(delta); + } + myself.stage.setExtent(StageMorph.prototype.dimensions); + myself.stage.clearPenTrails(); + myself.fixLayout(); + }; + } + + this.stageRatio = 1; + this.isSmallStage = false; + this.controlBar.stageSizeButton.refresh(); + this.setExtent(this.world().extent()); + if (this.isAnimating) { + zoom(); + } else { + StageMorph.prototype.dimensions = aPoint; + this.stage.setExtent(StageMorph.prototype.dimensions); + this.stage.clearPenTrails(); + this.fixLayout(); + } +}; + // IDE_Morph cloud interface IDE_Morph.prototype.initializeCloud = function () { diff --git a/history.txt b/history.txt index 4591e71..9e0e497 100755 --- a/history.txt +++ b/history.txt @@ -2089,3 +2089,7 @@ ______ 140205 ------ * Objects, Paint: One-stop-shopping for stage dimensions (changing the stage dimensions in line 3720 of objects.js takes care of everything) + +140211 +------ +* GUI: Set stage dimensions arbitrarily (new entries in the settings menu when holding shift) diff --git a/objects.js b/objects.js index d93f582..9a21465 100644 --- a/objects.js +++ b/objects.js @@ -124,7 +124,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2014-February-05'; +modules.objects = '2014-February-11'; var SpriteMorph; var StageMorph; diff --git a/paint.js b/paint.js index f4fd2f3..e3a01af 100644 --- a/paint.js +++ b/paint.js @@ -51,7 +51,7 @@ July 12 - pipette tool, code formatting adjustments (Jens) September 16 - flood fill freeze fix (Kartik) Jan 08 - mouse leave dragging fix (Kartik) - Feb 04 - dynamically adjust to stage dimensions (Jens) + Feb 11 - dynamically adjust to stage dimensions (Jens) */ @@ -65,7 +65,7 @@ // Global stuff //////////////////////////////////////////////////////// -modules.paint = '2014-February-05'; +modules.paint = '2014-February-11'; // Declarations -- cgit v1.3.1