mirror of
https://github.com/scratchfoundation/scratch-flash.git
synced 2024-12-04 21:21:06 -05:00
Allow wrapping C blocks in the middle of a stack
This commit is contained in:
parent
bcc3c5ea2f
commit
c3df7dcd5a
2 changed files with 41 additions and 4 deletions
|
@ -452,6 +452,13 @@ public class Block extends Sprite {
|
|||
}
|
||||
}
|
||||
|
||||
public function previewSubstack1Height(h:int):void {
|
||||
base.setSubstack1Height(h);
|
||||
base.redraw();
|
||||
fixElseLabel();
|
||||
if (nextBlock) nextBlock.y = base.nextBlockY();
|
||||
}
|
||||
|
||||
public function duplicate(forClone:Boolean, forStage:Boolean = false):Block {
|
||||
var newSpec:String = spec;
|
||||
if (forStage && op == 'whenClicked') newSpec = 'when Stage clicked';
|
||||
|
@ -625,9 +632,13 @@ public class Block extends Sprite {
|
|||
}
|
||||
|
||||
private function appendBlock(b:Block):void {
|
||||
var bottom:Block = bottomBlock();
|
||||
bottom.addChild(b);
|
||||
bottom.nextBlock = b;
|
||||
if (base.canHaveSubstack1() && !subStack1) {
|
||||
insertBlockSub1(b);
|
||||
} else {
|
||||
var bottom:Block = bottomBlock();
|
||||
bottom.addChild(b);
|
||||
bottom.nextBlock = b;
|
||||
}
|
||||
}
|
||||
|
||||
private function owningBlock():Block {
|
||||
|
|
|
@ -135,6 +135,32 @@ public class ScriptsPane extends ScrollFrameContents {
|
|||
|
||||
public function updateFeedbackFor(b:Block):void {
|
||||
nearestTarget = nearestTargetForBlockIn(b, possibleTargets);
|
||||
if (b.base.canHaveSubstack1() && !b.subStack1) {
|
||||
var o:Block = null;
|
||||
if (nearestTarget) {
|
||||
t = nearestTarget[1];
|
||||
switch (nearestTarget[2]) {
|
||||
case INSERT_NORMAL:
|
||||
o = t.nextBlock;
|
||||
break;
|
||||
case INSERT_WRAP:
|
||||
o = t;
|
||||
break;
|
||||
case INSERT_SUB1:
|
||||
o = t.subStack1;
|
||||
break;
|
||||
case INSERT_SUB2:
|
||||
o = t.subStack2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
var h:int = BlockShape.EmptySubstackH;
|
||||
if (o) {
|
||||
h = o.height;
|
||||
if (!o.bottomBlock().isTerminal) h -= BlockShape.NotchDepth;
|
||||
}
|
||||
b.previewSubstack1Height(h);
|
||||
}
|
||||
if (nearestTarget != null) {
|
||||
var localP:Point = globalToLocal(nearestTarget[0]);
|
||||
var t:* = nearestTarget[1];
|
||||
|
@ -221,7 +247,7 @@ public class ScriptsPane extends ScrollFrameContents {
|
|||
p = target.localToGlobal(new Point(-BlockShape.SubstackInset, -(b.base.substack1y() - BlockShape.NotchDepth)));
|
||||
possibleTargets.push([p, target, INSERT_WRAP]);
|
||||
}
|
||||
if (!b.isHat) findCommandTargetsIn(target, bEndWithTerminal);
|
||||
if (!b.isHat) findCommandTargetsIn(target, bEndWithTerminal && !bCanWrap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue