'From etoys3.0 of 24 February 2008 [latest update: #2100] on 28 August 2008 at 2:53:12 pm'! "Change Set: rotationHandlesAgain-sw Date: 28 August 2008 Author: Scott Wallace Put up balloon help rather than an informer when user tries to operate direction or rotation-center handle without shift key down. Restore requirement that shift key be down to operate direction arrow. A surprising number of things were wrong with the previous implementation..."! !HaloMorph methodsFor: 'private' stamp: 'sw 8/21/2008 22:20'! addDirectionHandles "If appropriate, add center-of-rotation and forward-direction handles to the halo." | 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: 'Forward direction (hold down shift key and drag to change it)' translated; on: #mouseDown send: #doDirection:with: to: self; on: #mouseMove send: #trackDirectionArrow:with: to: self; on: #mouseUp send: #setDirection:with: to: self. directionShaft setProperty: #activateOnShift toValue: true. 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: 'Rotation center (hold down the shift key and drag to change it)' translated; 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: 'sw 8/27/2008 13:51'! doDirection: anEvent with: directionHandle "The mouse went down on the forward-direction halo handle; respond appropriately." anEvent hand obtainHalo: self. anEvent shiftPressed ifTrue: [directionArrowAnchor _ (target point: target referencePosition in: self world) rounded. self positionDirectionShaft: directionHandle. self removeAllHandlesBut: directionHandle. directionHandle setProperty: #trackDirectionArrow toValue: true] ifFalse: [ActiveHand spawnBalloonFor: directionHandle]! ! !HaloMorph methodsFor: 'private' stamp: 'sw 8/27/2008 02:17'! prepareToTrackCenterOfRotation: evt with: rotationHandle "The mouse went down on the center of rotation." evt hand obtainHalo: self. evt shiftPressed ifTrue: [self removeAllHandlesBut: rotationHandle. rotationHandle setProperty: #trackCenterOfRotation toValue: true. evt hand showTemporaryCursor: Cursor blank] ifFalse: [ActiveHand spawnBalloonFor: rotationHandle]! ! !HaloMorph methodsFor: 'private' stamp: 'sw 8/27/2008 02:24'! setCenterOfRotation: evt with: rotationHandle | localPt | evt hand obtainHalo: self. evt hand showTemporaryCursor: nil. (rotationHandle hasProperty: #trackCenterOfRotation) ifTrue: [localPt := innerTarget transformFromWorld globalPointToLocal: rotationHandle center. innerTarget setRotationCenterFrom: localPt]. rotationHandle removeProperty: #trackCenterOfRotation. self endInteraction! ! !HaloMorph methodsFor: 'private' stamp: 'sw 8/27/2008 13:31'! setDirection: anEvent with: directionHandle "The user has let up after having dragged the direction arrow; now set the forward direction of the actual SketchMorph accordingly" (directionHandle hasProperty: #trackDirectionArrow) ifTrue: [anEvent hand obtainHalo: self. target setDirectionFrom: directionHandle center. directionHandle removeProperty: #trackDirectionArrow. self endInteraction]! ! !HaloMorph methodsFor: 'private' stamp: 'sw 8/27/2008 02:16'! trackCenterOfRotation: anEvent with: rotationHandle (rotationHandle hasProperty: #dragByCenterOfRotation) ifTrue:[^self doDrag: anEvent with: rotationHandle]. (rotationHandle hasProperty: #trackCenterOfRotation) ifTrue: [anEvent hand obtainHalo: self. rotationHandle center: anEvent cursorPoint]! ! !HaloMorph methodsFor: 'private' stamp: 'sw 8/27/2008 13:29'! trackDirectionArrow: anEvent with: shaft (shaft hasProperty: #trackDirectionArrow) ifTrue: [anEvent hand obtainHalo: self. shaft setVertices: {directionArrowAnchor. anEvent cursorPoint}. self layoutChanged]! !