diff options
Diffstat (limited to 'gui.js')
| -rw-r--r-- | gui.js | 87 |
1 files changed, 53 insertions, 34 deletions
@@ -69,7 +69,7 @@ SpeechBubbleMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.gui = '2014-Jun-04'; +modules.gui = '2014-July-11'; // Declarations @@ -889,8 +889,6 @@ IDE_Morph.prototype.createPalette = function (forSearching) { this.palette.setWidth(this.logo.width()); this.add(this.palette); - this.palette.scrollX(this.palette.padding); - this.palette.scrollY(this.palette.padding); return this.palette; }; @@ -924,6 +922,8 @@ IDE_Morph.prototype.createSpriteBar = function () { tabColors = this.tabColors, tabBar = new AlignmentMorph('row', -tabCorner * 2), tab, + symbols = ['\u2192', '\u21BB', '\u2194'], + labels = ['don\'t rotate', 'can rotate', 'only face left/right'], myself = this; if (this.spriteBar) { @@ -952,17 +952,13 @@ IDE_Morph.prototype.createSpriteBar = function () { each.refresh(); }); }, - ['\u2192', '\u21BB', '\u2194'][rotationStyle], // label + symbols[rotationStyle], // label function () { // query return myself.currentSprite instanceof SpriteMorph && myself.currentSprite.rotationStyle === rotationStyle; }, null, // environment - localize( - [ - 'don\'t rotate', 'can rotate', 'only face left/right' - ][rotationStyle] - ) + localize(labels[rotationStyle]) ); button.corner = 8; @@ -1729,7 +1725,7 @@ IDE_Morph.prototype.applySavedSettings = function () { // blocks zoom if (zoom) { - SyntaxElementMorph.prototype.setScale(zoom); + SyntaxElementMorph.prototype.setScale(Math.min(zoom, 12)); CommentMorph.prototype.refreshScale(); SpriteMorph.prototype.initBlocks(); } @@ -1837,23 +1833,23 @@ IDE_Morph.prototype.duplicateSprite = function (sprite) { IDE_Morph.prototype.removeSprite = function (sprite) { var idx = this.sprites.asArray().indexOf(sprite) + 1; - + this.stage.threads.stopAllForReceiver(sprite); sprite.destroy(); this.stage.watchers().forEach(function (watcher) { if (watcher.object() === sprite) { watcher.destroy(); } }); - - if (idx < 1) {return; } - + if (idx > 0) { + this.sprites.remove(idx); + } + this.createCorral(); + this.fixLayout(); this.currentSprite = detect( this.stage.children, function (morph) {return morph instanceof SpriteMorph; } ) || this.stage; - this.sprites.remove(this.sprites.asArray().indexOf(sprite) + 1); - this.createCorral(); - this.fixLayout(); + this.selectSprite(this.currentSprite); }; @@ -1861,7 +1857,7 @@ IDE_Morph.prototype.removeSprite = function (sprite) { IDE_Morph.prototype.userMenu = function () { var menu = new MenuMorph(this); - menu.addItem('help', 'nop'); + // menu.addItem('help', 'nop'); return menu; }; @@ -1947,7 +1943,7 @@ IDE_Morph.prototype.cloudMenu = function () { ); } else { menu.addItem( - 'Logout', + localize('Logout') + ' ' + SnapCloud.username, 'logout' ); menu.addItem( @@ -2270,18 +2266,7 @@ IDE_Morph.prototype.projectMenu = function () { menu = new MenuMorph(this); menu.addItem('Project notes...', 'editProjectNotes'); menu.addLine(); - menu.addItem( - 'New', - function () { - myself.confirm( - 'Replace the current project with a new one?', - 'New Project', - function () { - myself.newProject(); - } - ); - } - ); + menu.addItem('New', 'createNewProject'); menu.addItem('Open...', 'openProjectsBrowser'); menu.addItem('Save', "save"); if (shiftClicked) { @@ -2364,8 +2349,8 @@ IDE_Morph.prototype.projectMenu = function () { 'Import tools', function () { myself.droppedText( - myself.getURL( - 'http://snap.berkeley.edu/snapsource/tools.xml' + myself.getURLsbeOrRelative( + 'tools.xml' ), 'tools' ); @@ -3364,6 +3349,15 @@ IDE_Morph.prototype.toggleStageSize = function (isSmall) { } }; +IDE_Morph.prototype.createNewProject = function () { + var myself = this; + this.confirm( + 'Replace the current project with a new one?', + 'New Project', + function () {myself.newProject(); } + ); +}; + IDE_Morph.prototype.openProjectsBrowser = function () { new ProjectDialogMorph(this, 'open').popUp(); }; @@ -3499,7 +3493,7 @@ IDE_Morph.prototype.userSetBlocksScale = function () { new DialogBoxMorph( null, function (num) { - myself.setBlocksScale(num); + myself.setBlocksScale(Math.min(num, 12)); } ).withKey('zoomBlocks').prompt( 'Zoom blocks', @@ -4041,6 +4035,23 @@ IDE_Morph.prototype.getURL = function (url) { } }; +IDE_Morph.prototype.getURLsbeOrRelative = function (url) { + var request = new XMLHttpRequest(), + myself = this; + try { + request.open('GET', 'http://snap.berkeley.edu/snapsource/' + + url, false); + request.send(); + if (request.status === 200) { + return request.responseText; + } + return myself.getURL(url); + } catch (err) { + myself.showMessage(err); + return; + } +}; + // IDE_Morph user dialog shortcuts IDE_Morph.prototype.showMessage = function (message, secs) { @@ -4836,9 +4847,13 @@ ProjectDialogMorph.prototype.shareProject = function () { function () { SnapCloud.disconnect(); proj.Public = 'true'; + myself.unshareButton.show(); + myself.shareButton.hide(); entry.label.isBold = true; entry.label.drawNew(); entry.label.changed(); + myself.buttons.fixLayout(); + myself.drawNew(); myself.ide.showMessage('shared.', 2); }, myself.ide.cloudError(), @@ -4873,9 +4888,13 @@ ProjectDialogMorph.prototype.unshareProject = function () { function () { SnapCloud.disconnect(); proj.Public = 'false'; + myself.shareButton.show(); + myself.unshareButton.hide(); entry.label.isBold = false; entry.label.drawNew(); entry.label.changed(); + myself.buttons.fixLayout(); + myself.drawNew(); myself.ide.showMessage('unshared.', 2); }, myself.ide.cloudError(), |
