'From etoys2.2 of 21 September 2007 [latest update: #1753] on 5 November 2007 at 12:59:45 pm'! "Change Set: Paint-place-tk Date: 5 November 2007 Author: Ted Kaehler Fix silly error that made repaint come up in the wrong place on the screen."! !SketchEditorMorph methodsFor: 'start & finish' stamp: 'tk 11/5/2007 12:52'! findBounds: sketch in: aPasteUpMorph forBackground: forBackground "Return the final painting area (onion skin) where the user will paint. Compute the new location of the referencePoint (used to comput rotationCenter) as an offset in the paint area. Ugly but necessary." | margin refPtOffset bnds screen delta delta2 | "Always keep old sketch in center of paint area -- that is what onion skin blt will do" refPtOffset := "0@0 +" (sketch form extent * sketch rotationCenter). bnds := 0@0 corner: sketch form extent. bnds := bnds align: refPtOffset with: sketch referencePositionInWorld. "offset is relative inside bnds" screen := aPasteUpMorph world bounds. bnds extent > screen extent ifTrue: ["expanded sketch is bigger than world" refPtOffset := refPtOffset - (bnds extent - screen extent //2). "must keep at the right place in rectangle" bnds := screen] ifFalse: ["move so not off screen" delta := bnds amountToTranslateWithin: screen. bnds := bnds translateBy: delta]. "refPtOffset stays the same -- relative" "give it extra margin if any space left" delta2 := bnds extent - screen extent //2. (forBackground not and: [delta2 < (0@0)]) ifTrue: [ margin := (60@60) max: ((aPasteUpMorph reasonablePaintingExtent - bnds extent) // 2). margin := margin min: delta2 negated. bnds := bnds expandBy: margin. refPtOffset := refPtOffset + margin. delta := bnds amountToTranslateWithin: screen. bnds := bnds translateBy: delta]. "refPtOffset stays the same -- relative" self setProperty: #refPtOffset toValue: refPtOffset. ^ bnds! !