diff options
| author | Nathan Dinsmore <queryselector@gmail.com> | 2013-04-09 17:15:24 -0400 |
|---|---|---|
| committer | Nathan Dinsmore <queryselector@gmail.com> | 2013-04-09 17:15:24 -0400 |
| commit | ceeb41c0de5f6853a71011c34f1cf3a11a3583f0 (patch) | |
| tree | 75301091928dae10599dea1a3d3f9c78bec836f3 | |
| parent | 6f053fe214ce1f32530b708fd48f778d71244542 (diff) | |
| parent | 74ad2abc66cd2652048de4b7906b1f9f015540e7 (diff) | |
| download | snap-ceeb41c0de5f6853a71011c34f1cf3a11a3583f0.tar.gz snap-ceeb41c0de5f6853a71011c34f1cf3a11a3583f0.zip | |
Merge remote-tracking branch 'upstream/master'
| -rw-r--r-- | gui.js | 87 | ||||
| -rwxr-xr-x | history.txt | 6 | ||||
| -rw-r--r-- | morphic.js | 88 |
3 files changed, 152 insertions, 29 deletions
@@ -143,6 +143,7 @@ IDE_Morph.prototype.init = function (isAutoFill) { this.stageRatio = 1; // for IDE animations, e.g. when zooming this.loadNewProject = false; // flag when starting up translated + this.shield = null; // initialize inherited properties: IDE_Morph.uber.init.call(this); @@ -248,6 +249,11 @@ IDE_Morph.prototype.openIn = function (world) { this.toggleAppMode(true); this.runScripts(); } else if (location.hash.substr(0, 9) === '#present:') { + this.shield = new Morph(); + this.shield.color = this.color; + this.shield.setExtent(this.parent.extent()); + this.parent.add(this.shield); + myself.showMessage('Fetching project\nfrom the cloud...'); SnapCloud.getPublicProject( location.hash.substr(9), @@ -261,6 +267,8 @@ IDE_Morph.prototype.openIn = function (world) { myself.rawOpenCloudDataString(projectData); }, function () { + myself.shield.destroy(); + myself.shield = null; msg.destroy(); myself.toggleAppMode(true); myself.runScripts(); @@ -1686,7 +1694,6 @@ IDE_Morph.prototype.cloudMenu = function () { null, new Color(100, 0, 0) ); - menu.addLine(); menu.addItem( 'export project as cloud data...', function () { @@ -1701,6 +1708,53 @@ IDE_Morph.prototype.cloudMenu = function () { null, new Color(100, 0, 0) ); + menu.addLine(); + menu.addItem( + 'open shared project from cloud...', + function () { + myself.prompt('Author nameā¦', function (usr) { + myself.prompt('Project name...', function (prj) { + var id = 'Username=' + + encodeURIComponent(usr) + + '&ProjectName=' + + encodeURIComponent(prj); + myself.showMessage( + 'Fetching project\nfrom the cloud...' + ); + SnapCloud.getPublicProject( + id, + function (projectData) { + var msg; + if (!Process.prototype.isCatchingErrors) { + window.open( + 'data:text/xml,' + projectData + ); + } + myself.nextSteps([ + function () { + msg = myself.showMessage( + 'Opening project...' + ); + }, + function () { + myself.rawOpenCloudDataString( + projectData + ); + }, + function () { + msg.destroy(); + } + ]); + }, + myself.cloudError() + ); + + }); + }); + }, + null, + new Color(100, 0, 0) + ); } menu.popup(world, pos); }; @@ -3235,6 +3289,10 @@ IDE_Morph.prototype.cloudError = function () { // if none is found, show an error dialog box var response = responseText, explanation = getURL('http://snap.berkeley.edu/cloudmsg.txt'); + if (myself.shield) { + myself.shield.destroy(); + myself.shield = null; + } if (explanation) { myself.showMessage(explanation); return; @@ -3785,7 +3843,13 @@ ProjectDialogMorph.prototype.installCloudProjectList = function (pl) { this.projectList.length > 0 ? function (element) { return element.ProjectName; - } : null + } : null, + [ // format: display shared project names bold + [ + 'bold', + function (proj) {return proj.Public === 'true'; } + ] + ] ); this.fixListFieldItemColors(); @@ -4012,7 +4076,8 @@ ProjectDialogMorph.prototype.deleteProject = function () { ProjectDialogMorph.prototype.shareProject = function () { var myself = this, - proj = this.listField.selected; + proj = this.listField.selected, + entry = this.listField.active; if (proj) { this.ide.confirm( @@ -4021,6 +4086,7 @@ ProjectDialogMorph.prototype.shareProject = function () { ) + '\n"' + proj.ProjectName + '"?', 'Share Project', function () { + myself.ide.showMessage('sharing\nproject...'); SnapCloud.reconnect( function () { SnapCloud.callService( @@ -4028,7 +4094,10 @@ ProjectDialogMorph.prototype.shareProject = function () { function () { SnapCloud.disconnect(); proj.Public = 'true'; - myself.listField.select(proj); + entry.label.isBold = true; + entry.label.drawNew(); + entry.label.changed(); + myself.listField.select(proj, entry); myself.ide.showMessage('shared.', 2); }, myself.ide.cloudError(), @@ -4044,7 +4113,9 @@ ProjectDialogMorph.prototype.shareProject = function () { ProjectDialogMorph.prototype.unshareProject = function () { var myself = this, - proj = this.listField.selected; + proj = this.listField.selected, + entry = this.listField.active; + if (proj) { this.ide.confirm( @@ -4053,6 +4124,7 @@ ProjectDialogMorph.prototype.unshareProject = function () { ) + '\n"' + proj.ProjectName + '"?', 'Unshare Project', function () { + myself.ide.showMessage('unsharing\nproject...'); SnapCloud.reconnect( function () { SnapCloud.callService( @@ -4060,7 +4132,10 @@ ProjectDialogMorph.prototype.unshareProject = function () { function () { SnapCloud.disconnect(); proj.Public = 'false'; - myself.listField.select(proj); + entry.label.isBold = false; + entry.label.drawNew(); + entry.label.changed(); + myself.listField.select(proj, entry); myself.ide.showMessage('unshared.', 2); }, myself.ide.cloudError(), diff --git a/history.txt b/history.txt index 21d7ae7..6637ee7 100755 --- a/history.txt +++ b/history.txt @@ -1601,3 +1601,9 @@ ______ 130409 ------ * various formatting and encoding normalizations +* Morphic: Formatting options for Triggers and MenuItems (and ListItems): bold, italic +* Morphic: ListMorph (items) manipulation capabilites +* GUI: display shared project names bold typed in the project dialog +* GUI: Feedback msg when sharing / unsharing projects +* GUI: Shield (hide) IDE while opening a shared project for presentation +* GUI: Support for debugging shared projects @@ -1033,7 +1033,7 @@ /*global window, HTMLCanvasElement, getMinimumFontHeight, FileReader, Audio, FileList, getBlurredShadowSupport*/ -var morphicVersion = '2013-March-11'; +var morphicVersion = '2013-April-09'; var modules = {}; // keep track of additional loaded modules var useBlurredShadows = getBlurredShadowSupport(); // check for Chrome-bug @@ -6598,7 +6598,14 @@ MenuMorph.prototype.init = function (target, title, environment, fontSize) { this.edge = null; }; -MenuMorph.prototype.addItem = function (labelString, action, hint, color) { +MenuMorph.prototype.addItem = function ( + labelString, + action, + hint, + color, + bold, // bool + italic // bool +) { /* labelString is normally a single-line string. But it can also be one of the following: @@ -6611,7 +6618,9 @@ MenuMorph.prototype.addItem = function (labelString, action, hint, color) { localize(labelString || 'close'), action || nop, hint, - color]); + color, + bold || false, + italic || false]); }; MenuMorph.prototype.addLine = function (width) { @@ -6697,7 +6706,9 @@ MenuMorph.prototype.drawNew = function () { MorphicPreferences.menuFontName, myself.environment, tuple[2], // bubble help hint - tuple[3] // color + tuple[3], // color + tuple[4], // bold + tuple[5] // italic ); } if (isLine) { @@ -7892,7 +7903,9 @@ function TriggerMorph( fontStyle, environment, hint, - labelColor + labelColor, + labelBold, + labelItalic ) { this.init( target, @@ -7902,7 +7915,9 @@ function TriggerMorph( fontStyle, environment, hint, - labelColor + labelColor, + labelBold, + labelItalic ); } @@ -7914,7 +7929,9 @@ TriggerMorph.prototype.init = function ( fontStyle, environment, hint, - labelColor + labelColor, + labelBold, + labelItalic ) { // additional properties: this.target = target || null; @@ -7928,6 +7945,8 @@ TriggerMorph.prototype.init = function ( this.highlightColor = new Color(192, 192, 192); this.pressColor = new Color(128, 128, 128); this.labelColor = labelColor || new Color(0, 0, 0); + this.labelBold = labelBold || false; + this.labelItalic = labelItalic || false; // initialize inherited properties: TriggerMorph.uber.init.call(this); @@ -7976,8 +7995,8 @@ TriggerMorph.prototype.createLabel = function () { this.labelString, this.fontSize, this.fontStyle, - false, // bold - false, // italic + this.labelBold, + this.labelItalic, false, // numeric null, // shadow offset null, // shadow color @@ -8014,7 +8033,9 @@ TriggerMorph.prototype.trigger = function () { in the environment as optionally specified. Note: if action is also a function, instead of becoming the argument itself it will be called to answer the argument. - for selections, Yes/No Choices etc: + for selections, Yes/No Choices etc. As second argument pass + myself, so I can be modified to reflect status changes, e.g. + inside a list box: else (if target is not a function): @@ -8028,9 +8049,9 @@ TriggerMorph.prototype.trigger = function () { */ if (typeof this.target === 'function') { if (typeof this.action === 'function') { - this.target.call(this.environment, this.action.call()); + this.target.call(this.environment, this.action.call(), this); } else { - this.target.call(this.environment, this.action); + this.target.call(this.environment, this.action, this); } } else { if (typeof this.action === 'function') { @@ -8119,7 +8140,9 @@ function MenuItemMorph( fontStyle, environment, hint, - color + color, + bold, + italic ) { this.init( target, @@ -8129,7 +8152,9 @@ function MenuItemMorph( fontStyle, environment, hint, - color + color, + bold, + italic ); } @@ -8183,7 +8208,9 @@ MenuItemMorph.prototype.createLabelString = function (string) { var lbl = new TextMorph( string, this.fontSize, - this.fontStyle + this.fontStyle, + this.labelBold, + this.labelItalic ); lbl.setColor(this.labelColor); return lbl; @@ -8834,13 +8861,16 @@ function ListMorph(elements, labelGetter, format) { [ [<color>, <single-argument predicate>], + ['bold', <single-argument predicate>], + ['italic', <single-argument predicate>], ... ] - multiple color conditions can be passed in such a format list, the + multiple conditions can be passed in such a format list, the last predicate to evaluate true when given the list element sets - the given color. If no condition is met, the default color (black) - will be assigned. + the given format category (color, bold, italic). + If no condition is met, the default format (color black, non-bold, + non-italic) will be assigned. An example of how to use fomats can be found in the InspectorMorph's "markOwnProperties" mechanism. @@ -8871,7 +8901,8 @@ ListMorph.prototype.init = function (elements, labelGetter, format) { this.labelGetter = labelGetter; this.format = format; this.listContents = null; - this.selected = null; + this.selected = null; // actual element currently selected + this.active = null; // menu item representing the selected element this.action = null; this.acceptsDrops = false; this.buildListContents(); @@ -8891,18 +8922,28 @@ ListMorph.prototype.buildListContents = function () { this.elements = ['(empty)']; } this.elements.forEach(function (element) { - var color = null; + var color = null, + bold = false, + italic = false; myself.format.forEach(function (pair) { if (pair[1].call(null, element)) { - color = pair[0]; + if (pair[0] === 'bold') { + bold = true; + } else if (pair[0] === 'italic') { + italic = true; + } else { // assume it's a color + color = pair[0]; + } } }); myself.listContents.addItem( myself.labelGetter(element), // label string element, // action null, // hint - color + color, + bold, + italic ); }); this.listContents.setPosition(this.contents.position()); @@ -8911,8 +8952,9 @@ ListMorph.prototype.buildListContents = function () { this.addContents(this.listContents); }; -ListMorph.prototype.select = function (item) { +ListMorph.prototype.select = function (item, trigger) { this.selected = item; + this.active = trigger; if (this.action) { this.action.call(null, item); } |
