From 6dc9ed26ad71f3da5571733acf3f9ed694b8bad4 Mon Sep 17 00:00:00 2001 From: Michael Aschauer Date: Mon, 16 Feb 2015 20:35:02 +0100 Subject: [PATCH] start minimal reorganistaion, add shortcut/favicon --- index.html | 6 +- stitchcode/FileSaver.js | 244 +++++++++++++++++ stitchcode/examples/eckspir.xml | 1 + stitchcode/favicon.gif | Bin 0 -> 1246 bytes stitchcode/stitchcodeChangeSet.js | 437 +++--------------------------- stitchcode/stitchcodeGUI.js | 393 +++++++++++++++++++++++++++ 6 files changed, 686 insertions(+), 395 deletions(-) create mode 100644 stitchcode/FileSaver.js create mode 100644 stitchcode/examples/eckspir.xml create mode 100644 stitchcode/favicon.gif create mode 100644 stitchcode/stitchcodeGUI.js diff --git a/index.html b/index.html index 0736c192..f5403b96 100644 --- a/index.html +++ b/index.html @@ -2,7 +2,9 @@ - turtleStitch (based on Snap!) - Devlopment + TurtleStitch + + @@ -21,7 +23,9 @@ + +
1datamapmany1data lists
1
1
110i
1
cont
catchtag
cont
catchtag
1 diff --git a/stitchcode/favicon.gif b/stitchcode/favicon.gif new file mode 100644 index 0000000000000000000000000000000000000000..481676a02e1d68c629571440e3da0b1e1c792d3e GIT binary patch literal 1246 zcmdUu+fSPX07rk{t@JBUzCznk=%DR@av4Y&gI3UvdkbZhQlR4^y-_H#0UI~RlzU(S zGFX6tTNXeEBu-&wzQ~M#XqeN)8#*HoM$I76hnbidd;sy!@I0Nz^K$Zxxmuk=0R{FR zgXM!2!%s>E$skceqJk)rKs+mrL0}vi97jpw5gHHb3@)sFoNRdrNr6cMkLZv5R;3D+!$rZ=y;hz`4%NI}ufjCd&ygy?KLJ@-^A+Jyj z3sB6_#e9??(m=r?f|Y<(fKn1A!3hS$Pz}5SREBdl4mAX7NPZQI>QL19($!+v{ZorUIA}P8j02RDNw$JtBY`sj zPL8slgd2P(P>YmOFfJc~T?!B2mchfK4%%`8^dP^Ca;6gUga`gBMqHY_B9_<7mVGoUIQlLq$BF0H(>5YaStrLWXiC(Xpml#jwTM%Ikc6*qWQ<8Y0`J_*+}+_xyt3~FbXx>?k}3GZz* z+(GSKG~Pws9O~zBX%S6JxbhB;{tqY*MOl|?9j&!)MTfVwUXf=kG(&kn69OFJG>-Xi z6z~sm#L5k;a~u8qpxCPI)%mQXC9|^m>3E^WzUeG>FYh~7>_kee`=PIGrJBu-y_4KH z6HPI`%kq8VrdofNCrzCC{WDW!ZTq5Jy%dtU}_<*0TJ6qd~4^qlCw*R2cu0A2iOy7|Ysv56$z;r)!Qz46f` zSN`(D=Sw-`C*l`rSp=!MG238%s&&#Uvw_1Onas1BPiEAz=DnE`y2WQoxUe*;Nm?+> zN~dk 0) { - endIdx = line.search(new RegExp('.xml')); - name = line.substring(startIdx + 6, endIdx); - dta = { - name: name, - thumb: null, - notes: null - }; - projects.push(dta); - } - } - ); - projects.sort(function (x, y) { - return x.name < y.name ? -1 : 1; - }); - return projects; -}; diff --git a/stitchcode/stitchcodeGUI.js b/stitchcode/stitchcodeGUI.js new file mode 100644 index 00000000..1ab508df --- /dev/null +++ b/stitchcode/stitchcodeGUI.js @@ -0,0 +1,393 @@ +// Force flat design +IDE_Morph.prototype.setDefaultDesign = IDE_Morph.prototype.setFlatDesign; + +// change logo +IDE_Morph.prototype.originalCreateLogo = IDE_Morph.prototype.createLogo; +IDE_Morph.prototype.createLogo = function () { + this.originalCreateLogo(); + if (MorphicPreferences.isFlat) { + this.logo.texture = 'stitchcode/stitchcode_logo_small.png'; + } else { + this.logo.texture = 'stitchcode/stitchcode_logo_small_black.png'; + } + this.logo.drawNew(); +} + +// add buttons + +IDE_Morph.prototype.createControlBar = function () { + // assumes the logo has already been created + var padding = 5, + button, + stopButton, + pauseButton, + startButton, + projectButton, + settingsButton, + stageSizeButton, + appModeButton, + cloudButton, + upstitchButton, + x, + colors = [ + this.groupColor, + this.frameColor.darker(50), + this.frameColor.darker(50) + ], + myself = this; + + if (this.controlBar) { + this.controlBar.destroy(); + } + + this.controlBar = new Morph(); + this.controlBar.color = this.frameColor; + this.controlBar.setHeight(this.logo.height()); // height is fixed + this.controlBar.mouseClickLeft = function () { + this.world().fillPage(); + }; + this.add(this.controlBar); + + //smallStageButton + button = new ToggleButtonMorph( + null, //colors, + myself, // the IDE is the target + 'toggleStageSize', + [ + new SymbolMorph('smallStage', 14), + new SymbolMorph('normalStage', 14) + ], + function () { // query + return myself.isSmallStage; + } + ); + + button.corner = 12; + button.color = colors[0]; + button.highlightColor = colors[1]; + button.pressColor = colors[2]; + button.labelMinExtent = new Point(36, 18); + button.padding = 0; + button.labelShadowOffset = new Point(-1, -1); + button.labelShadowColor = colors[1]; + button.labelColor = this.buttonLabelColor; + button.contrast = this.buttonContrast; + button.drawNew(); + // button.hint = 'stage size\nsmall & normal'; + button.fixLayout(); + button.refresh(); + stageSizeButton = button; + this.controlBar.add(stageSizeButton); + this.controlBar.stageSizeButton = button; // for refreshing + + //appModeButton + button = new ToggleButtonMorph( + null, //colors, + myself, // the IDE is the target + 'toggleAppMode', + [ + new SymbolMorph('fullScreen', 14), + new SymbolMorph('normalScreen', 14) + ], + function () { // query + return myself.isAppMode; + } + ); + + button.corner = 12; + button.color = colors[0]; + button.highlightColor = colors[1]; + button.pressColor = colors[2]; + button.labelMinExtent = new Point(36, 18); + button.padding = 0; + button.labelShadowOffset = new Point(-1, -1); + button.labelShadowColor = colors[1]; + button.labelColor = this.buttonLabelColor; + button.contrast = this.buttonContrast; + button.drawNew(); + // button.hint = 'app & edit\nmodes'; + button.fixLayout(); + button.refresh(); + appModeButton = button; + this.controlBar.add(appModeButton); + this.controlBar.appModeButton = appModeButton; // for refreshing + + // upload StitchButton + button = new PushButtonMorph( + this, + 'uploadStitches', + new SymbolMorph('arrowUp', 14) + ); + button.corner = 12; + button.color = colors[0]; + button.highlightColor = colors[1]; + button.pressColor = colors[2]; + button.labelMinExtent = new Point(36, 18); + button.padding = 0; + button.labelShadowOffset = new Point(-1, -1); + button.labelShadowColor = colors[1]; + button.labelColor = this.buttonLabelColor; + button.contrast = this.buttonContrast; + button.drawNew(); + // button.hint = 'stop\nevery-\nthing'; + button.fixLayout(); + upstitchButton = button; + this.controlBar.add(upstitchButton); + + + // stopButton + button = new PushButtonMorph( + this, + 'stopAllScripts', + new SymbolMorph('octagon', 14) + ); + button.corner = 12; + button.color = colors[0]; + button.highlightColor = colors[1]; + button.pressColor = colors[2]; + button.labelMinExtent = new Point(36, 18); + button.padding = 0; + button.labelShadowOffset = new Point(-1, -1); + button.labelShadowColor = colors[1]; + button.labelColor = new Color(200, 0, 0); + button.contrast = this.buttonContrast; + button.drawNew(); + // button.hint = 'stop\nevery-\nthing'; + button.fixLayout(); + stopButton = button; + this.controlBar.add(stopButton); + + //pauseButton + button = new ToggleButtonMorph( + null, //colors, + myself, // the IDE is the target + 'togglePauseResume', + [ + new SymbolMorph('pause', 12), + new SymbolMorph('pointRight', 14) + ], + function () { // query + return myself.isPaused(); + } + ); + + button.corner = 12; + button.color = colors[0]; + button.highlightColor = colors[1]; + button.pressColor = colors[2]; + button.labelMinExtent = new Point(36, 18); + button.padding = 0; + button.labelShadowOffset = new Point(-1, -1); + button.labelShadowColor = colors[1]; + button.labelColor = new Color(255, 220, 0); + button.contrast = this.buttonContrast; + button.drawNew(); + // button.hint = 'pause/resume\nall scripts'; + button.fixLayout(); + button.refresh(); + pauseButton = button; + this.controlBar.add(pauseButton); + this.controlBar.pauseButton = pauseButton; // for refreshing + + // startButton + button = new PushButtonMorph( + this, + 'pressStart', + new SymbolMorph('flag', 14) + ); + button.corner = 12; + button.color = colors[0]; + button.highlightColor = colors[1]; + button.pressColor = colors[2]; + button.labelMinExtent = new Point(36, 18); + button.padding = 0; + button.labelShadowOffset = new Point(-1, -1); + button.labelShadowColor = colors[1]; + button.labelColor = new Color(0, 200, 0); + button.contrast = this.buttonContrast; + button.drawNew(); + // button.hint = 'start green\nflag scripts'; + button.fixLayout(); + startButton = button; + this.controlBar.add(startButton); + this.controlBar.startButton = startButton; + + // projectButton + button = new PushButtonMorph( + this, + 'projectMenu', + new SymbolMorph('file', 14) + //'\u270E' + ); + button.corner = 12; + button.color = colors[0]; + button.highlightColor = colors[1]; + button.pressColor = colors[2]; + button.labelMinExtent = new Point(36, 18); + button.padding = 0; + button.labelShadowOffset = new Point(-1, -1); + button.labelShadowColor = colors[1]; + button.labelColor = this.buttonLabelColor; + button.contrast = this.buttonContrast; + button.drawNew(); + // button.hint = 'open, save, & annotate project'; + button.fixLayout(); + projectButton = button; + this.controlBar.add(projectButton); + this.controlBar.projectButton = projectButton; // for menu positioning + + // settingsButton + button = new PushButtonMorph( + this, + 'settingsMenu', + new SymbolMorph('gears', 14) + //'\u2699' + ); + button.corner = 12; + button.color = colors[0]; + button.highlightColor = colors[1]; + button.pressColor = colors[2]; + button.labelMinExtent = new Point(36, 18); + button.padding = 0; + button.labelShadowOffset = new Point(-1, -1); + button.labelShadowColor = colors[1]; + button.labelColor = this.buttonLabelColor; + button.contrast = this.buttonContrast; + button.drawNew(); + // button.hint = 'edit settings'; + button.fixLayout(); + settingsButton = button; + this.controlBar.add(settingsButton); + this.controlBar.settingsButton = settingsButton; // for menu positioning + + // cloudButton + button = new PushButtonMorph( + this, + 'cloudMenu', + new SymbolMorph('cloud', 11) + ); + button.corner = 12; + button.color = colors[0]; + button.highlightColor = colors[1]; + button.pressColor = colors[2]; + button.labelMinExtent = new Point(36, 18); + button.padding = 0; + button.labelShadowOffset = new Point(-1, -1); + button.labelShadowColor = colors[1]; + button.labelColor = this.buttonLabelColor; + button.contrast = this.buttonContrast; + button.drawNew(); + // button.hint = 'cloud operations'; + button.fixLayout(); + cloudButton = button; + this.controlBar.add(cloudButton); + this.controlBar.cloudButton = cloudButton; // for menu positioning + + this.controlBar.fixLayout = function () { + x = this.right() - padding; + [stopButton, pauseButton, startButton].forEach( + function (button) { + button.setCenter(myself.controlBar.center()); + button.setRight(x); + x -= button.width(); + x -= padding; + } + ); + + x = Math.min( + startButton.left() - (3 * padding + 2 * stageSizeButton.width()), + myself.right() - StageMorph.prototype.dimensions.x * + (myself.isSmallStage ? myself.stageRatio : 1) + ); + [stageSizeButton, appModeButton].forEach( + function (button) { + x += padding; + button.setCenter(myself.controlBar.center()); + button.setLeft(x); + x += button.width(); + } + ); + + + upstitchButton.setCenter(myself.controlBar.center()); + upstitchButton.setRight(stageSizeButton.left() - padding); + + settingsButton.setCenter(myself.controlBar.center()); + settingsButton.setLeft(this.left()); + + cloudButton.setCenter(myself.controlBar.center()); + cloudButton.setRight(settingsButton.left() - padding); + + projectButton.setCenter(myself.controlBar.center()); + projectButton.setRight(cloudButton.left() - padding); + + this.updateLabel(); + }; + + this.controlBar.updateLabel = function () { + var suffix = myself.world().isDevMode ? + ' - ' + localize('development mode') : ''; + + if (this.label) { + this.label.destroy(); + } + if (myself.isAppMode) { + return; + } + + this.label = new StringMorph( + (myself.projectName || localize('untitled')) + suffix, + 14, + 'sans-serif', + true, + false, + false, + MorphicPreferences.isFlat ? null : new Point(2, 1), + myself.frameColor.darker(myself.buttonContrast) + ); + this.label.color = myself.buttonLabelColor; + this.label.drawNew(); + this.add(this.label); + this.label.setCenter(this.center()); + this.label.setLeft(this.settingsButton.right() + padding); + }; +}; + + + +IDE_Morph.prototype.uploadStitches = function () { + tStitch.upload(); +}; + + + +ProjectDialogMorph.prototype.getExamplesProjectList = function () { + var dir, + projects = []; + + //dir = this.ide.getURL('http://snap.berkeley.edu/snapsource/Examples/'); + dir = this.ide.getURL(getBaseURL() + '/stitchcode/examples/'); + dir.split('\n').forEach( + function (line) { + var startIdx = line.search(new RegExp('href=".*xml"')), + endIdx, + name, + dta; + if (startIdx > 0) { + endIdx = line.search(new RegExp('.xml')); + name = line.substring(startIdx + 6, endIdx); + dta = { + name: name, + thumb: null, + notes: null + }; + projects.push(dta); + } + } + ); + projects.sort(function (x, y) { + return x.name < y.name ? -1 : 1; + }); + return projects; +}; +