'From etoys2.1 of 6 September 2007 [latest update: #1589] on 6 September 2007 at 10:43:56 am'! "Change Set: Repaint-size-tk Date: 6 September 2007 Author: Ted Kaehler Bug from Kathleen Harness: If a SketchMorph is shrunk down to a small size, and you repaint, the original form can be cut off by the painting area. Also, when done painting, the player moves to the top left of the painting area. Fixed by using the correct rectangles."! !SketchEditorMorph methodsFor: 'initialization' stamp: 'tk 9/6/2007 10:38'! initializeFor: aSketchMorph inBounds: boundsToUse pasteUpMorph: aPasteUpMorph paintBoxPosition: aPosition "NB: if aPosition is nil, then it's assumed that the paintbox is obtained from a flap or some such, so do nothing special regarding a palette in this case. The palette needs already to be in the world for this to work." | w | (w _ aPasteUpMorph world) addMorphInLayer: self. "in back of palette" enclosingPasteUpMorph _ aPasteUpMorph. hostView _ aSketchMorph. "may be ownerless" self bounds: boundsToUse. palette _ w paintBox focusMorph: self. palette beStatic. "give Nebraska whatever help we can" palette fixupButtons. palette addWeakDependent: self. aPosition ifNotNil: [w addMorphFront: palette. "bring to front" palette position: aPosition]. paintingForm _ Form extent: bounds extent depth: w assuredCanvas depth. self dimTheWindow. self addRotationScaleHandles. aSketchMorph ifNotNil: [aSketchMorph form displayOn: paintingForm at: (paintingForm extent - aSketchMorph form extent // 2) clippingBox: (0@0 extent: paintingForm extent) rule: Form over fillColor: nil. "assume they are the same depth". undoBuffer _ paintingForm deepCopy. rotationCenter _ aSketchMorph rotationCenter]! ! !SketchMorph methodsFor: 'menu' stamp: 'tk 9/5/2007 17:54'! editDrawingIn: aPasteUpMorph forBackground: forBackground "Edit an existing sketch." | w bnds sketchEditor pal aPaintTab aWorld aPaintBox tfx rotCenter aCenter | self world assureNotPaintingElse: [^self]. aCenter := self center. w := aPasteUpMorph world. w prepareToPaint. w displayWorld. self visible: false. ActiveHand eventRecorders do: [:er | er rememberPaintBoxSettingsAtRecordingOutset]. bnds := forBackground ifTrue: [aPasteUpMorph boundsInWorld] ifFalse: [bnds := self boundsInWorld expandBy: 60 @ 60. (aPasteUpMorph paintingBoundsAround: bnds center) merge: bnds]. sketchEditor := SketchEditorMorph new. forBackground ifTrue: [sketchEditor setProperty: #background toValue: true]. w addMorphFront: sketchEditor. sketchEditor initializeFor: self inBounds: bnds pasteUpMorph: aPasteUpMorph. rotCenter _ self rotationCenter. sketchEditor afterNewPicDo: [:aForm :aRect | self visible: true. self form: aForm. tfx := aPasteUpMorph transformFrom: aPasteUpMorph world. self topRendererOrSelf center: (tfx globalPointToLocal: aCenter). self rotationStyle: sketchEditor rotationStyle. self forwardDirection: sketchEditor forwardDirection. (rotCenter notNil and: [(rotCenter = (0.5 @ 0.5)) not]) ifTrue: [self rotationCenter: rotCenter]. (aPaintTab := (aWorld := self world) paintingFlapTab) ifNotNil: [aPaintTab hideFlap] ifNil: [(aPaintBox := aWorld paintBox) ifNotNil: [aPaintBox delete]]. self presenter drawingJustCompleted: self. forBackground ifTrue: [self goBehind "shouldn't be necessary"]] ifNoBits: ["If no bits drawn. Must keep old pic. Can't have no picture" self visible: true. aWorld := self currentWorld. "sometimes by now I'm no longer in a world myself, but we still need to get ahold of the world so that we can deal with the palette" ((pal := aPasteUpMorph standardPalette) notNil and: [pal isInWorld]) ifTrue: [(aPaintBox := aWorld paintBox) ifNotNil: [aPaintBox delete]. pal viewMorph: self] ifFalse: [(aPaintTab := (aWorld := self world) paintingFlapTab) ifNotNil: [aPaintTab hideFlap] ifNil: [(aPaintBox := aWorld paintBox) ifNotNil: [aPaintBox delete]]]]! !