'From Squeak3.2alpha of 2 October 2001 [latest update: #4425] on 8 October 2001 at 2:37:39 pm'! "Change Set: CenterOfRotation-ar Date: 8 October 2001 Author: Andreas Raab Make accidental modification of the center of rotation handle harder. The mechanims treats a normal click on the center of rotation as equivalent to the brown halo handle. To change the center of rotation for real, a SHIFT-click is required."! !Morph methodsFor: 'halos and balloon help' stamp: 'ar 10/8/2001 14:26'! balloonHelpTextForHandle: aHandle "Answer a string providing balloon help for the given halo handle" | itsSelector | itsSelector _ aHandle eventHandler firstMouseSelector. #( (addFullHandles 'More halo handles') (addSimpleHandles 'Fewer halo handles') (chooseEmphasisOrAlignment 'Emphasis & alignment') (chooseFont 'Change font') (chooseNewGraphicFromHalo 'Choose a new graphic') (chooseStyle 'Change style') (dismiss 'Remove') (doDebug:with: 'Debug') (doDirection:with: 'Choose forward direction') (doDup:with: 'Duplicate') (doMenu:with: 'Menu') (doGrab:with: 'Pick up') (doRecolor:with: 'Change color') (editButtonsScript 'See the script for this button') (editDrawing 'Repaint') (maybeDoDup:with: 'Duplicate') (makeNascentScript 'Make a scratch script') (makeNewDrawingWithin 'Paint new object') (mouseDownInCollapseHandle:with: 'Collapse') (mouseDownOnHelpHandle: 'Help') (openViewerForArgument 'Open a Viewer for me') (openViewerForTarget:with: 'Open a Viewer for me') (paintBackground 'Paint background') (prepareToTrackCenterOfRotation:with: 'Move object or set center of rotation') (presentViewMenu 'Present the Viewing menu') (startDrag:with: 'Move') (startGrow:with: 'Change size') (startRot:with: 'Rotate') (startScale:with: 'Change scale') (tearOffTile 'Make a tile representing this object') (tearOffTileForTarget:with: 'Make a tile representing this object') (trackCenterOfRotation:with: 'Set center of rotation')) do: [:pair | itsSelector == pair first ifTrue: [^ pair last]]. (itsSelector == #mouseDownInDimissHandle:with:) ifTrue: [^ Preferences preserveTrash ifTrue: ['Move to trash'] ifFalse: ['Remove from screen']]. ^ 'unknown halo handle'! ! !HaloMorph methodsFor: 'private' stamp: 'ar 10/8/2001 14:34'! addDirectionHandles | centerHandle d w directionShaft patch patchColor crossHairColor | self showingDirectionHandles ifFalse: [^ self]. directionArrowAnchor _ (target point: target referencePosition in: self world) rounded. patch _ target imageFormForRectangle: (Rectangle center: directionArrowAnchor extent: 3@3). patchColor _ patch colorAt: 1@1. (directionShaft _ LineMorph newSticky makeForwardArrow) borderWidth: 2; borderColor: (Color green orColorUnlike: patchColor). self positionDirectionShaft: directionShaft. self addMorphFront: directionShaft. directionShaft setCenteredBalloonText: 'Set forward direction'; on: #mouseDown send: #doDirection:with: to: self; on: #mouseMove send: #trackDirectionArrow:with: to: self; on: #mouseUp send: #setDirection:with: to: self. d _ 15. "diameter" w _ 3. "borderWidth" crossHairColor _ Color red orColorUnlike: patchColor. (centerHandle _ EllipseMorph newBounds: (0@0 extent: d@d) color: Color transparent) borderWidth: w; borderColor: (Color blue orColorUnlike: patchColor); addMorph: (LineMorph from: (d//2)@w to: (d//2)@(d-w-1) color: crossHairColor width: 1) lock; addMorph: (LineMorph from: w@(d//2) to: (d-w-1)@(d//2) color: crossHairColor width: 1) lock; align: centerHandle bounds center with: directionArrowAnchor. self addMorph: centerHandle. centerHandle setCenteredBalloonText: 'Set rotation center'; on: #mouseDown send: #prepareToTrackCenterOfRotation:with: to: self; on: #mouseMove send: #trackCenterOfRotation:with: to: self; on: #mouseUp send: #setCenterOfRotation:with: to: self ! ! !HaloMorph methodsFor: 'private' stamp: 'ar 10/8/2001 14:35'! prepareToTrackCenterOfRotation: evt with: rotationHandle evt hand obtainHalo: self. evt shiftPressed ifTrue:[ self removeAllHandlesBut: rotationHandle. ] ifFalse:[ rotationHandle setProperty: #dragByCenterOfRotation toValue: true. self startDrag: evt with: rotationHandle ]. evt hand showTemporaryCursor: Cursor blank! ! !HaloMorph methodsFor: 'private' stamp: 'ar 10/8/2001 14:33'! setCenterOfRotation: evt with: rotationHandle | localPt | evt hand obtainHalo: self. evt hand showTemporaryCursor: nil. (rotationHandle hasProperty: #dragByCenterOfRotation) ifFalse:[ localPt _ innerTarget transformFromWorld globalPointToLocal: rotationHandle center. innerTarget setRotationCenterFrom: localPt. ]. rotationHandle removeProperty: #dragByCenterOfRotation. self endInteraction ! ! !HaloMorph methodsFor: 'private' stamp: 'ar 10/8/2001 14:32'! trackCenterOfRotation: anEvent with: rotationHandle (rotationHandle hasProperty: #dragByCenterOfRotation) ifTrue:[^self doDrag: anEvent with: rotationHandle]. anEvent hand obtainHalo: self. rotationHandle center: anEvent cursorPoint.! !