'From Squeak3.2alpha of 2 October 2001 [latest update: #4411] on 3 October 2001 at 12:34:32 am'! "Change Set: haloNameEdit-sw Date: 3 October 2001 Author: Scott Wallace When various gestures are made to a halo, any name-edits currently underway in the halo now get submitted, thus fixing quite a few long-standing bugs/annoyances that could peek out under such conditions. Also fixes the bug in update 4369 which had made the collapse handle not show after the drop of a morph being dragged via the black handle.."! !Morph methodsFor: 'halos and balloon help' stamp: 'sw 10/2/2001 23:18'! 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: '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: 'initialization' stamp: 'sw 10/2/2001 21:20'! acceptNameEdit "If the name is currently under edit, accept the changes" | label | (label _ self findA: NameStringInHalo) ifNotNil: [label hasFocus ifTrue: [label lostFocusWithoutAccepting]]! ! !HaloMorph methodsFor: 'initialization' stamp: 'sw 10/2/2001 21:23'! delete "Delete the halo. Tell the target that it no longer has the halo; accept any pending edits to the name; and then either actually delete myself or start to fade out" target ifNotNil: [target hasHalo: false]. self acceptNameEdit. self isMagicHalo: false. Preferences haloTransitions ifTrue: [self stopStepping; startStepping. self startSteppingSelector: #fadeOutFinally] ifFalse: [super delete]! ! !HaloMorph methodsFor: 'private' stamp: 'sw 10/2/2001 22:06'! doDebug: evt with: menuHandle "Ask hand to invoke the a debugging menu for my inner target. If shift key is down, immediately put up an inspector on the inner target" | menu | self obtainHaloForEvent: evt andRemoveAllHandlesBut: nil. self world displayWorld. evt shiftPressed ifTrue: [self delete. ^ innerTarget inspectInMorphic: evt]. menu _ innerTarget buildDebugMenu: evt hand. menu addTitle: innerTarget externalName. menu popUpEvent: evt in: self world. ! ! !HaloMorph methodsFor: 'private' stamp: 'sw 10/2/2001 22:52'! doDup: evt with: dupHandle "Ask hand to duplicate my target." (target isKindOf: SelectionMorph) ifTrue: [^ target doDup: evt fromHalo: self handle: dupHandle]. self obtainHaloForEvent: evt andRemoveAllHandlesBut: dupHandle. self setTarget: (target duplicateMorph: evt). self step. "update position if necessary" evt hand addMouseListener: self. "Listen for the drop"! ! !HaloMorph methodsFor: 'private' stamp: 'sw 10/2/2001 22:35'! doGrab: evt with: grabHandle "Ask hand to grab my target." self obtainHaloForEvent: evt andRemoveAllHandlesBut: grabHandle. evt hand grabMorph: target. self step. "update position if necessary" evt hand addMouseListener: self. "Listen for the drop"! ! !HaloMorph methodsFor: 'private' stamp: 'sw 10/2/2001 22:24'! doMenu: evt with: menuHandle "Ask hand to invoke the halo menu for my inner target." | menu | self obtainHaloForEvent: evt andRemoveAllHandlesBut: nil. self world displayWorld. menu _ innerTarget buildHandleMenu: evt hand. innerTarget mightEntertainDirectionHandles ifTrue: [menu addLine. self showingDirectionHandles ifTrue: [menu add: 'hide direction handles' target: self selector: #showDirectionHandles: argument: false] ifFalse: [menu add: 'show direction handles' target: self selector: #showDirectionHandles: argument: true]]. innerTarget addTitleForHaloMenu: menu. menu popUpEvent: evt in: self world. ! ! !HaloMorph methodsFor: 'private' stamp: 'sw 10/3/2001 00:21'! mouseDownInCollapseHandle: evt with: collapseHandle "The mouse went down in the collapse handle; collapse the morph" self obtainHaloForEvent: evt andRemoveAllHandlesBut: collapseHandle. self setDismissColor: evt with: collapseHandle! ! !HaloMorph methodsFor: 'private' stamp: 'sw 10/2/2001 22:16'! obtainHaloForEvent: evt andRemoveAllHandlesBut: aHandle "Make sure the event's hand correlates with the receiver, and remove all handles except the given one. If nil is provided as the handles argument, the result is that all handles are removed. Note that any pending edits to the name-string in the halo are accepted at this time." evt hand obtainHalo: self. self acceptNameEdit. self removeAllHandlesBut: aHandle! ! !HaloMorph methodsFor: 'private' stamp: 'sw 10/2/2001 22:09'! startDrag: evt with: dragHandle "Drag my target without removing it from its owner." | itsOwner | self obtainHaloForEvent: evt andRemoveAllHandlesBut: dragHandle. positionOffset _ dragHandle center - (target point: target position in: owner). ((itsOwner _ target topRendererOrSelf owner) notNil and: [itsOwner automaticViewing]) ifTrue: [target openViewerForArgument]! ! !HaloMorph methodsFor: 'private' stamp: 'sw 10/2/2001 22:11'! startGrow: evt with: growHandle "Initialize resizing of my target. Launch a command representing it, to support Undo" | botRt | self obtainHaloForEvent: evt andRemoveAllHandlesBut: growHandle. botRt _ target point: target bottomRight in: owner. (self world viewBox containsPoint: botRt) ifTrue: [positionOffset _ evt cursorPoint - botRt] ifFalse: [positionOffset _ 0@0]. self setProperty: #commandInProgress toValue: (Command new cmdWording: 'resizing'; undoTarget: target selector: #setExtentFromHalo: argument: target extent)! ! !HaloMorph methodsFor: 'private' stamp: 'sw 10/2/2001 22:09'! startRot: evt with: rotHandle "Initialize rotation of my target if it is rotatable. Launch a command object to represent the action" self obtainHaloForEvent: evt andRemoveAllHandlesBut: rotHandle. target isFlexMorph ifFalse: [target isInWorld ifFalse: [self setTarget: target player costume]. target addFlexShell]. growingOrRotating _ true. self removeAllHandlesBut: rotHandle. "remove all other handles" angleOffset _ evt cursorPoint - (target pointInWorld: target referencePosition). angleOffset _ Point r: angleOffset r degrees: angleOffset degrees - target rotationDegrees. self setProperty: #commandInProgress toValue: (Command new cmdWording: 'rotating'; undoTarget: target selector: #rotationDegrees: argument: target rotationDegrees) ! ! !HaloMorph methodsFor: 'private' stamp: 'sw 10/2/2001 22:16'! startScale: evt with: scaleHandle "Initialize scaling of my target." self obtainHaloForEvent: evt andRemoveAllHandlesBut: scaleHandle. target isFlexMorph ifFalse: [target addFlexShell]. growingOrRotating _ true. positionOffset _ 0@0 ! ! !HaloMorph methodsFor: 'handles' stamp: 'sw 10/3/2001 00:21'! addCollapseHandle: handleSpec "Add the collapse handle, with all of its event handlers set up, unless the target's owner is not the world or the hand." | collapseHandle | (target owner isWorldOrHandMorph) ifFalse: [^ self]. collapseHandle _ self addHandle: handleSpec on: #mouseDown send: #mouseDownInCollapseHandle:with: to: self. collapseHandle on: #mouseUp send: #maybeCollapse:with: to: self. collapseHandle on: #mouseMove send: #setDismissColor:with: to: self ! ! !HaloMorph methodsFor: 'handles' stamp: 'sw 10/2/2001 22:17'! addTileHandle: haloSpec "Add the 'tear-off-tile' handle from the spec" self addHandle: haloSpec on: #mouseDown send: #tearOffTileForTarget:with: to: self ! ! !HaloMorph methodsFor: 'handles' stamp: 'sw 10/2/2001 22:17'! addViewHandle: haloSpec "Add the 'open viewer' handle from the halo spec" self addHandle: haloSpec on: #mouseDown send: #openViewerForTarget:with: to: self ! ! !HaloMorph methodsFor: 'handles' stamp: 'sw 10/2/2001 22:18'! openViewerForTarget: evt with: aHandle "Open a viewer for my inner target" self obtainHaloForEvent: evt andRemoveAllHandlesBut: nil. innerTarget openViewerForArgument! ! !HaloMorph methodsFor: 'handles' stamp: 'sw 10/2/2001 22:19'! tearOffTileForTarget: evt with: aHandle "Tear off a tile representing my inner target" self obtainHaloForEvent: evt andRemoveAllHandlesBut: nil. innerTarget tearOffTile! !