summaryrefslogtreecommitdiff
path: root/gui.js
diff options
context:
space:
mode:
authorjmoenig <jens@moenig.org>2013-08-09 10:20:34 +0200
committerjmoenig <jens@moenig.org>2013-08-09 10:20:34 +0200
commit8a0efbd8dae76ec8a465e1c52d01d5ae0dbf42ed (patch)
tree4955ea1d1574e5824e53ddf65b7f293c6ec1e005 /gui.js
parent99115237d5e49baa3defef656bd5fffccebf923c (diff)
downloadsnap-byow-8a0efbd8dae76ec8a465e1c52d01d5ae0dbf42ed.tar.gz
snap-byow-8a0efbd8dae76ec8a465e1c52d01d5ae0dbf42ed.zip
Nested Sprite Rotation style buttons on corral icons
Diffstat (limited to 'gui.js')
-rw-r--r--gui.js49
1 files changed, 48 insertions, 1 deletions
diff --git a/gui.js b/gui.js
index 0eb84a9..db9419b 100644
--- a/gui.js
+++ b/gui.js
@@ -68,7 +68,7 @@ sb, CommentMorph, CommandBlockMorph*/
// Global stuff ////////////////////////////////////////////////////////
-modules.gui = '2013-August-07';
+modules.gui = '2013-August-09';
// Declarations
@@ -4699,6 +4699,7 @@ SpriteIconMorph.prototype.init = function (aSprite, aTemplate) {
this.object = aSprite || new SpriteMorph(); // mandatory, actually
this.version = this.object.version;
this.thumbnail = null;
+ this.rotationButton = null; // synchronous rotation of nested sprites
// initialize inherited properties:
SpriteIconMorph.uber.init.call(
@@ -4731,6 +4732,7 @@ SpriteIconMorph.prototype.createThumbnail = function () {
this.thumbnail.setExtent(this.thumbSize);
if (this.object instanceof SpriteMorph) { // support nested sprites
this.thumbnail.image = this.object.fullThumbnail(this.thumbSize);
+ this.createRotationButton();
} else {
this.thumbnail.image = this.object.thumbnail(this.thumbSize);
}
@@ -4764,6 +4766,46 @@ SpriteIconMorph.prototype.createLabel = function () {
this.add(this.label);
};
+SpriteIconMorph.prototype.createRotationButton = function () {
+ var button, myself = this;
+
+ if (this.rotationButton) {
+ this.rotationButton.destroy();
+ this.roationButton = null;
+ }
+ if (!this.object.anchor) {
+ return;
+ }
+
+ button = new ToggleButtonMorph(
+ null, // colors,
+ null, // target
+ function () {
+ myself.object.rotatesWithAnchor =
+ !myself.object.rotatesWithAnchor;
+ },
+ [
+ '\u2192',
+ '\u21BB'
+ ],
+ function () { // query
+ return myself.object.rotatesWithAnchor;
+ }
+ );
+
+ button.corner = 8;
+ button.labelMinExtent = new Point(11, 11);
+ button.padding = 0;
+ button.pressColor = button.color;
+ button.drawNew();
+ // button.hint = 'rotate synchronously\nwith anchor';
+ button.fixLayout();
+ button.refresh();
+ button.changed();
+ this.rotationButton = button;
+ this.add(this.rotationButton);
+};
+
// SpriteIconMorph stepping
SpriteIconMorph.prototype.step = function () {
@@ -4801,6 +4843,11 @@ SpriteIconMorph.prototype.fixLayout = function () {
this.top() + this.outline + this.edge + this.padding
);
+ if (this.rotationButton) {
+ this.rotationButton.setTop(this.top());
+ this.rotationButton.setRight(this.right());
+ }
+
this.label.setWidth(
Math.min(
this.label.children[0].width(), // the actual text