fixes and enhancements for nested sprites

when dragging an anchor, also drag its parts.
let users adjust parts’ positions via the context menu “move” option
pull/3/merge
Jens Mönig 2015-07-26 23:01:08 +02:00
rodzic f829635106
commit 60554d0059
1 zmienionych plików z 27 dodań i 3 usunięć

Wyświetl plik

@ -125,7 +125,7 @@ PrototypeHatBlockMorph*/
// Global stuff ////////////////////////////////////////////////////////
modules.objects = '2015-June-25';
modules.objects = '2015-July-26';
var SpriteMorph;
var StageMorph;
@ -2658,7 +2658,7 @@ SpriteMorph.prototype.userMenu = function () {
}
menu.addItem("duplicate", 'duplicate');
menu.addItem("delete", 'remove');
menu.addItem("move", 'move');
menu.addItem("move", 'moveCenter');
if (!this.isClone) {
menu.addItem("edit", 'edit');
}
@ -3176,12 +3176,20 @@ SpriteMorph.prototype.positionTalkBubble = function () {
SpriteMorph.prototype.prepareToBeGrabbed = function (hand) {
this.removeShadow();
this.recordLayers();
if (!this.bounds.containsPoint(hand.position())) {
if (!this.bounds.containsPoint(hand.position()) &&
this.isCorrectingOutsideDrag()) {
this.setCenter(hand.position());
}
this.addShadow();
};
SpriteMorph.prototype.isCorrectingOutsideDrag = function () {
// make sure I don't "trail behind" the hand when dragged
// override for morphs that you want to be dragged outside
// their full bounds
return !this.parts.length;
};
SpriteMorph.prototype.justDropped = function () {
this.restoreLayers();
this.positionTalkBubble();
@ -3240,6 +3248,22 @@ SpriteMorph.prototype.moveBy = function (delta, justMe) {
}
};
SpriteMorph.prototype.silentMoveBy = function (delta, justMe) {
SpriteMorph.uber.silentMoveBy.call(this, delta);
if (!justMe && this.parent instanceof HandMorph) {
this.parts.forEach(function (part) {
part.moveBy(delta);
});
}
};
SpriteMorph.prototype.rootForGrab = function () {
if (this.anchor) {
return this.anchor.rootForGrab();
}
return SpriteMorph.uber.rootForGrab.call(this);
};
SpriteMorph.prototype.slideBackTo = function (situation, inSteps) {
// override the inherited default to make sure my parts follow
var steps = inSteps || 5,