summaryrefslogtreecommitdiff
path: root/gui.js
diff options
context:
space:
mode:
Diffstat (limited to 'gui.js')
-rw-r--r--gui.js167
1 files changed, 125 insertions, 42 deletions
diff --git a/gui.js b/gui.js
index 0f4f2eb..1454ba3 100644
--- a/gui.js
+++ b/gui.js
@@ -64,11 +64,12 @@ standardSettings, Sound, BlockMorph, ToggleMorph, InputSlotDialogMorph,
ScriptsMorph, isNil, SymbolMorph, BlockExportDialogMorph,
BlockImportDialogMorph, SnapTranslator, localize, List, InputSlotMorph,
SnapCloud, Uint8Array, HandleMorph, SVG_Costume, fontHeight, hex_sha512,
-sb, CommentMorph, CommandBlockMorph, BlockLabelPlaceHolderMorph, Audio*/
+sb, CommentMorph, CommandBlockMorph, BlockLabelPlaceHolderMorph, Audio,
+SpeechBubbleMorph*/
// Global stuff ////////////////////////////////////////////////////////
-modules.gui = '2014-February-13';
+modules.gui = '2014-July-08';
// Declarations
@@ -848,7 +849,7 @@ IDE_Morph.prototype.createCategories = function () {
this.add(this.categories);
};
-IDE_Morph.prototype.createPalette = function () {
+IDE_Morph.prototype.createPalette = function (forSearching) {
// assumes that the logo pane has already been created
// needs the categories pane for layout
var myself = this;
@@ -857,7 +858,15 @@ IDE_Morph.prototype.createPalette = function () {
this.palette.destroy();
}
- this.palette = this.currentSprite.palette(this.currentCategory);
+ if (forSearching) {
+ this.palette = new ScrollFrameMorph(
+ null,
+ null,
+ this.currentSprite.sliderColor
+ );
+ } else {
+ this.palette = this.currentSprite.palette(this.currentCategory);
+ }
this.palette.isDraggable = false;
this.palette.acceptsDrops = true;
this.palette.contents.acceptsDrops = false;
@@ -880,8 +889,7 @@ IDE_Morph.prototype.createPalette = function () {
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;
};
IDE_Morph.prototype.createStage = function () {
@@ -914,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) {
@@ -942,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;
@@ -1937,7 +1943,7 @@ IDE_Morph.prototype.cloudMenu = function () {
);
} else {
menu.addItem(
- 'Logout',
+ localize('Logout') + ' ' + SnapCloud.username,
'logout'
);
menu.addItem(
@@ -2260,36 +2266,9 @@ 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',
- function () {
- if (myself.source === 'examples') {
- myself.source = 'local'; // cannot save to examples
- }
- if (myself.projectName) {
- if (myself.source === 'local') { // as well as 'examples'
- myself.saveProject(myself.projectName);
- } else { // 'cloud'
- myself.saveProjectToCloud(myself.projectName);
- }
- } else {
- myself.saveProjectsBrowser();
- }
- }
- );
+ menu.addItem('Save', "save");
if (shiftClicked) {
menu.addItem(
'Save to disk',
@@ -2356,6 +2335,15 @@ IDE_Morph.prototype.projectMenu = function () {
'show global custom block definitions as XML\nin a new browser window'
);
+ if (shiftClicked) {
+ menu.addItem(
+ 'Export all scripts as pic...',
+ function () {myself.exportScriptsPicture(); },
+ 'show a picture of all scripts\nand block definitions',
+ new Color(100, 0, 0)
+ );
+ }
+
menu.addLine();
menu.addItem(
'Import tools',
@@ -2532,6 +2520,7 @@ IDE_Morph.prototype.aboutSnap = function () {
+ '\n\nNathan Dinsmore: Saving/Loading, Snap-Logo Design, '
+ 'countless bugfixes'
+ '\nKartik Chandra: Paint Editor'
+ + '\nYuan Yuan: Graphic Effects'
+ '\nIan Reynolds: UI Design, Event Bindings, '
+ 'Sound primitives'
+ '\nIvan Motyashov: Initial Squeak Porting'
@@ -2720,6 +2709,22 @@ IDE_Morph.prototype.newProject = function () {
this.fixLayout();
};
+IDE_Morph.prototype.save = function () {
+ if (this.source === 'examples') {
+ this.source = 'local'; // cannot save to examples
+ }
+ if (this.projectName) {
+ if (this.source === 'local') { // as well as 'examples'
+ this.saveProject(this.projectName);
+ } else { // 'cloud'
+ this.saveProjectToCloud(this.projectName);
+ }
+ } else {
+ this.saveProjectsBrowser();
+ }
+};
+
+
IDE_Morph.prototype.saveProject = function (name) {
var myself = this;
this.nextSteps([
@@ -2837,6 +2842,56 @@ IDE_Morph.prototype.exportSprite = function (sprite) {
+ '</sprites>');
};
+IDE_Morph.prototype.exportScriptsPicture = function () {
+ var pics = [],
+ pic,
+ padding = 20,
+ w = 0,
+ h = 0,
+ y = 0,
+ ctx;
+
+ // collect all script pics
+ this.sprites.asArray().forEach(function (sprite) {
+ pics.push(sprite.image);
+ pics.push(sprite.scripts.scriptsPicture());
+ sprite.customBlocks.forEach(function (def) {
+ pics.push(def.scriptsPicture());
+ });
+ });
+ pics.push(this.stage.image);
+ pics.push(this.stage.scripts.scriptsPicture());
+ this.stage.customBlocks.forEach(function (def) {
+ pics.push(def.scriptsPicture());
+ });
+
+ // collect global block pics
+ this.stage.globalBlocks.forEach(function (def) {
+ pics.push(def.scriptsPicture());
+ });
+
+ pics = pics.filter(function (each) {return !isNil(each); });
+
+ // determine dimensions of composite
+ pics.forEach(function (each) {
+ w = Math.max(w, each.width);
+ h += (each.height);
+ h += padding;
+ });
+ h -= padding;
+ pic = newCanvas(new Point(w, h));
+ ctx = pic.getContext('2d');
+
+ // draw all parts
+ pics.forEach(function (each) {
+ ctx.drawImage(each, 0, y);
+ y += padding;
+ y += each.height;
+ });
+
+ window.open(pic.toDataURL());
+};
+
IDE_Morph.prototype.openProjectString = function (str) {
var msg,
myself = this;
@@ -3294,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();
};
@@ -4524,6 +4588,17 @@ ProjectDialogMorph.prototype.installCloudProjectList = function (pl) {
myself.preview.texture = item.Thumbnail || null;
myself.preview.cachedTexture = null;
myself.preview.drawNew();
+ (new SpeechBubbleMorph(new TextMorph(
+ localize('last changed') + '\n' + item.Updated,
+ null,
+ null,
+ null,
+ null,
+ 'center'
+ ))).popUp(
+ myself.world(),
+ myself.preview.rightCenter().add(new Point(2, 0))
+ );
}
if (item.Public === 'true') {
myself.shareButton.hide();
@@ -4755,9 +4830,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(),
@@ -4792,9 +4871,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(),