'From etoys2.2 of 1 October 2007 [latest update: #1773] on 13 November 2007 at 3:32:36 pm'! "Change Set: balloonHelpLocation-yo Date: 13 November 2007 Author: Yoshiki Ohshima Now you can force the direction of balloon help to particular direction."! !BalloonMorph class methodsFor: 'instance creation' stamp: 'yo 11/13/2007 15:03'! string: str for: morph corner: cornerName ^ self string: str for: morph corner: cornerName force: false. ! ! !BalloonMorph class methodsFor: 'instance creation' stamp: 'yo 11/13/2007 14:44'! string: str for: morph corner: cornerName force: forceFlag "Make up and return a balloon for morph. Find the quadrant that clips the text the least, using cornerName as a tie-breaker. tk 9/12/97" | tm vertices | tm _ self getTextMorph: str for: morph. vertices _ self getVertices: tm bounds. vertices _ self getBestLocation: vertices for: morph corner: cornerName force: forceFlag. ^ self new color: morph balloonColor; setVertices: vertices; addMorph: tm; setTarget: morph! ! !BalloonMorph class methodsFor: 'private' stamp: 'yo 11/13/2007 15:01'! getBestLocation: vertices for: morph corner: cornerName ^ self getBestLocation: vertices for: morph corner: cornerName force: false. ! ! !BalloonMorph class methodsFor: 'private' stamp: 'yo 11/13/2007 15:25'! getBestLocation: vertices for: morph corner: cornerName force: forceFlag "Try four rel locations of the balloon for greatest unclipped area. 12/99 sma" | rect maxArea verts rectCorner morphPoint mbc a mp dir bestVerts result usableArea | rect _ vertices first rect: (vertices at: 5). maxArea _ -1. verts _ vertices. usableArea _ (morph world ifNil: [self currentWorld]) viewBox. 1 to: 4 do: [:i | dir _ #(vertical horizontal) atWrap: i. verts _ verts collect: [:p | p flipBy: dir centerAt: rect center]. rectCorner _ #(bottomLeft bottomRight topRight topLeft) at: i. morphPoint _ #(topCenter topCenter bottomCenter bottomCenter) at: i. a _ ((rect align: (rect perform: rectCorner) with: (mbc _ morph boundsForBalloon perform: morphPoint)) intersect: usableArea) area. ((forceFlag and: [rectCorner = cornerName]) or: [ (a > maxArea or: [a = rect area and: [rectCorner = cornerName]])]) ifTrue: [maxArea _ a. bestVerts _ verts. mp _ mbc]. (forceFlag and: [rectCorner = cornerName]) ifTrue: [ ^ bestVerts collect: [:p | p + (mp - bestVerts first)] "Inlined align:with:". ]]. result _ bestVerts collect: [:p | p + (mp - bestVerts first)] "Inlined align:with:". ^ result! ! !SugarNavigatorBar methodsFor: 'initialization' stamp: 'yo 11/13/2007 15:25'! putUpInitialBalloonHelp " SugarNavigatorBar putUpInitialBalloonHelp " | paintButton suppliesButton b1 b2 p b | paintButton _ undoButton owner submorphs detect: [:e | e isButton and: [e actionSelector = #doNewPainting]]. suppliesButton _ undoButton owner submorphs detect: [:e | e isButton and: [e actionSelector = #toggleSupplies]]. b1 _ BalloonMorph string: self paintButtonInitialExplanation for: paintButton corner: #topRight force: false. b2 _ BalloonMorph string: self suppliesButtonInitialExplanation for: suppliesButton corner: #topLeft force: true. p _ PasteUpMorph new. p clipSubmorphs: false. p color: Color transparent. p borderWidth: 0. p addMorph: b1. p addMorph: b2. b _ BalloonMorph string: p for: World corner: #bottomLeft. b color: Color transparent. b borderWidth: 0. [(Delay forSeconds: 1) wait. b popUpForHand: ActiveHand] fork. ! !